Continued with coding convention:

- added curly braces around conditional code blocks
- added space between if/foreach/... and brace
- rewrote a code block so if dbm::is_result() fails it will abort, else the id
  is fetched from INSERT statement
- made some SQL keywords upper-cased and added back-ticks to columns/table names

Signed-off-by: Roland Haeder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2016-12-20 21:15:53 +01:00
parent af2909bf8f
commit 6e44acfed6
No known key found for this signature in database
GPG Key ID: B72F8185C6C7BD78
31 changed files with 173 additions and 127 deletions

View File

@ -129,10 +129,12 @@ function contacts_batch_actions(App &$a){
info ( sprintf( tt("%d contact edited.", "%d contacts edited.", $count_actions), $count_actions) ); info ( sprintf( tt("%d contact edited.", "%d contacts edited.", $count_actions), $count_actions) );
} }
if(x($_SESSION,'return_url')) if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']); goaway('' . $_SESSION['return_url']);
else }
else {
goaway('contacts'); goaway('contacts');
}
} }
@ -450,18 +452,22 @@ function contacts_content(App &$a) {
} }
// Now check how the user responded to the confirmation query // Now check how the user responded to the confirmation query
if ($_REQUEST['canceled']) { if ($_REQUEST['canceled']) {
if(x($_SESSION,'return_url')) if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']); goaway('' . $_SESSION['return_url']);
else }
else {
goaway('contacts'); goaway('contacts');
} }
}
_contact_drop($contact_id, $orig_record[0]); _contact_drop($contact_id, $orig_record[0]);
info( t('Contact has been removed.') . EOL ); info( t('Contact has been removed.') . EOL );
if(x($_SESSION,'return_url')) if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']); goaway('' . $_SESSION['return_url']);
else }
else {
goaway('contacts'); goaway('contacts');
}
return; // NOTREACHED return; // NOTREACHED
} }
if ($cmd === 'posts') { if ($cmd === 'posts') {

View File

@ -92,10 +92,12 @@ function directory_content(App &$a) {
WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit); WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit);
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
if(in_array('small', $a->argv)) if (in_array('small', $a->argv)) {
$photo = 'thumb'; $photo = 'thumb';
else }
else {
$photo = 'photo'; $photo = 'photo';
}
foreach ($r as $rr) { foreach ($r as $rr) {

View File

@ -10,18 +10,21 @@ function filerm_content(App &$a) {
$cat = unxmlify(trim($_GET['cat'])); $cat = unxmlify(trim($_GET['cat']));
$category = (($cat) ? true : false); $category = (($cat) ? true : false);
if($category) if ($category) {
$term = $cat; $term = $cat;
}
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
logger('filerm: tag ' . $term . ' item ' . $item_id); logger('filerm: tag ' . $term . ' item ' . $item_id);
if($item_id && strlen($term)) if ($item_id && strlen($term)) {
file_tag_unsave_file(local_user(),$item_id,$term, $category); file_tag_unsave_file(local_user(),$item_id,$term, $category);
}
if(x($_SESSION,'return_url')) if (x($_SESSION,'return_url')) {
goaway(App::get_baseurl() . '/' . $_SESSION['return_url']); goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
}
killme(); killme();
} }

View File

@ -157,8 +157,9 @@ function follow_post(App &$a) {
// NOTREACHED // NOTREACHED
} }
if ($_REQUEST['cancel']) if ($_REQUEST['cancel']) {
goaway($_SESSION['return_url']); goaway($_SESSION['return_url']);
}
$uid = local_user(); $uid = local_user();
$url = notags(trim($_REQUEST['url'])); $url = notags(trim($_REQUEST['url']));
@ -171,16 +172,20 @@ function follow_post(App &$a) {
$result = new_contact($uid,$url,true); $result = new_contact($uid,$url,true);
if ($result['success'] == false) { if ($result['success'] == false) {
if($result['message']) if ($result['message']) {
notice($result['message']); notice($result['message']);
}
goaway($return_url); goaway($return_url);
} elseif ($result['cid']) }
elseif ($result['cid']) {
goaway(App::get_baseurl().'/contacts/'.$result['cid']); goaway(App::get_baseurl().'/contacts/'.$result['cid']);
}
info( t('Contact added').EOL); info( t('Contact added').EOL);
if(strstr($return_url,'contacts')) if (strstr($return_url,'contacts')) {
goaway(App::get_baseurl().'/contacts/'.$contact_id); goaway(App::get_baseurl().'/contacts/'.$contact_id);
}
goaway($return_url); goaway($return_url);
// NOTREACHED // NOTREACHED

View File

@ -4,8 +4,9 @@ function hcard_init(App &$a) {
$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false); $blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
if($a->argc > 1) if ($a->argc > 1) {
$which = $a->argv[1]; $which = $a->argv[1];
}
else { else {
notice( t('No profile') . EOL ); notice( t('No profile') . EOL );
$a->error = 404; $a->error = 404;
@ -23,8 +24,9 @@ function hcard_init(App &$a) {
if ((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) { if ((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) {
$a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />'; $a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
} }
if(x($a->profile,'openidserver')) if (x($a->profile,'openidserver')) {
$a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n"; $a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
}
if (x($a->profile,'openid')) { if (x($a->profile,'openid')) {
$delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']); $delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
$a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n"; $a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
@ -33,9 +35,10 @@ function hcard_init(App &$a) {
if (! $blocked) { if (! $blocked) {
$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : ''); $keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
$keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords); $keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords);
if(strlen($keywords)) if (strlen($keywords)) {
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ; $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
} }
}
$a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ; $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . App::get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ; $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . App::get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;

View File

@ -523,16 +523,19 @@ function check_htaccess(&$checks) {
if (function_exists('curl_init')) { if (function_exists('curl_init')) {
$test = fetch_url(App::get_baseurl()."/install/testrewrite"); $test = fetch_url(App::get_baseurl()."/install/testrewrite");
if ($test!="ok") if ($test!="ok") {
$test = fetch_url(normalise_link(App::get_baseurl()."/install/testrewrite")); $test = fetch_url(normalise_link(App::get_baseurl()."/install/testrewrite"));
}
if ($test!="ok") { if ($test!="ok") {
$status = false; $status = false;
$help = t('Url rewrite in .htaccess is not working. Check your server configuration.'); $help = t('Url rewrite in .htaccess is not working. Check your server configuration.');
} }
check_add($checks, t('Url rewrite is working'), $status, true, $help); check_add($checks, t('Url rewrite is working'), $status, true, $help);
} else { }
else {
// cannot check modrewrite if libcurl is not installed // cannot check modrewrite if libcurl is not installed
/// @TODO Maybe issue warning here?
} }
} }

View File

@ -116,12 +116,14 @@ function invite_content(App &$a) {
$dirloc = get_config('system','directory'); $dirloc = get_config('system','directory');
if(strlen($dirloc)) { if(strlen($dirloc)) {
if($a->config['register_policy'] == REGISTER_CLOSED) if ($a->config['register_policy'] == REGISTER_CLOSED) {
$linktxt = sprintf( t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.'), $dirloc . '/siteinfo'); $linktxt = sprintf( t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.'), $dirloc . '/siteinfo');
elseif($a->config['register_policy'] != REGISTER_CLOSED) }
elseif($a->config['register_policy'] != REGISTER_CLOSED) {
$linktxt = sprintf( t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), App::get_baseurl()) $linktxt = sprintf( t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), App::get_baseurl())
. "\r\n" . "\r\n" . sprintf( t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.'),$dirloc . '/siteinfo'); . "\r\n" . "\r\n" . sprintf( t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.'),$dirloc . '/siteinfo');
} }
}
else { else {
$o = t('Our apologies. This system is not currently configured to connect with other public sites or invite members.'); $o = t('Our apologies. This system is not currently configured to connect with other public sites or invite members.');
return $o; return $o;

View File

@ -64,9 +64,10 @@ function item_post(App &$a) {
logger("item post: duplicate post", LOGGER_DEBUG); logger("item post: duplicate post", LOGGER_DEBUG);
item_post_return(App::get_baseurl(), $api_source, $return_path); item_post_return(App::get_baseurl(), $api_source, $return_path);
} }
else else {
$_SESSION['post-random'] = $_REQUEST['post_id_random']; $_SESSION['post-random'] = $_REQUEST['post_id_random'];
} }
}
/** /**
* Is this a reply to something? * Is this a reply to something?
@ -86,14 +87,16 @@ function item_post(App &$a) {
$objecttype = ACTIVITY_OBJ_COMMENT; $objecttype = ACTIVITY_OBJ_COMMENT;
if(! x($_REQUEST,'type')) if (! x($_REQUEST,'type')) {
$_REQUEST['type'] = 'net-comment'; $_REQUEST['type'] = 'net-comment';
}
if ($parent) { if ($parent) {
$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
intval($parent) intval($parent)
); );
} elseif($parent_uri && local_user()) { }
elseif ($parent_uri && local_user()) {
// This is coming from an API source, and we are logged in // This is coming from an API source, and we are logged in
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($parent_uri), dbesc($parent_uri),
@ -114,8 +117,9 @@ function item_post(App &$a) {
if (! dbm::is_result($r)) { if (! dbm::is_result($r)) {
notice( t('Unable to locate original post.') . EOL); notice( t('Unable to locate original post.') . EOL);
if(x($_REQUEST,'return')) if (x($_REQUEST,'return')) {
goaway($return_path); goaway($return_path);
}
killme(); killme();
} }
$parent_item = $r[0]; $parent_item = $r[0];
@ -450,12 +454,14 @@ function item_post(App &$a) {
$objecttype = ACTIVITY_OBJ_IMAGE; $objecttype = ACTIVITY_OBJ_IMAGE;
foreach ($images as $image) { foreach ($images as $image) {
if(! stristr($image,App::get_baseurl() . '/photo/')) if (! stristr($image,App::get_baseurl() . '/photo/')) {
continue; continue;
}
$image_uri = substr($image,strrpos($image,'/') + 1); $image_uri = substr($image,strrpos($image,'/') + 1);
$image_uri = substr($image_uri,0, strpos($image_uri,'-')); $image_uri = substr($image_uri,0, strpos($image_uri,'-'));
if(! strlen($image_uri)) if (! strlen($image_uri)) {
continue; continue;
}
$srch = '<' . intval($contact_id) . '>'; $srch = '<' . intval($contact_id) . '>';
$r = q("SELECT `id` FROM `photo` WHERE `allow_cid` = '%s' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' $r = q("SELECT `id` FROM `photo` WHERE `allow_cid` = '%s' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = ''

View File

@ -44,8 +44,9 @@ function noscrape_init(App &$a) {
if (is_array($a->profile) AND !$a->profile['hide-friends']) { if (is_array($a->profile) AND !$a->profile['hide-friends']) {
$r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1", $r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
intval($a->profile['uid'])); intval($a->profile['uid']));
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$json_info["updated"] = date("c", strtotime($r[0]['updated'])); $json_info["updated"] = date("c", strtotime($r[0]['updated']));
}
$r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 AND `archive` = 0 $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 AND `archive` = 0
AND `network` IN ('%s', '%s', '%s', '')", AND `network` IN ('%s', '%s', '%s', '')",
@ -54,9 +55,10 @@ function noscrape_init(App &$a) {
dbesc(NETWORK_DIASPORA), dbesc(NETWORK_DIASPORA),
dbesc(NETWORK_OSTATUS) dbesc(NETWORK_OSTATUS)
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$json_info["contacts"] = intval($r[0]['total']); $json_info["contacts"] = intval($r[0]['total']);
} }
}
//These are optional fields. //These are optional fields.
$profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital', 'about'); $profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital', 'about');

View File

@ -66,29 +66,39 @@ function openid_content(App &$a) {
$attr = $openid->getAttributes(); $attr = $openid->getAttributes();
if (is_array($attr) && count($attr)) { if (is_array($attr) && count($attr)) {
foreach ($attr as $k => $v) { foreach ($attr as $k => $v) {
if($k === 'namePerson/friendly') if ($k === 'namePerson/friendly') {
$nick = notags(trim($v)); $nick = notags(trim($v));
if($k === 'namePerson/first') }
if($k === 'namePerson/first') {
$first = notags(trim($v)); $first = notags(trim($v));
if($k === 'namePerson') }
if($k === 'namePerson') {
$args .= '&username=' . notags(trim($v)); $args .= '&username=' . notags(trim($v));
if($k === 'contact/email') }
if ($k === 'contact/email') {
$args .= '&email=' . notags(trim($v)); $args .= '&email=' . notags(trim($v));
if($k === 'media/image/aspect11') }
if ($k === 'media/image/aspect11') {
$photosq = bin2hex(trim($v)); $photosq = bin2hex(trim($v));
if($k === 'media/image/default') }
if ($k === 'media/image/default') {
$photo = bin2hex(trim($v)); $photo = bin2hex(trim($v));
} }
} }
if($nick) }
if ($nick) {
$args .= '&nickname=' . $nick; $args .= '&nickname=' . $nick;
elseif($first) }
elseif ($first) {
$args .= '&nickname=' . $first; $args .= '&nickname=' . $first;
}
if($photosq) if ($photosq) {
$args .= '&photo=' . $photosq; $args .= '&photo=' . $photosq;
elseif($photo) }
elseif ($photo) {
$args .= '&photo=' . $photo; $args .= '&photo=' . $photo;
}
$args .= '&openid_url=' . notags(trim($authid)); $args .= '&openid_url=' . notags(trim($authid));

View File

@ -780,6 +780,8 @@ function profiles_content(App &$a) {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$tpl = get_markup_template('profile_entry.tpl'); $tpl = get_markup_template('profile_entry.tpl');
$profiles = '';
foreach ($r as $rr) { foreach ($r as $rr) {
$profiles .= replace_macros($tpl, array( $profiles .= replace_macros($tpl, array(
'$photo' => $a->remove_baseurl($rr['thumb']), '$photo' => $a->remove_baseurl($rr['thumb']),

View File

@ -77,8 +77,10 @@ function viewcontacts_content(App &$a) {
$contacts = array(); $contacts = array();
foreach ($r as $rr) { foreach ($r as $rr) {
if($rr['self']) /// @TODO This triggers an E_NOTICE if 'self' is not there
if ($rr['self']) {
continue; continue;
}
$url = $rr['url']; $url = $rr['url'];