From a96eb3428dfd66e132ff834212be408ee64337b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Mon, 19 Dec 2016 14:42:20 +0100 Subject: [PATCH 01/96] Used more dbm::is_result() instead of (!$r) or (!count($r)), still there are more pending ... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also put SQL table columns into back-ticks. Signed-off-by: Roland Häder --- include/Contact.php | 4 ++-- include/api.php | 6 +++--- include/cron.php | 2 +- include/items.php | 6 +++--- include/lock.php | 3 ++- include/plugin.php | 2 +- include/poller.php | 2 +- include/socgraph.php | 2 +- include/user.php | 2 +- mod/profiles.php | 4 ++-- mod/regmod.php | 6 +++--- 11 files changed, 20 insertions(+), 19 deletions(-) diff --git a/include/Contact.php b/include/Contact.php index 7ca45a21bd..16c663d2af 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -229,14 +229,14 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) { dbesc(normalise_link($url)), intval($uid)); // Fetch the data from the contact table with "uid=0" (which is filled automatically) - if (!$r) + if (!dbm::is_result($r)) $r = q("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`, `keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, 0 AS `self` FROM `contact` WHERE `nurl` = '%s' AND `uid` = 0", dbesc(normalise_link($url))); // Fetch the data from the gcontact table - if (!$r) + if (!dbm::is_result($r)) $r = q("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, '' AS `xmpp`, `keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, `community` AS `forum`, 0 AS `prv`, `community`, `contact-type`, `birthday`, 0 AS `self` FROM `gcontact` WHERE `nurl` = '%s'", diff --git a/include/api.php b/include/api.php index 2ae1aeaa02..df62abd8e6 100644 --- a/include/api.php +++ b/include/api.php @@ -3590,7 +3590,7 @@ intval($gid), dbesc($name)); // error message if specified gid is not in database - if (count($rname) == 0) + if (!dbm::is_result($rname)) throw new BadRequestException('wrong group name'); // delete group @@ -3629,7 +3629,7 @@ intval($uid), dbesc($name)); // error message if specified group name already exists - if (count($rname) != 0) + if (dbm::is_result($rname)) throw new BadRequestException('group name already exists'); // check if specified group name is a deleted group @@ -3637,7 +3637,7 @@ intval($uid), dbesc($name)); // error message if specified group name already exists - if (count($rname) != 0) + if (dbm::is_result($rname)) $reactivate_group = true; // create group diff --git a/include/cron.php b/include/cron.php index 77332dcec6..9530302d34 100644 --- a/include/cron.php +++ b/include/cron.php @@ -264,7 +264,7 @@ function cron_poll_contacts($argc, $argv) { intval($c['id']) ); - if((! $res) || (! count($res))) + if (dbm::is_result($res)) continue; foreach($res as $contact) { diff --git a/include/items.php b/include/items.php index da9147fadd..9507b5e5fe 100644 --- a/include/items.php +++ b/include/items.php @@ -956,8 +956,8 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa // in it. if (!$deleted AND !$dontcache) { - $r = q('SELECT * FROM `item` WHERE id = %d', intval($current_post)); - if (count($r) == 1) { + $r = q('SELECT * FROM `item` WHERE `id` = %d', intval($current_post)); + if ((dbm::is_result($r)) && (count($r) == 1)) { if ($notify) call_hooks('post_local_end', $r[0]); else @@ -2230,7 +2230,7 @@ function posted_date_widget($url,$uid,$wall) { $ret = list_post_dates($uid,$wall); - if (! count($ret)) + if (! dbm::is_result($ret)) return $o; $cutoff_year = intval(datetime_convert('',date_default_timezone_get(),'now','Y')) - $visible_years; diff --git a/include/lock.php b/include/lock.php index 0c7b6acaa4..d49fda343f 100644 --- a/include/lock.php +++ b/include/lock.php @@ -23,7 +23,8 @@ function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30) { ); $got_lock = true; } - elseif(! dbm::is_result($r)) { // the Boolean value for count($r) should be equivalent to the Boolean value of $r + elseif(! dbm::is_result($r)) { + /// @TODO the Boolean value for count($r) should be equivalent to the Boolean value of $r q("INSERT INTO `locks` (`name`, `created`, `locked`) VALUES ('%s', '%s', 1)", dbesc($fn_name), dbesc(datetime_convert()) diff --git a/include/plugin.php b/include/plugin.php index 487ab57515..2d5531f90b 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -129,7 +129,7 @@ function reload_plugins() { */ function plugin_enabled($plugin) { $r = q("SELECT * FROM `addon` WHERE `installed` = 1 AND `name` = '%s'", $plugin); - return((bool)(count($r) > 0)); + return ((dbm::is_result($r)) && (count($r) > 0)); } diff --git a/include/poller.php b/include/poller.php index 44f4895cdb..d00360d2b7 100644 --- a/include/poller.php +++ b/include/poller.php @@ -213,7 +213,7 @@ function poller_max_connections_reached() { // The processlist only shows entries of the current user if ($max != 0) { $r = q("SHOW PROCESSLIST"); - if (!$r) + if (!dbm::is_result($r)) return false; $used = count($r); diff --git a/include/socgraph.php b/include/socgraph.php index 349fd0b2ca..f8a73a0a5c 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -1558,7 +1558,7 @@ function get_gcontact_id($contact) { proc_run(PRIORITY_LOW, 'include/gprobe.php', bin2hex($contact["url"])); } - if ((count($r) > 1) AND ($gcontact_id > 0) AND ($contact["url"] != "")) + if ((dbm::is_result($r)) AND (count($r) > 1) AND ($gcontact_id > 0) AND ($contact["url"] != "")) q("DELETE FROM `gcontact` WHERE `nurl` = '%s' AND `id` != %d", dbesc(normalise_link($contact["url"])), intval($gcontact_id)); diff --git a/include/user.php b/include/user.php index ec15d5b134..ae05b9e112 100644 --- a/include/user.php +++ b/include/user.php @@ -241,7 +241,7 @@ function create_user($arr) { WHERE `nickname` = '%s' ", dbesc($nickname) ); - if((count($r) > 1) && $newuid) { + if ((dbm::is_result($r)) && (count($r) > 1) && $newuid) { $result['message'] .= t('Nickname is already registered. Please choose another.') . EOL; q("DELETE FROM `user` WHERE `uid` = %d", intval($newuid) diff --git a/mod/profiles.php b/mod/profiles.php index f9fde658d2..39e9a6c1ff 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -92,7 +92,7 @@ function profiles_init(&$a) { intval(local_user()), intval($a->argv[2]) ); - if(! count($r1)) { + if(! dbm::is_result($r1)) { notice( t('Profile unavailable to clone.') . EOL); killme(); return; @@ -116,7 +116,7 @@ function profiles_init(&$a) { dbesc($name) ); info( t('New profile created.') . EOL); - if(count($r3) == 1) + if ((dbm::is_result($r3)) && (count($r3) == 1)) goaway('profiles/'.$r3[0]['id']); goaway('profiles'); diff --git a/mod/regmod.php b/mod/regmod.php index 0120017b00..8caa964aa9 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -12,14 +12,14 @@ function user_allow($hash) { ); - if(! count($register)) + if(! dbm::is_result($register)) return false; $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($register[0]['uid']) ); - if(! count($user)) + if(! dbm::is_result($user)) killme(); $r = q("DELETE FROM `register` WHERE `hash` = '%s'", @@ -69,7 +69,7 @@ function user_deny($hash) { dbesc($hash) ); - if(! count($register)) + if(! dbm::is_result($register)) return false; $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", From fb676335dbfb90d282622a68cb9a7113be19bc31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 10:10:33 +0100 Subject: [PATCH 02/96] Coding convention applied: - space between "if" and brace - curly braces on conditional blocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- boot.php | 2 +- include/dfrn.php | 6 ++++-- include/follow.php | 2 +- include/group.php | 5 +++-- include/like.php | 3 ++- include/lock.php | 2 +- include/notifier.php | 3 ++- include/onepoll.php | 3 ++- include/redir.php | 7 ++++--- include/socgraph.php | 2 +- include/text.php | 7 ++++--- mod/allfriends.php | 2 +- mod/attach.php | 4 ++-- mod/common.php | 2 +- mod/community.php | 2 +- mod/contactgroup.php | 2 +- mod/contacts.php | 4 ++-- mod/content.php | 2 +- mod/crepair.php | 7 ++++--- mod/delegate.php | 2 +- mod/dfrn_confirm.php | 6 +++--- mod/dfrn_notify.php | 7 ++++--- mod/dfrn_poll.php | 10 ++++++---- mod/dfrn_request.php | 5 +++-- mod/fsuggest.php | 4 ++-- mod/group.php | 4 ++-- mod/ignored.php | 3 ++- mod/item.php | 5 +++-- mod/lockview.php | 3 ++- mod/lostpass.php | 4 ++-- mod/manage.php | 3 ++- mod/match.php | 3 ++- mod/message.php | 2 +- mod/modexp.php | 3 ++- mod/network.php | 4 ++-- mod/poke.php | 2 +- mod/post.php | 3 ++- mod/profiles.php | 6 +++--- mod/profperm.php | 2 +- mod/pubsub.php | 9 +++++---- mod/receive.php | 3 ++- mod/salmon.php | 5 +++-- mod/search.php | 4 ++-- mod/settings.php | 5 +++-- mod/starred.php | 3 ++- mod/subthread.php | 3 ++- mod/suggest.php | 2 +- mod/tagrm.php | 6 ++++-- mod/viewcontacts.php | 3 ++- mod/wall_attach.php | 4 ++-- mod/wall_upload.php | 2 +- mod/wallmessage.php | 4 ++-- mod/xrd.php | 3 ++- 53 files changed, 117 insertions(+), 87 deletions(-) diff --git a/boot.php b/boot.php index b282f8d48e..c500468e5f 100644 --- a/boot.php +++ b/boot.php @@ -1028,7 +1028,7 @@ class App { } else { $r = q("SELECT `contact`.`avatar-date` AS picdate FROM `contact` WHERE `contact`.`thumb` like '%%/%s'", $common_filename); - if(! dbm::is_result($r)){ + if (! dbm::is_result($r)) { $this->cached_profile_image[$avatar_image] = $avatar_image; } else { $this->cached_profile_picdate[$common_filename] = "?rev=".urlencode($r[0]['picdate']); diff --git a/include/dfrn.php b/include/dfrn.php index 6451b8521b..689c5c2832 100644 --- a/include/dfrn.php +++ b/include/dfrn.php @@ -105,8 +105,9 @@ class dfrn { dbesc($owner_nick) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { killme(); + } $owner = $r[0]; $owner_id = $owner['uid']; @@ -139,8 +140,9 @@ class dfrn { intval($owner_id) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { killme(); + } $contact = $r[0]; require_once('include/security.php'); diff --git a/include/follow.php b/include/follow.php index d7066bcb55..e67beb84c2 100644 --- a/include/follow.php +++ b/include/follow.php @@ -254,7 +254,7 @@ function new_contact($uid,$url,$interactive = false) { intval($uid) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { $result['message'] .= t('Unable to retrieve contact information.') . EOL; return $result; } diff --git a/include/group.php b/include/group.php index 2c90330686..67712aae7c 100644 --- a/include/group.php +++ b/include/group.php @@ -143,13 +143,14 @@ function group_add_member($uid,$name,$member,$gid = 0) { return true; // You might question this, but // we indicate success because the group member was in fact created // -- It was just created at another time - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { $r = q("INSERT INTO `group_member` (`uid`, `gid`, `contact-id`) VALUES( %d, %d, %d ) ", intval($uid), intval($gid), intval($member) - ); + ); + } return $r; } diff --git a/include/like.php b/include/like.php index 8239633e6a..8223cf3626 100644 --- a/include/like.php +++ b/include/like.php @@ -78,8 +78,9 @@ function do_like($item_id, $verb) { intval($item['contact-id']), intval($item['uid']) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { return false; + } if(! $r[0]['self']) $remote_owner = $r[0]; } diff --git a/include/lock.php b/include/lock.php index d49fda343f..b3d488a357 100644 --- a/include/lock.php +++ b/include/lock.php @@ -23,7 +23,7 @@ function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30) { ); $got_lock = true; } - elseif(! dbm::is_result($r)) { + elseif (! dbm::is_result($r)) { /// @TODO the Boolean value for count($r) should be equivalent to the Boolean value of $r q("INSERT INTO `locks` (`name`, `created`, `locked`) VALUES ('%s', '%s', 1)", dbesc($fn_name), diff --git a/include/notifier.php b/include/notifier.php index c4e7df47ac..8823834c1d 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -210,8 +210,9 @@ function notifier_run(&$argv, &$argc){ intval($uid) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { return; + } $owner = $r[0]; diff --git a/include/onepoll.php b/include/onepoll.php index 2834036665..d92cb915b6 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -143,8 +143,9 @@ function onepoll_run(&$argv, &$argc){ $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", intval($importer_uid) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { return; + } $importer = $r[0]; diff --git a/include/redir.php b/include/redir.php index 8d65089de7..d8bb764396 100644 --- a/include/redir.php +++ b/include/redir.php @@ -36,9 +36,9 @@ function auto_redir(&$a, $contact_nick) { dbesc($nurl) ); - if((! dbm::is_result($r)) || $r[0]['id'] == remote_user()) + if ((! dbm::is_result($r)) || $r[0]['id'] == remote_user()) { return; - + } $r = q("SELECT * FROM contact WHERE nick = '%s' AND network = '%s' AND uid = %d AND url LIKE '%%%s%%' LIMIT 1", @@ -48,8 +48,9 @@ function auto_redir(&$a, $contact_nick) { dbesc($baseurl) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { return; + } $cid = $r[0]['id']; diff --git a/include/socgraph.php b/include/socgraph.php index c5fc31581e..598eb37373 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -330,7 +330,7 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca intval($gcid), intval($zcid) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { q("INSERT INTO `glink` (`cid`,`uid`,`gcid`,`zcid`, `updated`) VALUES (%d,%d,%d,%d, '%s') ", intval($cid), intval($uid), diff --git a/include/text.php b/include/text.php index a2c474d32e..05801d024c 100644 --- a/include/text.php +++ b/include/text.php @@ -2000,8 +2000,9 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) { intval($item), intval($uid) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { return false; + } q("UPDATE `item` SET `file` = '%s' WHERE `id` = %d AND `uid` = %d", dbesc(str_replace($pattern,'',$r[0]['file'])), @@ -2020,11 +2021,11 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) { //$r = q("select file from item where uid = %d and deleted = 0 " . file_tag_file_query('item',$file,(($cat) ? 'category' : 'file')), //); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { $saved = get_pconfig($uid,'system','filetags'); set_pconfig($uid,'system','filetags',str_replace($pattern,'',$saved)); - } + return true; } diff --git a/mod/allfriends.php b/mod/allfriends.php index 1f2c043ced..e4f067eaf7 100644 --- a/mod/allfriends.php +++ b/mod/allfriends.php @@ -39,7 +39,7 @@ function allfriends_content(&$a) { $r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { $o .= t('No friends to display.'); return $o; } diff --git a/mod/attach.php b/mod/attach.php index 274acfc2be..94cb75a386 100644 --- a/mod/attach.php +++ b/mod/attach.php @@ -16,7 +16,7 @@ function attach_init(&$a) { $r = q("SELECT * FROM `attach` WHERE `id` = %d LIMIT 1", intval($item_id) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('Item was not found.'). EOL); return; } @@ -29,7 +29,7 @@ function attach_init(&$a) { dbesc($item_id) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/common.php b/mod/common.php index 9f9379be57..9781d1607c 100644 --- a/mod/common.php +++ b/mod/common.php @@ -94,7 +94,7 @@ function common_content(&$a) { $r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { return $o; } diff --git a/mod/community.php b/mod/community.php index 40d4016f33..c8f04d8bd6 100644 --- a/mod/community.php +++ b/mod/community.php @@ -71,7 +71,7 @@ function community_content(&$a, $update = 0) { $r = community_getitems($a->pager['start'], $a->pager['itemspage']); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { info( t('No results.') . EOL); return $o; } diff --git a/mod/contactgroup.php b/mod/contactgroup.php index 4456db2f53..0671ff42ae 100644 --- a/mod/contactgroup.php +++ b/mod/contactgroup.php @@ -24,7 +24,7 @@ function contactgroup_content(&$a) { intval($a->argv[1]), intval(local_user()) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { killme(); } diff --git a/mod/contacts.php b/mod/contacts.php index 37cc09cab6..22e08b8c96 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -19,7 +19,7 @@ function contacts_init(&$a) { intval(local_user()), intval($contact_id) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { $contact_id = 0; } } @@ -169,7 +169,7 @@ function contacts_post(&$a) { intval($profile_id), intval(local_user()) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('Could not locate selected profile.') . EOL); return; } diff --git a/mod/content.php b/mod/content.php index bc98f7e51d..332a35f006 100644 --- a/mod/content.php +++ b/mod/content.php @@ -113,7 +113,7 @@ function content_content(&$a, $update = 0) { intval($group), intval($_SESSION['uid']) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { if($update) killme(); notice( t('No such group') . EOL ); diff --git a/mod/crepair.php b/mod/crepair.php index b4275f6baa..66faadb06a 100644 --- a/mod/crepair.php +++ b/mod/crepair.php @@ -14,7 +14,7 @@ function crepair_init(&$a) { intval(local_user()), intval($contact_id) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { $contact_id = 0; } } @@ -43,8 +43,9 @@ function crepair_post(&$a) { ); } - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { return; + } $contact = $r[0]; @@ -110,7 +111,7 @@ function crepair_content(&$a) { ); } - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('Contact not found.') . EOL); return; } diff --git a/mod/delegate.php b/mod/delegate.php index 343e1e3038..0ba5dd39c1 100644 --- a/mod/delegate.php +++ b/mod/delegate.php @@ -97,7 +97,7 @@ function delegate_content(&$a) { dbesc(NETWORK_DFRN) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('No potential page delegates located.') . EOL); return; } diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 7097b0117a..69d708f7fc 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -121,7 +121,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { intval($uid) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { logger('Contact not found in DB.'); notice( t('Contact not found.') . EOL ); notice( t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL ); @@ -553,7 +553,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1", dbesc($node)); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { $message = sprintf(t('No user record found for \'%s\' '), $node); xml_status(3,$message); // failure // NOTREACHED @@ -640,7 +640,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { dbesc($dfrn_pubkey), intval($dfrn_record) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { $message = t('Unable to set your contact credentials on our system.'); xml_status(3,$message); } diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index dfa2af18ce..ca12211583 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -42,7 +42,7 @@ function dfrn_notify_post(&$a) { dbesc($dfrn_id), dbesc($challenge) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { logger('dfrn_notify: could not match challenge to dfrn_id ' . $dfrn_id . ' challenge=' . $challenge); xml_status(3); } @@ -88,7 +88,7 @@ function dfrn_notify_post(&$a) { dbesc($a->argv[1]) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { logger('dfrn_notify: contact not found for dfrn_id ' . $dfrn_id); xml_status(3); //NOTREACHED @@ -284,8 +284,9 @@ function dfrn_notify_content(&$a) { dbesc($a->argv[1]) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { $status = 1; + } logger("Remote rino version: ".$rino_remote." for ".$r[0]["url"], LOGGER_DEBUG); diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 7c3fced12f..0c55af2a89 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -126,7 +126,7 @@ function dfrn_poll_init(&$a) { $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1", dbesc($sec) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { xml_status(3, 'No ticket'); // NOTREACHED } @@ -223,7 +223,7 @@ function dfrn_poll_post(&$a) { $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1", dbesc($sec) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { xml_status(3, 'No ticket'); // NOTREACHED } @@ -284,8 +284,9 @@ function dfrn_poll_post(&$a) { dbesc($challenge) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { killme(); + } $type = $r[0]['type']; $last_update = $r[0]['last_update']; @@ -319,8 +320,9 @@ function dfrn_poll_post(&$a) { $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1"); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { killme(); + } $contact = $r[0]; $owner_uid = $r[0]['uid']; diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 24a1dc0725..7a8021784d 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -371,7 +371,7 @@ function dfrn_request_post(&$a) { intval($uid) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('This account has not been configured for email. Request failed.') . EOL); return; } @@ -842,8 +842,9 @@ function dfrn_request_content(&$a) { $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", intval($a->profile['uid']) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { $mail_disabled = 1; + } } // "coming soon" is disabled for now diff --git a/mod/fsuggest.php b/mod/fsuggest.php index 1d56f45736..4370952ca1 100644 --- a/mod/fsuggest.php +++ b/mod/fsuggest.php @@ -16,7 +16,7 @@ function fsuggest_post(&$a) { intval($contact_id), intval(local_user()) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('Contact not found.') . EOL); return; } @@ -88,7 +88,7 @@ function fsuggest_content(&$a) { intval($contact_id), intval(local_user()) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('Contact not found.') . EOL); return; } diff --git a/mod/group.php b/mod/group.php index 33b819ed5d..c4854a602d 100644 --- a/mod/group.php +++ b/mod/group.php @@ -43,7 +43,7 @@ function group_post(&$a) { intval($a->argv[1]), intval(local_user()) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('Group not found.') . EOL ); goaway(App::get_baseurl() . '/contacts'); return; // NOTREACHED @@ -136,7 +136,7 @@ function group_content(&$a) { intval($a->argv[1]), intval(local_user()) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('Group not found.') . EOL ); goaway(App::get_baseurl() . '/contacts'); } diff --git a/mod/ignored.php b/mod/ignored.php index eec204c708..4aeeb21e6b 100644 --- a/mod/ignored.php +++ b/mod/ignored.php @@ -16,8 +16,9 @@ function ignored_init(&$a) { intval(local_user()), intval($message_id) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { killme(); + } if(! intval($r[0]['ignored'])) $ignored = 1; diff --git a/mod/item.php b/mod/item.php index c741f16144..7bee5f3eae 100644 --- a/mod/item.php +++ b/mod/item.php @@ -112,7 +112,7 @@ function item_post(&$a) { } } - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('Unable to locate original post.') . EOL); if(x($_REQUEST,'return')) goaway($return_path); @@ -464,8 +464,9 @@ function item_post(&$a) { intval($profile_uid) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { continue; + } $r = q("UPDATE `photo` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `resource-id` = '%s' AND `uid` = %d AND `album` = '%s' ", diff --git a/mod/lockview.php b/mod/lockview.php index c806fc3175..68b5d30cfe 100644 --- a/mod/lockview.php +++ b/mod/lockview.php @@ -21,8 +21,9 @@ function lockview_content(&$a) { dbesc($type), intval($item_id) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { killme(); + } $item = $r[0]; call_hooks('lockview_content', $item); diff --git a/mod/lostpass.php b/mod/lostpass.php index 122024d26b..92e64f7e2e 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -15,7 +15,7 @@ function lostpass_post(&$a) { dbesc($loginame) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('No valid account found.') . EOL); goaway(z_root()); } @@ -87,7 +87,7 @@ function lostpass_content(&$a) { $r = q("SELECT * FROM `user` WHERE `pwdreset` = '%s' LIMIT 1", dbesc($hash) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { $o = t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed."); return $o; } diff --git a/mod/manage.php b/mod/manage.php index 4a4f0a9e37..2138595bee 100644 --- a/mod/manage.php +++ b/mod/manage.php @@ -56,8 +56,9 @@ function manage_post(&$a) { ); } - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { return; + } unset($_SESSION['authenticated']); unset($_SESSION['uid']); diff --git a/mod/match.php b/mod/match.php index f7fe325b38..69bf3c1101 100644 --- a/mod/match.php +++ b/mod/match.php @@ -27,8 +27,9 @@ function match_content(&$a) { $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user()) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { return; + } if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) { notice( t('No keywords to match. Please add keywords to your default profile.') . EOL); return; diff --git a/mod/message.php b/mod/message.php index 0a2c797b42..b0d0ba95ca 100644 --- a/mod/message.php +++ b/mod/message.php @@ -381,7 +381,7 @@ function message_content(&$a) { $r = get_messages(local_user(), $a->pager['start'], $a->pager['itemspage']); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { info( t('No messages.') . EOL); return $o; } diff --git a/mod/modexp.php b/mod/modexp.php index d1dabb101b..3729e3236c 100644 --- a/mod/modexp.php +++ b/mod/modexp.php @@ -12,8 +12,9 @@ function modexp_init(&$a) { dbesc($nick) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { killme(); + } $lines = explode("\n",$r[0]['spubkey']); unset($lines[0]); diff --git a/mod/network.php b/mod/network.php index 057ef79145..c040a547a4 100644 --- a/mod/network.php +++ b/mod/network.php @@ -126,7 +126,7 @@ function network_init(&$a) { intval(local_user()), dbesc($search) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { q("INSERT INTO `search` ( `uid`,`term` ) VALUES ( %d, '%s') ", intval(local_user()), dbesc($search) @@ -463,7 +463,7 @@ function network_content(&$a, $update = 0) { intval($group), intval($_SESSION['uid']) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { if($update) killme(); notice( t('No such group') . EOL ); diff --git a/mod/poke.php b/mod/poke.php index 0619a34e07..fea5c0c0d8 100644 --- a/mod/poke.php +++ b/mod/poke.php @@ -52,7 +52,7 @@ function poke_init(&$a) { intval($uid) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { logger('poke: no contact ' . $contact_id); return; } diff --git a/mod/post.php b/mod/post.php index 76282d29a5..a8d345ecb6 100644 --- a/mod/post.php +++ b/mod/post.php @@ -23,8 +23,9 @@ function post_post(&$a) { AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", dbesc($nickname) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { http_status_exit(500); + } $importer = $r[0]; } diff --git a/mod/profiles.php b/mod/profiles.php index a5f5609b6b..44067032ea 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -15,7 +15,7 @@ function profiles_init(&$a) { intval($a->argv[2]), intval(local_user()) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('Profile not found.') . EOL); goaway('profiles'); return; // NOTREACHED @@ -130,7 +130,7 @@ function profiles_init(&$a) { intval($a->argv[1]), intval(local_user()) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('Profile not found.') . EOL); killme(); return; @@ -613,7 +613,7 @@ function profiles_content(&$a) { intval($a->argv[1]), intval(local_user()) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('Profile not found.') . EOL); return; } diff --git a/mod/profperm.php b/mod/profperm.php index 1c37f84ab2..aa610d3a93 100644 --- a/mod/profperm.php +++ b/mod/profperm.php @@ -52,7 +52,7 @@ function profperm_content(&$a) { intval($a->argv[1]), intval(local_user()) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('Invalid profile identifier.') . EOL ); return; } diff --git a/mod/pubsub.php b/mod/pubsub.php index ddda7ec228..ea7e1000ba 100644 --- a/mod/pubsub.php +++ b/mod/pubsub.php @@ -47,7 +47,7 @@ function pubsub_init(&$a) { $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", dbesc($nick) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { logger('pubsub: local account not found: ' . $nick); hub_return(false, ''); } @@ -62,7 +62,7 @@ function pubsub_init(&$a) { intval($contact_id), intval($owner['uid']) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { logger('pubsub: contact '.$contact_id.' not found.'); hub_return(false, ''); } @@ -117,8 +117,9 @@ function pubsub_post(&$a) { $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", dbesc($nick) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { hub_post_return(); + } $importer = $r[0]; @@ -131,7 +132,7 @@ function pubsub_post(&$a) { dbesc(NETWORK_FEED) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { logger('pubsub: no contact record for "'.$nick.' ('.$contact_id.')" - ignored. '.$xml); hub_post_return(); } diff --git a/mod/receive.php b/mod/receive.php index dd4e61ae4f..99e3648e91 100644 --- a/mod/receive.php +++ b/mod/receive.php @@ -34,8 +34,9 @@ function receive_post(&$a) { $r = q("SELECT * FROM `user` WHERE `guid` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", dbesc($guid) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { http_status_exit(500); + } $importer = $r[0]; } diff --git a/mod/salmon.php b/mod/salmon.php index 78cdc09328..ff5856a946 100644 --- a/mod/salmon.php +++ b/mod/salmon.php @@ -31,8 +31,9 @@ function salmon_post(&$a) { $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", dbesc($nick) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { http_status_exit(500); + } $importer = $r[0]; @@ -150,7 +151,7 @@ function salmon_post(&$a) { dbesc(normalise_link($author_link)), intval($importer['uid']) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { logger('mod-salmon: Author unknown to us.'); if(get_pconfig($importer['uid'],'system','ostatus_autofriend')) { $result = new_contact($importer['uid'],$author_link); diff --git a/mod/search.php b/mod/search.php index d36cc8fcb7..c19bb27673 100644 --- a/mod/search.php +++ b/mod/search.php @@ -53,7 +53,7 @@ function search_init(&$a) { intval(local_user()), dbesc($search) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { q("INSERT INTO `search` (`uid`,`term`) VALUES ( %d, '%s')", intval(local_user()), dbesc($search) @@ -219,7 +219,7 @@ function search_content(&$a) { intval($a->pager['start']), intval($a->pager['itemspage'])); } - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { info( t('No results.') . EOL); return $o; } diff --git a/mod/settings.php b/mod/settings.php index 41783815e7..e7fd55e944 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -225,7 +225,7 @@ function settings_post(&$a) { $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", intval(local_user()) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { q("INSERT INTO `mailacct` (`uid`) VALUES (%d)", intval(local_user()) ); @@ -752,8 +752,9 @@ function settings_content(&$a) { $settings_addons = ""; $r = q("SELECT * FROM `hook` WHERE `hook` = 'plugin_settings' "); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { $settings_addons = t('No Plugin settings configured'); + } call_hooks('plugin_settings', $settings_addons); diff --git a/mod/starred.php b/mod/starred.php index 5acbb393ef..0e5e75d167 100644 --- a/mod/starred.php +++ b/mod/starred.php @@ -18,8 +18,9 @@ function starred_init(&$a) { intval(local_user()), intval($message_id) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { killme(); + } if(! intval($r[0]['starred'])) $starred = 1; diff --git a/mod/subthread.php b/mod/subthread.php index dc014047a0..66072bcc88 100644 --- a/mod/subthread.php +++ b/mod/subthread.php @@ -41,8 +41,9 @@ function subthread_content(&$a) { intval($item['contact-id']), intval($item['uid']) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { return; + } if(! $r[0]['self']) $remote_owner = $r[0]; } diff --git a/mod/suggest.php b/mod/suggest.php index 080decc71a..73f5ffe4b2 100644 --- a/mod/suggest.php +++ b/mod/suggest.php @@ -67,7 +67,7 @@ function suggest_content(&$a) { $r = suggestion_query(local_user()); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { $o .= t('No suggestions available. If this is a new site, please try again in 24 hours.'); return $o; } diff --git a/mod/tagrm.php b/mod/tagrm.php index 08d390a70b..d6e57d36a9 100644 --- a/mod/tagrm.php +++ b/mod/tagrm.php @@ -19,8 +19,9 @@ function tagrm_post(&$a) { intval(local_user()) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + } $arr = explode(',', $r[0]['tag']); for($x = 0; $x < count($arr); $x ++) { @@ -68,8 +69,9 @@ function tagrm_content(&$a) { intval(local_user()) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + } $arr = explode(',', $r[0]['tag']); diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php index c9f465676c..3fd5d79e1b 100644 --- a/mod/viewcontacts.php +++ b/mod/viewcontacts.php @@ -16,8 +16,9 @@ function viewcontacts_init(&$a) { dbesc($nick) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { return; + } $a->data['user'] = $r[0]; $a->profile_uid = $r[0]['uid']; diff --git a/mod/wall_attach.php b/mod/wall_attach.php index 80fc1c6e79..525d3509c1 100644 --- a/mod/wall_attach.php +++ b/mod/wall_attach.php @@ -12,7 +12,7 @@ function wall_attach_post(&$a) { $r = q("SELECT `user`.*, `contact`.`id` FROM `user` LEFT JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1", dbesc($nick) ); - if(! dbm::is_result($r)){ + if (! dbm::is_result($r)) { if ($r_json) { echo json_encode(array('error'=>t('Invalid request.'))); killme(); @@ -168,7 +168,7 @@ function wall_attach_post(&$a) { dbesc($hash) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { $msg = t('File upload failed.'); if ($r_json) { echo json_encode(array('error'=>$msg)); diff --git a/mod/wall_upload.php b/mod/wall_upload.php index e277290985..eb2a92323a 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -15,7 +15,7 @@ function wall_upload_post(&$a, $desktopmode = true) { dbesc($nick) ); - if(! dbm::is_result($r)){ + if (! dbm::is_result($r)) { if ($r_json) { echo json_encode(array('error'=>t('Invalid request.'))); killme(); diff --git a/mod/wallmessage.php b/mod/wallmessage.php index 03a0b7a16f..afe25cbe8b 100644 --- a/mod/wallmessage.php +++ b/mod/wallmessage.php @@ -22,7 +22,7 @@ function wallmessage_post(&$a) { dbesc($recipient) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { logger('wallmessage: no recipient'); return; } @@ -91,7 +91,7 @@ function wallmessage_content(&$a) { dbesc($recipient) ); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { notice( t('No recipient.') . EOL); logger('wallmessage: no recipient'); return; diff --git a/mod/xrd.php b/mod/xrd.php index 576ae9b38f..290c524a7d 100644 --- a/mod/xrd.php +++ b/mod/xrd.php @@ -21,8 +21,9 @@ function xrd_init(&$a) { $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1", dbesc($name) ); - if(! dbm::is_result($r)) + if (! dbm::is_result($r)) { killme(); + } $salmon_key = salmon_key($r[0]['spubkey']); From e1f366164509fc8217f9d0cf21d7475f6d71b73a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Mon, 19 Dec 2016 14:26:13 +0100 Subject: [PATCH 03/96] *much* more usage of App::get_baseurl() instead of $a->get_baseurl() (coding convention applied) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/Contact.php | 16 +++++------ include/Photo.php | 26 ++++++++--------- include/auth.php | 3 +- include/bb2diaspora.php | 6 ++-- include/bbcode.php | 12 ++++---- include/contact_widgets.php | 3 +- include/conversation.php | 8 +++--- include/dbstructure.php | 4 +-- include/delivery.php | 2 +- include/enotify.php | 10 +++---- include/event.php | 2 +- include/follow.php | 2 +- include/identity.php | 36 ++++++++++++------------ include/items.php | 37 ++++++++++++------------- include/like.php | 4 +-- include/message.php | 13 ++++----- include/nav.php | 4 +-- include/network.php | 6 ++-- include/notifier.php | 2 +- include/oauth.php | 2 +- include/plugin.php | 5 ++-- include/pubsubpublish.php | 2 +- include/redir.php | 2 +- include/security.php | 8 +++--- include/socgraph.php | 10 +++---- include/tags.php | 6 ++-- include/text.php | 2 +- include/threads.php | 4 +-- include/uimport.php | 4 +-- mod/admin.php | 36 ++++++++++++------------ mod/allfriends.php | 2 +- mod/bookmarklet.php | 2 +- mod/cal.php | 12 ++++---- mod/contacts.php | 10 +++---- mod/content.php | 8 +++--- mod/delegate.php | 14 +++++----- mod/dfrn_confirm.php | 8 +++--- mod/dfrn_poll.php | 8 +++--- mod/dfrn_request.php | 18 ++++++------ mod/dirfind.php | 2 +- mod/display.php | 6 ++-- mod/editpost.php | 6 ++-- mod/events.php | 20 ++++++------- mod/fbrowser.php | 11 ++++---- mod/friendica.php | 4 +-- mod/group.php | 10 +++---- mod/hcard.php | 8 +++--- mod/home.php | 8 +++--- mod/ignored.php | 2 +- mod/install.php | 16 +++++------ mod/invite.php | 4 +-- mod/item.php | 20 ++++++------- mod/like.php | 2 +- mod/localtime.php | 2 +- mod/lostpass.php | 12 ++++---- mod/manage.php | 2 +- mod/message.php | 22 +++++++-------- mod/mood.php | 2 +- mod/msearch.php | 4 +-- mod/navigation.php | 2 +- mod/network.php | 2 +- mod/nodeinfo.php | 2 +- mod/noscrape.php | 4 +-- mod/notice.php | 2 +- mod/notify.php | 6 ++-- mod/oexchange.php | 4 +-- mod/openid.php | 2 +- mod/opensearch.php | 2 +- mod/ostatus_subscribe.php | 4 +-- mod/photos.php | 20 ++++++------- mod/ping.php | 10 +++---- mod/poke.php | 8 +++--- mod/profile.php | 16 +++++------ mod/profile_photo.php | 20 ++++++------- mod/profiles.php | 6 ++-- mod/proxy.php | 8 +++--- mod/randprof.php | 2 +- mod/register.php | 10 +++---- mod/regmod.php | 8 +++--- mod/repair_ostatus.php | 2 +- mod/rsd_xml.php | 2 +- mod/settings.php | 18 ++++++------ mod/starred.php | 2 +- mod/suggest.php | 6 ++-- mod/tagger.php | 16 +++++------ mod/tagrm.php | 16 +++++------ mod/toggle_mobile.php | 2 +- mod/uexport.php | 4 +-- mod/videos.php | 28 +++++++++---------- mod/wall_upload.php | 12 ++++---- mod/xrd.php | 20 ++++++------- view/php/default.php | 2 +- view/php/minimal.php | 2 +- view/theme/duepuntozero/config.php | 8 +++--- view/theme/frio/config.php | 2 +- view/theme/frio/php/default.php | 4 +-- view/theme/frio/php/standard.php | 4 +-- view/theme/frio/theme.php | 2 +- view/theme/frost-mobile/php/default.php | 2 +- view/theme/frost-mobile/theme.php | 4 +-- view/theme/frost/php/default.php | 2 +- view/theme/frost/theme.php | 4 +-- view/theme/quattro/config.php | 4 +-- view/theme/quattro/theme.php | 4 +-- view/theme/smoothly/php/default.php | 2 +- view/theme/smoothly/theme.php | 4 +-- view/theme/vier/config.php | 4 +-- view/theme/vier/theme.php | 2 +- 108 files changed, 407 insertions(+), 437 deletions(-) diff --git a/include/Contact.php b/include/Contact.php index 16c663d2af..13e11a8322 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -8,7 +8,6 @@ function user_remove($uid) { if(! $uid) return; - $a = get_app(); logger('Removing user: ' . $uid); $r = q("select * from user where uid = %d limit 1", intval($uid)); @@ -54,7 +53,7 @@ function user_remove($uid) { if($uid == local_user()) { unset($_SESSION['authenticated']); unset($_SESSION['uid']); - goaway($a->get_baseurl()); + goaway(App::get_baseurl()); } } @@ -86,7 +85,6 @@ function contact_remove($id) { function terminate_friendship($user,$self,$contact) { - $a = get_app(); require_once('include/datetime.php'); @@ -361,7 +359,7 @@ function contact_photo_menu($contact, $uid = 0) $sparkle = false; if ($contact['network'] === NETWORK_DFRN) { $sparkle = true; - $profile_link = $a->get_baseurl() . '/redir/' . $contact['id']; + $profile_link = App::get_baseurl() . '/redir/' . $contact['id']; } else { $profile_link = $contact['url']; } @@ -377,17 +375,17 @@ function contact_photo_menu($contact, $uid = 0) } if (in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DIASPORA))) { - $pm_url = $a->get_baseurl() . '/message/new/' . $contact['id']; + $pm_url = App::get_baseurl() . '/message/new/' . $contact['id']; } if ($contact['network'] == NETWORK_DFRN) { - $poke_link = $a->get_baseurl() . '/poke/?f=&c=' . $contact['id']; + $poke_link = App::get_baseurl() . '/poke/?f=&c=' . $contact['id']; } - $contact_url = $a->get_baseurl() . '/contacts/' . $contact['id']; + $contact_url = App::get_baseurl() . '/contacts/' . $contact['id']; - $posts_link = $a->get_baseurl() . '/contacts/' . $contact['id'] . '/posts'; - $contact_drop_link = $a->get_baseurl() . '/contacts/' . $contact['id'] . '/drop?confirm=1'; + $posts_link = App::get_baseurl() . '/contacts/' . $contact['id'] . '/posts'; + $contact_drop_link = App::get_baseurl() . '/contacts/' . $contact['id'] . '/drop?confirm=1'; /** * menu array: diff --git a/include/Photo.php b/include/Photo.php index 014cca7d25..1a97fe2fe4 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -794,8 +794,6 @@ function update_contact_avatar($avatar, $uid, $cid, $force = false) { function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) { - $a = get_app(); - $r = q("SELECT `resource-id` FROM `photo` WHERE `uid` = %d AND `contact-id` = %d AND `scale` = 4 AND `album` = 'Contact Photos' LIMIT 1", intval($uid), intval($cid) @@ -841,9 +839,9 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) { $photo_failure = true; } - $photo = $a->get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt(); - $thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt(); - $micro = $a->get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt(); + $photo = App::get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt(); + $thumb = App::get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt(); + $micro = App::get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt(); } else { $photo_failure = true; } @@ -853,9 +851,9 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) { } if ($photo_failure) { - $photo = $a->get_baseurl() . '/images/person-175.jpg'; - $thumb = $a->get_baseurl() . '/images/person-80.jpg'; - $micro = $a->get_baseurl() . '/images/person-48.jpg'; + $photo = App::get_baseurl() . '/images/person-175.jpg'; + $thumb = App::get_baseurl() . '/images/person-80.jpg'; + $micro = App::get_baseurl() . '/images/person-48.jpg'; } return(array($photo,$thumb,$micro)); @@ -1044,18 +1042,18 @@ function store_photo($a, $uid, $imagedata = "", $url = "") { return(array()); } - $image = array("page" => $a->get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash, - "full" => $a->get_baseurl()."/photo/{$hash}-0.".$ph->getExt()); + $image = array("page" => App::get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash, + "full" => App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt()); if ($width > 800 || $height > 800) { - $image["large"] = $a->get_baseurl()."/photo/{$hash}-0.".$ph->getExt(); + $image["large"] = App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt(); } if ($width > 640 || $height > 640) { $ph->scaleImage(640); $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 1, 0, $defperm); if ($r) { - $image["medium"] = $a->get_baseurl()."/photo/{$hash}-1.".$ph->getExt(); + $image["medium"] = App::get_baseurl()."/photo/{$hash}-1.".$ph->getExt(); } } @@ -1063,7 +1061,7 @@ function store_photo($a, $uid, $imagedata = "", $url = "") { $ph->scaleImage(320); $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 2, 0, $defperm); if ($r) { - $image["small"] = $a->get_baseurl()."/photo/{$hash}-2.".$ph->getExt(); + $image["small"] = App::get_baseurl()."/photo/{$hash}-2.".$ph->getExt(); } } @@ -1088,7 +1086,7 @@ function store_photo($a, $uid, $imagedata = "", $url = "") { $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 3, 0, $defperm); if ($r) { - $image["thumb"] = $a->get_baseurl()."/photo/{$hash}-3.".$ph->getExt(); + $image["thumb"] = App::get_baseurl()."/photo/{$hash}-3.".$ph->getExt(); } } diff --git a/include/auth.php b/include/auth.php index 2ca9c3efb2..e3c8d92eeb 100644 --- a/include/auth.php +++ b/include/auth.php @@ -125,8 +125,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params' $openid = new LightOpenID; $openid->identity = $openid_url; $_SESSION['openid'] = $openid_url; - $a = get_app(); - $openid->returnUrl = $a->get_baseurl(true).'/openid'; + $openid->returnUrl = App::get_baseurl(true).'/openid'; goaway($openid->authUrl()); } catch (Exception $e) { notice(t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.').'

'.t('The error message was:').' '.$e->getMessage()); diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 0c637dc3af..842dbf0b1c 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -144,8 +144,6 @@ function unescape_underscores_in_links($m) { function format_event_diaspora($ev) { - $a = get_app(); - if(! ((is_array($ev)) && count($ev))) return ''; @@ -160,7 +158,7 @@ function format_event_diaspora($ev) { $ev['start'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['start'] , $bd_format))) - . '](' . $a->get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['start'])) . ")\n"; + . '](' . App::get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['start'])) . ")\n"; if(! $ev['nofinish']) $o .= t('Finishes:') . ' ' . '[' @@ -168,7 +166,7 @@ function format_event_diaspora($ev) { $ev['finish'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['finish'] , $bd_format ))) - . '](' . $a->get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['finish'])) . ")\n"; + . '](' . App::get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['finish'])) . ")\n"; if(strlen($ev['location'])) $o .= t('Location:') . bb2diaspora($ev['location']) diff --git a/include/bbcode.php b/include/bbcode.php index 27213007ce..c05173f47c 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -613,9 +613,7 @@ function GetProfileUsername($profile, $username, $compact = false, $getnetwork = } function bb_DiasporaLinks($match) { - $a = get_app(); - - return "[url=".$a->get_baseurl()."/display/".$match[1]."]".$match[2]."[/url]"; + return "[url=".App::get_baseurl()."/display/".$match[1]."]".$match[2]."[/url]"; } function bb_RemovePictureLinks($match) { @@ -894,7 +892,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal // we may need to restrict this further if it picks up too many strays // link acct:user@host to a webfinger profile redirector - $Text = preg_replace('/acct:([^@]+)@((?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63})/', 'acct:$1@$2',$Text); + $Text = preg_replace('/acct:([^@]+)@((?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63})/', 'acct:$1@$2',$Text); // Perform MAIL Search $Text = preg_replace("/\[mail\]([$MAILSearchString]*)\[\/mail\]/", '$1', $Text); @@ -1063,9 +1061,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal return(bb_ShareAttributes($match, $simplehtml)); },$Text); - $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'
' . t('Encrypted content') . '
', $Text); - $Text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism",'
' . t('Encrypted content') . '
', $Text); - //$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",'
' . t('Encrypted content') . '
', $Text); + $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'
' . t('Encrypted content') . '
', $Text); + $Text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism",'
' . t('Encrypted content') . '
', $Text); + //$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",'
' . t('Encrypted content') . '
', $Text); // Try to Oembed diff --git a/include/contact_widgets.php b/include/contact_widgets.php index f66d23c518..a74080e75b 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -116,7 +116,6 @@ function networks_widget($baseurl,$selected = '') { } function fileas_widget($baseurl,$selected = '') { - $a = get_app(); if(! local_user()) return ''; @@ -235,7 +234,7 @@ function common_friends_visitor_widget($profile_uid) { return replace_macros(get_markup_template('remote_friends_common.tpl'), array( '$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t), - '$base' => $a->get_baseurl(), + '$base' => App::get_baseurl(), '$uid' => $profile_uid, '$cid' => (($cid) ? $cid : '0'), '$linkmore' => (($t > 5) ? 'true' : ''), diff --git a/include/conversation.php b/include/conversation.php index 567bf83e1b..916a9e229e 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -864,7 +864,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { } $o = replace_macros($page_template, array( - '$baseurl' => $a->get_baseurl($ssl_state), + '$baseurl' => App::get_baseurl($ssl_state), '$return_path' => $a->query_string, '$live_update' => $live_update_div, '$remove' => t('remove'), @@ -1183,7 +1183,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { $tpl = get_markup_template('jot-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array( '$newpost' => 'true', - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$geotag' => $geotag, '$nickname' => $x['nickname'], @@ -1201,7 +1201,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { $tpl = get_markup_template('jot-end.tpl'); $a->page['end'] .= replace_macros($tpl, array( '$newpost' => 'true', - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$geotag' => $geotag, '$nickname' => $x['nickname'], @@ -1267,7 +1267,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { '$ptyp' => (($notes_cid) ? 'note' : 'wall'), '$content' => $x['content'], '$post_id' => $x['post_id'], - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$defloc' => $x['default_location'], '$visitor' => $x['visitor'], '$pvisit' => (($notes_cid) ? 'none' : $x['visitor']), diff --git a/include/dbstructure.php b/include/dbstructure.php index c694014f68..be1158eabe 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -56,11 +56,11 @@ function update_fail($update_id, $error_message){ $email_tpl = get_intltext_template("update_fail_eml.tpl"); $email_msg = replace_macros($email_tpl, array( '$sitename' => $a->config['sitename'], - '$siteurl' => $a->get_baseurl(), + '$siteurl' => App::get_baseurl(), '$update' => DB_UPDATE_VERSION, '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION) )); - $subject=sprintf(t('Update Error at %s'), $a->get_baseurl()); + $subject=sprintf(t('Update Error at %s'), App::get_baseurl()); require_once('include/email.php'); $subject = email_header_encode($subject,'UTF-8'); mail($a->config['admin_email'], $subject, $email_msg, diff --git a/include/delivery.php b/include/delivery.php index a7aebe709a..db2f03c8f4 100644 --- a/include/delivery.php +++ b/include/delivery.php @@ -323,7 +323,7 @@ function delivery_run(&$argv, &$argc){ // perform local delivery if we are on the same site - if (link_compare($basepath,$a->get_baseurl())) { + if (link_compare($basepath,App::get_baseurl())) { $nickname = basename($contact['url']); if ($contact['issued-id']) diff --git a/include/enotify.php b/include/enotify.php index c6e0506e96..aa29e117a6 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -23,7 +23,7 @@ function notification($params) { $banner = t('Friendica Notification'); $product = FRIENDICA_PLATFORM; - $siteurl = $a->get_baseurl(true); + $siteurl = App::get_baseurl(true); $thanks = t('Thank You,'); $sitename = $a->config['sitename']; if (!x($a->config['admin_name'])) @@ -58,7 +58,7 @@ function notification($params) { $additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n"; $additional_mail_header .= "X-Friendica-Version: ".FRIENDICA_VERSION."\n"; $additional_mail_header .= "List-ID: \n"; - $additional_mail_header .= "List-Archive: <".$a->get_baseurl()."/notifications/system>\n"; + $additional_mail_header .= "List-Archive: <".App::get_baseurl()."/notifications/system>\n"; if (array_key_exists('item', $params)) { $title = $params['item']['title']; @@ -494,7 +494,7 @@ function notification($params) { } - $itemlink = $a->get_baseurl().'/notify/view/'.$notify_id; + $itemlink = App::get_baseurl().'/notify/view/'.$notify_id; $msg = replace_macros($epreamble, array('$itemlink' => $itemlink)); $msg_cache = format_notification_message($datarray['name_cache'], strip_tags(bbcode($msg))); $r = q("UPDATE `notify` SET `msg` = '%s', `msg_cache` = '%s' WHERE `id` = %d AND `uid` = %d", @@ -648,8 +648,6 @@ function notification($params) { * @param str $defaulttype (Optional) Forces a notification with this type. */ function check_item_notification($itemid, $uid, $defaulttype = "") { - $a = get_app(); - $notification_data = array("uid" => $uid, "profiles" => array()); call_hooks('check_item_notification', $notification_data); @@ -667,7 +665,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") { $profiles[] = $owner[0]["url"]; // Notifications from Diaspora are often with an URL in the Diaspora format - $profiles[] = $a->get_baseurl()."/u/".$user[0]["nickname"]; + $profiles[] = App::get_baseurl()."/u/".$user[0]["nickname"]; $profiles2 = array(); diff --git a/include/event.php b/include/event.php index 3a41dad4e7..4abe3ffef5 100644 --- a/include/event.php +++ b/include/event.php @@ -408,7 +408,7 @@ function event_store($arr) { intval($arr['uid']) ); //if (dbm::is_result($r)) - // $plink = $a->get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id; + // $plink = App::get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id; if($item_id) { diff --git a/include/follow.php b/include/follow.php index 7a3514b3a7..d7066bcb55 100644 --- a/include/follow.php +++ b/include/follow.php @@ -99,7 +99,7 @@ function new_contact($uid,$url,$interactive = false) { if($ret['network'] === NETWORK_DFRN) { if($interactive) { if(strlen($a->path)) - $myaddr = bin2hex($a->get_baseurl() . '/profile/' . $a->user['nickname']); + $myaddr = bin2hex(App::get_baseurl() . '/profile/' . $a->user['nickname']); else $myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname()); diff --git a/include/identity.php b/include/identity.php index bf05a00516..1307b42b1b 100644 --- a/include/identity.php +++ b/include/identity.php @@ -232,7 +232,7 @@ function profile_sidebar($profile, $block = 0) { if (isset($profile["url"])) $profile_url = normalise_link($profile["url"]); else - $profile_url = normalise_link($a->get_baseurl()."/profile/".$profile["nickname"]); + $profile_url = normalise_link(App::get_baseurl()."/profile/".$profile["nickname"]); $r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'", local_user(), $profile_url); @@ -279,7 +279,7 @@ function profile_sidebar($profile, $block = 0) { // show edit profile to yourself if ($profile['uid'] == local_user() && feature_enabled(local_user(),'multi_profiles')) { - $profile['edit'] = array($a->get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles')); + $profile['edit'] = array(App::get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles')); $r = q("SELECT * FROM `profile` WHERE `uid` = %d", local_user()); @@ -308,7 +308,7 @@ function profile_sidebar($profile, $block = 0) { } } if ($profile['uid'] == local_user() && !feature_enabled(local_user(),'multi_profiles')) { - $profile['edit'] = array($a->get_baseurl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile')); + $profile['edit'] = array(App::get_baseurl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile')); $profile['menu'] = array( 'chg_photo' => t('Change profile photo'), 'cr_new' => null, @@ -349,15 +349,15 @@ function profile_sidebar($profile, $block = 0) { if ($profile['guid'] != "") $diaspora = array( 'guid' => $profile['guid'], - 'podloc' => $a->get_baseurl(), + 'podloc' => App::get_baseurl(), 'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ), 'nickname' => $profile['nickname'], 'fullname' => $profile['name'], 'firstname' => $firstname, 'lastname' => $lastname, - 'photo300' => $a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg', - 'photo100' => $a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg', - 'photo50' => $a->get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg', + 'photo300' => App::get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg', + 'photo100' => App::get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg', + 'photo50' => App::get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg', ); else $diaspora = false; @@ -489,7 +489,7 @@ function get_birthdays() { $url = $rr['url']; if($rr['network'] === NETWORK_DFRN) { $sparkle = " sparkle"; - $url = $a->get_baseurl() . '/redir/' . $rr['cid']; + $url = App::get_baseurl() . '/redir/' . $rr['cid']; } $rr['link'] = $url; @@ -503,7 +503,7 @@ function get_birthdays() { } $tpl = get_markup_template("birthdays_reminder.tpl"); return replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$classtoday' => $classtoday, '$count' => $total, '$event_reminders' => t('Birthday Reminders'), @@ -587,7 +587,7 @@ function get_events() { $tpl = get_markup_template("events_reminder.tpl"); return replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$classtoday' => $classtoday, '$count' => count($r) - $skip, '$event_reminders' => t('Event Reminders'), @@ -685,7 +685,7 @@ function advanced_profile(&$a) { } if ($a->profile['uid'] == local_user()) - $profile['edit'] = array($a->get_baseurl(). '/profiles/'.$a->profile['id'], t('Edit profile'),"", t('Edit profile')); + $profile['edit'] = array(App::get_baseurl(). '/profiles/'.$a->profile['id'], t('Edit profile'),"", t('Edit profile')); return replace_macros($tpl, array( '$title' => t('Profile'), @@ -707,7 +707,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ if(x($_GET,'tab')) $tab = notags(trim($_GET['tab'])); - $url = $a->get_baseurl() . '/profile/' . $nickname; + $url = App::get_baseurl() . '/profile/' . $nickname; $tabs = array( array( @@ -728,7 +728,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ ), array( 'label' => t('Photos'), - 'url' => $a->get_baseurl() . '/photos/' . $nickname, + 'url' => App::get_baseurl() . '/photos/' . $nickname, 'sel' => ((!isset($tab)&&$a->argv[0]=='photos')?'active':''), 'title' => t('Photo Albums'), 'id' => 'photo-tab', @@ -736,7 +736,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ ), array( 'label' => t('Videos'), - 'url' => $a->get_baseurl() . '/videos/' . $nickname, + 'url' => App::get_baseurl() . '/videos/' . $nickname, 'sel' => ((!isset($tab)&&$a->argv[0]=='videos')?'active':''), 'title' => t('Videos'), 'id' => 'video-tab', @@ -748,7 +748,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ if ($is_owner && $a->theme_events_in_profile) { $tabs[] = array( 'label' => t('Events'), - 'url' => $a->get_baseurl() . '/events', + 'url' => App::get_baseurl() . '/events', 'sel' =>((!isset($tab)&&$a->argv[0]=='events')?'active':''), 'title' => t('Events and Calendar'), 'id' => 'events-tab', @@ -759,7 +759,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ } elseif (! $is_owner) { $tabs[] = array( 'label' => t('Events'), - 'url' => $a->get_baseurl() . '/cal/' . $nickname, + 'url' => App::get_baseurl() . '/cal/' . $nickname, 'sel' =>((!isset($tab)&&$a->argv[0]=='cal')?'active':''), 'title' => t('Events and Calendar'), 'id' => 'events-tab', @@ -770,7 +770,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ if ($is_owner){ $tabs[] = array( 'label' => t('Personal Notes'), - 'url' => $a->get_baseurl() . '/notes', + 'url' => App::get_baseurl() . '/notes', 'sel' =>((!isset($tab)&&$a->argv[0]=='notes')?'active':''), 'title' => t('Only You Can See This'), 'id' => 'notes-tab', @@ -781,7 +781,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ if ((! $is_owner) && ((count($a->profile)) || (! $a->profile['hide-friends']))) { $tabs[] = array( 'label' => t('Contacts'), - 'url' => $a->get_baseurl() . '/viewcontacts/' . $nickname, + 'url' => App::get_baseurl() . '/viewcontacts/' . $nickname, 'sel' => ((!isset($tab)&&$a->argv[0]=='viewcontacts')?'active':''), 'title' => t('Contacts'), 'id' => 'viewcontacts-tab', diff --git a/include/items.php b/include/items.php index 9507b5e5fe..20aa2e2e02 100644 --- a/include/items.php +++ b/include/items.php @@ -208,13 +208,12 @@ function add_page_info_data($data) { $hashtags = ""; if (isset($data["keywords"]) AND count($data["keywords"])) { - $a = get_app(); $hashtags = "\n"; foreach ($data["keywords"] AS $keyword) { /// @todo make a positive list of allowed characters $hashtag = str_replace(array(" ", "+", "/", ".", "#", "'", "’", "`", "(", ")", "„", "“"), array("","", "", "", "", "", "", "", "", "", "", ""), $keyword); - $hashtags .= "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url] "; + $hashtags .= "#[url=".App::get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url] "; } } @@ -251,7 +250,6 @@ function add_page_keywords($url, $no_photos = false, $photo = "", $keywords = fa $tags = ""; if (isset($data["keywords"]) AND count($data["keywords"])) { - $a = get_app(); foreach ($data["keywords"] AS $keyword) { $hashtag = str_replace(array(" ", "+", "/", ".", "#", "'"), array("","", "", "", "", ""), $keyword); @@ -259,7 +257,7 @@ function add_page_keywords($url, $no_photos = false, $photo = "", $keywords = fa if ($tags != "") $tags .= ","; - $tags .= "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url]"; + $tags .= "#[url=".App::get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url]"; } } @@ -557,8 +555,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa logger("Both author-link and owner-link are empty. Called by: ".App::callstack(), LOGGER_DEBUG); if ($arr['plink'] == "") { - $a = get_app(); - $arr['plink'] = $a->get_baseurl().'/display/'.urlencode($arr['guid']); + $arr['plink'] = App::get_baseurl().'/display/'.urlencode($arr['guid']); } if ($arr['network'] == "") { @@ -709,7 +706,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa $u = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($arr['uid'])); if (count($u)) { $a = get_app(); - $self = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']); + $self = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']); logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG); if ((normalise_link($arr['author-link']) == $self) OR (normalise_link($arr['owner-link']) == $self)) { q("UPDATE `thread` SET `mention` = 1 WHERE `iid` = %d", intval($parent_id)); @@ -1068,10 +1065,10 @@ function item_body_set_hashtags(&$item) { // All hashtags should point to the home server //$item["body"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", - // "#[url=".$a->get_baseurl()."/search?tag=$2]$2[/url]", $item["body"]); + // "#[url=".App::get_baseurl()."/search?tag=$2]$2[/url]", $item["body"]); //$item["tag"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", - // "#[url=".$a->get_baseurl()."/search?tag=$2]$2[/url]", $item["tag"]); + // "#[url=".App::get_baseurl()."/search?tag=$2]$2[/url]", $item["tag"]); // mask hashtags inside of url, bookmarks and attachments to avoid urls in urls $item["body"] = preg_replace_callback("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", @@ -1103,7 +1100,7 @@ function item_body_set_hashtags(&$item) { $basetag = str_replace('_',' ',substr($tag,1)); - $newtag = '#[url='.$a->get_baseurl().'/search?tag='.rawurlencode($basetag).']'.$basetag.'[/url]'; + $newtag = '#[url='.App::get_baseurl().'/search?tag='.rawurlencode($basetag).']'.$basetag.'[/url]'; $item["body"] = str_replace($tag, $newtag, $item["body"]); @@ -1207,12 +1204,12 @@ function tag_deliver($uid,$item_id) { $item = $i[0]; - $link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']); + $link = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']); // Diaspora uses their own hardwired link URL in @-tags // instead of the one we supply with webfinger - $dlink = normalise_link($a->get_baseurl() . '/u/' . $u[0]['nickname']); + $dlink = normalise_link(App::get_baseurl() . '/u/' . $u[0]['nickname']); $cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER); if ($cnt) { @@ -1312,12 +1309,12 @@ function tgroup_check($uid,$item) { $prvgroup = (($u[0]['page-flags'] == PAGE_PRVGROUP) ? true : false); - $link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']); + $link = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']); // Diaspora uses their own hardwired link URL in @-tags // instead of the one we supply with webfinger - $dlink = normalise_link($a->get_baseurl() . '/u/' . $u[0]['nickname']); + $dlink = normalise_link(App::get_baseurl() . '/u/' . $u[0]['nickname']); $cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER); if ($cnt) { @@ -1572,7 +1569,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) { 'to_name' => $r[0]['username'], 'to_email' => $r[0]['email'], 'uid' => $r[0]['uid'], - 'link' => $a->get_baseurl() . '/notifications/intro', + 'link' => App::get_baseurl() . '/notifications/intro', 'source_name' => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : t('[Name Withheld]')), 'source_link' => $contact_record['url'], 'source_photo' => $contact_record['photo'], @@ -1665,7 +1662,7 @@ function fix_private_photos($s, $uid, $item = null, $cid = 0) { $a = get_app(); logger('fix_private_photos: check for photos', LOGGER_DEBUG); - $site = substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')); + $site = substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')); $orig_body = $s; $new_body = ''; @@ -1929,7 +1926,7 @@ function drop_item($id,$interactive = true) { if (! $interactive) return 0; notice( t('Item not found.') . EOL); - goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); + goaway(App::get_baseurl() . '/' . $_SESSION['return_url']); } $item = $r[0]; @@ -1977,7 +1974,7 @@ function drop_item($id,$interactive = true) { } // Now check how the user responded to the confirmation query if ($_REQUEST['canceled']) { - goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); + goaway(App::get_baseurl() . '/' . $_SESSION['return_url']); } logger('delete item: ' . $item['id'], LOGGER_DEBUG); @@ -2127,13 +2124,13 @@ function drop_item($id,$interactive = true) { if (! $interactive) return $owner; - goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); + goaway(App::get_baseurl() . '/' . $_SESSION['return_url']); //NOTREACHED } else { if (! $interactive) return 0; notice( t('Permission denied.') . EOL); - goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); + goaway(App::get_baseurl() . '/' . $_SESSION['return_url']); //NOTREACHED } diff --git a/include/like.php b/include/like.php index 5b6d1b9e6e..8239633e6a 100644 --- a/include/like.php +++ b/include/like.php @@ -164,7 +164,7 @@ function do_like($item_id, $verb) { if($item['object-type'] === ACTIVITY_OBJ_EVENT) $post_type = t('event'); $objtype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); - $link = xmlify('' . "\n") ; + $link = xmlify('' . "\n") ; $body = $item['body']; $obj = <<< EOT @@ -214,7 +214,7 @@ EOT; $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; - $plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]'; + $plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]'; $arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink ); $arr['verb'] = $activity; diff --git a/include/message.php b/include/message.php index ea2fcef3bc..e5ebe6f915 100644 --- a/include/message.php +++ b/include/message.php @@ -27,7 +27,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){ } $guid = get_guid(32); - $uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $guid; + $uri = 'urn:X-dfrn:' . App::get_baseurl() . ':' . local_user() . ':' . $guid; $convid = 0; $reply = false; @@ -53,7 +53,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){ $recip_host = substr($recip_host,0,strpos($recip_host,'/')); $recip_handle = (($contact[0]['addr']) ? $contact[0]['addr'] : $contact[0]['nick'] . '@' . $recip_host); - $sender_handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3); + $sender_handle = $a->user['nickname'] . '@' . substr(App::get_baseurl(), strpos(App::get_baseurl(),'://') + 3); $conv_guid = get_guid(32); $convuri = $recip_handle.':'.$conv_guid; @@ -134,7 +134,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){ $images = $match[1]; if(count($images)) { foreach($images as $image) { - if(! stristr($image,$a->get_baseurl() . '/photo/')) + if(! stristr($image,App::get_baseurl() . '/photo/')) continue; $image_uri = substr($image,strrpos($image,'/') + 1); $image_uri = substr($image_uri,0, strpos($image_uri,'-')); @@ -164,16 +164,13 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){ - $a = get_app(); - - if(! $recipient) return -1; if(! strlen($subject)) $subject = t('[no subject]'); $guid = get_guid(32); - $uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $guid; + $uri = 'urn:X-dfrn:' . App::get_baseurl() . ':' . local_user() . ':' . $guid; $convid = 0; $reply = false; @@ -187,7 +184,7 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){ $conv_guid = get_guid(32); - $recip_handle = $recipient['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3); + $recip_handle = $recipient['nickname'] . '@' . substr(App::get_baseurl(), strpos(App::get_baseurl(),'://') + 3); $sender_nick = basename($replyto); $sender_host = substr($replyto,strpos($replyto,'://')+3); diff --git a/include/nav.php b/include/nav.php index 2a9f24ca9f..f71272f3b1 100644 --- a/include/nav.php +++ b/include/nav.php @@ -28,7 +28,7 @@ function nav(&$a) { $tpl = get_markup_template('nav.tpl'); $a->page['nav'] .= replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$sitelocation' => $nav_info['sitelocation'], '$nav' => $nav_info['nav'], '$banner' => $nav_info['banner'], @@ -65,7 +65,7 @@ function nav_info(App $a) $myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : ''); - $sitelocation = $myident . substr($a->get_baseurl($ssl_state), strpos($a->get_baseurl($ssl_state), '//') + 2 ); + $sitelocation = $myident . substr(App::get_baseurl($ssl_state), strpos(App::get_baseurl($ssl_state), '//') + 2 ); // nav links: array of array('href', 'text', 'extra css classes', 'title') $nav = array(); diff --git a/include/network.php b/include/network.php index df46d35932..cac77fcdf0 100644 --- a/include/network.php +++ b/include/network.php @@ -513,8 +513,6 @@ function allowed_email($email) { function avatar_img($email) { - $a = get_app(); - $avatar['size'] = 175; $avatar['email'] = $email; $avatar['url'] = ''; @@ -523,7 +521,7 @@ function avatar_img($email) { call_hooks('avatar_lookup', $avatar); if(! $avatar['success']) - $avatar['url'] = $a->get_baseurl() . '/images/person-175.jpg'; + $avatar['url'] = App::get_baseurl() . '/images/person-175.jpg'; logger('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], LOGGER_DEBUG); return $avatar['url']; @@ -569,7 +567,7 @@ function scale_external_images($srctext, $include_link = true, $scale_replace = foreach($matches as $mtch) { logger('scale_external_image: ' . $mtch[1]); - $hostname = str_replace('www.','',substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3)); + $hostname = str_replace('www.','',substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3)); if(stristr($mtch[1],$hostname)) continue; diff --git a/include/notifier.php b/include/notifier.php index 2f9599d072..c4e7df47ac 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -649,7 +649,7 @@ function notifier_run(&$argv, &$argc){ } else { - $params = 'hub.mode=publish&hub.url=' . urlencode( $a->get_baseurl() . '/dfrn_poll/' . $owner['nickname'] ); + $params = 'hub.mode=publish&hub.url=' . urlencode( App::get_baseurl() . '/dfrn_poll/' . $owner['nickname'] ); post_url($h,$params); logger('publish for item '.$item_id.' ' . $h . ' ' . $params . ' returned ' . $a->get_curl_code()); } diff --git a/include/oauth.php b/include/oauth.php index a30232df4a..3d4533d3e0 100644 --- a/include/oauth.php +++ b/include/oauth.php @@ -148,7 +148,7 @@ class FKOAuth1 extends OAuthServer { $_SESSION['mobile-theme'] = get_pconfig($record['uid'], 'system', 'mobile_theme'); $_SESSION['authenticated'] = 1; $_SESSION['page_flags'] = $record['page-flags']; - $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $record['nickname']; + $_SESSION['my_url'] = App::get_baseurl() . '/profile/' . $record['nickname']; $_SESSION['addr'] = $_SERVER['REMOTE_ADDR']; $_SESSION["allow_api"] = true; diff --git a/include/plugin.php b/include/plugin.php index 2d5531f90b..0108ce6216 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -410,13 +410,12 @@ function get_theme_info($theme){ * @return string */ function get_theme_screenshot($theme) { - $a = get_app(); $exts = array('.png','.jpg'); foreach($exts as $ext) { if(file_exists('view/theme/' . $theme . '/screenshot' . $ext)) - return($a->get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext); + return(App::get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext); } - return($a->get_baseurl() . '/images/blank.png'); + return(App::get_baseurl() . '/images/blank.png'); } // install and uninstall theme diff --git a/include/pubsubpublish.php b/include/pubsubpublish.php index 85637facb2..abf973a284 100644 --- a/include/pubsubpublish.php +++ b/include/pubsubpublish.php @@ -21,7 +21,7 @@ function handle_pubsubhubbub($id) { $headers = array("Content-type: application/atom+xml", sprintf("Link: <%s>;rel=hub,<%s>;rel=self", - $a->get_baseurl().'/pubsubhubbub', + App::get_baseurl().'/pubsubhubbub', $rr['topic']), "X-Hub-Signature: sha1=".$hmac_sig); diff --git a/include/redir.php b/include/redir.php index 8d8a035f1d..8d65089de7 100644 --- a/include/redir.php +++ b/include/redir.php @@ -20,7 +20,7 @@ function auto_redir(&$a, $contact_nick) { // // We also have to make sure that I'm a legitimate contact--I'm not blocked or pending. - $baseurl = $a->get_baseurl(); + $baseurl = App::get_baseurl(); $domain_st = strpos($baseurl, "://"); if($domain_st === false) return; diff --git a/include/security.php b/include/security.php index fa698c1b1a..7e14146d94 100644 --- a/include/security.php +++ b/include/security.php @@ -9,8 +9,8 @@ function authenticate_success($user_record, $login_initial = false, $interactive $_SESSION['mobile-theme'] = get_pconfig($user_record['uid'], 'system', 'mobile_theme'); $_SESSION['authenticated'] = 1; $_SESSION['page_flags'] = $user_record['page-flags']; - $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $user_record['nickname']; - $_SESSION['my_address'] = $user_record['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3); + $_SESSION['my_url'] = App::get_baseurl() . '/profile/' . $user_record['nickname']; + $_SESSION['my_address'] = $user_record['nickname'] . '@' . substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3); $_SESSION['addr'] = $_SERVER['REMOTE_ADDR']; $a->user = $user_record; @@ -98,7 +98,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive call_hooks('logged_in', $a->user); if(($a->module !== 'home') && isset($_SESSION['return_url'])) - goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); + goaway(App::get_baseurl() . '/' . $_SESSION['return_url']); } } @@ -378,7 +378,7 @@ function check_form_security_token_redirectOnErr($err_redirect, $typename = '', logger('check_form_security_token failed: user ' . $a->user['guid'] . ' - form element ' . $typename); logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); notice( check_form_security_std_err_msg() ); - goaway($a->get_baseurl() . $err_redirect ); + goaway(App::get_baseurl() . $err_redirect ); } } function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'form_security_token') { diff --git a/include/socgraph.php b/include/socgraph.php index f8a73a0a5c..c5fc31581e 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -207,7 +207,7 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca $orig_updated = $updated; // The global contacts should contain the original picture, not the cached one - if (($generation != 1) AND stristr(normalise_link($profile_photo), normalise_link($a->get_baseurl()."/photo/"))) + if (($generation != 1) AND stristr(normalise_link($profile_photo), normalise_link(App::get_baseurl()."/photo/"))) $profile_photo = ""; $r = q("SELECT `network` FROM `contact` WHERE `nurl` = '%s' AND `network` != '' AND `network` != '%s' LIMIT 1", @@ -1181,9 +1181,9 @@ function update_suggestions() { $done = array(); /// TODO Check if it is really neccessary to poll the own server - poco_load(0,0,0,$a->get_baseurl() . '/poco'); + poco_load(0,0,0,App::get_baseurl() . '/poco'); - $done[] = $a->get_baseurl() . '/poco'; + $done[] = App::get_baseurl() . '/poco'; if(strlen(get_config('system','directory'))) { $x = fetch_url(get_server()."/pubsites"); @@ -1771,8 +1771,6 @@ function gs_fetch_users($server) { logger("Fetching users from GNU Social server ".$server, LOGGER_DEBUG); - $a = get_app(); - $url = $server."/main/statistics"; $result = z_fetch_url($url); @@ -1811,7 +1809,7 @@ function gs_fetch_users($server) { "nick" => $user->nickname, "about" => $user->bio, "network" => NETWORK_OSTATUS, - "photo" => $a->get_baseurl()."/images/person-175.jpg"); + "photo" => App::get_baseurl()."/images/person-175.jpg"); get_gcontact_id($contact); } } diff --git a/include/tags.php b/include/tags.php index 6c1d01d74d..0a09438478 100644 --- a/include/tags.php +++ b/include/tags.php @@ -1,13 +1,11 @@ get_baseurl(); + $profile_base = App::get_baseurl(); $profile_data = parse_url($profile_base); $profile_base_friendica = $profile_data['host'].$profile_data['path']."/profile/"; $profile_base_diaspora = $profile_data['host'].$profile_data['path']."/u/"; - $searchpath = $a->get_baseurl()."/search?tag="; + $searchpath = App::get_baseurl()."/search?tag="; $messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `created`, `received`, `title`, `body`, `tag`, `parent` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid)); diff --git a/include/text.php b/include/text.php index 5856226c37..a2c474d32e 100644 --- a/include/text.php +++ b/include/text.php @@ -23,7 +23,7 @@ function replace_macros($s,$r) { $a = get_app(); // pass $baseurl to all templates - $r['$baseurl'] = $a->get_baseurl(); + $r['$baseurl'] = App::get_baseurl(); $t = $a->template_engine(); diff --git a/include/threads.php b/include/threads.php index 48391174ec..c214cf2644 100644 --- a/include/threads.php +++ b/include/threads.php @@ -267,12 +267,10 @@ function update_threads() { } function update_threads_mention() { - $a = get_app(); - $users = q("SELECT `uid`, `nickname` FROM `user` ORDER BY `uid`"); foreach ($users AS $user) { - $self = normalise_link($a->get_baseurl() . '/profile/' . $user['nickname']); + $self = normalise_link(App::get_baseurl() . '/profile/' . $user['nickname']); $selfhttps = str_replace("http://", "https://", $self); $parents = q("SELECT DISTINCT(`parent`) FROM `item` WHERE `uid` = %d AND ((`owner-link` IN ('%s', '%s')) OR (`author-link` IN ('%s', '%s')))", diff --git a/include/uimport.php b/include/uimport.php index 51672d92b6..0d9ffc35fc 100644 --- a/include/uimport.php +++ b/include/uimport.php @@ -133,7 +133,7 @@ function import_account(&$a, $file) { } $oldbaseurl = $account['baseurl']; - $newbaseurl = $a->get_baseurl(); + $newbaseurl = App::get_baseurl(); $olduid = $account['user']['uid']; unset($account['user']['uid']); @@ -290,5 +290,5 @@ function import_account(&$a, $file) { proc_run(PRIORITY_HIGH, 'include/notifier.php', 'relocate', $newuid); info(t("Done. You can now login with your username and password")); - goaway($a->get_baseurl() . "/login"); + goaway(App::get_baseurl() . "/login"); } diff --git a/mod/admin.php b/mod/admin.php index cf0d8d9ac6..832ca470fe 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -376,7 +376,7 @@ function admin_page_federation(&$a) { '$counts' => $counts, '$version' => FRIENDICA_VERSION, '$legendtext' => sprintf(t('Currently this node is aware of %d nodes from the following platforms:'), $total), - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), )); } @@ -489,7 +489,7 @@ function admin_page_summary(&$a) { '$accounts' => $accounts, '$pending' => array(t('Pending registrations'), $pending), '$version' => array(t('Version'), FRIENDICA_VERSION), - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$platform' => FRIENDICA_PLATFORM, '$codename' => FRIENDICA_CODENAME, '$build' => get_config('system','build'), @@ -527,7 +527,7 @@ function admin_page_site_post(&$a) { * send relocate for every local user * */ - $old_url = $a->get_baseurl(true); + $old_url = App::get_baseurl(true); // Generate host names for relocation the addresses in the format user@address.tld $new_host = str_replace("http://", "@", normalise_link($new_url)); @@ -961,7 +961,7 @@ function admin_page_site(&$a) { '$performance' => t('Performance'), '$worker_title' => t('Worker'), '$relocate'=> t('Relocate - WARNING: advanced function. Could make this server unreachable.'), - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), // name, label, value, help string, extra data... '$sitename' => array('sitename', t("Site name"), $a->config['sitename'],''), '$hostname' => array('hostname', t("Host name"), $a->config['hostname'], ""), @@ -1043,7 +1043,7 @@ function admin_page_site(&$a) { '$old_pager' => array('old_pager', t("Enable old style pager"), get_config('system','old_pager'), t("The old style pager has page numbers but slows down massively the page speed.")), '$only_tag_search' => array('only_tag_search', t("Only search in tags"), get_config('system','only_tag_search'), t("On large systems the text search can slow down the system extremely.")), - '$relocate_url' => array('relocate_url', t("New base url"), $a->get_baseurl(), t("Change base url for this server. Sends relocate message to all DFRN contacts of all users.")), + '$relocate_url' => array('relocate_url', t("New base url"), App::get_baseurl(), t("Change base url for this server. Sends relocate message to all DFRN contacts of all users.")), '$rino' => array('rino', t("RINO Encryption"), intval(get_config('system','rino_encrypt')), t("Encryption layer between nodes."), array("Disabled", "RINO1 (deprecated)", "RINO2")), '$embedly' => array('embedly', t("Embedly API key"), get_config('system','embedly'), t("Embedly is used to fetch additional data for web pages. This is an optional parameter.")), @@ -1131,13 +1131,13 @@ function admin_page_dbsync(&$a) { } if(! count($failed)) { $o = replace_macros(get_markup_template('structure_check.tpl'),array( - '$base' => $a->get_baseurl(true), + '$base' => App::get_baseurl(true), '$banner' => t('No failed updates.'), '$check' => t('Check database structure'), )); } else { $o = replace_macros(get_markup_template('failed_updates.tpl'),array( - '$base' => $a->get_baseurl(true), + '$base' => App::get_baseurl(true), '$banner' => t('Failed Updates'), '$desc' => t('This does not include updates prior to 1139, which did not return a status.'), '$mark' => t('Mark success (if update was manually applied)'), @@ -1205,7 +1205,7 @@ function admin_page_users_post(&$a){ Thank you and welcome to %4$s.')); $preamble = sprintf($preamble, $nu['username'], $a->config['sitename']); - $body = sprintf($body, $a->get_baseurl(), $nu['email'], $result['password'], $a->config['sitename']); + $body = sprintf($body, App::get_baseurl(), $nu['email'], $result['password'], $a->config['sitename']); notification(array( 'type' => "SYSTEM_EMAIL", @@ -1430,7 +1430,7 @@ function admin_page_users(&$a){ '$form_security_token' => get_form_security_token("admin_users"), // values // - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$pending' => $pending, 'deleted' => $deleted, @@ -1522,7 +1522,7 @@ function admin_page_plugins(&$a){ '$page' => t('Plugins'), '$toggle' => t('Toggle'), '$settings' => t('Settings'), - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$plugin' => $plugin, '$status' => $status, @@ -1547,10 +1547,10 @@ function admin_page_plugins(&$a){ */ if(x($_GET,"a") && $_GET['a']=="r") { - check_form_security_token_redirectOnErr($a->get_baseurl().'/admin/plugins', 'admin_themes', 't'); + check_form_security_token_redirectOnErr(App::get_baseurl().'/admin/plugins', 'admin_themes', 't'); reload_plugins(); info("Plugins reloaded"); - goaway($a->get_baseurl().'/admin/plugins'); + goaway(App::get_baseurl().'/admin/plugins'); } $plugins = array(); @@ -1582,7 +1582,7 @@ function admin_page_plugins(&$a){ '$page' => t('Plugins'), '$submit' => t('Save Settings'), '$reload' => t('Reload active plugins'), - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$function' => 'plugins', '$plugins' => $plugins, '$pcount' => count($plugins), @@ -1780,7 +1780,7 @@ function admin_page_themes(&$a){ '$page' => t('Themes'), '$toggle' => t('Toggle'), '$settings' => t('Settings'), - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$plugin' => $theme, '$status' => $status, '$action' => $action, @@ -1799,7 +1799,7 @@ function admin_page_themes(&$a){ // reload active themes if(x($_GET,"a") && $_GET['a']=="r") { - check_form_security_token_redirectOnErr($a->get_baseurl().'/admin/themes', 'admin_themes', 't'); + check_form_security_token_redirectOnErr(App::get_baseurl().'/admin/themes', 'admin_themes', 't'); if($themes) { foreach($themes as $th) { if($th['allowed']) { @@ -1809,7 +1809,7 @@ function admin_page_themes(&$a){ } } info("Themes reloaded"); - goaway($a->get_baseurl().'/admin/themes'); + goaway(App::get_baseurl().'/admin/themes'); } /* @@ -1830,7 +1830,7 @@ function admin_page_themes(&$a){ '$page' => t('Themes'), '$submit' => t('Save Settings'), '$reload' => t('Reload active themes'), - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$function' => 'themes', '$plugins' => $xthemes, '$pcount' => count($themes), @@ -1904,7 +1904,7 @@ function admin_page_logs(&$a){ '$page' => t('Logs'), '$submit' => t('Save Settings'), '$clear' => t('Clear'), - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$logname' => get_config('system','logfile'), // name, label, value, help string, extra data... diff --git a/mod/allfriends.php b/mod/allfriends.php index 240aa524be..1f2c043ced 100644 --- a/mod/allfriends.php +++ b/mod/allfriends.php @@ -60,7 +60,7 @@ function allfriends_content(&$a) { $photo_menu = contact_photo_menu ($rr); } else { - $connlnk = $a->get_baseurl() . '/follow/?url=' . $rr['url']; + $connlnk = App::get_baseurl() . '/follow/?url=' . $rr['url']; $photo_menu = array( 'profile' => array(t("View Profile"), zrl($rr['url'])), 'follow' => array(t("Connect/Follow"), $connlnk) diff --git a/mod/bookmarklet.php b/mod/bookmarklet.php index be8645c1fd..cb8320013f 100644 --- a/mod/bookmarklet.php +++ b/mod/bookmarklet.php @@ -15,7 +15,7 @@ function bookmarklet_content(&$a) { } $referer = normalise_link($_SERVER["HTTP_REFERER"]); - $page = normalise_link($a->get_baseurl()."/bookmarklet"); + $page = normalise_link(App::get_baseurl()."/bookmarklet"); if (!strstr($referer, $page)) { $content = add_page_info($_REQUEST["url"]); diff --git a/mod/cal.php b/mod/cal.php index ba43393284..1899a9899a 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -80,7 +80,7 @@ function cal_content(&$a) { $htpl = get_markup_template('event_head.tpl'); $a->page['htmlhead'] .= replace_macros($htpl,array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$module_url' => '/cal/' . $a->data['user']['nickname'], '$modparams' => 2, '$i18n' => $i18n, @@ -89,7 +89,7 @@ function cal_content(&$a) { $etpl = get_markup_template('event_end.tpl'); $a->page['end'] .= replace_macros($etpl,array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$editselect' => $editselect )); @@ -232,7 +232,7 @@ function cal_content(&$a) { foreach($r as $rr) { $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j')); if(! x($links,$j)) - $links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j; + $links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j; } } @@ -270,12 +270,12 @@ function cal_content(&$a) { } $o = replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$tabs' => $tabs, '$title' => t('Events'), '$view' => t('View'), - '$previus' => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''), - '$next' => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''), + '$previus' => array(App::get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''), + '$next' => array(App::get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''), '$calendar' => cal($y,$m,$links, ' eventcal'), '$events' => $events, diff --git a/mod/contacts.php b/mod/contacts.php index 735ccec727..37cc09cab6 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -78,13 +78,13 @@ function contacts_init(&$a) { $base = z_root(); $tpl = get_markup_template("contacts-head.tpl"); $a->page['htmlhead'] .= replace_macros($tpl,array( - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$base' => $base )); $tpl = get_markup_template("contacts-end.tpl"); $a->page['end'] .= replace_macros($tpl,array( - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$base' => $base )); @@ -480,11 +480,11 @@ function contacts_content(&$a) { $editselect = 'exact'; $a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array( - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$editselect' => $editselect, )); $a->page['end'] .= replace_macros(get_markup_template('contact_end.tpl'), array( - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$editselect' => $editselect, )); @@ -564,7 +564,7 @@ function contacts_content(&$a) { if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS)) AND ($contact['rel'] == CONTACT_IS_FOLLOWER)) - $follow = $a->get_baseurl(true)."/follow?url=".urlencode($contact["url"]); + $follow = App::get_baseurl(true)."/follow?url=".urlencode($contact["url"]); // Load contactact related actions like hide, suggest, delete and others $contact_actions = contact_actions($contact); diff --git a/mod/content.php b/mod/content.php index 1e2307f553..bc98f7e51d 100644 --- a/mod/content.php +++ b/mod/content.php @@ -117,7 +117,7 @@ function content_content(&$a, $update = 0) { if($update) killme(); notice( t('No such group') . EOL ); - goaway($a->get_baseurl(true) . '/network'); + goaway(App::get_baseurl(true) . '/network'); // NOTREACHED } @@ -509,8 +509,8 @@ function render_content(&$a, $items, $mode, $update, $preview = false) { 'like' => '', 'dislike' => '', 'comment' => '', - //'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl($ssl_state) . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))), - 'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl($ssl_state).'/display/'.$item['guid'], 'title'=> t('View in context'))), + //'conv' => (($preview) ? '' : array('href'=> App::get_baseurl($ssl_state) . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))), + 'conv' => (($preview) ? '' : array('href'=> App::get_baseurl($ssl_state).'/display/'.$item['guid'], 'title'=> t('View in context'))), 'previewing' => $previewing, 'wait' => t('Please wait'), ); @@ -743,7 +743,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) { } if(local_user() && link_compare($a->contact['url'],$item['author-link'])) - $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit")); + $edpost = array(App::get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit")); else $edpost = false; diff --git a/mod/delegate.php b/mod/delegate.php index 71628aed0e..343e1e3038 100644 --- a/mod/delegate.php +++ b/mod/delegate.php @@ -18,7 +18,7 @@ function delegate_content(&$a) { // delegated admins can view but not change delegation permissions if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) - goaway($a->get_baseurl() . '/delegate'); + goaway(App::get_baseurl() . '/delegate'); $id = $a->argv[2]; @@ -29,7 +29,7 @@ function delegate_content(&$a) { if (dbm::is_result($r)) { $r = q("select id from contact where uid = %d and nurl = '%s' limit 1", intval(local_user()), - dbesc(normalise_link($a->get_baseurl() . '/profile/' . $r[0]['nickname'])) + dbesc(normalise_link(App::get_baseurl() . '/profile/' . $r[0]['nickname'])) ); if (dbm::is_result($r)) { q("insert into manage ( uid, mid ) values ( %d , %d ) ", @@ -38,7 +38,7 @@ function delegate_content(&$a) { ); } } - goaway($a->get_baseurl() . '/delegate'); + goaway(App::get_baseurl() . '/delegate'); } if($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) { @@ -46,13 +46,13 @@ function delegate_content(&$a) { // delegated admins can view but not change delegation permissions if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) - goaway($a->get_baseurl() . '/delegate'); + goaway(App::get_baseurl() . '/delegate'); q("delete from manage where uid = %d and mid = %d limit 1", intval($a->argv[2]), intval(local_user()) ); - goaway($a->get_baseurl() . '/delegate'); + goaway(App::get_baseurl() . '/delegate'); } @@ -92,7 +92,7 @@ function delegate_content(&$a) { $r = q("select nurl from contact where substring_index(contact.nurl,'/',3) = '%s' and contact.uid = %d and contact.self = 0 and network = '%s' ", - dbesc(normalise_link($a->get_baseurl())), + dbesc(normalise_link(App::get_baseurl())), intval(local_user()), dbesc(NETWORK_DFRN) ); @@ -128,7 +128,7 @@ function delegate_content(&$a) { $o = replace_macros(get_markup_template('delegate.tpl'),array( '$header' => t('Delegate Page Management'), - '$base' => $a->get_baseurl(), + '$base' => App::get_baseurl(), '$desc' => t('Delegates are able to manage all aspects of this account/page except for basic account settings. Please do not delegate your personal account to anybody that you do not trust completely.'), '$head_managers' => t('Existing Page Managers'), '$managers' => $full_managers, diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index df663f7cd4..7097b0117a 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -194,7 +194,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { $params['public_key'] = $public_key; - $my_url = $a->get_baseurl() . '/profile/' . $user[0]['nickname']; + $my_url = App::get_baseurl() . '/profile/' . $user[0]['nickname']; openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey); $params['source_url'] = bin2hex($params['source_url']); @@ -504,7 +504,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { // do anything special with this new friend. if($handsfree === null) - goaway($a->get_baseurl() . '/contacts/' . intval($contact_id)); + goaway(App::get_baseurl() . '/contacts/' . intval($contact_id)); else return; //NOTREACHED @@ -664,7 +664,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { if (dbm::is_result($r)) $photo = $r[0]['photo']; else - $photo = $a->get_baseurl() . '/images/person-175.jpg'; + $photo = App::get_baseurl() . '/images/person-175.jpg'; require_once("include/Photo.php"); @@ -726,7 +726,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { 'to_name' => $r[0]['username'], 'to_email' => $r[0]['email'], 'uid' => $r[0]['uid'], - 'link' => $a->get_baseurl() . '/contacts/' . $dfrn_record, + 'link' => App::get_baseurl() . '/contacts/' . $dfrn_record, 'source_name' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')), 'source_link' => $r[0]['url'], 'source_photo' => $r[0]['photo'], diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 91cd33f49a..7c3fced12f 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -112,7 +112,7 @@ function dfrn_poll_init(&$a) { } } $profile = $r[0]['nickname']; - goaway((strlen($destination_url)) ? $destination_url : $a->get_baseurl() . '/profile/' . $profile); + goaway((strlen($destination_url)) ? $destination_url : App::get_baseurl() . '/profile/' . $profile); } goaway(z_root()); @@ -499,14 +499,14 @@ function dfrn_poll_content(&$a) { switch($destination_url) { case 'profile': - $dest = $a->get_baseurl() . '/profile/' . $profile . '?f=&tab=profile'; + $dest = App::get_baseurl() . '/profile/' . $profile . '?f=&tab=profile'; break; case 'photos': - $dest = $a->get_baseurl() . '/photos/' . $profile; + $dest = App::get_baseurl() . '/photos/' . $profile; break; case 'status': case '': - $dest = $a->get_baseurl() . '/profile/' . $profile; + $dest = App::get_baseurl() . '/profile/' . $profile; break; default: $dest = $destination_url . '?f=&redir=1'; diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 236970a2e9..24a1dc0725 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -193,9 +193,9 @@ function dfrn_request_post(&$a) { if (isset($photo)) update_contact_avatar($photo, local_user(), $r[0]["id"], true); - $forwardurl = $a->get_baseurl()."/contacts/".$r[0]['id']; + $forwardurl = App::get_baseurl()."/contacts/".$r[0]['id']; } else - $forwardurl = $a->get_baseurl()."/contacts"; + $forwardurl = App::get_baseurl()."/contacts"; /* * Allow the blocked remote notification to complete @@ -501,13 +501,13 @@ function dfrn_request_post(&$a) { else { if(! validate_url($url)) { notice( t('Invalid profile URL.') . EOL); - goaway($a->get_baseurl() . '/' . $a->cmd); + goaway(App::get_baseurl() . '/' . $a->cmd); return; // NOTREACHED } if(! allowed_url($url)) { notice( t('Disallowed profile URL.') . EOL); - goaway($a->get_baseurl() . '/' . $a->cmd); + goaway(App::get_baseurl() . '/' . $a->cmd); return; // NOTREACHED } @@ -518,7 +518,7 @@ function dfrn_request_post(&$a) { if(! count($parms)) { notice( t('Profile location is not valid or does not contain profile information.') . EOL ); - goaway($a->get_baseurl() . '/' . $a->cmd); + goaway(App::get_baseurl() . '/' . $a->cmd); } else { if(! x($parms,'fn')) @@ -605,7 +605,7 @@ function dfrn_request_post(&$a) { // "Homecoming" - send the requestor back to their site to record the introduction. - $dfrn_url = bin2hex($a->get_baseurl() . '/profile/' . $nickname); + $dfrn_url = bin2hex(App::get_baseurl() . '/profile/' . $nickname); $aes_allow = ((function_exists('openssl_encrypt')) ? 1 : 0); goaway($parms['dfrn-request'] . "?dfrn_url=$dfrn_url" @@ -634,7 +634,7 @@ function dfrn_request_post(&$a) { $uri = urlencode($uri); } else - $uri = $a->get_baseurl().'/profile/'.$nickname; + $uri = App::get_baseurl().'/profile/'.$nickname; $url = str_replace('{uri}', $uri, $url); goaway($url); @@ -742,7 +742,7 @@ function dfrn_request_content(&$a) { 'to_name' => $r[0]['username'], 'to_email' => $r[0]['email'], 'uid' => $r[0]['uid'], - 'link' => $a->get_baseurl() . '/notifications/intros', + 'link' => App::get_baseurl() . '/notifications/intros', 'source_name' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')), 'source_link' => $r[0]['url'], 'source_photo' => $r[0]['photo'], @@ -806,7 +806,7 @@ function dfrn_request_content(&$a) { $myaddr = $_GET['address']; elseif(local_user()) { if(strlen($a->path)) { - $myaddr = $a->get_baseurl() . '/profile/' . $a->user['nickname']; + $myaddr = App::get_baseurl() . '/profile/' . $a->user['nickname']; } else { $myaddr = $a->user['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 ); diff --git a/mod/dirfind.php b/mod/dirfind.php index 215731978c..1e3f6f354a 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -197,7 +197,7 @@ function dirfind_content(&$a, $prefix = "") { } else $photo_menu = array(); } else { - $connlnk = $a->get_baseurl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url); + $connlnk = App::get_baseurl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url); $conntxt = t('Connect'); $photo_menu = array( 'profile' => array(t("View Profile"), zrl($jj->url)), diff --git a/mod/display.php b/mod/display.php index 293156cf19..6ebe16ae8a 100644 --- a/mod/display.php +++ b/mod/display.php @@ -81,8 +81,8 @@ function display_init(&$a) { $profiledata = display_fetchauthor($a, $r[0]); - if (strstr(normalise_link($profiledata["url"]), normalise_link($a->get_baseurl()))) { - $nickname = str_replace(normalise_link($a->get_baseurl())."/profile/", "", normalise_link($profiledata["url"])); + if (strstr(normalise_link($profiledata["url"]), normalise_link(App::get_baseurl()))) { + $nickname = str_replace(normalise_link(App::get_baseurl())."/profile/", "", normalise_link($profiledata["url"])); if (($nickname != $a->user["nickname"])) { $r = qu("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile` @@ -184,7 +184,7 @@ function display_fetchauthor($a, $item) { if (local_user()) { if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) { - $profiledata["remoteconnect"] = $a->get_baseurl()."/follow?url=".urlencode($profiledata["url"]); + $profiledata["remoteconnect"] = App::get_baseurl()."/follow?url=".urlencode($profiledata["url"]); } } elseif ($profiledata["network"] == NETWORK_DFRN) { $connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]); diff --git a/mod/editpost.php b/mod/editpost.php index 217d793f52..eccd498d15 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -42,7 +42,7 @@ function editpost_content(&$a) { $tpl = get_markup_template('jot-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$ispublic' => ' ', // t('Visible to everybody'), '$geotag' => $geotag, @@ -51,7 +51,7 @@ function editpost_content(&$a) { $tpl = get_markup_template('jot-end.tpl'); $a->page['end'] .= replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$ispublic' => ' ', // t('Visible to everybody'), '$geotag' => $geotag, @@ -126,7 +126,7 @@ function editpost_content(&$a) { '$ptyp' => $itm[0]['type'], '$content' => undo_post_tagging($itm[0]['body']), '$post_id' => $post_id, - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$defloc' => $a->user['default-location'], '$visitor' => 'none', '$pvisit' => 'none', diff --git a/mod/events.php b/mod/events.php index 7cb171f9e5..9dbf7efb53 100644 --- a/mod/events.php +++ b/mod/events.php @@ -89,7 +89,7 @@ function events_post(&$a) { $type = 'event'; $action = ($event_id == '') ? 'new' : "event/" . $event_id; - $onerror_url = $a->get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish"; + $onerror_url = App::get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish"; if(strcmp($finish,$start) < 0 && !$nofinish) { notice( t('Event can not end before it has started.') . EOL); @@ -192,7 +192,7 @@ function events_content(&$a) { } if($a->argc == 1) - $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; + $_SESSION['return_url'] = App::get_baseurl() . '/' . $a->cmd; if(($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) { $r = q("update event set ignore = 1 where id = %d and uid = %d", @@ -222,7 +222,7 @@ function events_content(&$a) { $htpl = get_markup_template('event_head.tpl'); $a->page['htmlhead'] .= replace_macros($htpl,array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$module_url' => '/events', '$modparams' => 1, '$i18n' => $i18n, @@ -231,7 +231,7 @@ function events_content(&$a) { $etpl = get_markup_template('event_end.tpl'); $a->page['end'] .= replace_macros($etpl,array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$editselect' => $editselect )); @@ -337,7 +337,7 @@ function events_content(&$a) { foreach($r as $rr) { $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j')); if(! x($links,$j)) - $links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j; + $links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j; } } @@ -375,13 +375,13 @@ function events_content(&$a) { } $o = replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$tabs' => $tabs, '$title' => t('Events'), '$view' => t('View'), - '$new_event' => array($a->get_baseurl().'/events/new',t('Create New Event'),'',''), - '$previus' => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''), - '$next' => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''), + '$new_event' => array(App::get_baseurl().'/events/new',t('Create New Event'),'',''), + '$previus' => array(App::get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''), + '$next' => array(App::get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''), '$calendar' => cal($y,$m,$links, ' eventcal'), '$events' => $events, @@ -475,7 +475,7 @@ function events_content(&$a) { $tpl = get_markup_template('event_form.tpl'); $o .= replace_macros($tpl,array( - '$post' => $a->get_baseurl() . '/events', + '$post' => App::get_baseurl() . '/events', '$eid' => $eid, '$cid' => $cid, '$uri' => $uri, diff --git a/mod/fbrowser.php b/mod/fbrowser.php index 11ac2d8253..6af97368fb 100644 --- a/mod/fbrowser.php +++ b/mod/fbrowser.php @@ -10,6 +10,7 @@ require_once('include/Photo.php'); /** * @param App $a */ +/// @TODO & is missing or App ? function fbrowser_content($a){ if (!local_user()) @@ -83,9 +84,9 @@ function fbrowser_content($a){ $scale = $rr['loq']; return array( - $a->get_baseurl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'], + App::get_baseurl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'], $filename_e, - $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext + App::get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext ); } $files = array_map("_map_files1", $r); @@ -94,7 +95,7 @@ function fbrowser_content($a){ $o = replace_macros($tpl, array( '$type' => 'image', - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$path' => $path, '$folders' => $albums, '$files' =>$files, @@ -122,7 +123,7 @@ function fbrowser_content($a){ $filename_e = $rr['filename']; } - return array( $a->get_baseurl() . '/attach/' . $rr['id'], $filename_e, $a->get_baseurl() . '/images/icons/16/' . $filetype . '.png'); + return array( App::get_baseurl() . '/attach/' . $rr['id'], $filename_e, App::get_baseurl() . '/images/icons/16/' . $filetype . '.png'); } $files = array_map("_map_files2", $files); @@ -130,7 +131,7 @@ function fbrowser_content($a){ $tpl = get_markup_template($template_file); $o = replace_macros($tpl, array( '$type' => 'file', - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$path' => array( array( "", t("Files")) ), '$folders' => false, '$files' =>$files, diff --git a/mod/friendica.php b/mod/friendica.php index fb25f40e45..5d8e43e6cb 100644 --- a/mod/friendica.php +++ b/mod/friendica.php @@ -15,7 +15,7 @@ function friendica_init(&$a) { $r = q("SELECT username, nickname FROM user WHERE email='%s' $sql_extra", dbesc($adminlist[0])); $admin = array( 'name' => $r[0]['username'], - 'profile'=> $a->get_baseurl().'/profile/'.$r[0]['nickname'], + 'profile'=> App::get_baseurl().'/profile/'.$r[0]['nickname'], ); } else { $admin = false; @@ -49,7 +49,7 @@ function friendica_init(&$a) { 'site_name' => $a->config['sitename'], 'platform' => FRIENDICA_PLATFORM, 'info' => ((x($a->config,'info')) ? $a->config['info'] : ''), - 'no_scrape_url' => $a->get_baseurl().'/noscrape' + 'no_scrape_url' => App::get_baseurl().'/noscrape' ); echo json_encode($data); diff --git a/mod/group.php b/mod/group.php index db92ed7de6..33b819ed5d 100644 --- a/mod/group.php +++ b/mod/group.php @@ -29,11 +29,11 @@ function group_post(&$a) { info( t('Group created.') . EOL ); $r = group_byname(local_user(),$name); if($r) - goaway($a->get_baseurl() . '/group/' . $r); + goaway(App::get_baseurl() . '/group/' . $r); } else notice( t('Could not create group.') . EOL ); - goaway($a->get_baseurl() . '/group'); + goaway(App::get_baseurl() . '/group'); return; // NOTREACHED } if(($a->argc == 2) && (intval($a->argv[1]))) { @@ -45,7 +45,7 @@ function group_post(&$a) { ); if(! dbm::is_result($r)) { notice( t('Group not found.') . EOL ); - goaway($a->get_baseurl() . '/contacts'); + goaway(App::get_baseurl() . '/contacts'); return; // NOTREACHED } $group = $r[0]; @@ -114,7 +114,7 @@ function group_content(&$a) { else notice( t('Unable to remove group.') . EOL); } - goaway($a->get_baseurl() . '/group'); + goaway(App::get_baseurl() . '/group'); // NOTREACHED } @@ -138,7 +138,7 @@ function group_content(&$a) { ); if(! dbm::is_result($r)) { notice( t('Group not found.') . EOL ); - goaway($a->get_baseurl() . '/contacts'); + goaway(App::get_baseurl() . '/contacts'); } $group = $r[0]; $members = group_get_members($group['id']); diff --git a/mod/hcard.php b/mod/hcard.php index 6d2d9e2ebf..1231d71e62 100644 --- a/mod/hcard.php +++ b/mod/hcard.php @@ -38,14 +38,14 @@ function hcard_init(&$a) { } $a->page['htmlhead'] .= '' . "\r\n" ; - $a->page['htmlhead'] .= '' . "\r\n" ; + $a->page['htmlhead'] .= '' . "\r\n" ; $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : '')); - $a->page['htmlhead'] .= '' . "\r\n"; - header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false); + $a->page['htmlhead'] .= '' . "\r\n"; + header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false); $dfrn_pages = array('request', 'confirm', 'notify', 'poll'); foreach($dfrn_pages as $dfrn) - $a->page['htmlhead'] .= "get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n"; + $a->page['htmlhead'] .= "\r\n"; } diff --git a/mod/home.php b/mod/home.php index cdf4b37158..62ee9868fb 100644 --- a/mod/home.php +++ b/mod/home.php @@ -7,11 +7,11 @@ function home_init(&$a) { call_hooks('home_init',$ret); if(local_user() && ($a->user['nickname'])) - goaway($a->get_baseurl()."/network"); - //goaway($a->get_baseurl()."/profile/".$a->user['nickname']); + goaway(App::get_baseurl()."/network"); + //goaway(App::get_baseurl()."/profile/".$a->user['nickname']); if(strlen(get_config('system','singleuser'))) - goaway($a->get_baseurl()."/profile/" . get_config('system','singleuser')); + goaway(App::get_baseurl()."/profile/" . get_config('system','singleuser')); }} @@ -28,7 +28,7 @@ function home_content(&$a) { if(file_exists('home.html')){ if(file_exists('home.css')){ - $a->page['htmlhead'] .= '';} + $a->page['htmlhead'] .= '';} $o .= file_get_contents('home.html');} diff --git a/mod/ignored.php b/mod/ignored.php index ba55c55e36..eec204c708 100644 --- a/mod/ignored.php +++ b/mod/ignored.php @@ -35,7 +35,7 @@ function ignored_init(&$a) { if(strpos($return_path, '?')) $rand = "&$rand"; else $rand = "?$rand"; - goaway($a->get_baseurl() . "/" . $return_path . $rand); + goaway(App::get_baseurl() . "/" . $return_path . $rand); } // the json doesn't really matter, it will either be 0 or 1 diff --git a/mod/install.php b/mod/install.php index b5af1373a4..c5baa17db2 100755 --- a/mod/install.php +++ b/mod/install.php @@ -15,7 +15,7 @@ function install_init(&$a){ // We overwrite current theme css, because during install we could not have a working mod_rewrite // so we could not have a css at all. Here we set a static css file for the install procedure pages $a->config['system']['theme'] = "../install"; - $a->theme['stylesheet'] = $a->get_baseurl()."/view/install/style.css"; + $a->theme['stylesheet'] = App::get_baseurl()."/view/install/style.css"; @@ -231,7 +231,7 @@ function install_content(&$a) { '$next' => t('Next'), '$reload' => t('Check again'), '$phpath' => $phpath, - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), )); return $o; }; break; @@ -265,7 +265,7 @@ function install_content(&$a) { '$lbl_10' => t('Please select a default timezone for your website'), - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$phpath' => $phpath, @@ -305,7 +305,7 @@ function install_content(&$a) { '$timezone' => field_timezone('timezone', t('Please select a default timezone for your website'), $timezone, ''), '$language' => array('language', t('System Language:'), 'en', t('Set the default language for your Friendica installation interface and to send emails.'), $lang_choices), - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), @@ -518,14 +518,13 @@ function check_smarty3(&$checks) { } function check_htaccess(&$checks) { - $a = get_app(); $status = true; $help = ""; if (function_exists('curl_init')){ - $test = fetch_url($a->get_baseurl()."/install/testrewrite"); + $test = fetch_url(App::get_baseurl()."/install/testrewrite"); if ($test!="ok") - $test = fetch_url(normalise_link($a->get_baseurl()."/install/testrewrite")); + $test = fetch_url(normalise_link(App::get_baseurl()."/install/testrewrite")); if ($test!="ok") { $status = false; @@ -599,8 +598,7 @@ function load_database($db) { } function what_next() { - $a = get_app(); - $baseurl = $a->get_baseurl(); + $baseurl = App::get_baseurl(); return t('

What next

') ."

".t('IMPORTANT: You will need to [manually] setup a scheduled task for the poller.') diff --git a/mod/invite.php b/mod/invite.php index ccf876c7c0..5964acac43 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -119,7 +119,7 @@ function invite_content(&$a) { 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'); 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.'), $a->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'); } else { @@ -135,7 +135,7 @@ function invite_content(&$a) { '$default_message' => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n" . $linktxt . "\r\n" . "\r\n" . (($invonly) ? t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') .t('Once you have registered, please connect with me via my profile page at:') - . "\r\n" . "\r\n" . $a->get_baseurl() . '/profile/' . $a->user['nickname'] + . "\r\n" . "\r\n" . App::get_baseurl() . '/profile/' . $a->user['nickname'] . "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendica.com') . "\r\n" . "\r\n" , '$submit' => t('Submit') )); diff --git a/mod/item.php b/mod/item.php index 9ef82616c3..c741f16144 100644 --- a/mod/item.php +++ b/mod/item.php @@ -62,7 +62,7 @@ function item_post(&$a) { if(!$preview && x($_REQUEST['post_id_random'])) { if(x($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) { logger("item post: duplicate post", LOGGER_DEBUG); - item_post_return($a->get_baseurl(), $api_source, $return_path); + item_post_return(App::get_baseurl(), $api_source, $return_path); } else $_SESSION['post-random'] = $_REQUEST['post_id_random']; @@ -449,7 +449,7 @@ function item_post(&$a) { $objecttype = ACTIVITY_OBJ_IMAGE; foreach($images as $image) { - if(! stristr($image,$a->get_baseurl() . '/photo/')) + if(! stristr($image,App::get_baseurl() . '/photo/')) continue; $image_uri = substr($image,strrpos($image,'/') + 1); $image_uri = substr($image_uri,0, strpos($image_uri,'-')); @@ -640,7 +640,7 @@ function item_post(&$a) { if (dbm::is_result($r)) { if(strlen($attachments)) $attachments .= ','; - $attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]'; + $attachments .= '[attach]href="' . App::get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]'; } $body = str_replace($match[1],'',$body); } @@ -732,7 +732,7 @@ function item_post(&$a) { // $datarray['prvnets'] = $user['prvnets']; $datarray['parent-uri'] = ($parent == 0) ? $uri : $parent_item['uri']; - $datarray['plink'] = $a->get_baseurl().'/display/'.urlencode($datarray['guid']); + $datarray['plink'] = App::get_baseurl().'/display/'.urlencode($datarray['guid']); $datarray['last-child'] = 1; $datarray['visible'] = 1; @@ -766,7 +766,7 @@ function item_post(&$a) { $json = array('cancel' => 1); if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) - $json['reload'] = $a->get_baseurl() . '/' . $_REQUEST['jsreload']; + $json['reload'] = App::get_baseurl() . '/' . $_REQUEST['jsreload']; echo json_encode($json); killme(); @@ -938,7 +938,7 @@ function item_post(&$a) { 'to_email' => $user['email'], 'uid' => $user['uid'], 'item' => $datarray, - 'link' => $a->get_baseurl().'/display/'.urlencode($datarray['guid']), + 'link' => App::get_baseurl().'/display/'.urlencode($datarray['guid']), 'source_name' => $datarray['author-name'], 'source_link' => $datarray['author-link'], 'source_photo' => $datarray['author-avatar'], @@ -970,7 +970,7 @@ function item_post(&$a) { 'to_email' => $user['email'], 'uid' => $user['uid'], 'item' => $datarray, - 'link' => $a->get_baseurl().'/display/'.urlencode($datarray['guid']), + 'link' => App::get_baseurl().'/display/'.urlencode($datarray['guid']), 'source_name' => $datarray['author-name'], 'source_link' => $datarray['author-link'], 'source_photo' => $datarray['author-avatar'], @@ -991,14 +991,14 @@ function item_post(&$a) { continue; $disclaimer = '


' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'),$a->user['username']) . '
'; - $disclaimer .= sprintf( t('You may visit them online at %s'), $a->get_baseurl() . '/profile/' . $a->user['nickname']) . EOL; + $disclaimer .= sprintf( t('You may visit them online at %s'), App::get_baseurl() . '/profile/' . $a->user['nickname']) . EOL; $disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL; if (!$datarray['title']=='') { $subject = email_header_encode($datarray['title'],'UTF-8'); } else { $subject = email_header_encode('[Friendica]' . ' ' . sprintf( t('%s posted an update.'),$a->user['username']),'UTF-8'); } - $link = '' . $a->user['username'] . '

'; + $link = '' . $a->user['username'] . '

'; $html = prepare_body($datarray); $message = '' . $link . $html . $disclaimer . ''; include_once('include/html2plain.php'); @@ -1038,7 +1038,7 @@ function item_post(&$a) { logger('post_complete'); - item_post_return($a->get_baseurl(), $api_source, $return_path); + item_post_return(App::get_baseurl(), $api_source, $return_path); // NOTREACHED } diff --git a/mod/like.php b/mod/like.php index 8d383b9abe..cbab9185e4 100755 --- a/mod/like.php +++ b/mod/like.php @@ -24,7 +24,7 @@ function like_content(&$a) { // See if we've been passed a return path to redirect to $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); - like_content_return($a->get_baseurl(), $return_path); + like_content_return(App::get_baseurl(), $return_path); killme(); // NOTREACHED // return; // NOTREACHED } diff --git a/mod/localtime.php b/mod/localtime.php index d1453bc527..ce6bf84a12 100644 --- a/mod/localtime.php +++ b/mod/localtime.php @@ -36,7 +36,7 @@ function localtime_content(&$a) { $o .= '

' . sprintf( t('Converted localtime: %s'),$a->data['mod-localtime']) . '

'; - $o .= '
'; + $o .= ''; $o .= '

' . t('Please select your timezone:') . '

'; diff --git a/mod/lostpass.php b/mod/lostpass.php index 3dca3a8b81..122024d26b 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -36,8 +36,7 @@ function lostpass_post(&$a) { $sitename = $a->config['sitename']; - $siteurl = $a->get_baseurl(); - $resetlink = $a->get_baseurl() . '/lostpass?verify=' . $new_password; + $resetlink = App::get_baseurl() . '/lostpass?verify=' . $new_password; $preamble = deindent(t(' Dear %1$s, @@ -64,7 +63,7 @@ function lostpass_post(&$a) { Login Name: %3$s')); $preamble = sprintf($preamble, $username, $sitename); - $body = sprintf($body, $resetlink, $siteurl, $email); + $body = sprintf($body, $resetlink, App::get_baseurl(), $email); notification(array( 'type' => "SYSTEM_EMAIL", @@ -110,17 +109,16 @@ function lostpass_content(&$a) { '$lbl2' => t('Your password has been reset as requested.'), '$lbl3' => t('Your new password is'), '$lbl4' => t('Save or copy your new password - and then'), - '$lbl5' => '' . t('click here to login') . '.', + '$lbl5' => '' . t('click here to login') . '.', '$lbl6' => t('Your password may be changed from the Settings page after successful login.'), '$newpass' => $new_password, - '$baseurl' => $a->get_baseurl() + '$baseurl' => App::get_baseurl() )); info("Your password has been reset." . EOL); $sitename = $a->config['sitename']; - $siteurl = $a->get_baseurl(); // $username, $email, $new_password $preamble = deindent(t(' Dear %1$s, @@ -139,7 +137,7 @@ function lostpass_content(&$a) { ')); $preamble = sprintf($preamble, $username); - $body = sprintf($body, $siteurl, $email, $new_password); + $body = sprintf($body, App::get_baseurl(), $email, $new_password); notification(array( 'type' => "SYSTEM_EMAIL", diff --git a/mod/manage.php b/mod/manage.php index 66891db720..4a4f0a9e37 100644 --- a/mod/manage.php +++ b/mod/manage.php @@ -84,7 +84,7 @@ function manage_post(&$a) { $ret = array(); call_hooks('home_init',$ret); - goaway( $a->get_baseurl() . "/profile/" . $a->user['nickname'] ); + goaway( App::get_baseurl() . "/profile/" . $a->user['nickname'] ); // NOTREACHED } diff --git a/mod/message.php b/mod/message.php index 9bd5b0d722..0a2c797b42 100644 --- a/mod/message.php +++ b/mod/message.php @@ -24,17 +24,17 @@ function message_init(&$a) { '$tabs'=>$tabs, '$new'=>$new, )); - $base = $a->get_baseurl(); + $base = App::get_baseurl(); $head_tpl = get_markup_template('message-head.tpl'); $a->page['htmlhead'] .= replace_macros($head_tpl,array( - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$base' => $base )); $end_tpl = get_markup_template('message-end.tpl'); $a->page['end'] .= replace_macros($end_tpl,array( - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$base' => $base )); @@ -183,7 +183,7 @@ function message_content(&$a) { return; } - $myprofile = $a->get_baseurl().'/profile/' . $a->user['nickname']; + $myprofile = App::get_baseurl().'/profile/' . $a->user['nickname']; $tpl = get_markup_template('mail_head.tpl'); $header = replace_macros($tpl, array( @@ -234,7 +234,7 @@ function message_content(&$a) { if($r) { info( t('Message deleted.') . EOL ); } - //goaway($a->get_baseurl(true) . '/message' ); + //goaway(App::get_baseurl(true) . '/message' ); goaway($_SESSION['return_url']); } else { @@ -265,7 +265,7 @@ function message_content(&$a) { if($r) info( t('Conversation removed.') . EOL ); } - //goaway($a->get_baseurl(true) . '/message' ); + //goaway(App::get_baseurl(true) . '/message' ); goaway($_SESSION['return_url']); } @@ -285,7 +285,7 @@ function message_content(&$a) { $tpl = get_markup_template('msg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$nickname' => $a->user['nickname'], '$linkurl' => t('Please enter a link URL:') @@ -293,7 +293,7 @@ function message_content(&$a) { $tpl = get_markup_template('msg-end.tpl'); $a->page['end'] .= replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$nickname' => $a->user['nickname'], '$linkurl' => t('Please enter a link URL:') @@ -438,7 +438,7 @@ function message_content(&$a) { $tpl = get_markup_template('msg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$nickname' => $a->user['nickname'], '$linkurl' => t('Please enter a link URL:') @@ -446,7 +446,7 @@ function message_content(&$a) { $tpl = get_markup_template('msg-end.tpl'); $a->page['end'] .= replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$nickname' => $a->user['nickname'], '$linkurl' => t('Please enter a link URL:') @@ -573,7 +573,7 @@ function render_messages(array $msg, $t) { $tpl = get_markup_template($t); $rslt = ''; - $myprofile = $a->get_baseurl().'/profile/' . $a->user['nickname']; + $myprofile = App::get_baseurl().'/profile/' . $a->user['nickname']; foreach($msg as $rr) { diff --git a/mod/mood.php b/mod/mood.php index c64dd0d9ef..e378b9d0a4 100644 --- a/mod/mood.php +++ b/mod/mood.php @@ -91,7 +91,7 @@ function mood_init(&$a) { $item_id = item_store($arr); if($item_id) { q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d", - dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id), + dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id), intval($uid), intval($item_id) ); diff --git a/mod/msearch.php b/mod/msearch.php index 43b200ddf8..ba7a92d64e 100644 --- a/mod/msearch.php +++ b/mod/msearch.php @@ -29,8 +29,8 @@ function msearch_post(&$a) { foreach($r as $rr) $results[] = array( 'name' => $rr['name'], - 'url' => $a->get_baseurl() . '/profile/' . $rr['nickname'], - 'photo' => $a->get_baseurl() . '/photo/avatar/' . $rr['uid'] . '.jpg', + 'url' => App::get_baseurl() . '/profile/' . $rr['nickname'], + 'photo' => App::get_baseurl() . '/photo/avatar/' . $rr['uid'] . '.jpg', 'tags' => str_replace(array(',',' '),array(' ',' '),$rr['pub_keywords']) ); } diff --git a/mod/navigation.php b/mod/navigation.php index 5db69b171e..cba950a431 100644 --- a/mod/navigation.php +++ b/mod/navigation.php @@ -12,7 +12,7 @@ function navigation_content(&$a) { $tpl = get_markup_template('navigation.tpl'); return replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$sitelocation' => $nav_info['sitelocation'], '$nav' => $nav_info['nav'], '$banner' => $nav_info['banner'], diff --git a/mod/network.php b/mod/network.php index 9cfeda1026..057ef79145 100644 --- a/mod/network.php +++ b/mod/network.php @@ -100,7 +100,7 @@ function network_init(&$a) { $redir_url = ($net_queries ? $net_baseurl."?".$net_queries : $net_baseurl); - goaway($a->get_baseurl() . $redir_url); + goaway(App::get_baseurl() . $redir_url); } } diff --git a/mod/nodeinfo.php b/mod/nodeinfo.php index 5c70603468..e55dba128f 100644 --- a/mod/nodeinfo.php +++ b/mod/nodeinfo.php @@ -13,7 +13,7 @@ function nodeinfo_wellknown(&$a) { killme(); } $nodeinfo = array("links" => array(array("rel" => "http://nodeinfo.diaspora.software/ns/schema/1.0", - "href" => $a->get_baseurl()."/nodeinfo/1.0"))); + "href" => App::get_baseurl()."/nodeinfo/1.0"))); header('Content-type: application/json; charset=utf-8'); echo json_encode($nodeinfo, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES); diff --git a/mod/noscrape.php b/mod/noscrape.php index 537aff878f..289d0499e0 100644 --- a/mod/noscrape.php +++ b/mod/noscrape.php @@ -34,7 +34,7 @@ function noscrape_init(&$a) { 'addr' => $a->profile['addr'], 'nick' => $which, 'key' => $a->profile['pubkey'], - 'homepage' => $a->get_baseurl()."/profile/{$which}", + 'homepage' => App::get_baseurl()."/profile/{$which}", 'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY), 'photo' => $r[0]["photo"], 'tags' => $keywords @@ -64,7 +64,7 @@ function noscrape_init(&$a) { $dfrn_pages = array('request', 'confirm', 'notify', 'poll'); foreach($dfrn_pages as $dfrn) - $json_info["dfrn-{$dfrn}"] = $a->get_baseurl()."/dfrn_{$dfrn}/{$which}"; + $json_info["dfrn-{$dfrn}"] = App::get_baseurl()."/dfrn_{$dfrn}/{$which}"; //Output all the JSON! header('Content-type: application/json; charset=utf-8'); diff --git a/mod/notice.php b/mod/notice.php index 7fdf4493a4..71c4977be9 100644 --- a/mod/notice.php +++ b/mod/notice.php @@ -8,7 +8,7 @@ ); if (dbm::is_result($r)){ $nick = $r[0]['nickname']; - $url = $a->get_baseurl()."/display/$nick/$id"; + $url = App::get_baseurl()."/display/$nick/$id"; goaway($url); } else { $a->error = 404; diff --git a/mod/notify.php b/mod/notify.php index dceb326a4b..092639735d 100644 --- a/mod/notify.php +++ b/mod/notify.php @@ -18,13 +18,13 @@ function notify_init(&$a) { $guid = basename($urldata["path"]); $itemdata = get_item_id($guid, local_user()); if ($itemdata["id"] != 0) - $note['link'] = $a->get_baseurl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"]; + $note['link'] = App::get_baseurl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"]; } goaway($note['link']); } - goaway($a->get_baseurl(true)); + goaway(App::get_baseurl(true)); } if($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) { @@ -50,7 +50,7 @@ function notify_content(&$a) { if (dbm::is_result($r) > 0) { foreach ($r as $it) { $notif_content .= replace_macros($not_tpl,array( - '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'], + '$item_link' => App::get_baseurl(true).'/notify/view/'. $it['id'], '$item_image' => $it['photo'], '$item_text' => strip_tags(bbcode($it['msg'])), '$item_when' => relative_date($it['date']) diff --git a/mod/oexchange.php b/mod/oexchange.php index bbb436e702..b25c418e4c 100644 --- a/mod/oexchange.php +++ b/mod/oexchange.php @@ -6,7 +6,7 @@ function oexchange_init(&$a) { if(($a->argc > 1) && ($a->argv[1] === 'xrd')) { $tpl = get_markup_template('oexchange_xrd.tpl'); - $o = replace_macros($tpl, array('$base' => $a->get_baseurl())); + $o = replace_macros($tpl, array('$base' => App::get_baseurl())); echo $o; killme(); } @@ -35,7 +35,7 @@ function oexchange_content(&$a) { $tags = (((x($_REQUEST,'tags')) && strlen($_REQUEST['tags'])) ? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : ''); - $s = fetch_url($a->get_baseurl() . '/parse_url?f=&url=' . $url . $title . $description . $tags); + $s = fetch_url(App::get_baseurl() . '/parse_url?f=&url=' . $url . $title . $description . $tags); if(! strlen($s)) return; diff --git a/mod/openid.php b/mod/openid.php index 60a9c1381b..9ee1877674 100644 --- a/mod/openid.php +++ b/mod/openid.php @@ -92,7 +92,7 @@ function openid_content(&$a) { $args .= '&openid_url=' . notags(trim($authid)); - goaway($a->get_baseurl() . '/register' . $args); + goaway(App::get_baseurl() . '/register' . $args); // NOTREACHED } diff --git a/mod/opensearch.php b/mod/opensearch.php index ff748d1c53..50ecc4e69e 100644 --- a/mod/opensearch.php +++ b/mod/opensearch.php @@ -6,7 +6,7 @@ header("Content-type: application/opensearchdescription+xml"); $o = replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$nodename' => $a->get_hostname(), )); diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php index 6cca0bf679..2e09bfc0d6 100644 --- a/mod/ostatus_subscribe.php +++ b/mod/ostatus_subscribe.php @@ -45,7 +45,7 @@ function ostatus_subscribe_content(&$a) { $total = sizeof($friends); if ($counter >= $total) { - $a->page['htmlhead'] = ''; + $a->page['htmlhead'] = ''; del_pconfig($uid, "ostatus", "legacy_friends"); del_pconfig($uid, "ostatus", "legacy_contact"); $o .= t("Done"); @@ -72,7 +72,7 @@ function ostatus_subscribe_content(&$a) { $o .= "

".t("Keep this window open until done.")."

"; - $a->page['htmlhead'] = ''; + $a->page['htmlhead'] = ''; return $o; } diff --git a/mod/photos.php b/mod/photos.php index 24cc8fabbb..5b402746a9 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -356,7 +356,7 @@ function photos_post(&$a) { create_tags_from_itemuri($i[0]['uri'], $page_owner_uid); delete_thread_uri($i[0]['uri'], $page_owner_uid); - $url = $a->get_baseurl(); + $url = App::get_baseurl(); $drop_id = intval($i[0]['id']); if ($i[0]['visible']) @@ -496,8 +496,8 @@ function photos_post(&$a) { $arr['visible'] = $visibility; $arr['origin'] = 1; - $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']' - . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]' + $arr['body'] = '[url=' . App::get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']' + . '[img]' . App::get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]' . '[/url]'; $item_id = item_store($arr); @@ -615,7 +615,7 @@ function photos_post(&$a) { } } elseif (strpos($tag,'#') === 0) { $tagname = substr($tag, 1); - $str_tags .= '#[url='.$a->get_baseurl()."/search?tag=".$tagname.']'.$tagname.'[/url]'; + $str_tags .= '#[url='.App::get_baseurl()."/search?tag=".$tagname.']'.$tagname.'[/url]'; } } } @@ -685,8 +685,8 @@ function photos_post(&$a) { $arr['tag'] = $tagged[4]; $arr['inform'] = $tagged[2]; $arr['origin'] = 1; - $arr['body'] = sprintf( t('%1$s was tagged in %2$s by %3$s'), '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ; - $arr['body'] .= "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . $a->get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n" ; + $arr['body'] = sprintf( t('%1$s was tagged in %2$s by %3$s'), '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ; + $arr['body'] .= "\n\n" . '[url=' . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . App::get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n" ; $arr['object'] = '' . ACTIVITY_OBJ_PERSON . '' . $tagged[0] . '' . $tagged[1] . '/' . $tagged[0] . ''; $arr['object'] .= '' . xmlify('' . "\n"); @@ -695,8 +695,8 @@ function photos_post(&$a) { $arr['object'] .= '' . "\n"; $arr['target'] = '' . ACTIVITY_OBJ_PHOTO . '' . $p[0]['desc'] . '' - . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ''; - $arr['target'] .= '' . xmlify('' . "\n" . '') . ''; + . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ''; + $arr['target'] .= '' . xmlify('' . "\n" . '') . ''; $item_id = item_store($arr); if ($item_id) { @@ -908,8 +908,8 @@ function photos_post(&$a) { $arr['visible'] = $visible; $arr['origin'] = 1; - $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']' - . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/img]' + $arr['body'] = '[url=' . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']' + . '[img]' . App::get_baseurl() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/img]' . '[/url]'; $item_id = item_store($arr); diff --git a/mod/ping.php b/mod/ping.php index 1ef3cc5b47..cde03969f4 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -177,7 +177,7 @@ function ping_init(App $a) $intro_count = count($intros1) + count($intros2); $intros = $intros1 + $intros2; - $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ; + $myurl = App::get_baseurl() . '/profile/' . $a->user['nickname'] ; $mails = qu("SELECT `id`, `from-name`, `from-url`, `from-photo`, `created` FROM `mail` WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ", intval(local_user()), @@ -253,7 +253,7 @@ function ping_init(App $a) if (dbm::is_result($intros)) { foreach ($intros as $intro) { $notif = array( - 'href' => $a->get_baseurl() . '/notifications/intros/' . $intro['id'], + 'href' => App::get_baseurl() . '/notifications/intros/' . $intro['id'], 'name' => $intro['name'], 'url' => $intro['url'], 'photo' => $intro['photo'], @@ -268,7 +268,7 @@ function ping_init(App $a) if (dbm::is_result($mails)) { foreach ($mails as $mail) { $notif = array( - 'href' => $a->get_baseurl() . '/message/' . $mail['id'], + 'href' => App::get_baseurl() . '/message/' . $mail['id'], 'name' => $mail['from-name'], 'url' => $mail['from-url'], 'photo' => $mail['from-photo'], @@ -283,7 +283,7 @@ function ping_init(App $a) if (dbm::is_result($regs)) { foreach ($regs as $reg) { $notif = array( - 'href' => $a->get_baseurl() . '/admin/users/', + 'href' => App::get_baseurl() . '/admin/users/', 'name' => $reg['name'], 'url' => $reg['url'], 'photo' => $reg['micro'], @@ -450,7 +450,7 @@ function ping_get_notifications($uid) ); } - $notification["href"] = $a->get_baseurl() . "/notify/view/" . $notification["id"]; + $notification["href"] = App::get_baseurl() . "/notify/view/" . $notification["id"]; if ($notification["visible"] AND !$notification["spam"] AND !$notification["deleted"] AND !is_array($result[$notification["parent"]])) { diff --git a/mod/poke.php b/mod/poke.php index 8102c3697d..0619a34e07 100644 --- a/mod/poke.php +++ b/mod/poke.php @@ -118,7 +118,7 @@ function poke_init(&$a) { $arr['origin'] = 1; $arr['body'] = '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' . ' ' . t($verbs[$verb][0]) . ' ' . '[url=' . $target['url'] . ']' . $target['name'] . '[/url]'; - $arr['object'] = '' . ACTIVITY_OBJ_PERSON . '' . $target['name'] . '' . $a->get_baseurl() . '/contact/' . $target['id'] . ''; + $arr['object'] = '' . ACTIVITY_OBJ_PERSON . '' . $target['name'] . '' . App::get_baseurl() . '/contact/' . $target['id'] . ''; $arr['object'] .= '' . xmlify('' . "\n"); $arr['object'] .= xmlify('' . "\n"); @@ -127,7 +127,7 @@ function poke_init(&$a) { $item_id = item_store($arr); if($item_id) { //q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d", - // dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id), + // dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id), // intval($uid), // intval($item_id) //); @@ -166,11 +166,11 @@ function poke_content(&$a) { } - $base = $a->get_baseurl(); + $base = App::get_baseurl(); $head_tpl = get_markup_template('poke_head.tpl'); $a->page['htmlhead'] .= replace_macros($head_tpl,array( - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$base' => $base )); diff --git a/mod/profile.php b/mod/profile.php index 5ab675dd0d..a4b6183715 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -14,7 +14,7 @@ function profile_init(&$a) { else { $r = q("select nickname from user where blocked = 0 and account_expired = 0 and account_removed = 0 and verified = 1 order by rand() limit 1"); if (dbm::is_result($r)) { - goaway($a->get_baseurl() . '/profile/' . $r[0]['nickname']); + goaway(App::get_baseurl() . '/profile/' . $r[0]['nickname']); } else { logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG); @@ -56,15 +56,15 @@ function profile_init(&$a) { } $a->page['htmlhead'] .= '' . "\r\n" ; - $a->page['htmlhead'] .= '' . "\r\n" ; + $a->page['htmlhead'] .= '' . "\r\n" ; $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : '')); - $a->page['htmlhead'] .= '' . "\r\n"; - header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false); + $a->page['htmlhead'] .= '' . "\r\n"; + header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false); $dfrn_pages = array('request', 'confirm', 'notify', 'poll'); foreach($dfrn_pages as $dfrn) - $a->page['htmlhead'] .= "get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n"; - $a->page['htmlhead'] .= "get_baseurl()."/poco/{$which}\" />\r\n"; + $a->page['htmlhead'] .= "\r\n"; + $a->page['htmlhead'] .= "\r\n"; } @@ -181,8 +181,8 @@ function profile_content(&$a, $update = 0) { $commpage = (($a->profile['page-flags'] == PAGE_COMMUNITY) ? true : false); $commvisitor = (($commpage && $remote_contact == true) ? true : false); - $a->page['aside'] .= posted_date_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],$a->profile['profile_uid'],true); - $a->page['aside'] .= categories_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],(x($category) ? xmlify($category) : '')); + $a->page['aside'] .= posted_date_widget(App::get_baseurl(true) . '/profile/' . $a->profile['nickname'],$a->profile['profile_uid'],true); + $a->page['aside'] .= categories_widget(App::get_baseurl(true) . '/profile/' . $a->profile['nickname'],(x($category) ? xmlify($category) : '')); if(can_write_wall($a,$a->profile['profile_uid'])) { diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 20bbbbcbd4..371effd0cb 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -99,15 +99,15 @@ function profile_photo_post(&$a) { ); $r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `self` AND `uid` = %d", - dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()), - dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()), - dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-6.' . $im->getExt()), + dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()), + dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()), + dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-6.' . $im->getExt()), intval(local_user()) ); } else { $r = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d", - dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()), - dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()), + dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()), + dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()), intval($_REQUEST['profile']), intval(local_user()) ); @@ -123,7 +123,7 @@ function profile_photo_post(&$a) { info( t('Shift-reload the page or clear browser cache if the new photo does not display immediately.') . EOL); // Update global directory in background - $url = $a->get_baseurl() . '/profile/' . $a->user['nickname']; + $url = App::get_baseurl() . '/profile/' . $a->user['nickname']; if($url && strlen(get_config('system','directory'))) proc_run(PRIORITY_LOW, "include/directory.php", $url); @@ -134,7 +134,7 @@ function profile_photo_post(&$a) { notice( t('Unable to process image') . EOL); } - goaway($a->get_baseurl() . '/profiles'); + goaway(App::get_baseurl() . '/profiles'); return; // NOTREACHED } @@ -226,7 +226,7 @@ function profile_photo_content(&$a) { if($url && strlen(get_config('system','directory'))) proc_run(PRIORITY_LOW, "include/directory.php", $url); - goaway($a->get_baseurl() . '/profiles'); + goaway(App::get_baseurl() . '/profiles'); return; // NOTREACHED } $ph = new Photo($r[0]['data'], $r[0]['type']); @@ -251,7 +251,7 @@ function profile_photo_content(&$a) { '$submit' => t('Upload'), '$profiles' => $profiles, '$form_security_token' => get_form_security_token("profile_photo"), - '$select' => sprintf('%s %s', t('or'), ($newuser) ? '' . t('skip this step') . '' : '' . t('select a photo from your photo albums') . '') + '$select' => sprintf('%s %s', t('or'), ($newuser) ? '' . t('skip this step') . '' : '' . t('select a photo from your photo albums') . '') )); return $o; @@ -264,7 +264,7 @@ function profile_photo_content(&$a) { '$filename' => $filename, '$profile' => intval($_REQUEST['profile']), '$resource' => $a->config['imagecrop'] . '-' . $a->config['imagecrop_resolution'], - '$image_url' => $a->get_baseurl() . '/photo/' . $filename, + '$image_url' => App::get_baseurl() . '/photo/' . $filename, '$title' => t('Crop Image'), '$desc' => t('Please adjust the image cropping for optimum viewing.'), '$form_security_token' => get_form_security_token("profile_photo"), diff --git a/mod/profiles.php b/mod/profiles.php index 39e9a6c1ff..a5f5609b6b 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -629,11 +629,11 @@ function profiles_content(&$a) { $editselect = 'textareas'; $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array( - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$editselect' => $editselect, )); $a->page['end'] .= replace_macros(get_markup_template('profed_end.tpl'), array( - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$editselect' => $editselect, )); @@ -711,7 +711,7 @@ function profiles_content(&$a) { '$lbl_ex2' => t('Example: fishing photography software'), '$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''), - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$profile_id' => $r[0]['id'], '$profile_name' => array('profile_name', t('Profile Name:'), $r[0]['profile-name'], t('Required'), '*'), '$is_default' => $is_default, diff --git a/mod/proxy.php b/mod/proxy.php index 612dc910a0..ff58bba7f1 100644 --- a/mod/proxy.php +++ b/mod/proxy.php @@ -255,7 +255,7 @@ function proxy_url($url, $writemode = false, $size = '') { // Only continue if it isn't a local image and the isn't deactivated if (proxy_is_local_image($url)) { - $url = str_replace(normalise_link($a->get_baseurl()) . '/', $a->get_baseurl() . '/', $url); + $url = str_replace(normalise_link(App::get_baseurl()) . '/', App::get_baseurl() . '/', $url); return $url; } @@ -297,7 +297,7 @@ function proxy_url($url, $writemode = false, $size = '') { $longpath .= '.' . $extension; } - $proxypath = $a->get_baseurl() . '/proxy/' . $longpath; + $proxypath = App::get_baseurl() . '/proxy/' . $longpath; if ($size != '') { $size = ':' . $size; @@ -308,7 +308,7 @@ function proxy_url($url, $writemode = false, $size = '') { if ((strlen($proxypath) > 250) AND $writemode) { return $shortpath; } elseif (strlen($proxypath) > 250) { - return $a->get_baseurl() . '/proxy/' . $shortpath . '?url=' . urlencode($url); + return App::get_baseurl() . '/proxy/' . $shortpath . '?url=' . urlencode($url); } elseif ($writemode) { return $longpath; } else { @@ -366,7 +366,7 @@ function proxy_img_cb($matches) { function proxy_parse_html($html) { $a = get_app(); - $html = str_replace(normalise_link($a->get_baseurl())."/", $a->get_baseurl()."/", $html); + $html = str_replace(normalise_link(App::get_baseurl())."/", App::get_baseurl()."/", $html); return preg_replace_callback("/(]*src *= *[\"'])([^\"']+)([\"'][^>]*>)/siU", "proxy_img_cb", $html); } diff --git a/mod/randprof.php b/mod/randprof.php index 6713a81d9e..877bf818b9 100644 --- a/mod/randprof.php +++ b/mod/randprof.php @@ -6,5 +6,5 @@ function randprof_init(&$a) { $x = random_profile(); if($x) goaway(zrl($x)); - goaway($a->get_baseurl() . '/profile'); + goaway(App::get_baseurl() . '/profile'); } diff --git a/mod/register.php b/mod/register.php index f0348ef4e5..36ca189484 100644 --- a/mod/register.php +++ b/mod/register.php @@ -64,7 +64,7 @@ function register_post(&$a) { $user = $result['user']; if($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) { - $url = $a->get_baseurl() . '/profile/' . $user['nickname']; + $url = App::get_baseurl() . '/profile/' . $user['nickname']; proc_run(PRIORITY_LOW, "include/directory.php", $url); } @@ -85,7 +85,7 @@ function register_post(&$a) { $res = send_register_open_eml( $user['email'], $a->config['sitename'], - $a->get_baseurl(), + App::get_baseurl(), $user['username'], $result['password']); @@ -142,9 +142,9 @@ function register_post(&$a) { 'source_name' => $user['username'], 'source_mail' => $user['email'], 'source_nick' => $user['nickname'], - 'source_link' => $a->get_baseurl()."/admin/users/", - 'link' => $a->get_baseurl()."/admin/users/", - 'source_photo' => $a->get_baseurl() . "/photo/avatar/".$user['uid'].".jpg", + 'source_link' => App::get_baseurl()."/admin/users/", + 'link' => App::get_baseurl()."/admin/users/", + 'source_photo' => App::get_baseurl() . "/photo/avatar/".$user['uid'].".jpg", 'to_email' => $admin['email'], 'uid' => $admin['uid'], 'language' => ($admin['language']?$admin['language']:'en'), diff --git a/mod/regmod.php b/mod/regmod.php index 8caa964aa9..b6f1e4260f 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -35,7 +35,7 @@ function user_allow($hash) { intval($user[0]['uid']) ); if (dbm::is_result($r) && $r[0]['net-publish']) { - $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname']; + $url = App::get_baseurl() . '/profile/' . $user[0]['nickname']; if($url && strlen(get_config('system','directory'))) proc_run(PRIORITY_LOW, "include/directory.php", $url); } @@ -45,7 +45,7 @@ function user_allow($hash) { send_register_open_eml( $user[0]['email'], $a->config['sitename'], - $a->get_baseurl(), + App::get_baseurl(), $user[0]['username'], $register[0]['password']); @@ -121,13 +121,13 @@ function regmod_content(&$a) { if($cmd === 'deny') { user_deny($hash); - goaway($a->get_baseurl()."/admin/users/"); + goaway(App::get_baseurl()."/admin/users/"); killme(); } if($cmd === 'allow') { user_allow($hash); - goaway($a->get_baseurl()."/admin/users/"); + goaway(App::get_baseurl()."/admin/users/"); killme(); } } diff --git a/mod/repair_ostatus.php b/mod/repair_ostatus.php index 2b1224f423..7a454a4ae0 100755 --- a/mod/repair_ostatus.php +++ b/mod/repair_ostatus.php @@ -51,7 +51,7 @@ function repair_ostatus_content(&$a) { $result = new_contact($uid,$r[0]["url"],true); - $a->page['htmlhead'] = ''; + $a->page['htmlhead'] = ''; return $o; } diff --git a/mod/rsd_xml.php b/mod/rsd_xml.php index f4984f0f0f..6257adc1ba 100644 --- a/mod/rsd_xml.php +++ b/mod/rsd_xml.php @@ -10,7 +10,7 @@ function rsd_xml_content(&$a) { Friendica http://friendica.com/ - + http://status.net/wiki/TwitterCompatibleAPI false diff --git a/mod/settings.php b/mod/settings.php index a9521db221..41783815e7 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -138,7 +138,7 @@ function settings_post(&$a) { q("DELETE FROM tokens WHERE id='%s' AND uid=%d", dbesc($key), local_user()); - goaway($a->get_baseurl(true)."/settings/oauth/"); + goaway(App::get_baseurl(true)."/settings/oauth/"); return; } @@ -183,7 +183,7 @@ function settings_post(&$a) { local_user()); } } - goaway($a->get_baseurl(true)."/settings/oauth/"); + goaway(App::get_baseurl(true)."/settings/oauth/"); return; } @@ -718,7 +718,7 @@ function settings_content(&$a) { $r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d", dbesc($a->argv[3]), local_user()); - goaway($a->get_baseurl(true)."/settings/oauth/"); + goaway(App::get_baseurl(true)."/settings/oauth/"); return; } @@ -734,7 +734,7 @@ function settings_content(&$a) { $tpl = get_markup_template("settings_oauth.tpl"); $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_oauth"), - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$title' => t('Connected Apps'), '$add' => t('Add application'), '$edit' => t('Edit'), @@ -822,7 +822,7 @@ function settings_content(&$a) { $settings_connectors .= mini_group_select(local_user(), $default_group, t("Default group for OStatus contacts")); if ($legacy_contact != "") - $a->page['htmlhead'] = ''; + $a->page['htmlhead'] = ''; $settings_connectors .= '
'; $settings_connectors .= ''; @@ -830,7 +830,7 @@ function settings_content(&$a) { $settings_connectors .= ''.t('If you enter your old GNU Social/Statusnet account name here (in the format user@domain.tld), your contacts will be added automatically. The field will be emptied when done.').''; $settings_connectors .= '
'; - $settings_connectors .= '

'.t("Repair OStatus subscriptions").'

'; + $settings_connectors .= '

'.t("Repair OStatus subscriptions").'

'; $settings_connectors .= '
'; @@ -994,7 +994,7 @@ function settings_content(&$a) { '$ptitle' => t('Display Settings'), '$form_security_token' => get_form_security_token("settings_display"), '$submit' => t('Save Settings'), - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$uid' => local_user(), '$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes, true), @@ -1217,7 +1217,7 @@ function settings_content(&$a) { $tpl_addr = get_markup_template("settings_nick_set.tpl"); $prof_addr = replace_macros($tpl_addr,array( - '$desc' => sprintf(t("Your Identity Address is '%s' or '%s'."), $nickname.'@'.$a->get_hostname().$a->get_path(), $a->get_baseurl().'/profile/'.$nickname), + '$desc' => sprintf(t("Your Identity Address is '%s' or '%s'."), $nickname.'@'.$a->get_hostname().$a->get_path(), App::get_baseurl().'/profile/'.$nickname), '$basepath' => $a->get_hostname() )); @@ -1262,7 +1262,7 @@ function settings_content(&$a) { '$ptitle' => t('Account Settings'), '$submit' => t('Save Settings'), - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$uid' => local_user(), '$form_security_token' => get_form_security_token("settings"), '$nickname_block' => $prof_addr, diff --git a/mod/starred.php b/mod/starred.php index 27f924e44b..5acbb393ef 100644 --- a/mod/starred.php +++ b/mod/starred.php @@ -39,7 +39,7 @@ function starred_init(&$a) { if(strpos($return_path, '?')) $rand = "&$rand"; else $rand = "?$rand"; - goaway($a->get_baseurl() . "/" . $return_path . $rand); + goaway(App::get_baseurl() . "/" . $return_path . $rand); } // the json doesn't really matter, it will either be 0 or 1 diff --git a/mod/suggest.php b/mod/suggest.php index 8f4315a841..080decc71a 100644 --- a/mod/suggest.php +++ b/mod/suggest.php @@ -59,7 +59,7 @@ function suggest_content(&$a) { return; } - $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; + $_SESSION['return_url'] = App::get_baseurl() . '/' . $a->cmd; $a->page['aside'] .= findpeople_widget(); $a->page['aside'] .= follow_widget(); @@ -76,8 +76,8 @@ function suggest_content(&$a) { foreach($r as $rr) { - $connlnk = $a->get_baseurl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']); - $ignlnk = $a->get_baseurl() . '/suggest?ignore=' . $rr['id']; + $connlnk = App::get_baseurl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']); + $ignlnk = App::get_baseurl() . '/suggest?ignore=' . $rr['id']; $photo_menu = array( 'profile' => array(t("View Profile"), zrl($rr["url"])), 'follow' => array(t("Connect/Follow"), $connlnk), diff --git a/mod/tagger.php b/mod/tagger.php index e5e5263d81..d44288ef0a 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -63,7 +63,7 @@ function tagger_content(&$a) { $targettype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); $link = xmlify('' . "\n") ; + . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ; $body = xmlify($item['body']); @@ -78,7 +78,7 @@ function tagger_content(&$a) { EOT; - $tagid = $a->get_baseurl() . '/search?tag=' . $term; + $tagid = App::get_baseurl() . '/search?tag=' . $term; $objtype = ACTIVITY_OBJ_TAGTERM; $obj = <<< EOT @@ -97,7 +97,7 @@ EOT; if(! isset($bodyverb)) return; - $termlink = html_entity_decode('⌗') . '[url=' . $a->get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/url]'; + $termlink = html_entity_decode('⌗') . '[url=' . App::get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/url]'; $arr = array(); @@ -140,7 +140,7 @@ EOT; $post_id = item_store($arr); // q("UPDATE `item` set plink = '%s' where id = %d", -// dbesc($a->get_baseurl() . '/display/' . $owner_nick . '/' . $post_id), +// dbesc(App::get_baseurl() . '/display/' . $owner_nick . '/' . $post_id), // intval($post_id) // ); @@ -159,7 +159,7 @@ EOT; ); if((! $blocktags) && $t[0]['tcount']==0 ) { /*q("update item set tag = '%s' where id = %d", - dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'), + dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . App::get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'), intval($item['id']) );*/ @@ -168,7 +168,7 @@ EOT; $term_objtype, TERM_HASHTAG, dbesc($term), - dbesc($a->get_baseurl() . '/search?tag=' . $term), + dbesc(App::get_baseurl() . '/search?tag=' . $term), intval($owner_uid) ); } @@ -192,14 +192,14 @@ EOT; $term_objtype, TERM_HASHTAG, dbesc($term), - dbesc($a->get_baseurl() . '/search?tag=' . $term), + dbesc(App::get_baseurl() . '/search?tag=' . $term), intval($owner_uid) ); } /*if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) { q("update item set tag = '%s' where id = %d", - dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'), + dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . App::get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'), intval($r[0]['id']) ); }*/ diff --git a/mod/tagrm.php b/mod/tagrm.php index 57024b3c3b..08d390a70b 100644 --- a/mod/tagrm.php +++ b/mod/tagrm.php @@ -5,11 +5,11 @@ require_once('include/bbcode.php'); function tagrm_post(&$a) { if(! local_user()) - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); + goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); if((x($_POST,'submit')) && ($_POST['submit'] === t('Cancel'))) - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); + goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); $tag = ((x($_POST,'tag')) ? hex2bin(notags(trim($_POST['tag']))) : ''); $item = ((x($_POST,'item')) ? intval($_POST['item']) : 0 ); @@ -20,7 +20,7 @@ function tagrm_post(&$a) { ); if(! dbm::is_result($r)) - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); + goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); $arr = explode(',', $r[0]['tag']); for($x = 0; $x < count($arr); $x ++) { @@ -39,7 +39,7 @@ function tagrm_post(&$a) { ); info( t('Tag removed') . EOL ); - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); + goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); // NOTREACHED @@ -52,13 +52,13 @@ function tagrm_content(&$a) { $o = ''; if(! local_user()) { - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); + goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); // NOTREACHED } $item = (($a->argc > 1) ? intval($a->argv[1]) : 0); if(! $item) { - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); + goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); // NOTREACHED } @@ -69,12 +69,12 @@ function tagrm_content(&$a) { ); if(! dbm::is_result($r)) - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); + goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); $arr = explode(',', $r[0]['tag']); if(! count($arr)) - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); + goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); $o .= '

' . t('Remove Item Tag') . '

'; diff --git a/mod/toggle_mobile.php b/mod/toggle_mobile.php index 00991e44ca..dbf0eb0f13 100644 --- a/mod/toggle_mobile.php +++ b/mod/toggle_mobile.php @@ -10,7 +10,7 @@ function toggle_mobile_init(&$a) { if(isset($_GET['address'])) $address = $_GET['address']; else - $address = $a->get_baseurl(); + $address = App::get_baseurl(); goaway($address); } diff --git a/mod/uexport.php b/mod/uexport.php index e0a0b071f6..d9bd5ae01e 100644 --- a/mod/uexport.php +++ b/mod/uexport.php @@ -33,7 +33,7 @@ function uexport_content(&$a){ $tpl = get_markup_template("uexport.tpl"); return replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$title' => t('Export personal data'), '$options' => $options )); @@ -104,7 +104,7 @@ function uexport_account($a){ $output = array( 'version' => FRIENDICA_VERSION, 'schema' => DB_UPDATE_VERSION, - 'baseurl' => $a->get_baseurl(), + 'baseurl' => App::get_baseurl(), 'user' => $user, 'contact' => $contact, 'profile' => $profile, diff --git a/mod/videos.php b/mod/videos.php index 1e03c5005a..92e5fe5548 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -59,7 +59,7 @@ function videos_init(&$a) { if($albums_visible) { $o .= ''; @@ -87,12 +87,12 @@ function videos_init(&$a) { $tpl = get_markup_template("videos_head.tpl"); $a->page['htmlhead'] .= replace_macros($tpl,array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), )); $tpl = get_markup_template("videos_end.tpl"); $a->page['end'] .= replace_macros($tpl,array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), )); } @@ -106,13 +106,13 @@ function videos_post(&$a) { $owner_uid = $a->data['user']['uid']; - if (local_user() != $owner_uid) goaway($a->get_baseurl() . '/videos/' . $a->data['user']['nickname']); + if (local_user() != $owner_uid) goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']); if(($a->argc == 2) && x($_POST,'delete') && x($_POST, 'id')) { // Check if we should do HTML-based delete confirmation if(!x($_REQUEST,'confirm')) { - if(x($_REQUEST,'canceled')) goaway($a->get_baseurl() . '/videos/' . $a->data['user']['nickname']); + if(x($_REQUEST,'canceled')) goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']); $drop_url = $a->query_string; $a->page['content'] = replace_macros(get_markup_template('confirm.tpl'), array( @@ -160,7 +160,7 @@ function videos_post(&$a) { create_tags_from_itemuri($i[0]['uri'], local_user()); delete_thread_uri($i[0]['uri'], local_user()); - $url = $a->get_baseurl(); + $url = App::get_baseurl(); $drop_id = intval($i[0]['id']); if($i[0]['visible']) @@ -168,11 +168,11 @@ function videos_post(&$a) { } } - goaway($a->get_baseurl() . '/videos/' . $a->data['user']['nickname']); + goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']); return; // NOTREACHED } - goaway($a->get_baseurl() . '/videos/' . $a->data['user']['nickname']); + goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']); } @@ -376,13 +376,13 @@ function videos_content(&$a) { $videos[] = array( 'id' => $rr['id'], - 'link' => $a->get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['resource-id'], + 'link' => App::get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['resource-id'], 'title' => t('View Video'), - 'src' => $a->get_baseurl() . '/attach/' . $rr['id'] . '?attachment=0', + 'src' => App::get_baseurl() . '/attach/' . $rr['id'] . '?attachment=0', 'alt' => $alt_e, 'mime' => $rr['filetype'], 'album' => array( - 'link' => $a->get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']), + 'link' => App::get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']), 'name' => $name_e, 'alt' => t('View Album'), ), @@ -395,9 +395,9 @@ function videos_content(&$a) { $o .= replace_macros($tpl, array( '$title' => t('Recent Videos'), '$can_post' => $can_post, - '$upload' => array(t('Upload New Videos'), $a->get_baseurl().'/videos/'.$a->data['user']['nickname'].'/upload'), + '$upload' => array(t('Upload New Videos'), App::get_baseurl().'/videos/'.$a->data['user']['nickname'].'/upload'), '$videos' => $videos, - '$delete_url' => (($can_post)?$a->get_baseurl().'/videos/'.$a->data['user']['nickname']:False) + '$delete_url' => (($can_post)?App::get_baseurl().'/videos/'.$a->data['user']['nickname']:False) )); diff --git a/mod/wall_upload.php b/mod/wall_upload.php index 21d9bf49cb..e277290985 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -260,9 +260,9 @@ function wall_upload_post(&$a, $desktopmode = true) { $picture["width"] = $r[0]["width"]; $picture["height"] = $r[0]["height"]; $picture["type"] = $r[0]["type"]; - $picture["albumpage"] = $a->get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash; - $picture["picture"] = $a->get_baseurl()."/photo/{$hash}-0.".$ph->getExt(); - $picture["preview"] = $a->get_baseurl()."/photo/{$hash}-{$smallest}.".$ph->getExt(); + $picture["albumpage"] = App::get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash; + $picture["picture"] = App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt(); + $picture["preview"] = App::get_baseurl()."/photo/{$hash}-{$smallest}.".$ph->getExt(); if ($r_json) { echo json_encode(array('picture'=>$picture)); @@ -282,14 +282,14 @@ function wall_upload_post(&$a, $desktopmode = true) { //if we get the signal then return the image url info in BBCODE, otherwise this outputs the info and bails (for the ajax image uploader on wall post) if ($_REQUEST['hush']!='yeah') { if(local_user() && (! feature_enabled(local_user(),'richtext') || x($_REQUEST['nomce'])) ) { - echo "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]\n\n"; + echo "\n\n" . '[url=' . App::get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . App::get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]\n\n"; } else { - echo '

getExt()."\" alt=\"$basename\" />

"; + echo '

getExt()."\" alt=\"$basename\" />

"; } } else { - $m = '[url='.$a->get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash.'][img]'.$a->get_baseurl()."/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]"; + $m = '[url='.App::get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash.'][img]'.App::get_baseurl()."/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]"; return($m); } /* mod Waitman Gobble NO WARRANTY */ diff --git a/mod/xrd.php b/mod/xrd.php index 1250b0812c..576ae9b38f 100644 --- a/mod/xrd.php +++ b/mod/xrd.php @@ -31,14 +31,14 @@ function xrd_init(&$a) { $tpl = get_markup_template('xrd_diaspora.tpl'); $dspr = replace_macros($tpl,array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$dspr_guid' => $r[0]['guid'], '$dspr_key' => base64_encode(pemtorsa($r[0]['pubkey'])) )); $tpl = get_markup_template('xrd_person.tpl'); - $profile_url = $a->get_baseurl().'/profile/'.$r[0]['nickname']; + $profile_url = App::get_baseurl().'/profile/'.$r[0]['nickname']; if ($acct) $alias = $profile_url; @@ -54,15 +54,15 @@ function xrd_init(&$a) { '$accturi' => $uri, '$alias' => $alias, '$profile_url' => $profile_url, - '$hcard_url' => $a->get_baseurl() . '/hcard/' . $r[0]['nickname'], - '$atom' => $a->get_baseurl() . '/dfrn_poll/' . $r[0]['nickname'], - '$zot_post' => $a->get_baseurl() . '/post/' . $r[0]['nickname'], - '$poco_url' => $a->get_baseurl() . '/poco/' . $r[0]['nickname'], - '$photo' => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid'] . '.jpg', + '$hcard_url' => App::get_baseurl() . '/hcard/' . $r[0]['nickname'], + '$atom' => App::get_baseurl() . '/dfrn_poll/' . $r[0]['nickname'], + '$zot_post' => App::get_baseurl() . '/post/' . $r[0]['nickname'], + '$poco_url' => App::get_baseurl() . '/poco/' . $r[0]['nickname'], + '$photo' => App::get_baseurl() . '/photo/profile/' . $r[0]['uid'] . '.jpg', '$dspr' => $dspr, - '$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'], - '$salmen' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention', - '$subscribe' => $a->get_baseurl() . '/follow?url={uri}', + '$salmon' => App::get_baseurl() . '/salmon/' . $r[0]['nickname'], + '$salmen' => App::get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention', + '$subscribe' => App::get_baseurl() . '/follow?url={uri}', '$modexp' => 'data:application/magic-public-key,' . $salmon_key, '$bigkey' => salmon_key($r[0]['pubkey']) )); diff --git a/view/php/default.php b/view/php/default.php index df9adbc392..e51b531b5a 100644 --- a/view/php/default.php +++ b/view/php/default.php @@ -2,7 +2,7 @@ <?php if(x($page,'title')) echo $page['title'] ?> - + diff --git a/view/php/minimal.php b/view/php/minimal.php index a131e3ec5e..e93aac1125 100644 --- a/view/php/minimal.php +++ b/view/php/minimal.php @@ -2,7 +2,7 @@ <?php if(x($page,'title')) echo $page['title'] ?> - + diff --git a/view/theme/duepuntozero/config.php b/view/theme/duepuntozero/config.php index edf12c35fa..2c79896227 100644 --- a/view/theme/duepuntozero/config.php +++ b/view/theme/duepuntozero/config.php @@ -38,7 +38,7 @@ function theme_admin_post(&$a){ } } - +/// @TODO $a is no longer used function clean_form(&$a, &$colorset, $user){ $colorset = array( 'default'=>t('default'), @@ -56,9 +56,9 @@ function clean_form(&$a, &$colorset, $user){ } $t = get_markup_template("theme_settings.tpl" ); $o .= replace_macros($t, array( - '$submit' => t('Submit'), - '$baseurl' => $a->get_baseurl(), - '$title' => t("Theme settings"), + '$submit' => t('Submit'), + '$baseurl' => App::get_baseurl(), + '$title' => t("Theme settings"), '$colorset' => array('duepuntozero_colorset', t('Variations'), $color, '', $colorset), )); return $o; diff --git a/view/theme/frio/config.php b/view/theme/frio/config.php index 2e896d45f6..589f1591a0 100644 --- a/view/theme/frio/config.php +++ b/view/theme/frio/config.php @@ -57,7 +57,7 @@ function frio_form(&$a, $arr) { $t = get_markup_template('theme_settings.tpl'); $o .= replace_macros($t, array( '$submit' => t('Submit'), - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$title' => t("Theme settings"), '$schema' => array('frio_schema', t("Select scheme"), $arr["schema"], '', $scheme_choices), '$nav_bg' => array_key_exists("nav_bg", $disable) ? "" : array('frio_nav_bg', t('Navigation bar background color'), $arr['nav_bg']), diff --git a/view/theme/frio/php/default.php b/view/theme/frio/php/default.php index bfc11a3580..56118cc90e 100644 --- a/view/theme/frio/php/default.php +++ b/view/theme/frio/php/default.php @@ -18,9 +18,9 @@ <?php if(x($page,'title')) echo $page['title'] ?> - + - get_baseurl(); ?> + - + - get_baseurl(); ?> + diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php index 279edd64ec..5bc5140bf1 100644 --- a/view/theme/frio/theme.php +++ b/view/theme/frio/theme.php @@ -21,7 +21,7 @@ function frio_init(&$a) { set_template_engine($a, 'smarty3'); - $baseurl = $a->get_baseurl(); + $baseurl = App::get_baseurl(); $style = get_pconfig(local_user(), 'frio', 'style'); diff --git a/view/theme/frost-mobile/php/default.php b/view/theme/frost-mobile/php/default.php index 332291ca92..d739f56f26 100644 --- a/view/theme/frost-mobile/php/default.php +++ b/view/theme/frost-mobile/php/default.php @@ -2,7 +2,7 @@ <?php if(x($page,'title')) echo $page['title'] ?> - + module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>> diff --git a/view/theme/frost-mobile/theme.php b/view/theme/frost-mobile/theme.php index 29a990f7b8..24d5e9e52e 100644 --- a/view/theme/frost-mobile/theme.php +++ b/view/theme/frost-mobile/theme.php @@ -23,8 +23,8 @@ function frost_mobile_content_loaded(&$a) { // I could do this in style.php, but by having the CSS in a file the browser will cache it, // making pages load faster if( $a->module === 'home' || $a->module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) { -// $a->page['htmlhead'] = str_replace('$stylesheet', $a->get_baseurl() . '/view/theme/frost-mobile/login-style.css', $a->page['htmlhead']); - $a->theme['stylesheet'] = $a->get_baseurl() . '/view/theme/frost-mobile/login-style.css'; +// $a->page['htmlhead'] = str_replace('$stylesheet', App::get_baseurl() . '/view/theme/frost-mobile/login-style.css', $a->page['htmlhead']); + $a->theme['stylesheet'] = App::get_baseurl() . '/view/theme/frost-mobile/login-style.css'; } if( $a->module === 'login' ) $a->page['end'] .= ''; diff --git a/view/theme/frost/php/default.php b/view/theme/frost/php/default.php index c67bdcf20e..0fe3404f69 100644 --- a/view/theme/frost/php/default.php +++ b/view/theme/frost/php/default.php @@ -2,7 +2,7 @@ <?php if(x($page,'title')) echo $page['title'] ?> - + module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>> diff --git a/view/theme/frost/theme.php b/view/theme/frost/theme.php index 1093a04729..464c14d470 100644 --- a/view/theme/frost/theme.php +++ b/view/theme/frost/theme.php @@ -21,8 +21,8 @@ function frost_content_loaded(&$a) { // I could do this in style.php, but by having the CSS in a file the browser will cache it, // making pages load faster if( $a->module === 'home' || $a->module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) { - //$a->page['htmlhead'] = str_replace('$stylesheet', $a->get_baseurl() . '/view/theme/frost/login-style.css', $a->page['htmlhead']); - $a->theme['stylesheet'] = $a->get_baseurl() . '/view/theme/frost/login-style.css'; + //$a->page['htmlhead'] = str_replace('$stylesheet', App::get_baseurl() . '/view/theme/frost/login-style.css', $a->page['htmlhead']); + $a->theme['stylesheet'] = App::get_baseurl() . '/view/theme/frost/login-style.css'; } if( $a->module === 'login' ) $a->page['end'] .= ''; diff --git a/view/theme/quattro/config.php b/view/theme/quattro/config.php index db4356ccc8..2a32b9f05a 100644 --- a/view/theme/quattro/config.php +++ b/view/theme/quattro/config.php @@ -48,7 +48,7 @@ function theme_admin_post(&$a){ } } - +/// @TODO $a is no longer used here function quattro_form(&$a, $align, $color, $tfs, $pfs){ $colors = array( "dark"=>"Quattro", @@ -62,7 +62,7 @@ function quattro_form(&$a, $align, $color, $tfs, $pfs){ $t = get_markup_template("theme_settings.tpl" ); $o .= replace_macros($t, array( '$submit' => t('Submit'), - '$baseurl' => $a->get_baseurl(), + '$baseurl' => App::get_baseurl(), '$title' => t("Theme settings"), '$align' => array('quattro_align', t('Alignment'), $align, '', array('left'=>t('Left'), 'center'=>t('Center'))), '$color' => array('quattro_color', t('Color scheme'), $color, '', $colors), diff --git a/view/theme/quattro/theme.php b/view/theme/quattro/theme.php index 0b67c6b49a..f316323fd3 100644 --- a/view/theme/quattro/theme.php +++ b/view/theme/quattro/theme.php @@ -8,6 +8,6 @@ */ function quattro_init(&$a) { - $a->page['htmlhead'] .= ''; - $a->page['htmlhead'] .= '';; + $a->page['htmlhead'] .= ''; + $a->page['htmlhead'] .= '';; } diff --git a/view/theme/smoothly/php/default.php b/view/theme/smoothly/php/default.php index 405e1cad34..1e97c6b462 100644 --- a/view/theme/smoothly/php/default.php +++ b/view/theme/smoothly/php/default.php @@ -2,7 +2,7 @@ <?php if(x($page,'title')) echo $page['title'] ?> - + '; $a->page['htmlhead'] .= '';; } diff --git a/view/theme/smoothly/theme.php b/view/theme/smoothly/theme.php index 189110a952..32c48fffa4 100644 --- a/view/theme/smoothly/theme.php +++ b/view/theme/smoothly/theme.php @@ -10,7 +10,7 @@ * Screenshot: Screenshot */ -function smoothly_init(&$a) { +function smoothly_init(App &$a) { set_template_engine($a, 'smarty3'); $cssFile = null; diff --git a/view/theme/vier/config.php b/view/theme/vier/config.php index 0f07ff9a1e..55ef2654f1 100644 --- a/view/theme/vier/config.php +++ b/view/theme/vier/config.php @@ -5,7 +5,7 @@ -function theme_content(&$a){ +function theme_content(App &$a){ if(!local_user()) return; @@ -31,7 +31,7 @@ function theme_content(&$a){ $show_services, $show_friends, $show_lastusers); } -function theme_post(&$a){ +function theme_post(App &$a){ if(! local_user()) return; @@ -47,7 +47,7 @@ function theme_post(&$a){ } -function theme_admin(&$a){ +function theme_admin(App &$a){ if (!function_exists('get_vier_config')) return; @@ -76,7 +76,7 @@ function theme_admin(&$a){ return $o; } -function theme_admin_post(&$a){ +function theme_admin_post(App &$a){ if (isset($_POST['vier-settings-submit'])){ set_config('vier', 'style', $_POST['vier_style']); set_config('vier', 'show_pages', $_POST['vier_show_pages']); diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php index 45dde5f449..46921dc1c5 100644 --- a/view/theme/vier/theme.php +++ b/view/theme/vier/theme.php @@ -13,7 +13,7 @@ require_once("include/plugin.php"); require_once("include/socgraph.php"); require_once("mod/proxy.php"); -function vier_init(&$a) { +function vier_init(App &$a) { $a->theme_events_in_profile = false; From 34fcaeb209975e7eff0d9fd4f0776d29ff9007c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 10:59:11 +0100 Subject: [PATCH 16/96] changed to this: --------------------- function bla (App &$a) { $a->bla = 'stuff'; } --------------------- MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- doc/Plugins.md | 6 +++--- doc/autoloader.md | 2 +- doc/de/Plugins.md | 6 +++--- doc/themes.md | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/Plugins.md b/doc/Plugins.md index 49d0665fec..6460fd5a09 100644 --- a/doc/Plugins.md +++ b/doc/Plugins.md @@ -77,9 +77,9 @@ This will include: $a->argc = 3 $a->argv = array(0 => 'plugin', 1 => 'arg1', 2 => 'arg2'); -Your module functions will often contain the function plugin_name_content(&$a), which defines and returns the page body content. -They may also contain plugin_name_post(&$a) which is called before the _content function and typically handles the results of POST forms. -You may also have plugin_name_init(&$a) which is called very early on and often does module initialisation. +Your module functions will often contain the function plugin_name_content(App &$a), which defines and returns the page body content. +They may also contain plugin_name_post(App &$a) which is called before the _content function and typically handles the results of POST forms. +You may also have plugin_name_init(App &$a) which is called very early on and often does module initialisation. Templates --- diff --git a/doc/autoloader.md b/doc/autoloader.md index 947eade23c..25ffd7fe45 100644 --- a/doc/autoloader.md +++ b/doc/autoloader.md @@ -68,7 +68,7 @@ The code will be something like: file: mod/network.php getAll(); diff --git a/doc/de/Plugins.md b/doc/de/Plugins.md index 40be4a0695..b2c3f849ff 100644 --- a/doc/de/Plugins.md +++ b/doc/de/Plugins.md @@ -67,9 +67,9 @@ So würde http://example.com/plugin/arg1/arg2 nach einem Modul "plugin" suchen u $a->argc = 3 $a->argv = array(0 => 'plugin', 1 => 'arg1', 2 => 'arg2'); -Deine Modulfunktionen umfassen oft die Funktion plugin_name_content(&$a), welche den Seiteninhalt definiert und zurückgibt. -Sie können auch plugin_name_post(&$a) umfassen, welches vor der content-Funktion aufgerufen wird und normalerweise die Resultate der POST-Formulare handhabt. -Du kannst ebenso plugin_name_init(&$a) nutzen, was oft frühzeitig aufgerufen wird und das Modul initialisert. +Deine Modulfunktionen umfassen oft die Funktion plugin_name_content(App &$a), welche den Seiteninhalt definiert und zurückgibt. +Sie können auch plugin_name_post(App &$a) umfassen, welches vor der content-Funktion aufgerufen wird und normalerweise die Resultate der POST-Formulare handhabt. +Du kannst ebenso plugin_name_init(App &$a) nutzen, was oft frühzeitig aufgerufen wird und das Modul initialisert. Derzeitige Hooks diff --git a/doc/themes.md b/doc/themes.md index add44c776b..0ae7e694fe 100644 --- a/doc/themes.md +++ b/doc/themes.md @@ -122,7 +122,7 @@ the 1st part of the line is the name of the CSS file (without the .css) the 2nd Calling the t() function with the common name makes the string translateable. The selected 1st part will be saved in the database by the theme_post function. - function theme_post(&$a){ + function theme_post(App &$a){ // non local users shall not pass if(! local_user()) return; @@ -167,7 +167,7 @@ The content of this file should be something like theme_info = array( 'extends' => 'duepuntozero'. ); @@ -250,7 +250,7 @@ Next crucial part of the theme.php file is a definition of an init function. The name of the function is _init. So in the case of quattro it is - function quattro_init(&$a) { + function quattro_init(App &$a) { $a->theme_info = array(); set_template_engine($a, 'smarty3'); } From 92ad87590bfa2ec146587f1764d0e04ed51e9b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 11:04:29 +0100 Subject: [PATCH 17/96] added curly braces + space between "if" and brace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/group.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mod/group.php b/mod/group.php index db9fe35bca..08b7801a7b 100644 --- a/mod/group.php +++ b/mod/group.php @@ -28,15 +28,18 @@ function group_post(App &$a) { if($r) { info( t('Group created.') . EOL ); $r = group_byname(local_user(),$name); - if($r) + if ($r) { goaway(App::get_baseurl() . '/group/' . $r); + } } - else + else { notice( t('Could not create group.') . EOL ); + } goaway(App::get_baseurl() . '/group'); return; // NOTREACHED } - if(($a->argc == 2) && (intval($a->argv[1]))) { + + if (($a->argc == 2) && (intval($a->argv[1]))) { check_form_security_token_redirectOnErr('/group', 'group_edit'); $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", @@ -50,14 +53,16 @@ function group_post(App &$a) { } $group = $r[0]; $groupname = notags(trim($_POST['groupname'])); - if((strlen($groupname)) && ($groupname != $group['name'])) { + if ((strlen($groupname)) && ($groupname != $group['name'])) { $r = q("UPDATE `group` SET `name` = '%s' WHERE `uid` = %d AND `id` = %d", dbesc($groupname), intval(local_user()), intval($group['id']) ); - if($r) + + if ($r) { info( t('Group name changed.') . EOL ); + } } $a->page['aside'] = group_side(); From 40bdc5d33c740ed5c73f56056457a0e7b2d82117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 11:14:30 +0100 Subject: [PATCH 18/96] added curly braces + space between "if" and brace + added TODO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/home.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/mod/home.php b/mod/home.php index 7289a0fb6d..8bee1aef00 100644 --- a/mod/home.php +++ b/mod/home.php @@ -6,12 +6,13 @@ function home_init(App &$a) { $ret = array(); call_hooks('home_init',$ret); - if(local_user() && ($a->user['nickname'])) + if (local_user() && ($a->user['nickname'])) { goaway(App::get_baseurl()."/network"); - //goaway(App::get_baseurl()."/profile/".$a->user['nickname']); + } - if(strlen(get_config('system','singleuser'))) + if (strlen(get_config('system','singleuser'))) { goaway(App::get_baseurl()."/profile/" . get_config('system','singleuser')); + } }} @@ -21,18 +22,24 @@ function home_content(App &$a) { $o = ''; - if(x($_SESSION,'theme')) + if (x($_SESSION,'theme')) { unset($_SESSION['theme']); - if(x($_SESSION,'mobile-theme')) + } + if (x($_SESSION,'mobile-theme')) { unset($_SESSION['mobile-theme']); + } - if(file_exists('home.html')){ - if(file_exists('home.css')){ - $a->page['htmlhead'] .= '';} + /// @TODO No absolute path used, maybe risky (security) + if (file_exists('home.html')) { + if (file_exists('home.css')) { + $a->page['htmlhead'] .= ''; + } - $o .= file_get_contents('home.html');} + $o .= file_get_contents('home.html');} - else $o .= '

'.((x($a->config,'sitename')) ? sprintf(t("Welcome to %s"), $a->config['sitename']) : "").'

'; + else { + $o .= '

'.((x($a->config,'sitename')) ? sprintf(t("Welcome to %s"), $a->config['sitename']) : "").'

'; + } $o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1); From 244636d26c790ae15b8af105d07b37dac47c6ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 11:14:30 +0100 Subject: [PATCH 19/96] added curly braces + space between "if" and brace + added TODO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/home.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/mod/home.php b/mod/home.php index 7289a0fb6d..8bee1aef00 100644 --- a/mod/home.php +++ b/mod/home.php @@ -6,12 +6,13 @@ function home_init(App &$a) { $ret = array(); call_hooks('home_init',$ret); - if(local_user() && ($a->user['nickname'])) + if (local_user() && ($a->user['nickname'])) { goaway(App::get_baseurl()."/network"); - //goaway(App::get_baseurl()."/profile/".$a->user['nickname']); + } - if(strlen(get_config('system','singleuser'))) + if (strlen(get_config('system','singleuser'))) { goaway(App::get_baseurl()."/profile/" . get_config('system','singleuser')); + } }} @@ -21,18 +22,24 @@ function home_content(App &$a) { $o = ''; - if(x($_SESSION,'theme')) + if (x($_SESSION,'theme')) { unset($_SESSION['theme']); - if(x($_SESSION,'mobile-theme')) + } + if (x($_SESSION,'mobile-theme')) { unset($_SESSION['mobile-theme']); + } - if(file_exists('home.html')){ - if(file_exists('home.css')){ - $a->page['htmlhead'] .= '';} + /// @TODO No absolute path used, maybe risky (security) + if (file_exists('home.html')) { + if (file_exists('home.css')) { + $a->page['htmlhead'] .= ''; + } - $o .= file_get_contents('home.html');} + $o .= file_get_contents('home.html');} - else $o .= '

'.((x($a->config,'sitename')) ? sprintf(t("Welcome to %s"), $a->config['sitename']) : "").'

'; + else { + $o .= '

'.((x($a->config,'sitename')) ? sprintf(t("Welcome to %s"), $a->config['sitename']) : "").'

'; + } $o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1); From 4299cce71907ec820281be2e2208e2c62727ce00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 11:18:54 +0100 Subject: [PATCH 20/96] added curly braces + space between "if" and brace + added missing @param MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/item.php | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/mod/item.php b/mod/item.php index a665c6ffe3..a11845e55f 100644 --- a/mod/item.php +++ b/mod/item.php @@ -766,8 +766,9 @@ function item_post(App &$a) { } $json = array('cancel' => 1); - if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) + if (x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) { $json['reload'] = App::get_baseurl() . '/' . $_REQUEST['jsreload']; + } echo json_encode($json); killme(); @@ -1049,13 +1050,14 @@ function item_post_return($baseurl, $api_source, $return_path) { if($api_source) return; - if($return_path) { + if ($return_path) { goaway($return_path); } $json = array('success' => 1); - if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) + if (x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) { $json['reload'] = $baseurl . '/' . $_REQUEST['jsreload']; + } logger('post_json: ' . print_r($json,true), LOGGER_DEBUG); @@ -1067,15 +1069,16 @@ function item_post_return($baseurl, $api_source, $return_path) { function item_content(App &$a) { - if((! local_user()) && (! remote_user())) + if ((! local_user()) && (! remote_user())) { return; + } require_once('include/security.php'); $o = ''; - if(($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) { + if (($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) { $o = drop_item($a->argv[2], !is_ajax()); - if (is_ajax()){ + if (is_ajax()) { // ajax return: [, 0 (no perm) | ] echo json_encode(array(intval($a->argv[2]), intval($o))); killme(); @@ -1088,6 +1091,7 @@ function item_content(App &$a) { * This function removes the tag $tag from the text $body and replaces it with * the appropiate link. * + * @param App $a Application instance @TODO is unused in this function's scope (excluding included files) * @param unknown_type $body the text to replace the tag in * @param string $inform a comma-seperated string containing everybody to inform * @param string $str_tags string to add the tag to @@ -1105,13 +1109,14 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo $r = null; //is it a person tag? - if(strpos($tag,'@') === 0) { + if (strpos($tag,'@') === 0) { //is it already replaced? - if(strpos($tag,'[url=')) { + if (strpos($tag,'[url=')) { //append tag to str_tags - if(!stristr($str_tags,$tag)) { - if(strlen($str_tags)) + if (!stristr($str_tags,$tag)) { + if (strlen($str_tags)) { $str_tags .= ','; + } $str_tags .= $tag; } From 757a0c76f09907bdd066b195d3c9d8a995f54d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 11:18:54 +0100 Subject: [PATCH 21/96] added curly braces + space between "if" and brace + added missing @param MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/item.php | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/mod/item.php b/mod/item.php index a665c6ffe3..a11845e55f 100644 --- a/mod/item.php +++ b/mod/item.php @@ -766,8 +766,9 @@ function item_post(App &$a) { } $json = array('cancel' => 1); - if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) + if (x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) { $json['reload'] = App::get_baseurl() . '/' . $_REQUEST['jsreload']; + } echo json_encode($json); killme(); @@ -1049,13 +1050,14 @@ function item_post_return($baseurl, $api_source, $return_path) { if($api_source) return; - if($return_path) { + if ($return_path) { goaway($return_path); } $json = array('success' => 1); - if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) + if (x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) { $json['reload'] = $baseurl . '/' . $_REQUEST['jsreload']; + } logger('post_json: ' . print_r($json,true), LOGGER_DEBUG); @@ -1067,15 +1069,16 @@ function item_post_return($baseurl, $api_source, $return_path) { function item_content(App &$a) { - if((! local_user()) && (! remote_user())) + if ((! local_user()) && (! remote_user())) { return; + } require_once('include/security.php'); $o = ''; - if(($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) { + if (($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) { $o = drop_item($a->argv[2], !is_ajax()); - if (is_ajax()){ + if (is_ajax()) { // ajax return: [, 0 (no perm) | ] echo json_encode(array(intval($a->argv[2]), intval($o))); killme(); @@ -1088,6 +1091,7 @@ function item_content(App &$a) { * This function removes the tag $tag from the text $body and replaces it with * the appropiate link. * + * @param App $a Application instance @TODO is unused in this function's scope (excluding included files) * @param unknown_type $body the text to replace the tag in * @param string $inform a comma-seperated string containing everybody to inform * @param string $str_tags string to add the tag to @@ -1105,13 +1109,14 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo $r = null; //is it a person tag? - if(strpos($tag,'@') === 0) { + if (strpos($tag,'@') === 0) { //is it already replaced? - if(strpos($tag,'[url=')) { + if (strpos($tag,'[url=')) { //append tag to str_tags - if(!stristr($str_tags,$tag)) { - if(strlen($str_tags)) + if (!stristr($str_tags,$tag)) { + if (strlen($str_tags)) { $str_tags .= ','; + } $str_tags .= $tag; } From 9c097c20dd7d9bc3cc611c4da9448b8be23af45c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 11:21:32 +0100 Subject: [PATCH 22/96] added curly braces + space between "if" and brace + initialized $result (was only within if() block but not outside of it) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/group.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/mod/group.php b/mod/group.php index 08b7801a7b..75bb2b7c81 100644 --- a/mod/group.php +++ b/mod/group.php @@ -104,26 +104,32 @@ function group_content(App &$a) { } - if(($a->argc == 3) && ($a->argv[1] === 'drop')) { + if (($a->argc == 3) && ($a->argv[1] === 'drop')) { check_form_security_token_redirectOnErr('/group', 'group_drop', 't'); - if(intval($a->argv[2])) { + if (intval($a->argv[2])) { $r = q("SELECT `name` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[2]), intval(local_user()) ); - if (dbm::is_result($r)) + + $result = null; + + if (dbm::is_result($r)) { $result = group_rmv(local_user(),$r[0]['name']); - if($result) + } + + if ($result) { info( t('Group removed.') . EOL); - else + } else { notice( t('Unable to remove group.') . EOL); + } } goaway(App::get_baseurl() . '/group'); // NOTREACHED } - if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) { + if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) { check_form_security_token_ForbiddenOnErr('group_member_change', 't'); $r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1", @@ -134,7 +140,7 @@ function group_content(App &$a) { $change = intval($a->argv[2]); } - if(($a->argc > 1) && (intval($a->argv[1]))) { + if (($a->argc > 1) && (intval($a->argv[1]))) { require_once('include/acl_selectors.php'); $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", From beca51bfbaab4d0c26d4d8da1dbcbb277e2024d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 11:21:32 +0100 Subject: [PATCH 23/96] added curly braces + space between "if" and brace + initialized $result (was only within if() block but not outside of it) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/group.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/mod/group.php b/mod/group.php index 08b7801a7b..75bb2b7c81 100644 --- a/mod/group.php +++ b/mod/group.php @@ -104,26 +104,32 @@ function group_content(App &$a) { } - if(($a->argc == 3) && ($a->argv[1] === 'drop')) { + if (($a->argc == 3) && ($a->argv[1] === 'drop')) { check_form_security_token_redirectOnErr('/group', 'group_drop', 't'); - if(intval($a->argv[2])) { + if (intval($a->argv[2])) { $r = q("SELECT `name` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[2]), intval(local_user()) ); - if (dbm::is_result($r)) + + $result = null; + + if (dbm::is_result($r)) { $result = group_rmv(local_user(),$r[0]['name']); - if($result) + } + + if ($result) { info( t('Group removed.') . EOL); - else + } else { notice( t('Unable to remove group.') . EOL); + } } goaway(App::get_baseurl() . '/group'); // NOTREACHED } - if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) { + if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) { check_form_security_token_ForbiddenOnErr('group_member_change', 't'); $r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1", @@ -134,7 +140,7 @@ function group_content(App &$a) { $change = intval($a->argv[2]); } - if(($a->argc > 1) && (intval($a->argv[1]))) { + if (($a->argc > 1) && (intval($a->argv[1]))) { require_once('include/acl_selectors.php'); $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", From 507db84243e637b289f7e5381ef7bad44822421b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 11:27:40 +0100 Subject: [PATCH 24/96] added curly braces + space between "if" and brace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/notify.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/mod/notify.php b/mod/notify.php index cd836dada7..2d34821ded 100644 --- a/mod/notify.php +++ b/mod/notify.php @@ -3,10 +3,13 @@ require_once('include/NotificationsManager.php'); function notify_init(App &$a) { - if(! local_user()) return; + if (! local_user()) { + return; + } + $nm = new NotificationsManager(); - - if($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) { + + if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) { $note = $nm->getByID($a->argv[2]); if ($note) { $nm->setSeen($note); @@ -17,8 +20,9 @@ function notify_init(App &$a) { $urldata = parse_url($note['link']); $guid = basename($urldata["path"]); $itemdata = get_item_id($guid, local_user()); - if ($itemdata["id"] != 0) + if ($itemdata["id"] != 0) { $note['link'] = App::get_baseurl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"]; + } } goaway($note['link']); @@ -27,7 +31,7 @@ function notify_init(App &$a) { goaway(App::get_baseurl(true)); } - if($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) { + if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) { $r = $nm->setAllSeen(); $j = json_encode(array('result' => ($r) ? 'success' : 'fail')); echo $j; @@ -37,7 +41,9 @@ function notify_init(App &$a) { } function notify_content(App &$a) { - if(! local_user()) return login(); + if (! local_user()) { + return login(); + } $nm = new NotificationsManager(); From d0bc38dbf85cf94588dbf9a59b78ced29eac35a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 11:27:40 +0100 Subject: [PATCH 25/96] added curly braces + space between "if" and brace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/notify.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/mod/notify.php b/mod/notify.php index cd836dada7..2d34821ded 100644 --- a/mod/notify.php +++ b/mod/notify.php @@ -3,10 +3,13 @@ require_once('include/NotificationsManager.php'); function notify_init(App &$a) { - if(! local_user()) return; + if (! local_user()) { + return; + } + $nm = new NotificationsManager(); - - if($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) { + + if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) { $note = $nm->getByID($a->argv[2]); if ($note) { $nm->setSeen($note); @@ -17,8 +20,9 @@ function notify_init(App &$a) { $urldata = parse_url($note['link']); $guid = basename($urldata["path"]); $itemdata = get_item_id($guid, local_user()); - if ($itemdata["id"] != 0) + if ($itemdata["id"] != 0) { $note['link'] = App::get_baseurl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"]; + } } goaway($note['link']); @@ -27,7 +31,7 @@ function notify_init(App &$a) { goaway(App::get_baseurl(true)); } - if($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) { + if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) { $r = $nm->setAllSeen(); $j = json_encode(array('result' => ($r) ? 'success' : 'fail')); echo $j; @@ -37,7 +41,9 @@ function notify_init(App &$a) { } function notify_content(App &$a) { - if(! local_user()) return login(); + if (! local_user()) { + return login(); + } $nm = new NotificationsManager(); From c1845c97cc944882865a9542e1c76572f4cf03e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 11:33:04 +0100 Subject: [PATCH 26/96] added more curly braces + fixed space->tab for code indentation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/videos.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mod/videos.php b/mod/videos.php index eb5a2cee4e..de6e016666 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -106,13 +106,17 @@ function videos_post(App &$a) { $owner_uid = $a->data['user']['uid']; - if (local_user() != $owner_uid) goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']); + if (local_user() != $owner_uid) { + goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']); + } - if(($a->argc == 2) && x($_POST,'delete') && x($_POST, 'id')) { + if (($a->argc == 2) && x($_POST,'delete') && x($_POST, 'id')) { // Check if we should do HTML-based delete confirmation if(!x($_REQUEST,'confirm')) { - if(x($_REQUEST,'canceled')) goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']); + if (x($_REQUEST,'canceled')) { + goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']); + } $drop_url = $a->query_string; $a->page['content'] = replace_macros(get_markup_template('confirm.tpl'), array( @@ -149,7 +153,7 @@ function videos_post(App &$a) { dbesc($video_id), intval(local_user()) ); - #echo "
"; var_dump($i); killme();
+			//echo "
"; var_dump($i); killme();
 			if(count($i)) {
 				q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
 					dbesc(datetime_convert()),
@@ -172,7 +176,7 @@ function videos_post(App &$a) {
 		return; // NOTREACHED
 	}
 
-    goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+	goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
 
 }
 

From 1248b26d3c1acb0c6a54cf950dec1147a56d59cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?= 
Date: Tue, 20 Dec 2016 11:33:04 +0100
Subject: [PATCH 27/96] added more curly braces + fixed space->tab for code
 indentation.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Roland Häder 
---
 mod/videos.php | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/mod/videos.php b/mod/videos.php
index eb5a2cee4e..de6e016666 100644
--- a/mod/videos.php
+++ b/mod/videos.php
@@ -106,13 +106,17 @@ function videos_post(App &$a) {
 
 	$owner_uid = $a->data['user']['uid'];
 
-	if (local_user() != $owner_uid) goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+	if (local_user() != $owner_uid) {
+		goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+	}
 
-	if(($a->argc == 2) && x($_POST,'delete') && x($_POST, 'id')) {
+	if (($a->argc == 2) && x($_POST,'delete') && x($_POST, 'id')) {
 
 		// Check if we should do HTML-based delete confirmation
 		if(!x($_REQUEST,'confirm')) {
-			if(x($_REQUEST,'canceled')) goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+			if (x($_REQUEST,'canceled')) {
+				goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+			}
 
 			$drop_url = $a->query_string;
 			$a->page['content'] = replace_macros(get_markup_template('confirm.tpl'), array(
@@ -149,7 +153,7 @@ function videos_post(App &$a) {
 				dbesc($video_id),
 				intval(local_user())
 			);
-			#echo "
"; var_dump($i); killme();
+			//echo "
"; var_dump($i); killme();
 			if(count($i)) {
 				q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
 					dbesc(datetime_convert()),
@@ -172,7 +176,7 @@ function videos_post(App &$a) {
 		return; // NOTREACHED
 	}
 
-    goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+	goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
 
 }
 

From c86f09a89467f14cb138611dbffb73bcbb6c0861 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?= 
Date: Tue, 20 Dec 2016 11:36:03 +0100
Subject: [PATCH 28/96] added spaces + curly braces
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Roland Häder 
---
 include/notifier.php  |  2 +-
 include/socgraph.php  | 14 +++++++-------
 mod/profile_photo.php |  6 ++++--
 mod/profiles.php      |  3 ++-
 mod/redir.php         |  8 +++++---
 mod/regmod.php        |  3 ++-
 mod/settings.php      |  3 ++-
 7 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/include/notifier.php b/include/notifier.php
index 8823834c1d..9e1450ba2b 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -558,7 +558,7 @@ function notifier_run(&$argv, &$argc){
 	if($slap && count($url_recipients) && ($public_message || $push_notify) && $normal_mode) {
 		if(!get_config('system','dfrn_only')) {
 			foreach($url_recipients as $url) {
-				if($url) {
+				if ($url) {
 					logger('notifier: urldelivery: ' . $url);
 					$deliver_status = slapper($owner,$url,$slap);
 					/// @TODO Redeliver/queue these items on failure, though there is no contact record
diff --git a/include/socgraph.php b/include/socgraph.php
index 31c7e597d3..3fe1227f31 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -93,19 +93,19 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
 
 		if(isset($entry->urls)) {
 			foreach($entry->urls as $url) {
-				if($url->type == 'profile') {
+				if ($url->type == 'profile') {
 					$profile_url = $url->value;
 					continue;
 				}
-				if($url->type == 'webfinger') {
+				if ($url->type == 'webfinger') {
 					$connect_url = str_replace('acct:' , '', $url->value);
 					continue;
 				}
 			}
 		}
-		if(isset($entry->photos)) {
+		if (isset($entry->photos)) {
 			foreach($entry->photos as $photo) {
-				if($photo->type == 'profile') {
+				if ($photo->type == 'profile') {
 					$profile_photo = $photo->value;
 					continue;
 				}
@@ -1334,7 +1334,7 @@ function poco_discover_server_users($data, $server) {
 		$username = "";
 		if (isset($entry->urls)) {
 			foreach($entry->urls as $url)
-				if($url->type == 'profile') {
+				if ($url->type == 'profile') {
 					$profile_url = $url->value;
 					$urlparts = parse_url($profile_url);
 					$username = end(explode("/", $urlparts["path"]));
@@ -1378,11 +1378,11 @@ function poco_discover_server($data, $default_generation = 0) {
 
 		if(isset($entry->urls)) {
 			foreach($entry->urls as $url) {
-				if($url->type == 'profile') {
+				if ($url->type == 'profile') {
 					$profile_url = $url->value;
 					continue;
 				}
-				if($url->type == 'webfinger') {
+				if ($url->type == 'webfinger') {
 					$connect_url = str_replace('acct:' , '', $url->value);
 					continue;
 				}
diff --git a/mod/profile_photo.php b/mod/profile_photo.php
index 52cf6d26f4..fd7302e4da 100644
--- a/mod/profile_photo.php
+++ b/mod/profile_photo.php
@@ -124,8 +124,9 @@ function profile_photo_post(App &$a) {
 				info( t('Shift-reload the page or clear browser cache if the new photo does not display immediately.') . EOL);
 				// Update global directory in background
 				$url = App::get_baseurl() . '/profile/' . $a->user['nickname'];
-				if($url && strlen(get_config('system','directory')))
+				if ($url && strlen(get_config('system','directory'))) {
 					proc_run(PRIORITY_LOW, "include/directory.php", $url);
+				}
 
 				require_once('include/profile_update.php');
 				profile_change();
@@ -223,8 +224,9 @@ function profile_photo_content(App &$a) {
 
 			// Update global directory in background
 			$url = $_SESSION['my_url'];
-			if($url && strlen(get_config('system','directory')))
+			if ($url && strlen(get_config('system','directory'))) {
 				proc_run(PRIORITY_LOW, "include/directory.php", $url);
+			}
 
 			goaway(App::get_baseurl() . '/profiles');
 			return; // NOTREACHED
diff --git a/mod/profiles.php b/mod/profiles.php
index 186d7a615e..cca7a57ec5 100644
--- a/mod/profiles.php
+++ b/mod/profiles.php
@@ -502,8 +502,9 @@ function profiles_post(App &$a) {
 
 			// Update global directory in background
 			$url = $_SESSION['my_url'];
-			if($url && strlen(get_config('system','directory')))
+			if ($url && strlen(get_config('system','directory'))) {
 				proc_run(PRIORITY_LOW, "include/directory.php", $url);
+			}
 
 			require_once('include/profile_update.php');
 			profile_change();
diff --git a/mod/redir.php b/mod/redir.php
index e581580271..b0c0b2c099 100644
--- a/mod/redir.php
+++ b/mod/redir.php
@@ -63,12 +63,14 @@ function redir_init(App &$a) {
 			. '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest . $quiet );
 	}
 
-	if(local_user())
+	if (local_user()) {
 		$handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3);
-	if(remote_user())
+	}
+	if (remote_user()) {
 		$handle = $_SESSION['handle'];
+	}
 
-	if($url) {
+	if ($url) {
 		$url = str_replace('{zid}','&zid=' . $handle,$url);
 		goaway($url);
 	}
diff --git a/mod/regmod.php b/mod/regmod.php
index d20383ba53..60da71321e 100644
--- a/mod/regmod.php
+++ b/mod/regmod.php
@@ -38,8 +38,9 @@ function user_allow($hash) {
 	);
 	if (dbm::is_result($r) && $r[0]['net-publish']) {
 		$url = App::get_baseurl() . '/profile/' . $user[0]['nickname'];
-		if($url && strlen(get_config('system','directory')))
+		if ($url && strlen(get_config('system','directory'))) {
 			proc_run(PRIORITY_LOW, "include/directory.php", $url);
+		}
 	}
 
 	push_lang($register[0]['language']);
diff --git a/mod/settings.php b/mod/settings.php
index 0d052cc1b7..14ef33fc86 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -629,8 +629,9 @@ function settings_post(App &$a) {
 	if(($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) {
 		// Update global directory in background
 		$url = $_SESSION['my_url'];
-		if($url && strlen(get_config('system','directory')))
+		if ($url && strlen(get_config('system','directory'))) {
 			proc_run(PRIORITY_LOW, "include/directory.php", $url);
+		}
 	}
 
 	require_once('include/profile_update.php');

From d3391e12e340cd33833b79f858afeb04ce969ceb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?= 
Date: Tue, 20 Dec 2016 11:36:03 +0100
Subject: [PATCH 29/96] added spaces + curly braces
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Roland Häder 
---
 include/notifier.php  |  2 +-
 include/socgraph.php  | 14 +++++++-------
 mod/profile_photo.php |  6 ++++--
 mod/profiles.php      |  3 ++-
 mod/redir.php         |  8 +++++---
 mod/regmod.php        |  3 ++-
 mod/settings.php      |  3 ++-
 7 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/include/notifier.php b/include/notifier.php
index 8823834c1d..9e1450ba2b 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -558,7 +558,7 @@ function notifier_run(&$argv, &$argc){
 	if($slap && count($url_recipients) && ($public_message || $push_notify) && $normal_mode) {
 		if(!get_config('system','dfrn_only')) {
 			foreach($url_recipients as $url) {
-				if($url) {
+				if ($url) {
 					logger('notifier: urldelivery: ' . $url);
 					$deliver_status = slapper($owner,$url,$slap);
 					/// @TODO Redeliver/queue these items on failure, though there is no contact record
diff --git a/include/socgraph.php b/include/socgraph.php
index 31c7e597d3..3fe1227f31 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -93,19 +93,19 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
 
 		if(isset($entry->urls)) {
 			foreach($entry->urls as $url) {
-				if($url->type == 'profile') {
+				if ($url->type == 'profile') {
 					$profile_url = $url->value;
 					continue;
 				}
-				if($url->type == 'webfinger') {
+				if ($url->type == 'webfinger') {
 					$connect_url = str_replace('acct:' , '', $url->value);
 					continue;
 				}
 			}
 		}
-		if(isset($entry->photos)) {
+		if (isset($entry->photos)) {
 			foreach($entry->photos as $photo) {
-				if($photo->type == 'profile') {
+				if ($photo->type == 'profile') {
 					$profile_photo = $photo->value;
 					continue;
 				}
@@ -1334,7 +1334,7 @@ function poco_discover_server_users($data, $server) {
 		$username = "";
 		if (isset($entry->urls)) {
 			foreach($entry->urls as $url)
-				if($url->type == 'profile') {
+				if ($url->type == 'profile') {
 					$profile_url = $url->value;
 					$urlparts = parse_url($profile_url);
 					$username = end(explode("/", $urlparts["path"]));
@@ -1378,11 +1378,11 @@ function poco_discover_server($data, $default_generation = 0) {
 
 		if(isset($entry->urls)) {
 			foreach($entry->urls as $url) {
-				if($url->type == 'profile') {
+				if ($url->type == 'profile') {
 					$profile_url = $url->value;
 					continue;
 				}
-				if($url->type == 'webfinger') {
+				if ($url->type == 'webfinger') {
 					$connect_url = str_replace('acct:' , '', $url->value);
 					continue;
 				}
diff --git a/mod/profile_photo.php b/mod/profile_photo.php
index 52cf6d26f4..fd7302e4da 100644
--- a/mod/profile_photo.php
+++ b/mod/profile_photo.php
@@ -124,8 +124,9 @@ function profile_photo_post(App &$a) {
 				info( t('Shift-reload the page or clear browser cache if the new photo does not display immediately.') . EOL);
 				// Update global directory in background
 				$url = App::get_baseurl() . '/profile/' . $a->user['nickname'];
-				if($url && strlen(get_config('system','directory')))
+				if ($url && strlen(get_config('system','directory'))) {
 					proc_run(PRIORITY_LOW, "include/directory.php", $url);
+				}
 
 				require_once('include/profile_update.php');
 				profile_change();
@@ -223,8 +224,9 @@ function profile_photo_content(App &$a) {
 
 			// Update global directory in background
 			$url = $_SESSION['my_url'];
-			if($url && strlen(get_config('system','directory')))
+			if ($url && strlen(get_config('system','directory'))) {
 				proc_run(PRIORITY_LOW, "include/directory.php", $url);
+			}
 
 			goaway(App::get_baseurl() . '/profiles');
 			return; // NOTREACHED
diff --git a/mod/profiles.php b/mod/profiles.php
index 186d7a615e..cca7a57ec5 100644
--- a/mod/profiles.php
+++ b/mod/profiles.php
@@ -502,8 +502,9 @@ function profiles_post(App &$a) {
 
 			// Update global directory in background
 			$url = $_SESSION['my_url'];
-			if($url && strlen(get_config('system','directory')))
+			if ($url && strlen(get_config('system','directory'))) {
 				proc_run(PRIORITY_LOW, "include/directory.php", $url);
+			}
 
 			require_once('include/profile_update.php');
 			profile_change();
diff --git a/mod/redir.php b/mod/redir.php
index e581580271..b0c0b2c099 100644
--- a/mod/redir.php
+++ b/mod/redir.php
@@ -63,12 +63,14 @@ function redir_init(App &$a) {
 			. '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest . $quiet );
 	}
 
-	if(local_user())
+	if (local_user()) {
 		$handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3);
-	if(remote_user())
+	}
+	if (remote_user()) {
 		$handle = $_SESSION['handle'];
+	}
 
-	if($url) {
+	if ($url) {
 		$url = str_replace('{zid}','&zid=' . $handle,$url);
 		goaway($url);
 	}
diff --git a/mod/regmod.php b/mod/regmod.php
index d20383ba53..60da71321e 100644
--- a/mod/regmod.php
+++ b/mod/regmod.php
@@ -38,8 +38,9 @@ function user_allow($hash) {
 	);
 	if (dbm::is_result($r) && $r[0]['net-publish']) {
 		$url = App::get_baseurl() . '/profile/' . $user[0]['nickname'];
-		if($url && strlen(get_config('system','directory')))
+		if ($url && strlen(get_config('system','directory'))) {
 			proc_run(PRIORITY_LOW, "include/directory.php", $url);
+		}
 	}
 
 	push_lang($register[0]['language']);
diff --git a/mod/settings.php b/mod/settings.php
index 0d052cc1b7..14ef33fc86 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -629,8 +629,9 @@ function settings_post(App &$a) {
 	if(($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) {
 		// Update global directory in background
 		$url = $_SESSION['my_url'];
-		if($url && strlen(get_config('system','directory')))
+		if ($url && strlen(get_config('system','directory'))) {
 			proc_run(PRIORITY_LOW, "include/directory.php", $url);
+		}
 	}
 
 	require_once('include/profile_update.php');

From 5588472f6d2c4dade67955af67c72fe43150d76d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roland=20H=C3=A4der?= 
Date: Tue, 20 Dec 2016 11:38:16 +0100
Subject: [PATCH 30/96] added spaces + curly braces
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Roland Häder 
---
 include/conversation.php |  6 ++++--
 include/email.php        | 19 +++++++++++++------
 include/socgraph.php     |  7 ++++---
 include/text.php         |  2 +-
 mod/randprof.php         |  6 +++++-
 5 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/include/conversation.php b/include/conversation.php
index 916a9e229e..ccfc070d4e 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -324,11 +324,13 @@ function localize_item(&$item){
 	// add sparkle links to appropriate permalinks
 
 	$x = stristr($item['plink'],'/display/');
-	if($x) {
+	if ($x) {
 		$sparkle = false;
 		$y = best_link_url($item,$sparkle,true);
-		if(strstr($y,'/redir/'))
+
+		if (strstr($y,'/redir/')) {
 			$item['plink'] = $y . '?f=&url=' . $item['plink'];
+		}
 	}
 
 
diff --git a/include/email.php b/include/email.php
index 2c05d3233f..42f80c2427 100644
--- a/include/email.php
+++ b/include/email.php
@@ -96,15 +96,20 @@ function email_get_msg($mbox,$uid, $reply) {
 		$html = '';
 		foreach($struc->parts as $ptop => $p) {
 			$x = email_get_part($mbox,$uid,$p,$ptop + 1, 'plain');
-			if($x)	$text .= $x;
+			if ($x) {
+				$text .= $x;
+			}
 
 			$x = email_get_part($mbox,$uid,$p,$ptop + 1, 'html');
-			if($x)	$html .= $x;
+			if ($x) {
+				$html .= $x;
+			}
 		}
-		if (trim($html) != '')
+		if (trim($html) != '') {
 			$ret['body'] = html2bbcode($html);
-		else
+		} else {
 			$ret['body'] = $text;
+		}
 	}
 
 	$ret['body'] = removegpg($ret['body']);
@@ -112,8 +117,9 @@ function email_get_msg($mbox,$uid, $reply) {
 	$ret['body'] = $msg['body'];
 	$ret['body'] = convertquote($ret['body'], $reply);
 
-	if (trim($html) != '')
+	if (trim($html) != '') {
 		$ret['body'] = removelinebreak($ret['body']);
+	}
 
 	$ret['body'] = unifyattributionline($ret['body']);
 
@@ -189,8 +195,9 @@ function email_get_part($mbox,$uid,$p,$partno, $subtype) {
 		$x = "";
 		foreach ($p->parts as $partno0=>$p2) {
 			$x .=  email_get_part($mbox,$uid,$p2,$partno . '.' . ($partno0+1), $subtype);  // 1.2, 1.2.1, etc.
-			//if($x)
+			//if ($x) {
 			//	return $x;
+			//}
 		}
 		return $x;
 	}
diff --git a/include/socgraph.php b/include/socgraph.php
index 3fe1227f31..a779e88eff 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -1188,16 +1188,17 @@ function update_suggestions() {
 
 	if(strlen(get_config('system','directory'))) {
 		$x = fetch_url(get_server()."/pubsites");
-		if($x) {
+		if ($x) {
 			$j = json_decode($x);
-			if($j->entries) {
+			if ($j->entries) {
 				foreach($j->entries as $entry) {
 
 					poco_check_server($entry->url);
 
 					$url = $entry->url . '/poco';
-					if(! in_array($url,$done))
+					if (! in_array($url,$done)) {
 						poco_load(0,0,0,$entry->url . '/poco');
+					}
 				}
 			}
 		}
diff --git a/include/text.php b/include/text.php
index 59d4e1cc9f..8d3b6a8050 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1367,7 +1367,7 @@ function prepare_body(&$item,$attach = false, $preview = false) {
 	// map
 	if(strpos($s,'
') !== false && $item['coord']) { $x = generate_map(trim($item['coord'])); - if($x) { + if ($x) { $s = preg_replace('/\
/','$0' . $x,$s); } } diff --git a/mod/randprof.php b/mod/randprof.php index bf9fa34256..08157a3851 100644 --- a/mod/randprof.php +++ b/mod/randprof.php @@ -3,8 +3,12 @@ function randprof_init(App &$a) { require_once('include/Contact.php'); + $x = random_profile(); - if($x) + + if ($x) { goaway(zrl($x)); + } + goaway(App::get_baseurl() . '/profile'); } From ad3779fd06c41476f9cc35c7b43f395d0d8eaf8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 11:38:16 +0100 Subject: [PATCH 31/96] added spaces + curly braces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/conversation.php | 6 ++++-- include/email.php | 19 +++++++++++++------ include/socgraph.php | 7 ++++--- include/text.php | 2 +- mod/randprof.php | 6 +++++- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 916a9e229e..ccfc070d4e 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -324,11 +324,13 @@ function localize_item(&$item){ // add sparkle links to appropriate permalinks $x = stristr($item['plink'],'/display/'); - if($x) { + if ($x) { $sparkle = false; $y = best_link_url($item,$sparkle,true); - if(strstr($y,'/redir/')) + + if (strstr($y,'/redir/')) { $item['plink'] = $y . '?f=&url=' . $item['plink']; + } } diff --git a/include/email.php b/include/email.php index 2c05d3233f..42f80c2427 100644 --- a/include/email.php +++ b/include/email.php @@ -96,15 +96,20 @@ function email_get_msg($mbox,$uid, $reply) { $html = ''; foreach($struc->parts as $ptop => $p) { $x = email_get_part($mbox,$uid,$p,$ptop + 1, 'plain'); - if($x) $text .= $x; + if ($x) { + $text .= $x; + } $x = email_get_part($mbox,$uid,$p,$ptop + 1, 'html'); - if($x) $html .= $x; + if ($x) { + $html .= $x; + } } - if (trim($html) != '') + if (trim($html) != '') { $ret['body'] = html2bbcode($html); - else + } else { $ret['body'] = $text; + } } $ret['body'] = removegpg($ret['body']); @@ -112,8 +117,9 @@ function email_get_msg($mbox,$uid, $reply) { $ret['body'] = $msg['body']; $ret['body'] = convertquote($ret['body'], $reply); - if (trim($html) != '') + if (trim($html) != '') { $ret['body'] = removelinebreak($ret['body']); + } $ret['body'] = unifyattributionline($ret['body']); @@ -189,8 +195,9 @@ function email_get_part($mbox,$uid,$p,$partno, $subtype) { $x = ""; foreach ($p->parts as $partno0=>$p2) { $x .= email_get_part($mbox,$uid,$p2,$partno . '.' . ($partno0+1), $subtype); // 1.2, 1.2.1, etc. - //if($x) + //if ($x) { // return $x; + //} } return $x; } diff --git a/include/socgraph.php b/include/socgraph.php index 3fe1227f31..a779e88eff 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -1188,16 +1188,17 @@ function update_suggestions() { if(strlen(get_config('system','directory'))) { $x = fetch_url(get_server()."/pubsites"); - if($x) { + if ($x) { $j = json_decode($x); - if($j->entries) { + if ($j->entries) { foreach($j->entries as $entry) { poco_check_server($entry->url); $url = $entry->url . '/poco'; - if(! in_array($url,$done)) + if (! in_array($url,$done)) { poco_load(0,0,0,$entry->url . '/poco'); + } } } } diff --git a/include/text.php b/include/text.php index 59d4e1cc9f..8d3b6a8050 100644 --- a/include/text.php +++ b/include/text.php @@ -1367,7 +1367,7 @@ function prepare_body(&$item,$attach = false, $preview = false) { // map if(strpos($s,'
') !== false && $item['coord']) { $x = generate_map(trim($item['coord'])); - if($x) { + if ($x) { $s = preg_replace('/\
/','$0' . $x,$s); } } diff --git a/mod/randprof.php b/mod/randprof.php index bf9fa34256..08157a3851 100644 --- a/mod/randprof.php +++ b/mod/randprof.php @@ -3,8 +3,12 @@ function randprof_init(App &$a) { require_once('include/Contact.php'); + $x = random_profile(); - if($x) + + if ($x) { goaway(zrl($x)); + } + goaway(App::get_baseurl() . '/profile'); } From 51d352922ad485a537a70302423d5edc824733a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 11:39:53 +0100 Subject: [PATCH 32/96] Continued: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - added curly braces + spaces - added todo about testing empty/non-empty strings Signed-off-by: Roland Häder --- mod/settings.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mod/settings.php b/mod/settings.php index 14ef33fc86..97d4f5f603 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -824,8 +824,10 @@ function settings_content(App &$a) { $settings_connectors .= mini_group_select(local_user(), $default_group, t("Default group for OStatus contacts")); - if ($legacy_contact != "") + /// @TODO Found to much different usage to test empty/non-empty strings (e.g. empty(), trim() == '' ) which is wanted? + if ($legacy_contact != "") { $a->page['htmlhead'] = ''; + } $settings_connectors .= '
'; $settings_connectors .= ''; From e70b3b45df28bbed6429a28004270507f3508d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 11:39:53 +0100 Subject: [PATCH 33/96] Continued: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - added curly braces + spaces - added todo about testing empty/non-empty strings Signed-off-by: Roland Häder --- mod/settings.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mod/settings.php b/mod/settings.php index 14ef33fc86..97d4f5f603 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -824,8 +824,10 @@ function settings_content(App &$a) { $settings_connectors .= mini_group_select(local_user(), $default_group, t("Default group for OStatus contacts")); - if ($legacy_contact != "") + /// @TODO Found to much different usage to test empty/non-empty strings (e.g. empty(), trim() == '' ) which is wanted? + if ($legacy_contact != "") { $a->page['htmlhead'] = ''; + } $settings_connectors .= '
'; $settings_connectors .= ''; From e24c3a5b826d2357e40a173d9e7b66048dab5b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 11:56:34 +0100 Subject: [PATCH 34/96] added much more curly braces + space between "if" and brace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- doc/themes.md | 3 +- include/acl_selectors.php | 5 +- include/contact_widgets.php | 15 ++++-- include/group.php | 2 +- mod/allfriends.php | 11 ++-- mod/api.php | 4 +- mod/bookmarklet.php | 2 +- mod/community.php | 2 +- mod/contactgroup.php | 2 +- mod/contacts.php | 15 +++--- mod/content.php | 2 +- mod/crepair.php | 8 +-- mod/delegate.php | 2 +- mod/dirfind.php | 2 +- mod/editpost.php | 6 +-- mod/events.php | 8 +-- mod/filer.php | 2 +- mod/filerm.php | 2 +- mod/follow.php | 4 +- mod/fsuggest.php | 7 +-- mod/group.php | 4 +- mod/ignored.php | 14 +++-- mod/invite.php | 4 +- mod/manage.php | 5 +- mod/match.php | 3 +- mod/message.php | 4 +- mod/mood.php | 5 +- mod/network.php | 4 +- mod/nogroup.php | 8 +-- mod/notes.php | 5 +- mod/notifications.php | 4 +- mod/oexchange.php | 4 +- mod/ostatus_subscribe.php | 2 +- mod/poke.php | 14 +++-- mod/profile_photo.php | 6 +-- mod/profiles.php | 9 ++-- mod/profperm.php | 5 +- mod/qsearch.php | 3 +- mod/regmod.php | 11 ++-- mod/repair_ostatus.php | 2 +- mod/settings.php | 7 +-- mod/starred.php | 9 ++-- mod/suggest.php | 11 ++-- mod/tagrm.php | 8 +-- mod/uexport.php | 5 +- mod/viewsrc.php | 2 +- view/theme/duepuntozero/config.php | 84 ++++++++++++++++-------------- view/theme/frio/config.php | 9 +++- view/theme/quattro/config.php | 18 ++++--- view/theme/vier/config.php | 15 ++++-- 50 files changed, 224 insertions(+), 164 deletions(-) diff --git a/doc/themes.md b/doc/themes.md index 0ae7e694fe..0b8f6cb83d 100644 --- a/doc/themes.md +++ b/doc/themes.md @@ -124,8 +124,9 @@ The selected 1st part will be saved in the database by the theme_post function. function theme_post(App &$a){ // non local users shall not pass - if(! local_user()) + if (! local_user()) { return; + } // if the one specific submit button was pressed then proceed if (isset($_POST['duepuntozero-settings-submit'])){ // and save the selection key into the personal config of the user diff --git a/include/acl_selectors.php b/include/acl_selectors.php index cd68ffaa7d..c1edc8cc03 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -392,8 +392,9 @@ function construct_acl_data(&$a, $user) { function acl_lookup(&$a, $out_type = 'json') { - if(!local_user()) - return ""; + if (!local_user()) { + return ''; + } $start = (x($_REQUEST,'start') ? $_REQUEST['start'] : 0); $count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 100); diff --git a/include/contact_widgets.php b/include/contact_widgets.php index a74080e75b..71a75d431e 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -80,11 +80,13 @@ function networks_widget($baseurl,$selected = '') { $a = get_app(); - if(!local_user()) + if (!local_user()) { return ''; + } - if(!feature_enabled(local_user(),'networks')) + if (!feature_enabled(local_user(),'networks')) { return ''; + } $extra_sql = unavailable_networks(); @@ -116,15 +118,18 @@ function networks_widget($baseurl,$selected = '') { } function fileas_widget($baseurl,$selected = '') { - if(! local_user()) + if (! local_user()) { return ''; + } - if(! feature_enabled(local_user(),'filing')) + if (! feature_enabled(local_user(),'filing')) { return ''; + } $saved = get_pconfig(local_user(),'system','filetags'); - if(! strlen($saved)) + if (! strlen($saved)) { return; + } $matches = false; $terms = array(); diff --git a/include/group.php b/include/group.php index 67712aae7c..a2a55c4440 100644 --- a/include/group.php +++ b/include/group.php @@ -234,7 +234,7 @@ function group_side($every="contacts",$each="group",$editmode = "standard", $gro $o = ''; - if(! local_user()) + if (! local_user()) return ''; $groups = array(); diff --git a/mod/allfriends.php b/mod/allfriends.php index 43490e9640..f9cffcbb2d 100644 --- a/mod/allfriends.php +++ b/mod/allfriends.php @@ -8,16 +8,18 @@ require_once('mod/contacts.php'); function allfriends_content(App &$a) { $o = ''; - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } - if($a->argc > 1) + if ($a->argc > 1) { $cid = intval($a->argv[1]); + } - if(! $cid) + if (! $cid) { return; + } $uid = $a->user['uid']; @@ -26,7 +28,8 @@ function allfriends_content(App &$a) { intval(local_user()) ); - if(! count($c)) + if (! count($c)) { + } return; $a->page['aside'] = ""; diff --git a/mod/api.php b/mod/api.php index b398daac8c..74a0cff6f4 100644 --- a/mod/api.php +++ b/mod/api.php @@ -22,7 +22,7 @@ function oauth_get_client($request){ function api_post(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } @@ -84,7 +84,7 @@ function api_content(App &$a) { } - if(! local_user()) { + if (! local_user()) { /// @TODO We need login form to redirect to this page notice( t('Please login to continue.') . EOL ); return login(false,$request->get_parameters()); diff --git a/mod/bookmarklet.php b/mod/bookmarklet.php index 1d68069439..9bc8c33535 100644 --- a/mod/bookmarklet.php +++ b/mod/bookmarklet.php @@ -8,7 +8,7 @@ function bookmarklet_init(App &$a) { } function bookmarklet_content(App &$a) { - if(!local_user()) { + if (!local_user()) { $o = '

'.t('Login').'

'; $o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true); return $o; diff --git a/mod/community.php b/mod/community.php index 7a1e727338..2c2ea32b33 100644 --- a/mod/community.php +++ b/mod/community.php @@ -1,7 +1,7 @@ argv[1]==="batch") { contacts_batch_actions($a); @@ -147,15 +149,16 @@ function contacts_post(App &$a) { } $contact_id = intval($a->argv[1]); - if(! $contact_id) + if (! $contact_id) { return; + } $orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval(local_user()) ); - if(! count($orig_record)) { + if (! count($orig_record)) { notice( t('Could not access contact record.') . EOL); goaway('contacts'); return; // NOTREACHED @@ -164,7 +167,7 @@ function contacts_post(App &$a) { call_hooks('contact_edit_post', $_POST); $profile_id = intval($_POST['profile-assign']); - if($profile_id) { + if ($profile_id) { $r = q("SELECT `id` FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($profile_id), intval(local_user()) @@ -346,7 +349,7 @@ function contacts_content(App &$a) { nav_set_selected('contacts'); - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/content.php b/mod/content.php index 1a3fb10952..2377032a79 100644 --- a/mod/content.php +++ b/mod/content.php @@ -23,7 +23,7 @@ function content_content(&$a, $update = 0) { // Currently security is based on the logged in user - if(! local_user()) { + if (! local_user()) { return; } diff --git a/mod/crepair.php b/mod/crepair.php index 308d5b95e9..2661deaeed 100644 --- a/mod/crepair.php +++ b/mod/crepair.php @@ -3,8 +3,9 @@ require_once("include/contact_selectors.php"); require_once("mod/contacts.php"); function crepair_init(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } $contact_id = 0; @@ -31,8 +32,9 @@ function crepair_init(App &$a) { function crepair_post(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0); @@ -97,7 +99,7 @@ function crepair_post(App &$a) { function crepair_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/delegate.php b/mod/delegate.php index 7dbeef7377..8470a7ba0b 100644 --- a/mod/delegate.php +++ b/mod/delegate.php @@ -8,7 +8,7 @@ function delegate_init(App &$a) { function delegate_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/dirfind.php b/mod/dirfind.php index 80cba1c475..fc5750f2dd 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -7,7 +7,7 @@ require_once('mod/contacts.php'); function dirfind_init(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL ); return; } diff --git a/mod/editpost.php b/mod/editpost.php index 29f3dadff0..1bf150a5dd 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -6,14 +6,14 @@ function editpost_content(App &$a) { $o = ''; - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); - if(! $post_id) { + if (! $post_id) { notice( t('Item not found') . EOL); return; } @@ -23,7 +23,7 @@ function editpost_content(App &$a) { intval(local_user()) ); - if(! count($itm)) { + if (! count($itm)) { notice( t('Item not found') . EOL); return; } diff --git a/mod/events.php b/mod/events.php index bf65ff1267..0c1e9ae2f5 100644 --- a/mod/events.php +++ b/mod/events.php @@ -9,8 +9,9 @@ require_once('include/event.php'); require_once('include/items.php'); function events_init(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } if ($a->argc == 1) { // if it's a json request abort here becaus we don't @@ -34,8 +35,9 @@ function events_post(App &$a) { logger('post: ' . print_r($_REQUEST,true)); - if(! local_user()) + if (! local_user()) { return; + } $event_id = ((x($_POST,'event_id')) ? intval($_POST['event_id']) : 0); $cid = ((x($_POST,'cid')) ? intval($_POST['cid']) : 0); @@ -187,7 +189,7 @@ function events_post(App &$a) { function events_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/filer.php b/mod/filer.php index 4198502c4c..1b5589380b 100644 --- a/mod/filer.php +++ b/mod/filer.php @@ -7,7 +7,7 @@ require_once('include/items.php'); function filer_content(App &$a) { - if(! local_user()) { + if (! local_user()) { killme(); } diff --git a/mod/filerm.php b/mod/filerm.php index e109ed404b..cdc5a034aa 100644 --- a/mod/filerm.php +++ b/mod/filerm.php @@ -2,7 +2,7 @@ function filerm_content(App &$a) { - if(! local_user()) { + if (! local_user()) { killme(); } diff --git a/mod/follow.php b/mod/follow.php index d17c874f69..56e698547b 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -7,7 +7,7 @@ require_once('include/contact_selectors.php'); function follow_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); goaway($_SESSION['return_url']); // NOTREACHED @@ -151,7 +151,7 @@ function follow_content(App &$a) { function follow_post(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); goaway($_SESSION['return_url']); // NOTREACHED diff --git a/mod/fsuggest.php b/mod/fsuggest.php index 9d862848f1..fcbadcc9b7 100644 --- a/mod/fsuggest.php +++ b/mod/fsuggest.php @@ -3,12 +3,13 @@ function fsuggest_post(App &$a) { - if(! local_user()) { + if (! local_user()) { return; } - if($a->argc != 2) + if ($a->argc != 2) { return; + } $contact_id = intval($a->argv[1]); @@ -74,7 +75,7 @@ function fsuggest_content(App &$a) { require_once('include/acl_selectors.php'); - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/group.php b/mod/group.php index 75bb2b7c81..fc5c481817 100644 --- a/mod/group.php +++ b/mod/group.php @@ -15,7 +15,7 @@ function group_init(App &$a) { function group_post(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } @@ -73,7 +73,7 @@ function group_post(App &$a) { function group_content(App &$a) { $change = false; - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied') . EOL); return; } diff --git a/mod/ignored.php b/mod/ignored.php index 446d12a6ab..99b3a3ddcc 100644 --- a/mod/ignored.php +++ b/mod/ignored.php @@ -5,12 +5,15 @@ function ignored_init(App &$a) { $ignored = 0; - if(! local_user()) + if (! local_user()) { killme(); - if($a->argc > 1) + } + if ($a->argc > 1) { $message_id = intval($a->argv[1]); - if(! $message_id) + } + if (! $message_id) { killme(); + } $r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1", intval(local_user()), @@ -20,8 +23,9 @@ function ignored_init(App &$a) { killme(); } - if(! intval($r[0]['ignored'])) + if (! intval($r[0]['ignored'])) { $ignored = 1; + } $r = q("UPDATE `thread` SET `ignored` = %d WHERE `uid` = %d and `iid` = %d", intval($ignored), @@ -31,7 +35,7 @@ function ignored_init(App &$a) { // See if we've been passed a return path to redirect to $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); - if($return_path) { + if ($return_path) { $rand = '_=' . time(); if(strpos($return_path, '?')) $rand = "&$rand"; else $rand = "?$rand"; diff --git a/mod/invite.php b/mod/invite.php index 79b30d6e4b..2db71742f1 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -11,7 +11,7 @@ require_once('include/email.php'); function invite_post(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } @@ -97,7 +97,7 @@ function invite_post(App &$a) { function invite_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/manage.php b/mod/manage.php index 3eecfbb715..835a7fbcb7 100644 --- a/mod/manage.php +++ b/mod/manage.php @@ -5,8 +5,9 @@ require_once("include/text.php"); function manage_post(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } $uid = local_user(); $orig_record = $a->user; @@ -93,7 +94,7 @@ function manage_post(App &$a) { function manage_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/match.php b/mod/match.php index cdf2f8eacd..8bc255023f 100644 --- a/mod/match.php +++ b/mod/match.php @@ -16,8 +16,9 @@ require_once('mod/proxy.php'); function match_content(App &$a) { $o = ''; - if(! local_user()) + if (! local_user()) { return; + } $a->page['aside'] .= findpeople_widget(); $a->page['aside'] .= follow_widget(); diff --git a/mod/message.php b/mod/message.php index 0191eab0c9..ef62a78981 100644 --- a/mod/message.php +++ b/mod/message.php @@ -42,7 +42,7 @@ function message_init(App &$a) { function message_post(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } @@ -178,7 +178,7 @@ function message_content(App &$a) { $o = ''; nav_set_selected('messages'); - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/mood.php b/mod/mood.php index e98c16108f..0e603c869a 100644 --- a/mod/mood.php +++ b/mod/mood.php @@ -7,8 +7,9 @@ require_once('include/items.php'); function mood_init(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } $uid = local_user(); $verb = notags(trim($_GET['verb'])); @@ -110,7 +111,7 @@ function mood_init(App &$a) { function mood_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/network.php b/mod/network.php index dde3a3bae7..8b24b3e11b 100644 --- a/mod/network.php +++ b/mod/network.php @@ -1,6 +1,6 @@ query_string; return login(false); } diff --git a/mod/nogroup.php b/mod/nogroup.php index 3cf02069df..900ca4de09 100644 --- a/mod/nogroup.php +++ b/mod/nogroup.php @@ -6,14 +6,16 @@ require_once('include/contact_selectors.php'); function nogroup_init(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } require_once('include/group.php'); require_once('include/contact_widgets.php'); - if(! x($a->page,'aside')) + if (! x($a->page,'aside')) { $a->page['aside'] = ''; + } $a->page['aside'] .= group_side('contacts','group','extended',0,$contact_id); } @@ -21,7 +23,7 @@ function nogroup_init(App &$a) { function nogroup_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return ''; } diff --git a/mod/notes.php b/mod/notes.php index f50f41eaf2..b2aa5487af 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -2,8 +2,9 @@ function notes_init(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } $profile = 0; @@ -18,7 +19,7 @@ function notes_init(App &$a) { function notes_content(&$a,$update = false) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/notifications.php b/mod/notifications.php index e7f32a5872..e4fa08f3e2 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -11,7 +11,7 @@ require_once("include/network.php"); function notifications_post(App &$a) { - if(! local_user()) { + if (! local_user()) { goaway(z_root()); } @@ -67,7 +67,7 @@ function notifications_post(App &$a) { function notifications_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/oexchange.php b/mod/oexchange.php index 83b9453f2f..49c5d01f45 100644 --- a/mod/oexchange.php +++ b/mod/oexchange.php @@ -16,12 +16,12 @@ function oexchange_init(App &$a) { function oexchange_content(App &$a) { - if(! local_user()) { + if (! local_user()) { $o = login(false); return $o; } - if(($a->argc > 1) && $a->argv[1] === 'done') { + if (($a->argc > 1) && $a->argv[1] === 'done') { info( t('Post successful.') . EOL); return; } diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php index 55abdf183f..ba17e28b73 100644 --- a/mod/ostatus_subscribe.php +++ b/mod/ostatus_subscribe.php @@ -5,7 +5,7 @@ require_once('include/follow.php'); function ostatus_subscribe_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); goaway($_SESSION['return_url']); // NOTREACHED diff --git a/mod/poke.php b/mod/poke.php index cc6d4ff896..2e15ed853f 100644 --- a/mod/poke.php +++ b/mod/poke.php @@ -21,25 +21,29 @@ require_once('include/items.php'); function poke_init(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } $uid = local_user(); $verb = notags(trim($_GET['verb'])); - if(! $verb) + if (! $verb) { return; + } $verbs = get_poke_verbs(); - if(! array_key_exists($verb,$verbs)) + if (! array_key_exists($verb,$verbs)) { return; + } $activity = ACTIVITY_POKE . '#' . urlencode($verbs[$verb][0]); $contact_id = intval($_GET['cid']); - if(! $contact_id) + if (! $contact_id) { return; + } $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : 0); @@ -146,7 +150,7 @@ function poke_init(App &$a) { function poke_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/profile_photo.php b/mod/profile_photo.php index fd7302e4da..356c507f7a 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -4,7 +4,7 @@ require_once("include/Photo.php"); function profile_photo_init(App &$a) { - if(! local_user()) { + if (! local_user()) { return; } @@ -15,7 +15,7 @@ function profile_photo_init(App &$a) { function profile_photo_post(App &$a) { - if(! local_user()) { + if (! local_user()) { notice ( t('Permission denied.') . EOL ); return; } @@ -172,7 +172,7 @@ function profile_photo_post(App &$a) { if(! function_exists('profile_photo_content')) { function profile_photo_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL ); return; } diff --git a/mod/profiles.php b/mod/profiles.php index cca7a57ec5..20bd4cf6f1 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -6,7 +6,7 @@ function profiles_init(App &$a) { nav_set_selected('profiles'); - if(! local_user()) { + if (! local_user()) { return; } @@ -162,7 +162,7 @@ function profile_clean_keywords($keywords) { function profiles_post(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } @@ -595,14 +595,15 @@ function profile_activity($changed, $value) { $arr['deny_gid'] = $a->user['deny_gid']; $i = item_store($arr); - if($i) + if ($i) { proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i); + } } function profiles_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/profperm.php b/mod/profperm.php index 694e2f4db7..bbb055b021 100644 --- a/mod/profperm.php +++ b/mod/profperm.php @@ -2,8 +2,9 @@ function profperm_init(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } $which = $a->user['nickname']; $profile = $a->argv[1]; @@ -15,7 +16,7 @@ function profperm_init(App &$a) { function profperm_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied') . EOL); return; } diff --git a/mod/qsearch.php b/mod/qsearch.php index b42b1cfd84..118c93d9fa 100644 --- a/mod/qsearch.php +++ b/mod/qsearch.php @@ -2,8 +2,9 @@ function qsearch_init(App &$a) { - if(! local_user()) + if (! local_user()) { killme(); + } $limit = (get_config('system','qsearch_limit') ? intval(get_config('system','qsearch_limit')) : 100); diff --git a/mod/regmod.php b/mod/regmod.php index 60da71321e..44bdfe6644 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -103,32 +103,33 @@ function regmod_content(App &$a) { $_SESSION['return_url'] = $a->cmd; - if(! local_user()) { + if (! local_user()) { info( t('Please login.') . EOL); $o .= '

' . login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1); return $o; } - if((!is_site_admin()) || (x($_SESSION,'submanage') && intval($_SESSION['submanage']))) { + if ((!is_site_admin()) || (x($_SESSION,'submanage') && intval($_SESSION['submanage']))) { notice( t('Permission denied.') . EOL); return ''; } - if($a->argc != 3) + if ($a->argc != 3) { killme(); + } $cmd = $a->argv[1]; $hash = $a->argv[2]; - if($cmd === 'deny') { + if ($cmd === 'deny') { user_deny($hash); goaway(App::get_baseurl()."/admin/users/"); killme(); } - if($cmd === 'allow') { + if ($cmd === 'allow') { user_allow($hash); goaway(App::get_baseurl()."/admin/users/"); killme(); diff --git a/mod/repair_ostatus.php b/mod/repair_ostatus.php index 2ade3c2dcc..07721220a0 100755 --- a/mod/repair_ostatus.php +++ b/mod/repair_ostatus.php @@ -5,7 +5,7 @@ require_once('include/follow.php'); function repair_ostatus_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); goaway($_SESSION['return_url']); // NOTREACHED diff --git a/mod/settings.php b/mod/settings.php index 97d4f5f603..9aa7c57624 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -18,7 +18,7 @@ function get_theme_config_file($theme){ function settings_init(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL ); return; } @@ -118,8 +118,9 @@ function settings_init(App &$a) { function settings_post(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) { return; @@ -658,7 +659,7 @@ function settings_content(App &$a) { $o = ''; nav_set_selected('settings'); - if(! local_user()) { + if (! local_user()) { #notice( t('Permission denied.') . EOL ); return; } diff --git a/mod/starred.php b/mod/starred.php index f3fc5870ea..0a78f51aa7 100644 --- a/mod/starred.php +++ b/mod/starred.php @@ -7,12 +7,15 @@ function starred_init(App &$a) { $starred = 0; - if(! local_user()) + if (! local_user()) { killme(); - if($a->argc > 1) + } + if ($a->argc > 1) { $message_id = intval($a->argv[1]); - if(! $message_id) + } + if (! $message_id) { killme(); + } $r = q("SELECT starred FROM item WHERE uid = %d AND id = %d LIMIT 1", intval(local_user()), diff --git a/mod/suggest.php b/mod/suggest.php index 514b8f83c6..5af337ae1b 100644 --- a/mod/suggest.php +++ b/mod/suggest.php @@ -5,12 +5,13 @@ require_once('include/contact_widgets.php'); function suggest_init(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } - if(x($_GET,'ignore') && intval($_GET['ignore'])) { + if (x($_GET,'ignore') && intval($_GET['ignore'])) { // Check if we should do HTML-based delete confirmation - if($_REQUEST['confirm']) { + if ($_REQUEST['confirm']) { // can't take arguments in its "action" parameter // so add any arguments as hidden inputs $query = explode_querystring($a->query_string); @@ -35,7 +36,7 @@ function suggest_init(App &$a) { return; } // Now check how the user responded to the confirmation query - if(!$_REQUEST['canceled']) { + if (!$_REQUEST['canceled']) { q("INSERT INTO `gcign` ( `uid`, `gcid` ) VALUES ( %d, %d ) ", intval(local_user()), intval($_GET['ignore']) @@ -54,7 +55,7 @@ function suggest_content(App &$a) { require_once("mod/proxy.php"); $o = ''; - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/tagrm.php b/mod/tagrm.php index 5c87d0ce26..212f91d16e 100644 --- a/mod/tagrm.php +++ b/mod/tagrm.php @@ -4,7 +4,7 @@ require_once('include/bbcode.php'); function tagrm_post(App &$a) { - if(! local_user()) + if (! local_user()) goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); @@ -52,7 +52,7 @@ function tagrm_content(App &$a) { $o = ''; - if(! local_user()) { + if (! local_user()) { goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); // NOTREACHED } @@ -63,7 +63,6 @@ function tagrm_content(App &$a) { // NOTREACHED } - $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($item), intval(local_user()) @@ -75,8 +74,9 @@ function tagrm_content(App &$a) { $arr = explode(',', $r[0]['tag']); - if(! count($arr)) + if (! count($arr)) { goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + } $o .= '

' . t('Remove Item Tag') . '

'; diff --git a/mod/uexport.php b/mod/uexport.php index e98449a877..7aa9724d58 100644 --- a/mod/uexport.php +++ b/mod/uexport.php @@ -1,11 +1,12 @@ t('default'), - 'greenzero'=>t('greenzero'), - 'purplezero'=>t('purplezero'), - 'easterbunny'=>t('easterbunny'), - 'darkzero'=>t('darkzero'), - 'comix'=>t('comix'), - 'slackr'=>t('slackr'), - ); - if ($user) { - $color = get_pconfig(local_user(), 'duepuntozero', 'colorset'); - } else { - $color = get_config( 'duepuntozero', 'colorset'); - } - $t = get_markup_template("theme_settings.tpl" ); - $o .= replace_macros($t, array( - '$submit' => t('Submit'), - '$baseurl' => App::get_baseurl(), - '$title' => t("Theme settings"), - '$colorset' => array('duepuntozero_colorset', t('Variations'), $color, '', $colorset), - )); - return $o; + $colorset = array( + 'default'=>t('default'), + 'greenzero'=>t('greenzero'), + 'purplezero'=>t('purplezero'), + 'easterbunny'=>t('easterbunny'), + 'darkzero'=>t('darkzero'), + 'comix'=>t('comix'), + 'slackr'=>t('slackr'), + ); + + if ($user) { + $color = get_pconfig(local_user(), 'duepuntozero', 'colorset'); + } else { + $color = get_config( 'duepuntozero', 'colorset'); + } + + $t = get_markup_template("theme_settings.tpl" ); + /// @TODO No need for adding string here, $o is not defined + $o .= replace_macros($t, array( + '$submit' => t('Submit'), + '$baseurl' => App::get_baseurl(), + '$title'=> t("Theme settings"), + '$colorset' => array('duepuntozero_colorset', t('Variations'), $color, '', $colorset), + )); + + return $o; } diff --git a/view/theme/frio/config.php b/view/theme/frio/config.php index cb2683aa0b..000ef26092 100644 --- a/view/theme/frio/config.php +++ b/view/theme/frio/config.php @@ -2,7 +2,9 @@ require_once('view/theme/frio/php/Image.php'); function theme_content(App &$a) { - if(!local_user()) { return;} + if (!local_user()) { + return; + } $arr = array(); $arr["schema"] = get_pconfig(local_user(),'frio', 'schema'); @@ -18,7 +20,10 @@ function theme_content(App &$a) { } function theme_post(App &$a) { - if(!local_user()) { return;} + if (!local_user()) { + return; + } + if (isset($_POST['frio-settings-submit'])) { set_pconfig(local_user(), 'frio', 'schema', $_POST["frio_schema"]); set_pconfig(local_user(), 'frio', 'nav_bg', $_POST["frio_nav_bg"]); diff --git a/view/theme/quattro/config.php b/view/theme/quattro/config.php index 11e6f6cbce..1a5a9c0213 100644 --- a/view/theme/quattro/config.php +++ b/view/theme/quattro/config.php @@ -6,21 +6,23 @@ function theme_content(App &$a){ - if(!local_user()) - return; - + if (!local_user()) { + return; + } + $align = get_pconfig(local_user(), 'quattro', 'align' ); $color = get_pconfig(local_user(), 'quattro', 'color' ); - $tfs = get_pconfig(local_user(),"quattro","tfs"); - $pfs = get_pconfig(local_user(),"quattro","pfs"); - + $tfs = get_pconfig(local_user(),"quattro","tfs"); + $pfs = get_pconfig(local_user(),"quattro","pfs"); + return quattro_form($a,$align, $color, $tfs, $pfs); } function theme_post(App &$a){ - if(! local_user()) + if (! local_user()) { return; - + } + if (isset($_POST['quattro-settings-submit'])){ set_pconfig(local_user(), 'quattro', 'align', $_POST['quattro_align']); set_pconfig(local_user(), 'quattro', 'color', $_POST['quattro_color']); diff --git a/view/theme/vier/config.php b/view/theme/vier/config.php index 55ef2654f1..5326498908 100644 --- a/view/theme/vier/config.php +++ b/view/theme/vier/config.php @@ -6,19 +6,23 @@ function theme_content(App &$a){ - if(!local_user()) + if (!local_user()) { return; + } - if (!function_exists('get_vier_config')) + if (!function_exists('get_vier_config')) { return; + } $style = get_pconfig(local_user(), 'vier', 'style'); - if ($style == "") + if ($style == "") { $style = get_config('vier', 'style'); + } - if ($style == "") + if ($style == "") { $style = "plus"; + } $show_pages = get_vier_config('show_pages', true); $show_profiles = get_vier_config('show_profiles', true); @@ -32,8 +36,9 @@ function theme_content(App &$a){ } function theme_post(App &$a){ - if(! local_user()) + if (! local_user()) { return; + } if (isset($_POST['vier-settings-submit'])){ set_pconfig(local_user(), 'vier', 'style', $_POST['vier_style']); From 61c1317f804d8519492af249f8b4b8985f6cec5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 11:56:34 +0100 Subject: [PATCH 35/96] added much more curly braces + space between "if" and brace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- doc/themes.md | 3 +- include/acl_selectors.php | 5 +- include/contact_widgets.php | 15 ++++-- include/group.php | 2 +- mod/allfriends.php | 11 ++-- mod/api.php | 4 +- mod/bookmarklet.php | 2 +- mod/community.php | 2 +- mod/contactgroup.php | 2 +- mod/contacts.php | 15 +++--- mod/content.php | 2 +- mod/crepair.php | 8 +-- mod/delegate.php | 2 +- mod/dirfind.php | 2 +- mod/editpost.php | 6 +-- mod/events.php | 8 +-- mod/filer.php | 2 +- mod/filerm.php | 2 +- mod/follow.php | 4 +- mod/fsuggest.php | 7 +-- mod/group.php | 4 +- mod/ignored.php | 14 +++-- mod/invite.php | 4 +- mod/manage.php | 5 +- mod/match.php | 3 +- mod/message.php | 4 +- mod/mood.php | 5 +- mod/network.php | 4 +- mod/nogroup.php | 8 +-- mod/notes.php | 5 +- mod/notifications.php | 4 +- mod/oexchange.php | 4 +- mod/ostatus_subscribe.php | 2 +- mod/poke.php | 14 +++-- mod/profile_photo.php | 6 +-- mod/profiles.php | 9 ++-- mod/profperm.php | 5 +- mod/qsearch.php | 3 +- mod/regmod.php | 11 ++-- mod/repair_ostatus.php | 2 +- mod/settings.php | 7 +-- mod/starred.php | 9 ++-- mod/suggest.php | 11 ++-- mod/tagrm.php | 8 +-- mod/uexport.php | 5 +- mod/viewsrc.php | 2 +- view/theme/duepuntozero/config.php | 84 ++++++++++++++++-------------- view/theme/frio/config.php | 9 +++- view/theme/quattro/config.php | 18 ++++--- view/theme/vier/config.php | 15 ++++-- 50 files changed, 224 insertions(+), 164 deletions(-) diff --git a/doc/themes.md b/doc/themes.md index 0ae7e694fe..0b8f6cb83d 100644 --- a/doc/themes.md +++ b/doc/themes.md @@ -124,8 +124,9 @@ The selected 1st part will be saved in the database by the theme_post function. function theme_post(App &$a){ // non local users shall not pass - if(! local_user()) + if (! local_user()) { return; + } // if the one specific submit button was pressed then proceed if (isset($_POST['duepuntozero-settings-submit'])){ // and save the selection key into the personal config of the user diff --git a/include/acl_selectors.php b/include/acl_selectors.php index cd68ffaa7d..c1edc8cc03 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -392,8 +392,9 @@ function construct_acl_data(&$a, $user) { function acl_lookup(&$a, $out_type = 'json') { - if(!local_user()) - return ""; + if (!local_user()) { + return ''; + } $start = (x($_REQUEST,'start') ? $_REQUEST['start'] : 0); $count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 100); diff --git a/include/contact_widgets.php b/include/contact_widgets.php index a74080e75b..71a75d431e 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -80,11 +80,13 @@ function networks_widget($baseurl,$selected = '') { $a = get_app(); - if(!local_user()) + if (!local_user()) { return ''; + } - if(!feature_enabled(local_user(),'networks')) + if (!feature_enabled(local_user(),'networks')) { return ''; + } $extra_sql = unavailable_networks(); @@ -116,15 +118,18 @@ function networks_widget($baseurl,$selected = '') { } function fileas_widget($baseurl,$selected = '') { - if(! local_user()) + if (! local_user()) { return ''; + } - if(! feature_enabled(local_user(),'filing')) + if (! feature_enabled(local_user(),'filing')) { return ''; + } $saved = get_pconfig(local_user(),'system','filetags'); - if(! strlen($saved)) + if (! strlen($saved)) { return; + } $matches = false; $terms = array(); diff --git a/include/group.php b/include/group.php index 67712aae7c..a2a55c4440 100644 --- a/include/group.php +++ b/include/group.php @@ -234,7 +234,7 @@ function group_side($every="contacts",$each="group",$editmode = "standard", $gro $o = ''; - if(! local_user()) + if (! local_user()) return ''; $groups = array(); diff --git a/mod/allfriends.php b/mod/allfriends.php index 43490e9640..f9cffcbb2d 100644 --- a/mod/allfriends.php +++ b/mod/allfriends.php @@ -8,16 +8,18 @@ require_once('mod/contacts.php'); function allfriends_content(App &$a) { $o = ''; - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } - if($a->argc > 1) + if ($a->argc > 1) { $cid = intval($a->argv[1]); + } - if(! $cid) + if (! $cid) { return; + } $uid = $a->user['uid']; @@ -26,7 +28,8 @@ function allfriends_content(App &$a) { intval(local_user()) ); - if(! count($c)) + if (! count($c)) { + } return; $a->page['aside'] = ""; diff --git a/mod/api.php b/mod/api.php index b398daac8c..74a0cff6f4 100644 --- a/mod/api.php +++ b/mod/api.php @@ -22,7 +22,7 @@ function oauth_get_client($request){ function api_post(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } @@ -84,7 +84,7 @@ function api_content(App &$a) { } - if(! local_user()) { + if (! local_user()) { /// @TODO We need login form to redirect to this page notice( t('Please login to continue.') . EOL ); return login(false,$request->get_parameters()); diff --git a/mod/bookmarklet.php b/mod/bookmarklet.php index 1d68069439..9bc8c33535 100644 --- a/mod/bookmarklet.php +++ b/mod/bookmarklet.php @@ -8,7 +8,7 @@ function bookmarklet_init(App &$a) { } function bookmarklet_content(App &$a) { - if(!local_user()) { + if (!local_user()) { $o = '

'.t('Login').'

'; $o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true); return $o; diff --git a/mod/community.php b/mod/community.php index 7a1e727338..2c2ea32b33 100644 --- a/mod/community.php +++ b/mod/community.php @@ -1,7 +1,7 @@ argv[1]==="batch") { contacts_batch_actions($a); @@ -147,15 +149,16 @@ function contacts_post(App &$a) { } $contact_id = intval($a->argv[1]); - if(! $contact_id) + if (! $contact_id) { return; + } $orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval(local_user()) ); - if(! count($orig_record)) { + if (! count($orig_record)) { notice( t('Could not access contact record.') . EOL); goaway('contacts'); return; // NOTREACHED @@ -164,7 +167,7 @@ function contacts_post(App &$a) { call_hooks('contact_edit_post', $_POST); $profile_id = intval($_POST['profile-assign']); - if($profile_id) { + if ($profile_id) { $r = q("SELECT `id` FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($profile_id), intval(local_user()) @@ -346,7 +349,7 @@ function contacts_content(App &$a) { nav_set_selected('contacts'); - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/content.php b/mod/content.php index 1a3fb10952..2377032a79 100644 --- a/mod/content.php +++ b/mod/content.php @@ -23,7 +23,7 @@ function content_content(&$a, $update = 0) { // Currently security is based on the logged in user - if(! local_user()) { + if (! local_user()) { return; } diff --git a/mod/crepair.php b/mod/crepair.php index 308d5b95e9..2661deaeed 100644 --- a/mod/crepair.php +++ b/mod/crepair.php @@ -3,8 +3,9 @@ require_once("include/contact_selectors.php"); require_once("mod/contacts.php"); function crepair_init(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } $contact_id = 0; @@ -31,8 +32,9 @@ function crepair_init(App &$a) { function crepair_post(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0); @@ -97,7 +99,7 @@ function crepair_post(App &$a) { function crepair_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/delegate.php b/mod/delegate.php index 7dbeef7377..8470a7ba0b 100644 --- a/mod/delegate.php +++ b/mod/delegate.php @@ -8,7 +8,7 @@ function delegate_init(App &$a) { function delegate_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/dirfind.php b/mod/dirfind.php index 80cba1c475..fc5750f2dd 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -7,7 +7,7 @@ require_once('mod/contacts.php'); function dirfind_init(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL ); return; } diff --git a/mod/editpost.php b/mod/editpost.php index 29f3dadff0..1bf150a5dd 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -6,14 +6,14 @@ function editpost_content(App &$a) { $o = ''; - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); - if(! $post_id) { + if (! $post_id) { notice( t('Item not found') . EOL); return; } @@ -23,7 +23,7 @@ function editpost_content(App &$a) { intval(local_user()) ); - if(! count($itm)) { + if (! count($itm)) { notice( t('Item not found') . EOL); return; } diff --git a/mod/events.php b/mod/events.php index bf65ff1267..0c1e9ae2f5 100644 --- a/mod/events.php +++ b/mod/events.php @@ -9,8 +9,9 @@ require_once('include/event.php'); require_once('include/items.php'); function events_init(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } if ($a->argc == 1) { // if it's a json request abort here becaus we don't @@ -34,8 +35,9 @@ function events_post(App &$a) { logger('post: ' . print_r($_REQUEST,true)); - if(! local_user()) + if (! local_user()) { return; + } $event_id = ((x($_POST,'event_id')) ? intval($_POST['event_id']) : 0); $cid = ((x($_POST,'cid')) ? intval($_POST['cid']) : 0); @@ -187,7 +189,7 @@ function events_post(App &$a) { function events_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/filer.php b/mod/filer.php index 4198502c4c..1b5589380b 100644 --- a/mod/filer.php +++ b/mod/filer.php @@ -7,7 +7,7 @@ require_once('include/items.php'); function filer_content(App &$a) { - if(! local_user()) { + if (! local_user()) { killme(); } diff --git a/mod/filerm.php b/mod/filerm.php index e109ed404b..cdc5a034aa 100644 --- a/mod/filerm.php +++ b/mod/filerm.php @@ -2,7 +2,7 @@ function filerm_content(App &$a) { - if(! local_user()) { + if (! local_user()) { killme(); } diff --git a/mod/follow.php b/mod/follow.php index d17c874f69..56e698547b 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -7,7 +7,7 @@ require_once('include/contact_selectors.php'); function follow_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); goaway($_SESSION['return_url']); // NOTREACHED @@ -151,7 +151,7 @@ function follow_content(App &$a) { function follow_post(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); goaway($_SESSION['return_url']); // NOTREACHED diff --git a/mod/fsuggest.php b/mod/fsuggest.php index 9d862848f1..fcbadcc9b7 100644 --- a/mod/fsuggest.php +++ b/mod/fsuggest.php @@ -3,12 +3,13 @@ function fsuggest_post(App &$a) { - if(! local_user()) { + if (! local_user()) { return; } - if($a->argc != 2) + if ($a->argc != 2) { return; + } $contact_id = intval($a->argv[1]); @@ -74,7 +75,7 @@ function fsuggest_content(App &$a) { require_once('include/acl_selectors.php'); - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/group.php b/mod/group.php index 75bb2b7c81..fc5c481817 100644 --- a/mod/group.php +++ b/mod/group.php @@ -15,7 +15,7 @@ function group_init(App &$a) { function group_post(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } @@ -73,7 +73,7 @@ function group_post(App &$a) { function group_content(App &$a) { $change = false; - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied') . EOL); return; } diff --git a/mod/ignored.php b/mod/ignored.php index 446d12a6ab..99b3a3ddcc 100644 --- a/mod/ignored.php +++ b/mod/ignored.php @@ -5,12 +5,15 @@ function ignored_init(App &$a) { $ignored = 0; - if(! local_user()) + if (! local_user()) { killme(); - if($a->argc > 1) + } + if ($a->argc > 1) { $message_id = intval($a->argv[1]); - if(! $message_id) + } + if (! $message_id) { killme(); + } $r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1", intval(local_user()), @@ -20,8 +23,9 @@ function ignored_init(App &$a) { killme(); } - if(! intval($r[0]['ignored'])) + if (! intval($r[0]['ignored'])) { $ignored = 1; + } $r = q("UPDATE `thread` SET `ignored` = %d WHERE `uid` = %d and `iid` = %d", intval($ignored), @@ -31,7 +35,7 @@ function ignored_init(App &$a) { // See if we've been passed a return path to redirect to $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); - if($return_path) { + if ($return_path) { $rand = '_=' . time(); if(strpos($return_path, '?')) $rand = "&$rand"; else $rand = "?$rand"; diff --git a/mod/invite.php b/mod/invite.php index 79b30d6e4b..2db71742f1 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -11,7 +11,7 @@ require_once('include/email.php'); function invite_post(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } @@ -97,7 +97,7 @@ function invite_post(App &$a) { function invite_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/manage.php b/mod/manage.php index 3eecfbb715..835a7fbcb7 100644 --- a/mod/manage.php +++ b/mod/manage.php @@ -5,8 +5,9 @@ require_once("include/text.php"); function manage_post(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } $uid = local_user(); $orig_record = $a->user; @@ -93,7 +94,7 @@ function manage_post(App &$a) { function manage_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/match.php b/mod/match.php index cdf2f8eacd..8bc255023f 100644 --- a/mod/match.php +++ b/mod/match.php @@ -16,8 +16,9 @@ require_once('mod/proxy.php'); function match_content(App &$a) { $o = ''; - if(! local_user()) + if (! local_user()) { return; + } $a->page['aside'] .= findpeople_widget(); $a->page['aside'] .= follow_widget(); diff --git a/mod/message.php b/mod/message.php index 0191eab0c9..ef62a78981 100644 --- a/mod/message.php +++ b/mod/message.php @@ -42,7 +42,7 @@ function message_init(App &$a) { function message_post(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } @@ -178,7 +178,7 @@ function message_content(App &$a) { $o = ''; nav_set_selected('messages'); - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/mood.php b/mod/mood.php index e98c16108f..0e603c869a 100644 --- a/mod/mood.php +++ b/mod/mood.php @@ -7,8 +7,9 @@ require_once('include/items.php'); function mood_init(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } $uid = local_user(); $verb = notags(trim($_GET['verb'])); @@ -110,7 +111,7 @@ function mood_init(App &$a) { function mood_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/network.php b/mod/network.php index dde3a3bae7..8b24b3e11b 100644 --- a/mod/network.php +++ b/mod/network.php @@ -1,6 +1,6 @@ query_string; return login(false); } diff --git a/mod/nogroup.php b/mod/nogroup.php index 3cf02069df..900ca4de09 100644 --- a/mod/nogroup.php +++ b/mod/nogroup.php @@ -6,14 +6,16 @@ require_once('include/contact_selectors.php'); function nogroup_init(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } require_once('include/group.php'); require_once('include/contact_widgets.php'); - if(! x($a->page,'aside')) + if (! x($a->page,'aside')) { $a->page['aside'] = ''; + } $a->page['aside'] .= group_side('contacts','group','extended',0,$contact_id); } @@ -21,7 +23,7 @@ function nogroup_init(App &$a) { function nogroup_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return ''; } diff --git a/mod/notes.php b/mod/notes.php index f50f41eaf2..b2aa5487af 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -2,8 +2,9 @@ function notes_init(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } $profile = 0; @@ -18,7 +19,7 @@ function notes_init(App &$a) { function notes_content(&$a,$update = false) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/notifications.php b/mod/notifications.php index e7f32a5872..e4fa08f3e2 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -11,7 +11,7 @@ require_once("include/network.php"); function notifications_post(App &$a) { - if(! local_user()) { + if (! local_user()) { goaway(z_root()); } @@ -67,7 +67,7 @@ function notifications_post(App &$a) { function notifications_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/oexchange.php b/mod/oexchange.php index 83b9453f2f..49c5d01f45 100644 --- a/mod/oexchange.php +++ b/mod/oexchange.php @@ -16,12 +16,12 @@ function oexchange_init(App &$a) { function oexchange_content(App &$a) { - if(! local_user()) { + if (! local_user()) { $o = login(false); return $o; } - if(($a->argc > 1) && $a->argv[1] === 'done') { + if (($a->argc > 1) && $a->argv[1] === 'done') { info( t('Post successful.') . EOL); return; } diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php index 55abdf183f..ba17e28b73 100644 --- a/mod/ostatus_subscribe.php +++ b/mod/ostatus_subscribe.php @@ -5,7 +5,7 @@ require_once('include/follow.php'); function ostatus_subscribe_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); goaway($_SESSION['return_url']); // NOTREACHED diff --git a/mod/poke.php b/mod/poke.php index cc6d4ff896..2e15ed853f 100644 --- a/mod/poke.php +++ b/mod/poke.php @@ -21,25 +21,29 @@ require_once('include/items.php'); function poke_init(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } $uid = local_user(); $verb = notags(trim($_GET['verb'])); - if(! $verb) + if (! $verb) { return; + } $verbs = get_poke_verbs(); - if(! array_key_exists($verb,$verbs)) + if (! array_key_exists($verb,$verbs)) { return; + } $activity = ACTIVITY_POKE . '#' . urlencode($verbs[$verb][0]); $contact_id = intval($_GET['cid']); - if(! $contact_id) + if (! $contact_id) { return; + } $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : 0); @@ -146,7 +150,7 @@ function poke_init(App &$a) { function poke_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/profile_photo.php b/mod/profile_photo.php index fd7302e4da..356c507f7a 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -4,7 +4,7 @@ require_once("include/Photo.php"); function profile_photo_init(App &$a) { - if(! local_user()) { + if (! local_user()) { return; } @@ -15,7 +15,7 @@ function profile_photo_init(App &$a) { function profile_photo_post(App &$a) { - if(! local_user()) { + if (! local_user()) { notice ( t('Permission denied.') . EOL ); return; } @@ -172,7 +172,7 @@ function profile_photo_post(App &$a) { if(! function_exists('profile_photo_content')) { function profile_photo_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL ); return; } diff --git a/mod/profiles.php b/mod/profiles.php index cca7a57ec5..20bd4cf6f1 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -6,7 +6,7 @@ function profiles_init(App &$a) { nav_set_selected('profiles'); - if(! local_user()) { + if (! local_user()) { return; } @@ -162,7 +162,7 @@ function profile_clean_keywords($keywords) { function profiles_post(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } @@ -595,14 +595,15 @@ function profile_activity($changed, $value) { $arr['deny_gid'] = $a->user['deny_gid']; $i = item_store($arr); - if($i) + if ($i) { proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i); + } } function profiles_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/profperm.php b/mod/profperm.php index 694e2f4db7..bbb055b021 100644 --- a/mod/profperm.php +++ b/mod/profperm.php @@ -2,8 +2,9 @@ function profperm_init(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } $which = $a->user['nickname']; $profile = $a->argv[1]; @@ -15,7 +16,7 @@ function profperm_init(App &$a) { function profperm_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied') . EOL); return; } diff --git a/mod/qsearch.php b/mod/qsearch.php index b42b1cfd84..118c93d9fa 100644 --- a/mod/qsearch.php +++ b/mod/qsearch.php @@ -2,8 +2,9 @@ function qsearch_init(App &$a) { - if(! local_user()) + if (! local_user()) { killme(); + } $limit = (get_config('system','qsearch_limit') ? intval(get_config('system','qsearch_limit')) : 100); diff --git a/mod/regmod.php b/mod/regmod.php index 60da71321e..44bdfe6644 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -103,32 +103,33 @@ function regmod_content(App &$a) { $_SESSION['return_url'] = $a->cmd; - if(! local_user()) { + if (! local_user()) { info( t('Please login.') . EOL); $o .= '

' . login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1); return $o; } - if((!is_site_admin()) || (x($_SESSION,'submanage') && intval($_SESSION['submanage']))) { + if ((!is_site_admin()) || (x($_SESSION,'submanage') && intval($_SESSION['submanage']))) { notice( t('Permission denied.') . EOL); return ''; } - if($a->argc != 3) + if ($a->argc != 3) { killme(); + } $cmd = $a->argv[1]; $hash = $a->argv[2]; - if($cmd === 'deny') { + if ($cmd === 'deny') { user_deny($hash); goaway(App::get_baseurl()."/admin/users/"); killme(); } - if($cmd === 'allow') { + if ($cmd === 'allow') { user_allow($hash); goaway(App::get_baseurl()."/admin/users/"); killme(); diff --git a/mod/repair_ostatus.php b/mod/repair_ostatus.php index 2ade3c2dcc..07721220a0 100755 --- a/mod/repair_ostatus.php +++ b/mod/repair_ostatus.php @@ -5,7 +5,7 @@ require_once('include/follow.php'); function repair_ostatus_content(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); goaway($_SESSION['return_url']); // NOTREACHED diff --git a/mod/settings.php b/mod/settings.php index 97d4f5f603..9aa7c57624 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -18,7 +18,7 @@ function get_theme_config_file($theme){ function settings_init(App &$a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL ); return; } @@ -118,8 +118,9 @@ function settings_init(App &$a) { function settings_post(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) { return; @@ -658,7 +659,7 @@ function settings_content(App &$a) { $o = ''; nav_set_selected('settings'); - if(! local_user()) { + if (! local_user()) { #notice( t('Permission denied.') . EOL ); return; } diff --git a/mod/starred.php b/mod/starred.php index f3fc5870ea..0a78f51aa7 100644 --- a/mod/starred.php +++ b/mod/starred.php @@ -7,12 +7,15 @@ function starred_init(App &$a) { $starred = 0; - if(! local_user()) + if (! local_user()) { killme(); - if($a->argc > 1) + } + if ($a->argc > 1) { $message_id = intval($a->argv[1]); - if(! $message_id) + } + if (! $message_id) { killme(); + } $r = q("SELECT starred FROM item WHERE uid = %d AND id = %d LIMIT 1", intval(local_user()), diff --git a/mod/suggest.php b/mod/suggest.php index 514b8f83c6..5af337ae1b 100644 --- a/mod/suggest.php +++ b/mod/suggest.php @@ -5,12 +5,13 @@ require_once('include/contact_widgets.php'); function suggest_init(App &$a) { - if(! local_user()) + if (! local_user()) { return; + } - if(x($_GET,'ignore') && intval($_GET['ignore'])) { + if (x($_GET,'ignore') && intval($_GET['ignore'])) { // Check if we should do HTML-based delete confirmation - if($_REQUEST['confirm']) { + if ($_REQUEST['confirm']) { // can't take arguments in its "action" parameter // so add any arguments as hidden inputs $query = explode_querystring($a->query_string); @@ -35,7 +36,7 @@ function suggest_init(App &$a) { return; } // Now check how the user responded to the confirmation query - if(!$_REQUEST['canceled']) { + if (!$_REQUEST['canceled']) { q("INSERT INTO `gcign` ( `uid`, `gcid` ) VALUES ( %d, %d ) ", intval(local_user()), intval($_GET['ignore']) @@ -54,7 +55,7 @@ function suggest_content(App &$a) { require_once("mod/proxy.php"); $o = ''; - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/tagrm.php b/mod/tagrm.php index 5c87d0ce26..212f91d16e 100644 --- a/mod/tagrm.php +++ b/mod/tagrm.php @@ -4,7 +4,7 @@ require_once('include/bbcode.php'); function tagrm_post(App &$a) { - if(! local_user()) + if (! local_user()) goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); @@ -52,7 +52,7 @@ function tagrm_content(App &$a) { $o = ''; - if(! local_user()) { + if (! local_user()) { goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); // NOTREACHED } @@ -63,7 +63,6 @@ function tagrm_content(App &$a) { // NOTREACHED } - $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($item), intval(local_user()) @@ -75,8 +74,9 @@ function tagrm_content(App &$a) { $arr = explode(',', $r[0]['tag']); - if(! count($arr)) + if (! count($arr)) { goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + } $o .= '

' . t('Remove Item Tag') . '

'; diff --git a/mod/uexport.php b/mod/uexport.php index e98449a877..7aa9724d58 100644 --- a/mod/uexport.php +++ b/mod/uexport.php @@ -1,11 +1,12 @@ t('default'), - 'greenzero'=>t('greenzero'), - 'purplezero'=>t('purplezero'), - 'easterbunny'=>t('easterbunny'), - 'darkzero'=>t('darkzero'), - 'comix'=>t('comix'), - 'slackr'=>t('slackr'), - ); - if ($user) { - $color = get_pconfig(local_user(), 'duepuntozero', 'colorset'); - } else { - $color = get_config( 'duepuntozero', 'colorset'); - } - $t = get_markup_template("theme_settings.tpl" ); - $o .= replace_macros($t, array( - '$submit' => t('Submit'), - '$baseurl' => App::get_baseurl(), - '$title' => t("Theme settings"), - '$colorset' => array('duepuntozero_colorset', t('Variations'), $color, '', $colorset), - )); - return $o; + $colorset = array( + 'default'=>t('default'), + 'greenzero'=>t('greenzero'), + 'purplezero'=>t('purplezero'), + 'easterbunny'=>t('easterbunny'), + 'darkzero'=>t('darkzero'), + 'comix'=>t('comix'), + 'slackr'=>t('slackr'), + ); + + if ($user) { + $color = get_pconfig(local_user(), 'duepuntozero', 'colorset'); + } else { + $color = get_config( 'duepuntozero', 'colorset'); + } + + $t = get_markup_template("theme_settings.tpl" ); + /// @TODO No need for adding string here, $o is not defined + $o .= replace_macros($t, array( + '$submit' => t('Submit'), + '$baseurl' => App::get_baseurl(), + '$title'=> t("Theme settings"), + '$colorset' => array('duepuntozero_colorset', t('Variations'), $color, '', $colorset), + )); + + return $o; } diff --git a/view/theme/frio/config.php b/view/theme/frio/config.php index cb2683aa0b..000ef26092 100644 --- a/view/theme/frio/config.php +++ b/view/theme/frio/config.php @@ -2,7 +2,9 @@ require_once('view/theme/frio/php/Image.php'); function theme_content(App &$a) { - if(!local_user()) { return;} + if (!local_user()) { + return; + } $arr = array(); $arr["schema"] = get_pconfig(local_user(),'frio', 'schema'); @@ -18,7 +20,10 @@ function theme_content(App &$a) { } function theme_post(App &$a) { - if(!local_user()) { return;} + if (!local_user()) { + return; + } + if (isset($_POST['frio-settings-submit'])) { set_pconfig(local_user(), 'frio', 'schema', $_POST["frio_schema"]); set_pconfig(local_user(), 'frio', 'nav_bg', $_POST["frio_nav_bg"]); diff --git a/view/theme/quattro/config.php b/view/theme/quattro/config.php index 11e6f6cbce..1a5a9c0213 100644 --- a/view/theme/quattro/config.php +++ b/view/theme/quattro/config.php @@ -6,21 +6,23 @@ function theme_content(App &$a){ - if(!local_user()) - return; - + if (!local_user()) { + return; + } + $align = get_pconfig(local_user(), 'quattro', 'align' ); $color = get_pconfig(local_user(), 'quattro', 'color' ); - $tfs = get_pconfig(local_user(),"quattro","tfs"); - $pfs = get_pconfig(local_user(),"quattro","pfs"); - + $tfs = get_pconfig(local_user(),"quattro","tfs"); + $pfs = get_pconfig(local_user(),"quattro","pfs"); + return quattro_form($a,$align, $color, $tfs, $pfs); } function theme_post(App &$a){ - if(! local_user()) + if (! local_user()) { return; - + } + if (isset($_POST['quattro-settings-submit'])){ set_pconfig(local_user(), 'quattro', 'align', $_POST['quattro_align']); set_pconfig(local_user(), 'quattro', 'color', $_POST['quattro_color']); diff --git a/view/theme/vier/config.php b/view/theme/vier/config.php index 55ef2654f1..5326498908 100644 --- a/view/theme/vier/config.php +++ b/view/theme/vier/config.php @@ -6,19 +6,23 @@ function theme_content(App &$a){ - if(!local_user()) + if (!local_user()) { return; + } - if (!function_exists('get_vier_config')) + if (!function_exists('get_vier_config')) { return; + } $style = get_pconfig(local_user(), 'vier', 'style'); - if ($style == "") + if ($style == "") { $style = get_config('vier', 'style'); + } - if ($style == "") + if ($style == "") { $style = "plus"; + } $show_pages = get_vier_config('show_pages', true); $show_profiles = get_vier_config('show_profiles', true); @@ -32,8 +36,9 @@ function theme_content(App &$a){ } function theme_post(App &$a){ - if(! local_user()) + if (! local_user()) { return; + } if (isset($_POST['vier-settings-submit'])){ set_pconfig(local_user(), 'vier', 'style', $_POST['vier_style']); From 8d28135c59e08ae5505b04b1899b76764bdab0e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 12:35:18 +0100 Subject: [PATCH 36/96] added curly braces + space between "if" and brace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/tagrm.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mod/tagrm.php b/mod/tagrm.php index 212f91d16e..8379495a2d 100644 --- a/mod/tagrm.php +++ b/mod/tagrm.php @@ -4,12 +4,13 @@ require_once('include/bbcode.php'); function tagrm_post(App &$a) { - if (! local_user()) + if (! local_user()) { goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + } - - if((x($_POST,'submit')) && ($_POST['submit'] === t('Cancel'))) + if ((x($_POST,'submit')) && ($_POST['submit'] === t('Cancel'))) { goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + } $tag = ((x($_POST,'tag')) ? hex2bin(notags(trim($_POST['tag']))) : ''); $item = ((x($_POST,'item')) ? intval($_POST['item']) : 0 ); @@ -24,8 +25,8 @@ function tagrm_post(App &$a) { } $arr = explode(',', $r[0]['tag']); - for($x = 0; $x < count($arr); $x ++) { - if($arr[$x] === $tag) { + for ($x = 0; $x < count($arr); $x ++) { + if ($arr[$x] === $tag) { unset($arr[$x]); break; } From 76f43f9b302d03e9f3f91ea31f0294f94d5a3dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 12:35:18 +0100 Subject: [PATCH 37/96] added curly braces + space between "if" and brace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/tagrm.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mod/tagrm.php b/mod/tagrm.php index 212f91d16e..8379495a2d 100644 --- a/mod/tagrm.php +++ b/mod/tagrm.php @@ -4,12 +4,13 @@ require_once('include/bbcode.php'); function tagrm_post(App &$a) { - if (! local_user()) + if (! local_user()) { goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + } - - if((x($_POST,'submit')) && ($_POST['submit'] === t('Cancel'))) + if ((x($_POST,'submit')) && ($_POST['submit'] === t('Cancel'))) { goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + } $tag = ((x($_POST,'tag')) ? hex2bin(notags(trim($_POST['tag']))) : ''); $item = ((x($_POST,'item')) ? intval($_POST['item']) : 0 ); @@ -24,8 +25,8 @@ function tagrm_post(App &$a) { } $arr = explode(',', $r[0]['tag']); - for($x = 0; $x < count($arr); $x ++) { - if($arr[$x] === $tag) { + for ($x = 0; $x < count($arr); $x ++) { + if ($arr[$x] === $tag) { unset($arr[$x]); break; } From c22878643b91ca164e8aca25af18debbf46ee94c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 12:36:51 +0100 Subject: [PATCH 38/96] Opps, forgot this ... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/toggle_mobile.php | 10 ++++++---- view/theme/frost-mobile/theme.php | 6 ++++-- view/theme/frost/theme.php | 4 +++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/mod/toggle_mobile.php b/mod/toggle_mobile.php index 6c3651393d..89b73cd448 100644 --- a/mod/toggle_mobile.php +++ b/mod/toggle_mobile.php @@ -2,15 +2,17 @@ function toggle_mobile_init(App &$a) { - if(isset($_GET['off'])) + if (isset($_GET['off'])) { $_SESSION['show-mobile'] = false; - else + } else { $_SESSION['show-mobile'] = true; + } - if(isset($_GET['address'])) + if (isset($_GET['address'])) { $address = $_GET['address']; - else + } else { $address = App::get_baseurl(); + } goaway($address); } diff --git a/view/theme/frost-mobile/theme.php b/view/theme/frost-mobile/theme.php index 7fe17ce7e1..4ca592f4c8 100644 --- a/view/theme/frost-mobile/theme.php +++ b/view/theme/frost-mobile/theme.php @@ -22,11 +22,13 @@ function frost_mobile_content_loaded(App &$a) { // I could do this in style.php, but by having the CSS in a file the browser will cache it, // making pages load faster - if( $a->module === 'home' || $a->module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) { + if ( $a->module === 'home' || $a->module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) { // $a->page['htmlhead'] = str_replace('$stylesheet', App::get_baseurl() . '/view/theme/frost-mobile/login-style.css', $a->page['htmlhead']); $a->theme['stylesheet'] = App::get_baseurl() . '/view/theme/frost-mobile/login-style.css'; } - if( $a->module === 'login' ) + + if ( $a->module === 'login' ) { $a->page['end'] .= ''; + } } diff --git a/view/theme/frost/theme.php b/view/theme/frost/theme.php index 964ea88ec4..7746109e56 100644 --- a/view/theme/frost/theme.php +++ b/view/theme/frost/theme.php @@ -24,8 +24,10 @@ function frost_content_loaded(App &$a) { //$a->page['htmlhead'] = str_replace('$stylesheet', App::get_baseurl() . '/view/theme/frost/login-style.css', $a->page['htmlhead']); $a->theme['stylesheet'] = App::get_baseurl() . '/view/theme/frost/login-style.css'; } - if( $a->module === 'login' ) + + if ( $a->module === 'login' ) { $a->page['end'] .= ''; + } } From 3569c9d21205606d930422f1b02fc0dbe49d435a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 12:36:51 +0100 Subject: [PATCH 39/96] Opps, forgot this ... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/toggle_mobile.php | 10 ++++++---- view/theme/frost-mobile/theme.php | 6 ++++-- view/theme/frost/theme.php | 4 +++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/mod/toggle_mobile.php b/mod/toggle_mobile.php index 6c3651393d..89b73cd448 100644 --- a/mod/toggle_mobile.php +++ b/mod/toggle_mobile.php @@ -2,15 +2,17 @@ function toggle_mobile_init(App &$a) { - if(isset($_GET['off'])) + if (isset($_GET['off'])) { $_SESSION['show-mobile'] = false; - else + } else { $_SESSION['show-mobile'] = true; + } - if(isset($_GET['address'])) + if (isset($_GET['address'])) { $address = $_GET['address']; - else + } else { $address = App::get_baseurl(); + } goaway($address); } diff --git a/view/theme/frost-mobile/theme.php b/view/theme/frost-mobile/theme.php index 7fe17ce7e1..4ca592f4c8 100644 --- a/view/theme/frost-mobile/theme.php +++ b/view/theme/frost-mobile/theme.php @@ -22,11 +22,13 @@ function frost_mobile_content_loaded(App &$a) { // I could do this in style.php, but by having the CSS in a file the browser will cache it, // making pages load faster - if( $a->module === 'home' || $a->module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) { + if ( $a->module === 'home' || $a->module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) { // $a->page['htmlhead'] = str_replace('$stylesheet', App::get_baseurl() . '/view/theme/frost-mobile/login-style.css', $a->page['htmlhead']); $a->theme['stylesheet'] = App::get_baseurl() . '/view/theme/frost-mobile/login-style.css'; } - if( $a->module === 'login' ) + + if ( $a->module === 'login' ) { $a->page['end'] .= ''; + } } diff --git a/view/theme/frost/theme.php b/view/theme/frost/theme.php index 964ea88ec4..7746109e56 100644 --- a/view/theme/frost/theme.php +++ b/view/theme/frost/theme.php @@ -24,8 +24,10 @@ function frost_content_loaded(App &$a) { //$a->page['htmlhead'] = str_replace('$stylesheet', App::get_baseurl() . '/view/theme/frost/login-style.css', $a->page['htmlhead']); $a->theme['stylesheet'] = App::get_baseurl() . '/view/theme/frost/login-style.css'; } - if( $a->module === 'login' ) + + if ( $a->module === 'login' ) { $a->page['end'] .= ''; + } } From bbbc63b8ad77c40858105e7e87be7ea9b56e3bb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 12:36:51 +0100 Subject: [PATCH 40/96] Continued a bit: - added more curly braces around conditional blocks - added space between "if" and brace - aligned "=>" (will do with more if wanted) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/videos.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mod/videos.php b/mod/videos.php index de6e016666..52176524a2 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -380,12 +380,12 @@ function videos_content(App &$a) { $videos[] = array( 'id' => $rr['id'], - 'link' => App::get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['resource-id'], - 'title' => t('View Video'), - 'src' => App::get_baseurl() . '/attach/' . $rr['id'] . '?attachment=0', - 'alt' => $alt_e, - 'mime' => $rr['filetype'], - 'album' => array( + 'link' => App::get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['resource-id'], + 'title' => t('View Video'), + 'src' => App::get_baseurl() . '/attach/' . $rr['id'] . '?attachment=0', + 'alt' => $alt_e, + 'mime' => $rr['filetype'], + 'album' => array( 'link' => App::get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']), 'name' => $name_e, 'alt' => t('View Album'), @@ -397,11 +397,11 @@ function videos_content(App &$a) { $tpl = get_markup_template('videos_recent.tpl'); $o .= replace_macros($tpl, array( - '$title' => t('Recent Videos'), - '$can_post' => $can_post, - '$upload' => array(t('Upload New Videos'), App::get_baseurl().'/videos/'.$a->data['user']['nickname'].'/upload'), - '$videos' => $videos, - '$delete_url' => (($can_post)?App::get_baseurl().'/videos/'.$a->data['user']['nickname']:False) + '$title' => t('Recent Videos'), + '$can_post' => $can_post, + '$upload' => array(t('Upload New Videos'), App::get_baseurl().'/videos/'.$a->data['user']['nickname'].'/upload'), + '$videos' => $videos, + '$delete_url' => (($can_post)?App::get_baseurl().'/videos/'.$a->data['user']['nickname']:False) )); From d5f2d387bddd649b15591dfd3c21f8b2f02dea15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 12:36:51 +0100 Subject: [PATCH 41/96] Continued a bit: - added more curly braces around conditional blocks - added space between "if" and brace - aligned "=>" (will do with more if wanted) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/videos.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mod/videos.php b/mod/videos.php index de6e016666..52176524a2 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -380,12 +380,12 @@ function videos_content(App &$a) { $videos[] = array( 'id' => $rr['id'], - 'link' => App::get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['resource-id'], - 'title' => t('View Video'), - 'src' => App::get_baseurl() . '/attach/' . $rr['id'] . '?attachment=0', - 'alt' => $alt_e, - 'mime' => $rr['filetype'], - 'album' => array( + 'link' => App::get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['resource-id'], + 'title' => t('View Video'), + 'src' => App::get_baseurl() . '/attach/' . $rr['id'] . '?attachment=0', + 'alt' => $alt_e, + 'mime' => $rr['filetype'], + 'album' => array( 'link' => App::get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']), 'name' => $name_e, 'alt' => t('View Album'), @@ -397,11 +397,11 @@ function videos_content(App &$a) { $tpl = get_markup_template('videos_recent.tpl'); $o .= replace_macros($tpl, array( - '$title' => t('Recent Videos'), - '$can_post' => $can_post, - '$upload' => array(t('Upload New Videos'), App::get_baseurl().'/videos/'.$a->data['user']['nickname'].'/upload'), - '$videos' => $videos, - '$delete_url' => (($can_post)?App::get_baseurl().'/videos/'.$a->data['user']['nickname']:False) + '$title' => t('Recent Videos'), + '$can_post' => $can_post, + '$upload' => array(t('Upload New Videos'), App::get_baseurl().'/videos/'.$a->data['user']['nickname'].'/upload'), + '$videos' => $videos, + '$delete_url' => (($can_post)?App::get_baseurl().'/videos/'.$a->data['user']['nickname']:False) )); From 0e58bf66753af9e79e6654e4f4f09aa61541290b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 12:45:16 +0100 Subject: [PATCH 42/96] Changed $a->get_baseurl() to App::get_baseurl() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- boot.php | 6 +++--- index.php | 10 +++++----- mod/filerm.php | 2 +- mod/follow.php | 6 +++--- mod/help.php | 2 +- mod/match.php | 6 +++--- mod/redir.php | 2 +- mod/removeme.php | 2 +- mod/subthread.php | 4 ++-- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/boot.php b/boot.php index c80da23529..ccff45f734 100644 --- a/boot.php +++ b/boot.php @@ -1548,9 +1548,9 @@ function check_url(App &$a) { // We will only change the url to an ip address if there is no existing setting if(! x($url)) - $url = set_config('system','url',$a->get_baseurl()); - if((! link_compare($url,$a->get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname))) - $url = set_config('system','url',$a->get_baseurl()); + $url = set_config('system','url',App::get_baseurl()); + if((! link_compare($url,App::get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname))) + $url = set_config('system','url',App::get_baseurl()); return; } diff --git a/index.php b/index.php index 08f24af60f..39e8c583a0 100644 --- a/index.php +++ b/index.php @@ -60,15 +60,15 @@ if(!$install) { if ($a->max_processes_reached() OR $a->maxload_reached()) { header($_SERVER["SERVER_PROTOCOL"].' 503 Service Temporarily Unavailable'); header('Retry-After: 120'); - header('Refresh: 120; url='.$a->get_baseurl()."/".$a->query_string); + header('Refresh: 120; url='.App::get_baseurl()."/".$a->query_string); die("System is currently unavailable. Please try again later"); } if (get_config('system','force_ssl') AND ($a->get_scheme() == "http") AND (intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND - (substr($a->get_baseurl(), 0, 8) == "https://")) { + (substr(App::get_baseurl(), 0, 8) == "https://")) { header("HTTP/1.1 302 Moved Temporarily"); - header("Location: ".$a->get_baseurl()."/".$a->query_string); + header("Location: ".App::get_baseurl()."/".$a->query_string); exit(); } @@ -150,7 +150,7 @@ if((x($_GET,'zrl')) && (!$install && !$maintenance)) { * */ -// header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";'); +// header('Link: <' . App::get_baseurl() . '/amcd>; rel="acct-mgmt";'); if(x($_COOKIE["Friendica"]) || (x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login')) require("include/auth.php"); @@ -281,7 +281,7 @@ if(strlen($a->module)) { if((x($_SERVER,'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) { logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']); - goaway($a->get_baseurl() . $_SERVER['REQUEST_URI']); + goaway(App::get_baseurl() . $_SERVER['REQUEST_URI']); } logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG); diff --git a/mod/filerm.php b/mod/filerm.php index cdc5a034aa..f34421ba52 100644 --- a/mod/filerm.php +++ b/mod/filerm.php @@ -21,7 +21,7 @@ function filerm_content(App &$a) { file_tag_unsave_file(local_user(),$item_id,$term, $category); if(x($_SESSION,'return_url')) - goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); + goaway(App::get_baseurl() . '/' . $_SESSION['return_url']); killme(); } diff --git a/mod/follow.php b/mod/follow.php index 56e698547b..f318dc202c 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -63,7 +63,7 @@ function follow_content(App &$a) { $request = $ret["request"]; $tpl = get_markup_template('dfrn_request.tpl'); } else { - $request = $a->get_baseurl()."/follow"; + $request = App::get_baseurl()."/follow"; $tpl = get_markup_template('auto_request.tpl'); } @@ -175,12 +175,12 @@ function follow_post(App &$a) { notice($result['message']); goaway($return_url); } elseif ($result['cid']) - goaway($a->get_baseurl().'/contacts/'.$result['cid']); + goaway(App::get_baseurl().'/contacts/'.$result['cid']); info( t('Contact added').EOL); if(strstr($return_url,'contacts')) - goaway($a->get_baseurl().'/contacts/'.$contact_id); + goaway(App::get_baseurl().'/contacts/'.$contact_id); goaway($return_url); // NOTREACHED diff --git a/mod/help.php b/mod/help.php index fa574c9839..c2693dedba 100644 --- a/mod/help.php +++ b/mod/help.php @@ -77,7 +77,7 @@ function help_content(App &$a) { if ($level>$lastlevel) $toc.="
    "; $idnum[$level]++; $id = implode("_", array_slice($idnum,1,$level)); - $href = $a->get_baseurl()."/help/{$filename}#{$id}"; + $href = App::get_baseurl()."/help/{$filename}#{$id}"; $toc .= "
  • ".strip_tags($line)."
  • "; $line = "".$line; $lastlevel = $level; diff --git a/mod/match.php b/mod/match.php index 8bc255023f..f7274e4366 100644 --- a/mod/match.php +++ b/mod/match.php @@ -23,7 +23,7 @@ function match_content(App &$a) { $a->page['aside'] .= findpeople_widget(); $a->page['aside'] .= follow_widget(); - $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; + $_SESSION['return_url'] = App::get_baseurl() . '/' . $a->cmd; $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user()) @@ -47,7 +47,7 @@ function match_content(App &$a) { if(strlen(get_config('system','directory'))) $x = post_url(get_server().'/msearch', $params); else - $x = post_url($a->get_baseurl() . '/msearch', $params); + $x = post_url(App::get_baseurl() . '/msearch', $params); $j = json_decode($x); @@ -68,7 +68,7 @@ function match_content(App &$a) { if (!count($match)) { $jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo); - $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url; + $connlnk = App::get_baseurl() . '/follow/?url=' . $jj->url; $photo_menu = array( 'profile' => array(t("View Profile"), zrl($jj->url)), 'follow' => array(t("Connect/Follow"), $connlnk) diff --git a/mod/redir.php b/mod/redir.php index b0c0b2c099..e951b2d2a9 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -64,7 +64,7 @@ function redir_init(App &$a) { } if (local_user()) { - $handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3); + $handle = $a->user['nickname'] . '@' . substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3); } if (remote_user()) { $handle = $_SESSION['handle']; diff --git a/mod/removeme.php b/mod/removeme.php index b7bdaa9400..4257667c4b 100644 --- a/mod/removeme.php +++ b/mod/removeme.php @@ -47,7 +47,7 @@ function removeme_content(App &$a) { $tpl = get_markup_template('removeme.tpl'); $o .= replace_macros($tpl, array( - '$basedir' => $a->get_baseurl(), + '$basedir' => App::get_baseurl(), '$hash' => $hash, '$title' => t('Remove My Account'), '$desc' => t('This will completely remove your account. Once this has been done it is not recoverable.'), diff --git a/mod/subthread.php b/mod/subthread.php index 02b1482c3e..3d16f8ca9c 100644 --- a/mod/subthread.php +++ b/mod/subthread.php @@ -87,7 +87,7 @@ function subthread_content(App &$a) { $post_type = (($item['resource-id']) ? t('photo') : t('status')); $objtype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); - $link = xmlify('' . "\n") ; + $link = xmlify('' . "\n") ; $body = $item['body']; $obj = <<< EOT @@ -128,7 +128,7 @@ EOT; $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; - $plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]'; + $plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]'; $arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink ); $arr['verb'] = $activity; From 9972a029e3019a15f2b98def80e850ff85a43429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 12:45:16 +0100 Subject: [PATCH 43/96] Changed $a->get_baseurl() to App::get_baseurl() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- boot.php | 6 +++--- index.php | 10 +++++----- mod/filerm.php | 2 +- mod/follow.php | 6 +++--- mod/help.php | 2 +- mod/match.php | 6 +++--- mod/redir.php | 2 +- mod/removeme.php | 2 +- mod/subthread.php | 4 ++-- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/boot.php b/boot.php index c80da23529..ccff45f734 100644 --- a/boot.php +++ b/boot.php @@ -1548,9 +1548,9 @@ function check_url(App &$a) { // We will only change the url to an ip address if there is no existing setting if(! x($url)) - $url = set_config('system','url',$a->get_baseurl()); - if((! link_compare($url,$a->get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname))) - $url = set_config('system','url',$a->get_baseurl()); + $url = set_config('system','url',App::get_baseurl()); + if((! link_compare($url,App::get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname))) + $url = set_config('system','url',App::get_baseurl()); return; } diff --git a/index.php b/index.php index 08f24af60f..39e8c583a0 100644 --- a/index.php +++ b/index.php @@ -60,15 +60,15 @@ if(!$install) { if ($a->max_processes_reached() OR $a->maxload_reached()) { header($_SERVER["SERVER_PROTOCOL"].' 503 Service Temporarily Unavailable'); header('Retry-After: 120'); - header('Refresh: 120; url='.$a->get_baseurl()."/".$a->query_string); + header('Refresh: 120; url='.App::get_baseurl()."/".$a->query_string); die("System is currently unavailable. Please try again later"); } if (get_config('system','force_ssl') AND ($a->get_scheme() == "http") AND (intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND - (substr($a->get_baseurl(), 0, 8) == "https://")) { + (substr(App::get_baseurl(), 0, 8) == "https://")) { header("HTTP/1.1 302 Moved Temporarily"); - header("Location: ".$a->get_baseurl()."/".$a->query_string); + header("Location: ".App::get_baseurl()."/".$a->query_string); exit(); } @@ -150,7 +150,7 @@ if((x($_GET,'zrl')) && (!$install && !$maintenance)) { * */ -// header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";'); +// header('Link: <' . App::get_baseurl() . '/amcd>; rel="acct-mgmt";'); if(x($_COOKIE["Friendica"]) || (x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login')) require("include/auth.php"); @@ -281,7 +281,7 @@ if(strlen($a->module)) { if((x($_SERVER,'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) { logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']); - goaway($a->get_baseurl() . $_SERVER['REQUEST_URI']); + goaway(App::get_baseurl() . $_SERVER['REQUEST_URI']); } logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG); diff --git a/mod/filerm.php b/mod/filerm.php index cdc5a034aa..f34421ba52 100644 --- a/mod/filerm.php +++ b/mod/filerm.php @@ -21,7 +21,7 @@ function filerm_content(App &$a) { file_tag_unsave_file(local_user(),$item_id,$term, $category); if(x($_SESSION,'return_url')) - goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); + goaway(App::get_baseurl() . '/' . $_SESSION['return_url']); killme(); } diff --git a/mod/follow.php b/mod/follow.php index 56e698547b..f318dc202c 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -63,7 +63,7 @@ function follow_content(App &$a) { $request = $ret["request"]; $tpl = get_markup_template('dfrn_request.tpl'); } else { - $request = $a->get_baseurl()."/follow"; + $request = App::get_baseurl()."/follow"; $tpl = get_markup_template('auto_request.tpl'); } @@ -175,12 +175,12 @@ function follow_post(App &$a) { notice($result['message']); goaway($return_url); } elseif ($result['cid']) - goaway($a->get_baseurl().'/contacts/'.$result['cid']); + goaway(App::get_baseurl().'/contacts/'.$result['cid']); info( t('Contact added').EOL); if(strstr($return_url,'contacts')) - goaway($a->get_baseurl().'/contacts/'.$contact_id); + goaway(App::get_baseurl().'/contacts/'.$contact_id); goaway($return_url); // NOTREACHED diff --git a/mod/help.php b/mod/help.php index fa574c9839..c2693dedba 100644 --- a/mod/help.php +++ b/mod/help.php @@ -77,7 +77,7 @@ function help_content(App &$a) { if ($level>$lastlevel) $toc.="
      "; $idnum[$level]++; $id = implode("_", array_slice($idnum,1,$level)); - $href = $a->get_baseurl()."/help/{$filename}#{$id}"; + $href = App::get_baseurl()."/help/{$filename}#{$id}"; $toc .= "
    • ".strip_tags($line)."
    • "; $line = "".$line; $lastlevel = $level; diff --git a/mod/match.php b/mod/match.php index 8bc255023f..f7274e4366 100644 --- a/mod/match.php +++ b/mod/match.php @@ -23,7 +23,7 @@ function match_content(App &$a) { $a->page['aside'] .= findpeople_widget(); $a->page['aside'] .= follow_widget(); - $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; + $_SESSION['return_url'] = App::get_baseurl() . '/' . $a->cmd; $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user()) @@ -47,7 +47,7 @@ function match_content(App &$a) { if(strlen(get_config('system','directory'))) $x = post_url(get_server().'/msearch', $params); else - $x = post_url($a->get_baseurl() . '/msearch', $params); + $x = post_url(App::get_baseurl() . '/msearch', $params); $j = json_decode($x); @@ -68,7 +68,7 @@ function match_content(App &$a) { if (!count($match)) { $jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo); - $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url; + $connlnk = App::get_baseurl() . '/follow/?url=' . $jj->url; $photo_menu = array( 'profile' => array(t("View Profile"), zrl($jj->url)), 'follow' => array(t("Connect/Follow"), $connlnk) diff --git a/mod/redir.php b/mod/redir.php index b0c0b2c099..e951b2d2a9 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -64,7 +64,7 @@ function redir_init(App &$a) { } if (local_user()) { - $handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3); + $handle = $a->user['nickname'] . '@' . substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3); } if (remote_user()) { $handle = $_SESSION['handle']; diff --git a/mod/removeme.php b/mod/removeme.php index b7bdaa9400..4257667c4b 100644 --- a/mod/removeme.php +++ b/mod/removeme.php @@ -47,7 +47,7 @@ function removeme_content(App &$a) { $tpl = get_markup_template('removeme.tpl'); $o .= replace_macros($tpl, array( - '$basedir' => $a->get_baseurl(), + '$basedir' => App::get_baseurl(), '$hash' => $hash, '$title' => t('Remove My Account'), '$desc' => t('This will completely remove your account. Once this has been done it is not recoverable.'), diff --git a/mod/subthread.php b/mod/subthread.php index 02b1482c3e..3d16f8ca9c 100644 --- a/mod/subthread.php +++ b/mod/subthread.php @@ -87,7 +87,7 @@ function subthread_content(App &$a) { $post_type = (($item['resource-id']) ? t('photo') : t('status')); $objtype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); - $link = xmlify('' . "\n") ; + $link = xmlify('' . "\n") ; $body = $item['body']; $obj = <<< EOT @@ -128,7 +128,7 @@ EOT; $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; - $plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]'; + $plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]'; $arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink ); $arr['verb'] = $activity; From 51716957b24d97c20f078d1f880a6ca112cae792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 15:37:27 +0100 Subject: [PATCH 44/96] converted more to dbm::is_result() + added braces/space MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/dfrn.php | 2 +- include/items.php | 18 +++++++++++------- include/queue.php | 4 ++-- include/user.php | 13 ++++++++----- mod/common.php | 3 ++- mod/dfrn_confirm.php | 15 +++++++++------ mod/dfrn_poll.php | 4 ++-- mod/editpost.php | 2 +- mod/item.php | 3 ++- mod/photos.php | 2 +- mod/poco.php | 3 ++- mod/profile_photo.php | 31 +++++++++++++++++++------------ mod/videos.php | 2 +- 13 files changed, 61 insertions(+), 41 deletions(-) diff --git a/include/dfrn.php b/include/dfrn.php index 689c5c2832..90ff1dfbbf 100644 --- a/include/dfrn.php +++ b/include/dfrn.php @@ -2355,7 +2355,7 @@ class dfrn { dbesc($xt->id), intval($importer["importer_uid"]) ); - if(count($i)) { + if (dbm::is_result($i)) { // For tags, the owner cannot remove the tag on the author's copy of the post. diff --git a/include/items.php b/include/items.php index 20aa2e2e02..c75bc768c2 100644 --- a/include/items.php +++ b/include/items.php @@ -704,7 +704,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa // If its a post from myself then tag the thread as "mention" logger("item_store: Checking if parent ".$parent_id." has to be tagged as mention for user ".$arr['uid'], LOGGER_DEBUG); $u = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($arr['uid'])); - if (count($u)) { + if (dbm::is_result($u)) { $a = get_app(); $self = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']); logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG); @@ -1188,19 +1188,22 @@ function tag_deliver($uid,$item_id) { $u = q("select * from user where uid = %d limit 1", intval($uid) ); - if (! count($u)) + + if (! dbm::is_result($u)) { return; + } $community_page = (($u[0]['page-flags'] == PAGE_COMMUNITY) ? true : false); $prvgroup = (($u[0]['page-flags'] == PAGE_PRVGROUP) ? true : false); - $i = q("select * from item where id = %d and uid = %d limit 1", + $i = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($item_id), intval($uid) ); - if (! count($i)) + if (! dbm::is_result($i)) { return; + } $item = $i[0]; @@ -1298,12 +1301,13 @@ function tgroup_check($uid,$item) { if (($item['wall']) || ($item['origin']) || ($item['uri'] != $item['parent-uri'])) return false; - - $u = q("select * from user where uid = %d limit 1", + /// @TODO Encapsulate this or find it encapsulated and replace all occurrances + $u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid) ); - if (! count($u)) + if (! dbm::is_result($u)) { return false; + } $community_page = (($u[0]['page-flags'] == PAGE_COMMUNITY) ? true : false); $prvgroup = (($u[0]['page-flags'] == PAGE_PRVGROUP) ? true : false); diff --git a/include/queue.php b/include/queue.php index ad7079e959..1cc2ee095b 100644 --- a/include/queue.php +++ b/include/queue.php @@ -126,7 +126,7 @@ function queue_run(&$argv, &$argc){ $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($qi[0]['cid']) ); - if(! count($c)) { + if (! dbm::is_result($c)) { remove_queue_item($q_item['id']); continue; } @@ -156,7 +156,7 @@ function queue_run(&$argv, &$argc){ FROM `user` WHERE `uid` = %d LIMIT 1", intval($c[0]['uid']) ); - if(! count($u)) { + if (! dbm::is_result($u)) { remove_queue_item($q_item['id']); continue; } diff --git a/include/user.php b/include/user.php index ae05b9e112..d6970d475f 100644 --- a/include/user.php +++ b/include/user.php @@ -262,7 +262,7 @@ function create_user($arr) { intval($netpublish) ); - if($r === false) { + if ($r === false) { $result['message'] .= t('An error occurred creating your default profile. Please try again.') . EOL; // Start fresh next time. $r = q("DELETE FROM `user` WHERE `uid` = %d", @@ -325,24 +325,27 @@ function create_user($arr) { $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4 ); - if($r === false) + if ($r === false) { $photo_failure = true; + } $img->scaleImage(80); $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 5 ); - if($r === false) + if ($r === false) { $photo_failure = true; + } $img->scaleImage(48); $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 6 ); - if($r === false) + if ($r === false) { $photo_failure = true; + } - if(! $photo_failure) { + if (! $photo_failure) { q("UPDATE `photo` SET `profile` = 1 WHERE `resource-id` = '%s' ", dbesc($hash) ); diff --git a/mod/common.php b/mod/common.php index e0cd655061..f3601c0fe6 100644 --- a/mod/common.php +++ b/mod/common.php @@ -48,8 +48,9 @@ function common_content(App &$a) { $a->page['aside'] .= $vcard_widget; } - if(! count($c)) + if (! dbm::is_result($c)) { return; + } if(! $cid) { if(get_my_url()) { diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 6d97899aff..ba8e27431f 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -415,23 +415,26 @@ function dfrn_confirm_post(&$a,$handsfree = null) { ); } - if($r === false) - notice( t('Unable to set contact photo.') . EOL); + /// @TODO is dbm::is_result() working here? + if ($r === false) { + notice( t('Unable to set contact photo.') . EOL); + } // reload contact info $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($contact_id) ); - if (dbm::is_result($r)) + if (dbm::is_result($r)) { $contact = $r[0]; - else + } else { $contact = null; + } - if((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND)) { + if ((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND)) { - if(($contact) && ($contact['network'] === NETWORK_DIASPORA)) { + if (($contact) && ($contact['network'] === NETWORK_DIASPORA)) { require_once('include/diaspora.php'); $ret = diaspora::send_share($user[0],$r[0]); logger('share returns: ' . $ret); diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index f74429e580..a31a50ad25 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -137,7 +137,7 @@ function dfrn_poll_init(App &$a) { $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($r[0]['cid']) ); - if(! count($c)) { + if (! dbm::is_result($c)) { xml_status(3, 'No profile'); } $contact = $c[0]; @@ -234,7 +234,7 @@ function dfrn_poll_post(App &$a) { $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($r[0]['cid']) ); - if(! count($c)) { + if (! dbm::is_result($c)) { xml_status(3, 'No profile'); } $contact = $c[0]; diff --git a/mod/editpost.php b/mod/editpost.php index 1bf150a5dd..a655801d77 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -23,7 +23,7 @@ function editpost_content(App &$a) { intval(local_user()) ); - if (! count($itm)) { + if (! dbm::is_result($itm)) { notice( t('Item not found') . EOL); return; } diff --git a/mod/item.php b/mod/item.php index a11845e55f..864aa18e51 100644 --- a/mod/item.php +++ b/mod/item.php @@ -224,8 +224,9 @@ function item_post(App &$a) { intval($profile_uid), intval($post_id) ); - if(! count($i)) + if (! dbm::is_result($i)) { killme(); + } $orig_post = $i[0]; } diff --git a/mod/photos.php b/mod/photos.php index 94ddb91dd9..8d97a30051 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -346,7 +346,7 @@ function photos_post(App &$a) { dbesc($r[0]['resource-id']), intval($page_owner_uid) ); - if (count($i)) { + if (dbm::is_result($i)) { q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d", dbesc(datetime_convert()), dbesc(datetime_convert()), diff --git a/mod/poco.php b/mod/poco.php index 787776b906..11f984757a 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -16,8 +16,9 @@ function poco_init(App &$a) { } if(! x($user)) { $c = q("SELECT * FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1"); - if(! count($c)) + if (! dbm::is_result($c)) { http_status_exit(401); + } $system_mode = true; } diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 356c507f7a..0b6dd8d13b 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -73,22 +73,25 @@ function profile_photo_post(App &$a) { $r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 4, $is_default_profile); - if($r === false) + if ($r === false) { notice ( sprintf(t('Image size reduction [%s] failed.'),"175") . EOL ); + } $im->scaleImage(80); $r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 5, $is_default_profile); - if($r === false) + if ($r === false) { notice( sprintf(t('Image size reduction [%s] failed.'),"80") . EOL ); + } $im->scaleImage(48); $r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 6, $is_default_profile); - if($r === false) + if ($r === false) { notice( sprintf(t('Image size reduction [%s] failed.'),"48") . EOL ); + } // If setting for the default profile, unset the profile photo flag from any other photos I own @@ -282,15 +285,17 @@ function profile_photo_content(App &$a) { if(! function_exists('profile_photo_crop_ui_head')) { function profile_photo_crop_ui_head(&$a, $ph){ $max_length = get_config('system','max_image_length'); - if(! $max_length) + if (! $max_length) { $max_length = MAX_IMAGE_LENGTH; - if($max_length > 0) + } + if ($max_length > 0) { $ph->scaleImage($max_length); + } $width = $ph->getWidth(); $height = $ph->getHeight(); - if($width < 175 || $height < 175) { + if ($width < 175 || $height < 175) { $ph->scaleImageUp(200); $width = $ph->getWidth(); $height = $ph->getHeight(); @@ -303,19 +308,21 @@ function profile_photo_crop_ui_head(&$a, $ph){ $r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 0 ); - if($r) + if ($r) { info( t('Image uploaded successfully.') . EOL ); - else + } else { notice( t('Image upload failed.') . EOL ); + } - if($width > 640 || $height > 640) { + if ($width > 640 || $height > 640) { $ph->scaleImage(640); $r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 1 ); - - if($r === false) + + if ($r === false) { notice( sprintf(t('Image size reduction [%s] failed.'),"640") . EOL ); - else + } else { $smallest = 1; + } } $a->config['imagecrop'] = $hash; diff --git a/mod/videos.php b/mod/videos.php index 52176524a2..58c4b6c650 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -154,7 +154,7 @@ function videos_post(App &$a) { intval(local_user()) ); //echo "
      "; var_dump($i); killme();
      -			if(count($i)) {
      +			if (dbm::is_result($i)) {
       				q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
       					dbesc(datetime_convert()),
       					dbesc(datetime_convert()),
      
      From c0cc65304b06b027219a9f162deaab90fe2a0487 Mon Sep 17 00:00:00 2001
      From: =?UTF-8?q?Roland=20H=C3=A4der?= 
      Date: Tue, 20 Dec 2016 15:37:27 +0100
      Subject: [PATCH 45/96] converted more to dbm::is_result() + added braces/space
      MIME-Version: 1.0
      Content-Type: text/plain; charset=UTF-8
      Content-Transfer-Encoding: 8bit
      
      Signed-off-by: Roland Häder 
      ---
       include/dfrn.php      |  2 +-
       include/items.php     | 18 +++++++++++-------
       include/queue.php     |  4 ++--
       include/user.php      | 13 ++++++++-----
       mod/common.php        |  3 ++-
       mod/dfrn_confirm.php  | 15 +++++++++------
       mod/dfrn_poll.php     |  4 ++--
       mod/editpost.php      |  2 +-
       mod/item.php          |  3 ++-
       mod/photos.php        |  2 +-
       mod/poco.php          |  3 ++-
       mod/profile_photo.php | 31 +++++++++++++++++++------------
       mod/videos.php        |  2 +-
       13 files changed, 61 insertions(+), 41 deletions(-)
      
      diff --git a/include/dfrn.php b/include/dfrn.php
      index 689c5c2832..90ff1dfbbf 100644
      --- a/include/dfrn.php
      +++ b/include/dfrn.php
      @@ -2355,7 +2355,7 @@ class dfrn {
       						dbesc($xt->id),
       						intval($importer["importer_uid"])
       					);
      -					if(count($i)) {
      +					if (dbm::is_result($i)) {
       
       						// For tags, the owner cannot remove the tag on the author's copy of the post.
       
      diff --git a/include/items.php b/include/items.php
      index 20aa2e2e02..c75bc768c2 100644
      --- a/include/items.php
      +++ b/include/items.php
      @@ -704,7 +704,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
       			// If its a post from myself then tag the thread as "mention"
       			logger("item_store: Checking if parent ".$parent_id." has to be tagged as mention for user ".$arr['uid'], LOGGER_DEBUG);
       			$u = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($arr['uid']));
      -			if (count($u)) {
      +			if (dbm::is_result($u)) {
       				$a = get_app();
       				$self = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
       				logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG);
      @@ -1188,19 +1188,22 @@ function tag_deliver($uid,$item_id) {
       	$u = q("select * from user where uid = %d limit 1",
       		intval($uid)
       	);
      -	if (! count($u))
      +
      +	if (! dbm::is_result($u)) {
       		return;
      +	}
       
       	$community_page = (($u[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
       	$prvgroup = (($u[0]['page-flags'] == PAGE_PRVGROUP) ? true : false);
       
       
      -	$i = q("select * from item where id = %d and uid = %d limit 1",
      +	$i = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
       		intval($item_id),
       		intval($uid)
       	);
      -	if (! count($i))
      +	if (! dbm::is_result($i)) {
       		return;
      +	}
       
       	$item = $i[0];
       
      @@ -1298,12 +1301,13 @@ function tgroup_check($uid,$item) {
       	if (($item['wall']) || ($item['origin']) || ($item['uri'] != $item['parent-uri']))
       		return false;
       
      -
      -	$u = q("select * from user where uid = %d limit 1",
      +	/// @TODO Encapsulate this or find it encapsulated and replace all occurrances
      +	$u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
       		intval($uid)
       	);
      -	if (! count($u))
      +	if (! dbm::is_result($u)) {
       		return false;
      +	}
       
       	$community_page = (($u[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
       	$prvgroup = (($u[0]['page-flags'] == PAGE_PRVGROUP) ? true : false);
      diff --git a/include/queue.php b/include/queue.php
      index ad7079e959..1cc2ee095b 100644
      --- a/include/queue.php
      +++ b/include/queue.php
      @@ -126,7 +126,7 @@ function queue_run(&$argv, &$argc){
       		$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
       			intval($qi[0]['cid'])
       		);
      -		if(! count($c)) {
      +		if (! dbm::is_result($c)) {
       			remove_queue_item($q_item['id']);
       			continue;
       		}
      @@ -156,7 +156,7 @@ function queue_run(&$argv, &$argc){
       			FROM `user` WHERE `uid` = %d LIMIT 1",
       			intval($c[0]['uid'])
       		);
      -		if(! count($u)) {
      +		if (! dbm::is_result($u)) {
       			remove_queue_item($q_item['id']);
       			continue;
       		}
      diff --git a/include/user.php b/include/user.php
      index ae05b9e112..d6970d475f 100644
      --- a/include/user.php
      +++ b/include/user.php
      @@ -262,7 +262,7 @@ function create_user($arr) {
       			intval($netpublish)
       
       		);
      -		if($r === false) {
      +		if ($r === false) {
       			$result['message'] .=  t('An error occurred creating your default profile. Please try again.') . EOL;
       			// Start fresh next time.
       			$r = q("DELETE FROM `user` WHERE `uid` = %d",
      @@ -325,24 +325,27 @@ function create_user($arr) {
       
       			$r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4 );
       
      -			if($r === false)
      +			if ($r === false) {
       				$photo_failure = true;
      +			}
       
       			$img->scaleImage(80);
       
       			$r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 5 );
       
      -			if($r === false)
      +			if ($r === false) {
       				$photo_failure = true;
      +			}
       
       			$img->scaleImage(48);
       
       			$r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 6 );
       
      -			if($r === false)
      +			if ($r === false) {
       				$photo_failure = true;
      +			}
       
      -			if(! $photo_failure) {
      +			if (! $photo_failure) {
       				q("UPDATE `photo` SET `profile` = 1 WHERE `resource-id` = '%s' ",
       					dbesc($hash)
       				);
      diff --git a/mod/common.php b/mod/common.php
      index e0cd655061..f3601c0fe6 100644
      --- a/mod/common.php
      +++ b/mod/common.php
      @@ -48,8 +48,9 @@ function common_content(App &$a) {
       		$a->page['aside'] .= $vcard_widget;
       	}
       
      -	if(! count($c))
      +	if (! dbm::is_result($c)) {
       		return;
      +	}
       
       	if(! $cid) {
       		if(get_my_url()) {
      diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php
      index 6d97899aff..ba8e27431f 100644
      --- a/mod/dfrn_confirm.php
      +++ b/mod/dfrn_confirm.php
      @@ -415,23 +415,26 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
       			);
       		}
       
      -		if($r === false)
      -				notice( t('Unable to set contact photo.') . EOL);
      +		/// @TODO is dbm::is_result() working here?
      +		if ($r === false) {
      +			notice( t('Unable to set contact photo.') . EOL);
      +		}
       
       		// reload contact info
       
       		$r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
       			intval($contact_id)
       		);
      -		if (dbm::is_result($r))
      +		if (dbm::is_result($r)) {
       			$contact = $r[0];
      -		else
      +		} else {
       			$contact = null;
      +		}
       
       
      -		if((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND)) {
      +		if ((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND)) {
       
      -			if(($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
      +			if (($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
       				require_once('include/diaspora.php');
       				$ret = diaspora::send_share($user[0],$r[0]);
       				logger('share returns: ' . $ret);
      diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php
      index f74429e580..a31a50ad25 100644
      --- a/mod/dfrn_poll.php
      +++ b/mod/dfrn_poll.php
      @@ -137,7 +137,7 @@ function dfrn_poll_init(App &$a) {
       			$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
       				intval($r[0]['cid'])
       			);
      -			if(! count($c)) {
      +			if (! dbm::is_result($c)) {
       				xml_status(3, 'No profile');
       			}
       			$contact = $c[0];
      @@ -234,7 +234,7 @@ function dfrn_poll_post(App &$a) {
       			$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
       				intval($r[0]['cid'])
       			);
      -			if(! count($c)) {
      +			if (! dbm::is_result($c)) {
       				xml_status(3, 'No profile');
       			}
       			$contact = $c[0];
      diff --git a/mod/editpost.php b/mod/editpost.php
      index 1bf150a5dd..a655801d77 100644
      --- a/mod/editpost.php
      +++ b/mod/editpost.php
      @@ -23,7 +23,7 @@ function editpost_content(App &$a) {
       		intval(local_user())
       	);
       
      -	if (! count($itm)) {
      +	if (! dbm::is_result($itm)) {
       		notice( t('Item not found') . EOL);
       		return;
       	}
      diff --git a/mod/item.php b/mod/item.php
      index a11845e55f..864aa18e51 100644
      --- a/mod/item.php
      +++ b/mod/item.php
      @@ -224,8 +224,9 @@ function item_post(App &$a) {
       			intval($profile_uid),
       			intval($post_id)
       		);
      -		if(! count($i))
      +		if (! dbm::is_result($i)) {
       			killme();
      +		}
       		$orig_post = $i[0];
       	}
       
      diff --git a/mod/photos.php b/mod/photos.php
      index 94ddb91dd9..8d97a30051 100644
      --- a/mod/photos.php
      +++ b/mod/photos.php
      @@ -346,7 +346,7 @@ function photos_post(App &$a) {
       				dbesc($r[0]['resource-id']),
       				intval($page_owner_uid)
       			);
      -			if (count($i)) {
      +			if (dbm::is_result($i)) {
       				q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
       					dbesc(datetime_convert()),
       					dbesc(datetime_convert()),
      diff --git a/mod/poco.php b/mod/poco.php
      index 787776b906..11f984757a 100644
      --- a/mod/poco.php
      +++ b/mod/poco.php
      @@ -16,8 +16,9 @@ function poco_init(App &$a) {
       	}
       	if(! x($user)) {
       		$c = q("SELECT * FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1");
      -		if(! count($c))
      +		if (! dbm::is_result($c)) {
       			http_status_exit(401);
      +		}
       		$system_mode = true;
       	}
       
      diff --git a/mod/profile_photo.php b/mod/profile_photo.php
      index 356c507f7a..0b6dd8d13b 100644
      --- a/mod/profile_photo.php
      +++ b/mod/profile_photo.php
      @@ -73,22 +73,25 @@ function profile_photo_post(App &$a) {
       
       				$r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 4, $is_default_profile);
       
      -				if($r === false)
      +				if ($r === false) {
       					notice ( sprintf(t('Image size reduction [%s] failed.'),"175") . EOL );
      +				}
       
       				$im->scaleImage(80);
       
       				$r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 5, $is_default_profile);
       
      -				if($r === false)
      +				if ($r === false) {
       					notice( sprintf(t('Image size reduction [%s] failed.'),"80") . EOL );
      +				}
       
       				$im->scaleImage(48);
       
       				$r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 6, $is_default_profile);
       
      -				if($r === false)
      +				if ($r === false) {
       					notice( sprintf(t('Image size reduction [%s] failed.'),"48") . EOL );
      +				}
       
       				// If setting for the default profile, unset the profile photo flag from any other photos I own
       
      @@ -282,15 +285,17 @@ function profile_photo_content(App &$a) {
       if(! function_exists('profile_photo_crop_ui_head')) {
       function profile_photo_crop_ui_head(&$a, $ph){
       	$max_length = get_config('system','max_image_length');
      -	if(! $max_length)
      +	if (! $max_length) {
       		$max_length = MAX_IMAGE_LENGTH;
      -	if($max_length > 0)
      +	}
      +	if ($max_length > 0) {
       		$ph->scaleImage($max_length);
      +	}
       
       	$width = $ph->getWidth();
       	$height = $ph->getHeight();
       
      -	if($width < 175 || $height < 175) {
      +	if ($width < 175 || $height < 175) {
       		$ph->scaleImageUp(200);
       		$width = $ph->getWidth();
       		$height = $ph->getHeight();
      @@ -303,19 +308,21 @@ function profile_photo_crop_ui_head(&$a, $ph){
       
       	$r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 0 );	
       
      -	if($r)
      +	if ($r) {
       		info( t('Image uploaded successfully.') . EOL );
      -	else
      +	} else {
       		notice( t('Image upload failed.') . EOL );
      +	}
       
      -	if($width > 640 || $height > 640) {
      +	if ($width > 640 || $height > 640) {
       		$ph->scaleImage(640);
       		$r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 1 );	
      -		
      -		if($r === false)
      +
      +		if ($r === false) {
       			notice( sprintf(t('Image size reduction [%s] failed.'),"640") . EOL );
      -		else
      +		} else {
       			$smallest = 1;
      +		}
       	}
       
       	$a->config['imagecrop'] = $hash;
      diff --git a/mod/videos.php b/mod/videos.php
      index 52176524a2..58c4b6c650 100644
      --- a/mod/videos.php
      +++ b/mod/videos.php
      @@ -154,7 +154,7 @@ function videos_post(App &$a) {
       				intval(local_user())
       			);
       			//echo "
      "; var_dump($i); killme();
      -			if(count($i)) {
      +			if (dbm::is_result($i)) {
       				q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
       					dbesc(datetime_convert()),
       					dbesc(datetime_convert()),
      
      From 4b221d216e16a61e263e10935285413e58b6c765 Mon Sep 17 00:00:00 2001
      From: =?UTF-8?q?Roland=20H=C3=A4der?= 
      Date: Tue, 20 Dec 2016 17:43:46 +0100
      Subject: [PATCH 46/96] added more curly braces + space between "if" and brace
      MIME-Version: 1.0
      Content-Type: text/plain; charset=UTF-8
      Content-Transfer-Encoding: 8bit
      
      Signed-off-by: Roland Häder 
      ---
       boot.php             | 15 +++++----
       include/follow.php   | 20 +++++++-----
       include/salmon.php   | 21 ++++++------
       include/security.php | 28 ++++++++--------
       include/socgraph.php | 77 ++++++++++++++++++++++++++------------------
       index.php            | 39 ++++++++++++----------
       mod/admin.php        | 73 +++++++++++++++++++++--------------------
       mod/allfriends.php   |  2 +-
       mod/cal.php          |  2 +-
       mod/delegate.php     |  4 +--
       mod/dfrn_confirm.php |  9 +++---
       mod/dfrn_request.php | 39 +++++++++++++---------
       mod/dirfind.php      | 36 +++++++++++++--------
       mod/events.php       | 22 +++++++------
       mod/settings.php     |  5 +--
       15 files changed, 225 insertions(+), 167 deletions(-)
      
      diff --git a/boot.php b/boot.php
      index ccff45f734..70f7d324d3 100644
      --- a/boot.php
      +++ b/boot.php
      @@ -670,22 +670,23 @@ class App {
       
       		#set_include_path("include/$this->hostname" . PATH_SEPARATOR . get_include_path());
       
      -		if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,9) === "pagename=") {
      +		if ((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,9) === "pagename=") {
       			$this->query_string = substr($_SERVER['QUERY_STRING'],9);
       			// removing trailing / - maybe a nginx problem
       			if (substr($this->query_string, 0, 1) == "/")
       				$this->query_string = substr($this->query_string, 1);
      -		} elseif((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
      +		} elseif ((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
       			$this->query_string = substr($_SERVER['QUERY_STRING'],2);
       			// removing trailing / - maybe a nginx problem
       			if (substr($this->query_string, 0, 1) == "/")
       				$this->query_string = substr($this->query_string, 1);
       		}
       
      -		if (x($_GET,'pagename'))
      +		if (x($_GET,'pagename')) {
       			$this->cmd = trim($_GET['pagename'],'/\\');
      -		elseif (x($_GET,'q'))
      +		} elseif (x($_GET,'q')) {
       			$this->cmd = trim($_GET['q'],'/\\');
      +		}
       
       
       		// fix query_string
      @@ -694,13 +695,15 @@ class App {
       
       		// unix style "homedir"
       
      -		if(substr($this->cmd,0,1) === '~')
      +		if (substr($this->cmd,0,1) === '~') {
       			$this->cmd = 'profile/' . substr($this->cmd,1);
      +		}
       
       		// Diaspora style profile url
       
      -		if(substr($this->cmd,0,2) === 'u/')
      +		if (substr($this->cmd,0,2) === 'u/') {
       			$this->cmd = 'profile/' . substr($this->cmd,2);
      +		}
       
       
       		/*
      diff --git a/include/follow.php b/include/follow.php
      index e67beb84c2..15e8dd28d8 100644
      --- a/include/follow.php
      +++ b/include/follow.php
      @@ -77,12 +77,12 @@ function new_contact($uid,$url,$interactive = false) {
       
       	$url = str_replace('/#!/','/',$url);
       
      -	if(! allowed_url($url)) {
      +	if (! allowed_url($url)) {
       		$result['message'] = t('Disallowed profile URL.');
       		return $result;
       	}
       
      -	if(! $url) {
      +	if (! $url) {
       		$result['message'] = t('Connect URL missing.');
       		return $result;
       	}
      @@ -91,17 +91,21 @@ function new_contact($uid,$url,$interactive = false) {
       
       	call_hooks('follow', $arr);
       
      -	if(x($arr['contact'],'name'))
      +	if (x($arr['contact'],'name')) {
       		$ret = $arr['contact'];
      -	else
      +	}
      +	else {
       		$ret = probe_url($url);
      +	}
       
      -	if($ret['network'] === NETWORK_DFRN) {
      -		if($interactive) {
      -			if(strlen($a->path))
      +	if ($ret['network'] === NETWORK_DFRN) {
      +		if ($interactive) {
      +			if (strlen($a->path)) {
       				$myaddr = bin2hex(App::get_baseurl() . '/profile/' . $a->user['nickname']);
      -			else
      +			}
      +			else {
       				$myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
      +			}
       
       			goaway($ret['request'] . "&addr=$myaddr");
       
      diff --git a/include/salmon.php b/include/salmon.php
      index c5c3d72237..2b58334704 100644
      --- a/include/salmon.php
      +++ b/include/salmon.php
      @@ -24,22 +24,24 @@ function get_salmon_key($uri,$keyhash) {
       	// We have found at least one key URL
       	// If it's inline, parse it - otherwise get the key
       
      -	if(count($ret) > 0) {
      -		for($x = 0; $x < count($ret); $x ++) {
      -			if(substr($ret[$x],0,5) === 'data:') {
      -				if(strstr($ret[$x],','))
      +	if (count($ret) > 0) {
      +		for ($x = 0; $x < count($ret); $x ++) {
      +			if (substr($ret[$x],0,5) === 'data:') {
      +				if (strstr($ret[$x],',')) {
       					$ret[$x] = substr($ret[$x],strpos($ret[$x],',')+1);
      -				else
      +				} else {
       					$ret[$x] = substr($ret[$x],5);
      -			} elseif (normalise_link($ret[$x]) == 'http://')
      +				}
      +			} elseif (normalise_link($ret[$x]) == 'http://') {
       				$ret[$x] = fetch_url($ret[$x]);
      +			}
       		}
       	}
       
       
       	logger('Key located: ' . print_r($ret,true));
       
      -	if(count($ret) == 1) {
      +	if (count($ret) == 1) {
       
       		// We only found one one key so we don't care if the hash matches.
       		// If it's the wrong key we'll find out soon enough because
      @@ -50,10 +52,11 @@ function get_salmon_key($uri,$keyhash) {
       		return $ret[0];
       	}
       	else {
      -		foreach($ret as $a) {
      +		foreach ($ret as $a) {
       			$hash = base64url_encode(hash('sha256',$a));
      -			if($hash == $keyhash)
      +			if ($hash == $keyhash) {
       				return $a;
      +			}
       		}
       	}
       
      diff --git a/include/security.php b/include/security.php
      index 7e14146d94..cd00b5f7b0 100644
      --- a/include/security.php
      +++ b/include/security.php
      @@ -94,11 +94,12 @@ function authenticate_success($user_record, $login_initial = false, $interactive
       
       
       	}
      -	if($login_initial) {
      +	if ($login_initial) {
       		call_hooks('logged_in', $a->user);
       
      -		if(($a->module !== 'home') && isset($_SESSION['return_url']))
      +		if (($a->module !== 'home') && isset($_SESSION['return_url'])) {
       			goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
      +		}
       	}
       
       }
      @@ -109,16 +110,17 @@ function can_write_wall(&$a,$owner) {
       
       	static $verified = 0;
       
      -	if((! (local_user())) && (! (remote_user())))
      +	if ((! (local_user())) && (! (remote_user()))) {
       		return false;
      +	}
       
       	$uid = local_user();
       
      -	if(($uid) && ($uid == $owner)) {
      +	if (($uid) && ($uid == $owner)) {
       		return true;
       	}
       
      -	if(remote_user()) {
      +	if (remote_user()) {
       
       		// use remembered decision and avoid a DB lookup for each and every display item
       		// DO NOT use this function if there are going to be multiple owners
      @@ -126,25 +128,25 @@ function can_write_wall(&$a,$owner) {
       		// We have a contact-id for an authenticated remote user, this block determines if the contact
       		// belongs to this page owner, and has the necessary permissions to post content
       
      -		if($verified === 2)
      +		if ($verified === 2) {
       			return true;
      -		elseif($verified === 1)
      +		} elseif ($verified === 1) {
       			return false;
      -		else {
      +		} else {
       			$cid = 0;
       
      -			if(is_array($_SESSION['remote'])) {
      -				foreach($_SESSION['remote'] as $visitor) {
      -					if($visitor['uid'] == $owner) {
      +			if (is_array($_SESSION['remote'])) {
      +				foreach ($_SESSION['remote'] as $visitor) {
      +					if ($visitor['uid'] == $owner) {
       						$cid = $visitor['cid'];
       						break;
       					}
       				}
       			}
       
      -			if(! $cid)
      +			if (! $cid) {
       				return false;
      -
      +			}
       
       			$r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `user`.`uid` = `contact`.`uid` 
       				WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 
      diff --git a/include/socgraph.php b/include/socgraph.php
      index a779e88eff..7c70a22a54 100644
      --- a/include/socgraph.php
      +++ b/include/socgraph.php
      @@ -91,8 +91,8 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
       
       		$name = $entry->displayName;
       
      -		if(isset($entry->urls)) {
      -			foreach($entry->urls as $url) {
      +		if (isset($entry->urls)) {
      +			foreach ($entry->urls as $url) {
       				if ($url->type == 'profile') {
       					$profile_url = $url->value;
       					continue;
      @@ -104,7 +104,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
       			}
       		}
       		if (isset($entry->photos)) {
      -			foreach($entry->photos as $photo) {
      +			foreach ($entry->photos as $photo) {
       				if ($photo->type == 'profile') {
       					$profile_photo = $photo->value;
       					continue;
      @@ -112,29 +112,37 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
       			}
       		}
       
      -		if(isset($entry->updated))
      +		if (isset($entry->updated)) {
       			$updated = date("Y-m-d H:i:s", strtotime($entry->updated));
      +		}
       
      -		if(isset($entry->network))
      +		if (isset($entry->network)) {
       			$network = $entry->network;
      +		}
       
      -		if(isset($entry->currentLocation))
      +		if (isset($entry->currentLocation)) {
       			$location = $entry->currentLocation;
      +		}
       
      -		if(isset($entry->aboutMe))
      +		if (isset($entry->aboutMe)) {
       			$about = html2bbcode($entry->aboutMe);
      +		}
       
      -		if(isset($entry->gender))
      +		if (isset($entry->gender)) {
       			$gender = $entry->gender;
      +		}
       
      -		if(isset($entry->generation) AND ($entry->generation > 0))
      +		if (isset($entry->generation) AND ($entry->generation > 0)) {
       			$generation = ++$entry->generation;
      +		}
       
      -		if(isset($entry->tags))
      -			foreach($entry->tags as $tag)
      +		if (isset($entry->tags)) {
      +			foreach($entry->tags as $tag) {
       				$keywords = implode(", ", $tag);
      +			}
      +		}
       
      -		if(isset($entry->contactType) AND ($entry->contactType >= 0))
      +		if (isset($entry->contactType) AND ($entry->contactType >= 0))
       			$contact_type = $entry->contactType;
       
       		// If you query a Friendica server for its profiles, the network has to be Friendica
      @@ -171,8 +179,6 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
       
       function poco_check($profile_url, $name, $network, $profile_photo, $about, $location, $gender, $keywords, $connect_url, $updated, $generation, $cid = 0, $uid = 0, $zcid = 0) {
       
      -	$a = get_app();
      -
       	// Generation:
       	//  0: No definition
       	//  1: Profiles on this server
      @@ -1186,12 +1192,12 @@ function update_suggestions() {
       
       	$done[] = App::get_baseurl() . '/poco';
       
      -	if(strlen(get_config('system','directory'))) {
      +	if (strlen(get_config('system','directory'))) {
       		$x = fetch_url(get_server()."/pubsites");
       		if ($x) {
       			$j = json_decode($x);
       			if ($j->entries) {
      -				foreach($j->entries as $entry) {
      +				foreach ($j->entries as $entry) {
       
       					poco_check_server($entry->url);
       
      @@ -1210,7 +1216,7 @@ function update_suggestions() {
       	);
       
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$base = substr($rr['poco'],0,strrpos($rr['poco'],'/'));
       			if(! in_array($base,$done))
       				poco_load(0,0,0,$base);
      @@ -1221,7 +1227,7 @@ function update_suggestions() {
       function poco_discover_federation() {
       	$last = get_config('poco','last_federation_discovery');
       
      -	if($last) {
      +	if ($last) {
       		$next = $last + (24 * 60 * 60);
       		if($next > time())
       			return;
      @@ -1377,7 +1383,7 @@ function poco_discover_server($data, $default_generation = 0) {
       
       		$name = $entry->displayName;
       
      -		if(isset($entry->urls)) {
      +		if (isset($entry->urls)) {
       			foreach($entry->urls as $url) {
       				if ($url->type == 'profile') {
       					$profile_url = $url->value;
      @@ -1390,39 +1396,48 @@ function poco_discover_server($data, $default_generation = 0) {
       			}
       		}
       
      -		if(isset($entry->photos)) {
      -			foreach($entry->photos as $photo) {
      -				if($photo->type == 'profile') {
      +		if (isset($entry->photos)) {
      +			foreach ($entry->photos as $photo) {
      +				if ($photo->type == 'profile') {
       					$profile_photo = $photo->value;
       					continue;
       				}
       			}
       		}
       
      -		if(isset($entry->updated))
      +		if (isset($entry->updated)) {
       			$updated = date("Y-m-d H:i:s", strtotime($entry->updated));
      +		}
       
      -		if(isset($entry->network))
      +		if(isset($entry->network)) {
       			$network = $entry->network;
      +		}
       
      -		if(isset($entry->currentLocation))
      +		if(isset($entry->currentLocation)) {
       			$location = $entry->currentLocation;
      +		}
       
      -		if(isset($entry->aboutMe))
      +		if(isset($entry->aboutMe)) {
       			$about = html2bbcode($entry->aboutMe);
      +		}
       
      -		if(isset($entry->gender))
      +		if(isset($entry->gender)) {
       			$gender = $entry->gender;
      +		}
       
      -		if(isset($entry->generation) AND ($entry->generation > 0))
      +		if(isset($entry->generation) AND ($entry->generation > 0)) {
       			$generation = ++$entry->generation;
      +		}
       
      -		if(isset($entry->contactType) AND ($entry->contactType >= 0))
      +		if(isset($entry->contactType) AND ($entry->contactType >= 0)) {
       			$contact_type = $entry->contactType;
      +		}
       
      -		if(isset($entry->tags))
      -			foreach($entry->tags as $tag)
      +		if(isset($entry->tags)) {
      +			foreach ($entry->tags as $tag) {
       				$keywords = implode(", ", $tag);
      +			}
      +		}
       
       		if ($generation > 0) {
       			$success = true;
      diff --git a/index.php b/index.php
      index 39e8c583a0..f05151757b 100644
      --- a/index.php
      +++ b/index.php
      @@ -152,22 +152,26 @@ if((x($_GET,'zrl')) && (!$install && !$maintenance)) {
       
       // header('Link: <' . App::get_baseurl() . '/amcd>; rel="acct-mgmt";');
       
      -if(x($_COOKIE["Friendica"]) || (x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login'))
      +if (x($_COOKIE["Friendica"]) || (x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login')) {
       	require("include/auth.php");
      +}
       
      -if(! x($_SESSION,'authenticated'))
      +if (! x($_SESSION,'authenticated')) {
       	header('X-Account-Management-Status: none');
      +}
       
       /* set up page['htmlhead'] and page['end'] for the modules to use */
       $a->page['htmlhead'] = '';
       $a->page['end'] = '';
       
       
      -if(! x($_SESSION,'sysmsg'))
      +if (! x($_SESSION,'sysmsg')) {
       	$_SESSION['sysmsg'] = array();
      +}
       
      -if(! x($_SESSION,'sysmsg_info'))
      +if (! x($_SESSION,'sysmsg_info')) {
       	$_SESSION['sysmsg_info'] = array();
      +}
       
       /*
        * check_config() is responsible for running update scripts. These automatically
      @@ -177,11 +181,11 @@ if(! x($_SESSION,'sysmsg_info'))
       
       // in install mode, any url loads install module
       // but we need "view" module for stylesheet
      -if($install && $a->module!="view")
      +if ($install && $a->module!="view") {
       	$a->module = 'install';
      -elseif($maintenance && $a->module!="view")
      +} elseif ($maintenance && $a->module!="view") {
       	$a->module = 'maintenance';
      -else {
      +} else {
       	check_url($a);
       	check_db();
       	check_plugins($a);
      @@ -191,8 +195,7 @@ nav_set_selected('nothing');
       
       //Don't populate apps_menu if apps are private
       $privateapps = get_config('config','private_addons');
      -if((local_user()) || (! $privateapps === "1"))
      -{
      +if ((local_user()) || (! $privateapps === "1")) {
       	$arr = array('app_menu' => $a->apps);
       
       	call_hooks('app_menu', $arr);
      @@ -238,9 +241,9 @@ if(strlen($a->module)) {
       
       	$privateapps = get_config('config','private_addons');
       
      -	if(is_array($a->plugins) && in_array($a->module,$a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) {
      +	if (is_array($a->plugins) && in_array($a->module,$a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) {
       		//Check if module is an app and if public access to apps is allowed or not
      -		if((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") {
      +		if ((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") {
       			info( t("You must be logged in to use addons. "));
       		}
       		else {
      @@ -254,7 +257,7 @@ if(strlen($a->module)) {
       	 * If not, next look for a 'standard' program module in the 'mod' directory
       	 */
       
      -	if((! $a->module_loaded) && (file_exists("mod/{$a->module}.php"))) {
      +	if ((! $a->module_loaded) && (file_exists("mod/{$a->module}.php"))) {
       		include_once("mod/{$a->module}.php");
       		$a->module_loaded = true;
       	}
      @@ -272,14 +275,14 @@ if(strlen($a->module)) {
       	 *
       	 */
       
      -	if(! $a->module_loaded) {
      +	if (! $a->module_loaded) {
       
       		// Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit.
      -		if((x($_SERVER,'QUERY_STRING')) && preg_match('/{[0-9]}/',$_SERVER['QUERY_STRING']) !== 0) {
      +		if ((x($_SERVER,'QUERY_STRING')) && preg_match('/{[0-9]}/',$_SERVER['QUERY_STRING']) !== 0) {
       			killme();
       		}
       
      -		if((x($_SERVER,'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
      +		if ((x($_SERVER,'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
       			logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']);
       			goaway(App::get_baseurl() . $_SERVER['REQUEST_URI']);
       		}
      @@ -304,11 +307,13 @@ if (file_exists($theme_info_file)){
       
       /* initialise content region */
       
      -if(! x($a->page,'content'))
      +if (! x($a->page,'content')) {
       	$a->page['content'] = '';
      +}
       
      -if(!$install && !$maintenance)
      +if (!$install && !$maintenance) {
       	call_hooks('page_content_top',$a->page['content']);
      +}
       
       /**
        * Call module functions
      diff --git a/mod/admin.php b/mod/admin.php
      index 040f55a5a6..26d7da26be 100644
      --- a/mod/admin.php
      +++ b/mod/admin.php
      @@ -1129,19 +1129,19 @@ function admin_page_dbsync(App &$a) {
       			$failed[] = $upd;
       		}
       	}
      -	if(! count($failed)) {
      +	if (! count($failed)) {
       		$o = replace_macros(get_markup_template('structure_check.tpl'),array(
      -			'$base' => App::get_baseurl(true),
      +			'$base'   => App::get_baseurl(true),
       			'$banner' => t('No failed updates.'),
      -			'$check' => t('Check database structure'),
      +			'$check'  => t('Check database structure'),
       		));
       	} else {
       		$o = replace_macros(get_markup_template('failed_updates.tpl'),array(
      -			'$base' => App::get_baseurl(true),
      +			'$base'   => App::get_baseurl(true),
       			'$banner' => t('Failed Updates'),
      -			'$desc' => t('This does not include updates prior to 1139, which did not return a status.'),
      -			'$mark' => t('Mark success (if update was manually applied)'),
      -			'$apply' => t('Attempt to execute this update step automatically'),
      +			'$desc'   => t('This does not include updates prior to 1139, which did not return a status.'),
      +			'$mark'   => t('Mark success (if update was manually applied)'),
      +			'$apply'  => t('Attempt to execute this update step automatically'),
       			'$failed' => $failed
       		));
       	}
      @@ -1156,11 +1156,11 @@ function admin_page_dbsync(App &$a) {
        * @param App $a
        */
       function admin_page_users_post(App &$a){
      -	$pending     =	(x($_POST, 'pending')			? $_POST['pending']		: array());
      -	$users       =	(x($_POST, 'user')			? $_POST['user']		: array());
      -	$nu_name     =	(x($_POST, 'new_user_name')		? $_POST['new_user_name']	: '');
      -	$nu_nickname =	(x($_POST, 'new_user_nickname')		? $_POST['new_user_nickname']	: '');
      -	$nu_email    =	(x($_POST, 'new_user_email')		? $_POST['new_user_email']	: '');
      +	$pending     =	(x($_POST, 'pending')           ? $_POST['pending']           : array());
      +	$users       =	(x($_POST, 'user')              ? $_POST['user']		      : array());
      +	$nu_name     =	(x($_POST, 'new_user_name')     ? $_POST['new_user_name']     : '');
      +	$nu_nickname =	(x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : '');
      +	$nu_email    =	(x($_POST, 'new_user_email')    ? $_POST['new_user_email']    : '');
       	$nu_language = get_config('system', 'language');
       
       	check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
      @@ -1546,7 +1546,7 @@ function admin_page_plugins(App &$a){
       	 * List plugins
       	 */
       
      -	if(x($_GET,"a") && $_GET['a']=="r") {
      +	if (x($_GET,"a") && $_GET['a']=="r") {
       		check_form_security_token_redirectOnErr(App::get_baseurl().'/admin/plugins', 'admin_themes', 't');
       		reload_plugins();
       		info("Plugins reloaded");
      @@ -1555,23 +1555,26 @@ function admin_page_plugins(App &$a){
       
       	$plugins = array();
       	$files = glob("addon/*/");
      -	if($files) {
      -		foreach($files as $file) {
      -			if(is_dir($file)) {
      +	if ($files) {
      +		foreach ($files as $file) {
      +			if (is_dir($file)) {
       				list($tmp, $id)=array_map("trim", explode("/",$file));
       				$info = get_plugin_info($id);
       				$show_plugin = true;
       
       				// If the addon is unsupported, then only show it, when it is enabled
      -				if((strtolower($info["status"]) == "unsupported") AND !in_array($id,  $a->plugins))
      +				if ((strtolower($info["status"]) == "unsupported") AND !in_array($id,  $a->plugins)) {
       					$show_plugin = false;
      +				}
       
       				// Override the above szenario, when the admin really wants to see outdated stuff
      -				if(get_config("system", "show_unsupported_addons"))
      +				if (get_config("system", "show_unsupported_addons")) {
       					$show_plugin = true;
      +				}
       
      -				if($show_plugin)
      +				if ($show_plugin) {
       					$plugins[] = array($id, (in_array($id,  $a->plugins)?"on":"off") , $info);
      +				}
       			}
       		}
       	}
      @@ -1798,11 +1801,11 @@ function admin_page_themes(App &$a){
       
       
       	// reload active themes
      -	if(x($_GET,"a") && $_GET['a']=="r") {
      +	if (x($_GET,"a") && $_GET['a']=="r") {
       		check_form_security_token_redirectOnErr(App::get_baseurl().'/admin/themes', 'admin_themes', 't');
      -		if($themes) {
      -			foreach($themes as $th) {
      -				if($th['allowed']) {
      +		if ($themes) {
      +			foreach ($themes as $th) {
      +				if ($th['allowed']) {
       					uninstall_theme($th['name']);
       					install_theme($th['name']);
       				}
      @@ -1817,7 +1820,7 @@ function admin_page_themes(App &$a){
       	 */
       
       	$xthemes = array();
      -	if($themes) {
      +	if ($themes) {
       		foreach($themes as $th) {
       			$xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
       		}
      @@ -1826,17 +1829,17 @@ function admin_page_themes(App &$a){
       
       	$t = get_markup_template("admin_plugins.tpl");
       	return replace_macros($t, array(
      -		'$title' => t('Administration'),
      -		'$page' => t('Themes'),
      -		'$submit' => t('Save Settings'),
      -		'$reload' => t('Reload active themes'),
      -		'$baseurl' => App::get_baseurl(true),
      -		'$function' => 'themes',
      -		'$plugins' => $xthemes,
      -		'$pcount' => count($themes),
      -		'$noplugshint' => sprintf(t('No themes found on the system. They should be paced in %1$s'),'/view/themes'),
      -		'$experimental' => t('[Experimental]'),
      -		'$unsupported' => t('[Unsupported]'),
      +		'$title'               => t('Administration'),
      +		'$page'                => t('Themes'),
      +		'$submit'              => t('Save Settings'),
      +		'$reload'              => t('Reload active themes'),
      +		'$baseurl'             => App::get_baseurl(true),
      +		'$function'            => 'themes',
      +		'$plugins'             => $xthemes,
      +		'$pcount'              => count($themes),
      +		'$noplugshint'         => sprintf(t('No themes found on the system. They should be paced in %1$s'),'/view/themes'),
      +		'$experimental'        => t('[Experimental]'),
      +		'$unsupported'         => t('[Unsupported]'),
       		'$form_security_token' => get_form_security_token("admin_themes"),
       	));
       }
      diff --git a/mod/allfriends.php b/mod/allfriends.php
      index f9cffcbb2d..0682b2dd41 100644
      --- a/mod/allfriends.php
      +++ b/mod/allfriends.php
      @@ -29,8 +29,8 @@ function allfriends_content(App &$a) {
       	);
       
       	if (! count($c)) {
      -	}
       		return;
      +	}
       
       	$a->page['aside'] = "";
       	profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"]));
      diff --git a/mod/cal.php b/mod/cal.php
      index 48ba06ed6c..e6c9c72249 100644
      --- a/mod/cal.php
      +++ b/mod/cal.php
      @@ -231,7 +231,7 @@ function cal_content(App &$a) {
       			$r = sort_by_date($r);
       			foreach($r as $rr) {
       				$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
      -				if(! x($links,$j)) {
      +				if (! x($links,$j)) {
       					$links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;
       				}
       			}
      diff --git a/mod/delegate.php b/mod/delegate.php
      index 8470a7ba0b..1f261bb716 100644
      --- a/mod/delegate.php
      +++ b/mod/delegate.php
      @@ -13,7 +13,7 @@ function delegate_content(App &$a) {
       		return;
       	}
       
      -	if($a->argc > 2 && $a->argv[1] === 'add' && intval($a->argv[2])) {
      +	if ($a->argc > 2 && $a->argv[1] === 'add' && intval($a->argv[2])) {
       
       		// delegated admins can view but not change delegation permissions
       
      @@ -42,7 +42,7 @@ function delegate_content(App &$a) {
       		goaway(App::get_baseurl() . '/delegate');
       	}
       
      -	if($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) {
      +	if ($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) {
       
       		// delegated admins can view but not change delegation permissions
       
      diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php
      index ba8e27431f..22d4c15358 100644
      --- a/mod/dfrn_confirm.php
      +++ b/mod/dfrn_confirm.php
      @@ -506,10 +506,11 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
       		// Let's send our user to the contact editor in case they want to
       		// do anything special with this new friend.
       
      -		if($handsfree === null)
      +		if ($handsfree === null) {
       			goaway(App::get_baseurl() . '/contacts/' . intval($contact_id));
      -		else
      +		} else {
       			return;
      +		}
       		//NOTREACHED
       	}
       
      @@ -525,7 +526,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
       	 *
       	 */
       
      -	if(x($_POST,'source_url')) {
      +	if (x($_POST,'source_url')) {
       
       		// We are processing an external confirmation to an introduction created by our user.
       
      @@ -546,7 +547,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
       
       		// If $aes_key is set, both of these items require unpacking from the hex transport encoding.
       
      -		if(x($aes_key)) {
      +		if (x($aes_key)) {
       			$aes_key = hex2bin($aes_key);
       			$public_key = hex2bin($public_key);
       		}
      diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php
      index d5e8abe906..3a5711d0f7 100644
      --- a/mod/dfrn_request.php
      +++ b/mod/dfrn_request.php
      @@ -120,17 +120,19 @@ function dfrn_request_post(App &$a) {
       
       					$parms = Probe::profile($dfrn_url);
       
      -					if(! count($parms)) {
      +					if (! count($parms)) {
       						notice( t('Profile location is not valid or does not contain profile information.') . EOL );
       						return;
       					}
       					else {
      -						if(! x($parms,'fn'))
      +						if (! x($parms,'fn')) {
       							notice( t('Warning: profile location has no identifiable owner name.') . EOL );
      -						if(! x($parms,'photo'))
      +						}
      +						if (! x($parms,'photo')) {
       							notice( t('Warning: profile location has no profile photo.') . EOL );
      +						}
       						$invalid = Probe::valid_dfrn($parms);
      -						if($invalid) {
      +						if ($invalid) {
       							notice( sprintf( tt("%d required parameter was not found at the given location",
       												"%d required parameters were not found at the given location",
       												$invalid), $invalid) . EOL );
      @@ -502,13 +504,13 @@ function dfrn_request_post(App &$a) {
       				);
       			}
       			else {
      -				if(! validate_url($url)) {
      +				if (! validate_url($url)) {
       					notice( t('Invalid profile URL.') . EOL);
       					goaway(App::get_baseurl() . '/' . $a->cmd);
       					return; // NOTREACHED
       				}
       
      -				if(! allowed_url($url)) {
      +				if (! allowed_url($url)) {
       					notice( t('Disallowed profile URL.') . EOL);
       					goaway(App::get_baseurl() . '/' . $a->cmd);
       					return; // NOTREACHED
      @@ -519,17 +521,19 @@ function dfrn_request_post(App &$a) {
       
       				$parms = Probe::profile(($hcard) ? $hcard : $url);
       
      -				if(! count($parms)) {
      +				if (! count($parms)) {
       					notice( t('Profile location is not valid or does not contain profile information.') . EOL );
       					goaway(App::get_baseurl() . '/' . $a->cmd);
       				}
       				else {
      -					if(! x($parms,'fn'))
      +					if (! x($parms,'fn')) {
       						notice( t('Warning: profile location has no identifiable owner name.') . EOL );
      -					if(! x($parms,'photo'))
      +					}
      +					if (! x($parms,'photo')) {
       						notice( t('Warning: profile location has no profile photo.') . EOL );
      +					}
       					$invalid = Probe::valid_dfrn($parms);
      -					if($invalid) {
      +					if ($invalid) {
       						notice( sprintf( tt("%d required parameter was not found at the given location",
       											"%d required parameters were not found at the given location",
       											$invalid), $invalid) . EOL );
      @@ -810,15 +814,18 @@ function dfrn_request_content(App &$a) {
       			$myaddr = hex2bin($_GET['addr']);
       		elseif (x($_GET,'address') AND ($_GET['address'] != ""))
       			$myaddr = $_GET['address'];
      -		elseif(local_user()) {
      -			if(strlen($a->path)) {
      +		elseif (local_user()) {
      +			if (strlen($a->path)) {
       				$myaddr = App::get_baseurl() . '/profile/' . $a->user['nickname'];
       			}
       			else {
       				$myaddr = $a->user['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 );
       			}
      -		} else	// last, try a zrl
      +		}
      +		else {
      +			// last, try a zrl
       			$myaddr = get_my_url();
      +		}
       
       		$target_addr = $a->profile['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 );
       
      @@ -831,10 +838,12 @@ function dfrn_request_content(App &$a) {
       		 *
       		 */
       
      -		if($a->profile['page-flags'] == PAGE_NORMAL)
      +		if ($a->profile['page-flags'] == PAGE_NORMAL) {
       			$tpl = get_markup_template('dfrn_request.tpl');
      -		else
      +		}
      +		else {
       			$tpl = get_markup_template('auto_request.tpl');
      +		}
       
       		$page_desc = t("Please enter your 'Identity Address' from one of the following supported communications networks:");
       
      diff --git a/mod/dirfind.php b/mod/dirfind.php
      index fc5750f2dd..2b2badb640 100644
      --- a/mod/dirfind.php
      +++ b/mod/dirfind.php
      @@ -12,8 +12,9 @@ function dirfind_init(App &$a) {
       		return;
       	}
       
      -	if(! x($a->page,'aside'))
      +	if (! x($a->page,'aside')) {
       		$a->page['aside'] = '';
      +	}
       
       	$a->page['aside'] .= findpeople_widget();
       
      @@ -31,7 +32,7 @@ function dirfind_content(&$a, $prefix = "") {
       
       	$search = $prefix.notags(trim($_REQUEST['search']));
       
      -	if(strpos($search,'@') === 0) {
      +	if (strpos($search,'@') === 0) {
       		$search = substr($search,1);
       		$header = sprintf( t('People Search - %s'), $search);
       		if ((valid_email($search) AND validate_email($search)) OR
      @@ -41,7 +42,7 @@ function dirfind_content(&$a, $prefix = "") {
       		}
       	}
       
      -	if(strpos($search,'!') === 0) {
      +	if (strpos($search,'!') === 0) {
       		$search = substr($search,1);
       		$community = true;
       		$header = sprintf( t('Forum Search - %s'), $search);
      @@ -49,7 +50,7 @@ function dirfind_content(&$a, $prefix = "") {
       
       	$o = '';
       
      -	if($search) {
      +	if ($search) {
       
       		if ($discover_user) {
       			$j = new stdClass();
      @@ -85,15 +86,19 @@ function dirfind_content(&$a, $prefix = "") {
       			$perpage = 80;
       			$startrec = (($a->pager['page']) * $perpage) - $perpage;
       
      -			if (get_config('system','diaspora_enabled'))
      +			if (get_config('system','diaspora_enabled')) {
       				$diaspora = NETWORK_DIASPORA;
      -			else
      +			}
      +			else {
       				$diaspora = NETWORK_DFRN;
      +			}
       
      -			if (!get_config('system','ostatus_disabled'))
      +			if (!get_config('system','ostatus_disabled')) {
       				$ostatus = NETWORK_OSTATUS;
      -			else
      +			}
      +			else {
       				$ostatus = NETWORK_DFRN;
      +			}
       
       			$search2 = "%".$search."%";
       
      @@ -133,8 +138,9 @@ function dirfind_content(&$a, $prefix = "") {
       			$j->items_page = $perpage;
       			$j->page = $a->pager['page'];
       			foreach ($results AS $result) {
      -				if (poco_alternate_ostatus_url($result["url"]))
      -					 continue;
      +				if (poco_alternate_ostatus_url($result["url"])) {
      +					continue;
      +				}
       
       				$result = get_contact_details_by_url($result["url"], local_user(), $result);
       
      @@ -167,16 +173,16 @@ function dirfind_content(&$a, $prefix = "") {
       			$j = json_decode($x);
       		}
       
      -		if($j->total) {
      +		if ($j->total) {
       			$a->set_pager_total($j->total);
       			$a->set_pager_itemspage($j->items_page);
       		}
       
      -		if(count($j->results)) {
      +		if (count($j->results)) {
       
       			$id = 0;
       
      -			foreach($j->results as $jj) {
      +			foreach ($j->results as $jj) {
       
       				$alt_text = "";
       
      @@ -194,8 +200,10 @@ function dirfind_content(&$a, $prefix = "") {
       						$photo_menu = contact_photo_menu($contact[0]);
       						$details = _contact_detail_for_template($contact[0]);
       						$alt_text = $details['alt_text'];
      -					} else
      +					}
      +					else {
       						$photo_menu = array();
      +					}
       				} else {
       					$connlnk = App::get_baseurl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url);
       					$conntxt = t('Connect');
      diff --git a/mod/events.php b/mod/events.php
      index 0c1e9ae2f5..6bf7da6a28 100644
      --- a/mod/events.php
      +++ b/mod/events.php
      @@ -254,15 +254,15 @@ function events_content(App &$a) {
       	$ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0);
       
       	if($a->argc > 1) {
      -		if($a->argc > 2 && $a->argv[1] == 'event') {
      +		if ($a->argc > 2 && $a->argv[1] == 'event') {
       			$mode = 'edit';
       			$event_id = intval($a->argv[2]);
       		}
      -		if($a->argv[1] === 'new') {
      +		if ($a->argv[1] === 'new') {
       			$mode = 'new';
       			$event_id = 0;
       		}
      -		if($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
      +		if ($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
       			$mode = 'view';
       			$y = intval($a->argv[1]);
       			$m = intval($a->argv[2]);
      @@ -270,23 +270,27 @@ function events_content(App &$a) {
       	}
       
       	// The view mode part is similiar to /mod/cal.php
      -	if($mode == 'view') {
      +	if ($mode == 'view') {
       
       
       		$thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
       		$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
      -		if(! $y)
      +		if (! $y) {
       			$y = intval($thisyear);
      -		if(! $m)
      +		}
      +		if (! $m) {
       			$m = intval($thismonth);
      +		}
       
       		// Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
       		// An upper limit was chosen to keep search engines from exploring links millions of years in the future.
       
      -		if($y < 1901)
      +		if ($y < 1901) {
       			$y = 1900;
      -		if($y > 2099)
      +		}
      +		if ($y > 2099) {
       			$y = 2100;
      +		}
       
       		$nextyear = $y;
       		$nextmonth = $m + 1;
      @@ -342,7 +346,7 @@ function events_content(App &$a) {
       			$r = sort_by_date($r);
       			foreach($r as $rr) {
       				$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
      -				if(! x($links,$j)) {
      +				if (! x($links,$j)) {
       					$links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;
       				}
       			}
      diff --git a/mod/settings.php b/mod/settings.php
      index 9aa7c57624..515a97c14d 100644
      --- a/mod/settings.php
      +++ b/mod/settings.php
      @@ -1170,13 +1170,14 @@ function settings_content(App &$a) {
       		));
       	}
       
      -	if(strlen(get_config('system','directory'))) {
      +	if (strlen(get_config('system','directory'))) {
       		$profile_in_net_dir = replace_macros($opt_tpl,array(
       			'$field' 	=> array('profile_in_netdirectory', t('Publish your default profile in the global social directory?'), $profile['net-publish'], '', array(t('No'),t('Yes'))),
       		));
       	}
      -	else
      +	else {
       		$profile_in_net_dir = '';
      +	}
       
       
       	$hide_friends = replace_macros($opt_tpl,array(
      
      From af2909bf8fa971c222bb7b0fca2ccb373c570988 Mon Sep 17 00:00:00 2001
      From: Roland Haeder 
      Date: Tue, 20 Dec 2016 21:13:50 +0100
      Subject: [PATCH 47/96] 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 
      ---
       include/acl_selectors.php     | 22 ++++++++++++--------
       include/api.php               |  4 ++--
       include/bbcode.php            |  2 +-
       include/contact_selectors.php |  2 +-
       include/contact_widgets.php   |  8 ++++---
       include/conversation.php      |  2 +-
       include/datetime.php          |  2 +-
       include/diaspora.php          | 14 ++++++-------
       include/expire.php            |  2 +-
       include/group.php             |  6 +++---
       include/identity.php          |  6 +++---
       include/message.php           | 39 +++++++++++++++++++----------------
       include/notifier.php          |  4 ++--
       include/plugin.php            |  3 ++-
       include/pubsubpublish.php     | 14 ++++++++-----
       include/queue.php             | 13 ++++++------
       include/text.php              |  4 ++--
       include/user.php              |  2 +-
       18 files changed, 82 insertions(+), 67 deletions(-)
      
      diff --git a/include/acl_selectors.php b/include/acl_selectors.php
      index c1edc8cc03..b2e66c98f0 100644
      --- a/include/acl_selectors.php
      +++ b/include/acl_selectors.php
      @@ -34,7 +34,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
       	call_hooks($a->module . '_pre_' . $selname, $arr);
       
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			if((is_array($preselected)) && in_array($rr['id'], $preselected))
       				$selected = " selected=\"selected\" ";
       			else
      @@ -145,7 +145,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
       	call_hooks($a->module . '_pre_' . $selname, $arr);
       
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			if((is_array($preselected)) && in_array($rr['id'], $preselected))
       				$selected = " selected=\"selected\" ";
       			else
      @@ -221,16 +221,20 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
       	$receiverlist = array();
       
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      -			if((is_array($preselected)) && in_array($rr['id'], $preselected))
      +		foreach ($r as $rr) {
      +			if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
       				$selected = " selected=\"selected\" ";
      -			else
      +			}
      +			else {
       				$selected = '';
      +			}
       
      -			if($privmail)
      +			if ($privmail) {
       				$trimmed = GetProfileUsername($rr['url'], $rr['name'], false);
      -			else
      +			}
      +			else {
       				$trimmed = mb_substr($rr['name'],0,20);
      +			}
       
       			$receiverlist[] = $trimmed;
       
      @@ -260,7 +264,7 @@ function prune_deadguys($arr) {
       		return $arr;
       	$str = dbesc(implode(',',$arr));
       	$r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 ");
      -	if($r) {
      +	if ($r) {
       		$ret = array();
       		foreach($r as $rr)
       			$ret[] = intval($rr['id']);
      @@ -554,7 +558,7 @@ function acl_lookup(&$a, $out_type = 'json') {
       		// autocomplete for global contact search (e.g. navbar search)
       		$r = navbar_complete($a);
       		$contacts = array();
      -		if($r) {
      +		if ($r) {
       			foreach($r as $g) {
       				$contacts[] = array(
       					"photo"    => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
      diff --git a/include/api.php b/include/api.php
      index a450f867a5..35efccf090 100644
      --- a/include/api.php
      +++ b/include/api.php
      @@ -3068,8 +3068,8 @@
       		'image/gif' => 'gif'
       		);
       		$data = array('photo'=>array());
      -		if($r) {
      -			foreach($r as $rr) {
      +		if ($r) {
      +			foreach ($r as $rr) {
       				$photo = array();
       				$photo['id'] = $rr['resource-id'];
       				$photo['album'] = $rr['album'];
      diff --git a/include/bbcode.php b/include/bbcode.php
      index c05173f47c..74dde2fdf4 100644
      --- a/include/bbcode.php
      +++ b/include/bbcode.php
      @@ -343,7 +343,7 @@ function bb_replace_images($body, $images) {
       	$newbody = $body;
       
       	$cnt = 0;
      -	foreach($images as $image) {
      +	foreach ($images as $image) {
       		// We're depending on the property of 'foreach' (specified on the PHP website) that
       		// it loops over the array starting from the first element and going sequentially
       		// to the last element
      diff --git a/include/contact_selectors.php b/include/contact_selectors.php
      index 0790e503ea..ec9dff61d5 100644
      --- a/include/contact_selectors.php
      +++ b/include/contact_selectors.php
      @@ -13,7 +13,7 @@ function contact_profile_assign($current,$foreign_net) {
       			intval($_SESSION['uid']));
       
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$selected = (($rr['id'] == $current) ? " selected=\"selected\" " : "");
       			$o .= "\r\n";
       		}
      diff --git a/include/contact_widgets.php b/include/contact_widgets.php
      index 71a75d431e..36675da873 100644
      --- a/include/contact_widgets.php
      +++ b/include/contact_widgets.php
      @@ -97,9 +97,11 @@ function networks_widget($baseurl,$selected = '') {
       	$nets = array();
       	if (dbm::is_result($r)) {
       		require_once('include/contact_selectors.php');
      -		foreach($r as $rr) {
      -				if($rr['network'])
      -					$nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
      +		foreach ($r as $rr) {
      +			/// @TODO If 'network' is not there, this triggers an E_NOTICE
      +			if ($rr['network']) {
      +				$nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
      +			}
       		}
       	}
       
      diff --git a/include/conversation.php b/include/conversation.php
      index ccfc070d4e..36eded8e8a 100644
      --- a/include/conversation.php
      +++ b/include/conversation.php
      @@ -78,7 +78,7 @@ function item_redir_and_replace_images($body, $images, $cid) {
       	$newbody .= $origbody;
       
       	$cnt = 0;
      -	foreach($images as $image) {
      +	foreach ($images as $image) {
       		// We're depending on the property of 'foreach' (specified on the PHP website) that
       		// it loops over the array starting from the first element and going sequentially
       		// to the last element
      diff --git a/include/datetime.php b/include/datetime.php
      index e88c274ab9..a17c405dc3 100644
      --- a/include/datetime.php
      +++ b/include/datetime.php
      @@ -553,7 +553,7 @@ function update_contact_birthdays() {
       
       	$r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` != '0000-00-00' AND SUBSTRING(`bd`,1,4) != `bdyear` ");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       
       			logger('update_contact_birthday: ' . $rr['bd']);
       
      diff --git a/include/diaspora.php b/include/diaspora.php
      index 3b4832e74f..cfb624fdf2 100644
      --- a/include/diaspora.php
      +++ b/include/diaspora.php
      @@ -319,8 +319,8 @@ class diaspora {
       			dbesc(NETWORK_DIASPORA),
       			dbesc($msg["author"])
       		);
      -		if($r) {
      -			foreach($r as $rr) {
      +		if ($r) {
      +			foreach ($r as $rr) {
       				logger("delivering to: ".$rr["username"]);
       				self::dispatch($rr,$msg);
       			}
      @@ -806,7 +806,7 @@ class diaspora {
       			dbesc($guid)
       		);
       
      -		if($r) {
      +		if ($r) {
       			logger("message ".$guid." already exists for user ".$uid);
       			return $r[0]["id"];
       		}
      @@ -1577,7 +1577,7 @@ class diaspora {
       			dbesc($message_uri),
       			intval($importer["uid"])
       		);
      -		if($r) {
      +		if ($r) {
       			logger("duplicate message already delivered.", LOGGER_DEBUG);
       			return false;
       		}
      @@ -2022,7 +2022,7 @@ class diaspora {
       				FROM `item` WHERE `guid` = '%s' AND `visible` AND NOT `deleted` AND `body` != '' LIMIT 1",
       			dbesc($guid));
       
      -		if($r) {
      +		if ($r) {
       			logger("reshared message ".$guid." already exists on system.");
       
       			// Maybe it is already a reshared item?
      @@ -2623,7 +2623,7 @@ class diaspora {
       
       		logger("transmit: ".$logid."-".$guid." returns: ".$return_code);
       
      -		if(!$return_code || (($return_code == 503) && (stristr($a->get_curl_headers(), "retry-after")))) {
      +		if (!$return_code || (($return_code == 503) && (stristr($a->get_curl_headers(), "retry-after")))) {
       			logger("queue message");
       
       			$r = q("SELECT `id` FROM `queue` WHERE `cid` = %d AND `network` = '%s' AND `content` = '%s' AND `batch` = %d LIMIT 1",
      @@ -2632,7 +2632,7 @@ class diaspora {
       				dbesc($slap),
       				intval($public_batch)
       			);
      -			if($r) {
      +			if ($r) {
       				logger("add_to_queue ignored - identical item already in queue");
       			} else {
       				// queue message for redelivery
      diff --git a/include/expire.php b/include/expire.php
      index eca2b1c42a..e3313a78be 100644
      --- a/include/expire.php
      +++ b/include/expire.php
      @@ -40,7 +40,7 @@ function expire_run(&$argv, &$argc){
       
       	$r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
       			item_expire($rr['uid'],$rr['expire']);
       		}
      diff --git a/include/group.php b/include/group.php
      index a2a55c4440..6332c45da2 100644
      --- a/include/group.php
      +++ b/include/group.php
      @@ -53,7 +53,7 @@ function group_rmv($uid,$name) {
       		$r = q("SELECT def_gid, allow_gid, deny_gid FROM user WHERE uid = %d LIMIT 1",
       		       intval($uid)
       		);
      -		if($r) {
      +		if ($r) {
       			$user_info = $r[0];
       			$change = false;
       
      @@ -199,7 +199,7 @@ function mini_group_select($uid,$gid = 0, $label = "") {
       	);
       	$grps[] = array('name' => '', 'id' => '0', 'selected' => '');
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$grps[] = array('name' => $rr['name'], 'id' => $rr['id'], 'selected' => (($gid == $rr['id']) ? 'true' : ''));
       		}
       
      @@ -257,7 +257,7 @@ function group_side($every="contacts",$each="group",$editmode = "standard", $gro
       	}
       
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$selected = (($group_id == $rr['id']) ? ' group-selected' : '');
       
       			if ($editmode == "full") {
      diff --git a/include/identity.php b/include/identity.php
      index 380560228a..35516efbea 100644
      --- a/include/identity.php
      +++ b/include/identity.php
      @@ -294,7 +294,7 @@ function profile_sidebar($profile, $block = 0) {
       
       		if (dbm::is_result($r)) {
       
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				$profile['menu']['entries'][] = array(
       					'photo' => $rr['thumb'],
       					'id' => $rr['id'],
      @@ -469,7 +469,7 @@ function get_birthdays() {
       		$cids = array();
       
       		$istoday = false;
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			if(strlen($rr['name']))
       				$total ++;
       			if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now))
      @@ -549,7 +549,7 @@ function get_events() {
       	if (dbm::is_result($r)) {
       		$now = strtotime('now');
       		$istoday = false;
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			if(strlen($rr['name']))
       				$total ++;
       
      diff --git a/include/message.php b/include/message.php
      index e5ebe6f915..5bd611f220 100644
      --- a/include/message.php
      +++ b/include/message.php
      @@ -130,12 +130,13 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
       
       	$match = null;
       
      -	if(preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) {
      +	if (preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) {
       		$images = $match[1];
      -		if(count($images)) {
      -			foreach($images as $image) {
      -				if(! stristr($image,App::get_baseurl() . '/photo/'))
      +		if (count($images)) {
      +			foreach ($images as $image) {
      +				if (! stristr($image,App::get_baseurl() . '/photo/')) {
       					continue;
      +				}
       				$image_uri = substr($image,strrpos($image,'/') + 1);
       				$image_uri = substr($image_uri,0, strpos($image_uri,'-'));
       				$r = q("UPDATE `photo` SET `allow_cid` = '%s'
      @@ -149,25 +150,25 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
       		}
       	}
       
      -	if($post_id) {
      +	if ($post_id) {
       		proc_run(PRIORITY_HIGH, "include/notifier.php", "mail", $post_id);
       		return intval($post_id);
      -	} else {
      +	}
      +	else {
       		return -3;
       	}
       
       }
       
      -
      -
      -
      -
       function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
       
      -	if(! $recipient) return -1;
      +	if (! $recipient) {
      +		return -1;
      +	}
       
      -	if(! strlen($subject))
      +	if (! strlen($subject)) {
       		$subject = t('[no subject]');
      +	}
       
       	$guid = get_guid(32);
        	$uri = 'urn:X-dfrn:' . App::get_baseurl() . ':' . local_user() . ':' . $guid;
      @@ -179,8 +180,9 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
       
       	$me = probe_url($replyto);
       
      -	if(! $me['name'])
      +	if (! $me['name']) {
       		return -2;
      +	}
       
       	$conv_guid = get_guid(32);
       
      @@ -193,7 +195,7 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
       
       	$handles = $recip_handle . ';' . $sender_handle;
       
      -	$r = q("insert into conv (uid,guid,creator,created,updated,subject,recips) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ",
      +	$r = q("INSERT INTO `conv` (`uid`,`guid`,`creator`,`created`,`updated`,`subject`,`recips`) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ",
       		intval($recipient['uid']),
       		dbesc($conv_guid),
       		dbesc($sender_handle),
      @@ -203,18 +205,19 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
       		dbesc($handles)
       	);
       
      -	$r = q("select * from conv where guid = '%s' and uid = %d limit 1",
      +	$r = q("SELECT * FROM `conv` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
       		dbesc($conv_guid),
       		intval($recipient['uid'])
       	);
      -	if (dbm::is_result($r))
      -		$convid = $r[0]['id'];
       
      -	if(! $convid) {
      +
      +	if (! dbm::is_result($r)) {
       		logger('send message: conversation not found.');
       		return -4;
       	}
       
      +	$convid = $r[0]['id'];
      +
       	$r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`,
       		`contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`, `unknown`)
       		VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s', %d )",
      diff --git a/include/notifier.php b/include/notifier.php
      index d78db4055d..72387c98db 100644
      --- a/include/notifier.php
      +++ b/include/notifier.php
      @@ -598,7 +598,7 @@ function notifier_run(&$argv, &$argc){
       
       			// throw everything into the queue in case we get killed
       
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				if((! $mail) && (! $fsuggest) && (! $followup)) {
       					q("INSERT INTO `deliverq` (`cmd`,`item`,`contact`) VALUES ('%s', %d, %d)
       						ON DUPLICATE KEY UPDATE `cmd` = '%s', `item` = %d, `contact` = %d",
      @@ -608,7 +608,7 @@ function notifier_run(&$argv, &$argc){
       				}
       			}
       
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       
       				// except for Diaspora batch jobs
       				// Don't deliver to folks who have already been delivered to
      diff --git a/include/plugin.php b/include/plugin.php
      index 89c783f900..0b9c0166aa 100644
      --- a/include/plugin.php
      +++ b/include/plugin.php
      @@ -187,8 +187,9 @@ function load_hooks() {
       	$a = get_app();
       	$a->hooks = array();
       	$r = q("SELECT * FROM `hook` WHERE 1 ORDER BY `priority` DESC, `file`");
      +
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			if(! array_key_exists($rr['hook'],$a->hooks))
       				$a->hooks[$rr['hook']] = array();
       			$a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
      diff --git a/include/pubsubpublish.php b/include/pubsubpublish.php
      index abf973a284..6bd90bfc21 100644
      --- a/include/pubsubpublish.php
      +++ b/include/pubsubpublish.php
      @@ -76,16 +76,19 @@ function pubsubpublish_run(&$argv, &$argc){
       	load_config('system');
       
       	// Don't check this stuff if the function is called by the poller
      -	if (App::callstack() != "poller_run")
      -		if (App::is_already_running("pubsubpublish", "include/pubsubpublish.php", 540))
      +	if (App::callstack() != "poller_run") {
      +		if (App::is_already_running("pubsubpublish", "include/pubsubpublish.php", 540)) {
       			return;
      +		}
      +	}
       
       	$a->set_baseurl(get_config('system','url'));
       
       	load_hooks();
       
      -	if($argc > 1)
      +	if ($argc > 1) {
       		$pubsubpublish_id = intval($argv[1]);
      +	}
       	else {
       		// We'll push to each subscriber that has push > 0,
       		// i.e. there has been an update (set in notifier.php).
      @@ -95,10 +98,11 @@ function pubsubpublish_run(&$argv, &$argc){
       		$interval = Config::get("system", "delivery_interval", 2);
       
       		// If we are using the worker we don't need a delivery interval
      -		if (get_config("system", "worker"))
      +		if (get_config("system", "worker")) {
       			$interval = false;
      +		}
       
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			logger("Publish feed to ".$rr["callback_url"], LOGGER_DEBUG);
       			proc_run(PRIORITY_HIGH, 'include/pubsubpublish.php', $rr["id"]);
       
      diff --git a/include/queue.php b/include/queue.php
      index 1cc2ee095b..2ef97fecd4 100644
      --- a/include/queue.php
      +++ b/include/queue.php
      @@ -58,20 +58,21 @@ function queue_run(&$argv, &$argc){
       			$interval = false;
       
       		$r = q("select * from deliverq where 1");
      -		if($r) {
      -			foreach($r as $rr) {
      +		if ($r) {
      +			foreach ($r as $rr) {
       				logger('queue: deliverq');
       				proc_run(PRIORITY_HIGH,'include/delivery.php',$rr['cmd'],$rr['item'],$rr['contact']);
      -				if($interval)
      -				@time_sleep_until(microtime(true) + (float) $interval);
      +				if($interval) {
      +					time_sleep_until(microtime(true) + (float) $interval);
      +				}
       			}
       		}
       
       		$r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`
       			INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
       			WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
      -		if($r) {
      -			foreach($r as $rr) {
      +		if ($r) {
      +			foreach ($r as $rr) {
       				logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']);
       				logger('Expired queue data :' . $rr['content'], LOGGER_DATA);
       			}
      diff --git a/include/text.php b/include/text.php
      index 8d3b6a8050..6672b0d32f 100644
      --- a/include/text.php
      +++ b/include/text.php
      @@ -912,7 +912,7 @@ function contact_block() {
       			if (dbm::is_result($r)) {
       				$contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
       				$micropro = Array();
      -				foreach($r as $rr) {
      +				foreach ($r as $rr) {
       					$micropro[] = micropro($rr,true,'mpfriend');
       				}
       			}
      @@ -1717,7 +1717,7 @@ function bb_translate_video($s) {
       
       	$matches = null;
       	$r = preg_match_all("/\[video\](.*?)\[\/video\]/ism",$s,$matches,PREG_SET_ORDER);
      -	if($r) {
      +	if ($r) {
       		foreach($matches as $mtch) {
       			if((stristr($mtch[1],'youtube')) || (stristr($mtch[1],'youtu.be')))
       				$s = str_replace($mtch[0],'[youtube]' . $mtch[1] . '[/youtube]',$s);
      diff --git a/include/user.php b/include/user.php
      index d6970d475f..df871c5468 100644
      --- a/include/user.php
      +++ b/include/user.php
      @@ -216,7 +216,7 @@ function create_user($arr) {
       		dbesc($default_service_class)
       	);
       
      -	if($r) {
      +	if ($r) {
       		$r = q("SELECT * FROM `user`
       			WHERE `username` = '%s' AND `password` = '%s' LIMIT 1",
       			dbesc($username),
      
      From 6e44acfed6b029818ad094771919184c485f9c16 Mon Sep 17 00:00:00 2001
      From: Roland Haeder 
      Date: Tue, 20 Dec 2016 21:15:53 +0100
      Subject: [PATCH 48/96] 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 
      ---
       mod/admin.php         |  2 +-
       mod/allfriends.php    |  2 +-
       mod/cal.php           |  2 +-
       mod/common.php        |  2 +-
       mod/contacts.php      | 28 +++++++++++++++++-----------
       mod/delegate.php      |  2 +-
       mod/dfrn_request.php  |  6 +++---
       mod/directory.php     |  8 +++++---
       mod/events.php        |  2 +-
       mod/filerm.php        |  9 ++++++---
       mod/follow.php        | 15 ++++++++++-----
       mod/group.php         |  2 +-
       mod/hcard.php         | 23 +++++++++++++----------
       mod/install.php       | 13 ++++++++-----
       mod/invite.php        | 16 +++++++++-------
       mod/item.php          | 32 +++++++++++++++++++-------------
       mod/lostpass.php      |  2 +-
       mod/message.php       |  4 ++--
       mod/network.php       | 20 ++++++++++----------
       mod/nogroup.php       |  2 +-
       mod/noscrape.php      | 28 +++++++++++++++-------------
       mod/openid.php        | 36 +++++++++++++++++++++++-------------
       mod/photos.php        |  4 ++--
       mod/poco.php          |  2 +-
       mod/profile.php       |  2 +-
       mod/profile_photo.php |  2 +-
       mod/profiles.php      | 20 +++++++++++---------
       mod/search.php        |  2 +-
       mod/suggest.php       |  2 +-
       mod/videos.php        |  4 ++--
       mod/viewcontacts.php  |  6 ++++--
       31 files changed, 173 insertions(+), 127 deletions(-)
      
      diff --git a/mod/admin.php b/mod/admin.php
      index 26d7da26be..c502e36fc5 100644
      --- a/mod/admin.php
      +++ b/mod/admin.php
      @@ -1122,7 +1122,7 @@ function admin_page_dbsync(App &$a) {
       	$failed = array();
       	$r = q("SELECT `k`, `v` FROM `config` WHERE `cat` = 'database' ");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$upd = intval(substr($rr['k'],7));
       			if($upd < 1139 || $rr['v'] === 'success')
       				continue;
      diff --git a/mod/allfriends.php b/mod/allfriends.php
      index 0682b2dd41..9e14a67d2e 100644
      --- a/mod/allfriends.php
      +++ b/mod/allfriends.php
      @@ -49,7 +49,7 @@ function allfriends_content(App &$a) {
       
       	$id = 0;
       
      -	foreach($r as $rr) {
      +	foreach ($r as $rr) {
       
       		//get further details of the contact
       		$contact_details = get_contact_details_by_url($rr['url'], $uid, $rr);
      diff --git a/mod/cal.php b/mod/cal.php
      index e6c9c72249..7cb36e7a54 100644
      --- a/mod/cal.php
      +++ b/mod/cal.php
      @@ -229,7 +229,7 @@ function cal_content(App &$a) {
       
       		if (dbm::is_result($r)) {
       			$r = sort_by_date($r);
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
       				if (! x($links,$j)) {
       					$links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;
      diff --git a/mod/common.php b/mod/common.php
      index f3601c0fe6..ab27dc667a 100644
      --- a/mod/common.php
      +++ b/mod/common.php
      @@ -101,7 +101,7 @@ function common_content(App &$a) {
       
       	$id = 0;
       
      -	foreach($r as $rr) {
      +	foreach ($r as $rr) {
       
       		//get further details of the contact
       		$contact_details = get_contact_details_by_url($rr['url'], $uid);
      diff --git a/mod/contacts.php b/mod/contacts.php
      index 4f634bbc1c..f709f9d2fb 100644
      --- a/mod/contacts.php
      +++ b/mod/contacts.php
      @@ -129,10 +129,12 @@ function contacts_batch_actions(App &$a){
       		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']);
      -	else
      +	}
      +	else {
       		goaway('contacts');
      +	}
       
       }
       
      @@ -387,7 +389,7 @@ function contacts_content(App &$a) {
       
       		if($cmd === 'block') {
       			$r = _contact_block($contact_id, $orig_record[0]);
      -			if($r) {
      +			if ($r) {
       				$blocked = (($orig_record[0]['blocked']) ? 0 : 1);
       				info((($blocked) ? t('Contact has been blocked') : t('Contact has been unblocked')).EOL);
       			}
      @@ -398,7 +400,7 @@ function contacts_content(App &$a) {
       
       		if($cmd === 'ignore') {
       			$r = _contact_ignore($contact_id, $orig_record[0]);
      -			if($r) {
      +			if ($r) {
       				$readonly = (($orig_record[0]['readonly']) ? 0 : 1);
       				info((($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')).EOL);
       			}
      @@ -410,7 +412,7 @@ function contacts_content(App &$a) {
       
       		if($cmd === 'archive') {
       			$r = _contact_archive($contact_id, $orig_record[0]);
      -			if($r) {
      +			if ($r) {
       				$archived = (($orig_record[0]['archive']) ? 0 : 1);
       				info((($archived) ? t('Contact has been archived') : t('Contact has been unarchived')).EOL);
       			}
      @@ -449,22 +451,26 @@ function contacts_content(App &$a) {
       				));
       			}
       			// Now check how the user responded to the confirmation query
      -			if($_REQUEST['canceled']) {
      -				if(x($_SESSION,'return_url'))
      +			if ($_REQUEST['canceled']) {
      +				if (x($_SESSION,'return_url')) {
       					goaway('' . $_SESSION['return_url']);
      -				else
      +				}
      +				else {
       					goaway('contacts');
      +				}
       			}
       
       			_contact_drop($contact_id, $orig_record[0]);
       			info( t('Contact has been removed.') . EOL );
      -			if(x($_SESSION,'return_url'))
      +			if (x($_SESSION,'return_url')) {
       				goaway('' . $_SESSION['return_url']);
      -			else
      +			}
      +			else {
       				goaway('contacts');
      +			}
       			return; // NOTREACHED
       		}
      -		if($cmd === 'posts') {
      +		if ($cmd === 'posts') {
       			return contact_posts($a, $contact_id);
       		}
       	}
      diff --git a/mod/delegate.php b/mod/delegate.php
      index 1f261bb716..40618eb324 100644
      --- a/mod/delegate.php
      +++ b/mod/delegate.php
      @@ -107,7 +107,7 @@ function delegate_content(App &$a) {
       	$nicknames = array();
       
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$nicknames[] = "'" . dbesc(basename($rr['nurl'])) . "'";
       		}
       	}
      diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php
      index 3a5711d0f7..b9c1b67446 100644
      --- a/mod/dfrn_request.php
      +++ b/mod/dfrn_request.php
      @@ -178,7 +178,7 @@ function dfrn_request_post(App &$a) {
       					);
       				}
       
      -				if($r) {
      +				if ($r) {
       					info( t("Introduction complete.") . EOL);
       				}
       
      @@ -301,7 +301,7 @@ function dfrn_request_post(App &$a) {
       			dbesc(NETWORK_MAIL2)
       		);
       		if (dbm::is_result($r)) {
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				if(! $rr['rel']) {
       					q("DELETE FROM `contact` WHERE `id` = %d",
       						intval($rr['cid'])
      @@ -326,7 +326,7 @@ function dfrn_request_post(App &$a) {
       			dbesc(NETWORK_MAIL2)
       		);
       		if (dbm::is_result($r)) {
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				if(! $rr['rel']) {
       					q("DELETE FROM `contact` WHERE `id` = %d",
       						intval($rr['cid'])
      diff --git a/mod/directory.php b/mod/directory.php
      index c702acf376..f3fbb9eb77 100644
      --- a/mod/directory.php
      +++ b/mod/directory.php
      @@ -92,12 +92,14 @@ function directory_content(App &$a) {
       			WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit);
       	if (dbm::is_result($r)) {
       
      -		if(in_array('small', $a->argv))
      +		if (in_array('small', $a->argv)) {
       			$photo = 'thumb';
      -		else
      +		}
      +		else {
       			$photo = 'photo';
      +		}
       
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       
       			$itemurl= '';
       
      diff --git a/mod/events.php b/mod/events.php
      index 6bf7da6a28..c8a5694343 100644
      --- a/mod/events.php
      +++ b/mod/events.php
      @@ -344,7 +344,7 @@ function events_content(App &$a) {
       
       		if (dbm::is_result($r)) {
       			$r = sort_by_date($r);
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
       				if (! x($links,$j)) {
       					$links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;
      diff --git a/mod/filerm.php b/mod/filerm.php
      index f34421ba52..7dbfe29473 100644
      --- a/mod/filerm.php
      +++ b/mod/filerm.php
      @@ -10,18 +10,21 @@ function filerm_content(App &$a) {
       	$cat = unxmlify(trim($_GET['cat']));
       
       	$category = (($cat) ? true : false);
      -	if($category)
      +	if ($category) {
       		$term = $cat;
      +	}
       
       	$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
       
       	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);
      +	}
       
      -	if(x($_SESSION,'return_url'))
      +	if (x($_SESSION,'return_url')) {
       		goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
      +	}
       
       	killme();
       }
      diff --git a/mod/follow.php b/mod/follow.php
      index f318dc202c..2c90923e6f 100644
      --- a/mod/follow.php
      +++ b/mod/follow.php
      @@ -157,8 +157,9 @@ function follow_post(App &$a) {
       		// NOTREACHED
       	}
       
      -	if ($_REQUEST['cancel'])
      +	if ($_REQUEST['cancel']) {
       		goaway($_SESSION['return_url']);
      +	}
       
       	$uid = local_user();
       	$url = notags(trim($_REQUEST['url']));
      @@ -170,17 +171,21 @@ function follow_post(App &$a) {
       
       	$result = new_contact($uid,$url,true);
       
      -	if($result['success'] == false) {
      -		if($result['message'])
      +	if ($result['success'] == false) {
      +		if ($result['message']) {
       			notice($result['message']);
      +		}
       		goaway($return_url);
      -	} elseif ($result['cid'])
      +	}
      +	elseif ($result['cid']) {
       		goaway(App::get_baseurl().'/contacts/'.$result['cid']);
      +	}
       
       	info( t('Contact added').EOL);
       
      -	if(strstr($return_url,'contacts'))
      +	if (strstr($return_url,'contacts')) {
       		goaway(App::get_baseurl().'/contacts/'.$contact_id);
      +	}
       
       	goaway($return_url);
       	// NOTREACHED
      diff --git a/mod/group.php b/mod/group.php
      index fc5c481817..bf9009ae0c 100644
      --- a/mod/group.php
      +++ b/mod/group.php
      @@ -25,7 +25,7 @@ function group_post(App &$a) {
       
       		$name = notags(trim($_POST['groupname']));
       		$r = group_add(local_user(),$name);
      -		if($r) {
      +		if ($r) {
       			info( t('Group created.') . EOL );
       			$r = group_byname(local_user(),$name);
       			if ($r) {
      diff --git a/mod/hcard.php b/mod/hcard.php
      index 1d51ac80ee..50721720d0 100644
      --- a/mod/hcard.php
      +++ b/mod/hcard.php
      @@ -4,8 +4,9 @@ function hcard_init(App &$a) {
       
       	$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
       
      -	if($a->argc > 1)
      +	if ($a->argc > 1) {
       		$which = $a->argv[1];
      +	}
       	else {
       		notice( t('No profile') . EOL );
       		$a->error = 404;
      @@ -13,28 +14,30 @@ function hcard_init(App &$a) {
       	}
       
       	$profile = 0;
      -	if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
      -		$which = $a->user['nickname'];
      -		$profile = $a->argv[1];		
      +	if ((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
      +		$which   = $a->user['nickname'];
      +		$profile = $a->argv[1];
       	}
       
       	profile_load($a,$which,$profile);
       
      -	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'] .= '';
       	}
      -	if(x($a->profile,'openidserver'))				
      +	if (x($a->profile,'openidserver')) {
       		$a->page['htmlhead'] .= '' . "\r\n";
      -	if(x($a->profile,'openid')) {
      +	}
      +	if (x($a->profile,'openid')) {
       		$delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
       		$a->page['htmlhead'] .= '' . "\r\n";
       	}
       
      -	if(! $blocked) {
      +	if (! $blocked) {
       		$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
       		$keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords);
      -		if(strlen($keywords))
      +		if (strlen($keywords)) {
       			$a->page['htmlhead'] .= '' . "\r\n" ;
      +		}
       	}
       
       	$a->page['htmlhead'] .= '' . "\r\n" ;
      @@ -44,7 +47,7 @@ function hcard_init(App &$a) {
       	header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
       
       	$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
      -	foreach($dfrn_pages as $dfrn) {
      +	foreach ($dfrn_pages as $dfrn) {
       		$a->page['htmlhead'] .= "\r\n";
       	}
       
      diff --git a/mod/install.php b/mod/install.php
      index 92b136c338..1206aa61ea 100755
      --- a/mod/install.php
      +++ b/mod/install.php
      @@ -52,7 +52,7 @@ function install_post(App &$a) {
       					$r = q("CREATE DATABASE '%s'",
       							dbesc($dbdata)
       					);
      -					if($r) {
      +					if ($r) {
       						unset($db);
       						$db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true);
       					} else {
      @@ -520,19 +520,22 @@ function check_smarty3(&$checks) {
       function check_htaccess(&$checks) {
       	$status = true;
       	$help = "";
      -	if (function_exists('curl_init')){
      +	if (function_exists('curl_init')) {
       		$test = fetch_url(App::get_baseurl()."/install/testrewrite");
       
      -		if ($test!="ok")
      +		if ($test!="ok") {
       			$test = fetch_url(normalise_link(App::get_baseurl()."/install/testrewrite"));
      +		}
       
       		if ($test!="ok") {
       			$status = false;
       			$help = t('Url rewrite in .htaccess is not working. Check your server configuration.');
       		}
       		check_add($checks, t('Url rewrite is working'), $status, true, $help);
      -	} else {
      +	}
      +	else {
       		// cannot check modrewrite if libcurl is not installed
      +		/// @TODO Maybe issue warning here?
       	}
       }
       
      @@ -549,7 +552,7 @@ function check_imagik(&$checks) {
       	}
       	if ($imagick == false) {
       		check_add($checks, t('ImageMagick PHP extension is not installed'), $imagick, false, "");
      -		}
      +	}
       	else {
       		check_add($checks, t('ImageMagick PHP extension is installed'), $imagick, false, "");
       		if ($imagick) {
      diff --git a/mod/invite.php b/mod/invite.php
      index 2db71742f1..2662c792f0 100644
      --- a/mod/invite.php
      +++ b/mod/invite.php
      @@ -116,11 +116,13 @@ function invite_content(App &$a) {
       
       	$dirloc = get_config('system','directory');
       	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');
      -		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())
       			. "\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 {
       		$o = t('Our apologies. This system is not currently configured to connect with other public sites or invite members.');
      @@ -129,15 +131,15 @@ function invite_content(App &$a) {
       
       	$o = replace_macros($tpl, array(
       		'$form_security_token' => get_form_security_token("send_invite"),
      -		'$invite' => t('Send invitations'),
      -		'$addr_text' => t('Enter email addresses, one per line:'),
      -		'$msg_text' => t('Your message:'),
      -		'$default_message' => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n"
      +		'$invite'              => t('Send invitations'),
      +		'$addr_text'           => t('Enter email addresses, one per line:'),
      +		'$msg_text'            => t('Your message:'),
      +		'$default_message'     => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n"
       			. $linktxt
       			. "\r\n" . "\r\n" . (($invonly) ? t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') .t('Once you have registered, please connect with me via my profile page at:') 
       			. "\r\n" . "\r\n" . App::get_baseurl() . '/profile/' . $a->user['nickname']
       			. "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendica.com') . "\r\n" . "\r\n"  ,
      -		'$submit' => t('Submit')
      +		'$submit'              => t('Submit')
       	));
       
       	return $o;
      diff --git a/mod/item.php b/mod/item.php
      index 864aa18e51..487ddee916 100644
      --- a/mod/item.php
      +++ b/mod/item.php
      @@ -59,13 +59,14 @@ function item_post(App &$a) {
       	// Check for doubly-submitted posts, and reject duplicates
       	// Note that we have to ignore previews, otherwise nothing will post
       	// after it's been previewed
      -	if(!$preview && x($_REQUEST['post_id_random'])) {
      -		if(x($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) {
      +	if (!$preview && x($_REQUEST['post_id_random'])) {
      +		if (x($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) {
       			logger("item post: duplicate post", LOGGER_DEBUG);
       			item_post_return(App::get_baseurl(), $api_source, $return_path);
       		}
      -		else
      +		else {
       			$_SESSION['post-random'] = $_REQUEST['post_id_random'];
      +		}
       	}
       
       	/**
      @@ -82,18 +83,20 @@ function item_post(App &$a) {
       	$r = false;
       	$objecttype = null;
       
      -	if($parent || $parent_uri) {
      +	if ($parent || $parent_uri) {
       
       		$objecttype = ACTIVITY_OBJ_COMMENT;
       
      -		if(! x($_REQUEST,'type'))
      +		if (! x($_REQUEST,'type')) {
       			$_REQUEST['type'] = 'net-comment';
      +		}
       
      -		if($parent) {
      +		if ($parent) {
       			$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
       				intval($parent)
       			);
      -		} elseif($parent_uri && local_user()) {
      +		}
      +		elseif ($parent_uri && local_user()) {
       			// 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",
       				dbesc($parent_uri),
      @@ -105,7 +108,7 @@ function item_post(App &$a) {
       		if (dbm::is_result($r)) {
       			$parid = $r[0]['parent'];
       			$parent_uri = $r[0]['uri'];
      -			if($r[0]['id'] != $r[0]['parent']) {
      +			if ($r[0]['id'] != $r[0]['parent']) {
       				$r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1",
       					intval($parid)
       				);
      @@ -114,8 +117,9 @@ function item_post(App &$a) {
       
       		if (! dbm::is_result($r)) {
       			notice( t('Unable to locate original post.') . EOL);
      -			if(x($_REQUEST,'return'))
      +			if (x($_REQUEST,'return')) {
       				goaway($return_path);
      +			}
       			killme();
       		}
       		$parent_item = $r[0];
      @@ -125,7 +129,7 @@ function item_post(App &$a) {
       		//if(($parid) && ($parid != $parent))
       		$thr_parent = $parent_uri;
       
      -		if($parent_item['contact-id'] && $uid) {
      +		if ($parent_item['contact-id'] && $uid) {
       			$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
       				intval($parent_item['contact-id']),
       				intval($uid)
      @@ -449,13 +453,15 @@ function item_post(App &$a) {
       
       			$objecttype = ACTIVITY_OBJ_IMAGE;
       
      -			foreach($images as $image) {
      -				if(! stristr($image,App::get_baseurl() . '/photo/'))
      +			foreach ($images as $image) {
      +				if (! stristr($image,App::get_baseurl() . '/photo/')) {
       					continue;
      +				}
       				$image_uri = substr($image,strrpos($image,'/') + 1);
       				$image_uri = substr($image_uri,0, strpos($image_uri,'-'));
      -				if(! strlen($image_uri))
      +				if (! strlen($image_uri)) {
       					continue;
      +				}
       				$srch = '<' . intval($contact_id) . '>';
       
       				$r = q("SELECT `id` FROM `photo` WHERE `allow_cid` = '%s' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = ''
      diff --git a/mod/lostpass.php b/mod/lostpass.php
      index 3174bcd0e0..43e9cf715e 100644
      --- a/mod/lostpass.php
      +++ b/mod/lostpass.php
      @@ -102,7 +102,7 @@ function lostpass_content(App &$a) {
       			dbesc($new_password_encoded),
       			intval($uid)
       		);
      -		if($r) {
      +		if ($r) {
       			$tpl = get_markup_template('pwdreset.tpl');
       			$o .= replace_macros($tpl,array(
       				'$lbl1' => t('Password Reset'),
      diff --git a/mod/message.php b/mod/message.php
      index ef62a78981..776a23bccd 100644
      --- a/mod/message.php
      +++ b/mod/message.php
      @@ -160,7 +160,7 @@ function item_redir_and_replace_images($body, $images, $cid) {
       	$newbody = $newbody . $origbody;
       
       	$cnt = 0;
      -	foreach($images as $image) {
      +	foreach ($images as $image) {
       		// We're depending on the property of 'foreach' (specified on the PHP website) that
       		// it loops over the array starting from the first element and going sequentially
       		// to the last element
      @@ -231,7 +231,7 @@ function message_content(App &$a) {
       				intval($a->argv[2]),
       				intval(local_user())
       			);
      -			if($r) {
      +			if ($r) {
       				info( t('Message deleted.') . EOL );
       			}
       			//goaway(App::get_baseurl(true) . '/message' );
      diff --git a/mod/network.php b/mod/network.php
      index 8b24b3e11b..6c9bf75799 100644
      --- a/mod/network.php
      +++ b/mod/network.php
      @@ -183,13 +183,13 @@ function saved_searches($search) {
       	$saved = array();
       
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$saved[] = array(
      -				'id'		=> $rr['id'],
      -				'term'		=> $rr['term'],
      -				'encodedterm' 	=> urlencode($rr['term']),
      -				'delete'	=> t('Remove term'),
      -				'selected'	=> ($search==$rr['term']),
      +				'id'          => $rr['id'],
      +				'term'        => $rr['term'],
      +				'encodedterm' => urlencode($rr['term']),
      +				'delete'      => t('Remove term'),
      +				'selected'    => ($search==$rr['term']),
       			);
       		}
       	}
      @@ -197,10 +197,10 @@ function saved_searches($search) {
       
       	$tpl = get_markup_template("saved_searches_aside.tpl");
       	$o = replace_macros($tpl, array(
      -		'$title'	=> t('Saved Searches'),
      -		'$add'		=> t('add'),
      -		'$searchbox'	=> search($search,'netsearch-box',$srchurl,true),
      -		'$saved' 	=> $saved,
      +		'$title'     => t('Saved Searches'),
      +		'$add'       => t('add'),
      +		'$searchbox' => search($search,'netsearch-box',$srchurl,true),
      +		'$saved'     => $saved,
       	));
       
       	return $o;
      diff --git a/mod/nogroup.php b/mod/nogroup.php
      index 900ca4de09..c448406277 100644
      --- a/mod/nogroup.php
      +++ b/mod/nogroup.php
      @@ -35,7 +35,7 @@ function nogroup_content(App &$a) {
       	}
       	$r = contacts_not_grouped(local_user(),$a->pager['start'],$a->pager['itemspage']);
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       
       			$contact_details = get_contact_details_by_url($rr['url'], local_user(), $rr);
       
      diff --git a/mod/noscrape.php b/mod/noscrape.php
      index f1370167c5..33255f0fa4 100644
      --- a/mod/noscrape.php
      +++ b/mod/noscrape.php
      @@ -31,21 +31,22 @@ function noscrape_init(App &$a) {
       		intval($a->profile['uid']));
       
       	$json_info = array(
      -		'fn' => $a->profile['name'],
      -		'addr' => $a->profile['addr'],
      -		'nick' => $which,
      -		'key' => $a->profile['pubkey'],
      +		'fn'       => $a->profile['name'],
      +		'addr'     => $a->profile['addr'],
      +		'nick'     => $which,
      +		'key'      => $a->profile['pubkey'],
       		'homepage' => App::get_baseurl()."/profile/{$which}",
      -		'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
      -		'photo' => $r[0]["photo"],
      -		'tags' => $keywords
      +		'comm'     => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
      +		'photo'    => $r[0]["photo"],
      +		'tags'     => $keywords
       	);
       
      -	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",
       			intval($a->profile['uid']));
      -		if (dbm::is_result($r))
      +		if (dbm::is_result($r)) {
       			$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
       				AND `network` IN ('%s', '%s', '%s', '')",
      @@ -54,20 +55,21 @@ function noscrape_init(App &$a) {
       			dbesc(NETWORK_DIASPORA),
       			dbesc(NETWORK_OSTATUS)
       		);
      -		if (dbm::is_result($r))
      +		if (dbm::is_result($r)) {
       			$json_info["contacts"] = intval($r[0]['total']);
      +		}
       	}
       
       	//These are optional fields.
       	$profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital', 'about');
      -	foreach($profile_fields as $field) {
      -		if(!empty($a->profile[$field])) {
      +	foreach ($profile_fields as $field) {
      +		if (!empty($a->profile[$field])) {
       			$json_info["$field"] = $a->profile[$field];
       		}
       	}
       
       	$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
      -	foreach($dfrn_pages as $dfrn) {
      +	foreach ($dfrn_pages as $dfrn) {
       		$json_info["dfrn-{$dfrn}"] = App::get_baseurl()."/dfrn_{$dfrn}/{$which}";
       	}
       
      diff --git a/mod/openid.php b/mod/openid.php
      index e14b5f82d9..ce707c4150 100644
      --- a/mod/openid.php
      +++ b/mod/openid.php
      @@ -56,7 +56,7 @@ function openid_content(App &$a) {
       			// Successful OpenID login - but we can't match it to an existing account.
       			// New registration?
       
      -			if($a->config['register_policy'] == REGISTER_CLOSED) {
      +			if ($a->config['register_policy'] == REGISTER_CLOSED) {
       				notice( t('Account not found and OpenID registration is not permitted on this site.') . EOL);
       				goaway(z_root());
       			}
      @@ -64,31 +64,41 @@ function openid_content(App &$a) {
       			unset($_SESSION['register']);
       			$args = '';
       			$attr = $openid->getAttributes();
      -			if(is_array($attr) && count($attr)) {
      -				foreach($attr as $k => $v) {
      -					if($k === 'namePerson/friendly')
      +			if (is_array($attr) && count($attr)) {
      +				foreach ($attr as $k => $v) {
      +					if ($k === 'namePerson/friendly') {
       						$nick = notags(trim($v));
      -					if($k === 'namePerson/first')
      +					}
      +					if($k === 'namePerson/first') {
       						$first = notags(trim($v));
      -					if($k === 'namePerson')
      +					}
      +					if($k === 'namePerson') {
       						$args .= '&username=' . notags(trim($v));
      -					if($k === 'contact/email')
      +					}
      +					if ($k === 'contact/email') {
       						$args .= '&email=' . notags(trim($v));
      -					if($k === 'media/image/aspect11')
      +					}
      +					if ($k === 'media/image/aspect11') {
       						$photosq = bin2hex(trim($v));
      -					if($k === 'media/image/default')
      +					}
      +					if ($k === 'media/image/default') {
       						$photo = bin2hex(trim($v));
      +					}
       				}
       			}
      -			if($nick)
      +			if ($nick) {
       				$args .= '&nickname=' . $nick;
      -			elseif($first)
      +			}
      +			elseif ($first) {
       				$args .= '&nickname=' . $first;
      +			}
       
      -			if($photosq)
      +			if ($photosq) {
       				$args .= '&photo=' . $photosq;
      -			elseif($photo)
      +			}
      +			elseif ($photo) {
       				$args .= '&photo=' . $photo;
      +			}
       
       			$args .= '&openid_url=' . notags(trim($authid));
       
      diff --git a/mod/photos.php b/mod/photos.php
      index 317d7272b4..d4b2a3b19f 100644
      --- a/mod/photos.php
      +++ b/mod/photos.php
      @@ -255,7 +255,7 @@ function photos_post(App &$a) {
       				);
       			}
       			if (dbm::is_result($r)) {
      -				foreach($r as $rr) {
      +				foreach ($r as $rr) {
       					$res[] = "'" . dbesc($rr['rid']) . "'" ;
       				}
       			} else {
      @@ -277,7 +277,7 @@ function photos_post(App &$a) {
       				intval($page_owner_uid)
       			);
       			if (dbm::is_result($r)) {
      -				foreach($r as $rr) {
      +				foreach ($r as $rr) {
       					q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
       						dbesc(datetime_convert()),
       						dbesc($rr['parent-uri']),
      diff --git a/mod/poco.php b/mod/poco.php
      index 11f984757a..0415e1a2ce 100644
      --- a/mod/poco.php
      +++ b/mod/poco.php
      @@ -175,7 +175,7 @@ function poco_init(App &$a) {
       
       	if(is_array($r)) {
       		if (dbm::is_result($r)) {
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				if (!isset($rr['generation'])) {
       					if ($global)
       						$rr['generation'] = 3;
      diff --git a/mod/profile.php b/mod/profile.php
      index b7756453fe..52ffe8c47d 100644
      --- a/mod/profile.php
      +++ b/mod/profile.php
      @@ -62,7 +62,7 @@ function profile_init(App &$a) {
       	header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
       
       	$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
      -	foreach($dfrn_pages as $dfrn) {
      +	foreach ($dfrn_pages as $dfrn) {
       		$a->page['htmlhead'] .= "\r\n";
       	}
       	$a->page['htmlhead'] .= "\r\n";
      diff --git a/mod/profile_photo.php b/mod/profile_photo.php
      index 0b6dd8d13b..9b1ff8adb8 100644
      --- a/mod/profile_photo.php
      +++ b/mod/profile_photo.php
      @@ -204,7 +204,7 @@ function profile_photo_content(App &$a) {
       			return;
       		}
       		$havescale = false;
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			if($rr['scale'] == 5)
       				$havescale = true;
       		}
      diff --git a/mod/profiles.php b/mod/profiles.php
      index 20bd4cf6f1..bf2f20d2a9 100644
      --- a/mod/profiles.php
      +++ b/mod/profiles.php
      @@ -780,24 +780,26 @@ function profiles_content(App &$a) {
       		if (dbm::is_result($r)) {
       
       			$tpl = get_markup_template('profile_entry.tpl');
      -			foreach($r as $rr) {
      +
      +			$profiles = '';
      +			foreach ($r as $rr) {
       				$profiles .= replace_macros($tpl, array(
      -					'$photo' => $a->remove_baseurl($rr['thumb']),
      -					'$id' => $rr['id'],
      -					'$alt' => t('Profile Image'),
      +					'$photo'        => $a->remove_baseurl($rr['thumb']),
      +					'$id'           => $rr['id'],
      +					'$alt'          => t('Profile Image'),
       					'$profile_name' => $rr['profile-name'],
      -					'$visible' => (($rr['is-default']) ? '' . t('visible to everybody') . ''
      +					'$visible'      => (($rr['is-default']) ? '' . t('visible to everybody') . ''
       						: '' . t('Edit visibility') . '')
       				));
       			}
       
       			$tpl_header = get_markup_template('profile_listing_header.tpl');
       			$o .= replace_macros($tpl_header,array(
      -				'$header' => t('Edit/Manage Profiles'),
      -				'$chg_photo' => t('Change profile photo'),
      -				'$cr_new' => t('Create New Profile'),
      +				'$header'      => t('Edit/Manage Profiles'),
      +				'$chg_photo'   => t('Change profile photo'),
      +				'$cr_new'      => t('Create New Profile'),
       				'$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new"),
      -				'$profiles' => $profiles
      +				'$profiles'    => $profiles
       			));
       		}
       		return $o;
      diff --git a/mod/search.php b/mod/search.php
      index 3a25376268..22879f7f9e 100644
      --- a/mod/search.php
      +++ b/mod/search.php
      @@ -17,7 +17,7 @@ function search_saved_searches() {
       
       	if (dbm::is_result($r)) {
       		$saved = array();
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$saved[] = array(
       				'id'		=> $rr['id'],
       				'term'		=> $rr['term'],
      diff --git a/mod/suggest.php b/mod/suggest.php
      index 5af337ae1b..4c08db8b6c 100644
      --- a/mod/suggest.php
      +++ b/mod/suggest.php
      @@ -75,7 +75,7 @@ function suggest_content(App &$a) {
       
       	require_once 'include/contact_selectors.php';
       
      -	foreach($r as $rr) {
      +	foreach ($r as $rr) {
       
       		$connlnk = App::get_baseurl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
       		$ignlnk = App::get_baseurl() . '/suggest?ignore=' . $rr['id'];
      diff --git a/mod/videos.php b/mod/videos.php
      index 58c4b6c650..00c7c6dfa1 100644
      --- a/mod/videos.php
      +++ b/mod/videos.php
      @@ -368,8 +368,8 @@ function videos_content(App &$a) {
       
       	$videos = array();
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      -			if($a->theme['template_engine'] === 'internal') {
      +		foreach ($r as $rr) {
      +			if ($a->theme['template_engine'] === 'internal') {
       				$alt_e = template_escape($rr['filename']);
       				$name_e = template_escape($rr['album']);
       			}
      diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php
      index 6ae458b6a2..9c72a46e9c 100644
      --- a/mod/viewcontacts.php
      +++ b/mod/viewcontacts.php
      @@ -76,9 +76,11 @@ function viewcontacts_content(App &$a) {
       
       	$contacts = array();
       
      -	foreach($r as $rr) {
      -		if($rr['self'])
      +	foreach ($r as $rr) {
      +		/// @TODO This triggers an E_NOTICE if 'self' is not there
      +		if ($rr['self']) {
       			continue;
      +		}
       
       		$url = $rr['url'];
       
      
      From 54615be22efc5e606fa7f13ba49d82af3b0c41fc Mon Sep 17 00:00:00 2001
      From: Roland Haeder 
      Date: Tue, 20 Dec 2016 21:16:01 +0100
      Subject: [PATCH 49/96] 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 
      ---
       update.php                | 24 ++++++++---------
       view/theme/frio/theme.php | 11 ++++----
       view/theme/vier/theme.php | 57 +++++++++++++++++++++++++--------------
       3 files changed, 55 insertions(+), 37 deletions(-)
      
      diff --git a/update.php b/update.php
      index 0679b5a1f8..7aec2ec2b8 100644
      --- a/update.php
      +++ b/update.php
      @@ -86,7 +86,7 @@ function update_1006() {
       
       	$r = q("SELECT * FROM `user` WHERE `spubkey` = '' ");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$sres=openssl_pkey_new(array('encrypt_key' => false ));
       			$sprvkey = '';
       			openssl_pkey_export($sres, $sprvkey);
      @@ -123,7 +123,7 @@ function update_1011() {
       	q("ALTER TABLE `contact` ADD `nick` CHAR( 255 ) NOT NULL AFTER `name` ");
       	$r = q("SELECT * FROM `contact` WHERE 1");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       				q("UPDATE `contact` SET `nick` = '%s' WHERE `id` = %d",
       					dbesc(basename($rr['url'])),
       					intval($rr['id'])
      @@ -146,7 +146,7 @@ function update_1014() {
       	q("ALTER TABLE `contact` ADD `micro` TEXT NOT NULL AFTER `thumb` ");
       	$r = q("SELECT * FROM `photo` WHERE `scale` = 4");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$ph = new Photo($rr['data']);
       			if($ph->is_valid()) {
       				$ph->scaleImage(48);
      @@ -156,7 +156,7 @@ function update_1014() {
       	}
       	$r = q("SELECT * FROM `contact` WHERE 1");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			if(stristr($rr['thumb'],'avatar'))
       				q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d",
       					dbesc(str_replace('avatar','micro',$rr['thumb'])),
      @@ -309,7 +309,7 @@ function update_1031() {
       	// Repair any bad links that slipped into the item table
       	$r = q("SELECT `id`, `object` FROM `item` WHERE `object` != '' ");
       	if($r && dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			if(strstr($rr['object'],'type="http')) {
       				q("UPDATE `item` SET `object` = '%s' WHERE `id` = %d",
       					dbesc(str_replace('type="http','href="http',$rr['object'])),
      @@ -357,7 +357,7 @@ function update_1036() {
       
       	$r = dbq("SELECT * FROM `contact` WHERE `network` = 'dfrn' && `photo` LIKE '%include/photo%' ");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d",
       				dbesc(str_replace('include/photo','photo',$rr['photo'])),
       				dbesc(str_replace('include/photo','photo',$rr['thumb'])),
      @@ -607,7 +607,7 @@ function update_1075() {
       	q("ALTER TABLE `user` ADD `guid` CHAR( 16 ) NOT NULL AFTER `uid` ");
       	$r = q("SELECT `uid` FROM `user` WHERE 1");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$found = true;
       			do {
       				$guid = substr(random_string(),0,16);
      @@ -689,7 +689,7 @@ function update_1082() {
       		return;
       	$r = q("SELECT distinct(`resource-id`) FROM `photo` WHERE 1 group by `id`");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$guid = get_guid();
       			q("update `photo` set `guid` = '%s' where `resource-id` = '%s'",
       				dbesc($guid),
      @@ -732,7 +732,7 @@ function update_1087() {
       
       	$r = q("SELECT `id` FROM `item` WHERE `parent` = `id` ");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$x = q("SELECT max(`created`) AS `cdate` FROM `item` WHERE `parent` = %d LIMIT 1",
       				intval($rr['id'])
       			);
      @@ -855,7 +855,7 @@ function update_1100() {
       
       	$r = q("select id, url from contact where url != '' and nurl = '' ");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			q("update contact set nurl = '%s' where id = %d",
       				dbesc(normalise_link($rr['url'])),
       				intval($rr['id'])
      @@ -1169,7 +1169,7 @@ function update_1136() {
       
       	$r = q("select * from config where 1 order by id desc");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$found = false;
       			foreach($arr as $x) {
       				if($x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) {
      @@ -1188,7 +1188,7 @@ function update_1136() {
       	$arr = array();
       	$r = q("select * from pconfig where 1 order by id desc");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$found = false;
       			foreach($arr as $x) {
       				if($x['uid'] == $rr['uid'] && $x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) {
      diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php
      index 664881a4a8..f9cbf79a6a 100644
      --- a/view/theme/frio/theme.php
      +++ b/view/theme/frio/theme.php
      @@ -271,7 +271,7 @@ function frio_remote_nav($a,&$nav) {
        * We use this to give the data to textcomplete and have a filter function at the
        * contact page.
        * 
      - * @param App $a The app data
      + * @param App $a The app data @TODO Unused
        * @param array $results The array with the originals from acl_lookup()
        */
       function frio_acl_lookup($a, &$results) {
      @@ -281,17 +281,18 @@ function frio_acl_lookup($a, &$results) {
       
       	// we introduce a new search type, r should do the same query like it's
       	// done in /mod/contacts for connections
      -	if($results["type"] == "r") {
      +	if ($results["type"] == "r") {
       		$searching = false;
      -		if($search) {
      +		if ($search) {
       			$search_hdr = $search;
       			$search_txt = dbesc(protect_sprintf(preg_quote($search)));
       			$searching = true;
       		}
       		$sql_extra .= (($searching) ? " AND (`attag` LIKE '%%".dbesc($search_txt)."%%' OR `name` LIKE '%%".dbesc($search_txt)."%%' OR `nick` LIKE '%%".dbesc($search_txt)."%%') " : "");
       
      -		if($nets)
      +		if ($nets) {
       			$sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets));
      +		}
       
       		$sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : '');
       
      @@ -312,7 +313,7 @@ function frio_acl_lookup($a, &$results) {
       		$contacts = array();
       
       		if (dbm::is_result($r)) {
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				$contacts[] = _contact_detail_for_template($rr);
       			}
       		}
      diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php
      index 46921dc1c5..8be91220af 100644
      --- a/view/theme/vier/theme.php
      +++ b/view/theme/vier/theme.php
      @@ -152,7 +152,7 @@ function vier_community_info() {
       			$aside['$comunity_profiles_title'] = t('Community Profiles');
       			$aside['$comunity_profiles_items'] = array();
       
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				$entry = replace_macros($tpl,array(
       					'$id' => $rr['id'],
       					//'$profile_link' => zrl($rr['url']),
      @@ -182,7 +182,7 @@ function vier_community_info() {
       			$aside['$lastusers_title'] = t('Last users');
       			$aside['$lastusers_items'] = array();
       
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				$profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
       				$entry = replace_macros($tpl,array(
       					'$id' => $rr['id'],
      @@ -300,7 +300,7 @@ function vier_community_info() {
       
       			$aside['$helpers_items'] = array();
       
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				$entry = replace_macros($tpl,array(
       					'$url' => $rr['url'],
       					'$title' => $rr['name'],
      @@ -316,55 +316,72 @@ function vier_community_info() {
       	//connectable services
       	if ($show_services) {
       
      +		/// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
       		$r = array();
       
      -		if (plugin_enabled("appnet"))
      +		if (plugin_enabled("appnet")) {
       			$r[] = array("photo" => "images/appnet.png", "name" => "App.net");
      +		}
       
      -		if (plugin_enabled("buffer"))
      +		if (plugin_enabled("buffer")) {
       			$r[] = array("photo" => "images/buffer.png", "name" => "Buffer");
      +		}
       
      -		if (plugin_enabled("blogger"))
      +		if (plugin_enabled("blogger")) {
       			$r[] = array("photo" => "images/blogger.png", "name" => "Blogger");
      +		}
       
      -		if (plugin_enabled("dwpost"))
      +		if (plugin_enabled("dwpost")) {
       			$r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth");
      +		}
       
      -		if (plugin_enabled("fbpost"))
      +		if (plugin_enabled("fbpost")) {
       			$r[] = array("photo" => "images/facebook.png", "name" => "Facebook");
      +		}
       
      -		if (plugin_enabled("ifttt"))
      +		if (plugin_enabled("ifttt")) {
       			$r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT");
      +		}
       
      -		if (plugin_enabled("statusnet"))
      +		if (plugin_enabled("statusnet")) {
       			$r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social");
      +		}
       
      -		if (plugin_enabled("gpluspost"))
      +		if (plugin_enabled("gpluspost")) {
       			$r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
      +		}
       
      -		//if (plugin_enabled("ijpost"))
      +		//if (plugin_enabled("ijpost")) {
       		//	$r[] = array("photo" => "images/", "name" => "");
      +		//}
       
      -		if (plugin_enabled("libertree"))
      +		if (plugin_enabled("libertree")) {
       			$r[] = array("photo" => "images/libertree.png", "name" => "Libertree");
      +		}
       
      -		//if (plugin_enabled("ljpost"))
      +		//if (plugin_enabled("ljpost")) {
       		//	$r[] = array("photo" => "images/", "name" => "");
      +		//}
       
      -		if (plugin_enabled("pumpio"))
      +		if (plugin_enabled("pumpio")) {
       			$r[] = array("photo" => "images/pumpio.png", "name" => "pump.io");
      +		}
       
      -		if (plugin_enabled("tumblr"))
      +		if (plugin_enabled("tumblr")) {
       			$r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr");
      +		}
       
      -		if (plugin_enabled("twitter"))
      +		if (plugin_enabled("twitter")) {
       			$r[] = array("photo" => "images/twitter.png", "name" => "Twitter");
      +		}
       
      -		if (plugin_enabled("wppost"))
      +		if (plugin_enabled("wppost")) {
       			$r[] = array("photo" => "images/wordpress.png", "name" => "Wordpress");
      +		}
       
      -		if(function_exists("imap_open") AND !get_config("system","imap_disabled") AND !get_config("system","dfrn_only"))
      +		if (function_exists("imap_open") AND !get_config("system","imap_disabled") AND !get_config("system","dfrn_only")) {
       			$r[] = array("photo" => "images/mail.png", "name" => "E-Mail");
      +		}
       
       		$tpl = get_markup_template('ch_connectors.tpl');
       
      @@ -374,7 +391,7 @@ function vier_community_info() {
       			$con_services['title'] = Array("", t('Connect Services'), "", "");
       			$aside['$con_services'] = $con_services;
       
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				$entry = replace_macros($tpl,array(
       					'$url' => $url,
       					'$photo' => $rr['photo'],
      
      From f334f9e61fd54b81726596272904806b1af4e969 Mon Sep 17 00:00:00 2001
      From: Hypolite Petovan 
      Date: Mon, 19 Dec 2016 20:19:26 -0500
      Subject: [PATCH 50/96] proxy_url: Fix extension extraction for URLs containing
       a . after a ?
      
      ---
       mod/proxy.php | 16 ++++++++--------
       1 file changed, 8 insertions(+), 8 deletions(-)
      
      diff --git a/mod/proxy.php b/mod/proxy.php
      index ff58bba7f1..d57d9baec5 100644
      --- a/mod/proxy.php
      +++ b/mod/proxy.php
      @@ -281,14 +281,14 @@ function proxy_url($url, $writemode = false, $size = '') {
       
       	$longpath .= '/' . strtr(base64_encode($url), '+/', '-_');
       
      -	// Checking for valid extensions. Only add them if they are safe
      -	$pos = strrpos($url, '.');
      -	if ($pos) {
      -		$extension = strtolower(substr($url, $pos + 1));
      -		$pos = strpos($extension, '?');
      -		if ($pos) {
      -			$extension = substr($extension, 0, $pos);
      -		}
      +	// Extract the URL extension, disregarding GET parameters starting with ?
      +	$question_mark_pos = strpos($url, '?');
      +	if ($question_mark_pos === false) {
      +		$question_mark_pos = strlen($url);
      +	}
      +	$dot_pos = strrpos($url, '.', $question_mark_pos - strlen($url));
      +	if ($dot_pos !== false) {
      +		$extension = strtolower(substr($url, $dot_pos + 1, $question_mark_pos - ($dot_pos + 1)));
       	}
       
       	$extensions = array('jpg', 'jpeg', 'gif', 'png');
      
      From 70a042fd04d0481ed3893454c11e8d4323584e74 Mon Sep 17 00:00:00 2001
      From: =?UTF-8?q?Roland=20H=C3=A4der?= 
      Date: Tue, 20 Dec 2016 17:43:46 +0100
      Subject: [PATCH 51/96] added more curly braces + space between "if" and brace
      MIME-Version: 1.0
      Content-Type: text/plain; charset=UTF-8
      Content-Transfer-Encoding: 8bit
      
      Signed-off-by: Roland Häder 
      ---
       boot.php             | 15 +++++----
       include/follow.php   | 20 +++++++-----
       include/salmon.php   | 21 ++++++------
       include/security.php | 28 ++++++++--------
       include/socgraph.php | 77 ++++++++++++++++++++++++++------------------
       index.php            | 39 ++++++++++++----------
       mod/admin.php        | 73 +++++++++++++++++++++--------------------
       mod/allfriends.php   |  2 +-
       mod/cal.php          |  2 +-
       mod/delegate.php     |  4 +--
       mod/dfrn_confirm.php |  9 +++---
       mod/dfrn_request.php | 39 +++++++++++++---------
       mod/dirfind.php      | 36 +++++++++++++--------
       mod/events.php       | 22 +++++++------
       mod/settings.php     |  5 +--
       15 files changed, 225 insertions(+), 167 deletions(-)
      
      diff --git a/boot.php b/boot.php
      index ccff45f734..70f7d324d3 100644
      --- a/boot.php
      +++ b/boot.php
      @@ -670,22 +670,23 @@ class App {
       
       		#set_include_path("include/$this->hostname" . PATH_SEPARATOR . get_include_path());
       
      -		if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,9) === "pagename=") {
      +		if ((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,9) === "pagename=") {
       			$this->query_string = substr($_SERVER['QUERY_STRING'],9);
       			// removing trailing / - maybe a nginx problem
       			if (substr($this->query_string, 0, 1) == "/")
       				$this->query_string = substr($this->query_string, 1);
      -		} elseif((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
      +		} elseif ((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
       			$this->query_string = substr($_SERVER['QUERY_STRING'],2);
       			// removing trailing / - maybe a nginx problem
       			if (substr($this->query_string, 0, 1) == "/")
       				$this->query_string = substr($this->query_string, 1);
       		}
       
      -		if (x($_GET,'pagename'))
      +		if (x($_GET,'pagename')) {
       			$this->cmd = trim($_GET['pagename'],'/\\');
      -		elseif (x($_GET,'q'))
      +		} elseif (x($_GET,'q')) {
       			$this->cmd = trim($_GET['q'],'/\\');
      +		}
       
       
       		// fix query_string
      @@ -694,13 +695,15 @@ class App {
       
       		// unix style "homedir"
       
      -		if(substr($this->cmd,0,1) === '~')
      +		if (substr($this->cmd,0,1) === '~') {
       			$this->cmd = 'profile/' . substr($this->cmd,1);
      +		}
       
       		// Diaspora style profile url
       
      -		if(substr($this->cmd,0,2) === 'u/')
      +		if (substr($this->cmd,0,2) === 'u/') {
       			$this->cmd = 'profile/' . substr($this->cmd,2);
      +		}
       
       
       		/*
      diff --git a/include/follow.php b/include/follow.php
      index e67beb84c2..15e8dd28d8 100644
      --- a/include/follow.php
      +++ b/include/follow.php
      @@ -77,12 +77,12 @@ function new_contact($uid,$url,$interactive = false) {
       
       	$url = str_replace('/#!/','/',$url);
       
      -	if(! allowed_url($url)) {
      +	if (! allowed_url($url)) {
       		$result['message'] = t('Disallowed profile URL.');
       		return $result;
       	}
       
      -	if(! $url) {
      +	if (! $url) {
       		$result['message'] = t('Connect URL missing.');
       		return $result;
       	}
      @@ -91,17 +91,21 @@ function new_contact($uid,$url,$interactive = false) {
       
       	call_hooks('follow', $arr);
       
      -	if(x($arr['contact'],'name'))
      +	if (x($arr['contact'],'name')) {
       		$ret = $arr['contact'];
      -	else
      +	}
      +	else {
       		$ret = probe_url($url);
      +	}
       
      -	if($ret['network'] === NETWORK_DFRN) {
      -		if($interactive) {
      -			if(strlen($a->path))
      +	if ($ret['network'] === NETWORK_DFRN) {
      +		if ($interactive) {
      +			if (strlen($a->path)) {
       				$myaddr = bin2hex(App::get_baseurl() . '/profile/' . $a->user['nickname']);
      -			else
      +			}
      +			else {
       				$myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
      +			}
       
       			goaway($ret['request'] . "&addr=$myaddr");
       
      diff --git a/include/salmon.php b/include/salmon.php
      index c5c3d72237..2b58334704 100644
      --- a/include/salmon.php
      +++ b/include/salmon.php
      @@ -24,22 +24,24 @@ function get_salmon_key($uri,$keyhash) {
       	// We have found at least one key URL
       	// If it's inline, parse it - otherwise get the key
       
      -	if(count($ret) > 0) {
      -		for($x = 0; $x < count($ret); $x ++) {
      -			if(substr($ret[$x],0,5) === 'data:') {
      -				if(strstr($ret[$x],','))
      +	if (count($ret) > 0) {
      +		for ($x = 0; $x < count($ret); $x ++) {
      +			if (substr($ret[$x],0,5) === 'data:') {
      +				if (strstr($ret[$x],',')) {
       					$ret[$x] = substr($ret[$x],strpos($ret[$x],',')+1);
      -				else
      +				} else {
       					$ret[$x] = substr($ret[$x],5);
      -			} elseif (normalise_link($ret[$x]) == 'http://')
      +				}
      +			} elseif (normalise_link($ret[$x]) == 'http://') {
       				$ret[$x] = fetch_url($ret[$x]);
      +			}
       		}
       	}
       
       
       	logger('Key located: ' . print_r($ret,true));
       
      -	if(count($ret) == 1) {
      +	if (count($ret) == 1) {
       
       		// We only found one one key so we don't care if the hash matches.
       		// If it's the wrong key we'll find out soon enough because
      @@ -50,10 +52,11 @@ function get_salmon_key($uri,$keyhash) {
       		return $ret[0];
       	}
       	else {
      -		foreach($ret as $a) {
      +		foreach ($ret as $a) {
       			$hash = base64url_encode(hash('sha256',$a));
      -			if($hash == $keyhash)
      +			if ($hash == $keyhash) {
       				return $a;
      +			}
       		}
       	}
       
      diff --git a/include/security.php b/include/security.php
      index 7e14146d94..cd00b5f7b0 100644
      --- a/include/security.php
      +++ b/include/security.php
      @@ -94,11 +94,12 @@ function authenticate_success($user_record, $login_initial = false, $interactive
       
       
       	}
      -	if($login_initial) {
      +	if ($login_initial) {
       		call_hooks('logged_in', $a->user);
       
      -		if(($a->module !== 'home') && isset($_SESSION['return_url']))
      +		if (($a->module !== 'home') && isset($_SESSION['return_url'])) {
       			goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
      +		}
       	}
       
       }
      @@ -109,16 +110,17 @@ function can_write_wall(&$a,$owner) {
       
       	static $verified = 0;
       
      -	if((! (local_user())) && (! (remote_user())))
      +	if ((! (local_user())) && (! (remote_user()))) {
       		return false;
      +	}
       
       	$uid = local_user();
       
      -	if(($uid) && ($uid == $owner)) {
      +	if (($uid) && ($uid == $owner)) {
       		return true;
       	}
       
      -	if(remote_user()) {
      +	if (remote_user()) {
       
       		// use remembered decision and avoid a DB lookup for each and every display item
       		// DO NOT use this function if there are going to be multiple owners
      @@ -126,25 +128,25 @@ function can_write_wall(&$a,$owner) {
       		// We have a contact-id for an authenticated remote user, this block determines if the contact
       		// belongs to this page owner, and has the necessary permissions to post content
       
      -		if($verified === 2)
      +		if ($verified === 2) {
       			return true;
      -		elseif($verified === 1)
      +		} elseif ($verified === 1) {
       			return false;
      -		else {
      +		} else {
       			$cid = 0;
       
      -			if(is_array($_SESSION['remote'])) {
      -				foreach($_SESSION['remote'] as $visitor) {
      -					if($visitor['uid'] == $owner) {
      +			if (is_array($_SESSION['remote'])) {
      +				foreach ($_SESSION['remote'] as $visitor) {
      +					if ($visitor['uid'] == $owner) {
       						$cid = $visitor['cid'];
       						break;
       					}
       				}
       			}
       
      -			if(! $cid)
      +			if (! $cid) {
       				return false;
      -
      +			}
       
       			$r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `user`.`uid` = `contact`.`uid` 
       				WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 
      diff --git a/include/socgraph.php b/include/socgraph.php
      index a779e88eff..7c70a22a54 100644
      --- a/include/socgraph.php
      +++ b/include/socgraph.php
      @@ -91,8 +91,8 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
       
       		$name = $entry->displayName;
       
      -		if(isset($entry->urls)) {
      -			foreach($entry->urls as $url) {
      +		if (isset($entry->urls)) {
      +			foreach ($entry->urls as $url) {
       				if ($url->type == 'profile') {
       					$profile_url = $url->value;
       					continue;
      @@ -104,7 +104,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
       			}
       		}
       		if (isset($entry->photos)) {
      -			foreach($entry->photos as $photo) {
      +			foreach ($entry->photos as $photo) {
       				if ($photo->type == 'profile') {
       					$profile_photo = $photo->value;
       					continue;
      @@ -112,29 +112,37 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
       			}
       		}
       
      -		if(isset($entry->updated))
      +		if (isset($entry->updated)) {
       			$updated = date("Y-m-d H:i:s", strtotime($entry->updated));
      +		}
       
      -		if(isset($entry->network))
      +		if (isset($entry->network)) {
       			$network = $entry->network;
      +		}
       
      -		if(isset($entry->currentLocation))
      +		if (isset($entry->currentLocation)) {
       			$location = $entry->currentLocation;
      +		}
       
      -		if(isset($entry->aboutMe))
      +		if (isset($entry->aboutMe)) {
       			$about = html2bbcode($entry->aboutMe);
      +		}
       
      -		if(isset($entry->gender))
      +		if (isset($entry->gender)) {
       			$gender = $entry->gender;
      +		}
       
      -		if(isset($entry->generation) AND ($entry->generation > 0))
      +		if (isset($entry->generation) AND ($entry->generation > 0)) {
       			$generation = ++$entry->generation;
      +		}
       
      -		if(isset($entry->tags))
      -			foreach($entry->tags as $tag)
      +		if (isset($entry->tags)) {
      +			foreach($entry->tags as $tag) {
       				$keywords = implode(", ", $tag);
      +			}
      +		}
       
      -		if(isset($entry->contactType) AND ($entry->contactType >= 0))
      +		if (isset($entry->contactType) AND ($entry->contactType >= 0))
       			$contact_type = $entry->contactType;
       
       		// If you query a Friendica server for its profiles, the network has to be Friendica
      @@ -171,8 +179,6 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
       
       function poco_check($profile_url, $name, $network, $profile_photo, $about, $location, $gender, $keywords, $connect_url, $updated, $generation, $cid = 0, $uid = 0, $zcid = 0) {
       
      -	$a = get_app();
      -
       	// Generation:
       	//  0: No definition
       	//  1: Profiles on this server
      @@ -1186,12 +1192,12 @@ function update_suggestions() {
       
       	$done[] = App::get_baseurl() . '/poco';
       
      -	if(strlen(get_config('system','directory'))) {
      +	if (strlen(get_config('system','directory'))) {
       		$x = fetch_url(get_server()."/pubsites");
       		if ($x) {
       			$j = json_decode($x);
       			if ($j->entries) {
      -				foreach($j->entries as $entry) {
      +				foreach ($j->entries as $entry) {
       
       					poco_check_server($entry->url);
       
      @@ -1210,7 +1216,7 @@ function update_suggestions() {
       	);
       
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$base = substr($rr['poco'],0,strrpos($rr['poco'],'/'));
       			if(! in_array($base,$done))
       				poco_load(0,0,0,$base);
      @@ -1221,7 +1227,7 @@ function update_suggestions() {
       function poco_discover_federation() {
       	$last = get_config('poco','last_federation_discovery');
       
      -	if($last) {
      +	if ($last) {
       		$next = $last + (24 * 60 * 60);
       		if($next > time())
       			return;
      @@ -1377,7 +1383,7 @@ function poco_discover_server($data, $default_generation = 0) {
       
       		$name = $entry->displayName;
       
      -		if(isset($entry->urls)) {
      +		if (isset($entry->urls)) {
       			foreach($entry->urls as $url) {
       				if ($url->type == 'profile') {
       					$profile_url = $url->value;
      @@ -1390,39 +1396,48 @@ function poco_discover_server($data, $default_generation = 0) {
       			}
       		}
       
      -		if(isset($entry->photos)) {
      -			foreach($entry->photos as $photo) {
      -				if($photo->type == 'profile') {
      +		if (isset($entry->photos)) {
      +			foreach ($entry->photos as $photo) {
      +				if ($photo->type == 'profile') {
       					$profile_photo = $photo->value;
       					continue;
       				}
       			}
       		}
       
      -		if(isset($entry->updated))
      +		if (isset($entry->updated)) {
       			$updated = date("Y-m-d H:i:s", strtotime($entry->updated));
      +		}
       
      -		if(isset($entry->network))
      +		if(isset($entry->network)) {
       			$network = $entry->network;
      +		}
       
      -		if(isset($entry->currentLocation))
      +		if(isset($entry->currentLocation)) {
       			$location = $entry->currentLocation;
      +		}
       
      -		if(isset($entry->aboutMe))
      +		if(isset($entry->aboutMe)) {
       			$about = html2bbcode($entry->aboutMe);
      +		}
       
      -		if(isset($entry->gender))
      +		if(isset($entry->gender)) {
       			$gender = $entry->gender;
      +		}
       
      -		if(isset($entry->generation) AND ($entry->generation > 0))
      +		if(isset($entry->generation) AND ($entry->generation > 0)) {
       			$generation = ++$entry->generation;
      +		}
       
      -		if(isset($entry->contactType) AND ($entry->contactType >= 0))
      +		if(isset($entry->contactType) AND ($entry->contactType >= 0)) {
       			$contact_type = $entry->contactType;
      +		}
       
      -		if(isset($entry->tags))
      -			foreach($entry->tags as $tag)
      +		if(isset($entry->tags)) {
      +			foreach ($entry->tags as $tag) {
       				$keywords = implode(", ", $tag);
      +			}
      +		}
       
       		if ($generation > 0) {
       			$success = true;
      diff --git a/index.php b/index.php
      index 39e8c583a0..f05151757b 100644
      --- a/index.php
      +++ b/index.php
      @@ -152,22 +152,26 @@ if((x($_GET,'zrl')) && (!$install && !$maintenance)) {
       
       // header('Link: <' . App::get_baseurl() . '/amcd>; rel="acct-mgmt";');
       
      -if(x($_COOKIE["Friendica"]) || (x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login'))
      +if (x($_COOKIE["Friendica"]) || (x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login')) {
       	require("include/auth.php");
      +}
       
      -if(! x($_SESSION,'authenticated'))
      +if (! x($_SESSION,'authenticated')) {
       	header('X-Account-Management-Status: none');
      +}
       
       /* set up page['htmlhead'] and page['end'] for the modules to use */
       $a->page['htmlhead'] = '';
       $a->page['end'] = '';
       
       
      -if(! x($_SESSION,'sysmsg'))
      +if (! x($_SESSION,'sysmsg')) {
       	$_SESSION['sysmsg'] = array();
      +}
       
      -if(! x($_SESSION,'sysmsg_info'))
      +if (! x($_SESSION,'sysmsg_info')) {
       	$_SESSION['sysmsg_info'] = array();
      +}
       
       /*
        * check_config() is responsible for running update scripts. These automatically
      @@ -177,11 +181,11 @@ if(! x($_SESSION,'sysmsg_info'))
       
       // in install mode, any url loads install module
       // but we need "view" module for stylesheet
      -if($install && $a->module!="view")
      +if ($install && $a->module!="view") {
       	$a->module = 'install';
      -elseif($maintenance && $a->module!="view")
      +} elseif ($maintenance && $a->module!="view") {
       	$a->module = 'maintenance';
      -else {
      +} else {
       	check_url($a);
       	check_db();
       	check_plugins($a);
      @@ -191,8 +195,7 @@ nav_set_selected('nothing');
       
       //Don't populate apps_menu if apps are private
       $privateapps = get_config('config','private_addons');
      -if((local_user()) || (! $privateapps === "1"))
      -{
      +if ((local_user()) || (! $privateapps === "1")) {
       	$arr = array('app_menu' => $a->apps);
       
       	call_hooks('app_menu', $arr);
      @@ -238,9 +241,9 @@ if(strlen($a->module)) {
       
       	$privateapps = get_config('config','private_addons');
       
      -	if(is_array($a->plugins) && in_array($a->module,$a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) {
      +	if (is_array($a->plugins) && in_array($a->module,$a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) {
       		//Check if module is an app and if public access to apps is allowed or not
      -		if((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") {
      +		if ((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") {
       			info( t("You must be logged in to use addons. "));
       		}
       		else {
      @@ -254,7 +257,7 @@ if(strlen($a->module)) {
       	 * If not, next look for a 'standard' program module in the 'mod' directory
       	 */
       
      -	if((! $a->module_loaded) && (file_exists("mod/{$a->module}.php"))) {
      +	if ((! $a->module_loaded) && (file_exists("mod/{$a->module}.php"))) {
       		include_once("mod/{$a->module}.php");
       		$a->module_loaded = true;
       	}
      @@ -272,14 +275,14 @@ if(strlen($a->module)) {
       	 *
       	 */
       
      -	if(! $a->module_loaded) {
      +	if (! $a->module_loaded) {
       
       		// Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit.
      -		if((x($_SERVER,'QUERY_STRING')) && preg_match('/{[0-9]}/',$_SERVER['QUERY_STRING']) !== 0) {
      +		if ((x($_SERVER,'QUERY_STRING')) && preg_match('/{[0-9]}/',$_SERVER['QUERY_STRING']) !== 0) {
       			killme();
       		}
       
      -		if((x($_SERVER,'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
      +		if ((x($_SERVER,'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
       			logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']);
       			goaway(App::get_baseurl() . $_SERVER['REQUEST_URI']);
       		}
      @@ -304,11 +307,13 @@ if (file_exists($theme_info_file)){
       
       /* initialise content region */
       
      -if(! x($a->page,'content'))
      +if (! x($a->page,'content')) {
       	$a->page['content'] = '';
      +}
       
      -if(!$install && !$maintenance)
      +if (!$install && !$maintenance) {
       	call_hooks('page_content_top',$a->page['content']);
      +}
       
       /**
        * Call module functions
      diff --git a/mod/admin.php b/mod/admin.php
      index 040f55a5a6..26d7da26be 100644
      --- a/mod/admin.php
      +++ b/mod/admin.php
      @@ -1129,19 +1129,19 @@ function admin_page_dbsync(App &$a) {
       			$failed[] = $upd;
       		}
       	}
      -	if(! count($failed)) {
      +	if (! count($failed)) {
       		$o = replace_macros(get_markup_template('structure_check.tpl'),array(
      -			'$base' => App::get_baseurl(true),
      +			'$base'   => App::get_baseurl(true),
       			'$banner' => t('No failed updates.'),
      -			'$check' => t('Check database structure'),
      +			'$check'  => t('Check database structure'),
       		));
       	} else {
       		$o = replace_macros(get_markup_template('failed_updates.tpl'),array(
      -			'$base' => App::get_baseurl(true),
      +			'$base'   => App::get_baseurl(true),
       			'$banner' => t('Failed Updates'),
      -			'$desc' => t('This does not include updates prior to 1139, which did not return a status.'),
      -			'$mark' => t('Mark success (if update was manually applied)'),
      -			'$apply' => t('Attempt to execute this update step automatically'),
      +			'$desc'   => t('This does not include updates prior to 1139, which did not return a status.'),
      +			'$mark'   => t('Mark success (if update was manually applied)'),
      +			'$apply'  => t('Attempt to execute this update step automatically'),
       			'$failed' => $failed
       		));
       	}
      @@ -1156,11 +1156,11 @@ function admin_page_dbsync(App &$a) {
        * @param App $a
        */
       function admin_page_users_post(App &$a){
      -	$pending     =	(x($_POST, 'pending')			? $_POST['pending']		: array());
      -	$users       =	(x($_POST, 'user')			? $_POST['user']		: array());
      -	$nu_name     =	(x($_POST, 'new_user_name')		? $_POST['new_user_name']	: '');
      -	$nu_nickname =	(x($_POST, 'new_user_nickname')		? $_POST['new_user_nickname']	: '');
      -	$nu_email    =	(x($_POST, 'new_user_email')		? $_POST['new_user_email']	: '');
      +	$pending     =	(x($_POST, 'pending')           ? $_POST['pending']           : array());
      +	$users       =	(x($_POST, 'user')              ? $_POST['user']		      : array());
      +	$nu_name     =	(x($_POST, 'new_user_name')     ? $_POST['new_user_name']     : '');
      +	$nu_nickname =	(x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : '');
      +	$nu_email    =	(x($_POST, 'new_user_email')    ? $_POST['new_user_email']    : '');
       	$nu_language = get_config('system', 'language');
       
       	check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
      @@ -1546,7 +1546,7 @@ function admin_page_plugins(App &$a){
       	 * List plugins
       	 */
       
      -	if(x($_GET,"a") && $_GET['a']=="r") {
      +	if (x($_GET,"a") && $_GET['a']=="r") {
       		check_form_security_token_redirectOnErr(App::get_baseurl().'/admin/plugins', 'admin_themes', 't');
       		reload_plugins();
       		info("Plugins reloaded");
      @@ -1555,23 +1555,26 @@ function admin_page_plugins(App &$a){
       
       	$plugins = array();
       	$files = glob("addon/*/");
      -	if($files) {
      -		foreach($files as $file) {
      -			if(is_dir($file)) {
      +	if ($files) {
      +		foreach ($files as $file) {
      +			if (is_dir($file)) {
       				list($tmp, $id)=array_map("trim", explode("/",$file));
       				$info = get_plugin_info($id);
       				$show_plugin = true;
       
       				// If the addon is unsupported, then only show it, when it is enabled
      -				if((strtolower($info["status"]) == "unsupported") AND !in_array($id,  $a->plugins))
      +				if ((strtolower($info["status"]) == "unsupported") AND !in_array($id,  $a->plugins)) {
       					$show_plugin = false;
      +				}
       
       				// Override the above szenario, when the admin really wants to see outdated stuff
      -				if(get_config("system", "show_unsupported_addons"))
      +				if (get_config("system", "show_unsupported_addons")) {
       					$show_plugin = true;
      +				}
       
      -				if($show_plugin)
      +				if ($show_plugin) {
       					$plugins[] = array($id, (in_array($id,  $a->plugins)?"on":"off") , $info);
      +				}
       			}
       		}
       	}
      @@ -1798,11 +1801,11 @@ function admin_page_themes(App &$a){
       
       
       	// reload active themes
      -	if(x($_GET,"a") && $_GET['a']=="r") {
      +	if (x($_GET,"a") && $_GET['a']=="r") {
       		check_form_security_token_redirectOnErr(App::get_baseurl().'/admin/themes', 'admin_themes', 't');
      -		if($themes) {
      -			foreach($themes as $th) {
      -				if($th['allowed']) {
      +		if ($themes) {
      +			foreach ($themes as $th) {
      +				if ($th['allowed']) {
       					uninstall_theme($th['name']);
       					install_theme($th['name']);
       				}
      @@ -1817,7 +1820,7 @@ function admin_page_themes(App &$a){
       	 */
       
       	$xthemes = array();
      -	if($themes) {
      +	if ($themes) {
       		foreach($themes as $th) {
       			$xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
       		}
      @@ -1826,17 +1829,17 @@ function admin_page_themes(App &$a){
       
       	$t = get_markup_template("admin_plugins.tpl");
       	return replace_macros($t, array(
      -		'$title' => t('Administration'),
      -		'$page' => t('Themes'),
      -		'$submit' => t('Save Settings'),
      -		'$reload' => t('Reload active themes'),
      -		'$baseurl' => App::get_baseurl(true),
      -		'$function' => 'themes',
      -		'$plugins' => $xthemes,
      -		'$pcount' => count($themes),
      -		'$noplugshint' => sprintf(t('No themes found on the system. They should be paced in %1$s'),'/view/themes'),
      -		'$experimental' => t('[Experimental]'),
      -		'$unsupported' => t('[Unsupported]'),
      +		'$title'               => t('Administration'),
      +		'$page'                => t('Themes'),
      +		'$submit'              => t('Save Settings'),
      +		'$reload'              => t('Reload active themes'),
      +		'$baseurl'             => App::get_baseurl(true),
      +		'$function'            => 'themes',
      +		'$plugins'             => $xthemes,
      +		'$pcount'              => count($themes),
      +		'$noplugshint'         => sprintf(t('No themes found on the system. They should be paced in %1$s'),'/view/themes'),
      +		'$experimental'        => t('[Experimental]'),
      +		'$unsupported'         => t('[Unsupported]'),
       		'$form_security_token' => get_form_security_token("admin_themes"),
       	));
       }
      diff --git a/mod/allfriends.php b/mod/allfriends.php
      index f9cffcbb2d..0682b2dd41 100644
      --- a/mod/allfriends.php
      +++ b/mod/allfriends.php
      @@ -29,8 +29,8 @@ function allfriends_content(App &$a) {
       	);
       
       	if (! count($c)) {
      -	}
       		return;
      +	}
       
       	$a->page['aside'] = "";
       	profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"]));
      diff --git a/mod/cal.php b/mod/cal.php
      index 48ba06ed6c..e6c9c72249 100644
      --- a/mod/cal.php
      +++ b/mod/cal.php
      @@ -231,7 +231,7 @@ function cal_content(App &$a) {
       			$r = sort_by_date($r);
       			foreach($r as $rr) {
       				$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
      -				if(! x($links,$j)) {
      +				if (! x($links,$j)) {
       					$links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;
       				}
       			}
      diff --git a/mod/delegate.php b/mod/delegate.php
      index 8470a7ba0b..1f261bb716 100644
      --- a/mod/delegate.php
      +++ b/mod/delegate.php
      @@ -13,7 +13,7 @@ function delegate_content(App &$a) {
       		return;
       	}
       
      -	if($a->argc > 2 && $a->argv[1] === 'add' && intval($a->argv[2])) {
      +	if ($a->argc > 2 && $a->argv[1] === 'add' && intval($a->argv[2])) {
       
       		// delegated admins can view but not change delegation permissions
       
      @@ -42,7 +42,7 @@ function delegate_content(App &$a) {
       		goaway(App::get_baseurl() . '/delegate');
       	}
       
      -	if($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) {
      +	if ($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) {
       
       		// delegated admins can view but not change delegation permissions
       
      diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php
      index ba8e27431f..22d4c15358 100644
      --- a/mod/dfrn_confirm.php
      +++ b/mod/dfrn_confirm.php
      @@ -506,10 +506,11 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
       		// Let's send our user to the contact editor in case they want to
       		// do anything special with this new friend.
       
      -		if($handsfree === null)
      +		if ($handsfree === null) {
       			goaway(App::get_baseurl() . '/contacts/' . intval($contact_id));
      -		else
      +		} else {
       			return;
      +		}
       		//NOTREACHED
       	}
       
      @@ -525,7 +526,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
       	 *
       	 */
       
      -	if(x($_POST,'source_url')) {
      +	if (x($_POST,'source_url')) {
       
       		// We are processing an external confirmation to an introduction created by our user.
       
      @@ -546,7 +547,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
       
       		// If $aes_key is set, both of these items require unpacking from the hex transport encoding.
       
      -		if(x($aes_key)) {
      +		if (x($aes_key)) {
       			$aes_key = hex2bin($aes_key);
       			$public_key = hex2bin($public_key);
       		}
      diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php
      index d5e8abe906..3a5711d0f7 100644
      --- a/mod/dfrn_request.php
      +++ b/mod/dfrn_request.php
      @@ -120,17 +120,19 @@ function dfrn_request_post(App &$a) {
       
       					$parms = Probe::profile($dfrn_url);
       
      -					if(! count($parms)) {
      +					if (! count($parms)) {
       						notice( t('Profile location is not valid or does not contain profile information.') . EOL );
       						return;
       					}
       					else {
      -						if(! x($parms,'fn'))
      +						if (! x($parms,'fn')) {
       							notice( t('Warning: profile location has no identifiable owner name.') . EOL );
      -						if(! x($parms,'photo'))
      +						}
      +						if (! x($parms,'photo')) {
       							notice( t('Warning: profile location has no profile photo.') . EOL );
      +						}
       						$invalid = Probe::valid_dfrn($parms);
      -						if($invalid) {
      +						if ($invalid) {
       							notice( sprintf( tt("%d required parameter was not found at the given location",
       												"%d required parameters were not found at the given location",
       												$invalid), $invalid) . EOL );
      @@ -502,13 +504,13 @@ function dfrn_request_post(App &$a) {
       				);
       			}
       			else {
      -				if(! validate_url($url)) {
      +				if (! validate_url($url)) {
       					notice( t('Invalid profile URL.') . EOL);
       					goaway(App::get_baseurl() . '/' . $a->cmd);
       					return; // NOTREACHED
       				}
       
      -				if(! allowed_url($url)) {
      +				if (! allowed_url($url)) {
       					notice( t('Disallowed profile URL.') . EOL);
       					goaway(App::get_baseurl() . '/' . $a->cmd);
       					return; // NOTREACHED
      @@ -519,17 +521,19 @@ function dfrn_request_post(App &$a) {
       
       				$parms = Probe::profile(($hcard) ? $hcard : $url);
       
      -				if(! count($parms)) {
      +				if (! count($parms)) {
       					notice( t('Profile location is not valid or does not contain profile information.') . EOL );
       					goaway(App::get_baseurl() . '/' . $a->cmd);
       				}
       				else {
      -					if(! x($parms,'fn'))
      +					if (! x($parms,'fn')) {
       						notice( t('Warning: profile location has no identifiable owner name.') . EOL );
      -					if(! x($parms,'photo'))
      +					}
      +					if (! x($parms,'photo')) {
       						notice( t('Warning: profile location has no profile photo.') . EOL );
      +					}
       					$invalid = Probe::valid_dfrn($parms);
      -					if($invalid) {
      +					if ($invalid) {
       						notice( sprintf( tt("%d required parameter was not found at the given location",
       											"%d required parameters were not found at the given location",
       											$invalid), $invalid) . EOL );
      @@ -810,15 +814,18 @@ function dfrn_request_content(App &$a) {
       			$myaddr = hex2bin($_GET['addr']);
       		elseif (x($_GET,'address') AND ($_GET['address'] != ""))
       			$myaddr = $_GET['address'];
      -		elseif(local_user()) {
      -			if(strlen($a->path)) {
      +		elseif (local_user()) {
      +			if (strlen($a->path)) {
       				$myaddr = App::get_baseurl() . '/profile/' . $a->user['nickname'];
       			}
       			else {
       				$myaddr = $a->user['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 );
       			}
      -		} else	// last, try a zrl
      +		}
      +		else {
      +			// last, try a zrl
       			$myaddr = get_my_url();
      +		}
       
       		$target_addr = $a->profile['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 );
       
      @@ -831,10 +838,12 @@ function dfrn_request_content(App &$a) {
       		 *
       		 */
       
      -		if($a->profile['page-flags'] == PAGE_NORMAL)
      +		if ($a->profile['page-flags'] == PAGE_NORMAL) {
       			$tpl = get_markup_template('dfrn_request.tpl');
      -		else
      +		}
      +		else {
       			$tpl = get_markup_template('auto_request.tpl');
      +		}
       
       		$page_desc = t("Please enter your 'Identity Address' from one of the following supported communications networks:");
       
      diff --git a/mod/dirfind.php b/mod/dirfind.php
      index fc5750f2dd..2b2badb640 100644
      --- a/mod/dirfind.php
      +++ b/mod/dirfind.php
      @@ -12,8 +12,9 @@ function dirfind_init(App &$a) {
       		return;
       	}
       
      -	if(! x($a->page,'aside'))
      +	if (! x($a->page,'aside')) {
       		$a->page['aside'] = '';
      +	}
       
       	$a->page['aside'] .= findpeople_widget();
       
      @@ -31,7 +32,7 @@ function dirfind_content(&$a, $prefix = "") {
       
       	$search = $prefix.notags(trim($_REQUEST['search']));
       
      -	if(strpos($search,'@') === 0) {
      +	if (strpos($search,'@') === 0) {
       		$search = substr($search,1);
       		$header = sprintf( t('People Search - %s'), $search);
       		if ((valid_email($search) AND validate_email($search)) OR
      @@ -41,7 +42,7 @@ function dirfind_content(&$a, $prefix = "") {
       		}
       	}
       
      -	if(strpos($search,'!') === 0) {
      +	if (strpos($search,'!') === 0) {
       		$search = substr($search,1);
       		$community = true;
       		$header = sprintf( t('Forum Search - %s'), $search);
      @@ -49,7 +50,7 @@ function dirfind_content(&$a, $prefix = "") {
       
       	$o = '';
       
      -	if($search) {
      +	if ($search) {
       
       		if ($discover_user) {
       			$j = new stdClass();
      @@ -85,15 +86,19 @@ function dirfind_content(&$a, $prefix = "") {
       			$perpage = 80;
       			$startrec = (($a->pager['page']) * $perpage) - $perpage;
       
      -			if (get_config('system','diaspora_enabled'))
      +			if (get_config('system','diaspora_enabled')) {
       				$diaspora = NETWORK_DIASPORA;
      -			else
      +			}
      +			else {
       				$diaspora = NETWORK_DFRN;
      +			}
       
      -			if (!get_config('system','ostatus_disabled'))
      +			if (!get_config('system','ostatus_disabled')) {
       				$ostatus = NETWORK_OSTATUS;
      -			else
      +			}
      +			else {
       				$ostatus = NETWORK_DFRN;
      +			}
       
       			$search2 = "%".$search."%";
       
      @@ -133,8 +138,9 @@ function dirfind_content(&$a, $prefix = "") {
       			$j->items_page = $perpage;
       			$j->page = $a->pager['page'];
       			foreach ($results AS $result) {
      -				if (poco_alternate_ostatus_url($result["url"]))
      -					 continue;
      +				if (poco_alternate_ostatus_url($result["url"])) {
      +					continue;
      +				}
       
       				$result = get_contact_details_by_url($result["url"], local_user(), $result);
       
      @@ -167,16 +173,16 @@ function dirfind_content(&$a, $prefix = "") {
       			$j = json_decode($x);
       		}
       
      -		if($j->total) {
      +		if ($j->total) {
       			$a->set_pager_total($j->total);
       			$a->set_pager_itemspage($j->items_page);
       		}
       
      -		if(count($j->results)) {
      +		if (count($j->results)) {
       
       			$id = 0;
       
      -			foreach($j->results as $jj) {
      +			foreach ($j->results as $jj) {
       
       				$alt_text = "";
       
      @@ -194,8 +200,10 @@ function dirfind_content(&$a, $prefix = "") {
       						$photo_menu = contact_photo_menu($contact[0]);
       						$details = _contact_detail_for_template($contact[0]);
       						$alt_text = $details['alt_text'];
      -					} else
      +					}
      +					else {
       						$photo_menu = array();
      +					}
       				} else {
       					$connlnk = App::get_baseurl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url);
       					$conntxt = t('Connect');
      diff --git a/mod/events.php b/mod/events.php
      index 0c1e9ae2f5..6bf7da6a28 100644
      --- a/mod/events.php
      +++ b/mod/events.php
      @@ -254,15 +254,15 @@ function events_content(App &$a) {
       	$ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0);
       
       	if($a->argc > 1) {
      -		if($a->argc > 2 && $a->argv[1] == 'event') {
      +		if ($a->argc > 2 && $a->argv[1] == 'event') {
       			$mode = 'edit';
       			$event_id = intval($a->argv[2]);
       		}
      -		if($a->argv[1] === 'new') {
      +		if ($a->argv[1] === 'new') {
       			$mode = 'new';
       			$event_id = 0;
       		}
      -		if($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
      +		if ($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
       			$mode = 'view';
       			$y = intval($a->argv[1]);
       			$m = intval($a->argv[2]);
      @@ -270,23 +270,27 @@ function events_content(App &$a) {
       	}
       
       	// The view mode part is similiar to /mod/cal.php
      -	if($mode == 'view') {
      +	if ($mode == 'view') {
       
       
       		$thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
       		$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
      -		if(! $y)
      +		if (! $y) {
       			$y = intval($thisyear);
      -		if(! $m)
      +		}
      +		if (! $m) {
       			$m = intval($thismonth);
      +		}
       
       		// Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
       		// An upper limit was chosen to keep search engines from exploring links millions of years in the future.
       
      -		if($y < 1901)
      +		if ($y < 1901) {
       			$y = 1900;
      -		if($y > 2099)
      +		}
      +		if ($y > 2099) {
       			$y = 2100;
      +		}
       
       		$nextyear = $y;
       		$nextmonth = $m + 1;
      @@ -342,7 +346,7 @@ function events_content(App &$a) {
       			$r = sort_by_date($r);
       			foreach($r as $rr) {
       				$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
      -				if(! x($links,$j)) {
      +				if (! x($links,$j)) {
       					$links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;
       				}
       			}
      diff --git a/mod/settings.php b/mod/settings.php
      index 9aa7c57624..515a97c14d 100644
      --- a/mod/settings.php
      +++ b/mod/settings.php
      @@ -1170,13 +1170,14 @@ function settings_content(App &$a) {
       		));
       	}
       
      -	if(strlen(get_config('system','directory'))) {
      +	if (strlen(get_config('system','directory'))) {
       		$profile_in_net_dir = replace_macros($opt_tpl,array(
       			'$field' 	=> array('profile_in_netdirectory', t('Publish your default profile in the global social directory?'), $profile['net-publish'], '', array(t('No'),t('Yes'))),
       		));
       	}
      -	else
      +	else {
       		$profile_in_net_dir = '';
      +	}
       
       
       	$hide_friends = replace_macros($opt_tpl,array(
      
      From 4edc73486e99f3921f871d889c9cf5de4351e3b5 Mon Sep 17 00:00:00 2001
      From: Roland Haeder 
      Date: Tue, 20 Dec 2016 21:13:50 +0100
      Subject: [PATCH 52/96] 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 
      ---
       include/acl_selectors.php     | 22 ++++++++++++--------
       include/api.php               |  4 ++--
       include/bbcode.php            |  2 +-
       include/contact_selectors.php |  2 +-
       include/contact_widgets.php   |  8 ++++---
       include/conversation.php      |  2 +-
       include/datetime.php          |  2 +-
       include/diaspora.php          | 14 ++++++-------
       include/expire.php            |  2 +-
       include/group.php             |  6 +++---
       include/identity.php          |  6 +++---
       include/message.php           | 39 +++++++++++++++++++----------------
       include/notifier.php          |  4 ++--
       include/plugin.php            |  3 ++-
       include/pubsubpublish.php     | 14 ++++++++-----
       include/queue.php             | 13 ++++++------
       include/text.php              |  4 ++--
       include/user.php              |  2 +-
       18 files changed, 82 insertions(+), 67 deletions(-)
      
      diff --git a/include/acl_selectors.php b/include/acl_selectors.php
      index c1edc8cc03..b2e66c98f0 100644
      --- a/include/acl_selectors.php
      +++ b/include/acl_selectors.php
      @@ -34,7 +34,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
       	call_hooks($a->module . '_pre_' . $selname, $arr);
       
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			if((is_array($preselected)) && in_array($rr['id'], $preselected))
       				$selected = " selected=\"selected\" ";
       			else
      @@ -145,7 +145,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
       	call_hooks($a->module . '_pre_' . $selname, $arr);
       
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			if((is_array($preselected)) && in_array($rr['id'], $preselected))
       				$selected = " selected=\"selected\" ";
       			else
      @@ -221,16 +221,20 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
       	$receiverlist = array();
       
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      -			if((is_array($preselected)) && in_array($rr['id'], $preselected))
      +		foreach ($r as $rr) {
      +			if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
       				$selected = " selected=\"selected\" ";
      -			else
      +			}
      +			else {
       				$selected = '';
      +			}
       
      -			if($privmail)
      +			if ($privmail) {
       				$trimmed = GetProfileUsername($rr['url'], $rr['name'], false);
      -			else
      +			}
      +			else {
       				$trimmed = mb_substr($rr['name'],0,20);
      +			}
       
       			$receiverlist[] = $trimmed;
       
      @@ -260,7 +264,7 @@ function prune_deadguys($arr) {
       		return $arr;
       	$str = dbesc(implode(',',$arr));
       	$r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 ");
      -	if($r) {
      +	if ($r) {
       		$ret = array();
       		foreach($r as $rr)
       			$ret[] = intval($rr['id']);
      @@ -554,7 +558,7 @@ function acl_lookup(&$a, $out_type = 'json') {
       		// autocomplete for global contact search (e.g. navbar search)
       		$r = navbar_complete($a);
       		$contacts = array();
      -		if($r) {
      +		if ($r) {
       			foreach($r as $g) {
       				$contacts[] = array(
       					"photo"    => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
      diff --git a/include/api.php b/include/api.php
      index a450f867a5..35efccf090 100644
      --- a/include/api.php
      +++ b/include/api.php
      @@ -3068,8 +3068,8 @@
       		'image/gif' => 'gif'
       		);
       		$data = array('photo'=>array());
      -		if($r) {
      -			foreach($r as $rr) {
      +		if ($r) {
      +			foreach ($r as $rr) {
       				$photo = array();
       				$photo['id'] = $rr['resource-id'];
       				$photo['album'] = $rr['album'];
      diff --git a/include/bbcode.php b/include/bbcode.php
      index c05173f47c..74dde2fdf4 100644
      --- a/include/bbcode.php
      +++ b/include/bbcode.php
      @@ -343,7 +343,7 @@ function bb_replace_images($body, $images) {
       	$newbody = $body;
       
       	$cnt = 0;
      -	foreach($images as $image) {
      +	foreach ($images as $image) {
       		// We're depending on the property of 'foreach' (specified on the PHP website) that
       		// it loops over the array starting from the first element and going sequentially
       		// to the last element
      diff --git a/include/contact_selectors.php b/include/contact_selectors.php
      index 0790e503ea..ec9dff61d5 100644
      --- a/include/contact_selectors.php
      +++ b/include/contact_selectors.php
      @@ -13,7 +13,7 @@ function contact_profile_assign($current,$foreign_net) {
       			intval($_SESSION['uid']));
       
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$selected = (($rr['id'] == $current) ? " selected=\"selected\" " : "");
       			$o .= "\r\n";
       		}
      diff --git a/include/contact_widgets.php b/include/contact_widgets.php
      index 71a75d431e..36675da873 100644
      --- a/include/contact_widgets.php
      +++ b/include/contact_widgets.php
      @@ -97,9 +97,11 @@ function networks_widget($baseurl,$selected = '') {
       	$nets = array();
       	if (dbm::is_result($r)) {
       		require_once('include/contact_selectors.php');
      -		foreach($r as $rr) {
      -				if($rr['network'])
      -					$nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
      +		foreach ($r as $rr) {
      +			/// @TODO If 'network' is not there, this triggers an E_NOTICE
      +			if ($rr['network']) {
      +				$nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
      +			}
       		}
       	}
       
      diff --git a/include/conversation.php b/include/conversation.php
      index ccfc070d4e..36eded8e8a 100644
      --- a/include/conversation.php
      +++ b/include/conversation.php
      @@ -78,7 +78,7 @@ function item_redir_and_replace_images($body, $images, $cid) {
       	$newbody .= $origbody;
       
       	$cnt = 0;
      -	foreach($images as $image) {
      +	foreach ($images as $image) {
       		// We're depending on the property of 'foreach' (specified on the PHP website) that
       		// it loops over the array starting from the first element and going sequentially
       		// to the last element
      diff --git a/include/datetime.php b/include/datetime.php
      index e88c274ab9..a17c405dc3 100644
      --- a/include/datetime.php
      +++ b/include/datetime.php
      @@ -553,7 +553,7 @@ function update_contact_birthdays() {
       
       	$r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` != '0000-00-00' AND SUBSTRING(`bd`,1,4) != `bdyear` ");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       
       			logger('update_contact_birthday: ' . $rr['bd']);
       
      diff --git a/include/diaspora.php b/include/diaspora.php
      index 3b4832e74f..cfb624fdf2 100644
      --- a/include/diaspora.php
      +++ b/include/diaspora.php
      @@ -319,8 +319,8 @@ class diaspora {
       			dbesc(NETWORK_DIASPORA),
       			dbesc($msg["author"])
       		);
      -		if($r) {
      -			foreach($r as $rr) {
      +		if ($r) {
      +			foreach ($r as $rr) {
       				logger("delivering to: ".$rr["username"]);
       				self::dispatch($rr,$msg);
       			}
      @@ -806,7 +806,7 @@ class diaspora {
       			dbesc($guid)
       		);
       
      -		if($r) {
      +		if ($r) {
       			logger("message ".$guid." already exists for user ".$uid);
       			return $r[0]["id"];
       		}
      @@ -1577,7 +1577,7 @@ class diaspora {
       			dbesc($message_uri),
       			intval($importer["uid"])
       		);
      -		if($r) {
      +		if ($r) {
       			logger("duplicate message already delivered.", LOGGER_DEBUG);
       			return false;
       		}
      @@ -2022,7 +2022,7 @@ class diaspora {
       				FROM `item` WHERE `guid` = '%s' AND `visible` AND NOT `deleted` AND `body` != '' LIMIT 1",
       			dbesc($guid));
       
      -		if($r) {
      +		if ($r) {
       			logger("reshared message ".$guid." already exists on system.");
       
       			// Maybe it is already a reshared item?
      @@ -2623,7 +2623,7 @@ class diaspora {
       
       		logger("transmit: ".$logid."-".$guid." returns: ".$return_code);
       
      -		if(!$return_code || (($return_code == 503) && (stristr($a->get_curl_headers(), "retry-after")))) {
      +		if (!$return_code || (($return_code == 503) && (stristr($a->get_curl_headers(), "retry-after")))) {
       			logger("queue message");
       
       			$r = q("SELECT `id` FROM `queue` WHERE `cid` = %d AND `network` = '%s' AND `content` = '%s' AND `batch` = %d LIMIT 1",
      @@ -2632,7 +2632,7 @@ class diaspora {
       				dbesc($slap),
       				intval($public_batch)
       			);
      -			if($r) {
      +			if ($r) {
       				logger("add_to_queue ignored - identical item already in queue");
       			} else {
       				// queue message for redelivery
      diff --git a/include/expire.php b/include/expire.php
      index eca2b1c42a..e3313a78be 100644
      --- a/include/expire.php
      +++ b/include/expire.php
      @@ -40,7 +40,7 @@ function expire_run(&$argv, &$argc){
       
       	$r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
       			item_expire($rr['uid'],$rr['expire']);
       		}
      diff --git a/include/group.php b/include/group.php
      index a2a55c4440..6332c45da2 100644
      --- a/include/group.php
      +++ b/include/group.php
      @@ -53,7 +53,7 @@ function group_rmv($uid,$name) {
       		$r = q("SELECT def_gid, allow_gid, deny_gid FROM user WHERE uid = %d LIMIT 1",
       		       intval($uid)
       		);
      -		if($r) {
      +		if ($r) {
       			$user_info = $r[0];
       			$change = false;
       
      @@ -199,7 +199,7 @@ function mini_group_select($uid,$gid = 0, $label = "") {
       	);
       	$grps[] = array('name' => '', 'id' => '0', 'selected' => '');
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$grps[] = array('name' => $rr['name'], 'id' => $rr['id'], 'selected' => (($gid == $rr['id']) ? 'true' : ''));
       		}
       
      @@ -257,7 +257,7 @@ function group_side($every="contacts",$each="group",$editmode = "standard", $gro
       	}
       
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$selected = (($group_id == $rr['id']) ? ' group-selected' : '');
       
       			if ($editmode == "full") {
      diff --git a/include/identity.php b/include/identity.php
      index 380560228a..35516efbea 100644
      --- a/include/identity.php
      +++ b/include/identity.php
      @@ -294,7 +294,7 @@ function profile_sidebar($profile, $block = 0) {
       
       		if (dbm::is_result($r)) {
       
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				$profile['menu']['entries'][] = array(
       					'photo' => $rr['thumb'],
       					'id' => $rr['id'],
      @@ -469,7 +469,7 @@ function get_birthdays() {
       		$cids = array();
       
       		$istoday = false;
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			if(strlen($rr['name']))
       				$total ++;
       			if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now))
      @@ -549,7 +549,7 @@ function get_events() {
       	if (dbm::is_result($r)) {
       		$now = strtotime('now');
       		$istoday = false;
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			if(strlen($rr['name']))
       				$total ++;
       
      diff --git a/include/message.php b/include/message.php
      index e5ebe6f915..5bd611f220 100644
      --- a/include/message.php
      +++ b/include/message.php
      @@ -130,12 +130,13 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
       
       	$match = null;
       
      -	if(preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) {
      +	if (preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) {
       		$images = $match[1];
      -		if(count($images)) {
      -			foreach($images as $image) {
      -				if(! stristr($image,App::get_baseurl() . '/photo/'))
      +		if (count($images)) {
      +			foreach ($images as $image) {
      +				if (! stristr($image,App::get_baseurl() . '/photo/')) {
       					continue;
      +				}
       				$image_uri = substr($image,strrpos($image,'/') + 1);
       				$image_uri = substr($image_uri,0, strpos($image_uri,'-'));
       				$r = q("UPDATE `photo` SET `allow_cid` = '%s'
      @@ -149,25 +150,25 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
       		}
       	}
       
      -	if($post_id) {
      +	if ($post_id) {
       		proc_run(PRIORITY_HIGH, "include/notifier.php", "mail", $post_id);
       		return intval($post_id);
      -	} else {
      +	}
      +	else {
       		return -3;
       	}
       
       }
       
      -
      -
      -
      -
       function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
       
      -	if(! $recipient) return -1;
      +	if (! $recipient) {
      +		return -1;
      +	}
       
      -	if(! strlen($subject))
      +	if (! strlen($subject)) {
       		$subject = t('[no subject]');
      +	}
       
       	$guid = get_guid(32);
        	$uri = 'urn:X-dfrn:' . App::get_baseurl() . ':' . local_user() . ':' . $guid;
      @@ -179,8 +180,9 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
       
       	$me = probe_url($replyto);
       
      -	if(! $me['name'])
      +	if (! $me['name']) {
       		return -2;
      +	}
       
       	$conv_guid = get_guid(32);
       
      @@ -193,7 +195,7 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
       
       	$handles = $recip_handle . ';' . $sender_handle;
       
      -	$r = q("insert into conv (uid,guid,creator,created,updated,subject,recips) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ",
      +	$r = q("INSERT INTO `conv` (`uid`,`guid`,`creator`,`created`,`updated`,`subject`,`recips`) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ",
       		intval($recipient['uid']),
       		dbesc($conv_guid),
       		dbesc($sender_handle),
      @@ -203,18 +205,19 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
       		dbesc($handles)
       	);
       
      -	$r = q("select * from conv where guid = '%s' and uid = %d limit 1",
      +	$r = q("SELECT * FROM `conv` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
       		dbesc($conv_guid),
       		intval($recipient['uid'])
       	);
      -	if (dbm::is_result($r))
      -		$convid = $r[0]['id'];
       
      -	if(! $convid) {
      +
      +	if (! dbm::is_result($r)) {
       		logger('send message: conversation not found.');
       		return -4;
       	}
       
      +	$convid = $r[0]['id'];
      +
       	$r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`,
       		`contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`, `unknown`)
       		VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s', %d )",
      diff --git a/include/notifier.php b/include/notifier.php
      index d78db4055d..72387c98db 100644
      --- a/include/notifier.php
      +++ b/include/notifier.php
      @@ -598,7 +598,7 @@ function notifier_run(&$argv, &$argc){
       
       			// throw everything into the queue in case we get killed
       
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				if((! $mail) && (! $fsuggest) && (! $followup)) {
       					q("INSERT INTO `deliverq` (`cmd`,`item`,`contact`) VALUES ('%s', %d, %d)
       						ON DUPLICATE KEY UPDATE `cmd` = '%s', `item` = %d, `contact` = %d",
      @@ -608,7 +608,7 @@ function notifier_run(&$argv, &$argc){
       				}
       			}
       
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       
       				// except for Diaspora batch jobs
       				// Don't deliver to folks who have already been delivered to
      diff --git a/include/plugin.php b/include/plugin.php
      index 89c783f900..0b9c0166aa 100644
      --- a/include/plugin.php
      +++ b/include/plugin.php
      @@ -187,8 +187,9 @@ function load_hooks() {
       	$a = get_app();
       	$a->hooks = array();
       	$r = q("SELECT * FROM `hook` WHERE 1 ORDER BY `priority` DESC, `file`");
      +
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			if(! array_key_exists($rr['hook'],$a->hooks))
       				$a->hooks[$rr['hook']] = array();
       			$a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
      diff --git a/include/pubsubpublish.php b/include/pubsubpublish.php
      index abf973a284..6bd90bfc21 100644
      --- a/include/pubsubpublish.php
      +++ b/include/pubsubpublish.php
      @@ -76,16 +76,19 @@ function pubsubpublish_run(&$argv, &$argc){
       	load_config('system');
       
       	// Don't check this stuff if the function is called by the poller
      -	if (App::callstack() != "poller_run")
      -		if (App::is_already_running("pubsubpublish", "include/pubsubpublish.php", 540))
      +	if (App::callstack() != "poller_run") {
      +		if (App::is_already_running("pubsubpublish", "include/pubsubpublish.php", 540)) {
       			return;
      +		}
      +	}
       
       	$a->set_baseurl(get_config('system','url'));
       
       	load_hooks();
       
      -	if($argc > 1)
      +	if ($argc > 1) {
       		$pubsubpublish_id = intval($argv[1]);
      +	}
       	else {
       		// We'll push to each subscriber that has push > 0,
       		// i.e. there has been an update (set in notifier.php).
      @@ -95,10 +98,11 @@ function pubsubpublish_run(&$argv, &$argc){
       		$interval = Config::get("system", "delivery_interval", 2);
       
       		// If we are using the worker we don't need a delivery interval
      -		if (get_config("system", "worker"))
      +		if (get_config("system", "worker")) {
       			$interval = false;
      +		}
       
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			logger("Publish feed to ".$rr["callback_url"], LOGGER_DEBUG);
       			proc_run(PRIORITY_HIGH, 'include/pubsubpublish.php', $rr["id"]);
       
      diff --git a/include/queue.php b/include/queue.php
      index 1cc2ee095b..2ef97fecd4 100644
      --- a/include/queue.php
      +++ b/include/queue.php
      @@ -58,20 +58,21 @@ function queue_run(&$argv, &$argc){
       			$interval = false;
       
       		$r = q("select * from deliverq where 1");
      -		if($r) {
      -			foreach($r as $rr) {
      +		if ($r) {
      +			foreach ($r as $rr) {
       				logger('queue: deliverq');
       				proc_run(PRIORITY_HIGH,'include/delivery.php',$rr['cmd'],$rr['item'],$rr['contact']);
      -				if($interval)
      -				@time_sleep_until(microtime(true) + (float) $interval);
      +				if($interval) {
      +					time_sleep_until(microtime(true) + (float) $interval);
      +				}
       			}
       		}
       
       		$r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`
       			INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
       			WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
      -		if($r) {
      -			foreach($r as $rr) {
      +		if ($r) {
      +			foreach ($r as $rr) {
       				logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']);
       				logger('Expired queue data :' . $rr['content'], LOGGER_DATA);
       			}
      diff --git a/include/text.php b/include/text.php
      index 8d3b6a8050..6672b0d32f 100644
      --- a/include/text.php
      +++ b/include/text.php
      @@ -912,7 +912,7 @@ function contact_block() {
       			if (dbm::is_result($r)) {
       				$contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
       				$micropro = Array();
      -				foreach($r as $rr) {
      +				foreach ($r as $rr) {
       					$micropro[] = micropro($rr,true,'mpfriend');
       				}
       			}
      @@ -1717,7 +1717,7 @@ function bb_translate_video($s) {
       
       	$matches = null;
       	$r = preg_match_all("/\[video\](.*?)\[\/video\]/ism",$s,$matches,PREG_SET_ORDER);
      -	if($r) {
      +	if ($r) {
       		foreach($matches as $mtch) {
       			if((stristr($mtch[1],'youtube')) || (stristr($mtch[1],'youtu.be')))
       				$s = str_replace($mtch[0],'[youtube]' . $mtch[1] . '[/youtube]',$s);
      diff --git a/include/user.php b/include/user.php
      index d6970d475f..df871c5468 100644
      --- a/include/user.php
      +++ b/include/user.php
      @@ -216,7 +216,7 @@ function create_user($arr) {
       		dbesc($default_service_class)
       	);
       
      -	if($r) {
      +	if ($r) {
       		$r = q("SELECT * FROM `user`
       			WHERE `username` = '%s' AND `password` = '%s' LIMIT 1",
       			dbesc($username),
      
      From d6e57f034834173c5f9917bd87d50d9591e6c39a Mon Sep 17 00:00:00 2001
      From: Roland Haeder 
      Date: Tue, 20 Dec 2016 21:15:53 +0100
      Subject: [PATCH 53/96] 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 
      ---
       mod/admin.php         |  2 +-
       mod/allfriends.php    |  2 +-
       mod/cal.php           |  2 +-
       mod/common.php        |  2 +-
       mod/contacts.php      | 28 +++++++++++++++++-----------
       mod/delegate.php      |  2 +-
       mod/dfrn_request.php  |  6 +++---
       mod/directory.php     |  8 +++++---
       mod/events.php        |  2 +-
       mod/filerm.php        |  9 ++++++---
       mod/follow.php        | 15 ++++++++++-----
       mod/group.php         |  2 +-
       mod/hcard.php         | 23 +++++++++++++----------
       mod/install.php       | 13 ++++++++-----
       mod/invite.php        | 16 +++++++++-------
       mod/item.php          | 32 +++++++++++++++++++-------------
       mod/lostpass.php      |  2 +-
       mod/message.php       |  4 ++--
       mod/network.php       | 20 ++++++++++----------
       mod/nogroup.php       |  2 +-
       mod/noscrape.php      | 28 +++++++++++++++-------------
       mod/openid.php        | 36 +++++++++++++++++++++++-------------
       mod/photos.php        |  4 ++--
       mod/poco.php          |  2 +-
       mod/profile.php       |  2 +-
       mod/profile_photo.php |  2 +-
       mod/profiles.php      | 20 +++++++++++---------
       mod/search.php        |  2 +-
       mod/suggest.php       |  2 +-
       mod/videos.php        |  4 ++--
       mod/viewcontacts.php  |  6 ++++--
       31 files changed, 173 insertions(+), 127 deletions(-)
      
      diff --git a/mod/admin.php b/mod/admin.php
      index 26d7da26be..c502e36fc5 100644
      --- a/mod/admin.php
      +++ b/mod/admin.php
      @@ -1122,7 +1122,7 @@ function admin_page_dbsync(App &$a) {
       	$failed = array();
       	$r = q("SELECT `k`, `v` FROM `config` WHERE `cat` = 'database' ");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$upd = intval(substr($rr['k'],7));
       			if($upd < 1139 || $rr['v'] === 'success')
       				continue;
      diff --git a/mod/allfriends.php b/mod/allfriends.php
      index 0682b2dd41..9e14a67d2e 100644
      --- a/mod/allfriends.php
      +++ b/mod/allfriends.php
      @@ -49,7 +49,7 @@ function allfriends_content(App &$a) {
       
       	$id = 0;
       
      -	foreach($r as $rr) {
      +	foreach ($r as $rr) {
       
       		//get further details of the contact
       		$contact_details = get_contact_details_by_url($rr['url'], $uid, $rr);
      diff --git a/mod/cal.php b/mod/cal.php
      index e6c9c72249..7cb36e7a54 100644
      --- a/mod/cal.php
      +++ b/mod/cal.php
      @@ -229,7 +229,7 @@ function cal_content(App &$a) {
       
       		if (dbm::is_result($r)) {
       			$r = sort_by_date($r);
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
       				if (! x($links,$j)) {
       					$links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;
      diff --git a/mod/common.php b/mod/common.php
      index f3601c0fe6..ab27dc667a 100644
      --- a/mod/common.php
      +++ b/mod/common.php
      @@ -101,7 +101,7 @@ function common_content(App &$a) {
       
       	$id = 0;
       
      -	foreach($r as $rr) {
      +	foreach ($r as $rr) {
       
       		//get further details of the contact
       		$contact_details = get_contact_details_by_url($rr['url'], $uid);
      diff --git a/mod/contacts.php b/mod/contacts.php
      index 4f634bbc1c..f709f9d2fb 100644
      --- a/mod/contacts.php
      +++ b/mod/contacts.php
      @@ -129,10 +129,12 @@ function contacts_batch_actions(App &$a){
       		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']);
      -	else
      +	}
      +	else {
       		goaway('contacts');
      +	}
       
       }
       
      @@ -387,7 +389,7 @@ function contacts_content(App &$a) {
       
       		if($cmd === 'block') {
       			$r = _contact_block($contact_id, $orig_record[0]);
      -			if($r) {
      +			if ($r) {
       				$blocked = (($orig_record[0]['blocked']) ? 0 : 1);
       				info((($blocked) ? t('Contact has been blocked') : t('Contact has been unblocked')).EOL);
       			}
      @@ -398,7 +400,7 @@ function contacts_content(App &$a) {
       
       		if($cmd === 'ignore') {
       			$r = _contact_ignore($contact_id, $orig_record[0]);
      -			if($r) {
      +			if ($r) {
       				$readonly = (($orig_record[0]['readonly']) ? 0 : 1);
       				info((($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')).EOL);
       			}
      @@ -410,7 +412,7 @@ function contacts_content(App &$a) {
       
       		if($cmd === 'archive') {
       			$r = _contact_archive($contact_id, $orig_record[0]);
      -			if($r) {
      +			if ($r) {
       				$archived = (($orig_record[0]['archive']) ? 0 : 1);
       				info((($archived) ? t('Contact has been archived') : t('Contact has been unarchived')).EOL);
       			}
      @@ -449,22 +451,26 @@ function contacts_content(App &$a) {
       				));
       			}
       			// Now check how the user responded to the confirmation query
      -			if($_REQUEST['canceled']) {
      -				if(x($_SESSION,'return_url'))
      +			if ($_REQUEST['canceled']) {
      +				if (x($_SESSION,'return_url')) {
       					goaway('' . $_SESSION['return_url']);
      -				else
      +				}
      +				else {
       					goaway('contacts');
      +				}
       			}
       
       			_contact_drop($contact_id, $orig_record[0]);
       			info( t('Contact has been removed.') . EOL );
      -			if(x($_SESSION,'return_url'))
      +			if (x($_SESSION,'return_url')) {
       				goaway('' . $_SESSION['return_url']);
      -			else
      +			}
      +			else {
       				goaway('contacts');
      +			}
       			return; // NOTREACHED
       		}
      -		if($cmd === 'posts') {
      +		if ($cmd === 'posts') {
       			return contact_posts($a, $contact_id);
       		}
       	}
      diff --git a/mod/delegate.php b/mod/delegate.php
      index 1f261bb716..40618eb324 100644
      --- a/mod/delegate.php
      +++ b/mod/delegate.php
      @@ -107,7 +107,7 @@ function delegate_content(App &$a) {
       	$nicknames = array();
       
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$nicknames[] = "'" . dbesc(basename($rr['nurl'])) . "'";
       		}
       	}
      diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php
      index 3a5711d0f7..b9c1b67446 100644
      --- a/mod/dfrn_request.php
      +++ b/mod/dfrn_request.php
      @@ -178,7 +178,7 @@ function dfrn_request_post(App &$a) {
       					);
       				}
       
      -				if($r) {
      +				if ($r) {
       					info( t("Introduction complete.") . EOL);
       				}
       
      @@ -301,7 +301,7 @@ function dfrn_request_post(App &$a) {
       			dbesc(NETWORK_MAIL2)
       		);
       		if (dbm::is_result($r)) {
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				if(! $rr['rel']) {
       					q("DELETE FROM `contact` WHERE `id` = %d",
       						intval($rr['cid'])
      @@ -326,7 +326,7 @@ function dfrn_request_post(App &$a) {
       			dbesc(NETWORK_MAIL2)
       		);
       		if (dbm::is_result($r)) {
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				if(! $rr['rel']) {
       					q("DELETE FROM `contact` WHERE `id` = %d",
       						intval($rr['cid'])
      diff --git a/mod/directory.php b/mod/directory.php
      index c702acf376..f3fbb9eb77 100644
      --- a/mod/directory.php
      +++ b/mod/directory.php
      @@ -92,12 +92,14 @@ function directory_content(App &$a) {
       			WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit);
       	if (dbm::is_result($r)) {
       
      -		if(in_array('small', $a->argv))
      +		if (in_array('small', $a->argv)) {
       			$photo = 'thumb';
      -		else
      +		}
      +		else {
       			$photo = 'photo';
      +		}
       
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       
       			$itemurl= '';
       
      diff --git a/mod/events.php b/mod/events.php
      index 6bf7da6a28..c8a5694343 100644
      --- a/mod/events.php
      +++ b/mod/events.php
      @@ -344,7 +344,7 @@ function events_content(App &$a) {
       
       		if (dbm::is_result($r)) {
       			$r = sort_by_date($r);
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
       				if (! x($links,$j)) {
       					$links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;
      diff --git a/mod/filerm.php b/mod/filerm.php
      index f34421ba52..7dbfe29473 100644
      --- a/mod/filerm.php
      +++ b/mod/filerm.php
      @@ -10,18 +10,21 @@ function filerm_content(App &$a) {
       	$cat = unxmlify(trim($_GET['cat']));
       
       	$category = (($cat) ? true : false);
      -	if($category)
      +	if ($category) {
       		$term = $cat;
      +	}
       
       	$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
       
       	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);
      +	}
       
      -	if(x($_SESSION,'return_url'))
      +	if (x($_SESSION,'return_url')) {
       		goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
      +	}
       
       	killme();
       }
      diff --git a/mod/follow.php b/mod/follow.php
      index f318dc202c..2c90923e6f 100644
      --- a/mod/follow.php
      +++ b/mod/follow.php
      @@ -157,8 +157,9 @@ function follow_post(App &$a) {
       		// NOTREACHED
       	}
       
      -	if ($_REQUEST['cancel'])
      +	if ($_REQUEST['cancel']) {
       		goaway($_SESSION['return_url']);
      +	}
       
       	$uid = local_user();
       	$url = notags(trim($_REQUEST['url']));
      @@ -170,17 +171,21 @@ function follow_post(App &$a) {
       
       	$result = new_contact($uid,$url,true);
       
      -	if($result['success'] == false) {
      -		if($result['message'])
      +	if ($result['success'] == false) {
      +		if ($result['message']) {
       			notice($result['message']);
      +		}
       		goaway($return_url);
      -	} elseif ($result['cid'])
      +	}
      +	elseif ($result['cid']) {
       		goaway(App::get_baseurl().'/contacts/'.$result['cid']);
      +	}
       
       	info( t('Contact added').EOL);
       
      -	if(strstr($return_url,'contacts'))
      +	if (strstr($return_url,'contacts')) {
       		goaway(App::get_baseurl().'/contacts/'.$contact_id);
      +	}
       
       	goaway($return_url);
       	// NOTREACHED
      diff --git a/mod/group.php b/mod/group.php
      index fc5c481817..bf9009ae0c 100644
      --- a/mod/group.php
      +++ b/mod/group.php
      @@ -25,7 +25,7 @@ function group_post(App &$a) {
       
       		$name = notags(trim($_POST['groupname']));
       		$r = group_add(local_user(),$name);
      -		if($r) {
      +		if ($r) {
       			info( t('Group created.') . EOL );
       			$r = group_byname(local_user(),$name);
       			if ($r) {
      diff --git a/mod/hcard.php b/mod/hcard.php
      index 1d51ac80ee..50721720d0 100644
      --- a/mod/hcard.php
      +++ b/mod/hcard.php
      @@ -4,8 +4,9 @@ function hcard_init(App &$a) {
       
       	$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
       
      -	if($a->argc > 1)
      +	if ($a->argc > 1) {
       		$which = $a->argv[1];
      +	}
       	else {
       		notice( t('No profile') . EOL );
       		$a->error = 404;
      @@ -13,28 +14,30 @@ function hcard_init(App &$a) {
       	}
       
       	$profile = 0;
      -	if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
      -		$which = $a->user['nickname'];
      -		$profile = $a->argv[1];		
      +	if ((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
      +		$which   = $a->user['nickname'];
      +		$profile = $a->argv[1];
       	}
       
       	profile_load($a,$which,$profile);
       
      -	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'] .= '';
       	}
      -	if(x($a->profile,'openidserver'))				
      +	if (x($a->profile,'openidserver')) {
       		$a->page['htmlhead'] .= '' . "\r\n";
      -	if(x($a->profile,'openid')) {
      +	}
      +	if (x($a->profile,'openid')) {
       		$delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
       		$a->page['htmlhead'] .= '' . "\r\n";
       	}
       
      -	if(! $blocked) {
      +	if (! $blocked) {
       		$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
       		$keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords);
      -		if(strlen($keywords))
      +		if (strlen($keywords)) {
       			$a->page['htmlhead'] .= '' . "\r\n" ;
      +		}
       	}
       
       	$a->page['htmlhead'] .= '' . "\r\n" ;
      @@ -44,7 +47,7 @@ function hcard_init(App &$a) {
       	header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
       
       	$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
      -	foreach($dfrn_pages as $dfrn) {
      +	foreach ($dfrn_pages as $dfrn) {
       		$a->page['htmlhead'] .= "\r\n";
       	}
       
      diff --git a/mod/install.php b/mod/install.php
      index 92b136c338..1206aa61ea 100755
      --- a/mod/install.php
      +++ b/mod/install.php
      @@ -52,7 +52,7 @@ function install_post(App &$a) {
       					$r = q("CREATE DATABASE '%s'",
       							dbesc($dbdata)
       					);
      -					if($r) {
      +					if ($r) {
       						unset($db);
       						$db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true);
       					} else {
      @@ -520,19 +520,22 @@ function check_smarty3(&$checks) {
       function check_htaccess(&$checks) {
       	$status = true;
       	$help = "";
      -	if (function_exists('curl_init')){
      +	if (function_exists('curl_init')) {
       		$test = fetch_url(App::get_baseurl()."/install/testrewrite");
       
      -		if ($test!="ok")
      +		if ($test!="ok") {
       			$test = fetch_url(normalise_link(App::get_baseurl()."/install/testrewrite"));
      +		}
       
       		if ($test!="ok") {
       			$status = false;
       			$help = t('Url rewrite in .htaccess is not working. Check your server configuration.');
       		}
       		check_add($checks, t('Url rewrite is working'), $status, true, $help);
      -	} else {
      +	}
      +	else {
       		// cannot check modrewrite if libcurl is not installed
      +		/// @TODO Maybe issue warning here?
       	}
       }
       
      @@ -549,7 +552,7 @@ function check_imagik(&$checks) {
       	}
       	if ($imagick == false) {
       		check_add($checks, t('ImageMagick PHP extension is not installed'), $imagick, false, "");
      -		}
      +	}
       	else {
       		check_add($checks, t('ImageMagick PHP extension is installed'), $imagick, false, "");
       		if ($imagick) {
      diff --git a/mod/invite.php b/mod/invite.php
      index 2db71742f1..2662c792f0 100644
      --- a/mod/invite.php
      +++ b/mod/invite.php
      @@ -116,11 +116,13 @@ function invite_content(App &$a) {
       
       	$dirloc = get_config('system','directory');
       	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');
      -		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())
       			. "\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 {
       		$o = t('Our apologies. This system is not currently configured to connect with other public sites or invite members.');
      @@ -129,15 +131,15 @@ function invite_content(App &$a) {
       
       	$o = replace_macros($tpl, array(
       		'$form_security_token' => get_form_security_token("send_invite"),
      -		'$invite' => t('Send invitations'),
      -		'$addr_text' => t('Enter email addresses, one per line:'),
      -		'$msg_text' => t('Your message:'),
      -		'$default_message' => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n"
      +		'$invite'              => t('Send invitations'),
      +		'$addr_text'           => t('Enter email addresses, one per line:'),
      +		'$msg_text'            => t('Your message:'),
      +		'$default_message'     => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n"
       			. $linktxt
       			. "\r\n" . "\r\n" . (($invonly) ? t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') .t('Once you have registered, please connect with me via my profile page at:') 
       			. "\r\n" . "\r\n" . App::get_baseurl() . '/profile/' . $a->user['nickname']
       			. "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendica.com') . "\r\n" . "\r\n"  ,
      -		'$submit' => t('Submit')
      +		'$submit'              => t('Submit')
       	));
       
       	return $o;
      diff --git a/mod/item.php b/mod/item.php
      index 864aa18e51..487ddee916 100644
      --- a/mod/item.php
      +++ b/mod/item.php
      @@ -59,13 +59,14 @@ function item_post(App &$a) {
       	// Check for doubly-submitted posts, and reject duplicates
       	// Note that we have to ignore previews, otherwise nothing will post
       	// after it's been previewed
      -	if(!$preview && x($_REQUEST['post_id_random'])) {
      -		if(x($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) {
      +	if (!$preview && x($_REQUEST['post_id_random'])) {
      +		if (x($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) {
       			logger("item post: duplicate post", LOGGER_DEBUG);
       			item_post_return(App::get_baseurl(), $api_source, $return_path);
       		}
      -		else
      +		else {
       			$_SESSION['post-random'] = $_REQUEST['post_id_random'];
      +		}
       	}
       
       	/**
      @@ -82,18 +83,20 @@ function item_post(App &$a) {
       	$r = false;
       	$objecttype = null;
       
      -	if($parent || $parent_uri) {
      +	if ($parent || $parent_uri) {
       
       		$objecttype = ACTIVITY_OBJ_COMMENT;
       
      -		if(! x($_REQUEST,'type'))
      +		if (! x($_REQUEST,'type')) {
       			$_REQUEST['type'] = 'net-comment';
      +		}
       
      -		if($parent) {
      +		if ($parent) {
       			$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
       				intval($parent)
       			);
      -		} elseif($parent_uri && local_user()) {
      +		}
      +		elseif ($parent_uri && local_user()) {
       			// 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",
       				dbesc($parent_uri),
      @@ -105,7 +108,7 @@ function item_post(App &$a) {
       		if (dbm::is_result($r)) {
       			$parid = $r[0]['parent'];
       			$parent_uri = $r[0]['uri'];
      -			if($r[0]['id'] != $r[0]['parent']) {
      +			if ($r[0]['id'] != $r[0]['parent']) {
       				$r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1",
       					intval($parid)
       				);
      @@ -114,8 +117,9 @@ function item_post(App &$a) {
       
       		if (! dbm::is_result($r)) {
       			notice( t('Unable to locate original post.') . EOL);
      -			if(x($_REQUEST,'return'))
      +			if (x($_REQUEST,'return')) {
       				goaway($return_path);
      +			}
       			killme();
       		}
       		$parent_item = $r[0];
      @@ -125,7 +129,7 @@ function item_post(App &$a) {
       		//if(($parid) && ($parid != $parent))
       		$thr_parent = $parent_uri;
       
      -		if($parent_item['contact-id'] && $uid) {
      +		if ($parent_item['contact-id'] && $uid) {
       			$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
       				intval($parent_item['contact-id']),
       				intval($uid)
      @@ -449,13 +453,15 @@ function item_post(App &$a) {
       
       			$objecttype = ACTIVITY_OBJ_IMAGE;
       
      -			foreach($images as $image) {
      -				if(! stristr($image,App::get_baseurl() . '/photo/'))
      +			foreach ($images as $image) {
      +				if (! stristr($image,App::get_baseurl() . '/photo/')) {
       					continue;
      +				}
       				$image_uri = substr($image,strrpos($image,'/') + 1);
       				$image_uri = substr($image_uri,0, strpos($image_uri,'-'));
      -				if(! strlen($image_uri))
      +				if (! strlen($image_uri)) {
       					continue;
      +				}
       				$srch = '<' . intval($contact_id) . '>';
       
       				$r = q("SELECT `id` FROM `photo` WHERE `allow_cid` = '%s' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = ''
      diff --git a/mod/lostpass.php b/mod/lostpass.php
      index 3174bcd0e0..43e9cf715e 100644
      --- a/mod/lostpass.php
      +++ b/mod/lostpass.php
      @@ -102,7 +102,7 @@ function lostpass_content(App &$a) {
       			dbesc($new_password_encoded),
       			intval($uid)
       		);
      -		if($r) {
      +		if ($r) {
       			$tpl = get_markup_template('pwdreset.tpl');
       			$o .= replace_macros($tpl,array(
       				'$lbl1' => t('Password Reset'),
      diff --git a/mod/message.php b/mod/message.php
      index ef62a78981..776a23bccd 100644
      --- a/mod/message.php
      +++ b/mod/message.php
      @@ -160,7 +160,7 @@ function item_redir_and_replace_images($body, $images, $cid) {
       	$newbody = $newbody . $origbody;
       
       	$cnt = 0;
      -	foreach($images as $image) {
      +	foreach ($images as $image) {
       		// We're depending on the property of 'foreach' (specified on the PHP website) that
       		// it loops over the array starting from the first element and going sequentially
       		// to the last element
      @@ -231,7 +231,7 @@ function message_content(App &$a) {
       				intval($a->argv[2]),
       				intval(local_user())
       			);
      -			if($r) {
      +			if ($r) {
       				info( t('Message deleted.') . EOL );
       			}
       			//goaway(App::get_baseurl(true) . '/message' );
      diff --git a/mod/network.php b/mod/network.php
      index 8b24b3e11b..6c9bf75799 100644
      --- a/mod/network.php
      +++ b/mod/network.php
      @@ -183,13 +183,13 @@ function saved_searches($search) {
       	$saved = array();
       
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$saved[] = array(
      -				'id'		=> $rr['id'],
      -				'term'		=> $rr['term'],
      -				'encodedterm' 	=> urlencode($rr['term']),
      -				'delete'	=> t('Remove term'),
      -				'selected'	=> ($search==$rr['term']),
      +				'id'          => $rr['id'],
      +				'term'        => $rr['term'],
      +				'encodedterm' => urlencode($rr['term']),
      +				'delete'      => t('Remove term'),
      +				'selected'    => ($search==$rr['term']),
       			);
       		}
       	}
      @@ -197,10 +197,10 @@ function saved_searches($search) {
       
       	$tpl = get_markup_template("saved_searches_aside.tpl");
       	$o = replace_macros($tpl, array(
      -		'$title'	=> t('Saved Searches'),
      -		'$add'		=> t('add'),
      -		'$searchbox'	=> search($search,'netsearch-box',$srchurl,true),
      -		'$saved' 	=> $saved,
      +		'$title'     => t('Saved Searches'),
      +		'$add'       => t('add'),
      +		'$searchbox' => search($search,'netsearch-box',$srchurl,true),
      +		'$saved'     => $saved,
       	));
       
       	return $o;
      diff --git a/mod/nogroup.php b/mod/nogroup.php
      index 900ca4de09..c448406277 100644
      --- a/mod/nogroup.php
      +++ b/mod/nogroup.php
      @@ -35,7 +35,7 @@ function nogroup_content(App &$a) {
       	}
       	$r = contacts_not_grouped(local_user(),$a->pager['start'],$a->pager['itemspage']);
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       
       			$contact_details = get_contact_details_by_url($rr['url'], local_user(), $rr);
       
      diff --git a/mod/noscrape.php b/mod/noscrape.php
      index f1370167c5..33255f0fa4 100644
      --- a/mod/noscrape.php
      +++ b/mod/noscrape.php
      @@ -31,21 +31,22 @@ function noscrape_init(App &$a) {
       		intval($a->profile['uid']));
       
       	$json_info = array(
      -		'fn' => $a->profile['name'],
      -		'addr' => $a->profile['addr'],
      -		'nick' => $which,
      -		'key' => $a->profile['pubkey'],
      +		'fn'       => $a->profile['name'],
      +		'addr'     => $a->profile['addr'],
      +		'nick'     => $which,
      +		'key'      => $a->profile['pubkey'],
       		'homepage' => App::get_baseurl()."/profile/{$which}",
      -		'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
      -		'photo' => $r[0]["photo"],
      -		'tags' => $keywords
      +		'comm'     => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
      +		'photo'    => $r[0]["photo"],
      +		'tags'     => $keywords
       	);
       
      -	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",
       			intval($a->profile['uid']));
      -		if (dbm::is_result($r))
      +		if (dbm::is_result($r)) {
       			$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
       				AND `network` IN ('%s', '%s', '%s', '')",
      @@ -54,20 +55,21 @@ function noscrape_init(App &$a) {
       			dbesc(NETWORK_DIASPORA),
       			dbesc(NETWORK_OSTATUS)
       		);
      -		if (dbm::is_result($r))
      +		if (dbm::is_result($r)) {
       			$json_info["contacts"] = intval($r[0]['total']);
      +		}
       	}
       
       	//These are optional fields.
       	$profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital', 'about');
      -	foreach($profile_fields as $field) {
      -		if(!empty($a->profile[$field])) {
      +	foreach ($profile_fields as $field) {
      +		if (!empty($a->profile[$field])) {
       			$json_info["$field"] = $a->profile[$field];
       		}
       	}
       
       	$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
      -	foreach($dfrn_pages as $dfrn) {
      +	foreach ($dfrn_pages as $dfrn) {
       		$json_info["dfrn-{$dfrn}"] = App::get_baseurl()."/dfrn_{$dfrn}/{$which}";
       	}
       
      diff --git a/mod/openid.php b/mod/openid.php
      index e14b5f82d9..ce707c4150 100644
      --- a/mod/openid.php
      +++ b/mod/openid.php
      @@ -56,7 +56,7 @@ function openid_content(App &$a) {
       			// Successful OpenID login - but we can't match it to an existing account.
       			// New registration?
       
      -			if($a->config['register_policy'] == REGISTER_CLOSED) {
      +			if ($a->config['register_policy'] == REGISTER_CLOSED) {
       				notice( t('Account not found and OpenID registration is not permitted on this site.') . EOL);
       				goaway(z_root());
       			}
      @@ -64,31 +64,41 @@ function openid_content(App &$a) {
       			unset($_SESSION['register']);
       			$args = '';
       			$attr = $openid->getAttributes();
      -			if(is_array($attr) && count($attr)) {
      -				foreach($attr as $k => $v) {
      -					if($k === 'namePerson/friendly')
      +			if (is_array($attr) && count($attr)) {
      +				foreach ($attr as $k => $v) {
      +					if ($k === 'namePerson/friendly') {
       						$nick = notags(trim($v));
      -					if($k === 'namePerson/first')
      +					}
      +					if($k === 'namePerson/first') {
       						$first = notags(trim($v));
      -					if($k === 'namePerson')
      +					}
      +					if($k === 'namePerson') {
       						$args .= '&username=' . notags(trim($v));
      -					if($k === 'contact/email')
      +					}
      +					if ($k === 'contact/email') {
       						$args .= '&email=' . notags(trim($v));
      -					if($k === 'media/image/aspect11')
      +					}
      +					if ($k === 'media/image/aspect11') {
       						$photosq = bin2hex(trim($v));
      -					if($k === 'media/image/default')
      +					}
      +					if ($k === 'media/image/default') {
       						$photo = bin2hex(trim($v));
      +					}
       				}
       			}
      -			if($nick)
      +			if ($nick) {
       				$args .= '&nickname=' . $nick;
      -			elseif($first)
      +			}
      +			elseif ($first) {
       				$args .= '&nickname=' . $first;
      +			}
       
      -			if($photosq)
      +			if ($photosq) {
       				$args .= '&photo=' . $photosq;
      -			elseif($photo)
      +			}
      +			elseif ($photo) {
       				$args .= '&photo=' . $photo;
      +			}
       
       			$args .= '&openid_url=' . notags(trim($authid));
       
      diff --git a/mod/photos.php b/mod/photos.php
      index 317d7272b4..d4b2a3b19f 100644
      --- a/mod/photos.php
      +++ b/mod/photos.php
      @@ -255,7 +255,7 @@ function photos_post(App &$a) {
       				);
       			}
       			if (dbm::is_result($r)) {
      -				foreach($r as $rr) {
      +				foreach ($r as $rr) {
       					$res[] = "'" . dbesc($rr['rid']) . "'" ;
       				}
       			} else {
      @@ -277,7 +277,7 @@ function photos_post(App &$a) {
       				intval($page_owner_uid)
       			);
       			if (dbm::is_result($r)) {
      -				foreach($r as $rr) {
      +				foreach ($r as $rr) {
       					q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
       						dbesc(datetime_convert()),
       						dbesc($rr['parent-uri']),
      diff --git a/mod/poco.php b/mod/poco.php
      index 11f984757a..0415e1a2ce 100644
      --- a/mod/poco.php
      +++ b/mod/poco.php
      @@ -175,7 +175,7 @@ function poco_init(App &$a) {
       
       	if(is_array($r)) {
       		if (dbm::is_result($r)) {
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				if (!isset($rr['generation'])) {
       					if ($global)
       						$rr['generation'] = 3;
      diff --git a/mod/profile.php b/mod/profile.php
      index b7756453fe..52ffe8c47d 100644
      --- a/mod/profile.php
      +++ b/mod/profile.php
      @@ -62,7 +62,7 @@ function profile_init(App &$a) {
       	header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
       
       	$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
      -	foreach($dfrn_pages as $dfrn) {
      +	foreach ($dfrn_pages as $dfrn) {
       		$a->page['htmlhead'] .= "\r\n";
       	}
       	$a->page['htmlhead'] .= "\r\n";
      diff --git a/mod/profile_photo.php b/mod/profile_photo.php
      index 0b6dd8d13b..9b1ff8adb8 100644
      --- a/mod/profile_photo.php
      +++ b/mod/profile_photo.php
      @@ -204,7 +204,7 @@ function profile_photo_content(App &$a) {
       			return;
       		}
       		$havescale = false;
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			if($rr['scale'] == 5)
       				$havescale = true;
       		}
      diff --git a/mod/profiles.php b/mod/profiles.php
      index 20bd4cf6f1..bf2f20d2a9 100644
      --- a/mod/profiles.php
      +++ b/mod/profiles.php
      @@ -780,24 +780,26 @@ function profiles_content(App &$a) {
       		if (dbm::is_result($r)) {
       
       			$tpl = get_markup_template('profile_entry.tpl');
      -			foreach($r as $rr) {
      +
      +			$profiles = '';
      +			foreach ($r as $rr) {
       				$profiles .= replace_macros($tpl, array(
      -					'$photo' => $a->remove_baseurl($rr['thumb']),
      -					'$id' => $rr['id'],
      -					'$alt' => t('Profile Image'),
      +					'$photo'        => $a->remove_baseurl($rr['thumb']),
      +					'$id'           => $rr['id'],
      +					'$alt'          => t('Profile Image'),
       					'$profile_name' => $rr['profile-name'],
      -					'$visible' => (($rr['is-default']) ? '' . t('visible to everybody') . ''
      +					'$visible'      => (($rr['is-default']) ? '' . t('visible to everybody') . ''
       						: '' . t('Edit visibility') . '')
       				));
       			}
       
       			$tpl_header = get_markup_template('profile_listing_header.tpl');
       			$o .= replace_macros($tpl_header,array(
      -				'$header' => t('Edit/Manage Profiles'),
      -				'$chg_photo' => t('Change profile photo'),
      -				'$cr_new' => t('Create New Profile'),
      +				'$header'      => t('Edit/Manage Profiles'),
      +				'$chg_photo'   => t('Change profile photo'),
      +				'$cr_new'      => t('Create New Profile'),
       				'$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new"),
      -				'$profiles' => $profiles
      +				'$profiles'    => $profiles
       			));
       		}
       		return $o;
      diff --git a/mod/search.php b/mod/search.php
      index 3a25376268..22879f7f9e 100644
      --- a/mod/search.php
      +++ b/mod/search.php
      @@ -17,7 +17,7 @@ function search_saved_searches() {
       
       	if (dbm::is_result($r)) {
       		$saved = array();
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$saved[] = array(
       				'id'		=> $rr['id'],
       				'term'		=> $rr['term'],
      diff --git a/mod/suggest.php b/mod/suggest.php
      index 5af337ae1b..4c08db8b6c 100644
      --- a/mod/suggest.php
      +++ b/mod/suggest.php
      @@ -75,7 +75,7 @@ function suggest_content(App &$a) {
       
       	require_once 'include/contact_selectors.php';
       
      -	foreach($r as $rr) {
      +	foreach ($r as $rr) {
       
       		$connlnk = App::get_baseurl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
       		$ignlnk = App::get_baseurl() . '/suggest?ignore=' . $rr['id'];
      diff --git a/mod/videos.php b/mod/videos.php
      index 58c4b6c650..00c7c6dfa1 100644
      --- a/mod/videos.php
      +++ b/mod/videos.php
      @@ -368,8 +368,8 @@ function videos_content(App &$a) {
       
       	$videos = array();
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      -			if($a->theme['template_engine'] === 'internal') {
      +		foreach ($r as $rr) {
      +			if ($a->theme['template_engine'] === 'internal') {
       				$alt_e = template_escape($rr['filename']);
       				$name_e = template_escape($rr['album']);
       			}
      diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php
      index 6ae458b6a2..9c72a46e9c 100644
      --- a/mod/viewcontacts.php
      +++ b/mod/viewcontacts.php
      @@ -76,9 +76,11 @@ function viewcontacts_content(App &$a) {
       
       	$contacts = array();
       
      -	foreach($r as $rr) {
      -		if($rr['self'])
      +	foreach ($r as $rr) {
      +		/// @TODO This triggers an E_NOTICE if 'self' is not there
      +		if ($rr['self']) {
       			continue;
      +		}
       
       		$url = $rr['url'];
       
      
      From 013f8a413905dafd2e6f51afde1f01b61d63baa8 Mon Sep 17 00:00:00 2001
      From: Roland Haeder 
      Date: Tue, 20 Dec 2016 21:16:01 +0100
      Subject: [PATCH 54/96] 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 
      ---
       update.php                | 24 ++++++++---------
       view/theme/frio/theme.php | 11 ++++----
       view/theme/vier/theme.php | 57 +++++++++++++++++++++++++--------------
       3 files changed, 55 insertions(+), 37 deletions(-)
      
      diff --git a/update.php b/update.php
      index 0679b5a1f8..7aec2ec2b8 100644
      --- a/update.php
      +++ b/update.php
      @@ -86,7 +86,7 @@ function update_1006() {
       
       	$r = q("SELECT * FROM `user` WHERE `spubkey` = '' ");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$sres=openssl_pkey_new(array('encrypt_key' => false ));
       			$sprvkey = '';
       			openssl_pkey_export($sres, $sprvkey);
      @@ -123,7 +123,7 @@ function update_1011() {
       	q("ALTER TABLE `contact` ADD `nick` CHAR( 255 ) NOT NULL AFTER `name` ");
       	$r = q("SELECT * FROM `contact` WHERE 1");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       				q("UPDATE `contact` SET `nick` = '%s' WHERE `id` = %d",
       					dbesc(basename($rr['url'])),
       					intval($rr['id'])
      @@ -146,7 +146,7 @@ function update_1014() {
       	q("ALTER TABLE `contact` ADD `micro` TEXT NOT NULL AFTER `thumb` ");
       	$r = q("SELECT * FROM `photo` WHERE `scale` = 4");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$ph = new Photo($rr['data']);
       			if($ph->is_valid()) {
       				$ph->scaleImage(48);
      @@ -156,7 +156,7 @@ function update_1014() {
       	}
       	$r = q("SELECT * FROM `contact` WHERE 1");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			if(stristr($rr['thumb'],'avatar'))
       				q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d",
       					dbesc(str_replace('avatar','micro',$rr['thumb'])),
      @@ -309,7 +309,7 @@ function update_1031() {
       	// Repair any bad links that slipped into the item table
       	$r = q("SELECT `id`, `object` FROM `item` WHERE `object` != '' ");
       	if($r && dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			if(strstr($rr['object'],'type="http')) {
       				q("UPDATE `item` SET `object` = '%s' WHERE `id` = %d",
       					dbesc(str_replace('type="http','href="http',$rr['object'])),
      @@ -357,7 +357,7 @@ function update_1036() {
       
       	$r = dbq("SELECT * FROM `contact` WHERE `network` = 'dfrn' && `photo` LIKE '%include/photo%' ");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d",
       				dbesc(str_replace('include/photo','photo',$rr['photo'])),
       				dbesc(str_replace('include/photo','photo',$rr['thumb'])),
      @@ -607,7 +607,7 @@ function update_1075() {
       	q("ALTER TABLE `user` ADD `guid` CHAR( 16 ) NOT NULL AFTER `uid` ");
       	$r = q("SELECT `uid` FROM `user` WHERE 1");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$found = true;
       			do {
       				$guid = substr(random_string(),0,16);
      @@ -689,7 +689,7 @@ function update_1082() {
       		return;
       	$r = q("SELECT distinct(`resource-id`) FROM `photo` WHERE 1 group by `id`");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$guid = get_guid();
       			q("update `photo` set `guid` = '%s' where `resource-id` = '%s'",
       				dbesc($guid),
      @@ -732,7 +732,7 @@ function update_1087() {
       
       	$r = q("SELECT `id` FROM `item` WHERE `parent` = `id` ");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$x = q("SELECT max(`created`) AS `cdate` FROM `item` WHERE `parent` = %d LIMIT 1",
       				intval($rr['id'])
       			);
      @@ -855,7 +855,7 @@ function update_1100() {
       
       	$r = q("select id, url from contact where url != '' and nurl = '' ");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			q("update contact set nurl = '%s' where id = %d",
       				dbesc(normalise_link($rr['url'])),
       				intval($rr['id'])
      @@ -1169,7 +1169,7 @@ function update_1136() {
       
       	$r = q("select * from config where 1 order by id desc");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$found = false;
       			foreach($arr as $x) {
       				if($x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) {
      @@ -1188,7 +1188,7 @@ function update_1136() {
       	$arr = array();
       	$r = q("select * from pconfig where 1 order by id desc");
       	if (dbm::is_result($r)) {
      -		foreach($r as $rr) {
      +		foreach ($r as $rr) {
       			$found = false;
       			foreach($arr as $x) {
       				if($x['uid'] == $rr['uid'] && $x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) {
      diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php
      index 664881a4a8..f9cbf79a6a 100644
      --- a/view/theme/frio/theme.php
      +++ b/view/theme/frio/theme.php
      @@ -271,7 +271,7 @@ function frio_remote_nav($a,&$nav) {
        * We use this to give the data to textcomplete and have a filter function at the
        * contact page.
        * 
      - * @param App $a The app data
      + * @param App $a The app data @TODO Unused
        * @param array $results The array with the originals from acl_lookup()
        */
       function frio_acl_lookup($a, &$results) {
      @@ -281,17 +281,18 @@ function frio_acl_lookup($a, &$results) {
       
       	// we introduce a new search type, r should do the same query like it's
       	// done in /mod/contacts for connections
      -	if($results["type"] == "r") {
      +	if ($results["type"] == "r") {
       		$searching = false;
      -		if($search) {
      +		if ($search) {
       			$search_hdr = $search;
       			$search_txt = dbesc(protect_sprintf(preg_quote($search)));
       			$searching = true;
       		}
       		$sql_extra .= (($searching) ? " AND (`attag` LIKE '%%".dbesc($search_txt)."%%' OR `name` LIKE '%%".dbesc($search_txt)."%%' OR `nick` LIKE '%%".dbesc($search_txt)."%%') " : "");
       
      -		if($nets)
      +		if ($nets) {
       			$sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets));
      +		}
       
       		$sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : '');
       
      @@ -312,7 +313,7 @@ function frio_acl_lookup($a, &$results) {
       		$contacts = array();
       
       		if (dbm::is_result($r)) {
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				$contacts[] = _contact_detail_for_template($rr);
       			}
       		}
      diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php
      index 46921dc1c5..8be91220af 100644
      --- a/view/theme/vier/theme.php
      +++ b/view/theme/vier/theme.php
      @@ -152,7 +152,7 @@ function vier_community_info() {
       			$aside['$comunity_profiles_title'] = t('Community Profiles');
       			$aside['$comunity_profiles_items'] = array();
       
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				$entry = replace_macros($tpl,array(
       					'$id' => $rr['id'],
       					//'$profile_link' => zrl($rr['url']),
      @@ -182,7 +182,7 @@ function vier_community_info() {
       			$aside['$lastusers_title'] = t('Last users');
       			$aside['$lastusers_items'] = array();
       
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				$profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
       				$entry = replace_macros($tpl,array(
       					'$id' => $rr['id'],
      @@ -300,7 +300,7 @@ function vier_community_info() {
       
       			$aside['$helpers_items'] = array();
       
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				$entry = replace_macros($tpl,array(
       					'$url' => $rr['url'],
       					'$title' => $rr['name'],
      @@ -316,55 +316,72 @@ function vier_community_info() {
       	//connectable services
       	if ($show_services) {
       
      +		/// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
       		$r = array();
       
      -		if (plugin_enabled("appnet"))
      +		if (plugin_enabled("appnet")) {
       			$r[] = array("photo" => "images/appnet.png", "name" => "App.net");
      +		}
       
      -		if (plugin_enabled("buffer"))
      +		if (plugin_enabled("buffer")) {
       			$r[] = array("photo" => "images/buffer.png", "name" => "Buffer");
      +		}
       
      -		if (plugin_enabled("blogger"))
      +		if (plugin_enabled("blogger")) {
       			$r[] = array("photo" => "images/blogger.png", "name" => "Blogger");
      +		}
       
      -		if (plugin_enabled("dwpost"))
      +		if (plugin_enabled("dwpost")) {
       			$r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth");
      +		}
       
      -		if (plugin_enabled("fbpost"))
      +		if (plugin_enabled("fbpost")) {
       			$r[] = array("photo" => "images/facebook.png", "name" => "Facebook");
      +		}
       
      -		if (plugin_enabled("ifttt"))
      +		if (plugin_enabled("ifttt")) {
       			$r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT");
      +		}
       
      -		if (plugin_enabled("statusnet"))
      +		if (plugin_enabled("statusnet")) {
       			$r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social");
      +		}
       
      -		if (plugin_enabled("gpluspost"))
      +		if (plugin_enabled("gpluspost")) {
       			$r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
      +		}
       
      -		//if (plugin_enabled("ijpost"))
      +		//if (plugin_enabled("ijpost")) {
       		//	$r[] = array("photo" => "images/", "name" => "");
      +		//}
       
      -		if (plugin_enabled("libertree"))
      +		if (plugin_enabled("libertree")) {
       			$r[] = array("photo" => "images/libertree.png", "name" => "Libertree");
      +		}
       
      -		//if (plugin_enabled("ljpost"))
      +		//if (plugin_enabled("ljpost")) {
       		//	$r[] = array("photo" => "images/", "name" => "");
      +		//}
       
      -		if (plugin_enabled("pumpio"))
      +		if (plugin_enabled("pumpio")) {
       			$r[] = array("photo" => "images/pumpio.png", "name" => "pump.io");
      +		}
       
      -		if (plugin_enabled("tumblr"))
      +		if (plugin_enabled("tumblr")) {
       			$r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr");
      +		}
       
      -		if (plugin_enabled("twitter"))
      +		if (plugin_enabled("twitter")) {
       			$r[] = array("photo" => "images/twitter.png", "name" => "Twitter");
      +		}
       
      -		if (plugin_enabled("wppost"))
      +		if (plugin_enabled("wppost")) {
       			$r[] = array("photo" => "images/wordpress.png", "name" => "Wordpress");
      +		}
       
      -		if(function_exists("imap_open") AND !get_config("system","imap_disabled") AND !get_config("system","dfrn_only"))
      +		if (function_exists("imap_open") AND !get_config("system","imap_disabled") AND !get_config("system","dfrn_only")) {
       			$r[] = array("photo" => "images/mail.png", "name" => "E-Mail");
      +		}
       
       		$tpl = get_markup_template('ch_connectors.tpl');
       
      @@ -374,7 +391,7 @@ function vier_community_info() {
       			$con_services['title'] = Array("", t('Connect Services'), "", "");
       			$aside['$con_services'] = $con_services;
       
      -			foreach($r as $rr) {
      +			foreach ($r as $rr) {
       				$entry = replace_macros($tpl,array(
       					'$url' => $url,
       					'$photo' => $rr['photo'],
      
      From 536f078ed4993d645739f7989b760ddfeb0c6743 Mon Sep 17 00:00:00 2001
      From: Roland Haeder 
      Date: Tue, 20 Dec 2016 21:31:05 +0100
      Subject: [PATCH 55/96] Continued with coding convention: - added curly braces
       around conditional code blocks - added space between if/foreach/... and brace
       - made some SQL keywords upper-cased and added back-ticks to columns/table
       names
      
      Signed-off-by: Roland Haeder 
      ---
       include/like.php  | 55 +++++++++++++++++++++++++++--------------------
       mod/item.php      | 15 ++++++++-----
       mod/noscrape.php  |  1 -
       mod/settings.php  |  8 +++----
       mod/starred.php   | 17 +++++++++------
       mod/subthread.php | 18 +++++++++-------
       mod/tagger.php    |  5 +++--
       mod/tagrm.php     |  7 +++---
       mod/xrd.php       |  8 ++++---
       9 files changed, 78 insertions(+), 56 deletions(-)
      
      diff --git a/include/like.php b/include/like.php
      index b04b9b4e09..94ff33a699 100644
      --- a/include/like.php
      +++ b/include/like.php
      @@ -66,7 +66,7 @@ function do_like($item_id, $verb) {
       
       	$owner_uid = $item['uid'];
       
      -	if(! can_write_wall($a,$owner_uid)) {
      +	if (! can_write_wall($a,$owner_uid)) {
       		return false;
       	}
       
      @@ -81,8 +81,9 @@ function do_like($item_id, $verb) {
       		if (! dbm::is_result($r)) {
       			return false;
       		}
      -		if(! $r[0]['self'])
      +		if (! $r[0]['self']) {
       			$remote_owner = $r[0];
      +		}
       	}
       
       	// this represents the post owner on this system.
      @@ -91,21 +92,22 @@ function do_like($item_id, $verb) {
       		WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
       		intval($owner_uid)
       	);
      -	if (dbm::is_result($r))
      +	if (dbm::is_result($r)) {
       		$owner = $r[0];
      +	}
       
      -	if(! $owner) {
      +	if (! $owner) {
       		logger('like: no owner');
       		return false;
       	}
       
      -	if(! $remote_owner)
      +	if (! $remote_owner) {
       		$remote_owner = $owner;
      -
      +	}
       
       	// This represents the person posting
       
      -	if((local_user()) && (local_user() == $owner_uid)) {
      +	if ((local_user()) && (local_user() == $owner_uid)) {
       		$contact = $owner;
       	}
       	else {
      @@ -116,7 +118,7 @@ function do_like($item_id, $verb) {
       		if (dbm::is_result($r))
       			$contact = $r[0];
       	}
      -	if(! $contact) {
      +	if (! $contact) {
       		return false;
       	}
       
      @@ -125,7 +127,7 @@ function do_like($item_id, $verb) {
       
       	// event participation are essentially radio toggles. If you make a subsequent choice,
       	// we need to eradicate your first choice.
      -	if($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
      +	if ($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
       		$verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' ";
       	}
       
      @@ -162,8 +164,9 @@ function do_like($item_id, $verb) {
       	$uri = item_new_uri($a->get_hostname(),$owner_uid);
       
       	$post_type = (($item['resource-id']) ? t('photo') : t('status'));
      -	if($item['object-type'] === ACTIVITY_OBJ_EVENT)
      +	if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
       		$post_type = t('event');
      +	}
       	$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
       	$link = xmlify('' . "\n") ;
       	$body = $item['body'];
      @@ -179,20 +182,31 @@ function do_like($item_id, $verb) {
       		$body
       	
EOT; - if($verb === 'like') + if ($verb === 'like') { $bodyverb = t('%1$s likes %2$s\'s %3$s'); - if($verb === 'dislike') + } + if ($verb === 'dislike') { $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s'); - if($verb === 'attendyes') + } + if ($verb === 'attendyes') { $bodyverb = t('%1$s is attending %2$s\'s %3$s'); - if($verb === 'attendno') + } + if ($verb === 'attendno') { $bodyverb = t('%1$s is not attending %2$s\'s %3$s'); - if($verb === 'attendmaybe') + } + if ($verb === 'attendmaybe') { $bodyverb = t('%1$s may attend %2$s\'s %3$s'); + } - if(! isset($bodyverb)) - return false; + if (! isset($bodyverb)) { + return false; + } + $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; + $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; + $plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]'; + + /// @TODO Or rewrite this to multi-line initialization of the array? $arr = array(); $arr['guid'] = get_guid(32); @@ -212,12 +226,7 @@ EOT; $arr['author-name'] = $contact['name']; $arr['author-link'] = $contact['url']; $arr['author-avatar'] = $contact['thumb']; - - $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; - $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; - $plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]'; $arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink ); - $arr['verb'] = $activity; $arr['object-type'] = $objtype; $arr['object'] = $obj; @@ -231,7 +240,7 @@ EOT; $post_id = item_store($arr); - if(! $item['visible']) { + if (! $item['visible']) { $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d", intval($item['id']), intval($owner_uid) diff --git a/mod/item.php b/mod/item.php index 487ddee916..2080bb1653 100644 --- a/mod/item.php +++ b/mod/item.php @@ -646,8 +646,9 @@ function item_post(App &$a) { intval($mtch) ); if (dbm::is_result($r)) { - if(strlen($attachments)) + if (strlen($attachments)) { $attachments .= ','; + } $attachments .= '[attach]href="' . App::get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]'; } $body = str_replace($match[1],'',$body); @@ -656,14 +657,17 @@ function item_post(App &$a) { $wall = 0; - if($post_type === 'wall' || $post_type === 'wall-comment') + if ($post_type === 'wall' || $post_type === 'wall-comment') { $wall = 1; + } - if(! strlen($verb)) + if (! strlen($verb)) { $verb = ACTIVITY_POST ; + } - if ($network == "") + if ($network == "") { $network = NETWORK_DFRN; + } $gravity = (($parent) ? 6 : 0 ); @@ -677,8 +681,9 @@ function item_post(App &$a) { $uri = (($message_id) ? $message_id : item_new_uri($a->get_hostname(),$profile_uid, $guid)); // Fallback so that we alway have a thr-parent - if(!$thr_parent) + if (!$thr_parent) { $thr_parent = $uri; + } $datarray = array(); $datarray['uid'] = $profile_uid; diff --git a/mod/noscrape.php b/mod/noscrape.php index 33255f0fa4..758ce8ba53 100644 --- a/mod/noscrape.php +++ b/mod/noscrape.php @@ -26,7 +26,6 @@ function noscrape_init(App &$a) { $keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords); $keywords = explode(',', $keywords); - /// @TODO This query's result is not being used (see below), maybe old-lost code? $r = q("SELECT `photo` FROM `contact` WHERE `self` AND `uid` = %d", intval($a->profile['uid'])); diff --git a/mod/settings.php b/mod/settings.php index 515a97c14d..3c0087fafa 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -627,7 +627,7 @@ function settings_post(App &$a) { ); } - if(($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) { + if (($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) { // Update global directory in background $url = $_SESSION['my_url']; if ($url && strlen(get_config('system','directory'))) { @@ -642,10 +642,10 @@ function settings_post(App &$a) { update_gcontact_for_user(local_user()); //$_SESSION['theme'] = $theme; - if($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) { + if ($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) { - // FIXME - set to un-verified, blocked and redirect to logout - // Why? Are we verifying people or email addresses? + /// @TODO set to un-verified, blocked and redirect to logout + /// @TODO Why? Are we verifying people or email addresses? } diff --git a/mod/starred.php b/mod/starred.php index 0a78f51aa7..b100c0bff1 100644 --- a/mod/starred.php +++ b/mod/starred.php @@ -17,7 +17,7 @@ function starred_init(App &$a) { killme(); } - $r = q("SELECT starred FROM item WHERE uid = %d AND id = %d LIMIT 1", + $r = q("SELECT `starred` FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1", intval(local_user()), intval($message_id) ); @@ -25,10 +25,11 @@ function starred_init(App &$a) { killme(); } - if(! intval($r[0]['starred'])) + if (! intval($r[0]['starred'])) { $starred = 1; + } - $r = q("UPDATE item SET starred = %d WHERE uid = %d and id = %d", + $r = q("UPDATE `item` SET `starred` = %d WHERE `uid` = %d AND `id` = %d", intval($starred), intval(local_user()), intval($message_id) @@ -38,10 +39,14 @@ function starred_init(App &$a) { // See if we've been passed a return path to redirect to $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); - if($return_path) { + if ($return_path) { $rand = '_=' . time(); - if(strpos($return_path, '?')) $rand = "&$rand"; - else $rand = "?$rand"; + if (strpos($return_path, '?')) { + $rand = "&$rand"; + } + else { + $rand = "?$rand"; + } goaway(App::get_baseurl() . "/" . $return_path . $rand); } diff --git a/mod/subthread.php b/mod/subthread.php index 958f4ba03b..a00196825b 100644 --- a/mod/subthread.php +++ b/mod/subthread.php @@ -44,8 +44,9 @@ function subthread_content(App &$a) { if (! dbm::is_result($r)) { return; } - if(! $r[0]['self']) + if (! $r[0]['self']) { $remote_owner = $r[0]; + } } // this represents the post owner on this system. @@ -57,18 +58,18 @@ function subthread_content(App &$a) { if (dbm::is_result($r)) $owner = $r[0]; - if(! $owner) { + if (! $owner) { logger('like: no owner'); return; } - if(! $remote_owner) + if (! $remote_owner) $remote_owner = $owner; // This represents the person posting - if((local_user()) && (local_user() == $owner_uid)) { + if ((local_user()) && (local_user() == $owner_uid)) { $contact = $owner; } else { @@ -79,7 +80,7 @@ function subthread_content(App &$a) { if (dbm::is_result($r)) $contact = $r[0]; } - if(! $contact) { + if (! $contact) { return; } @@ -103,8 +104,9 @@ function subthread_content(App &$a) { EOT; $bodyverb = t('%1$s is following %2$s\'s %3$s'); - if(! isset($bodyverb)) - return; + if (! isset($bodyverb)) { + return; + } $arr = array(); @@ -144,7 +146,7 @@ EOT; $post_id = item_store($arr); - if(! $item['visible']) { + if (! $item['visible']) { $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d", intval($item['id']), intval($owner_uid) diff --git a/mod/tagger.php b/mod/tagger.php index b1f91d1bc4..da5c4700f9 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -94,8 +94,9 @@ EOT; $bodyverb = t('%1$s tagged %2$s\'s %3$s with %4$s'); - if(! isset($bodyverb)) - return; + if (! isset($bodyverb)) { + return; + } $termlink = html_entity_decode('⌗') . '[url=' . App::get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/url]'; diff --git a/mod/tagrm.php b/mod/tagrm.php index 8379495a2d..2a9a26e37b 100644 --- a/mod/tagrm.php +++ b/mod/tagrm.php @@ -59,7 +59,7 @@ function tagrm_content(App &$a) { } $item = (($a->argc > 1) ? intval($a->argv[1]) : 0); - if(! $item) { + if (! $item) { goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); // NOTREACHED } @@ -87,8 +87,7 @@ function tagrm_content(App &$a) { $o .= ''; $o .= '
    '; - - foreach($arr as $x) { + foreach ($arr as $x) { $o .= '
  • ' . bbcode($x) . '
  • '; } @@ -98,5 +97,5 @@ function tagrm_content(App &$a) { $o .= ''; return $o; - + } diff --git a/mod/xrd.php b/mod/xrd.php index 02a5d7b23c..a56c7fbdff 100644 --- a/mod/xrd.php +++ b/mod/xrd.php @@ -41,13 +41,15 @@ function xrd_init(App &$a) { $profile_url = App::get_baseurl().'/profile/'.$r[0]['nickname']; - if ($acct) + if ($acct) { $alias = $profile_url; + } else { $alias = 'acct:'.$r[0]['nickname'].'@'.$a->get_hostname(); - if ($a->get_path()) + if ($a->get_path()) { $alias .= '/'.$a->get_path(); + } } $o = replace_macros($tpl, array( @@ -65,7 +67,7 @@ function xrd_init(App &$a) { '$salmen' => App::get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention', '$subscribe' => App::get_baseurl() . '/follow?url={uri}', '$modexp' => 'data:application/magic-public-key,' . $salmon_key, - '$bigkey' => salmon_key($r[0]['pubkey']) + '$bigkey' => salmon_key($r[0]['pubkey']), )); From 9814414b6a69da17a32977181cb83277528d4530 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 20 Dec 2016 21:39:06 +0100 Subject: [PATCH 56/96] used dbm::is_result() instead of count() Signed-off-by: Roland Haeder --- mod/item.php | 2 +- mod/lostpass.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mod/item.php b/mod/item.php index 2080bb1653..695e76a2fa 100644 --- a/mod/item.php +++ b/mod/item.php @@ -139,7 +139,7 @@ function item_post(App &$a) { // If the contact id doesn't fit with the contact, then set the contact to null $thrparent = q("SELECT `author-link`, `network` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($thr_parent)); - if (count($thrparent) AND ($thrparent[0]["network"] === NETWORK_OSTATUS) + if (dbm::is_result($thrparent) AND ($thrparent[0]["network"] === NETWORK_OSTATUS) AND (normalise_link($parent_contact["url"]) != normalise_link($thrparent[0]["author-link"]))) { $parent_contact = null; diff --git a/mod/lostpass.php b/mod/lostpass.php index 43e9cf715e..f9e9400fc2 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -102,6 +102,8 @@ function lostpass_content(App &$a) { dbesc($new_password_encoded), intval($uid) ); + + /// @TODO Is dbm::is_result() okay here? if ($r) { $tpl = get_markup_template('pwdreset.tpl'); $o .= replace_macros($tpl,array( From 7c342600c388d1cbf7845c05a4aa3ffc0a02f598 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 20 Dec 2016 21:51:25 +0100 Subject: [PATCH 57/96] used more App::get_baseurl() instead of get_app()->get_baseurl(). Signed-off-by: Roland Haeder --- include/poller.php | 2 +- mod/proxy.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/poller.php b/include/poller.php index d00360d2b7..b631d2acd1 100644 --- a/include/poller.php +++ b/include/poller.php @@ -484,7 +484,7 @@ function call_worker() { return; } - $url = get_app()->get_baseurl()."/worker"; + $url = App::get_baseurl()."/worker"; fetch_url($url, false, $redirects, 1); } diff --git a/mod/proxy.php b/mod/proxy.php index d57d9baec5..af0f912616 100644 --- a/mod/proxy.php +++ b/mod/proxy.php @@ -326,7 +326,7 @@ function proxy_is_local_image($url) { if (strtolower(substr($url, 0, 5)) == "data:") return true; // links normalised - bug #431 - $baseurl = normalise_link(get_app()->get_baseurl()); + $baseurl = normalise_link(App::get_baseurl()); $url = normalise_link($url); return (substr($url, 0, strlen($baseurl)) == $baseurl); } From 7f98c8086c20027a7c096e0ad5a2752f9125396b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Wed, 21 Dec 2016 09:30:49 +0100 Subject: [PATCH 58/96] added curly braces + space MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder Conflicts: mod/events.php --- mod/events.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/mod/events.php b/mod/events.php index c8a5694343..1ed04deb08 100644 --- a/mod/events.php +++ b/mod/events.php @@ -16,7 +16,7 @@ function events_init(App &$a) { if ($a->argc == 1) { // if it's a json request abort here becaus we don't // need the widget data - if($a->argv[1] === 'json') + if ($a->argv[1] === 'json') return; $cal_widget = widget_events(); @@ -52,33 +52,35 @@ function events_post(App &$a) { // The default setting for the `private` field in event_store() is false, so mirror that $private_event = false; - if($start_text) { + if ($start_text) { $start = $start_text; } else { $start = sprintf('%d-%d-%d %d:%d:0',$startyear,$startmonth,$startday,$starthour,$startminute); } - if($nofinish) { + if ($nofinish) { $finish = '0000-00-00 00:00:00'; } - if($finish_text) { + if ($finish_text) { $finish = $finish_text; } else { $finish = sprintf('%d-%d-%d %d:%d:0',$finishyear,$finishmonth,$finishday,$finishhour,$finishminute); } - if($adjust) { + if ($adjust) { $start = datetime_convert(date_default_timezone_get(),'UTC',$start); - if(! $nofinish) + if (! $nofinish) { $finish = datetime_convert(date_default_timezone_get(),'UTC',$finish); + } } else { $start = datetime_convert('UTC','UTC',$start); - if(! $nofinish) + if (! $nofinish) { $finish = datetime_convert('UTC','UTC',$finish); + } } // Don't allow the event to finish before it begins. @@ -94,9 +96,9 @@ function events_post(App &$a) { $action = ($event_id == '') ? 'new' : "event/" . $event_id; $onerror_url = App::get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish"; - if(strcmp($finish,$start) < 0 && !$nofinish) { + if (strcmp($finish,$start) < 0 && !$nofinish) { notice( t('Event can not end before it has started.') . EOL); - if(intval($_REQUEST['preview'])) { + if (intval($_REQUEST['preview'])) { echo( t('Event can not end before it has started.')); killme(); } From e6a4a736fc30e9669351dad72b67d46199f6424c Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 21 Dec 2016 22:53:08 +0100 Subject: [PATCH 59/96] no need for this else block Signed-off-by: Roland Haeder --- mod/proxy.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mod/proxy.php b/mod/proxy.php index bf1e93ccf8..8046e4e963 100644 --- a/mod/proxy.php +++ b/mod/proxy.php @@ -136,6 +136,7 @@ function proxy_init(App $a) { } $valid = true; + $r = array(); if (!$direct_cache AND ($cachefile == '')) { $r = qu("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash); @@ -146,8 +147,6 @@ function proxy_init(App $a) { $mime = 'image/jpeg'; } } - } else { - $r = array(); } if (!dbm::is_result($r)) { From d3e666f71a3a0c5e3ddd420dc71b5ceeacae81b5 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 21 Dec 2016 23:04:09 +0100 Subject: [PATCH 60/96] added curly braces/spaces + replace spaces with tabs to fix code indending (or so?) Signed-off-by: Roland Haeder --- include/message.php | 3 +- mod/dirfind.php | 13 +++---- mod/follow.php | 18 +++++----- mod/home.php | 7 ++-- mod/install.php | 87 +++++++++++++++++++++++---------------------- mod/invite.php | 48 ++++++++++++------------- mod/starred.php | 3 +- 7 files changed, 88 insertions(+), 91 deletions(-) diff --git a/include/message.php b/include/message.php index 5bd611f220..3d5d4d33ab 100644 --- a/include/message.php +++ b/include/message.php @@ -153,8 +153,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){ if ($post_id) { proc_run(PRIORITY_HIGH, "include/notifier.php", "mail", $post_id); return intval($post_id); - } - else { + } else { return -3; } diff --git a/mod/dirfind.php b/mod/dirfind.php index 2b2badb640..7eb830bb68 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -88,20 +88,19 @@ function dirfind_content(&$a, $prefix = "") { if (get_config('system','diaspora_enabled')) { $diaspora = NETWORK_DIASPORA; - } - else { + } else { $diaspora = NETWORK_DFRN; } if (!get_config('system','ostatus_disabled')) { $ostatus = NETWORK_OSTATUS; - } - else { + } else { $ostatus = NETWORK_DFRN; } $search2 = "%".$search."%"; + /// @TODO These 2 SELECTs are not checked on validity with dbm::is_result() $count = q("SELECT count(*) AS `total` FROM `gcontact` LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl` AND `contact`.`network` = `gcontact`.`network` @@ -200,8 +199,7 @@ function dirfind_content(&$a, $prefix = "") { $photo_menu = contact_photo_menu($contact[0]); $details = _contact_detail_for_template($contact[0]); $alt_text = $details['alt_text']; - } - else { + } else { $photo_menu = array(); } } else { @@ -243,8 +241,7 @@ function dirfind_content(&$a, $prefix = "") { '$paginate' => paginate($a), )); - } - else { + } else { info( t('No matches') . EOL); } diff --git a/mod/follow.php b/mod/follow.php index 2c90923e6f..3ba33780ba 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -56,10 +56,11 @@ function follow_content(App &$a) { // NOTREACHED } - if ($ret["network"] == NETWORK_MAIL) + if ($ret["network"] == NETWORK_MAIL) { $ret["url"] = $ret["addr"]; + } - if($ret['network'] === NETWORK_DFRN) { + if ($ret['network'] === NETWORK_DFRN) { $request = $ret["request"]; $tpl = get_markup_template('dfrn_request.tpl'); } else { @@ -84,20 +85,22 @@ function follow_content(App &$a) { $r = q("SELECT `id`, `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($ret["url"])); - if (!$r) + if (!$r) { $r = array(array("location" => "", "about" => "", "keywords" => "")); - else + } else { $gcontact_id = $r[0]["id"]; + } - if($ret['network'] === NETWORK_DIASPORA) { + if ($ret['network'] === NETWORK_DIASPORA) { $r[0]["location"] = ""; $r[0]["about"] = ""; } $header = $ret["name"]; - if ($ret["addr"] != "") + if ($ret["addr"] != "") { $header .= " <".$ret["addr"].">"; + } //$header .= " (".network_to_name($ret['network'], $ret['url']).")"; $header = t("Connect/Follow"); @@ -176,8 +179,7 @@ function follow_post(App &$a) { notice($result['message']); } goaway($return_url); - } - elseif ($result['cid']) { + } elseif ($result['cid']) { goaway(App::get_baseurl().'/contacts/'.$result['cid']); } diff --git a/mod/home.php b/mod/home.php index 8bee1aef00..ed66bad147 100644 --- a/mod/home.php +++ b/mod/home.php @@ -16,7 +16,6 @@ function home_init(App &$a) { }} - if(! function_exists('home_content')) { function home_content(App &$a) { @@ -35,9 +34,8 @@ function home_content(App &$a) { $a->page['htmlhead'] .= ''; } - $o .= file_get_contents('home.html');} - - else { + $o .= file_get_contents('home.html'); + } else { $o .= '

    '.((x($a->config,'sitename')) ? sprintf(t("Welcome to %s"), $a->config['sitename']) : "").'

    '; } @@ -48,5 +46,4 @@ function home_content(App &$a) { return $o; - }} diff --git a/mod/install.php b/mod/install.php index 1206aa61ea..80a4cb799e 100755 --- a/mod/install.php +++ b/mod/install.php @@ -11,17 +11,16 @@ function install_init(App &$a){ echo "ok"; killme(); } - + // We overwrite current theme css, because during install we could not have a working mod_rewrite // so we could not have a css at all. Here we set a static css file for the install procedure pages $a->config['system']['theme'] = "../install"; $a->theme['stylesheet'] = App::get_baseurl()."/view/install/style.css"; - - - + global $install_wizard_pass; - if (x($_POST,'pass')) + if (x($_POST,'pass')) { $install_wizard_pass = intval($_POST['pass']); + } } @@ -63,7 +62,7 @@ function install_post(App &$a) { return; } }*/ - if(get_db_errno()) { + if (get_db_errno()) { $a->data['db_conn_failed']=true; } @@ -107,17 +106,18 @@ function install_post(App &$a) { $result = file_put_contents('.htconfig.php', $txt); - if(! $result) { + if (! $result) { $a->data['txt'] = $txt; } $errors = load_database($db); - if($errors) + if ($errors) { $a->data['db_failed'] = $errors; - else + } else { $a->data['db_installed'] = true; + } return; break; @@ -125,10 +125,11 @@ function install_post(App &$a) { } function get_db_errno() { - if(class_exists('mysqli')) + if (class_exists('mysqli')) { return mysqli_connect_errno(); - else + } else { return mysql_errno(); + } } function install_content(App &$a) { @@ -140,23 +141,23 @@ function install_content(App &$a) { - if(x($a->data,'db_conn_failed')) { + if (x($a->data,'db_conn_failed')) { $install_wizard_pass = 2; $wizard_status = t('Could not connect to database.'); } - if(x($a->data,'db_create_failed')) { + if (x($a->data,'db_create_failed')) { $install_wizard_pass = 2; $wizard_status = t('Could not create table.'); } $db_return_text=""; - if(x($a->data,'db_installed')) { + if (x($a->data,'db_installed')) { $txt = '

    '; $txt .= t('Your Friendica site database has been installed.') . EOL; $db_return_text .= $txt; } - if(x($a->data,'db_failed')) { + if (x($a->data,'db_failed')) { $txt = t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL; $txt .= t('Please see the file "INSTALL.txt".') . EOL ."


    " ; $txt .= "
    ".$a->data['db_failed'] . "
    ". EOL ; @@ -176,7 +177,7 @@ function install_content(App &$a) { } } - if(x($a->data,'txt') && strlen($a->data['txt'])) { + if (x($a->data,'txt') && strlen($a->data['txt'])) { $db_return_text .= manual_config($a); } @@ -205,16 +206,19 @@ function install_content(App &$a) { check_keys($checks); - if(x($_POST,'phpath')) + if (x($_POST,'phpath')) { $phpath = notags(trim($_POST['phpath'])); + } check_php($phpath, $checks); - check_htaccess($checks); + check_htaccess($checks); + /// @TODO Maybe move this out? function check_passed($v, $c){ - if ($c['required']) + if ($c['required']) { $v = $v && $c['status']; + } return $v; } $checkspassed = array_reduce($checks, "check_passed", true); @@ -343,7 +347,7 @@ function check_php(&$phpath, &$checks) { $passed = strlen($phpath); } $help = ""; - if(!$passed) { + if (!$passed) { $help .= t('Could not find a command line version of PHP in the web server PATH.'). EOL; $help .= t("If you don't have a command line version of PHP installed on server, you will not be able to run background polling via cron. See 'Setup the poller'") . EOL ; $help .= EOL . EOL ; @@ -370,7 +374,7 @@ function check_php(&$phpath, &$checks) { } - if($passed2) { + if ($passed2) { $str = autoname(8); $cmd = "$phpath testargs.php $str"; $result = trim(shell_exec($cmd)); @@ -392,15 +396,17 @@ function check_keys(&$checks) { $res = false; - if(function_exists('openssl_pkey_new')) - $res=openssl_pkey_new(array( - 'digest_alg' => 'sha1', - 'private_key_bits' => 4096, - 'encrypt_key' => false )); + if (function_exists('openssl_pkey_new')) { + $res = openssl_pkey_new(array( + 'digest_alg' => 'sha1', + 'private_key_bits' => 4096, + 'encrypt_key' => false + )); + } // Get private key - if(! $res) { + if (! $res) { $help .= t('Error: the "openssl_pkey_new" function on this system is not able to generate encryption keys'). EOL; $help .= t('If running under Windows, please see "http://www.php.net/manual/en/openssl.installation.php".'); } @@ -420,7 +426,7 @@ function check_funcs(&$checks) { check_add($ck_funcs, t('XML PHP module'), true, true, ""); check_add($ck_funcs, t('iconv module'), true, true, ""); - if(function_exists('apache_get_modules')){ + if (function_exists('apache_get_modules')){ if (! in_array('mod_rewrite',apache_get_modules())) { check_add($ck_funcs, t('Apache mod_rewrite module'), false, true, t('Error: Apache webserver mod-rewrite module is required but not installed.')); } else { @@ -428,31 +434,31 @@ function check_funcs(&$checks) { } } - if(! function_exists('curl_init')){ + if (! function_exists('curl_init')){ $ck_funcs[0]['status']= false; $ck_funcs[0]['help']= t('Error: libCURL PHP module required but not installed.'); } - if(! function_exists('imagecreatefromjpeg')){ + if (! function_exists('imagecreatefromjpeg')){ $ck_funcs[1]['status']= false; $ck_funcs[1]['help']= t('Error: GD graphics PHP module with JPEG support required but not installed.'); } - if(! function_exists('openssl_public_encrypt')) { + if (! function_exists('openssl_public_encrypt')) { $ck_funcs[2]['status']= false; $ck_funcs[2]['help']= t('Error: openssl PHP module required but not installed.'); } - if(! function_exists('mysqli_connect')){ + if (! function_exists('mysqli_connect')){ $ck_funcs[3]['status']= false; $ck_funcs[3]['help']= t('Error: mysqli PHP module required but not installed.'); } - if(! function_exists('mb_strlen')){ + if (! function_exists('mb_strlen')){ $ck_funcs[4]['status']= false; $ck_funcs[4]['help']= t('Error: mb_string PHP module required but not installed.'); } - if(! function_exists('mcrypt_create_iv')){ + if (! function_exists('mcrypt_create_iv')){ $ck_funcs[5]['status']= false; $ck_funcs[5]['help']= t('Error: mcrypt PHP module required but not installed.'); } - if(! function_exists('iconv_strlen')){ + if (! function_exists('iconv_strlen')){ $ck_funcs[7]['status']= false; $ck_funcs[7]['help']= t('Error: iconv PHP module required but not installed.'); } @@ -487,7 +493,7 @@ function check_funcs(&$checks) { function check_htconfig(&$checks) { $status = true; $help = ""; - if( (file_exists('.htconfig.php') && !is_writable('.htconfig.php')) || + if ((file_exists('.htconfig.php') && !is_writable('.htconfig.php')) || (!file_exists('.htconfig.php') && !is_writable('.')) ) { $status=false; @@ -504,7 +510,7 @@ function check_htconfig(&$checks) { function check_smarty3(&$checks) { $status = true; $help = ""; - if( !is_writable('view/smarty3') ) { + if (!is_writable('view/smarty3') ) { $status=false; $help = t('Friendica uses the Smarty3 template engine to render its web views. Smarty3 compiles templates to PHP to speed up rendering.') .EOL; @@ -532,8 +538,7 @@ function check_htaccess(&$checks) { $help = t('Url rewrite in .htaccess is not working. Check your server configuration.'); } check_add($checks, t('Url rewrite is working'), $status, true, $help); - } - else { + } else { // cannot check modrewrite if libcurl is not installed /// @TODO Maybe issue warning here? } @@ -552,8 +557,7 @@ function check_imagik(&$checks) { } if ($imagick == false) { check_add($checks, t('ImageMagick PHP extension is not installed'), $imagick, false, ""); - } - else { + } else { check_add($checks, t('ImageMagick PHP extension is installed'), $imagick, false, ""); if ($imagick) { check_add($checks, t('ImageMagick supports GIF'), $gif, false, ""); @@ -562,7 +566,6 @@ function check_imagik(&$checks) { } - function manual_config(App &$a) { $data = htmlentities($a->data['txt'],ENT_COMPAT,'UTF-8'); $o = t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.'); diff --git a/mod/invite.php b/mod/invite.php index 2662c792f0..f7f48290c5 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -19,14 +19,15 @@ function invite_post(App &$a) { check_form_security_token_redirectOnErr('/', 'send_invite'); $max_invites = intval(get_config('system','max_invites')); - if(! $max_invites) + if (! $max_invites) { $max_invites = 50; + } $current_invites = intval(get_pconfig(local_user(),'system','sent_invites')); - if($current_invites > $max_invites) { + if ($current_invites > $max_invites) { notice( t('Total invitation limit exceeded.') . EOL); return; - }; + } $recips = ((x($_POST,'recipients')) ? explode("\n",$_POST['recipients']) : array()); @@ -34,23 +35,24 @@ function invite_post(App &$a) { $total = 0; - if(get_config('system','invitation_only')) { + if (get_config('system','invitation_only')) { $invonly = true; $x = get_pconfig(local_user(),'system','invites_remaining'); - if((! $x) && (! is_site_admin())) + if ((! $x) && (! is_site_admin())) { return; + } } - foreach($recips as $recip) { + foreach ($recips as $recip) { $recip = trim($recip); - if(! valid_email($recip)) { + if (! valid_email($recip)) { notice( sprintf( t('%s : Not a valid email address.'), $recip) . EOL); continue; } - - if($invonly && ($x || is_site_admin())) { + + if ($invonly && ($x || is_site_admin())) { $code = autoname(8) . srand(1000,9999); $nmessage = str_replace('$invite_code',$code,$message); @@ -59,16 +61,17 @@ function invite_post(App &$a) { dbesc(datetime_convert()) ); - if(! is_site_admin()) { + if (! is_site_admin()) { $x --; - if($x >= 0) + if ($x >= 0) { set_pconfig(local_user(),'system','invites_remaining',$x); - else + } else { return; + } } - } - else + } else { $nmessage = $message; + } $res = mail($recip, email_header_encode( t('Please join us on Friendica'),'UTF-8'), $nmessage, @@ -76,7 +79,7 @@ function invite_post(App &$a) { . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit' ); - if($res) { + if ($res) { $total ++; $current_invites ++; set_pconfig(local_user(),'system','sent_invites',$current_invites); @@ -84,8 +87,7 @@ function invite_post(App &$a) { notice( t('Invitation limit exceeded. Please contact your site administrator.') . EOL); return; } - } - else { + } else { notice( sprintf( t('%s : Message delivery failed.'), $recip) . EOL); } @@ -105,26 +107,24 @@ function invite_content(App &$a) { $tpl = get_markup_template('invite.tpl'); $invonly = false; - if(get_config('system','invitation_only')) { + if (get_config('system','invitation_only')) { $invonly = true; $x = get_pconfig(local_user(),'system','invites_remaining'); - if((! $x) && (! is_site_admin())) { + if ((! $x) && (! is_site_admin())) { notice( t('You have no more invitations available') . EOL); return ''; } } $dirloc = get_config('system','directory'); - if(strlen($dirloc)) { + if (strlen($dirloc)) { 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'); - } - 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()) . "\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.'); return $o; } diff --git a/mod/starred.php b/mod/starred.php index b100c0bff1..c23b07b8b5 100644 --- a/mod/starred.php +++ b/mod/starred.php @@ -43,8 +43,7 @@ function starred_init(App &$a) { $rand = '_=' . time(); if (strpos($return_path, '?')) { $rand = "&$rand"; - } - else { + } else { $rand = "?$rand"; } From 59404e4eaf1b074de40301496a492395b0cccb44 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 21 Dec 2016 23:17:22 +0100 Subject: [PATCH 61/96] More curly braces added, left some TODOs behind Signed-off-by: Roland Haeder --- mod/settings.php | 100 +++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/mod/settings.php b/mod/settings.php index 3c0087fafa..1fbd24325d 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -671,9 +671,9 @@ function settings_content(App &$a) { - if(($a->argc > 1) && ($a->argv[1] === 'oauth')) { + if (($a->argc > 1) && ($a->argv[1] === 'oauth')) { - if(($a->argc > 2) && ($a->argv[2] === 'add')) { + if (($a->argc > 2) && ($a->argv[2] === 'add')) { $tpl = get_markup_template("settings_oauth_edit.tpl"); $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_oauth"), @@ -689,7 +689,7 @@ function settings_content(App &$a) { return $o; } - if(($a->argc > 3) && ($a->argv[2] === 'edit')) { + if (($a->argc > 3) && ($a->argv[2] === 'edit')) { $r = q("SELECT * FROM clients WHERE client_id='%s' AND uid=%d", dbesc($a->argv[3]), local_user()); @@ -725,7 +725,7 @@ function settings_content(App &$a) { return; } - + /// @TODO validate result with dbm::is_result() $r = q("SELECT clients.*, tokens.id as oauth_token, (clients.uid=%d) AS my FROM clients LEFT JOIN tokens ON clients.client_id=tokens.client_id @@ -751,7 +751,7 @@ function settings_content(App &$a) { } - if(($a->argc > 1) && ($a->argv[1] === 'addon')) { + if (($a->argc > 1) && ($a->argv[1] === 'addon')) { $settings_addons = ""; $r = q("SELECT * FROM `hook` WHERE `hook` = 'plugin_settings' "); @@ -771,14 +771,14 @@ function settings_content(App &$a) { return $o; } - if(($a->argc > 1) && ($a->argv[1] === 'features')) { + if (($a->argc > 1) && ($a->argv[1] === 'features')) { $arr = array(); $features = get_features(); - foreach($features as $fname => $fdata) { + foreach ($features as $fname => $fdata) { $arr[$fname] = array(); $arr[$fname][0] = $fdata[0]; - foreach(array_slice($fdata,1) as $f) { + foreach (array_slice($fdata,1) as $f) { $arr[$fname][1][] = array('feature_' .$f[0],$f[1],((intval(feature_enabled(local_user(),$f[0]))) ? "1" : ''),$f[2],array(t('Off'),t('On'))); } } @@ -787,14 +787,14 @@ function settings_content(App &$a) { $tpl = get_markup_template("settings_features.tpl"); $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_features"), - '$title' => t('Additional Features'), - '$features' => $arr, - '$submit' => t('Save Settings'), + '$title' => t('Additional Features'), + '$features' => $arr, + '$submit' => t('Save Settings'), )); return $o; } - if(($a->argc > 1) && ($a->argv[1] === 'connectors')) { + if (($a->argc > 1) && ($a->argv[1] === 'connectors')) { $settings_connectors = ''; $settings_connectors .= '

    '. t('General Social Media Settings').'

    '; @@ -860,8 +860,7 @@ function settings_content(App &$a) { $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", local_user() ); - } - else { + } else { $r = null; } @@ -878,10 +877,9 @@ function settings_content(App &$a) { $tpl = get_markup_template("settings_connectors.tpl"); - if(! service_class_allows(local_user(),'email_connect')) { + if (! service_class_allows(local_user(),'email_connect')) { $mail_disabled_message = upgrade_bool_message(); - } - else { + } else { $mail_disabled_message = (($mail_disabled) ? t('Email access is disabled on this site.') : ''); } @@ -919,38 +917,42 @@ function settings_content(App &$a) { /* * DISPLAY SETTINGS */ - if(($a->argc > 1) && ($a->argv[1] === 'display')) { + if (($a->argc > 1) && ($a->argv[1] === 'display')) { $default_theme = get_config('system','theme'); - if(! $default_theme) + if (! $default_theme) { $default_theme = 'default'; + } $default_mobile_theme = get_config('system','mobile-theme'); - if(! $mobile_default_theme) + if (! $mobile_default_theme) { $mobile_default_theme = 'none'; + } $allowed_themes_str = get_config('system','allowed_themes'); $allowed_themes_raw = explode(',',$allowed_themes_str); $allowed_themes = array(); - if(count($allowed_themes_raw)) - foreach($allowed_themes_raw as $x) - if(strlen(trim($x)) && is_dir("view/theme/$x")) + if (count($allowed_themes_raw)) { + foreach ($allowed_themes_raw as $x) { + if (strlen(trim($x)) && is_dir("view/theme/$x")) { $allowed_themes[] = trim($x); + } + } + } $themes = array(); $mobile_themes = array("---" => t('No special theme for mobile devices')); $files = glob('view/theme/*'); /* */ - if($allowed_themes) { - foreach($allowed_themes as $th) { + if ($allowed_themes) { + foreach ($allowed_themes as $th) { $f = $th; $is_experimental = file_exists('view/theme/' . $th . '/experimental'); $unsupported = file_exists('view/theme/' . $th . '/unsupported'); $is_mobile = file_exists('view/theme/' . $th . '/mobile'); if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){ $theme_name = (($is_experimental) ? sprintf("%s - \x28Experimental\x29", $f) : $f); - if($is_mobile) { + if ($is_mobile) { $mobile_themes[$f]=$theme_name; - } - else { + } else { $themes[$f]=$theme_name; } } @@ -962,8 +964,9 @@ function settings_content(App &$a) { $nowarn_insecure = intval(get_pconfig(local_user(), 'system', 'nowarn_insecure')); $browser_update = intval(get_pconfig(local_user(), 'system','update_interval')); - if (intval($browser_update) != -1) + if (intval($browser_update) != -1) { $browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds + } $itemspage_network = intval(get_pconfig(local_user(), 'system','itemspage_network')); $itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : 40); // default if not set: 40 items @@ -1042,8 +1045,9 @@ function settings_content(App &$a) { $p = q("SELECT * FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user()) ); - if(count($p)) + if (count($p)) { $profile = $p[0]; + } $username = $a->user['username']; $email = $a->user['email']; @@ -1090,8 +1094,9 @@ function settings_content(App &$a) { // nowarn_insecure - if(! strlen($a->user['timezone'])) + if (! strlen($a->user['timezone'])) { $timezone = date_default_timezone_get(); + } // Set the account type to "Community" when the page is a community page but the account type doesn't fit // This is only happening on the first visit after the update @@ -1152,19 +1157,16 @@ function settings_content(App &$a) { $noid = get_config('system','no_openid'); - if($noid) { + if ($noid) { $openid_field = false; - } - else { + } else { $openid_field = array('openid_url', t('OpenID:'),$openid, t("\x28Optional\x29 Allow this OpenID to login to this account."), "", "", "url"); } - $opt_tpl = get_markup_template("field_yesno.tpl"); if(get_config('system','publish_all')) { $profile_in_dir = ''; - } - else { + } else { $profile_in_dir = replace_macros($opt_tpl,array( '$field' => array('profile_in_directory', t('Publish your default profile in your local site directory?'), $profile['publish'], '', array(t('No'),t('Yes'))), )); @@ -1174,12 +1176,10 @@ function settings_content(App &$a) { $profile_in_net_dir = replace_macros($opt_tpl,array( '$field' => array('profile_in_netdirectory', t('Publish your default profile in the global social directory?'), $profile['net-publish'], '', array(t('No'),t('Yes'))), )); - } - else { + } else { $profile_in_net_dir = ''; } - $hide_friends = replace_macros($opt_tpl,array( '$field' => array('hide-friends', t('Hide your contact/friend list from viewers of your default profile?'), $profile['hide-friends'], '', array(t('No'),t('Yes'))), )); @@ -1194,19 +1194,16 @@ function settings_content(App &$a) { )); - $blocktags = replace_macros($opt_tpl,array( '$field' => array('blocktags', t('Allow friends to tag your posts?'), (intval($a->user['blocktags']) ? '0' : '1'), '', array(t('No'),t('Yes'))), )); - $suggestme = replace_macros($opt_tpl,array( '$field' => array('suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', array(t('No'),t('Yes'))), )); - $unkmail = replace_macros($opt_tpl,array( '$field' => array('unkmail', t('Permit unknown people to send you private mail?'), $unkmail, '', array(t('No'),t('Yes'))), @@ -1215,9 +1212,9 @@ function settings_content(App &$a) { $invisible = (((! $profile['publish']) && (! $profile['net-publish'])) ? true : false); - if($invisible) + if ($invisible) { info( t('Profile is not published.') . EOL ); - + } //$subdir = ((strlen($a->get_path())) ? '
    ' . t('or') . ' ' . 'profile/' . $nickname : ''); @@ -1244,27 +1241,30 @@ function settings_content(App &$a) { require_once('include/group.php'); $group_select = mini_group_select(local_user(),$a->user['def_gid']); - // Private/public post links for the non-JS ACL form $private_post = 1; - if($_REQUEST['public']) + if ($_REQUEST['public']) { $private_post = 0; + } $query_str = $a->query_string; - if(strpos($query_str, 'public=1') !== false) + if (strpos($query_str, 'public=1') !== false) { $query_str = str_replace(array('?public=1', '&public=1'), array('', ''), $query_str); + } // I think $a->query_string may never have ? in it, but I could be wrong // It looks like it's from the index.php?q=[etc] rewrite that the web // server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61 - if(strpos($query_str, '?') === false) + if (strpos($query_str, '?') === false) { $public_post_link = '?public=1'; - else + } else { $public_post_link = '&public=1'; + } /* Installed langs */ $lang_choices = get_available_languages(); + /// @TODO Fix indending (or so) $o .= replace_macros($stpl, array( '$ptitle' => t('Account Settings'), From d242e72c656e6185e634ba6978783c2596f0918a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 09:09:27 +0100 Subject: [PATCH 62/96] applied coding convention rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/like.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/like.php b/include/like.php index 94ff33a699..4df15b4b63 100644 --- a/include/like.php +++ b/include/like.php @@ -48,10 +48,8 @@ function do_like($item_id, $verb) { break; } - logger('like: verb ' . $verb . ' item ' . $item_id); - $r = q("SELECT * FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1", dbesc($item_id), dbesc($item_id) @@ -109,8 +107,7 @@ function do_like($item_id, $verb) { if ((local_user()) && (local_user() == $owner_uid)) { $contact = $owner; - } - else { + } else { $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($_SESSION['visitor_id']), intval($owner_uid) From b2ffde3f6badde0d503a461f18885d20f57fb4e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 09:09:27 +0100 Subject: [PATCH 63/96] applied coding convention rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/like.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/like.php b/include/like.php index 94ff33a699..4df15b4b63 100644 --- a/include/like.php +++ b/include/like.php @@ -48,10 +48,8 @@ function do_like($item_id, $verb) { break; } - logger('like: verb ' . $verb . ' item ' . $item_id); - $r = q("SELECT * FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1", dbesc($item_id), dbesc($item_id) @@ -109,8 +107,7 @@ function do_like($item_id, $verb) { if ((local_user()) && (local_user() == $owner_uid)) { $contact = $owner; - } - else { + } else { $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($_SESSION['visitor_id']), intval($owner_uid) From 41da37ae670e1f3238d58916a4837b1907a116df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 11:21:50 +0100 Subject: [PATCH 64/96] Beatification/coding convention: - added a lot spaces to make it look nicer - added curly braces (coding convention) - added needed spaces (coding convention)get_id - removed obsolete $a = get_app() call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- object/Item.php | 383 ++++++++++++++++++++++++------------------------ 1 file changed, 193 insertions(+), 190 deletions(-) diff --git a/object/Item.php b/object/Item.php index d14b5418cc..e60344f7d3 100644 --- a/object/Item.php +++ b/object/Item.php @@ -52,21 +52,22 @@ class Item extends BaseObject { $ssl_state = ((local_user()) ? true : false); $this->redirect_url = 'redir/' . $this->get_data_value('cid') ; - if(get_config('system','thread_allow') && $a->theme_thread_allow && !$this->is_toplevel()) + if (get_config('system','thread_allow') && $a->theme_thread_allow && !$this->is_toplevel()) { $this->threaded = true; + } // Prepare the children - if(count($data['children'])) { - foreach($data['children'] as $item) { + if (count($data['children'])) { + foreach ($data['children'] as $item) { /* * Only add will be displayed */ - if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { - continue; - } - if(! visible_activity($item)) { + if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { + continue; + } elseif (! visible_activity($item)) { continue; } + $item['pagedrop'] = $data['pagedrop']; $child = new Item($item); $this->add_child($child); @@ -91,11 +92,11 @@ class Item extends BaseObject { $item = $this->get_data(); $edited = false; if (strcmp($item['created'], $item['edited'])<>0) { - $edited = array( - 'label' => t('This entry was edited'), - 'date' => datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r'), - 'relative' => relative_date($item['edited']) - ); + $edited = array( + 'label' => t('This entry was edited'), + 'date' => datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r'), + 'relative' => relative_date($item['edited']) + ); } $commentww = ''; $sparkle = ''; @@ -111,7 +112,6 @@ class Item extends BaseObject { $conv = $this->get_conversation(); - $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) ? t('Private Message') @@ -134,22 +134,24 @@ class Item extends BaseObject { $drop = array( 'dropping' => $dropping, 'pagedrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $item['pagedrop'] : ''), - 'select' => t('Select'), - 'delete' => t('Delete'), + 'select' => t('Select'), + 'delete' => t('Delete'), ); $filer = (($conv->get_profile_owner() == local_user()) ? t("save to folder") : false); $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true); $profile_name = htmlentities(((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']); - if($item['author-link'] && (! $item['author-name'])) + if ($item['author-link'] && (! $item['author-name'])) { $profile_name = $item['author-link']; + } $sp = false; $profile_link = best_link_url($item,$sp); if ($profile_link === 'mailbox') { $profile_link = ''; } + if ($sp) { $sparkle = ' sparkle'; } else { @@ -198,13 +200,14 @@ class Item extends BaseObject { // process action responses - e.g. like/dislike/attend/agree/whatever $response_verbs = array('like'); - if(feature_enabled($conv->get_profile_owner(),'dislike')) + if (feature_enabled($conv->get_profile_owner(),'dislike')) { $response_verbs[] = 'dislike'; - if($item['object-type'] === ACTIVITY_OBJ_EVENT) { + } + if ($item['object-type'] === ACTIVITY_OBJ_EVENT) { $response_verbs[] = 'attendyes'; $response_verbs[] = 'attendno'; $response_verbs[] = 'attendmaybe'; - if($conv->is_writable()) { + if ($conv->is_writable()) { $isevent = true; $attend = array( t('I will attend'), t('I will not attend'), t('I might attend')); } @@ -213,8 +216,7 @@ class Item extends BaseObject { $responses = get_responses($conv_responses,$response_verbs,$this,$item); foreach ($response_verbs as $value=>$verbs) { - $responses[$verbs][output] = ((x($conv_responses[$verbs],$item['uri'])) ? format_like($conv_responses[$verbs][$item['uri']],$conv_responses[$verbs][$item['uri'] . '-l'],$verbs,$item['uri']) : ''); - + $responses[$verbs]['output'] = ((x($conv_responses[$verbs],$item['uri'])) ? format_like($conv_responses[$verbs][$item['uri']],$conv_responses[$verbs][$item['uri'] . '-l'],$verbs,$item['uri']) : ''); } /* @@ -224,20 +226,21 @@ class Item extends BaseObject { */ $this->check_wall_to_wall(); - if($this->is_wall_to_wall() && ($this->get_owner_url() == $this->get_redirect_url())) + if ($this->is_wall_to_wall() && ($this->get_owner_url() == $this->get_redirect_url())) { $osparkle = ' sparkle'; + } - if($this->is_toplevel()) { - if($conv->get_profile_owner() == local_user()) { + if ($this->is_toplevel()) { + if ($conv->get_profile_owner() == local_user()) { $isstarred = (($item['starred']) ? "starred" : "unstarred"); $star = array( - 'do' => t("add star"), - 'undo' => t("remove star"), - 'toggle' => t("toggle star status"), - 'classdo' => (($item['starred']) ? "hidden" : ""), + 'do' => t("add star"), + 'undo' => t("remove star"), + 'toggle' => t("toggle star status"), + 'classdo' => (($item['starred']) ? "hidden" : ""), 'classundo' => (($item['starred']) ? "" : "hidden"), - 'starred' => t('starred'), + 'starred' => t('starred'), ); $r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1", intval($item['uid']), @@ -245,19 +248,19 @@ class Item extends BaseObject { ); if (dbm::is_result($r)) { $ignore = array( - 'do' => t("ignore thread"), - 'undo' => t("unignore thread"), - 'toggle' => t("toggle ignore status"), - 'classdo' => (($r[0]['ignored']) ? "hidden" : ""), + 'do' => t("ignore thread"), + 'undo' => t("unignore thread"), + 'toggle' => t("toggle ignore status"), + 'classdo' => (($r[0]['ignored']) ? "hidden" : ""), 'classundo' => (($r[0]['ignored']) ? "" : "hidden"), - 'ignored' => t('ignored'), + 'ignored' => t('ignored'), ); } $tagger = ''; if(feature_enabled($conv->get_profile_owner(),'commtag')) { $tagger = array( - 'add' => t("add tag"), + 'add' => t("add tag"), 'class' => "", ); } @@ -266,17 +269,19 @@ class Item extends BaseObject { $indent = 'comment'; } - if($conv->is_writable()) { + if ($conv->is_writable()) { $buttons = array( 'like' => array( t("I like this \x28toggle\x29"), t("like")), 'dislike' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? array( t("I don't like this \x28toggle\x29"), t("dislike")) : ''), ); - if ($shareable) $buttons['share'] = array( t('Share this'), t('share')); + if ($shareable) { + $buttons['share'] = array( t('Share this'), t('share')); + } } $comment = $this->get_comment_box($indent); - if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0){ + if (strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0){ $shiny = 'shiny'; } @@ -298,8 +303,9 @@ class Item extends BaseObject { foreach ($languages as $language) { $langdata = explode(";", $language); - if ($langstr != "") + if ($langstr != "") { $langstr .= ", "; + } //$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)"; $langstr .= round($langdata[1]*100, 1)."% ".$langdata[0]; @@ -311,20 +317,19 @@ class Item extends BaseObject { list($categories, $folders) = get_cats_and_terms($item); - if($a->theme['template_engine'] === 'internal') { - $body_e = template_escape($body); - $text_e = strip_tags(template_escape($body)); - $name_e = template_escape($profile_name); - $title_e = template_escape($item['title']); - $location_e = template_escape($location); + if ($a->theme['template_engine'] === 'internal') { + $body_e = template_escape($body); + $text_e = strip_tags(template_escape($body)); + $name_e = template_escape($profile_name); + $title_e = template_escape($item['title']); + $location_e = template_escape($location); $owner_name_e = template_escape($this->get_owner_name()); - } - else { - $body_e = $body; - $text_e = strip_tags($body); - $name_e = $profile_name; - $title_e = $item['title']; - $location_e = $location; + } else { + $body_e = $body; + $text_e = strip_tags($body); + $name_e = $profile_name; + $title_e = $item['title']; + $location_e = $location; $owner_name_e = $this->get_owner_name(); } @@ -334,89 +339,93 @@ class Item extends BaseObject { $tagger = ''; } - if (($item["item_network"] == NETWORK_FEED) AND isset($buttons["like"])) + if (($item["item_network"] == NETWORK_FEED) AND isset($buttons["like"])) { unset($buttons["like"]); + } - if (($item["item_network"] == NETWORK_MAIL) AND isset($buttons["like"])) + if (($item["item_network"] == NETWORK_MAIL) AND isset($buttons["like"])) { unset($buttons["like"]); + } // Diaspora isn't able to do likes on comments - but red does if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment') AND - !diaspora::is_redmatrix($item["owner-link"]) AND isset($buttons["like"])) + !diaspora::is_redmatrix($item["owner-link"]) AND isset($buttons["like"])) { unset($buttons["like"]); + } // Diaspora doesn't has multithreaded comments - if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment')) + if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment')) { unset($comment); + } // Facebook can like comments - but it isn't programmed in the connector yet. - if (($item["item_network"] == NETWORK_FACEBOOK) AND ($indent == 'comment') AND isset($buttons["like"])) + if (($item["item_network"] == NETWORK_FACEBOOK) AND ($indent == 'comment') AND isset($buttons["like"])) { unset($buttons["like"]); + } $tmp_item = array( - 'template' => $this->get_template(), - - 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), - 'tags' => $item['tags'], - 'hashtags' => $item['hashtags'], - 'mentions' => $item['mentions'], - 'txt_cats' => t('Categories:'), - 'txt_folders' => t('Filed under:'), - 'has_cats' => ((count($categories)) ? 'true' : ''), - 'has_folders' => ((count($folders)) ? 'true' : ''), - 'categories' => $categories, - 'folders' => $folders, - 'body' => $body_e, - 'text' => $text_e, - 'id' => $this->get_id(), - 'guid' => urlencode($item['guid']), - 'isevent' => $isevent, - 'attend' => $attend, - 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), - 'olinktitle' => sprintf( t('View %s\'s profile @ %s'), htmlentities($this->get_owner_name()), ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])), - 'to' => t('to'), - 'via' => t('via'), - 'wall' => t('Wall-to-Wall'), - 'vwall' => t('via Wall-To-Wall:'), - 'profile_url' => $profile_link, + 'template' => $this->get_template(), + 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), + 'tags' => $item['tags'], + 'hashtags' => $item['hashtags'], + 'mentions' => $item['mentions'], + 'txt_cats' => t('Categories:'), + 'txt_folders' => t('Filed under:'), + 'has_cats' => ((count($categories)) ? 'true' : ''), + 'has_folders' => ((count($folders)) ? 'true' : ''), + 'categories' => $categories, + 'folders' => $folders, + 'body' => $body_e, + 'text' => $text_e, + 'id' => $this->get_id(), + 'guid' => urlencode($item['guid']), + 'isevent' => $isevent, + 'attend' => $attend, + 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), + 'olinktitle' => sprintf( t('View %s\'s profile @ %s'), htmlentities($this->get_owner_name()), ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])), + 'to' => t('to'), + 'via' => t('via'), + 'wall' => t('Wall-to-Wall'), + 'vwall' => t('via Wall-To-Wall:'), + 'profile_url' => $profile_link, 'item_photo_menu' => item_photo_menu($item), - 'name' => $name_e, - 'thumb' => $a->remove_baseurl(proxy_url($item['author-thumb'], false, PROXY_SIZE_THUMB)), - 'osparkle' => $osparkle, - 'sparkle' => $sparkle, - 'title' => $title_e, - 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), - 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), - 'app' => $item['app'], - 'created' => relative_date($item['created']), - 'lock' => $lock, - 'location' => $location_e, - 'indent' => $indent, - 'shiny' => $shiny, - 'owner_url' => $this->get_owner_url(), - 'owner_photo' => $a->remove_baseurl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)), - 'owner_name' => htmlentities($owner_name_e), - 'plink' => get_plink($item), - 'edpost' => ((feature_enabled($conv->get_profile_owner(),'edit_posts')) ? $edpost : ''), - 'isstarred' => $isstarred, - 'star' => ((feature_enabled($conv->get_profile_owner(),'star_posts')) ? $star : ''), - 'ignore' => ((feature_enabled($conv->get_profile_owner(),'ignore_posts')) ? $ignore : ''), - 'tagger' => $tagger, - 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''), - 'drop' => $drop, - 'vote' => $buttons, - 'like' => $responses['like']['output'], - 'dislike' => $responses['dislike']['output'], - 'responses' => $responses, - 'switchcomment' => t('Comment'), - 'comment' => $comment, - 'previewing' => ($conv->is_preview() ? ' preview ' : ''), - 'wait' => t('Please wait'), - 'thread_level' => $thread_level, - 'postopts' => $langstr, - 'edited' => $edited, - 'network' => $item["item_network"], - 'network_name' => network_to_name($item['item_network'], $profile_link), + 'name' => $name_e, + 'thumb' => $a->remove_baseurl(proxy_url($item['author-thumb'], false, PROXY_SIZE_THUMB)), + 'osparkle' => $osparkle, + 'sparkle' => $sparkle, + 'title' => $title_e, + 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), + 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), + 'app' => $item['app'], + 'created' => relative_date($item['created']), + 'lock' => $lock, + 'location' => $location_e, + 'indent' => $indent, + 'shiny' => $shiny, + 'owner_url' => $this->get_owner_url(), + 'owner_photo' => $a->remove_baseurl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)), + 'owner_name' => htmlentities($owner_name_e), + 'plink' => get_plink($item), + 'edpost' => ((feature_enabled($conv->get_profile_owner(),'edit_posts')) ? $edpost : ''), + 'isstarred' => $isstarred, + 'star' => ((feature_enabled($conv->get_profile_owner(),'star_posts')) ? $star : ''), + 'ignore' => ((feature_enabled($conv->get_profile_owner(),'ignore_posts')) ? $ignore : ''), + 'tagger' => $tagger, + 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''), + 'drop' => $drop, + 'vote' => $buttons, + 'like' => $responses['like']['output'], + 'dislike' => $responses['dislike']['output'], + 'responses' => $responses, + 'switchcomment' => t('Comment'), + 'comment' => $comment, + 'previewing' => ($conv->is_preview() ? ' preview ' : ''), + 'wait' => t('Please wait'), + 'thread_level' => $thread_level, + 'postopts' => $langstr, + 'edited' => $edited, + 'network' => $item["item_network"], + 'network_name' => network_to_name($item['item_network'], $profile_link), ); $arr = array('item' => $item, 'output' => $tmp_item); @@ -427,39 +436,37 @@ class Item extends BaseObject { $result['children'] = array(); $children = $this->get_children(); $nb_children = count($children); - if($nb_children > 0) { - foreach($children as $child) { + if ($nb_children > 0) { + foreach ($children as $child) { $result['children'][] = $child->get_template_data($conv_responses, $thread_level + 1); } // Collapse - if(($nb_children > 2) || ($thread_level > 1)) { + if (($nb_children > 2) || ($thread_level > 1)) { $result['children'][0]['comment_firstcollapsed'] = true; $result['children'][0]['num_comments'] = sprintf( tt('%d comment','%d comments',$total_children),$total_children ); $result['children'][0]['hidden_comments_num'] = $total_children; $result['children'][0]['hidden_comments_text'] = tt('comment', 'comments', $total_children); $result['children'][0]['hide_text'] = t('show more'); - if($thread_level > 1) { + if ($thread_level > 1) { $result['children'][$nb_children - 1]['comment_lastcollapsed'] = true; - } - else { + } else { $result['children'][$nb_children - 3]['comment_lastcollapsed'] = true; } } } if ($this->is_toplevel()) { - $result['total_comments_num'] = "$total_children"; - $result['total_comments_text'] = tt('comment', 'comments', $total_children); + $result['total_comments_num'] = "$total_children"; + $result['total_comments_text'] = tt('comment', 'comments', $total_children); } $result['private'] = $item['private']; $result['toplevel'] = ($this->is_toplevel() ? 'toplevel_item' : ''); - if($this->is_threaded()) { + if ($this->is_threaded()) { $result['flatten'] = false; $result['threaded'] = true; - } - else { + } else { $result['flatten'] = true; $result['threaded'] = false; } @@ -478,23 +485,21 @@ class Item extends BaseObject { /** * Add a child item */ - public function add_child($item) { + public function add_child(Item $item) { $item_id = $item->get_id(); - if(!$item_id) { + if (!$item_id) { logger('[ERROR] Item::add_child : Item has no ID!!', LOGGER_DEBUG); return false; - } - if($this->get_child($item->get_id())) { + } elseif ($this->get_child($item->get_id())) { logger('[WARN] Item::add_child : Item already exists ('. $item->get_id() .').', LOGGER_DEBUG); return false; } /* * Only add what will be displayed */ - if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) { + if ($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) { return false; - } - if(activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) { + } elseif (activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) { return false; } @@ -507,9 +512,10 @@ class Item extends BaseObject { * Get a child by its ID */ public function get_child($id) { - foreach($this->get_children() as $child) { - if($child->get_id() == $id) + foreach ($this->get_children() as $child) { + if ($child->get_id() == $id) { return $child; + } } return null; } @@ -546,8 +552,8 @@ class Item extends BaseObject { */ public function remove_child($item) { $id = $item->get_id(); - foreach($this->get_children() as $key => $child) { - if($child->get_id() == $id) { + foreach ($this->get_children() as $key => $child) { + if ($child->get_id() == $id) { $child->remove_parent(); unset($this->children[$key]); // Reindex the array, in order to make sure there won't be any trouble on loops using count() @@ -575,8 +581,9 @@ class Item extends BaseObject { $this->conversation = $conv; // Set it on our children too - foreach($this->get_children() as $child) + foreach ($this->get_children() as $child) { $child->set_conversation($conv); + } } /** @@ -603,7 +610,7 @@ class Item extends BaseObject { * _ false on failure */ public function get_data_value($name) { - if(!isset($this->data[$name])) { + if (!isset($this->data[$name])) { // logger('[ERROR] Item::get_data_value : Item has no value name "'. $name .'".', LOGGER_DEBUG); return false; } @@ -615,9 +622,7 @@ class Item extends BaseObject { * Set template */ private function set_template($name) { - $a = get_app(); - - if(!x($this->available_templates, $name)) { + if (!x($this->available_templates, $name)) { logger('[ERROR] Item::set_template : Template not available ("'. $name .'").', LOGGER_DEBUG); return false; } @@ -645,13 +650,14 @@ class Item extends BaseObject { private function is_writable() { $conv = $this->get_conversation(); - if($conv) { + if ($conv) { // This will allow us to comment on wall-to-wall items owned by our friends // and community forums even if somebody else wrote the post. // bug #517 - this fixes for conversation owner - if($conv->get_mode() == 'profile' && $conv->get_profile_owner() == local_user()) - return true; + if ($conv->get_mode() == 'profile' && $conv->get_profile_owner() == local_user()) { + return true; + } // this fixes for visitors return ($this->writable || ($this->is_visiting() && $conv->get_mode() == 'profile')); @@ -665,8 +671,8 @@ class Item extends BaseObject { private function count_descendants() { $children = $this->get_children(); $total = count($children); - if($total > 0) { - foreach($children as $child) { + if ($total > 0) { + foreach ($children as $child) { $total += $child->count_descendants(); } } @@ -689,7 +695,7 @@ class Item extends BaseObject { */ private function get_comment_box($indent) { $a = $this->get_app(); - if(!$this->is_toplevel() && !(get_config('system','thread_allow') && $a->theme_thread_allow)) { + if (!$this->is_toplevel() && !(get_config('system','thread_allow') && $a->theme_thread_allow)) { return ''; } @@ -697,48 +703,48 @@ class Item extends BaseObject { $conv = $this->get_conversation(); $template = get_markup_template($this->get_comment_box_template()); $ww = ''; - if( ($conv->get_mode() === 'network') && $this->is_wall_to_wall() ) + if ( ($conv->get_mode() === 'network') && $this->is_wall_to_wall() ) $ww = 'ww'; - if($conv->is_writable() && $this->is_writable()) { + if ($conv->is_writable() && $this->is_writable()) { $qc = $qcomment = null; /* * Hmmm, code depending on the presence of a particular plugin? * This should be better if done by a hook */ - if(in_array('qcomment',$a->plugins)) { + if (in_array('qcomment',$a->plugins)) { $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null); $qcomment = (($qc) ? explode("\n",$qc) : null); } $comment_box = replace_macros($template,array( '$return_path' => $a->query_string, - '$threaded' => $this->is_threaded(), -// '$jsreload' => (($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''), - '$jsreload' => '', - '$type' => (($conv->get_mode() === 'profile') ? 'wall-comment' : 'net-comment'), - '$id' => $this->get_id(), - '$parent' => $this->get_id(), - '$qcomment' => $qcomment, + '$threaded' => $this->is_threaded(), +// '$jsreload' => (($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''), + '$jsreload' => '', + '$type' => (($conv->get_mode() === 'profile') ? 'wall-comment' : 'net-comment'), + '$id' => $this->get_id(), + '$parent' => $this->get_id(), + '$qcomment' => $qcomment, '$profile_uid' => $conv->get_profile_owner(), - '$mylink' => $a->remove_baseurl($a->contact['url']), - '$mytitle' => t('This is you'), - '$myphoto' => $a->remove_baseurl($a->contact['thumb']), - '$comment' => t('Comment'), - '$submit' => t('Submit'), - '$edbold' => t('Bold'), - '$editalic' => t('Italic'), - '$eduline' => t('Underline'), - '$edquote' => t('Quote'), - '$edcode' => t('Code'), - '$edimg' => t('Image'), - '$edurl' => t('Link'), - '$edvideo' => t('Video'), - '$preview' => ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''), - '$indent' => $indent, - '$sourceapp' => t($a->sourcename), - '$ww' => (($conv->get_mode() === 'network') ? $ww : ''), - '$rand_num' => random_digits(12) + '$mylink' => $a->remove_baseurl($a->contact['url']), + '$mytitle' => t('This is you'), + '$myphoto' => $a->remove_baseurl($a->contact['thumb']), + '$comment' => t('Comment'), + '$submit' => t('Submit'), + '$edbold' => t('Bold'), + '$editalic' => t('Italic'), + '$eduline' => t('Underline'), + '$edquote' => t('Quote'), + '$edcode' => t('Code'), + '$edimg' => t('Image'), + '$edurl' => t('Link'), + '$edvideo' => t('Video'), + '$preview' => ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''), + '$indent' => $indent, + '$sourceapp' => t($a->sourcename), + '$ww' => (($conv->get_mode() === 'network') ? $ww : ''), + '$rand_num' => random_digits(12) )); } @@ -768,14 +774,13 @@ class Item extends BaseObject { $this->owner_photo = $a->page_contact['thumb']; $this->owner_name = $a->page_contact['name']; $this->wall_to_wall = true; - } - else if($this->get_data_value('owner-link')) { + } elseif($this->get_data_value('owner-link')) { $owner_linkmatch = (($this->get_data_value('owner-link')) && link_compare($this->get_data_value('owner-link'),$this->get_data_value('author-link'))); $alias_linkmatch = (($this->get_data_value('alias')) && link_compare($this->get_data_value('alias'),$this->get_data_value('author-link'))); $owner_namematch = (($this->get_data_value('owner-name')) && $this->get_data_value('owner-name') == $this->get_data_value('author-name')); - if((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) { + if ((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) { // The author url doesn't match the owner (typically the contact) // and also doesn't match the contact alias. @@ -791,18 +796,18 @@ class Item extends BaseObject { $this->owner_name = $this->get_data_value('owner-name'); $this->wall_to_wall = true; // If it is our contact, use a friendly redirect link - if((link_compare($this->get_data_value('owner-link'),$this->get_data_value('url'))) + if ((link_compare($this->get_data_value('owner-link'),$this->get_data_value('url'))) && ($this->get_data_value('network') === NETWORK_DFRN)) { $this->owner_url = $this->get_redirect_url(); - } - else + } else { $this->owner_url = zrl($this->get_data_value('owner-link')); + } } } } } - if(!$this->wall_to_wall) { + if (!$this->wall_to_wall) { $this->set_template('wall'); $this->owner_url = ''; $this->owner_photo = ''; @@ -830,8 +835,6 @@ class Item extends BaseObject { return $this->visiting; } - - - } +/// @TODO These are discouraged and should be removed: ?> From dfc2c1f805b775cf69418051965890da32e16a23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 11:21:50 +0100 Subject: [PATCH 65/96] Beatification/coding convention: - added a lot spaces to make it look nicer - added curly braces (coding convention) - added needed spaces (coding convention)get_id - removed obsolete $a = get_app() call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- object/Item.php | 383 ++++++++++++++++++++++++------------------------ 1 file changed, 193 insertions(+), 190 deletions(-) diff --git a/object/Item.php b/object/Item.php index d14b5418cc..e60344f7d3 100644 --- a/object/Item.php +++ b/object/Item.php @@ -52,21 +52,22 @@ class Item extends BaseObject { $ssl_state = ((local_user()) ? true : false); $this->redirect_url = 'redir/' . $this->get_data_value('cid') ; - if(get_config('system','thread_allow') && $a->theme_thread_allow && !$this->is_toplevel()) + if (get_config('system','thread_allow') && $a->theme_thread_allow && !$this->is_toplevel()) { $this->threaded = true; + } // Prepare the children - if(count($data['children'])) { - foreach($data['children'] as $item) { + if (count($data['children'])) { + foreach ($data['children'] as $item) { /* * Only add will be displayed */ - if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { - continue; - } - if(! visible_activity($item)) { + if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { + continue; + } elseif (! visible_activity($item)) { continue; } + $item['pagedrop'] = $data['pagedrop']; $child = new Item($item); $this->add_child($child); @@ -91,11 +92,11 @@ class Item extends BaseObject { $item = $this->get_data(); $edited = false; if (strcmp($item['created'], $item['edited'])<>0) { - $edited = array( - 'label' => t('This entry was edited'), - 'date' => datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r'), - 'relative' => relative_date($item['edited']) - ); + $edited = array( + 'label' => t('This entry was edited'), + 'date' => datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r'), + 'relative' => relative_date($item['edited']) + ); } $commentww = ''; $sparkle = ''; @@ -111,7 +112,6 @@ class Item extends BaseObject { $conv = $this->get_conversation(); - $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) ? t('Private Message') @@ -134,22 +134,24 @@ class Item extends BaseObject { $drop = array( 'dropping' => $dropping, 'pagedrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $item['pagedrop'] : ''), - 'select' => t('Select'), - 'delete' => t('Delete'), + 'select' => t('Select'), + 'delete' => t('Delete'), ); $filer = (($conv->get_profile_owner() == local_user()) ? t("save to folder") : false); $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true); $profile_name = htmlentities(((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']); - if($item['author-link'] && (! $item['author-name'])) + if ($item['author-link'] && (! $item['author-name'])) { $profile_name = $item['author-link']; + } $sp = false; $profile_link = best_link_url($item,$sp); if ($profile_link === 'mailbox') { $profile_link = ''; } + if ($sp) { $sparkle = ' sparkle'; } else { @@ -198,13 +200,14 @@ class Item extends BaseObject { // process action responses - e.g. like/dislike/attend/agree/whatever $response_verbs = array('like'); - if(feature_enabled($conv->get_profile_owner(),'dislike')) + if (feature_enabled($conv->get_profile_owner(),'dislike')) { $response_verbs[] = 'dislike'; - if($item['object-type'] === ACTIVITY_OBJ_EVENT) { + } + if ($item['object-type'] === ACTIVITY_OBJ_EVENT) { $response_verbs[] = 'attendyes'; $response_verbs[] = 'attendno'; $response_verbs[] = 'attendmaybe'; - if($conv->is_writable()) { + if ($conv->is_writable()) { $isevent = true; $attend = array( t('I will attend'), t('I will not attend'), t('I might attend')); } @@ -213,8 +216,7 @@ class Item extends BaseObject { $responses = get_responses($conv_responses,$response_verbs,$this,$item); foreach ($response_verbs as $value=>$verbs) { - $responses[$verbs][output] = ((x($conv_responses[$verbs],$item['uri'])) ? format_like($conv_responses[$verbs][$item['uri']],$conv_responses[$verbs][$item['uri'] . '-l'],$verbs,$item['uri']) : ''); - + $responses[$verbs]['output'] = ((x($conv_responses[$verbs],$item['uri'])) ? format_like($conv_responses[$verbs][$item['uri']],$conv_responses[$verbs][$item['uri'] . '-l'],$verbs,$item['uri']) : ''); } /* @@ -224,20 +226,21 @@ class Item extends BaseObject { */ $this->check_wall_to_wall(); - if($this->is_wall_to_wall() && ($this->get_owner_url() == $this->get_redirect_url())) + if ($this->is_wall_to_wall() && ($this->get_owner_url() == $this->get_redirect_url())) { $osparkle = ' sparkle'; + } - if($this->is_toplevel()) { - if($conv->get_profile_owner() == local_user()) { + if ($this->is_toplevel()) { + if ($conv->get_profile_owner() == local_user()) { $isstarred = (($item['starred']) ? "starred" : "unstarred"); $star = array( - 'do' => t("add star"), - 'undo' => t("remove star"), - 'toggle' => t("toggle star status"), - 'classdo' => (($item['starred']) ? "hidden" : ""), + 'do' => t("add star"), + 'undo' => t("remove star"), + 'toggle' => t("toggle star status"), + 'classdo' => (($item['starred']) ? "hidden" : ""), 'classundo' => (($item['starred']) ? "" : "hidden"), - 'starred' => t('starred'), + 'starred' => t('starred'), ); $r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1", intval($item['uid']), @@ -245,19 +248,19 @@ class Item extends BaseObject { ); if (dbm::is_result($r)) { $ignore = array( - 'do' => t("ignore thread"), - 'undo' => t("unignore thread"), - 'toggle' => t("toggle ignore status"), - 'classdo' => (($r[0]['ignored']) ? "hidden" : ""), + 'do' => t("ignore thread"), + 'undo' => t("unignore thread"), + 'toggle' => t("toggle ignore status"), + 'classdo' => (($r[0]['ignored']) ? "hidden" : ""), 'classundo' => (($r[0]['ignored']) ? "" : "hidden"), - 'ignored' => t('ignored'), + 'ignored' => t('ignored'), ); } $tagger = ''; if(feature_enabled($conv->get_profile_owner(),'commtag')) { $tagger = array( - 'add' => t("add tag"), + 'add' => t("add tag"), 'class' => "", ); } @@ -266,17 +269,19 @@ class Item extends BaseObject { $indent = 'comment'; } - if($conv->is_writable()) { + if ($conv->is_writable()) { $buttons = array( 'like' => array( t("I like this \x28toggle\x29"), t("like")), 'dislike' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? array( t("I don't like this \x28toggle\x29"), t("dislike")) : ''), ); - if ($shareable) $buttons['share'] = array( t('Share this'), t('share')); + if ($shareable) { + $buttons['share'] = array( t('Share this'), t('share')); + } } $comment = $this->get_comment_box($indent); - if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0){ + if (strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0){ $shiny = 'shiny'; } @@ -298,8 +303,9 @@ class Item extends BaseObject { foreach ($languages as $language) { $langdata = explode(";", $language); - if ($langstr != "") + if ($langstr != "") { $langstr .= ", "; + } //$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)"; $langstr .= round($langdata[1]*100, 1)."% ".$langdata[0]; @@ -311,20 +317,19 @@ class Item extends BaseObject { list($categories, $folders) = get_cats_and_terms($item); - if($a->theme['template_engine'] === 'internal') { - $body_e = template_escape($body); - $text_e = strip_tags(template_escape($body)); - $name_e = template_escape($profile_name); - $title_e = template_escape($item['title']); - $location_e = template_escape($location); + if ($a->theme['template_engine'] === 'internal') { + $body_e = template_escape($body); + $text_e = strip_tags(template_escape($body)); + $name_e = template_escape($profile_name); + $title_e = template_escape($item['title']); + $location_e = template_escape($location); $owner_name_e = template_escape($this->get_owner_name()); - } - else { - $body_e = $body; - $text_e = strip_tags($body); - $name_e = $profile_name; - $title_e = $item['title']; - $location_e = $location; + } else { + $body_e = $body; + $text_e = strip_tags($body); + $name_e = $profile_name; + $title_e = $item['title']; + $location_e = $location; $owner_name_e = $this->get_owner_name(); } @@ -334,89 +339,93 @@ class Item extends BaseObject { $tagger = ''; } - if (($item["item_network"] == NETWORK_FEED) AND isset($buttons["like"])) + if (($item["item_network"] == NETWORK_FEED) AND isset($buttons["like"])) { unset($buttons["like"]); + } - if (($item["item_network"] == NETWORK_MAIL) AND isset($buttons["like"])) + if (($item["item_network"] == NETWORK_MAIL) AND isset($buttons["like"])) { unset($buttons["like"]); + } // Diaspora isn't able to do likes on comments - but red does if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment') AND - !diaspora::is_redmatrix($item["owner-link"]) AND isset($buttons["like"])) + !diaspora::is_redmatrix($item["owner-link"]) AND isset($buttons["like"])) { unset($buttons["like"]); + } // Diaspora doesn't has multithreaded comments - if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment')) + if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment')) { unset($comment); + } // Facebook can like comments - but it isn't programmed in the connector yet. - if (($item["item_network"] == NETWORK_FACEBOOK) AND ($indent == 'comment') AND isset($buttons["like"])) + if (($item["item_network"] == NETWORK_FACEBOOK) AND ($indent == 'comment') AND isset($buttons["like"])) { unset($buttons["like"]); + } $tmp_item = array( - 'template' => $this->get_template(), - - 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), - 'tags' => $item['tags'], - 'hashtags' => $item['hashtags'], - 'mentions' => $item['mentions'], - 'txt_cats' => t('Categories:'), - 'txt_folders' => t('Filed under:'), - 'has_cats' => ((count($categories)) ? 'true' : ''), - 'has_folders' => ((count($folders)) ? 'true' : ''), - 'categories' => $categories, - 'folders' => $folders, - 'body' => $body_e, - 'text' => $text_e, - 'id' => $this->get_id(), - 'guid' => urlencode($item['guid']), - 'isevent' => $isevent, - 'attend' => $attend, - 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), - 'olinktitle' => sprintf( t('View %s\'s profile @ %s'), htmlentities($this->get_owner_name()), ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])), - 'to' => t('to'), - 'via' => t('via'), - 'wall' => t('Wall-to-Wall'), - 'vwall' => t('via Wall-To-Wall:'), - 'profile_url' => $profile_link, + 'template' => $this->get_template(), + 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), + 'tags' => $item['tags'], + 'hashtags' => $item['hashtags'], + 'mentions' => $item['mentions'], + 'txt_cats' => t('Categories:'), + 'txt_folders' => t('Filed under:'), + 'has_cats' => ((count($categories)) ? 'true' : ''), + 'has_folders' => ((count($folders)) ? 'true' : ''), + 'categories' => $categories, + 'folders' => $folders, + 'body' => $body_e, + 'text' => $text_e, + 'id' => $this->get_id(), + 'guid' => urlencode($item['guid']), + 'isevent' => $isevent, + 'attend' => $attend, + 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), + 'olinktitle' => sprintf( t('View %s\'s profile @ %s'), htmlentities($this->get_owner_name()), ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])), + 'to' => t('to'), + 'via' => t('via'), + 'wall' => t('Wall-to-Wall'), + 'vwall' => t('via Wall-To-Wall:'), + 'profile_url' => $profile_link, 'item_photo_menu' => item_photo_menu($item), - 'name' => $name_e, - 'thumb' => $a->remove_baseurl(proxy_url($item['author-thumb'], false, PROXY_SIZE_THUMB)), - 'osparkle' => $osparkle, - 'sparkle' => $sparkle, - 'title' => $title_e, - 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), - 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), - 'app' => $item['app'], - 'created' => relative_date($item['created']), - 'lock' => $lock, - 'location' => $location_e, - 'indent' => $indent, - 'shiny' => $shiny, - 'owner_url' => $this->get_owner_url(), - 'owner_photo' => $a->remove_baseurl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)), - 'owner_name' => htmlentities($owner_name_e), - 'plink' => get_plink($item), - 'edpost' => ((feature_enabled($conv->get_profile_owner(),'edit_posts')) ? $edpost : ''), - 'isstarred' => $isstarred, - 'star' => ((feature_enabled($conv->get_profile_owner(),'star_posts')) ? $star : ''), - 'ignore' => ((feature_enabled($conv->get_profile_owner(),'ignore_posts')) ? $ignore : ''), - 'tagger' => $tagger, - 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''), - 'drop' => $drop, - 'vote' => $buttons, - 'like' => $responses['like']['output'], - 'dislike' => $responses['dislike']['output'], - 'responses' => $responses, - 'switchcomment' => t('Comment'), - 'comment' => $comment, - 'previewing' => ($conv->is_preview() ? ' preview ' : ''), - 'wait' => t('Please wait'), - 'thread_level' => $thread_level, - 'postopts' => $langstr, - 'edited' => $edited, - 'network' => $item["item_network"], - 'network_name' => network_to_name($item['item_network'], $profile_link), + 'name' => $name_e, + 'thumb' => $a->remove_baseurl(proxy_url($item['author-thumb'], false, PROXY_SIZE_THUMB)), + 'osparkle' => $osparkle, + 'sparkle' => $sparkle, + 'title' => $title_e, + 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), + 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), + 'app' => $item['app'], + 'created' => relative_date($item['created']), + 'lock' => $lock, + 'location' => $location_e, + 'indent' => $indent, + 'shiny' => $shiny, + 'owner_url' => $this->get_owner_url(), + 'owner_photo' => $a->remove_baseurl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)), + 'owner_name' => htmlentities($owner_name_e), + 'plink' => get_plink($item), + 'edpost' => ((feature_enabled($conv->get_profile_owner(),'edit_posts')) ? $edpost : ''), + 'isstarred' => $isstarred, + 'star' => ((feature_enabled($conv->get_profile_owner(),'star_posts')) ? $star : ''), + 'ignore' => ((feature_enabled($conv->get_profile_owner(),'ignore_posts')) ? $ignore : ''), + 'tagger' => $tagger, + 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''), + 'drop' => $drop, + 'vote' => $buttons, + 'like' => $responses['like']['output'], + 'dislike' => $responses['dislike']['output'], + 'responses' => $responses, + 'switchcomment' => t('Comment'), + 'comment' => $comment, + 'previewing' => ($conv->is_preview() ? ' preview ' : ''), + 'wait' => t('Please wait'), + 'thread_level' => $thread_level, + 'postopts' => $langstr, + 'edited' => $edited, + 'network' => $item["item_network"], + 'network_name' => network_to_name($item['item_network'], $profile_link), ); $arr = array('item' => $item, 'output' => $tmp_item); @@ -427,39 +436,37 @@ class Item extends BaseObject { $result['children'] = array(); $children = $this->get_children(); $nb_children = count($children); - if($nb_children > 0) { - foreach($children as $child) { + if ($nb_children > 0) { + foreach ($children as $child) { $result['children'][] = $child->get_template_data($conv_responses, $thread_level + 1); } // Collapse - if(($nb_children > 2) || ($thread_level > 1)) { + if (($nb_children > 2) || ($thread_level > 1)) { $result['children'][0]['comment_firstcollapsed'] = true; $result['children'][0]['num_comments'] = sprintf( tt('%d comment','%d comments',$total_children),$total_children ); $result['children'][0]['hidden_comments_num'] = $total_children; $result['children'][0]['hidden_comments_text'] = tt('comment', 'comments', $total_children); $result['children'][0]['hide_text'] = t('show more'); - if($thread_level > 1) { + if ($thread_level > 1) { $result['children'][$nb_children - 1]['comment_lastcollapsed'] = true; - } - else { + } else { $result['children'][$nb_children - 3]['comment_lastcollapsed'] = true; } } } if ($this->is_toplevel()) { - $result['total_comments_num'] = "$total_children"; - $result['total_comments_text'] = tt('comment', 'comments', $total_children); + $result['total_comments_num'] = "$total_children"; + $result['total_comments_text'] = tt('comment', 'comments', $total_children); } $result['private'] = $item['private']; $result['toplevel'] = ($this->is_toplevel() ? 'toplevel_item' : ''); - if($this->is_threaded()) { + if ($this->is_threaded()) { $result['flatten'] = false; $result['threaded'] = true; - } - else { + } else { $result['flatten'] = true; $result['threaded'] = false; } @@ -478,23 +485,21 @@ class Item extends BaseObject { /** * Add a child item */ - public function add_child($item) { + public function add_child(Item $item) { $item_id = $item->get_id(); - if(!$item_id) { + if (!$item_id) { logger('[ERROR] Item::add_child : Item has no ID!!', LOGGER_DEBUG); return false; - } - if($this->get_child($item->get_id())) { + } elseif ($this->get_child($item->get_id())) { logger('[WARN] Item::add_child : Item already exists ('. $item->get_id() .').', LOGGER_DEBUG); return false; } /* * Only add what will be displayed */ - if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) { + if ($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) { return false; - } - if(activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) { + } elseif (activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) { return false; } @@ -507,9 +512,10 @@ class Item extends BaseObject { * Get a child by its ID */ public function get_child($id) { - foreach($this->get_children() as $child) { - if($child->get_id() == $id) + foreach ($this->get_children() as $child) { + if ($child->get_id() == $id) { return $child; + } } return null; } @@ -546,8 +552,8 @@ class Item extends BaseObject { */ public function remove_child($item) { $id = $item->get_id(); - foreach($this->get_children() as $key => $child) { - if($child->get_id() == $id) { + foreach ($this->get_children() as $key => $child) { + if ($child->get_id() == $id) { $child->remove_parent(); unset($this->children[$key]); // Reindex the array, in order to make sure there won't be any trouble on loops using count() @@ -575,8 +581,9 @@ class Item extends BaseObject { $this->conversation = $conv; // Set it on our children too - foreach($this->get_children() as $child) + foreach ($this->get_children() as $child) { $child->set_conversation($conv); + } } /** @@ -603,7 +610,7 @@ class Item extends BaseObject { * _ false on failure */ public function get_data_value($name) { - if(!isset($this->data[$name])) { + if (!isset($this->data[$name])) { // logger('[ERROR] Item::get_data_value : Item has no value name "'. $name .'".', LOGGER_DEBUG); return false; } @@ -615,9 +622,7 @@ class Item extends BaseObject { * Set template */ private function set_template($name) { - $a = get_app(); - - if(!x($this->available_templates, $name)) { + if (!x($this->available_templates, $name)) { logger('[ERROR] Item::set_template : Template not available ("'. $name .'").', LOGGER_DEBUG); return false; } @@ -645,13 +650,14 @@ class Item extends BaseObject { private function is_writable() { $conv = $this->get_conversation(); - if($conv) { + if ($conv) { // This will allow us to comment on wall-to-wall items owned by our friends // and community forums even if somebody else wrote the post. // bug #517 - this fixes for conversation owner - if($conv->get_mode() == 'profile' && $conv->get_profile_owner() == local_user()) - return true; + if ($conv->get_mode() == 'profile' && $conv->get_profile_owner() == local_user()) { + return true; + } // this fixes for visitors return ($this->writable || ($this->is_visiting() && $conv->get_mode() == 'profile')); @@ -665,8 +671,8 @@ class Item extends BaseObject { private function count_descendants() { $children = $this->get_children(); $total = count($children); - if($total > 0) { - foreach($children as $child) { + if ($total > 0) { + foreach ($children as $child) { $total += $child->count_descendants(); } } @@ -689,7 +695,7 @@ class Item extends BaseObject { */ private function get_comment_box($indent) { $a = $this->get_app(); - if(!$this->is_toplevel() && !(get_config('system','thread_allow') && $a->theme_thread_allow)) { + if (!$this->is_toplevel() && !(get_config('system','thread_allow') && $a->theme_thread_allow)) { return ''; } @@ -697,48 +703,48 @@ class Item extends BaseObject { $conv = $this->get_conversation(); $template = get_markup_template($this->get_comment_box_template()); $ww = ''; - if( ($conv->get_mode() === 'network') && $this->is_wall_to_wall() ) + if ( ($conv->get_mode() === 'network') && $this->is_wall_to_wall() ) $ww = 'ww'; - if($conv->is_writable() && $this->is_writable()) { + if ($conv->is_writable() && $this->is_writable()) { $qc = $qcomment = null; /* * Hmmm, code depending on the presence of a particular plugin? * This should be better if done by a hook */ - if(in_array('qcomment',$a->plugins)) { + if (in_array('qcomment',$a->plugins)) { $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null); $qcomment = (($qc) ? explode("\n",$qc) : null); } $comment_box = replace_macros($template,array( '$return_path' => $a->query_string, - '$threaded' => $this->is_threaded(), -// '$jsreload' => (($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''), - '$jsreload' => '', - '$type' => (($conv->get_mode() === 'profile') ? 'wall-comment' : 'net-comment'), - '$id' => $this->get_id(), - '$parent' => $this->get_id(), - '$qcomment' => $qcomment, + '$threaded' => $this->is_threaded(), +// '$jsreload' => (($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''), + '$jsreload' => '', + '$type' => (($conv->get_mode() === 'profile') ? 'wall-comment' : 'net-comment'), + '$id' => $this->get_id(), + '$parent' => $this->get_id(), + '$qcomment' => $qcomment, '$profile_uid' => $conv->get_profile_owner(), - '$mylink' => $a->remove_baseurl($a->contact['url']), - '$mytitle' => t('This is you'), - '$myphoto' => $a->remove_baseurl($a->contact['thumb']), - '$comment' => t('Comment'), - '$submit' => t('Submit'), - '$edbold' => t('Bold'), - '$editalic' => t('Italic'), - '$eduline' => t('Underline'), - '$edquote' => t('Quote'), - '$edcode' => t('Code'), - '$edimg' => t('Image'), - '$edurl' => t('Link'), - '$edvideo' => t('Video'), - '$preview' => ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''), - '$indent' => $indent, - '$sourceapp' => t($a->sourcename), - '$ww' => (($conv->get_mode() === 'network') ? $ww : ''), - '$rand_num' => random_digits(12) + '$mylink' => $a->remove_baseurl($a->contact['url']), + '$mytitle' => t('This is you'), + '$myphoto' => $a->remove_baseurl($a->contact['thumb']), + '$comment' => t('Comment'), + '$submit' => t('Submit'), + '$edbold' => t('Bold'), + '$editalic' => t('Italic'), + '$eduline' => t('Underline'), + '$edquote' => t('Quote'), + '$edcode' => t('Code'), + '$edimg' => t('Image'), + '$edurl' => t('Link'), + '$edvideo' => t('Video'), + '$preview' => ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''), + '$indent' => $indent, + '$sourceapp' => t($a->sourcename), + '$ww' => (($conv->get_mode() === 'network') ? $ww : ''), + '$rand_num' => random_digits(12) )); } @@ -768,14 +774,13 @@ class Item extends BaseObject { $this->owner_photo = $a->page_contact['thumb']; $this->owner_name = $a->page_contact['name']; $this->wall_to_wall = true; - } - else if($this->get_data_value('owner-link')) { + } elseif($this->get_data_value('owner-link')) { $owner_linkmatch = (($this->get_data_value('owner-link')) && link_compare($this->get_data_value('owner-link'),$this->get_data_value('author-link'))); $alias_linkmatch = (($this->get_data_value('alias')) && link_compare($this->get_data_value('alias'),$this->get_data_value('author-link'))); $owner_namematch = (($this->get_data_value('owner-name')) && $this->get_data_value('owner-name') == $this->get_data_value('author-name')); - if((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) { + if ((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) { // The author url doesn't match the owner (typically the contact) // and also doesn't match the contact alias. @@ -791,18 +796,18 @@ class Item extends BaseObject { $this->owner_name = $this->get_data_value('owner-name'); $this->wall_to_wall = true; // If it is our contact, use a friendly redirect link - if((link_compare($this->get_data_value('owner-link'),$this->get_data_value('url'))) + if ((link_compare($this->get_data_value('owner-link'),$this->get_data_value('url'))) && ($this->get_data_value('network') === NETWORK_DFRN)) { $this->owner_url = $this->get_redirect_url(); - } - else + } else { $this->owner_url = zrl($this->get_data_value('owner-link')); + } } } } } - if(!$this->wall_to_wall) { + if (!$this->wall_to_wall) { $this->set_template('wall'); $this->owner_url = ''; $this->owner_photo = ''; @@ -830,8 +835,6 @@ class Item extends BaseObject { return $this->visiting; } - - - } +/// @TODO These are discouraged and should be removed: ?> From c9194b038145a5f4efa272052ad194e679c29611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 15:30:23 +0100 Subject: [PATCH 66/96] Continued with code convention: - added more curly braces - added space betweent if/foreach and brace - added spaces for beautification - converted some " to ' (mixed usage) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/Contact.php | 11 ++- include/acl_selectors.php | 148 ++++++++++++++++++++------------------ mod/fbrowser.php | 31 ++++---- mod/ostatus_subscribe.php | 17 +++-- 4 files changed, 111 insertions(+), 96 deletions(-) diff --git a/include/Contact.php b/include/Contact.php index 28a692541b..c86d6e7f80 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -85,11 +85,12 @@ function contact_remove($id) { function terminate_friendship($user,$self,$contact) { + /// @TODO Get rid of this, include/datetime.php should care about by itself $a = get_app(); require_once('include/datetime.php'); - if($contact['network'] === NETWORK_OSTATUS) { + if ($contact['network'] === NETWORK_OSTATUS) { require_once('include/ostatus.php'); @@ -99,16 +100,14 @@ function terminate_friendship($user,$self,$contact) { $item['follow'] = $contact["url"]; $slap = ostatus::salmon($item, $user); - if((x($contact,'notify')) && (strlen($contact['notify']))) { + if ((x($contact,'notify')) && (strlen($contact['notify']))) { require_once('include/salmon.php'); slapper($user,$contact['notify'],$slap); } - } - elseif($contact['network'] === NETWORK_DIASPORA) { + } elseif ($contact['network'] === NETWORK_DIASPORA) { require_once('include/diaspora.php'); Diaspora::send_unshare($user,$contact); - } - elseif($contact['network'] === NETWORK_DFRN) { + } elseif ($contact['network'] === NETWORK_DFRN) { require_once('include/dfrn.php'); dfrn::deliver($user,$contact,'placeholder', 1); } diff --git a/include/acl_selectors.php b/include/acl_selectors.php index b2e66c98f0..4c0b610d46 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -65,20 +65,24 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { $exclude = false; $size = 4; - if(is_array($options)) { - if(x($options,'size')) + if (is_array($options)) { + if (x($options,'size')) $size = $options['size']; - if(x($options,'mutual_friends')) + if (x($options,'mutual_friends')) { $mutual = true; - if(x($options,'single')) + } + if (x($options,'single')) { $single = true; - if(x($options,'multiple')) + } + if (x($options,'multiple')) { $single = false; - if(x($options,'exclude')) + } + if (x($options,'exclude')) { $exclude = $options['exclude']; + } - if(x($options,'networks')) { + if (x($options,'networks')) { switch($options['networks']) { case 'DFRN_ONLY': $networks = array(NETWORK_DFRN); @@ -146,10 +150,11 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { if (dbm::is_result($r)) { foreach ($r as $rr) { - if((is_array($preselected)) && in_array($rr['id'], $preselected)) + if ((is_array($preselected)) && in_array($rr['id'], $preselected)) { $selected = " selected=\"selected\" "; - else + } else { $selected = ''; + } $trimmed = mb_substr($rr['name'],0,20); @@ -231,8 +236,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p if ($privmail) { $trimmed = GetProfileUsername($rr['url'], $rr['name'], false); - } - else { + } else { $trimmed = mb_substr($rr['name'],0,20); } @@ -260,16 +264,22 @@ function fixacl(&$item) { function prune_deadguys($arr) { - if(! $arr) + if (! $arr) { return $arr; + } + $str = dbesc(implode(',',$arr)); + $r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 "); + if ($r) { $ret = array(); - foreach($r as $rr) + foreach ($r as $rr) { $ret[] = intval($rr['id']); + } return $ret; } + return array(); } @@ -545,35 +555,33 @@ function acl_lookup(&$a, $out_type = 'json') { dbesc(NETWORK_ZOT), dbesc(NETWORK_DIASPORA) ); - } - elseif($type == 'a') { + } elseif ($type == 'a') { $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact` WHERE `uid` = %d AND `pending` = 0 $sql_extra2 ORDER BY `name` ASC ", intval(local_user()) ); - } - elseif($type == 'x') { + } elseif ($type == 'x') { // autocomplete for global contact search (e.g. navbar search) $r = navbar_complete($a); $contacts = array(); if ($r) { - foreach($r as $g) { + foreach ($r as $g) { $contacts[] = array( - "photo" => proxy_url($g['photo'], false, PROXY_SIZE_MICRO), - "name" => $g['name'], - "nick" => (x($g['addr']) ? $g['addr'] : $g['url']), - "network" => $g['network'], - "link" => $g['url'], - "forum" => (x($g['community']) ? 1 : 0), + 'photo' => proxy_url($g['photo'], false, PROXY_SIZE_MICRO), + 'name' => $g['name'], + 'nick' => (x($g['addr']) ? $g['addr'] : $g['url']), + 'network' => $g['network'], + 'link' => $g['url'], + 'forum' => (x($g['community']) ? 1 : 0), ); } } $o = array( 'start' => $start, - 'count' => $count, - 'items' => $contacts, + 'count' => $count, + 'items' => $contacts, ); echo json_encode($o); killme(); @@ -583,16 +591,16 @@ function acl_lookup(&$a, $out_type = 'json') { if (dbm::is_result($r)) { - foreach($r as $g){ + foreach ($r as $g){ $contacts[] = array( - "type" => "c", - "photo" => proxy_url($g['micro'], false, PROXY_SIZE_MICRO), - "name" => htmlentities($g['name']), - "id" => intval($g['id']), - "network" => $g['network'], - "link" => $g['url'], - "nick" => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']), - "forum" => ((x($g['forum']) || x($g['prv'])) ? 1 : 0), + 'type' => 'c', + 'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO), + 'name' => htmlentities($g['name']), + 'id' => intval($g['id']), + 'network' => $g['network'], + 'link' => $g['url'], + 'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']), + 'forum' => ((x($g['forum']) || x($g['prv'])) ? 1 : 0), ); } } @@ -618,7 +626,7 @@ function acl_lookup(&$a, $out_type = 'json') { implode("','", $known_contacts) ); if (dbm::is_result($r)){ - foreach($r as $row) { + foreach ($r as $row) { // nickname.. $up = parse_url($row['author-link']); $nick = explode("/",$up['path']); @@ -626,14 +634,14 @@ function acl_lookup(&$a, $out_type = 'json') { $nick .= "@".$up['host']; // /nickname $unknow_contacts[] = array( - "type" => "c", - "photo" => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO), - "name" => htmlentities($row['author-name']), - "id" => '', - "network" => "unknown", - "link" => $row['author-link'], - "nick" => htmlentities($nick), - "forum" => false + 'type' => 'c', + 'photo' => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO), + 'name' => htmlentities($row['author-name']), + 'id' => '', + 'network' => 'unknown', + 'link' => $row['author-link'], + 'nick' => htmlentities($nick), + 'forum' => false ); } } @@ -643,34 +651,34 @@ function acl_lookup(&$a, $out_type = 'json') { } $results = array( - "tot" => $tot, - "start" => $start, - "count" => $count, - "groups" => $groups, - "contacts" => $contacts, - "items" => $items, - "type" => $type, - "search" => $search, + 'tot' => $tot, + 'start' => $start, + 'count' => $count, + 'groups' => $groups, + 'contacts' => $contacts, + 'items' => $items, + 'type' => $type, + 'search' => $search, ); call_hooks('acl_lookup_end', $results); if($out_type === 'html') { $o = array( - 'tot' => $results["tot"], - 'start' => $results["start"], - 'count' => $results["count"], - 'groups' => $results["groups"], - 'contacts' => $results["contacts"], + 'tot' => $results['tot'], + 'start' => $results['start'], + 'count' => $results['count'], + 'groups' => $results['groups'], + 'contacts' => $results['contacts'], ); return $o; } $o = array( - 'tot' => $results["tot"], - 'start' => $results["start"], - 'count' => $results["count"], - 'items' => $results["items"], + 'tot' => $results['tot'], + 'start' => $results['start'], + 'count' => $results['count'], + 'items' => $results['items'], ); echo json_encode($o); @@ -687,7 +695,7 @@ function navbar_complete(App &$a) { // logger('navbar_complete'); - if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { + if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { return; } @@ -698,28 +706,32 @@ function navbar_complete(App &$a) { $mode = $_REQUEST['smode']; // don't search if search term has less than 2 characters - if(! $search || mb_strlen($search) < 2) + if (! $search || mb_strlen($search) < 2) { return array(); + } - if(substr($search,0,1) === '@') + if (substr($search,0,1) === '@') { $search = substr($search,1); + } - if($localsearch) { + if ($localsearch) { $x = DirSearch::global_search_by_name($search, $mode); return $x; } - if(! $localsearch) { + if (! $localsearch) { $p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : ''); $x = z_fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search)); - if($x['success']) { + if ($x['success']) { $t = 0; $j = json_decode($x['body'],true); - if($j && $j['results']) { + if ($j && $j['results']) { return $j['results']; } } } + + /// @TODO Not needed here? return; } diff --git a/mod/fbrowser.php b/mod/fbrowser.php index 8c54a47ba2..9c8d2169ba 100644 --- a/mod/fbrowser.php +++ b/mod/fbrowser.php @@ -93,19 +93,19 @@ function fbrowser_content(App &$a){ $tpl = get_markup_template($template_file); $o = replace_macros($tpl, array( - '$type' => 'image', - '$baseurl' => App::get_baseurl(), - '$path' => $path, - '$folders' => $albums, - '$files' =>$files, - '$cancel' => t('Cancel'), + '$type' => 'image', + '$baseurl' => App::get_baseurl(), + '$path' => $path, + '$folders' => $albums, + '$files' => $files, + '$cancel' => t('Cancel'), '$nickname' => $a->user['nickname'], )); break; case "file": - if ($a->argc==2){ + if ($a->argc==2) { $files = q("SELECT `id`, `filename`, `filetype` FROM `attach` WHERE `uid` = %d ", intval(local_user()) ); @@ -115,10 +115,9 @@ function fbrowser_content(App &$a){ list($m1,$m2) = explode("/",$rr['filetype']); $filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip"); - if($a->theme['template_engine'] === 'internal') { + if ($a->theme['template_engine'] === 'internal') { $filename_e = template_escape($rr['filename']); - } - else { + } else { $filename_e = $rr['filename']; } @@ -129,12 +128,12 @@ function fbrowser_content(App &$a){ $tpl = get_markup_template($template_file); $o = replace_macros($tpl, array( - '$type' => 'file', - '$baseurl' => App::get_baseurl(), - '$path' => array( array( "", t("Files")) ), - '$folders' => false, - '$files' =>$files, - '$cancel' => t('Cancel'), + '$type' => 'file', + '$baseurl' => App::get_baseurl(), + '$path' => array( array( "", t("Files")) ), + '$folders' => false, + '$files' =>$files, + '$cancel' => t('Cancel'), '$nickname' => $a->user['nickname'], )); diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php index ba17e28b73..b2f536e6df 100644 --- a/mod/ostatus_subscribe.php +++ b/mod/ostatus_subscribe.php @@ -21,21 +21,24 @@ function ostatus_subscribe_content(App &$a) { if (get_pconfig($uid, "ostatus", "legacy_friends") == "") { - if ($_REQUEST["url"] == "") + if ($_REQUEST["url"] == "") { return $o.t("No contact provided."); + } $contact = probe_url($_REQUEST["url"]); - if (!$contact) + if (!$contact) { return $o.t("Couldn't fetch information for contact."); + } $api = $contact["baseurl"]."/api/"; // Fetching friends $data = z_fetch_url($api."statuses/friends.json?screen_name=".$contact["nick"]); - if (!$data["success"]) + if (!$data["success"]) { return $o.t("Couldn't fetch friends for contact."); + } set_pconfig($uid, "ostatus", "legacy_friends", $data["body"]); } @@ -61,12 +64,14 @@ function ostatus_subscribe_content(App &$a) { $data = probe_url($url); if ($data["network"] == NETWORK_OSTATUS) { $result = new_contact($uid,$url,true); - if ($result["success"]) + if ($result["success"]) { $o .= " - ".t("success"); - else + } else { $o .= " - ".t("failed"); - } else + } + } else { $o .= " - ".t("ignored"); + } $o .= "

    "; From 4011f244d6ca0f0e50241dfaae7aa6e0425e66fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 15:30:23 +0100 Subject: [PATCH 67/96] Continued with code convention: - added more curly braces - added space betweent if/foreach and brace - added spaces for beautification - converted some " to ' (mixed usage) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/Contact.php | 11 ++- include/acl_selectors.php | 148 ++++++++++++++++++++------------------ mod/fbrowser.php | 31 ++++---- mod/ostatus_subscribe.php | 17 +++-- 4 files changed, 111 insertions(+), 96 deletions(-) diff --git a/include/Contact.php b/include/Contact.php index 28a692541b..c86d6e7f80 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -85,11 +85,12 @@ function contact_remove($id) { function terminate_friendship($user,$self,$contact) { + /// @TODO Get rid of this, include/datetime.php should care about by itself $a = get_app(); require_once('include/datetime.php'); - if($contact['network'] === NETWORK_OSTATUS) { + if ($contact['network'] === NETWORK_OSTATUS) { require_once('include/ostatus.php'); @@ -99,16 +100,14 @@ function terminate_friendship($user,$self,$contact) { $item['follow'] = $contact["url"]; $slap = ostatus::salmon($item, $user); - if((x($contact,'notify')) && (strlen($contact['notify']))) { + if ((x($contact,'notify')) && (strlen($contact['notify']))) { require_once('include/salmon.php'); slapper($user,$contact['notify'],$slap); } - } - elseif($contact['network'] === NETWORK_DIASPORA) { + } elseif ($contact['network'] === NETWORK_DIASPORA) { require_once('include/diaspora.php'); Diaspora::send_unshare($user,$contact); - } - elseif($contact['network'] === NETWORK_DFRN) { + } elseif ($contact['network'] === NETWORK_DFRN) { require_once('include/dfrn.php'); dfrn::deliver($user,$contact,'placeholder', 1); } diff --git a/include/acl_selectors.php b/include/acl_selectors.php index b2e66c98f0..4c0b610d46 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -65,20 +65,24 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { $exclude = false; $size = 4; - if(is_array($options)) { - if(x($options,'size')) + if (is_array($options)) { + if (x($options,'size')) $size = $options['size']; - if(x($options,'mutual_friends')) + if (x($options,'mutual_friends')) { $mutual = true; - if(x($options,'single')) + } + if (x($options,'single')) { $single = true; - if(x($options,'multiple')) + } + if (x($options,'multiple')) { $single = false; - if(x($options,'exclude')) + } + if (x($options,'exclude')) { $exclude = $options['exclude']; + } - if(x($options,'networks')) { + if (x($options,'networks')) { switch($options['networks']) { case 'DFRN_ONLY': $networks = array(NETWORK_DFRN); @@ -146,10 +150,11 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { if (dbm::is_result($r)) { foreach ($r as $rr) { - if((is_array($preselected)) && in_array($rr['id'], $preselected)) + if ((is_array($preselected)) && in_array($rr['id'], $preselected)) { $selected = " selected=\"selected\" "; - else + } else { $selected = ''; + } $trimmed = mb_substr($rr['name'],0,20); @@ -231,8 +236,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p if ($privmail) { $trimmed = GetProfileUsername($rr['url'], $rr['name'], false); - } - else { + } else { $trimmed = mb_substr($rr['name'],0,20); } @@ -260,16 +264,22 @@ function fixacl(&$item) { function prune_deadguys($arr) { - if(! $arr) + if (! $arr) { return $arr; + } + $str = dbesc(implode(',',$arr)); + $r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 "); + if ($r) { $ret = array(); - foreach($r as $rr) + foreach ($r as $rr) { $ret[] = intval($rr['id']); + } return $ret; } + return array(); } @@ -545,35 +555,33 @@ function acl_lookup(&$a, $out_type = 'json') { dbesc(NETWORK_ZOT), dbesc(NETWORK_DIASPORA) ); - } - elseif($type == 'a') { + } elseif ($type == 'a') { $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact` WHERE `uid` = %d AND `pending` = 0 $sql_extra2 ORDER BY `name` ASC ", intval(local_user()) ); - } - elseif($type == 'x') { + } elseif ($type == 'x') { // autocomplete for global contact search (e.g. navbar search) $r = navbar_complete($a); $contacts = array(); if ($r) { - foreach($r as $g) { + foreach ($r as $g) { $contacts[] = array( - "photo" => proxy_url($g['photo'], false, PROXY_SIZE_MICRO), - "name" => $g['name'], - "nick" => (x($g['addr']) ? $g['addr'] : $g['url']), - "network" => $g['network'], - "link" => $g['url'], - "forum" => (x($g['community']) ? 1 : 0), + 'photo' => proxy_url($g['photo'], false, PROXY_SIZE_MICRO), + 'name' => $g['name'], + 'nick' => (x($g['addr']) ? $g['addr'] : $g['url']), + 'network' => $g['network'], + 'link' => $g['url'], + 'forum' => (x($g['community']) ? 1 : 0), ); } } $o = array( 'start' => $start, - 'count' => $count, - 'items' => $contacts, + 'count' => $count, + 'items' => $contacts, ); echo json_encode($o); killme(); @@ -583,16 +591,16 @@ function acl_lookup(&$a, $out_type = 'json') { if (dbm::is_result($r)) { - foreach($r as $g){ + foreach ($r as $g){ $contacts[] = array( - "type" => "c", - "photo" => proxy_url($g['micro'], false, PROXY_SIZE_MICRO), - "name" => htmlentities($g['name']), - "id" => intval($g['id']), - "network" => $g['network'], - "link" => $g['url'], - "nick" => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']), - "forum" => ((x($g['forum']) || x($g['prv'])) ? 1 : 0), + 'type' => 'c', + 'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO), + 'name' => htmlentities($g['name']), + 'id' => intval($g['id']), + 'network' => $g['network'], + 'link' => $g['url'], + 'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']), + 'forum' => ((x($g['forum']) || x($g['prv'])) ? 1 : 0), ); } } @@ -618,7 +626,7 @@ function acl_lookup(&$a, $out_type = 'json') { implode("','", $known_contacts) ); if (dbm::is_result($r)){ - foreach($r as $row) { + foreach ($r as $row) { // nickname.. $up = parse_url($row['author-link']); $nick = explode("/",$up['path']); @@ -626,14 +634,14 @@ function acl_lookup(&$a, $out_type = 'json') { $nick .= "@".$up['host']; // /nickname $unknow_contacts[] = array( - "type" => "c", - "photo" => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO), - "name" => htmlentities($row['author-name']), - "id" => '', - "network" => "unknown", - "link" => $row['author-link'], - "nick" => htmlentities($nick), - "forum" => false + 'type' => 'c', + 'photo' => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO), + 'name' => htmlentities($row['author-name']), + 'id' => '', + 'network' => 'unknown', + 'link' => $row['author-link'], + 'nick' => htmlentities($nick), + 'forum' => false ); } } @@ -643,34 +651,34 @@ function acl_lookup(&$a, $out_type = 'json') { } $results = array( - "tot" => $tot, - "start" => $start, - "count" => $count, - "groups" => $groups, - "contacts" => $contacts, - "items" => $items, - "type" => $type, - "search" => $search, + 'tot' => $tot, + 'start' => $start, + 'count' => $count, + 'groups' => $groups, + 'contacts' => $contacts, + 'items' => $items, + 'type' => $type, + 'search' => $search, ); call_hooks('acl_lookup_end', $results); if($out_type === 'html') { $o = array( - 'tot' => $results["tot"], - 'start' => $results["start"], - 'count' => $results["count"], - 'groups' => $results["groups"], - 'contacts' => $results["contacts"], + 'tot' => $results['tot'], + 'start' => $results['start'], + 'count' => $results['count'], + 'groups' => $results['groups'], + 'contacts' => $results['contacts'], ); return $o; } $o = array( - 'tot' => $results["tot"], - 'start' => $results["start"], - 'count' => $results["count"], - 'items' => $results["items"], + 'tot' => $results['tot'], + 'start' => $results['start'], + 'count' => $results['count'], + 'items' => $results['items'], ); echo json_encode($o); @@ -687,7 +695,7 @@ function navbar_complete(App &$a) { // logger('navbar_complete'); - if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { + if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { return; } @@ -698,28 +706,32 @@ function navbar_complete(App &$a) { $mode = $_REQUEST['smode']; // don't search if search term has less than 2 characters - if(! $search || mb_strlen($search) < 2) + if (! $search || mb_strlen($search) < 2) { return array(); + } - if(substr($search,0,1) === '@') + if (substr($search,0,1) === '@') { $search = substr($search,1); + } - if($localsearch) { + if ($localsearch) { $x = DirSearch::global_search_by_name($search, $mode); return $x; } - if(! $localsearch) { + if (! $localsearch) { $p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : ''); $x = z_fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search)); - if($x['success']) { + if ($x['success']) { $t = 0; $j = json_decode($x['body'],true); - if($j && $j['results']) { + if ($j && $j['results']) { return $j['results']; } } } + + /// @TODO Not needed here? return; } diff --git a/mod/fbrowser.php b/mod/fbrowser.php index 8c54a47ba2..9c8d2169ba 100644 --- a/mod/fbrowser.php +++ b/mod/fbrowser.php @@ -93,19 +93,19 @@ function fbrowser_content(App &$a){ $tpl = get_markup_template($template_file); $o = replace_macros($tpl, array( - '$type' => 'image', - '$baseurl' => App::get_baseurl(), - '$path' => $path, - '$folders' => $albums, - '$files' =>$files, - '$cancel' => t('Cancel'), + '$type' => 'image', + '$baseurl' => App::get_baseurl(), + '$path' => $path, + '$folders' => $albums, + '$files' => $files, + '$cancel' => t('Cancel'), '$nickname' => $a->user['nickname'], )); break; case "file": - if ($a->argc==2){ + if ($a->argc==2) { $files = q("SELECT `id`, `filename`, `filetype` FROM `attach` WHERE `uid` = %d ", intval(local_user()) ); @@ -115,10 +115,9 @@ function fbrowser_content(App &$a){ list($m1,$m2) = explode("/",$rr['filetype']); $filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip"); - if($a->theme['template_engine'] === 'internal') { + if ($a->theme['template_engine'] === 'internal') { $filename_e = template_escape($rr['filename']); - } - else { + } else { $filename_e = $rr['filename']; } @@ -129,12 +128,12 @@ function fbrowser_content(App &$a){ $tpl = get_markup_template($template_file); $o = replace_macros($tpl, array( - '$type' => 'file', - '$baseurl' => App::get_baseurl(), - '$path' => array( array( "", t("Files")) ), - '$folders' => false, - '$files' =>$files, - '$cancel' => t('Cancel'), + '$type' => 'file', + '$baseurl' => App::get_baseurl(), + '$path' => array( array( "", t("Files")) ), + '$folders' => false, + '$files' =>$files, + '$cancel' => t('Cancel'), '$nickname' => $a->user['nickname'], )); diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php index ba17e28b73..b2f536e6df 100644 --- a/mod/ostatus_subscribe.php +++ b/mod/ostatus_subscribe.php @@ -21,21 +21,24 @@ function ostatus_subscribe_content(App &$a) { if (get_pconfig($uid, "ostatus", "legacy_friends") == "") { - if ($_REQUEST["url"] == "") + if ($_REQUEST["url"] == "") { return $o.t("No contact provided."); + } $contact = probe_url($_REQUEST["url"]); - if (!$contact) + if (!$contact) { return $o.t("Couldn't fetch information for contact."); + } $api = $contact["baseurl"]."/api/"; // Fetching friends $data = z_fetch_url($api."statuses/friends.json?screen_name=".$contact["nick"]); - if (!$data["success"]) + if (!$data["success"]) { return $o.t("Couldn't fetch friends for contact."); + } set_pconfig($uid, "ostatus", "legacy_friends", $data["body"]); } @@ -61,12 +64,14 @@ function ostatus_subscribe_content(App &$a) { $data = probe_url($url); if ($data["network"] == NETWORK_OSTATUS) { $result = new_contact($uid,$url,true); - if ($result["success"]) + if ($result["success"]) { $o .= " - ".t("success"); - else + } else { $o .= " - ".t("failed"); - } else + } + } else { $o .= " - ".t("ignored"); + } $o .= "

    "; From 30642756e5a5fa30941e6e23e09b90d8092aef8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 16:50:40 +0100 Subject: [PATCH 68/96] Code style changed: - added more curly braces - made SQL keywords all-uppercase - added spaces between if/foreach and brace - // Is for single-line comments *only*, please don't abuse it for multiple line comments, use /* */ instead and a asterisk in front of every line. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/dbstructure.php | 91 ++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 37 deletions(-) diff --git a/include/dbstructure.php b/include/dbstructure.php index be1158eabe..50c2856ab6 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -26,7 +26,6 @@ function update_fail($update_id, $error_message){ } // every admin could had different language - foreach ($adminlist as $admin) { $lang = (($admin['language'])?$admin['language']:'en'); push_lang($lang); @@ -83,8 +82,9 @@ function table_structure($table) { if (dbm::is_result($indexes)) foreach ($indexes AS $index) { - if ($index["Index_type"] == "FULLTEXT") + if ($index["Index_type"] == "FULLTEXT") { continue; + } if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) { $indexdata[$index["Key_name"]] = array('UNIQUE'); @@ -95,26 +95,31 @@ function table_structure($table) { // To avoid the need to add this to every index definition we just ignore it here. // Exception are primary indexes // Since there are some combindex primary indexes we use the limit of 180 here. - if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY"))) + if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY"))) { $column .= "(".$index["Sub_part"].")"; + } $indexdata[$index["Key_name"]][] = $column; } if (dbm::is_result($structures)) { - foreach($structures AS $field) { + foreach ($structures AS $field) { $fielddata[$field["Field"]]["type"] = $field["Type"]; - if ($field["Null"] == "NO") + if ($field["Null"] == "NO") { $fielddata[$field["Field"]]["not null"] = true; + } - if (isset($field["Default"])) + if (isset($field["Default"])) { $fielddata[$field["Field"]]["default"] = $field["Default"]; + } - if ($field["Extra"] != "") + if ($field["Extra"] != "") { $fielddata[$field["Field"]]["extra"] = $field["Extra"]; + } - if ($field["Key"] == "PRI") + if ($field["Key"] == "PRI") { $fielddata[$field["Field"]]["primary"] = true; + } } } return(array("fields"=>$fielddata, "indexes"=>$indexdata)); @@ -138,13 +143,15 @@ function print_structure($database, $charset) { function update_structure($verbose, $action, $tables=null, $definition=null) { global $a, $db; - if ($action) + if ($action) { set_config('system', 'maintenance', 1); + } - if (isset($a->config["system"]["db_charset"])) + if (isset($a->config["system"]["db_charset"])) { $charset = $a->config["system"]["db_charset"]; - else + } else { $charset = "utf8"; + } $errors = false; @@ -153,8 +160,9 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { // Get the current structure $database = array(); - if (is_null($tables)) - $tables = q("show tables"); + if (is_null($tables)) { + $tables = q("SHOW TABLES"); + } foreach ($tables AS $table) { $table = current($table); @@ -164,21 +172,24 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { } // Get the definition - if (is_null($definition)) + if (is_null($definition)) { $definition = db_definition($charset); + } // Ensure index conversion to unique removes duplicates $sql_config = "SET session old_alter_table=1;"; - if ($verbose) + if ($verbose) { echo $sql_config."\n"; - if ($action) - @$db->q($sql_config); + } + if ($action) { + $db->q($sql_config); + } // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements if ((version_compare($db->server_info(), '5.7.4') >= 0) AND !(strpos($db->server_info(), 'MariaDB') !== false)) { $ignore = ''; - }else { + } else { $ignore = ' IGNORE'; } @@ -193,10 +204,12 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { } $is_new_table = True; } else { - // Drop the index if it isn't present in the definition - // or the definition differ from current status - // and index name doesn't start with "local_" - foreach ($database[$name]["indexes"] AS $indexname => $fieldnames) { + /* + * Drop the index if it isn't present in the definition + * or the definition differ from current status + * and index name doesn't start with "local_" + */ + foreach ($database[$name]["indexes"] as $indexname => $fieldnames) { $current_index_definition = implode(",",$fieldnames); if (isset($structure["indexes"][$indexname])) { $new_index_definition = implode(",",$structure["indexes"][$indexname]); @@ -205,39 +218,44 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { } if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') { $sql2=db_drop_index($indexname); - if ($sql3 == "") + if ($sql3 == "") { $sql3 = "ALTER".$ignore." TABLE `".$name."` ".$sql2; - else + } else { $sql3 .= ", ".$sql2; + } } } // Compare the field structure field by field foreach ($structure["fields"] AS $fieldname => $parameters) { if (!isset($database[$name]["fields"][$fieldname])) { $sql2=db_add_table_field($fieldname, $parameters); - if ($sql3 == "") + if ($sql3 == "") { $sql3 = "ALTER TABLE `".$name."` ".$sql2; - else + } else { $sql3 .= ", ".$sql2; + } } else { // Compare the field definition $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]); $new_field_definition = implode(",",$parameters); if ($current_field_definition != $new_field_definition) { $sql2=db_modify_table_field($fieldname, $parameters); - if ($sql3 == "") + if ($sql3 == "") { $sql3 = "ALTER TABLE `".$name."` ".$sql2; - else + } else { $sql3 .= ", ".$sql2; + } } } } } - // Create the index if the index don't exists in database - // or the definition differ from the current status. - // Don't create keys if table is new + /* + * Create the index if the index don't exists in database + * or the definition differ from the current status. + * Don't create keys if table is new + */ if (!$is_new_table) { foreach ($structure["indexes"] AS $indexname => $fieldnames) { if (isset($database[$name]["indexes"][$indexname])) { @@ -367,10 +385,11 @@ function db_create_index($indexname, $fieldnames, $method="ADD") { if ($names != "") $names .= ","; - if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) + if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) { $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")"; - else + } else { $names .= "`".dbesc($fieldname)."`"; + } } if ($indexname == "PRIMARY") { @@ -383,8 +402,9 @@ function db_create_index($indexname, $fieldnames, $method="ADD") { } function db_index_suffix($charset, $reduce = 0) { - if ($charset != "utf8mb4") + if ($charset != "utf8mb4") { return ""; + } // On utf8mb4 indexes can only have a length of 191 $indexlength = 191 - $reduce; @@ -1573,9 +1593,6 @@ function dbstructure_run(&$argv, &$argc) { echo "dumpsql dump database schema\n"; return; - - - } if (array_search(__file__,get_included_files())===0){ From 70a03f38e55126f444d92aad07a2eacf67ea427f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 16:50:40 +0100 Subject: [PATCH 69/96] Code style changed: - added more curly braces - made SQL keywords all-uppercase - added spaces between if/foreach and brace - // Is for single-line comments *only*, please don't abuse it for multiple line comments, use /* */ instead and a asterisk in front of every line. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/dbstructure.php | 91 ++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 37 deletions(-) diff --git a/include/dbstructure.php b/include/dbstructure.php index be1158eabe..50c2856ab6 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -26,7 +26,6 @@ function update_fail($update_id, $error_message){ } // every admin could had different language - foreach ($adminlist as $admin) { $lang = (($admin['language'])?$admin['language']:'en'); push_lang($lang); @@ -83,8 +82,9 @@ function table_structure($table) { if (dbm::is_result($indexes)) foreach ($indexes AS $index) { - if ($index["Index_type"] == "FULLTEXT") + if ($index["Index_type"] == "FULLTEXT") { continue; + } if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) { $indexdata[$index["Key_name"]] = array('UNIQUE'); @@ -95,26 +95,31 @@ function table_structure($table) { // To avoid the need to add this to every index definition we just ignore it here. // Exception are primary indexes // Since there are some combindex primary indexes we use the limit of 180 here. - if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY"))) + if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY"))) { $column .= "(".$index["Sub_part"].")"; + } $indexdata[$index["Key_name"]][] = $column; } if (dbm::is_result($structures)) { - foreach($structures AS $field) { + foreach ($structures AS $field) { $fielddata[$field["Field"]]["type"] = $field["Type"]; - if ($field["Null"] == "NO") + if ($field["Null"] == "NO") { $fielddata[$field["Field"]]["not null"] = true; + } - if (isset($field["Default"])) + if (isset($field["Default"])) { $fielddata[$field["Field"]]["default"] = $field["Default"]; + } - if ($field["Extra"] != "") + if ($field["Extra"] != "") { $fielddata[$field["Field"]]["extra"] = $field["Extra"]; + } - if ($field["Key"] == "PRI") + if ($field["Key"] == "PRI") { $fielddata[$field["Field"]]["primary"] = true; + } } } return(array("fields"=>$fielddata, "indexes"=>$indexdata)); @@ -138,13 +143,15 @@ function print_structure($database, $charset) { function update_structure($verbose, $action, $tables=null, $definition=null) { global $a, $db; - if ($action) + if ($action) { set_config('system', 'maintenance', 1); + } - if (isset($a->config["system"]["db_charset"])) + if (isset($a->config["system"]["db_charset"])) { $charset = $a->config["system"]["db_charset"]; - else + } else { $charset = "utf8"; + } $errors = false; @@ -153,8 +160,9 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { // Get the current structure $database = array(); - if (is_null($tables)) - $tables = q("show tables"); + if (is_null($tables)) { + $tables = q("SHOW TABLES"); + } foreach ($tables AS $table) { $table = current($table); @@ -164,21 +172,24 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { } // Get the definition - if (is_null($definition)) + if (is_null($definition)) { $definition = db_definition($charset); + } // Ensure index conversion to unique removes duplicates $sql_config = "SET session old_alter_table=1;"; - if ($verbose) + if ($verbose) { echo $sql_config."\n"; - if ($action) - @$db->q($sql_config); + } + if ($action) { + $db->q($sql_config); + } // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements if ((version_compare($db->server_info(), '5.7.4') >= 0) AND !(strpos($db->server_info(), 'MariaDB') !== false)) { $ignore = ''; - }else { + } else { $ignore = ' IGNORE'; } @@ -193,10 +204,12 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { } $is_new_table = True; } else { - // Drop the index if it isn't present in the definition - // or the definition differ from current status - // and index name doesn't start with "local_" - foreach ($database[$name]["indexes"] AS $indexname => $fieldnames) { + /* + * Drop the index if it isn't present in the definition + * or the definition differ from current status + * and index name doesn't start with "local_" + */ + foreach ($database[$name]["indexes"] as $indexname => $fieldnames) { $current_index_definition = implode(",",$fieldnames); if (isset($structure["indexes"][$indexname])) { $new_index_definition = implode(",",$structure["indexes"][$indexname]); @@ -205,39 +218,44 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { } if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') { $sql2=db_drop_index($indexname); - if ($sql3 == "") + if ($sql3 == "") { $sql3 = "ALTER".$ignore." TABLE `".$name."` ".$sql2; - else + } else { $sql3 .= ", ".$sql2; + } } } // Compare the field structure field by field foreach ($structure["fields"] AS $fieldname => $parameters) { if (!isset($database[$name]["fields"][$fieldname])) { $sql2=db_add_table_field($fieldname, $parameters); - if ($sql3 == "") + if ($sql3 == "") { $sql3 = "ALTER TABLE `".$name."` ".$sql2; - else + } else { $sql3 .= ", ".$sql2; + } } else { // Compare the field definition $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]); $new_field_definition = implode(",",$parameters); if ($current_field_definition != $new_field_definition) { $sql2=db_modify_table_field($fieldname, $parameters); - if ($sql3 == "") + if ($sql3 == "") { $sql3 = "ALTER TABLE `".$name."` ".$sql2; - else + } else { $sql3 .= ", ".$sql2; + } } } } } - // Create the index if the index don't exists in database - // or the definition differ from the current status. - // Don't create keys if table is new + /* + * Create the index if the index don't exists in database + * or the definition differ from the current status. + * Don't create keys if table is new + */ if (!$is_new_table) { foreach ($structure["indexes"] AS $indexname => $fieldnames) { if (isset($database[$name]["indexes"][$indexname])) { @@ -367,10 +385,11 @@ function db_create_index($indexname, $fieldnames, $method="ADD") { if ($names != "") $names .= ","; - if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) + if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) { $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")"; - else + } else { $names .= "`".dbesc($fieldname)."`"; + } } if ($indexname == "PRIMARY") { @@ -383,8 +402,9 @@ function db_create_index($indexname, $fieldnames, $method="ADD") { } function db_index_suffix($charset, $reduce = 0) { - if ($charset != "utf8mb4") + if ($charset != "utf8mb4") { return ""; + } // On utf8mb4 indexes can only have a length of 191 $indexlength = 191 - $reduce; @@ -1573,9 +1593,6 @@ function dbstructure_run(&$argv, &$argc) { echo "dumpsql dump database schema\n"; return; - - - } if (array_search(__file__,get_included_files())===0){ From 8db0be09b844a49e096110fb856cf847d6bff9a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 16:58:50 +0100 Subject: [PATCH 70/96] Coding convention applied: - added curly braces - added space between if/foreach and brace - avoided 2 return statements (true/false) by replacing them with just one - added TODO for applying above to all findings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/items.php | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/include/items.php b/include/items.php index c75bc768c2..327096341c 100644 --- a/include/items.php +++ b/include/items.php @@ -1260,8 +1260,9 @@ function tag_deliver($uid,$item_id) { $c = q("select name, url, thumb from contact where self = 1 and uid = %d limit 1", intval($u[0]['uid']) ); - if (! count($c)) + if (! count($c)) { return; + } // also reset all the privacy bits to the forum default permissions @@ -1269,8 +1270,8 @@ function tag_deliver($uid,$item_id) { $forum_mode = (($prvgroup) ? 2 : 1); - q("update item set wall = 1, origin = 1, forum_mode = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s', - `private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' where id = %d", + q("UPDATE `item` SET `wall` = 1, `origin` = 1, `forum_mode` = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s', + `private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `id` = %d", intval($forum_mode), dbesc($c[0]['name']), dbesc($c[0]['url']), @@ -1322,7 +1323,7 @@ function tgroup_check($uid,$item) { $cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER); if ($cnt) { - foreach($matches as $mtch) { + foreach ($matches as $mtch) { if (link_compare($link,$mtch[1]) || link_compare($dlink,$mtch[1])) { $mention = true; logger('tgroup_check: mention found: ' . $mtch[2]); @@ -1330,13 +1331,12 @@ function tgroup_check($uid,$item) { } } - if (! $mention) + if (! $mention) { return false; + } - if ((! $community_page) && (! $prvgroup)) - return false; - - return true; + /// @TODO Combines both return statements into one + return (($community_page) || ($prvgroup)); } /* @@ -1348,15 +1348,16 @@ function tgroup_check($uid,$item) { assumes the update has been seen before and should be ignored. */ function edited_timestamp_is_newer($existing, $update) { - if (!x($existing,'edited') || !$existing['edited']) { - return true; - } - if (!x($update,'edited') || !$update['edited']) { - return false; - } - $existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']); - $update_edited = datetime_convert('UTC', 'UTC', $update['edited']); - return (strcmp($existing_edited, $update_edited) < 0); + if (!x($existing,'edited') || !$existing['edited']) { + return true; + } + if (!x($update,'edited') || !$update['edited']) { + return false; + } + + $existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']); + $update_edited = datetime_convert('UTC', 'UTC', $update['edited']); + return (strcmp($existing_edited, $update_edited) < 0); } /** From 1c0bd914584c2f58432e5bef7083f71c9d6a09fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 16:58:50 +0100 Subject: [PATCH 71/96] Coding convention applied: - added curly braces - added space between if/foreach and brace - avoided 2 return statements (true/false) by replacing them with just one - added TODO for applying above to all findings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/items.php | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/include/items.php b/include/items.php index c75bc768c2..327096341c 100644 --- a/include/items.php +++ b/include/items.php @@ -1260,8 +1260,9 @@ function tag_deliver($uid,$item_id) { $c = q("select name, url, thumb from contact where self = 1 and uid = %d limit 1", intval($u[0]['uid']) ); - if (! count($c)) + if (! count($c)) { return; + } // also reset all the privacy bits to the forum default permissions @@ -1269,8 +1270,8 @@ function tag_deliver($uid,$item_id) { $forum_mode = (($prvgroup) ? 2 : 1); - q("update item set wall = 1, origin = 1, forum_mode = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s', - `private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' where id = %d", + q("UPDATE `item` SET `wall` = 1, `origin` = 1, `forum_mode` = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s', + `private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `id` = %d", intval($forum_mode), dbesc($c[0]['name']), dbesc($c[0]['url']), @@ -1322,7 +1323,7 @@ function tgroup_check($uid,$item) { $cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER); if ($cnt) { - foreach($matches as $mtch) { + foreach ($matches as $mtch) { if (link_compare($link,$mtch[1]) || link_compare($dlink,$mtch[1])) { $mention = true; logger('tgroup_check: mention found: ' . $mtch[2]); @@ -1330,13 +1331,12 @@ function tgroup_check($uid,$item) { } } - if (! $mention) + if (! $mention) { return false; + } - if ((! $community_page) && (! $prvgroup)) - return false; - - return true; + /// @TODO Combines both return statements into one + return (($community_page) || ($prvgroup)); } /* @@ -1348,15 +1348,16 @@ function tgroup_check($uid,$item) { assumes the update has been seen before and should be ignored. */ function edited_timestamp_is_newer($existing, $update) { - if (!x($existing,'edited') || !$existing['edited']) { - return true; - } - if (!x($update,'edited') || !$update['edited']) { - return false; - } - $existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']); - $update_edited = datetime_convert('UTC', 'UTC', $update['edited']); - return (strcmp($existing_edited, $update_edited) < 0); + if (!x($existing,'edited') || !$existing['edited']) { + return true; + } + if (!x($update,'edited') || !$update['edited']) { + return false; + } + + $existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']); + $update_edited = datetime_convert('UTC', 'UTC', $update['edited']); + return (strcmp($existing_edited, $update_edited) < 0); } /** From 5547bc2cc254d27c78bcdd15123a024b52e0a99b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 17:03:00 +0100 Subject: [PATCH 72/96] Continued rewriting a bit: - more usage of dbm::is_result() - nicer look of code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/items.php | 4 +--- mod/allfriends.php | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/include/items.php b/include/items.php index 327096341c..8d95c35529 100644 --- a/include/items.php +++ b/include/items.php @@ -1260,7 +1260,7 @@ function tag_deliver($uid,$item_id) { $c = q("select name, url, thumb from contact where self = 1 and uid = %d limit 1", intval($u[0]['uid']) ); - if (! count($c)) { + if (! dbm::is_result($c)) { return; } @@ -1293,8 +1293,6 @@ function tag_deliver($uid,$item_id) { function tgroup_check($uid,$item) { - $a = get_app(); - $mention = false; // check that the message originated elsewhere and is a top-level post diff --git a/mod/allfriends.php b/mod/allfriends.php index 9e14a67d2e..7a134a7be1 100644 --- a/mod/allfriends.php +++ b/mod/allfriends.php @@ -28,7 +28,7 @@ function allfriends_content(App &$a) { intval(local_user()) ); - if (! count($c)) { + if (! dbm::is_result($c)) { return; } @@ -71,20 +71,20 @@ function allfriends_content(App &$a) { } $entry = array( - 'url' => $rr['url'], - 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), - 'name' => htmlentities($contact_details['name']), - 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB), - 'img_hover' => htmlentities($contact_details['name']), - 'details' => $contact_details['location'], - 'tags' => $contact_details['keywords'], - 'about' => $contact_details['about'], - 'account_type' => account_type($contact_details), - 'network' => network_to_name($contact_details['network'], $contact_details['url']), - 'photo_menu' => $photo_menu, - 'conntxt' => t('Connect'), - 'connlnk' => $connlnk, - 'id' => ++$id, + 'url' => $rr['url'], + 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), + 'name' => htmlentities($contact_details['name']), + 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB), + 'img_hover' => htmlentities($contact_details['name']), + 'details' => $contact_details['location'], + 'tags' => $contact_details['keywords'], + 'about' => $contact_details['about'], + 'account_type' => account_type($contact_details), + 'network' => network_to_name($contact_details['network'], $contact_details['url']), + 'photo_menu' => $photo_menu, + 'conntxt' => t('Connect'), + 'connlnk' => $connlnk, + 'id' => ++$id, ); $entries[] = $entry; } From b33a28c082ab1dae9d982e72f2d2bf5f055dfea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 17:03:00 +0100 Subject: [PATCH 73/96] Continued rewriting a bit: - more usage of dbm::is_result() - nicer look of code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/items.php | 4 +--- mod/allfriends.php | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/include/items.php b/include/items.php index 327096341c..8d95c35529 100644 --- a/include/items.php +++ b/include/items.php @@ -1260,7 +1260,7 @@ function tag_deliver($uid,$item_id) { $c = q("select name, url, thumb from contact where self = 1 and uid = %d limit 1", intval($u[0]['uid']) ); - if (! count($c)) { + if (! dbm::is_result($c)) { return; } @@ -1293,8 +1293,6 @@ function tag_deliver($uid,$item_id) { function tgroup_check($uid,$item) { - $a = get_app(); - $mention = false; // check that the message originated elsewhere and is a top-level post diff --git a/mod/allfriends.php b/mod/allfriends.php index 9e14a67d2e..7a134a7be1 100644 --- a/mod/allfriends.php +++ b/mod/allfriends.php @@ -28,7 +28,7 @@ function allfriends_content(App &$a) { intval(local_user()) ); - if (! count($c)) { + if (! dbm::is_result($c)) { return; } @@ -71,20 +71,20 @@ function allfriends_content(App &$a) { } $entry = array( - 'url' => $rr['url'], - 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), - 'name' => htmlentities($contact_details['name']), - 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB), - 'img_hover' => htmlentities($contact_details['name']), - 'details' => $contact_details['location'], - 'tags' => $contact_details['keywords'], - 'about' => $contact_details['about'], - 'account_type' => account_type($contact_details), - 'network' => network_to_name($contact_details['network'], $contact_details['url']), - 'photo_menu' => $photo_menu, - 'conntxt' => t('Connect'), - 'connlnk' => $connlnk, - 'id' => ++$id, + 'url' => $rr['url'], + 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), + 'name' => htmlentities($contact_details['name']), + 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB), + 'img_hover' => htmlentities($contact_details['name']), + 'details' => $contact_details['location'], + 'tags' => $contact_details['keywords'], + 'about' => $contact_details['about'], + 'account_type' => account_type($contact_details), + 'network' => network_to_name($contact_details['network'], $contact_details['url']), + 'photo_menu' => $photo_menu, + 'conntxt' => t('Connect'), + 'connlnk' => $connlnk, + 'id' => ++$id, ); $entries[] = $entry; } From 13b57d4d5091531284ece6a39fc74a0a2642efb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 17:12:34 +0100 Subject: [PATCH 74/96] Coding convention continued: - added curly braces - added spaces between if/foreach and brace - made code block look nicer (spaces added, tabs replaced by space) - added TODO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/common.php | 71 +++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/mod/common.php b/mod/common.php index ab27dc667a..26ef7e48b7 100644 --- a/mod/common.php +++ b/mod/common.php @@ -19,23 +19,27 @@ function common_content(App &$a) { return; } - if($cmd !== 'loc' && $cmd != 'rem') + if ($cmd !== 'loc' && $cmd != 'rem') { return; + } - if(! $uid) + if (! $uid) { return; + } - if($cmd === 'loc' && $cid) { + if ($cmd === 'loc' && $cid) { $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval($uid) ); + /// @TODO Handle $c with dbm::is_result() $a->page['aside'] = ""; profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"])); } else { $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($uid) ); + /// @TODO Handle $c with dbm::is_result() $vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"),array( '$name' => htmlentities($c[0]['name']), @@ -43,8 +47,9 @@ function common_content(App &$a) { 'url' => 'contacts/' . $cid )); - if(! x($a->page,'aside')) + if (! x($a->page,'aside')) { $a->page['aside'] = ''; + } $a->page['aside'] .= $vcard_widget; } @@ -70,29 +75,29 @@ function common_content(App &$a) { } } - - - if($cid == 0 && $zcid == 0) + if ($cid == 0 && $zcid == 0) { return; + } - - if($cid) + if ($cid) { $t = count_common_friends($uid, $cid); - else + } else { $t = count_common_friends_zcid($uid, $zcid); + } - if(count($t)) + if (count($t)) { $a->set_pager_total($t); - else { + } else { notice( t('No contacts in common.') . EOL); return $o; } - if($cid) + if ($cid) { $r = common_friends($uid, $cid, $a->pager['start'], $a->pager['itemspage']); - else + } else { $r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']); + } if (! dbm::is_result($r)) { @@ -106,39 +111,41 @@ function common_content(App &$a) { //get further details of the contact $contact_details = get_contact_details_by_url($rr['url'], $uid); - // $rr[id] is needed to use contact_photo_menu() - $rr[id] = $rr[cid]; + // $rr['id'] is needed to use contact_photo_menu() + /// @TODO Adding '/" here avoids E_NOTICE on missing constants + $rr['id'] = $rr['cid']; $photo_menu = ''; $photo_menu = contact_photo_menu($rr); $entry = array( - 'url' => $rr['url'], - 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), - 'name' => $contact_details['name'], - 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB), - 'img_hover' => htmlentities($contact_details['name']), - 'details' => $contact_details['location'], - 'tags' => $contact_details['keywords'], - 'about' => $contact_details['about'], - 'account_type' => account_type($contact_details), - 'network' => network_to_name($contact_details['network'], $contact_details['url']), - 'photo_menu' => $photo_menu, - 'id' => ++$id, + 'url' => $rr['url'], + 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), + 'name' => $contact_details['name'], + 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB), + 'img_hover' => htmlentities($contact_details['name']), + 'details' => $contact_details['location'], + 'tags' => $contact_details['keywords'], + 'about' => $contact_details['about'], + 'account_type' => account_type($contact_details), + 'network' => network_to_name($contact_details['network'], $contact_details['url']), + 'photo_menu' => $photo_menu, + 'id' => ++$id, ); $entries[] = $entry; } - if($cmd === 'loc' && $cid && $uid == local_user()) { + if ($cmd === 'loc' && $cid && $uid == local_user()) { $tab_str = contacts_tab($a, $cid, 4); - } else + } else { $title = t('Common Friends'); + } $tpl = get_markup_template('viewcontact_template.tpl'); $o .= replace_macros($tpl,array( - '$title' => $title, - '$tab_str' => $tab_str, + '$title' => $title, + '$tab_str' => $tab_str, '$contacts' => $entries, '$paginate' => paginate($a), )); From 7c8e834546823eeadc68a2451b871addda38af57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 17:12:34 +0100 Subject: [PATCH 75/96] Coding convention continued: - added curly braces - added spaces between if/foreach and brace - made code block look nicer (spaces added, tabs replaced by space) - added TODO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/common.php | 71 +++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/mod/common.php b/mod/common.php index ab27dc667a..26ef7e48b7 100644 --- a/mod/common.php +++ b/mod/common.php @@ -19,23 +19,27 @@ function common_content(App &$a) { return; } - if($cmd !== 'loc' && $cmd != 'rem') + if ($cmd !== 'loc' && $cmd != 'rem') { return; + } - if(! $uid) + if (! $uid) { return; + } - if($cmd === 'loc' && $cid) { + if ($cmd === 'loc' && $cid) { $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval($uid) ); + /// @TODO Handle $c with dbm::is_result() $a->page['aside'] = ""; profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"])); } else { $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($uid) ); + /// @TODO Handle $c with dbm::is_result() $vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"),array( '$name' => htmlentities($c[0]['name']), @@ -43,8 +47,9 @@ function common_content(App &$a) { 'url' => 'contacts/' . $cid )); - if(! x($a->page,'aside')) + if (! x($a->page,'aside')) { $a->page['aside'] = ''; + } $a->page['aside'] .= $vcard_widget; } @@ -70,29 +75,29 @@ function common_content(App &$a) { } } - - - if($cid == 0 && $zcid == 0) + if ($cid == 0 && $zcid == 0) { return; + } - - if($cid) + if ($cid) { $t = count_common_friends($uid, $cid); - else + } else { $t = count_common_friends_zcid($uid, $zcid); + } - if(count($t)) + if (count($t)) { $a->set_pager_total($t); - else { + } else { notice( t('No contacts in common.') . EOL); return $o; } - if($cid) + if ($cid) { $r = common_friends($uid, $cid, $a->pager['start'], $a->pager['itemspage']); - else + } else { $r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']); + } if (! dbm::is_result($r)) { @@ -106,39 +111,41 @@ function common_content(App &$a) { //get further details of the contact $contact_details = get_contact_details_by_url($rr['url'], $uid); - // $rr[id] is needed to use contact_photo_menu() - $rr[id] = $rr[cid]; + // $rr['id'] is needed to use contact_photo_menu() + /// @TODO Adding '/" here avoids E_NOTICE on missing constants + $rr['id'] = $rr['cid']; $photo_menu = ''; $photo_menu = contact_photo_menu($rr); $entry = array( - 'url' => $rr['url'], - 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), - 'name' => $contact_details['name'], - 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB), - 'img_hover' => htmlentities($contact_details['name']), - 'details' => $contact_details['location'], - 'tags' => $contact_details['keywords'], - 'about' => $contact_details['about'], - 'account_type' => account_type($contact_details), - 'network' => network_to_name($contact_details['network'], $contact_details['url']), - 'photo_menu' => $photo_menu, - 'id' => ++$id, + 'url' => $rr['url'], + 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), + 'name' => $contact_details['name'], + 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB), + 'img_hover' => htmlentities($contact_details['name']), + 'details' => $contact_details['location'], + 'tags' => $contact_details['keywords'], + 'about' => $contact_details['about'], + 'account_type' => account_type($contact_details), + 'network' => network_to_name($contact_details['network'], $contact_details['url']), + 'photo_menu' => $photo_menu, + 'id' => ++$id, ); $entries[] = $entry; } - if($cmd === 'loc' && $cid && $uid == local_user()) { + if ($cmd === 'loc' && $cid && $uid == local_user()) { $tab_str = contacts_tab($a, $cid, 4); - } else + } else { $title = t('Common Friends'); + } $tpl = get_markup_template('viewcontact_template.tpl'); $o .= replace_macros($tpl,array( - '$title' => $title, - '$tab_str' => $tab_str, + '$title' => $title, + '$tab_str' => $tab_str, '$contacts' => $entries, '$paginate' => paginate($a), )); From 97c507e76392cb9aac982ddd494961bab62d81cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Dec 2016 10:10:33 +0100 Subject: [PATCH 76/96] Coding convention applied: - space between "if" and brace - curly braces on conditional blocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/like.php | 3 ++- mod/subthread.php | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/like.php b/include/like.php index 893047da3c..210bde6906 100644 --- a/include/like.php +++ b/include/like.php @@ -112,8 +112,9 @@ function do_like($item_id, $verb) { intval($_SESSION['visitor_id']), intval($owner_uid) ); - if (dbm::is_result($r)) + if (dbm::is_result($r)) { $contact = $r[0]; + } } if (! $contact) { return false; diff --git a/mod/subthread.php b/mod/subthread.php index a00196825b..c689f7f6cb 100644 --- a/mod/subthread.php +++ b/mod/subthread.php @@ -71,8 +71,7 @@ function subthread_content(App &$a) { if ((local_user()) && (local_user() == $owner_uid)) { $contact = $owner; - } - else { + } else { $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($_SESSION['visitor_id']), intval($owner_uid) From f8a213e23be1c43a00dea6079f78100f6df99d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Mon, 19 Dec 2016 14:26:13 +0100 Subject: [PATCH 77/96] *much* more usage of App::get_baseurl() instead of $a->get_baseurl() (coding convention applied) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/Contact.php | 2 +- include/contact_widgets.php | 10 ++-- include/follow.php | 61 +++++++++---------- include/identity.php | 94 +++++++++++++++++++++--------- include/network.php | 53 +++++++++-------- include/plugin.php | 43 +++++++------- include/socgraph.php | 3 +- mod/admin.php | 8 +-- mod/delegate.php | 4 +- mod/dfrn_request.php | 23 ++++---- mod/events.php | 2 +- mod/group.php | 5 +- mod/hcard.php | 1 - mod/invite.php | 2 +- mod/item.php | 13 +++-- mod/profile.php | 63 +++++++++----------- mod/profile_photo.php | 15 ++--- mod/videos.php | 4 +- view/theme/duepuntozero/config.php | 16 ++--- 19 files changed, 226 insertions(+), 196 deletions(-) diff --git a/include/Contact.php b/include/Contact.php index c86d6e7f80..5d8ccc4529 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -85,7 +85,7 @@ function contact_remove($id) { function terminate_friendship($user,$self,$contact) { - /// @TODO Get rid of this, include/datetime.php should care about by itself + /// @TODO Get rid of this, include/datetime.php should care about it by itself $a = get_app(); require_once('include/datetime.php'); diff --git a/include/contact_widgets.php b/include/contact_widgets.php index 36675da873..fee569e94d 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -135,8 +135,8 @@ function fileas_widget($baseurl,$selected = '') { $matches = false; $terms = array(); - $cnt = preg_match_all('/\[(.*?)\]/',$saved,$matches,PREG_SET_ORDER); - if($cnt) { + $cnt = preg_match_all('/\[(.*?)\]/',$saved,$matches,PREG_SET_ORDER); + if ($cnt) { foreach($matches as $mtch) { $unescaped = xmlify(file_tag_decode($mtch[1])); $terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? 'selected' : '')); @@ -158,12 +158,14 @@ function categories_widget($baseurl,$selected = '') { $a = get_app(); - if(! feature_enabled($a->profile['profile_uid'],'categories')) + if (! feature_enabled($a->profile['profile_uid'],'categories')) { return ''; + } $saved = get_pconfig($a->profile['profile_uid'],'system','filetags'); - if(! strlen($saved)) + if (! strlen($saved)) { return; + } $matches = false; $terms = array(); diff --git a/include/follow.php b/include/follow.php index e7693822ab..8d80538e0c 100644 --- a/include/follow.php +++ b/include/follow.php @@ -102,8 +102,7 @@ function new_contact($uid,$url,$interactive = false) { if ($interactive) { if (strlen($a->path)) { $myaddr = bin2hex(App::get_baseurl() . '/profile/' . $a->user['nickname']); - } - else { + } else { $myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname()); } @@ -111,53 +110,45 @@ function new_contact($uid,$url,$interactive = false) { // NOTREACHED } - } - else { - if(get_config('system','dfrn_only')) { + } else { + if (get_config('system','dfrn_only')) { $result['message'] = t('This site is not configured to allow communications with other networks.') . EOL; $result['message'] != t('No compatible communication protocols or feeds were discovered.') . EOL; return $result; } } - - - - - // This extra param just confuses things, remove it - if($ret['network'] === NETWORK_DIASPORA) + if ($ret['network'] === NETWORK_DIASPORA) { $ret['url'] = str_replace('?absolute=true','',$ret['url']); - + } // do we have enough information? - if(! ((x($ret,'name')) && (x($ret,'poll')) && ((x($ret,'url')) || (x($ret,'addr'))))) { + if (! ((x($ret,'name')) && (x($ret,'poll')) && ((x($ret,'url')) || (x($ret,'addr'))))) { $result['message'] .= t('The profile address specified does not provide adequate information.') . EOL; - if(! x($ret,'poll')) + if (! x($ret,'poll')) { $result['message'] .= t('No compatible communication protocols or feeds were discovered.') . EOL; - if(! x($ret,'name')) + } + if (! x($ret,'name')) { $result['message'] .= t('An author or name was not found.') . EOL; - if(! x($ret,'url')) + } + if (! x($ret,'url')) { $result['message'] .= t('No browser URL could be matched to this address.') . EOL; - if(strpos($url,'@') !== false) { + } + if (strpos($url,'@') !== false) { $result['message'] .= t('Unable to match @-style Identity Address with a known protocol or email contact.') . EOL; $result['message'] .= t('Use mailto: in front of address to force email check.') . EOL; } return $result; } - if($ret['network'] === NETWORK_OSTATUS && get_config('system','ostatus_disabled')) { + if ($ret['network'] === NETWORK_OSTATUS && get_config('system','ostatus_disabled')) { $result['message'] .= t('The profile address specified belongs to a network which has been disabled on this site.') . EOL; $ret['notify'] = ''; } - - - - - - if(! $ret['notify']) { + if (! $ret['notify']) { $result['message'] .= t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL; } @@ -167,8 +158,9 @@ function new_contact($uid,$url,$interactive = false) { $hidden = (($ret['network'] === NETWORK_MAIL) ? 1 : 0); - if(in_array($ret['network'], array(NETWORK_MAIL, NETWORK_DIASPORA))) + if (in_array($ret['network'], array(NETWORK_MAIL, NETWORK_DIASPORA))) { $writeable = 1; + } // check if we already have a contact // the poll url is more reliable than the profile url, as we may have @@ -188,7 +180,7 @@ function new_contact($uid,$url,$interactive = false) { if (dbm::is_result($r)) { // update contact - if($r[0]['rel'] == CONTACT_IS_FOLLOWER || ($network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING)) { + if ($r[0]['rel'] == CONTACT_IS_FOLLOWER || ($network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING)) { q("UPDATE `contact` SET `rel` = %d , `subhub` = %d, `readonly` = 0 WHERE `id` = %d AND `uid` = %d", intval(CONTACT_IS_FRIEND), intval($subhub), @@ -197,29 +189,28 @@ function new_contact($uid,$url,$interactive = false) { ); } } else { - - // check service class limits - $r = q("select count(*) as total from contact where uid = %d and pending = 0 and self = 0", + $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `pending` = 0 AND `self` = 0", intval($uid) ); if (dbm::is_result($r)) $total_contacts = $r[0]['total']; - if(! service_class_allows($uid,'total_contacts',$total_contacts)) { + if (! service_class_allows($uid,'total_contacts',$total_contacts)) { $result['message'] .= upgrade_message(); return $result; } - $r = q("select count(network) as total from contact where uid = %d and network = '%s' and pending = 0 and self = 0", + $r = q("SELECT COUNT(`network`) AS `total` FROM `contact` WHERE `uid` = %d AND `network` = '%s' AND `pending` = 0 AND `self` = 0", intval($uid), dbesc($network) ); - if (dbm::is_result($r)) + if (dbm::is_result($r)) { $total_network = $r[0]['total']; + } - if(! service_class_allows($uid,'total_contacts_' . $network,$total_network)) { + if (! service_class_allows($uid,'total_contacts_' . $network,$total_network)) { $result['message'] .= upgrade_message(); return $result; } @@ -268,8 +259,9 @@ function new_contact($uid,$url,$interactive = false) { $result['cid'] = $contact_id; $def_gid = get_default_group($uid, $contact["network"]); - if (intval($def_gid)) + if (intval($def_gid)) { group_add_member($uid, '', $contact_id, $def_gid); + } // Update the avatar update_contact_avatar($ret['photo'],$uid,$contact_id); @@ -285,7 +277,6 @@ function new_contact($uid,$url,$interactive = false) { if (dbm::is_result($r)) { if (($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) { - // create a follow slap $item = array(); $item['verb'] = ACTIVITY_FOLLOW; diff --git a/include/identity.php b/include/identity.php index 35516efbea..a302dc34cd 100644 --- a/include/identity.php +++ b/include/identity.php @@ -231,8 +231,7 @@ function profile_sidebar($profile, $block = 0) { if ($connect AND local_user()) { if (isset($profile["url"])) { $profile_url = normalise_link($profile["url"]); - } - else { + } else { $profile_url = normalise_link(App::get_baseurl()."/profile/".$profile["nickname"]); } @@ -638,50 +637,87 @@ function advanced_profile(App &$a) { if($a->profile['marital']) $profile['marital'] = array( t('Status:'), $a->profile['marital']); - - if($a->profile['with']) $profile['marital']['with'] = $a->profile['with']; - - if(strlen($a->profile['howlong']) && $a->profile['howlong'] !== '0000-00-00 00:00:00') { - $profile['howlong'] = relative_date($a->profile['howlong'], t('for %1$d %2$s')); + /// @TODO Maybe use x() here, plus below? + if ($a->profile['with']) { + $profile['marital']['with'] = $a->profile['with']; } - if($a->profile['sexual']) $profile['sexual'] = array( t('Sexual Preference:'), $a->profile['sexual'] ); + if (strlen($a->profile['howlong']) && $a->profile['howlong'] !== '0000-00-00 00:00:00') { + $profile['howlong'] = relative_date($a->profile['howlong'], t('for %1$d %2$s')); + } - if($a->profile['homepage']) $profile['homepage'] = array( t('Homepage:'), linkify($a->profile['homepage']) ); + if ($a->profile['sexual']) { + $profile['sexual'] = array( t('Sexual Preference:'), $a->profile['sexual'] ); + } - if($a->profile['hometown']) $profile['hometown'] = array( t('Hometown:'), linkify($a->profile['hometown']) ); + if ($a->profile['homepage']) { + $profile['homepage'] = array( t('Homepage:'), linkify($a->profile['homepage']) ); + } - if($a->profile['pub_keywords']) $profile['pub_keywords'] = array( t('Tags:'), $a->profile['pub_keywords']); + if ($a->profile['hometown']) { + $profile['hometown'] = array( t('Hometown:'), linkify($a->profile['hometown']) ); + } - if($a->profile['politic']) $profile['politic'] = array( t('Political Views:'), $a->profile['politic']); + if ($a->profile['pub_keywords']) { + $profile['pub_keywords'] = array( t('Tags:'), $a->profile['pub_keywords']); + } - if($a->profile['religion']) $profile['religion'] = array( t('Religion:'), $a->profile['religion']); + if ($a->profile['politic']) { + $profile['politic'] = array( t('Political Views:'), $a->profile['politic']); + } - if($txt = prepare_text($a->profile['about'])) $profile['about'] = array( t('About:'), $txt ); + if ($a->profile['religion']) { + $profile['religion'] = array( t('Religion:'), $a->profile['religion']); + } - if($txt = prepare_text($a->profile['interest'])) $profile['interest'] = array( t('Hobbies/Interests:'), $txt); + if ($txt = prepare_text($a->profile['about'])) { + $profile['about'] = array( t('About:'), $txt ); + } - if($txt = prepare_text($a->profile['likes'])) $profile['likes'] = array( t('Likes:'), $txt); + if ($txt = prepare_text($a->profile['interest'])) { + $profile['interest'] = array( t('Hobbies/Interests:'), $txt); + } - if($txt = prepare_text($a->profile['dislikes'])) $profile['dislikes'] = array( t('Dislikes:'), $txt); + if ($txt = prepare_text($a->profile['likes'])) { + $profile['likes'] = array( t('Likes:'), $txt); + } + if ($txt = prepare_text($a->profile['dislikes'])) { + $profile['dislikes'] = array( t('Dislikes:'), $txt); + } - if($txt = prepare_text($a->profile['contact'])) $profile['contact'] = array( t('Contact information and Social Networks:'), $txt); + if ($txt = prepare_text($a->profile['contact'])) { + $profile['contact'] = array( t('Contact information and Social Networks:'), $txt); + } - if($txt = prepare_text($a->profile['music'])) $profile['music'] = array( t('Musical interests:'), $txt); + if ($txt = prepare_text($a->profile['music'])) { + $profile['music'] = array( t('Musical interests:'), $txt); + } - if($txt = prepare_text($a->profile['book'])) $profile['book'] = array( t('Books, literature:'), $txt); + if ($txt = prepare_text($a->profile['book'])) { + $profile['book'] = array( t('Books, literature:'), $txt); + } - if($txt = prepare_text($a->profile['tv'])) $profile['tv'] = array( t('Television:'), $txt); + if ($txt = prepare_text($a->profile['tv'])) { + $profile['tv'] = array( t('Television:'), $txt); + } - if($txt = prepare_text($a->profile['film'])) $profile['film'] = array( t('Film/dance/culture/entertainment:'), $txt); + if ($txt = prepare_text($a->profile['film'])) { + $profile['film'] = array( t('Film/dance/culture/entertainment:'), $txt); + } - if($txt = prepare_text($a->profile['romance'])) $profile['romance'] = array( t('Love/Romance:'), $txt); + if ($txt = prepare_text($a->profile['romance'])) { + $profile['romance'] = array( t('Love/Romance:'), $txt); + } - if($txt = prepare_text($a->profile['work'])) $profile['work'] = array( t('Work/employment:'), $txt); + if ($txt = prepare_text($a->profile['work'])) { + $profile['work'] = array( t('Work/employment:'), $txt); + } + + if ($txt = prepare_text($a->profile['education'])) { + $profile['education'] = array( t('School/education:'), $txt ); + } - if($txt = prepare_text($a->profile['education'])) $profile['education'] = array( t('School/education:'), $txt ); - //show subcribed forum if it is enabled in the usersettings if (feature_enabled($uid,'forumlist_profile')) { $profile['forumlist'] = array( t('Forums:'), ForumManager::profile_advanced($uid)); @@ -705,11 +741,13 @@ function advanced_profile(App &$a) { function profile_tabs($a, $is_owner=False, $nickname=Null){ //echo "
    "; var_dump($a->user); killme();
     
    -	if (is_null($nickname))
    +	if (is_null($nickname)) {
     		$nickname  = $a->user['nickname'];
    +	}
     
    -	if(x($_GET,'tab'))
    +	if (x($_GET,'tab')) {
     		$tab = notags(trim($_GET['tab']));
    +	}
     
     	$url = App::get_baseurl() . '/profile/' . $nickname;
     
    diff --git a/include/network.php b/include/network.php
    index 7a662e4cbf..969f583828 100644
    --- a/include/network.php
    +++ b/include/network.php
    @@ -541,10 +541,11 @@ function parse_xml_string($s,$strict = true) {
     	libxml_use_internal_errors(true);
     
     	$x = @simplexml_load_string($s2);
    -	if(! $x) {
    +	if (! $x) {
     		logger('libxml: parse: error: ' . $s2, LOGGER_DATA);
    -		foreach(libxml_get_errors() as $err)
    +		foreach (libxml_get_errors() as $err) {
     			logger('libxml: parse: ' . $err->code." at ".$err->line.":".$err->column." : ".$err->message, LOGGER_DATA);
    +		}
     		libxml_clear_errors();
     	}
     	return $x;
    @@ -553,8 +554,9 @@ function parse_xml_string($s,$strict = true) {
     function scale_external_images($srctext, $include_link = true, $scale_replace = false) {
     
     	// Suppress "view full size"
    -	if (intval(get_config('system','no_view_full_size')))
    +	if (intval(get_config('system','no_view_full_size'))) {
     		$include_link = false;
    +	}
     
     	$a = get_app();
     
    @@ -563,38 +565,41 @@ function scale_external_images($srctext, $include_link = true, $scale_replace =
     
     	$matches = null;
     	$c = preg_match_all('/\[img.*?\](.*?)\[\/img\]/ism',$s,$matches,PREG_SET_ORDER);
    -	if($c) {
    +	if ($c) {
     		require_once('include/Photo.php');
    -		foreach($matches as $mtch) {
    +		foreach ($matches as $mtch) {
     			logger('scale_external_image: ' . $mtch[1]);
     
     			$hostname = str_replace('www.','',substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3));
    -			if(stristr($mtch[1],$hostname))
    +			if (stristr($mtch[1],$hostname)) {
     				continue;
    +			}
     
     			// $scale_replace, if passed, is an array of two elements. The
     			// first is the name of the full-size image. The second is the
     			// name of a remote, scaled-down version of the full size image.
     			// This allows Friendica to display the smaller remote image if
     			// one exists, while still linking to the full-size image
    -			if($scale_replace)
    +			if ($scale_replace) {
     				$scaled = str_replace($scale_replace[0], $scale_replace[1], $mtch[1]);
    -			else
    +			} else {
     				$scaled = $mtch[1];
    -			$i = @fetch_url($scaled);
    -			if(! $i)
    +			}
    +			$i = fetch_url($scaled);
    +			if (! $i) {
     				return $srctext;
    +			}
     
     			// guess mimetype from headers or filename
     			$type = guess_image_type($mtch[1],true);
     
    -			if($i) {
    +			if ($i) {
     				$ph = new Photo($i, $type);
    -				if($ph->is_valid()) {
    +				if ($ph->is_valid()) {
     					$orig_width = $ph->getWidth();
     					$orig_height = $ph->getHeight();
     
    -					if($orig_width > 640 || $orig_height > 640) {
    +					if ($orig_width > 640 || $orig_height > 640) {
     
     						$ph->scaleImage(640);
     						$new_width = $ph->getWidth();
    @@ -620,7 +625,7 @@ function scale_external_images($srctext, $include_link = true, $scale_replace =
     function fix_contact_ssl_policy(&$contact,$new_policy) {
     
     	$ssl_changed = false;
    -	if((intval($new_policy) == SSL_POLICY_SELFSIGN || $new_policy === 'self') && strstr($contact['url'],'https:')) {
    +	if ((intval($new_policy) == SSL_POLICY_SELFSIGN || $new_policy === 'self') && strstr($contact['url'],'https:')) {
     		$ssl_changed = true;
     		$contact['url']     = 	str_replace('https:','http:',$contact['url']);
     		$contact['request'] = 	str_replace('https:','http:',$contact['request']);
    @@ -630,7 +635,7 @@ function fix_contact_ssl_policy(&$contact,$new_policy) {
     		$contact['poco']    = 	str_replace('https:','http:',$contact['poco']);
     	}
     
    -	if((intval($new_policy) == SSL_POLICY_FULL || $new_policy === 'full') && strstr($contact['url'],'http:')) {
    +	if ((intval($new_policy) == SSL_POLICY_FULL || $new_policy === 'full') && strstr($contact['url'],'http:')) {
     		$ssl_changed = true;
     		$contact['url']     = 	str_replace('http:','https:',$contact['url']);
     		$contact['request'] = 	str_replace('http:','https:',$contact['request']);
    @@ -640,15 +645,15 @@ function fix_contact_ssl_policy(&$contact,$new_policy) {
     		$contact['poco']    = 	str_replace('http:','https:',$contact['poco']);
     	}
     
    -	if($ssl_changed) {
    -		q("update contact set
    -			url = '%s',
    -			request = '%s',
    -			notify = '%s',
    -			poll = '%s',
    -			confirm = '%s',
    -			poco = '%s'
    -			where id = %d limit 1",
    +	if ($ssl_changed) {
    +		q("UPDATE `contact` SET
    +			`url` = '%s',
    +			`request` = '%s',
    +			`notify` = '%s',
    +			`poll` = '%s',
    +			`confirm` = '%s',
    +			`poco` = '%s'
    +			WHERE `id` = %d LIMIT 1",
     			dbesc($contact['url']),
     			dbesc($contact['request']),
     			dbesc($contact['notify']),
    diff --git a/include/plugin.php b/include/plugin.php
    index 0b9c0166aa..8cb2783eef 100644
    --- a/include/plugin.php
    +++ b/include/plugin.php
    @@ -413,7 +413,7 @@ function get_theme_info($theme){
     function get_theme_screenshot($theme) {
     	$exts = array('.png','.jpg');
     	foreach($exts as $ext) {
    -		if(file_exists('view/theme/' . $theme . '/screenshot' . $ext)) {
    +		if (file_exists('view/theme/' . $theme . '/screenshot' . $ext)) {
     			return(App::get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext);
     		}
     	}
    @@ -425,8 +425,8 @@ if (! function_exists('uninstall_theme')){
     function uninstall_theme($theme){
     	logger("Addons: uninstalling theme " . $theme);
     
    -	@include_once("view/theme/$theme/theme.php");
    -	if(function_exists("{$theme}_uninstall")) {
    +	include_once("view/theme/$theme/theme.php");
    +	if (function_exists("{$theme}_uninstall")) {
     		$func = "{$theme}_uninstall";
     		$func();
     	}
    @@ -436,19 +436,19 @@ if (! function_exists('install_theme')){
     function install_theme($theme) {
     	// silently fail if theme was removed
     
    -	if(! file_exists("view/theme/$theme/theme.php"))
    +	if (! file_exists("view/theme/$theme/theme.php")) {
     		return false;
    +	}
     
     	logger("Addons: installing theme $theme");
     
    -	@include_once("view/theme/$theme/theme.php");
    +	include_once("view/theme/$theme/theme.php");
     
    -	if(function_exists("{$theme}_install")) {
    +	if (function_exists("{$theme}_install")) {
     		$func = "{$theme}_install";
     		$func();
     		return true;
    -	}
    -	else {
    +	} else {
     		logger("Addons: FAILED installing theme $theme");
     		return false;
     	}
    @@ -467,10 +467,9 @@ function install_theme($theme) {
     
     function service_class_allows($uid,$property,$usage = false) {
     
    -	if($uid == local_user()) {
    +	if ($uid == local_user()) {
     		$service_class = $a->user['service_class'];
    -	}
    -	else {
    +	} else {
     		$r = q("SELECT `service_class` FROM `user` WHERE `uid` = %d LIMIT 1",
     			intval($uid)
     		);
    @@ -478,18 +477,23 @@ function service_class_allows($uid,$property,$usage = false) {
     			$service_class = $r[0]['service_class'];
     		}
     	}
    -	if(! x($service_class))
    -		return true; // everything is allowed
    +
    +	if (! x($service_class)) [
    +		// everything is allowed
    +		return true;
    +	}
     
     	$arr = get_config('service_class',$service_class);
    -	if(! is_array($arr) || (! count($arr)))
    +	if (! is_array($arr) || (! count($arr))) {
     		return true;
    +	}
     
    -	if($usage === false)
    +	if ($usage === false) {
     		return ((x($arr[$property])) ? (bool) $arr['property'] : true);
    -	else {
    -		if(! array_key_exists($property,$arr))
    +	} else {
    +		if (! array_key_exists($property,$arr)) {
     			return true;
    +		}
     		return (((intval($usage)) < intval($arr[$property])) ? true : false);
     	}
     }
    @@ -497,10 +501,9 @@ function service_class_allows($uid,$property,$usage = false) {
     
     function service_class_fetch($uid,$property) {
     
    -	if($uid == local_user()) {
    +	if ($uid == local_user()) {
     		$service_class = $a->user['service_class'];
    -	}
    -	else {
    +	} else {
     		$r = q("SELECT `service_class` FROM `user` WHERE `uid` = %d LIMIT 1",
     			intval($uid)
     		);
    diff --git a/include/socgraph.php b/include/socgraph.php
    index 7c70a22a54..e55643e6d3 100644
    --- a/include/socgraph.php
    +++ b/include/socgraph.php
    @@ -220,8 +220,9 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
     	$r = q("SELECT `network` FROM `contact` WHERE `nurl` = '%s' AND `network` != '' AND `network` != '%s' LIMIT 1",
     		dbesc(normalise_link($profile_url)), dbesc(NETWORK_STATUSNET)
     	);
    -	if (dbm::is_result($r))
    +	if (dbm::is_result($r)) {
     		$network = $r[0]["network"];
    +	}
     
     	if (($network == "") OR ($network == NETWORK_OSTATUS)) {
     		$r = q("SELECT `network`, `url` FROM `contact` WHERE `alias` IN ('%s', '%s') AND `network` != '' AND `network` != '%s' LIMIT 1",
    diff --git a/mod/admin.php b/mod/admin.php
    index c502e36fc5..48320fb36c 100644
    --- a/mod/admin.php
    +++ b/mod/admin.php
    @@ -1851,12 +1851,12 @@ function admin_page_themes(App &$a){
      * @param App $a
      */
     function admin_page_logs_post(App &$a) {
    -	if(x($_POST,"page_logs")) {
    +	if (x($_POST,"page_logs")) {
     		check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs');
     
    -		$logfile 	=	((x($_POST,'logfile'))		? notags(trim($_POST['logfile']))	: '');
    -		$debugging	=	((x($_POST,'debugging'))	? true					: false);
    -		$loglevel 	=	((x($_POST,'loglevel'))		? intval(trim($_POST['loglevel']))	: 0);
    +		$logfile   = (x($_POST,'logfile'))    ? notags(trim($_POST['logfile']))	: '');
    +		$debugging = ((x($_POST,'debugging')) ? true					: false);
    +		$loglevel  = ((x($_POST,'loglevel'))  ? intval(trim($_POST['loglevel']))	: 0);
     
     		set_config('system','logfile', $logfile);
     		set_config('system','debugging',  $debugging);
    diff --git a/mod/delegate.php b/mod/delegate.php
    index 40618eb324..6930a5943a 100644
    --- a/mod/delegate.php
    +++ b/mod/delegate.php
    @@ -21,7 +21,6 @@ function delegate_content(App &$a) {
     			goaway(App::get_baseurl() . '/delegate');
     		}
     
    -
     		$id = $a->argv[2];
     
     		$r = q("select `nickname` from user where uid = %d limit 1",
    @@ -45,12 +44,11 @@ function delegate_content(App &$a) {
     	if ($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) {
     
     		// delegated admins can view but not change delegation permissions
    -
     		if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
     			goaway(App::get_baseurl() . '/delegate');
     		}
     
    -		q("delete from manage where uid = %d and mid = %d limit 1",
    +		q("DELETE FROM `manage` WHERE `uid` = %d AND `mid` = %d LIMIT 1",
     			intval($a->argv[2]),
     			intval(local_user())
     		);
    diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php
    index b9c1b67446..353f8fdc96 100644
    --- a/mod/dfrn_request.php
    +++ b/mod/dfrn_request.php
    @@ -810,19 +810,17 @@ function dfrn_request_content(App &$a) {
     
     		// At first look if an address was provided
     		// Otherwise take the local address
    -		if (x($_GET,'addr') AND ($_GET['addr'] != ""))
    +		if (x($_GET,'addr') AND ($_GET['addr'] != "")) {
     			$myaddr = hex2bin($_GET['addr']);
    -		elseif (x($_GET,'address') AND ($_GET['address'] != ""))
    +		} elseif (x($_GET,'address') AND ($_GET['address'] != "")) {
     			$myaddr = $_GET['address'];
    -		elseif (local_user()) {
    +		} elseif (local_user()) {
     			if (strlen($a->path)) {
     				$myaddr = App::get_baseurl() . '/profile/' . $a->user['nickname'];
    -			}
    -			else {
    +			} else {
     				$myaddr = $a->user['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 );
     			}
    -		}
    -		else {
    +		} else {
     			// last, try a zrl
     			$myaddr = get_my_url();
     		}
    @@ -840,8 +838,7 @@ function dfrn_request_content(App &$a) {
     
     		if ($a->profile['page-flags'] == PAGE_NORMAL) {
     			$tpl = get_markup_template('dfrn_request.tpl');
    -		}
    -		else {
    +		} else {
     			$tpl = get_markup_template('auto_request.tpl');
     		}
     
    @@ -850,10 +847,12 @@ function dfrn_request_content(App &$a) {
     		// see if we are allowed to have NETWORK_MAIL2 contacts
     
     		$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
    -		if(get_config('system','dfrn_only'))
    -			$mail_disabled = 1;
     
    -		if(! $mail_disabled) {
    +		if (get_config('system','dfrn_only')) {
    +			$mail_disabled = 1;
    +		}
    +
    +		if (! $mail_disabled) {
     			$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
     				intval($a->profile['uid'])
     			);
    diff --git a/mod/events.php b/mod/events.php
    index 1ed04deb08..8281a97661 100644
    --- a/mod/events.php
    +++ b/mod/events.php
    @@ -354,7 +354,7 @@ function events_content(App &$a) {
     			}
     		}
     
    -		$events=array();
    +		$events = array();
     
     		// transform the event in a usable array
     		if (dbm::is_result($r)) {
    diff --git a/mod/group.php b/mod/group.php
    index bf9009ae0c..681bc88cc3 100644
    --- a/mod/group.php
    +++ b/mod/group.php
    @@ -31,8 +31,7 @@ function group_post(App &$a) {
     			if ($r) {
     				goaway(App::get_baseurl() . '/group/' . $r);
     			}
    -		}
    -		else {
    +		} else {
     			notice( t('Could not create group.') . EOL );
     		}
     		goaway(App::get_baseurl() . '/group');
    @@ -92,7 +91,7 @@ function group_content(App &$a) {
     			'$submit' => t('Save Group'),
     	);
     
    -	if(($a->argc == 2) && ($a->argv[1] === 'new')) {
    +	if (($a->argc == 2) && ($a->argv[1] === 'new')) {
     
     		return replace_macros($tpl, $context + array(
     			'$title' => t('Create a group of contacts/friends.'),
    diff --git a/mod/hcard.php b/mod/hcard.php
    index 50721720d0..d53405009a 100644
    --- a/mod/hcard.php
    +++ b/mod/hcard.php
    @@ -52,4 +52,3 @@ function hcard_init(App &$a) {
     	}
     
     }
    -
    diff --git a/mod/invite.php b/mod/invite.php
    index f7f48290c5..a7739fc774 100644
    --- a/mod/invite.php
    +++ b/mod/invite.php
    @@ -120,7 +120,7 @@ function invite_content(App &$a) {
     	if (strlen($dirloc)) {
     		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');
    -		} 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())
     			. "\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');
     		}
    diff --git a/mod/item.php b/mod/item.php
    index bf3aa4c980..0746f0ada8 100644
    --- a/mod/item.php
    +++ b/mod/item.php
    @@ -454,7 +454,7 @@ function item_post(App &$a) {
     			$objecttype = ACTIVITY_OBJ_IMAGE;
     
     			foreach ($images as $image) {
    -				if (! stristr($image,App::get_baseurl() . '/photo/')) {
    +				if (! stristr($image,App::get_baseurl() . '/photo/'))
     					continue;
     				}
     				$image_uri = substr($image,strrpos($image,'/') + 1);
    @@ -620,16 +620,17 @@ function item_post(App &$a) {
     				continue;
     
     			$success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag, $network);
    -			if($success['replaced'])
    +			if ($success['replaced']) {
     				$tagged[] = $tag;
    -			if(is_array($success['contact']) && intval($success['contact']['prv'])) {
    +			}
    +			if (is_array($success['contact']) && intval($success['contact']['prv'])) {
     				$private_forum = true;
     				$private_id = $success['contact']['id'];
     			}
     		}
     	}
     
    -	if(($private_forum) && (! $parent) && (! $private)) {
    +	if (($private_forum) && (! $parent) && (! $private)) {
     		// we tagged a private forum in a top level post and the message was public.
     		// Restrict it.
     		$private = 1;
    @@ -639,8 +640,8 @@ function item_post(App &$a) {
     	$attachments = '';
     	$match = false;
     
    -	if(preg_match_all('/(\[attachment\]([0-9]+)\[\/attachment\])/',$body,$match)) {
    -		foreach($match[2] as $mtch) {
    +	if (preg_match_all('/(\[attachment\]([0-9]+)\[\/attachment\])/',$body,$match)) {
    +		foreach ($match[2] as $mtch) {
     			$r = q("SELECT `id`,`filename`,`filesize`,`filetype` FROM `attach` WHERE `uid` = %d AND `id` = %d LIMIT 1",
     				intval($profile_uid),
     				intval($mtch)
    diff --git a/mod/profile.php b/mod/profile.php
    index 52ffe8c47d..8519f7e82e 100644
    --- a/mod/profile.php
    +++ b/mod/profile.php
    @@ -74,24 +74,24 @@ function profile_content(&$a, $update = 0) {
     
     	$category = $datequery = $datequery2 = '';
     
    -	if($a->argc > 2) {
    -		for($x = 2; $x < $a->argc; $x ++) {
    -			if(is_a_date_arg($a->argv[$x])) {
    -				if($datequery)
    +	if ($a->argc > 2) {
    +		for ($x = 2; $x < $a->argc; $x ++) {
    +			if (is_a_date_arg($a->argv[$x])) {
    +				if ($datequery) {
     					$datequery2 = escape_tags($a->argv[$x]);
    -				else
    +				} else {
     					$datequery = escape_tags($a->argv[$x]);
    -			}
    -			else
    +			} else {
     				$category = $a->argv[$x];
    +			}
     		}
     	}
     
    -	if(! x($category)) {
    +	if (! x($category)) {
     		$category = ((x($_GET,'category')) ? $_GET['category'] : '');
     	}
     
    -	if(get_config('system','block_public') && (! local_user()) && (! remote_user())) {
    +	if (get_config('system','block_public') && (! local_user()) && (! remote_user())) {
     		return login();
     	}
     
    @@ -106,32 +106,30 @@ function profile_content(&$a, $update = 0) {
     	$tab = 'posts';
     	$o = '';
     
    -	if($update) {
    +	if ($update) {
     		// Ensure we've got a profile owner if updating.
     		$a->profile['profile_uid'] = $update;
    -	}
    -	else {
    -		if($a->profile['profile_uid'] == local_user()) {
    +	} else {
    +		if ($a->profile['profile_uid'] == local_user()) {
     			nav_set_selected('home');
     		}
     	}
     
    -
     	$contact = null;
     	$remote_contact = false;
     
     	$contact_id = 0;
     
    -	if(is_array($_SESSION['remote'])) {
    -		foreach($_SESSION['remote'] as $v) {
    -			if($v['uid'] == $a->profile['profile_uid']) {
    +	if (is_array($_SESSION['remote'])) {
    +		foreach ($_SESSION['remote'] as $v) {
    +			if ($v['uid'] == $a->profile['profile_uid']) {
     				$contact_id = $v['cid'];
     				break;
     			}
     		}
     	}
     
    -	if($contact_id) {
    +	if ($contact_id) {
     		$groups = init_groups_visitor($contact_id);
     		$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
     			intval($contact_id),
    @@ -143,8 +141,8 @@ function profile_content(&$a, $update = 0) {
     		}
     	}
     
    -	if(! $remote_contact) {
    -		if(local_user()) {
    +	if (! $remote_contact) {
    +		if (local_user()) {
     			$contact_id = $_SESSION['cid'];
     			$contact = $a->contact;
     		}
    @@ -152,32 +150,29 @@ function profile_content(&$a, $update = 0) {
     
     	$is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
     
    -	if($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
    +	if ($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
     		notice( t('Access to this profile has been restricted.') . EOL);
     		return;
     	}
     
    -	if(! $update) {
    -
    -
    -		if(x($_GET,'tab'))
    +	if (! $update) {
    +		if (x($_GET,'tab'))
     			$tab = notags(trim($_GET['tab']));
     
     		$o.=profile_tabs($a, $is_owner, $a->profile['nickname']);
     
     
    -		if($tab === 'profile') {
    +		if ($tab === 'profile') {
     			$o .= advanced_profile($a);
     			call_hooks('profile_advanced',$o);
     			return $o;
     		}
     
    -
     		$o .= common_friends_visitor_widget($a->profile['profile_uid']);
     
    -
    -		if(x($_SESSION,'new_member') && $_SESSION['new_member'] && $is_owner)
    +		if (x($_SESSION,'new_member') && $_SESSION['new_member'] && $is_owner) {
     			$o .= '' . t('Tips for New Members') . '' . EOL;
    +		}
     
     		$commpage = (($a->profile['page-flags'] == PAGE_COMMUNITY) ? true : false);
     		$commvisitor = (($commpage && $remote_contact == true) ? true : false);
    @@ -185,7 +180,7 @@ function profile_content(&$a, $update = 0) {
     		$a->page['aside'] .= posted_date_widget(App::get_baseurl(true) . '/profile/' . $a->profile['nickname'],$a->profile['profile_uid'],true);
     		$a->page['aside'] .= categories_widget(App::get_baseurl(true) . '/profile/' . $a->profile['nickname'],(x($category) ? xmlify($category) : ''));
     
    -		if(can_write_wall($a,$a->profile['profile_uid'])) {
    +		if (can_write_wall($a,$a->profile['profile_uid'])) {
     
     			$x = array(
     				'is_owner' => $is_owner,
    @@ -215,7 +210,7 @@ function profile_content(&$a, $update = 0) {
     	$sql_extra = item_permissions_sql($a->profile['profile_uid'],$remote_contact,$groups);
     
     
    -	if($update) {
    +	if ($update) {
     
     		$r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`
     			FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
    @@ -234,16 +229,16 @@ function profile_content(&$a, $update = 0) {
     	} else {
     		$sql_post_table = "";
     
    -		if(x($category)) {
    +		if (x($category)) {
     			$sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
     				dbesc(protect_sprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($a->profile['profile_uid']));
     			//$sql_extra .= protect_sprintf(file_tag_file_query('item',$category,'category'));
     		}
     
    -		if($datequery) {
    +		if ($datequery) {
     			$sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery))));
     		}
    -		if($datequery2) {
    +		if ($datequery2) {
     			$sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
     		}
     
    diff --git a/mod/profile_photo.php b/mod/profile_photo.php
    index 9b1ff8adb8..c600dd1f86 100644
    --- a/mod/profile_photo.php
    +++ b/mod/profile_photo.php
    @@ -133,9 +133,9 @@ function profile_photo_post(App &$a) {
     
     				require_once('include/profile_update.php');
     				profile_change();
    -			}
    -			else
    +			} else {
     				notice( t('Unable to process image') . EOL);
    +			}
     		}
     
     		goaway(App::get_baseurl() . '/profiles');
    @@ -146,11 +146,13 @@ function profile_photo_post(App &$a) {
     	$filename = basename($_FILES['userfile']['name']);
     	$filesize = intval($_FILES['userfile']['size']);
     	$filetype = $_FILES['userfile']['type'];
    -    if ($filetype=="") $filetype=guess_image_type($filename);
    -    
    +	if ($filetype == "") {
    +		$filetype = guess_image_type($filename);
    +	}
    +
     	$maximagesize = get_config('system','maximagesize');
     
    -	if(($maximagesize) && ($filesize > $maximagesize)) {
    +	if (($maximagesize) && ($filesize > $maximagesize)) {
     		notice( sprintf(t('Image exceeds size limit of %s'), formatBytes($maximagesize)) . EOL);
     		@unlink($src);
     		return;
    @@ -159,7 +161,7 @@ function profile_photo_post(App &$a) {
     	$imagedata = @file_get_contents($src);
     	$ph = new Photo($imagedata, $filetype);
     
    -	if(! $ph->is_valid()) {
    +	if (! $ph->is_valid()) {
     		notice( t('Unable to process image.') . EOL );
     		@unlink($src);
     		return;
    @@ -168,7 +170,6 @@ function profile_photo_post(App &$a) {
     	$ph->orient($src);
     	@unlink($src);
     	return profile_photo_crop_ui_head($a, $ph);
    -	
     }
     
     
    diff --git a/mod/videos.php b/mod/videos.php
    index 64838998f1..433ce5fc63 100644
    --- a/mod/videos.php
    +++ b/mod/videos.php
    @@ -113,7 +113,7 @@ function videos_post(App &$a) {
     	if (($a->argc == 2) && x($_POST,'delete') && x($_POST, 'id')) {
     
     		// Check if we should do HTML-based delete confirmation
    -		if(!x($_REQUEST,'confirm')) {
    +		if (!x($_REQUEST,'confirm')) {
     			if (x($_REQUEST,'canceled')) {
     				goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
     			}
    @@ -138,7 +138,6 @@ function videos_post(App &$a) {
     
     		$video_id = $_POST['id'];
     
    -
     		$r = q("SELECT `id`  FROM `attach` WHERE `uid` = %d AND `id` = '%s' LIMIT 1",
     			intval(local_user()),
     			dbesc($video_id)
    @@ -409,4 +408,3 @@ function videos_content(App &$a) {
     	$o .= paginate($a);
     	return $o;
     }
    -
    diff --git a/view/theme/duepuntozero/config.php b/view/theme/duepuntozero/config.php
    index acea9947bf..eec76d173b 100644
    --- a/view/theme/duepuntozero/config.php
    +++ b/view/theme/duepuntozero/config.php
    @@ -42,13 +42,13 @@ function theme_admin_post(App &$a){
     /// @TODO $a is no longer used
     function clean_form(&$a, &$colorset, $user){
     	$colorset = array(
    -		'default'=>t('default'), 
    -		'greenzero'=>t('greenzero'),
    -		'purplezero'=>t('purplezero'),
    -		'easterbunny'=>t('easterbunny'),
    -		'darkzero'=>t('darkzero'),
    -		'comix'=>t('comix'),
    -		'slackr'=>t('slackr'),
    +		'default'     =>t('default'), 
    +		'greenzero'   =>t('greenzero'),
    +		'purplezero'  =>t('purplezero'),
    +		'easterbunny' =>t('easterbunny'),
    +		'darkzero'    =>t('darkzero'),
    +		'comix'       =>t('comix'),
    +		'slackr'      =>t('slackr'),
     	);
     
     	if ($user) {
    @@ -62,7 +62,7 @@ function clean_form(&$a, &$colorset, $user){
     	$o .= replace_macros($t, array(
     		'$submit'   => t('Submit'),
     		'$baseurl'  => App::get_baseurl(),
    -		'$title'=> t("Theme settings"),
    +		'$title'    => t("Theme settings"),
     		'$colorset' => array('duepuntozero_colorset', t('Variations'), $color, '', $colorset),
     	));
     
    
    From 9b6ad2fc4754185708d00d3be4c4a2aebcb73e7e Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Roland=20H=C3=A4der?= 
    Date: Tue, 20 Dec 2016 10:39:06 +0100
    Subject: [PATCH 78/96] Coding convention: - added curly braces - added space
     between "if" and brace - also added TODO (old-lost code?)
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    Signed-off-by: Roland Häder 
    ---
     mod/hcard.php    | 4 ++++
     mod/noscrape.php | 1 +
     mod/profile.php  | 4 ++++
     3 files changed, 9 insertions(+)
    
    diff --git a/mod/hcard.php b/mod/hcard.php
    index d53405009a..8d79dd0546 100644
    --- a/mod/hcard.php
    +++ b/mod/hcard.php
    @@ -47,7 +47,11 @@ function hcard_init(App &$a) {
     	header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
     
     	$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
    +<<<<<<< upstream/develop
     	foreach ($dfrn_pages as $dfrn) {
    +=======
    +	foreach($dfrn_pages as $dfrn) {
    +>>>>>>> HEAD~65
     		$a->page['htmlhead'] .= "\r\n";
     	}
     
    diff --git a/mod/noscrape.php b/mod/noscrape.php
    index 758ce8ba53..33255f0fa4 100644
    --- a/mod/noscrape.php
    +++ b/mod/noscrape.php
    @@ -26,6 +26,7 @@ function noscrape_init(App &$a) {
     	$keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords);
     	$keywords = explode(',', $keywords);
     
    +	/// @TODO This query's result is not being used (see below), maybe old-lost code?
     	$r = q("SELECT `photo` FROM `contact` WHERE `self` AND `uid` = %d",
     		intval($a->profile['uid']));
     
    diff --git a/mod/profile.php b/mod/profile.php
    index 8519f7e82e..28b508dc0e 100644
    --- a/mod/profile.php
    +++ b/mod/profile.php
    @@ -62,7 +62,11 @@ function profile_init(App &$a) {
     	header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
     
     	$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
    +<<<<<<< upstream/develop
     	foreach ($dfrn_pages as $dfrn) {
    +=======
    +	foreach($dfrn_pages as $dfrn) {
    +>>>>>>> HEAD~65
     		$a->page['htmlhead'] .= "\r\n";
     	}
     	$a->page['htmlhead'] .= "\r\n";
    
    From 9fad8109ffafa689ff5b230906d21dec18cd8725 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Roland=20H=C3=A4der?= 
    Date: Tue, 20 Dec 2016 10:58:55 +0100
    Subject: [PATCH 79/96] changed to this: --------------------- function bla
     (App &$a) { 	$a->bla = 'stuff'; } ---------------------
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    Signed-off-by: Roland Häder 
    ---
     mod/admin.php    | 14 +++++++-------
     mod/contacts.php | 13 ++++++++-----
     mod/hcard.php    |  4 ----
     mod/network.php  |  6 ++----
     mod/notify.php   |  2 --
     mod/profile.php  |  4 ----
     mod/suggest.php  |  1 -
     mod/uexport.php  |  1 +
     8 files changed, 18 insertions(+), 27 deletions(-)
    
    diff --git a/mod/admin.php b/mod/admin.php
    index 48320fb36c..e1ccf67caf 100644
    --- a/mod/admin.php
    +++ b/mod/admin.php
    @@ -1156,21 +1156,21 @@ function admin_page_dbsync(App &$a) {
      * @param App $a
      */
     function admin_page_users_post(App &$a){
    -	$pending     =	(x($_POST, 'pending')           ? $_POST['pending']           : array());
    -	$users       =	(x($_POST, 'user')              ? $_POST['user']		      : array());
    -	$nu_name     =	(x($_POST, 'new_user_name')     ? $_POST['new_user_name']     : '');
    -	$nu_nickname =	(x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : '');
    -	$nu_email    =	(x($_POST, 'new_user_email')    ? $_POST['new_user_email']    : '');
    +	$pending     = (x($_POST, 'pending')           ? $_POST['pending']           : array());
    +	$users       = (x($_POST, 'user')              ? $_POST['user']		      : array());
    +	$nu_name     = (x($_POST, 'new_user_name')     ? $_POST['new_user_name']     : '');
    +	$nu_nickname = (x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : '');
    +	$nu_email    = (x($_POST, 'new_user_email')    ? $_POST['new_user_email']    : '');
     	$nu_language = get_config('system', 'language');
     
     	check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
     
    -	if(!($nu_name==="") && !($nu_email==="") && !($nu_nickname==="")) {
    +	if (!($nu_name==="") && !($nu_email==="") && !($nu_nickname==="")) {
     		require_once('include/user.php');
     
     		$result = create_user(array('username'=>$nu_name, 'email'=>$nu_email, 
     			'nickname'=>$nu_nickname, 'verified'=>1, 'language'=>$nu_language));
    -		if(! $result['success']) {
    +		if (! $result['success']) {
     			notice($result['message']);
     			return;
     		}
    diff --git a/mod/contacts.php b/mod/contacts.php
    index f709f9d2fb..26dfe06078 100644
    --- a/mod/contacts.php
    +++ b/mod/contacts.php
    @@ -28,19 +28,22 @@ function contacts_init(App &$a) {
     	require_once('include/group.php');
     	require_once('include/contact_widgets.php');
     
    -	if ($_GET['nets'] == "all")
    -	$_GET['nets'] = "";
    +	if ($_GET['nets'] == "all") {
    +		$_GET['nets'] = "";
    +	}
     
    -	if(! x($a->page,'aside'))
    +	if (! x($a->page,'aside')) {
     		$a->page['aside'] = '';
    +	}
     
    -	if($contact_id) {
    +	if ($contact_id) {
     			$a->data['contact'] = $r[0];
     
     			if (($a->data['contact']['network'] != "") AND ($a->data['contact']['network'] != NETWORK_DFRN)) {
     				$networkname = format_network_name($a->data['contact']['network'],$a->data['contact']['url']);
    -			} else
    +			} else {
     				$networkname = '';
    +			}
     
     			$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"),array(
     				'$name' => htmlentities($a->data['contact']['name']),
    diff --git a/mod/hcard.php b/mod/hcard.php
    index 8d79dd0546..d53405009a 100644
    --- a/mod/hcard.php
    +++ b/mod/hcard.php
    @@ -47,11 +47,7 @@ function hcard_init(App &$a) {
     	header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
     
     	$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
    -<<<<<<< upstream/develop
     	foreach ($dfrn_pages as $dfrn) {
    -=======
    -	foreach($dfrn_pages as $dfrn) {
    ->>>>>>> HEAD~65
     		$a->page['htmlhead'] .= "\r\n";
     	}
     
    diff --git a/mod/network.php b/mod/network.php
    index f433277076..61df38fb12 100644
    --- a/mod/network.php
    +++ b/mod/network.php
    @@ -25,7 +25,6 @@ function network_init(App &$a) {
     	parse_str($query_string, $query_array);
     	array_shift($query_array);
     
    -
     	// fetch last used network view and redirect if needed
     	if (! $is_a_date_query) {
     		$sel_tabs = network_query_get_sel_tab($a);
    @@ -42,10 +41,9 @@ function network_init(App &$a) {
     		$net_baseurl = '/network';
     		$net_args = array();
     
    -		if($remember_group) {
    +		if ($remember_group) {
     			$net_baseurl .= '/' . $last_sel_groups; // Note that the group number must come before the "/new" tab selection
    -		}
    -		else if($sel_groups !== false) {
    +		} elseif($sel_groups !== false) {
     			$net_baseurl .= '/' . $sel_groups;
     		}
     
    diff --git a/mod/notify.php b/mod/notify.php
    index 2d34821ded..2696afaada 100644
    --- a/mod/notify.php
    +++ b/mod/notify.php
    @@ -1,12 +1,10 @@
     argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
    diff --git a/mod/profile.php b/mod/profile.php
    index 28b508dc0e..8519f7e82e 100644
    --- a/mod/profile.php
    +++ b/mod/profile.php
    @@ -62,11 +62,7 @@ function profile_init(App &$a) {
     	header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
     
     	$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
    -<<<<<<< upstream/develop
     	foreach ($dfrn_pages as $dfrn) {
    -=======
    -	foreach($dfrn_pages as $dfrn) {
    ->>>>>>> HEAD~65
     		$a->page['htmlhead'] .= "\r\n";
     	}
     	$a->page['htmlhead'] .= "\r\n";
    diff --git a/mod/suggest.php b/mod/suggest.php
    index 6ded66286a..a6c4b6e568 100644
    --- a/mod/suggest.php
    +++ b/mod/suggest.php
    @@ -3,7 +3,6 @@
     require_once('include/socgraph.php');
     require_once('include/contact_widgets.php');
     
    -
     function suggest_init(App &$a) {
     	if (! local_user()) {
     		return;
    diff --git a/mod/uexport.php b/mod/uexport.php
    index 7aa9724d58..1ca046d224 100644
    --- a/mod/uexport.php
    +++ b/mod/uexport.php
    @@ -9,6 +9,7 @@ function uexport_init(App &$a){
     	settings_init($a);
     }
     
    +/// @TODO Change space -> tab where wanted
     function uexport_content(App &$a){
     
         if ($a->argc > 1) {
    
    From 820ef8e4c76c606e74f5ec1708bbd0e807faa44b Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Roland=20H=C3=A4der?= 
    Date: Tue, 20 Dec 2016 10:59:06 +0100
    Subject: [PATCH 80/96] changed to this: --------------------- function bla
     (App &$a) { 	$a->bla = 'stuff'; } ---------------------
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    Signed-off-by: Roland Häder 
    ---
     view/theme/duepuntozero/config.php | 2 --
     view/theme/quattro/config.php      | 1 -
     2 files changed, 3 deletions(-)
    
    diff --git a/view/theme/duepuntozero/config.php b/view/theme/duepuntozero/config.php
    index eec76d173b..48c9c87099 100644
    --- a/view/theme/duepuntozero/config.php
    +++ b/view/theme/duepuntozero/config.php
    @@ -3,7 +3,6 @@
      * Theme settings
      */
     
    -
     function theme_content(App &$a){
     	if (!local_user()) {
     		return;
    @@ -25,7 +24,6 @@ function theme_post(App &$a){
     	}
     }
     
    -
     function theme_admin(App &$a){
     	$colorset = get_config( 'duepuntozero', 'colorset');
     	$user = false;
    diff --git a/view/theme/quattro/config.php b/view/theme/quattro/config.php
    index 0c619569a0..32f71db015 100644
    --- a/view/theme/quattro/config.php
    +++ b/view/theme/quattro/config.php
    @@ -29,7 +29,6 @@ function theme_post(App &$a){
     	}
     }
     
    -
     function theme_admin(App &$a){
     	$align = get_config('quattro', 'align' );
     	$color = get_config('quattro', 'color' );
    
    From 8b8a45b7038f573a2e18e761eeff4f506185af0b Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Roland=20H=C3=A4der?= 
    Date: Tue, 20 Dec 2016 11:27:40 +0100
    Subject: [PATCH 81/96] added curly braces + space between "if" and brace
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    Signed-off-by: Roland Häder 
    ---
     mod/notify.php | 1 +
     1 file changed, 1 insertion(+)
    
    diff --git a/mod/notify.php b/mod/notify.php
    index 2696afaada..bd7a7faf49 100644
    --- a/mod/notify.php
    +++ b/mod/notify.php
    @@ -5,6 +5,7 @@ function notify_init(App &$a) {
     	if (! local_user()) {
     		return;
     	}
    +
     	$nm = new NotificationsManager();
     
     	if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
    
    From 8ce20f975c7fc1c27d1981234aefc93b0e7b662a Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Roland=20H=C3=A4der?= 
    Date: Tue, 20 Dec 2016 12:45:16 +0100
    Subject: [PATCH 82/96] Changed $a->get_baseurl() to App::get_baseurl()
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    Signed-off-by: Roland Häder 
    ---
     mod/filerm.php    | 5 +++++
     mod/subthread.php | 4 ++++
     2 files changed, 9 insertions(+)
    
    diff --git a/mod/filerm.php b/mod/filerm.php
    index 7dbfe29473..7662289ad2 100644
    --- a/mod/filerm.php
    +++ b/mod/filerm.php
    @@ -22,9 +22,14 @@ function filerm_content(App &$a) {
     		file_tag_unsave_file(local_user(),$item_id,$term, $category);
     	}
     
    +<<<<<<< upstream/develop
     	if (x($_SESSION,'return_url')) {
     		goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
     	}
    +=======
    +	if(x($_SESSION,'return_url'))
    +		goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
    +>>>>>>> HEAD~33
     
     	killme();
     }
    diff --git a/mod/subthread.php b/mod/subthread.php
    index c689f7f6cb..368619dec4 100644
    --- a/mod/subthread.php
    +++ b/mod/subthread.php
    @@ -86,7 +86,11 @@ function subthread_content(App &$a) {
     	$uri = item_new_uri($a->get_hostname(),$owner_uid);
     
     	$post_type = (($item['resource-id']) ? t('photo') : t('status'));
    +<<<<<<< upstream/develop
     	$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
    +=======
    +	$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
    +>>>>>>> HEAD~33
     	$link = xmlify('' . "\n") ;
     	$body = $item['body'];
     
    
    From 3472191b055bdb9a912daceaea1ccd8516137091 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Roland=20H=C3=A4der?= 
    Date: Tue, 20 Dec 2016 12:45:16 +0100
    Subject: [PATCH 83/96] Changed $a->get_baseurl() to App::get_baseurl()
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    Signed-off-by: Roland Häder 
    ---
     mod/filerm.php    | 5 -----
     mod/subthread.php | 3 +++
     2 files changed, 3 insertions(+), 5 deletions(-)
    
    diff --git a/mod/filerm.php b/mod/filerm.php
    index 7662289ad2..7dbfe29473 100644
    --- a/mod/filerm.php
    +++ b/mod/filerm.php
    @@ -22,14 +22,9 @@ function filerm_content(App &$a) {
     		file_tag_unsave_file(local_user(),$item_id,$term, $category);
     	}
     
    -<<<<<<< upstream/develop
     	if (x($_SESSION,'return_url')) {
     		goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
     	}
    -=======
    -	if(x($_SESSION,'return_url'))
    -		goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
    ->>>>>>> HEAD~33
     
     	killme();
     }
    diff --git a/mod/subthread.php b/mod/subthread.php
    index 368619dec4..69b7f3a601 100644
    --- a/mod/subthread.php
    +++ b/mod/subthread.php
    @@ -90,7 +90,10 @@ function subthread_content(App &$a) {
     	$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
     =======
     	$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
    +<<<<<<< upstream/develop
     >>>>>>> HEAD~33
    +=======
    +>>>>>>> HEAD~32
     	$link = xmlify('' . "\n") ;
     	$body = $item['body'];
     
    
    From 54905a3d81065915418af7f96953f957bf795300 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Roland=20H=C3=A4der?= 
    Date: Tue, 20 Dec 2016 17:43:46 +0100
    Subject: [PATCH 84/96] added more curly braces + space between "if" and brace
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    Signed-off-by: Roland Häder 
    ---
     mod/subthread.php | 7 -------
     1 file changed, 7 deletions(-)
    
    diff --git a/mod/subthread.php b/mod/subthread.php
    index 69b7f3a601..c689f7f6cb 100644
    --- a/mod/subthread.php
    +++ b/mod/subthread.php
    @@ -86,14 +86,7 @@ function subthread_content(App &$a) {
     	$uri = item_new_uri($a->get_hostname(),$owner_uid);
     
     	$post_type = (($item['resource-id']) ? t('photo') : t('status'));
    -<<<<<<< upstream/develop
     	$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
    -=======
    -	$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
    -<<<<<<< upstream/develop
    ->>>>>>> HEAD~33
    -=======
    ->>>>>>> HEAD~32
     	$link = xmlify('' . "\n") ;
     	$body = $item['body'];
     
    
    From ca82678a6da703157a95a815d57649af5066397b Mon Sep 17 00:00:00 2001
    From: Roland Haeder 
    Date: Tue, 20 Dec 2016 21:13:50 +0100
    Subject: [PATCH 85/96] 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 
    ---
     include/acl_selectors.php | 6 +++---
     include/message.php       | 3 ++-
     2 files changed, 5 insertions(+), 4 deletions(-)
    
    diff --git a/include/acl_selectors.php b/include/acl_selectors.php
    index 4c0b610d46..f6c4f947ed 100644
    --- a/include/acl_selectors.php
    +++ b/include/acl_selectors.php
    @@ -272,7 +272,7 @@ function prune_deadguys($arr) {
     
     	$r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 ");
     
    -	if ($r) {
    +	if (dbm::is_result($r)) {
     		$ret = array();
     		foreach ($r as $rr) {
     			$ret[] = intval($rr['id']);
    @@ -585,9 +585,9 @@ function acl_lookup(&$a, $out_type = 'json') {
     		);
     		echo json_encode($o);
     		killme();
    -	}
    -	else
    +	} else {
     		$r = array();
    +	}
     
     
     	if (dbm::is_result($r)) {
    diff --git a/include/message.php b/include/message.php
    index 3d5d4d33ab..5bd611f220 100644
    --- a/include/message.php
    +++ b/include/message.php
    @@ -153,7 +153,8 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
     	if ($post_id) {
     		proc_run(PRIORITY_HIGH, "include/notifier.php", "mail", $post_id);
     		return intval($post_id);
    -	} else {
    +	}
    +	else {
     		return -3;
     	}
     
    
    From c1b76e889e4b2ca50abe191c22f3a8bb7a9bfdaf Mon Sep 17 00:00:00 2001
    From: Roland Haeder 
    Date: Tue, 20 Dec 2016 21:15:53 +0100
    Subject: [PATCH 86/96] 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 
    ---
     mod/install.php | 3 ++-
     1 file changed, 2 insertions(+), 1 deletion(-)
    
    diff --git a/mod/install.php b/mod/install.php
    index 9adeac604e..f7329592e0 100755
    --- a/mod/install.php
    +++ b/mod/install.php
    @@ -538,7 +538,8 @@ function check_htaccess(&$checks) {
     			$help = t('Url rewrite in .htaccess is not working. Check your server configuration.');
     		}
     		check_add($checks, t('Url rewrite is working'), $status, true, $help);
    -	} else {
    +	}
    +	else {
     		// cannot check modrewrite if libcurl is not installed
     		/// @TODO Maybe issue warning here?
     	}
    
    From 45dd1ccc7bcd8cf9d9218b373042df26dc8a2df4 Mon Sep 17 00:00:00 2001
    From: Roland Haeder 
    Date: Tue, 20 Dec 2016 21:15:53 +0100
    Subject: [PATCH 87/96] 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 
    ---
     mod/item.php | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/mod/item.php b/mod/item.php
    index 0746f0ada8..ee532bd99b 100644
    --- a/mod/item.php
    +++ b/mod/item.php
    @@ -454,7 +454,7 @@ function item_post(App &$a) {
     			$objecttype = ACTIVITY_OBJ_IMAGE;
     
     			foreach ($images as $image) {
    -				if (! stristr($image,App::get_baseurl() . '/photo/'))
    +				if (! stristr($image,App::get_baseurl() . '/photo/')) {
     					continue;
     				}
     				$image_uri = substr($image,strrpos($image,'/') + 1);
    
    From 89319d9579bb052e0b105ab6a41d432d0df9b49f Mon Sep 17 00:00:00 2001
    From: Roland Haeder 
    Date: Tue, 20 Dec 2016 21:31:05 +0100
    Subject: [PATCH 88/96] Continued with coding convention: - added curly braces
     around conditional code blocks - added space between if/foreach/... and brace
     - made some SQL keywords upper-cased and added back-ticks to columns/table
     names
    
    Signed-off-by: Roland Haeder 
    ---
     mod/noscrape.php | 1 -
     1 file changed, 1 deletion(-)
    
    diff --git a/mod/noscrape.php b/mod/noscrape.php
    index 33255f0fa4..758ce8ba53 100644
    --- a/mod/noscrape.php
    +++ b/mod/noscrape.php
    @@ -26,7 +26,6 @@ function noscrape_init(App &$a) {
     	$keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords);
     	$keywords = explode(',', $keywords);
     
    -	/// @TODO This query's result is not being used (see below), maybe old-lost code?
     	$r = q("SELECT `photo` FROM `contact` WHERE `self` AND `uid` = %d",
     		intval($a->profile['uid']));
     
    
    From 3dbb92c0dcbf087bfded1f84a7aab500c1b4b0c1 Mon Sep 17 00:00:00 2001
    From: Roland Haeder 
    Date: Wed, 21 Dec 2016 23:04:09 +0100
    Subject: [PATCH 89/96] added curly braces/spaces + replace spaces with tabs to
     fix code indending (or so?)
    
    Signed-off-by: Roland Haeder 
    ---
     include/message.php | 3 +--
     mod/install.php     | 4 +---
     2 files changed, 2 insertions(+), 5 deletions(-)
    
    diff --git a/include/message.php b/include/message.php
    index 5bd611f220..3d5d4d33ab 100644
    --- a/include/message.php
    +++ b/include/message.php
    @@ -153,8 +153,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
     	if ($post_id) {
     		proc_run(PRIORITY_HIGH, "include/notifier.php", "mail", $post_id);
     		return intval($post_id);
    -	}
    -	else {
    +	} else {
     		return -3;
     	}
     
    diff --git a/mod/install.php b/mod/install.php
    index f7329592e0..382fcefd76 100755
    --- a/mod/install.php
    +++ b/mod/install.php
    @@ -538,8 +538,7 @@ function check_htaccess(&$checks) {
     			$help = t('Url rewrite in .htaccess is not working. Check your server configuration.');
     		}
     		check_add($checks, t('Url rewrite is working'), $status, true, $help);
    -	}
    -	else {
    +	} else {
     		// cannot check modrewrite if libcurl is not installed
     		/// @TODO Maybe issue warning here?
     	}
    @@ -582,7 +581,6 @@ function load_database_rem($v, $i){
     	}
     }
     
    -
     function load_database($db) {
     
     	require_once("include/dbstructure.php");
    
    From b7c9d63b7ae4db97c78f8a7a3844455e4c63a3eb Mon Sep 17 00:00:00 2001
    From: Roland Haeder 
    Date: Fri, 23 Dec 2016 20:09:10 +0100
    Subject: [PATCH 90/96] Fixed parser errors (opps) + changed # -> // Please do
     so also as # for comments is deprecated.
    
    Signed-off-by: Roland Haeder 
    ---
     include/plugin.php                        |  2 +-
     library/spam/b8/storage/storage_frndc.php | 51 ++++++++++-------------
     mod/admin.php                             |  6 +--
     mod/profile.php                           |  8 ++--
     4 files changed, 32 insertions(+), 35 deletions(-)
    
    diff --git a/include/plugin.php b/include/plugin.php
    index 8cb2783eef..83f6f1ab95 100644
    --- a/include/plugin.php
    +++ b/include/plugin.php
    @@ -478,7 +478,7 @@ function service_class_allows($uid,$property,$usage = false) {
     		}
     	}
     
    -	if (! x($service_class)) [
    +	if (! x($service_class)) {
     		// everything is allowed
     		return true;
     	}
    diff --git a/library/spam/b8/storage/storage_frndc.php b/library/spam/b8/storage/storage_frndc.php
    index 62909d4715..e01e652ae4 100644
    --- a/library/spam/b8/storage/storage_frndc.php
    +++ b/library/spam/b8/storage/storage_frndc.php
    @@ -123,15 +123,17 @@ class b8_storage_frndc extends b8_storage_base
     	function __destruct()
     	{
     
    -		if($this->_connection === NULL)
    +		if ($this->_connection === NULL) {
     			return;
    +		}
     
    -		# Commit any changes before closing
    +		// Commit any changes before closing
     		$this->_commit();
     
    -		# Just close the connection if no link-resource was passed and b8 created it's own connection
    -		if($this->config['connection'] === NULL)
    +		// Just close the connection if no link-resource was passed and b8 created it's own connection
    +		if ($this->config['connection'] === NULL) {
     			mysql_close($this->_connection);
    +		}
     
     		$this->connected = FALSE;
     
    @@ -163,9 +165,8 @@ class b8_storage_frndc extends b8_storage_base
     	protected function _get_query($tokens, $uid)
     	{
     
    -		# Construct the query ...
    -
    -		if(count($tokens) > 0) {
    +		// Construct the query ...
    +		if (count($tokens) > 0) {
     
     			$where = array();
     
    @@ -175,42 +176,42 @@ class b8_storage_frndc extends b8_storage_base
     			}
     
     			$where = 'term IN ("' . implode('", "', $where) . '")';
    -		}
    -
    -		else {
    +		} else {
     			$token = dbesc($token);
     			$where = 'term = "' . $token . '"';
     		}
     
    -		# ... and fetch the data
    +		// ... and fetch the data
     
    -		$result = q('
    -			SELECT * FROM spam WHERE ' . $where . ' AND uid = ' . $uid );
    +		$result = q('SELECT * FROM `spam` WHERE ' . $where . ' AND `uid` = ' . $uid );
     
     
     		$returned_tokens = array();
    -		if(count($result)) {
    -			foreach($result as $rr)
    +		if (dbm::is_result($result)) {
    +			foreach ($result as $rr) {
     				$returned_tokens[] = $rr['term'];
    +			}
     		}
     		$to_create = array();
     
    -		if(count($tokens) > 0) {
    +		if (count($tokens) > 0) {
     			foreach($tokens as $token)
     				if(! in_array($token,$returned_tokens))
     					$to_create[] = str_tolower($token); 
     		}
    -		if(count($to_create)) {
    +		if (count($to_create)) {
     			$sql = '';
    -			foreach($to_create as $term) {
    -				if(strlen($sql))
    +			foreach ($to_create as $term) {
    +				if (strlen($sql)) {
     					$sql .= ',';
    -				$sql .= sprintf("(term,datetime,uid) values('%s','%s',%d)",
    -					dbesc(str_tolower($term))
    +				}
    +				$sql .= sprintf("(`term`,`datetime`,`uid`) VALUES('%s','%s',%d)",
    +					dbesc(str_tolower($term)),
     					dbesc(datetime_convert()),
     					intval($uid)
     				);
    -			q("insert into spam " . $sql);
    +			}
    +			q("INSERT INTO `spam` " . $sql);
     		}
     
     		return $result;
    @@ -225,7 +226,6 @@ class b8_storage_frndc extends b8_storage_base
     	 * @param string $count
     	 * @return void
     	 */
    -
     	protected function _put($token, $count, $uid) {
     		$token = dbesc($token);
     		$count = dbesc($count);
    @@ -241,7 +241,6 @@ class b8_storage_frndc extends b8_storage_base
     	 * @param string $count
     	 * @return void
     	 */
    -
     	protected function _update($token, $count, $uid)
     	{
     		$token = dbesc($token);
    @@ -257,7 +256,6 @@ class b8_storage_frndc extends b8_storage_base
     	 * @param string $token
     	 * @return void
     	 */
    -
     	protected function _del($token, $uid)
     	{
     		$token = dbesc($token);
    @@ -272,7 +270,6 @@ class b8_storage_frndc extends b8_storage_base
     	 * @access protected
     	 * @return void
     	 */
    -
     	protected function _commit($uid)
     	{
     
    @@ -314,5 +311,3 @@ class b8_storage_frndc extends b8_storage_base
     	}
     
     }
    -
    -?>
    \ No newline at end of file
    diff --git a/mod/admin.php b/mod/admin.php
    index e1ccf67caf..100a125335 100644
    --- a/mod/admin.php
    +++ b/mod/admin.php
    @@ -1854,9 +1854,9 @@ function admin_page_logs_post(App &$a) {
     	if (x($_POST,"page_logs")) {
     		check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs');
     
    -		$logfile   = (x($_POST,'logfile'))    ? notags(trim($_POST['logfile']))	: '');
    -		$debugging = ((x($_POST,'debugging')) ? true					: false);
    -		$loglevel  = ((x($_POST,'loglevel'))  ? intval(trim($_POST['loglevel']))	: 0);
    +		$logfile   = ((x($_POST,'logfile'))    ? notags(trim($_POST['logfile'])) : '');
    +		$debugging = ((x($_POST,'debugging')) ? true : false);
    +		$loglevel  = ((x($_POST,'loglevel'))  ? intval(trim($_POST['loglevel'])) : 0);
     
     		set_config('system','logfile', $logfile);
     		set_config('system','debugging',  $debugging);
    diff --git a/mod/profile.php b/mod/profile.php
    index 8519f7e82e..32539758e2 100644
    --- a/mod/profile.php
    +++ b/mod/profile.php
    @@ -41,14 +41,15 @@ function profile_init(App &$a) {
     	if((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) {
     		$a->page['htmlhead'] .= '';
     	}
    -	if(x($a->profile,'openidserver'))
    +	if (x($a->profile,'openidserver')) {
     		$a->page['htmlhead'] .= '' . "\r\n";
    -	if(x($a->profile,'openid')) {
    +	}
    +	if (x($a->profile,'openid')) {
     		$delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'https://' . $a->profile['openid']);
     		$a->page['htmlhead'] .= '' . "\r\n";
     	}
     	// site block
    -	if((! $blocked) && (! $userblock)) {
    +	if ((! $blocked) && (! $userblock)) {
     		$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
     		$keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords);
     		if(strlen($keywords))
    @@ -81,6 +82,7 @@ function profile_content(&$a, $update = 0) {
     					$datequery2 = escape_tags($a->argv[$x]);
     				} else {
     					$datequery = escape_tags($a->argv[$x]);
    +				}
     			} else {
     				$category = $a->argv[$x];
     			}
    
    From 7aa799a0ee5e43e2677d177cf70dcbfb62151e5d Mon Sep 17 00:00:00 2001
    From: Roland Haeder 
    Date: Fri, 23 Dec 2016 20:09:10 +0100
    Subject: [PATCH 91/96] Fixed parser errors (opps) + changed # -> // Please do
     so also as # for comments is deprecated.
    
    Signed-off-by: Roland Haeder 
    ---
     include/plugin.php                        |  2 +-
     library/spam/b8/storage/storage_frndc.php | 51 ++++++++++-------------
     mod/admin.php                             |  6 +--
     mod/profile.php                           |  8 ++--
     4 files changed, 32 insertions(+), 35 deletions(-)
    
    diff --git a/include/plugin.php b/include/plugin.php
    index 8cb2783eef..83f6f1ab95 100644
    --- a/include/plugin.php
    +++ b/include/plugin.php
    @@ -478,7 +478,7 @@ function service_class_allows($uid,$property,$usage = false) {
     		}
     	}
     
    -	if (! x($service_class)) [
    +	if (! x($service_class)) {
     		// everything is allowed
     		return true;
     	}
    diff --git a/library/spam/b8/storage/storage_frndc.php b/library/spam/b8/storage/storage_frndc.php
    index 62909d4715..e01e652ae4 100644
    --- a/library/spam/b8/storage/storage_frndc.php
    +++ b/library/spam/b8/storage/storage_frndc.php
    @@ -123,15 +123,17 @@ class b8_storage_frndc extends b8_storage_base
     	function __destruct()
     	{
     
    -		if($this->_connection === NULL)
    +		if ($this->_connection === NULL) {
     			return;
    +		}
     
    -		# Commit any changes before closing
    +		// Commit any changes before closing
     		$this->_commit();
     
    -		# Just close the connection if no link-resource was passed and b8 created it's own connection
    -		if($this->config['connection'] === NULL)
    +		// Just close the connection if no link-resource was passed and b8 created it's own connection
    +		if ($this->config['connection'] === NULL) {
     			mysql_close($this->_connection);
    +		}
     
     		$this->connected = FALSE;
     
    @@ -163,9 +165,8 @@ class b8_storage_frndc extends b8_storage_base
     	protected function _get_query($tokens, $uid)
     	{
     
    -		# Construct the query ...
    -
    -		if(count($tokens) > 0) {
    +		// Construct the query ...
    +		if (count($tokens) > 0) {
     
     			$where = array();
     
    @@ -175,42 +176,42 @@ class b8_storage_frndc extends b8_storage_base
     			}
     
     			$where = 'term IN ("' . implode('", "', $where) . '")';
    -		}
    -
    -		else {
    +		} else {
     			$token = dbesc($token);
     			$where = 'term = "' . $token . '"';
     		}
     
    -		# ... and fetch the data
    +		// ... and fetch the data
     
    -		$result = q('
    -			SELECT * FROM spam WHERE ' . $where . ' AND uid = ' . $uid );
    +		$result = q('SELECT * FROM `spam` WHERE ' . $where . ' AND `uid` = ' . $uid );
     
     
     		$returned_tokens = array();
    -		if(count($result)) {
    -			foreach($result as $rr)
    +		if (dbm::is_result($result)) {
    +			foreach ($result as $rr) {
     				$returned_tokens[] = $rr['term'];
    +			}
     		}
     		$to_create = array();
     
    -		if(count($tokens) > 0) {
    +		if (count($tokens) > 0) {
     			foreach($tokens as $token)
     				if(! in_array($token,$returned_tokens))
     					$to_create[] = str_tolower($token); 
     		}
    -		if(count($to_create)) {
    +		if (count($to_create)) {
     			$sql = '';
    -			foreach($to_create as $term) {
    -				if(strlen($sql))
    +			foreach ($to_create as $term) {
    +				if (strlen($sql)) {
     					$sql .= ',';
    -				$sql .= sprintf("(term,datetime,uid) values('%s','%s',%d)",
    -					dbesc(str_tolower($term))
    +				}
    +				$sql .= sprintf("(`term`,`datetime`,`uid`) VALUES('%s','%s',%d)",
    +					dbesc(str_tolower($term)),
     					dbesc(datetime_convert()),
     					intval($uid)
     				);
    -			q("insert into spam " . $sql);
    +			}
    +			q("INSERT INTO `spam` " . $sql);
     		}
     
     		return $result;
    @@ -225,7 +226,6 @@ class b8_storage_frndc extends b8_storage_base
     	 * @param string $count
     	 * @return void
     	 */
    -
     	protected function _put($token, $count, $uid) {
     		$token = dbesc($token);
     		$count = dbesc($count);
    @@ -241,7 +241,6 @@ class b8_storage_frndc extends b8_storage_base
     	 * @param string $count
     	 * @return void
     	 */
    -
     	protected function _update($token, $count, $uid)
     	{
     		$token = dbesc($token);
    @@ -257,7 +256,6 @@ class b8_storage_frndc extends b8_storage_base
     	 * @param string $token
     	 * @return void
     	 */
    -
     	protected function _del($token, $uid)
     	{
     		$token = dbesc($token);
    @@ -272,7 +270,6 @@ class b8_storage_frndc extends b8_storage_base
     	 * @access protected
     	 * @return void
     	 */
    -
     	protected function _commit($uid)
     	{
     
    @@ -314,5 +311,3 @@ class b8_storage_frndc extends b8_storage_base
     	}
     
     }
    -
    -?>
    \ No newline at end of file
    diff --git a/mod/admin.php b/mod/admin.php
    index e1ccf67caf..100a125335 100644
    --- a/mod/admin.php
    +++ b/mod/admin.php
    @@ -1854,9 +1854,9 @@ function admin_page_logs_post(App &$a) {
     	if (x($_POST,"page_logs")) {
     		check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs');
     
    -		$logfile   = (x($_POST,'logfile'))    ? notags(trim($_POST['logfile']))	: '');
    -		$debugging = ((x($_POST,'debugging')) ? true					: false);
    -		$loglevel  = ((x($_POST,'loglevel'))  ? intval(trim($_POST['loglevel']))	: 0);
    +		$logfile   = ((x($_POST,'logfile'))    ? notags(trim($_POST['logfile'])) : '');
    +		$debugging = ((x($_POST,'debugging')) ? true : false);
    +		$loglevel  = ((x($_POST,'loglevel'))  ? intval(trim($_POST['loglevel'])) : 0);
     
     		set_config('system','logfile', $logfile);
     		set_config('system','debugging',  $debugging);
    diff --git a/mod/profile.php b/mod/profile.php
    index 8519f7e82e..32539758e2 100644
    --- a/mod/profile.php
    +++ b/mod/profile.php
    @@ -41,14 +41,15 @@ function profile_init(App &$a) {
     	if((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) {
     		$a->page['htmlhead'] .= '';
     	}
    -	if(x($a->profile,'openidserver'))
    +	if (x($a->profile,'openidserver')) {
     		$a->page['htmlhead'] .= '' . "\r\n";
    -	if(x($a->profile,'openid')) {
    +	}
    +	if (x($a->profile,'openid')) {
     		$delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'https://' . $a->profile['openid']);
     		$a->page['htmlhead'] .= '' . "\r\n";
     	}
     	// site block
    -	if((! $blocked) && (! $userblock)) {
    +	if ((! $blocked) && (! $userblock)) {
     		$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
     		$keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords);
     		if(strlen($keywords))
    @@ -81,6 +82,7 @@ function profile_content(&$a, $update = 0) {
     					$datequery2 = escape_tags($a->argv[$x]);
     				} else {
     					$datequery = escape_tags($a->argv[$x]);
    +				}
     			} else {
     				$category = $a->argv[$x];
     			}
    
    From f844d96a7f9ea47a5be346cfd973200115d81bc5 Mon Sep 17 00:00:00 2001
    From: Roland Haeder 
    Date: Fri, 23 Dec 2016 20:21:38 +0100
    Subject: [PATCH 92/96] added some spaces
    
    Signed-off-by: Roland Haeder 
    ---
     mod/admin.php | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/mod/admin.php b/mod/admin.php
    index 100a125335..963d010317 100644
    --- a/mod/admin.php
    +++ b/mod/admin.php
    @@ -1854,8 +1854,8 @@ function admin_page_logs_post(App &$a) {
     	if (x($_POST,"page_logs")) {
     		check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs');
     
    -		$logfile   = ((x($_POST,'logfile'))    ? notags(trim($_POST['logfile'])) : '');
    -		$debugging = ((x($_POST,'debugging')) ? true : false);
    +		$logfile   = ((x($_POST,'logfile'))   ? notags(trim($_POST['logfile']))  : '');
    +		$debugging = ((x($_POST,'debugging')) ? true                             : false);
     		$loglevel  = ((x($_POST,'loglevel'))  ? intval(trim($_POST['loglevel'])) : 0);
     
     		set_config('system','logfile', $logfile);
    
    From 7131e45cb16f7011fd151f9b41dd7ab3e205ac38 Mon Sep 17 00:00:00 2001
    From: Roland Haeder 
    Date: Fri, 23 Dec 2016 20:21:38 +0100
    Subject: [PATCH 93/96] added some spaces
    
    Signed-off-by: Roland Haeder 
    ---
     mod/admin.php | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/mod/admin.php b/mod/admin.php
    index 100a125335..963d010317 100644
    --- a/mod/admin.php
    +++ b/mod/admin.php
    @@ -1854,8 +1854,8 @@ function admin_page_logs_post(App &$a) {
     	if (x($_POST,"page_logs")) {
     		check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs');
     
    -		$logfile   = ((x($_POST,'logfile'))    ? notags(trim($_POST['logfile'])) : '');
    -		$debugging = ((x($_POST,'debugging')) ? true : false);
    +		$logfile   = ((x($_POST,'logfile'))   ? notags(trim($_POST['logfile']))  : '');
    +		$debugging = ((x($_POST,'debugging')) ? true                             : false);
     		$loglevel  = ((x($_POST,'loglevel'))  ? intval(trim($_POST['loglevel'])) : 0);
     
     		set_config('system','logfile', $logfile);
    
    From bc9cb5e5f6bca2a193b85b3b6700592f8042b150 Mon Sep 17 00:00:00 2001
    From: Roland Haeder 
    Date: Fri, 30 Dec 2016 21:48:09 +0100
    Subject: [PATCH 94/96] added curly braces + fixed indenting according to code
     review by Hypolite
    
    Signed-off-by: Roland Haeder 
    ---
     include/follow.php            | 10 +++-----
     include/items.php             | 11 ++++++---
     mod/contacts.php              | 46 ++++++++++++++++++-----------------
     mod/profile.php               | 12 +++------
     view/theme/quattro/config.php |  6 ++---
     5 files changed, 42 insertions(+), 43 deletions(-)
    
    diff --git a/include/follow.php b/include/follow.php
    index 8d80538e0c..3045191077 100644
    --- a/include/follow.php
    +++ b/include/follow.php
    @@ -110,12 +110,10 @@ function new_contact($uid,$url,$interactive = false) {
     
     			// NOTREACHED
     		}
    -	} else {
    -		if (get_config('system','dfrn_only')) {
    -			$result['message'] = t('This site is not configured to allow communications with other networks.') . EOL;
    -			$result['message'] != t('No compatible communication protocols or feeds were discovered.') . EOL;
    -			return $result;
    -		}
    +	} elseif (get_config('system','dfrn_only')) {
    +		$result['message'] = t('This site is not configured to allow communications with other networks.') . EOL;
    +		$result['message'] != t('No compatible communication protocols or feeds were discovered.') . EOL;
    +		return $result;
     	}
     
     	// This extra param just confuses things, remove it
    diff --git a/include/items.php b/include/items.php
    index 8d95c35529..fa4f3290b1 100644
    --- a/include/items.php
    +++ b/include/items.php
    @@ -955,12 +955,14 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
     
     		$r = q('SELECT * FROM `item` WHERE `id` = %d', intval($current_post));
     		if ((dbm::is_result($r)) && (count($r) == 1)) {
    -			if ($notify)
    +			if ($notify) {
     				call_hooks('post_local_end', $r[0]);
    -			else
    +			} else {
     				call_hooks('post_remote_end', $r[0]);
    -		} else
    +			}
    +		} else {
     			logger('item_store: new item not found in DB, id ' . $current_post);
    +		}
     	}
     
     	if ($arr['parent-uri'] === $arr['uri']) {
    @@ -994,8 +996,9 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
     
     	check_item_notification($current_post, $uid);
     
    -	if ($notify)
    +	if ($notify) {
     		proc_run(PRIORITY_HIGH, "include/notifier.php", $notify_type, $current_post);
    +	}
     
     	return $current_post;
     }
    diff --git a/mod/contacts.php b/mod/contacts.php
    index 26dfe06078..38e0992257 100644
    --- a/mod/contacts.php
    +++ b/mod/contacts.php
    @@ -37,34 +37,36 @@ function contacts_init(App &$a) {
     	}
     
     	if ($contact_id) {
    -			$a->data['contact'] = $r[0];
    +		$a->data['contact'] = $r[0];
     
    -			if (($a->data['contact']['network'] != "") AND ($a->data['contact']['network'] != NETWORK_DFRN)) {
    -				$networkname = format_network_name($a->data['contact']['network'],$a->data['contact']['url']);
    -			} else {
    -				$networkname = '';
    -			}
    +		if (($a->data['contact']['network'] != "") AND ($a->data['contact']['network'] != NETWORK_DFRN)) {
    +			$networkname = format_network_name($a->data['contact']['network'],$a->data['contact']['url']);
    +		} else {
    +			$networkname = '';
    +		}
     
    -			$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"),array(
    -				'$name' => htmlentities($a->data['contact']['name']),
    -				'$photo' => $a->data['contact']['photo'],
    -				'$url' => ($a->data['contact']['network'] == NETWORK_DFRN) ? "redir/".$a->data['contact']['id'] : $a->data['contact']['url'],
    -				'$addr' => (($a->data['contact']['addr'] != "") ? ($a->data['contact']['addr']) : ""),
    -				'$network_name' => $networkname,
    -				'$network' => t('Network:'),
    -				'$account_type' => account_type($a->data['contact'])
    -			));
    -			$finpeople_widget = '';
    -			$follow_widget = '';
    -			$networks_widget = '';
    -	}
    -	else {
    +		/// @TODO Add nice spaces
    +		$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"),array(
    +			'$name' => htmlentities($a->data['contact']['name']),
    +			'$photo' => $a->data['contact']['photo'],
    +			'$url' => ($a->data['contact']['network'] == NETWORK_DFRN) ? "redir/".$a->data['contact']['id'] : $a->data['contact']['url'],
    +			'$addr' => (($a->data['contact']['addr'] != "") ? ($a->data['contact']['addr']) : ""),
    +			'$network_name' => $networkname,
    +			'$network' => t('Network:'),
    +			'$account_type' => account_type($a->data['contact'])
    +		));
    +
    +		$finpeople_widget = '';
    +		$follow_widget = '';
    +		$networks_widget = '';
    +	} else {
     		$vcard_widget = '';
     		$networks_widget .= networks_widget('contacts',$_GET['nets']);
    -		if (isset($_GET['add']))
    +		if (isset($_GET['add'])) {
     			$follow_widget = follow_widget($_GET['add']);
    -		else
    +		} else {
     			$follow_widget = follow_widget();
    +		}
     
     		$findpeople_widget .= findpeople_widget();
     	}
    diff --git a/mod/profile.php b/mod/profile.php
    index 32539758e2..32d3985b7f 100644
    --- a/mod/profile.php
    +++ b/mod/profile.php
    @@ -111,10 +111,8 @@ function profile_content(&$a, $update = 0) {
     	if ($update) {
     		// Ensure we've got a profile owner if updating.
     		$a->profile['profile_uid'] = $update;
    -	} else {
    -		if ($a->profile['profile_uid'] == local_user()) {
    -			nav_set_selected('home');
    -		}
    +	} elseif ($a->profile['profile_uid'] == local_user()) {
    +		nav_set_selected('home');
     	}
     
     	$contact = null;
    @@ -158,12 +156,12 @@ function profile_content(&$a, $update = 0) {
     	}
     
     	if (! $update) {
    -		if (x($_GET,'tab'))
    +		if (x($_GET,'tab')) {
     			$tab = notags(trim($_GET['tab']));
    +		}
     
     		$o.=profile_tabs($a, $is_owner, $a->profile['nickname']);
     
    -
     		if ($tab === 'profile') {
     			$o .= advanced_profile($a);
     			call_hooks('profile_advanced',$o);
    @@ -201,14 +199,12 @@ function profile_content(&$a, $update = 0) {
     
     		$o .= status_editor($a,$x);
     		}
    -
     	}
     
     
     	/**
     	 * Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
     	 */
    -
     	$sql_extra = item_permissions_sql($a->profile['profile_uid'],$remote_contact,$groups);
     
     
    diff --git a/view/theme/quattro/config.php b/view/theme/quattro/config.php
    index 32f71db015..6c80afdc22 100644
    --- a/view/theme/quattro/config.php
    +++ b/view/theme/quattro/config.php
    @@ -33,7 +33,7 @@ function theme_admin(App &$a){
     	$align = get_config('quattro', 'align' );
     	$color = get_config('quattro', 'color' );
     	$tfs = get_config("quattro","tfs");
    -	$pfs = get_config("quattro","pfs");    
    +	$pfs = get_config("quattro","pfs");
     
     	return quattro_form($a,$align, $color, $tfs, $pfs);
     }
    @@ -69,8 +69,8 @@ function quattro_form(App &$a, $align, $color, $tfs, $pfs){
     		'$title'   => t("Theme settings"),
     		'$align'   => array('quattro_align', t('Alignment'), $align, '', array('left'=>t('Left'), 'center'=>t('Center'))),
     		'$color'   => array('quattro_color', t('Color scheme'), $color, '', $colors),
    -        '$pfs'     => array('quattro_pfs', t('Posts font size'), $pfs),
    -        '$tfs'     => array('quattro_tfs',t('Textareas font size'), $tfs),
    +		'$pfs'     => array('quattro_pfs', t('Posts font size'), $pfs),
    +		'$tfs'     => array('quattro_tfs',t('Textareas font size'), $tfs),
     	));
     	return $o;
     }
    
    From d2df464d8c4fe0dab390c3016f651f423bd3b9a4 Mon Sep 17 00:00:00 2001
    From: Roland Haeder 
    Date: Fri, 30 Dec 2016 21:48:09 +0100
    Subject: [PATCH 95/96] added curly braces + fixed indenting according to code
     review by Hypolite
    
    Signed-off-by: Roland Haeder 
    ---
     include/follow.php            | 10 +++-----
     include/items.php             | 11 ++++++---
     mod/contacts.php              | 46 ++++++++++++++++++-----------------
     mod/profile.php               | 12 +++------
     view/theme/quattro/config.php |  6 ++---
     5 files changed, 42 insertions(+), 43 deletions(-)
    
    diff --git a/include/follow.php b/include/follow.php
    index 8d80538e0c..3045191077 100644
    --- a/include/follow.php
    +++ b/include/follow.php
    @@ -110,12 +110,10 @@ function new_contact($uid,$url,$interactive = false) {
     
     			// NOTREACHED
     		}
    -	} else {
    -		if (get_config('system','dfrn_only')) {
    -			$result['message'] = t('This site is not configured to allow communications with other networks.') . EOL;
    -			$result['message'] != t('No compatible communication protocols or feeds were discovered.') . EOL;
    -			return $result;
    -		}
    +	} elseif (get_config('system','dfrn_only')) {
    +		$result['message'] = t('This site is not configured to allow communications with other networks.') . EOL;
    +		$result['message'] != t('No compatible communication protocols or feeds were discovered.') . EOL;
    +		return $result;
     	}
     
     	// This extra param just confuses things, remove it
    diff --git a/include/items.php b/include/items.php
    index 8d95c35529..fa4f3290b1 100644
    --- a/include/items.php
    +++ b/include/items.php
    @@ -955,12 +955,14 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
     
     		$r = q('SELECT * FROM `item` WHERE `id` = %d', intval($current_post));
     		if ((dbm::is_result($r)) && (count($r) == 1)) {
    -			if ($notify)
    +			if ($notify) {
     				call_hooks('post_local_end', $r[0]);
    -			else
    +			} else {
     				call_hooks('post_remote_end', $r[0]);
    -		} else
    +			}
    +		} else {
     			logger('item_store: new item not found in DB, id ' . $current_post);
    +		}
     	}
     
     	if ($arr['parent-uri'] === $arr['uri']) {
    @@ -994,8 +996,9 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
     
     	check_item_notification($current_post, $uid);
     
    -	if ($notify)
    +	if ($notify) {
     		proc_run(PRIORITY_HIGH, "include/notifier.php", $notify_type, $current_post);
    +	}
     
     	return $current_post;
     }
    diff --git a/mod/contacts.php b/mod/contacts.php
    index 26dfe06078..38e0992257 100644
    --- a/mod/contacts.php
    +++ b/mod/contacts.php
    @@ -37,34 +37,36 @@ function contacts_init(App &$a) {
     	}
     
     	if ($contact_id) {
    -			$a->data['contact'] = $r[0];
    +		$a->data['contact'] = $r[0];
     
    -			if (($a->data['contact']['network'] != "") AND ($a->data['contact']['network'] != NETWORK_DFRN)) {
    -				$networkname = format_network_name($a->data['contact']['network'],$a->data['contact']['url']);
    -			} else {
    -				$networkname = '';
    -			}
    +		if (($a->data['contact']['network'] != "") AND ($a->data['contact']['network'] != NETWORK_DFRN)) {
    +			$networkname = format_network_name($a->data['contact']['network'],$a->data['contact']['url']);
    +		} else {
    +			$networkname = '';
    +		}
     
    -			$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"),array(
    -				'$name' => htmlentities($a->data['contact']['name']),
    -				'$photo' => $a->data['contact']['photo'],
    -				'$url' => ($a->data['contact']['network'] == NETWORK_DFRN) ? "redir/".$a->data['contact']['id'] : $a->data['contact']['url'],
    -				'$addr' => (($a->data['contact']['addr'] != "") ? ($a->data['contact']['addr']) : ""),
    -				'$network_name' => $networkname,
    -				'$network' => t('Network:'),
    -				'$account_type' => account_type($a->data['contact'])
    -			));
    -			$finpeople_widget = '';
    -			$follow_widget = '';
    -			$networks_widget = '';
    -	}
    -	else {
    +		/// @TODO Add nice spaces
    +		$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"),array(
    +			'$name' => htmlentities($a->data['contact']['name']),
    +			'$photo' => $a->data['contact']['photo'],
    +			'$url' => ($a->data['contact']['network'] == NETWORK_DFRN) ? "redir/".$a->data['contact']['id'] : $a->data['contact']['url'],
    +			'$addr' => (($a->data['contact']['addr'] != "") ? ($a->data['contact']['addr']) : ""),
    +			'$network_name' => $networkname,
    +			'$network' => t('Network:'),
    +			'$account_type' => account_type($a->data['contact'])
    +		));
    +
    +		$finpeople_widget = '';
    +		$follow_widget = '';
    +		$networks_widget = '';
    +	} else {
     		$vcard_widget = '';
     		$networks_widget .= networks_widget('contacts',$_GET['nets']);
    -		if (isset($_GET['add']))
    +		if (isset($_GET['add'])) {
     			$follow_widget = follow_widget($_GET['add']);
    -		else
    +		} else {
     			$follow_widget = follow_widget();
    +		}
     
     		$findpeople_widget .= findpeople_widget();
     	}
    diff --git a/mod/profile.php b/mod/profile.php
    index 32539758e2..32d3985b7f 100644
    --- a/mod/profile.php
    +++ b/mod/profile.php
    @@ -111,10 +111,8 @@ function profile_content(&$a, $update = 0) {
     	if ($update) {
     		// Ensure we've got a profile owner if updating.
     		$a->profile['profile_uid'] = $update;
    -	} else {
    -		if ($a->profile['profile_uid'] == local_user()) {
    -			nav_set_selected('home');
    -		}
    +	} elseif ($a->profile['profile_uid'] == local_user()) {
    +		nav_set_selected('home');
     	}
     
     	$contact = null;
    @@ -158,12 +156,12 @@ function profile_content(&$a, $update = 0) {
     	}
     
     	if (! $update) {
    -		if (x($_GET,'tab'))
    +		if (x($_GET,'tab')) {
     			$tab = notags(trim($_GET['tab']));
    +		}
     
     		$o.=profile_tabs($a, $is_owner, $a->profile['nickname']);
     
    -
     		if ($tab === 'profile') {
     			$o .= advanced_profile($a);
     			call_hooks('profile_advanced',$o);
    @@ -201,14 +199,12 @@ function profile_content(&$a, $update = 0) {
     
     		$o .= status_editor($a,$x);
     		}
    -
     	}
     
     
     	/**
     	 * Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
     	 */
    -
     	$sql_extra = item_permissions_sql($a->profile['profile_uid'],$remote_contact,$groups);
     
     
    diff --git a/view/theme/quattro/config.php b/view/theme/quattro/config.php
    index 32f71db015..6c80afdc22 100644
    --- a/view/theme/quattro/config.php
    +++ b/view/theme/quattro/config.php
    @@ -33,7 +33,7 @@ function theme_admin(App &$a){
     	$align = get_config('quattro', 'align' );
     	$color = get_config('quattro', 'color' );
     	$tfs = get_config("quattro","tfs");
    -	$pfs = get_config("quattro","pfs");    
    +	$pfs = get_config("quattro","pfs");
     
     	return quattro_form($a,$align, $color, $tfs, $pfs);
     }
    @@ -69,8 +69,8 @@ function quattro_form(App &$a, $align, $color, $tfs, $pfs){
     		'$title'   => t("Theme settings"),
     		'$align'   => array('quattro_align', t('Alignment'), $align, '', array('left'=>t('Left'), 'center'=>t('Center'))),
     		'$color'   => array('quattro_color', t('Color scheme'), $color, '', $colors),
    -        '$pfs'     => array('quattro_pfs', t('Posts font size'), $pfs),
    -        '$tfs'     => array('quattro_tfs',t('Textareas font size'), $tfs),
    +		'$pfs'     => array('quattro_pfs', t('Posts font size'), $pfs),
    +		'$tfs'     => array('quattro_tfs',t('Textareas font size'), $tfs),
     	));
     	return $o;
     }
    
    From 3caf3bccd9f9fe43ab14ea66452a137d25dfbff4 Mon Sep 17 00:00:00 2001
    From: Hypolite Petovan 
    Date: Sat, 7 Jan 2017 23:27:50 +1100
    Subject: [PATCH 96/96] Updated SSL english docs
    
    Fixes #1034
    ---
     doc/SSL.md | 61 ++++++++++++++++++++++++++++++++++++++++--------------
     1 file changed, 46 insertions(+), 15 deletions(-)
    
    diff --git a/doc/SSL.md b/doc/SSL.md
    index 5b3511d306..95de83305f 100644
    --- a/doc/SSL.md
    +++ b/doc/SSL.md
    @@ -3,15 +3,15 @@ Using SSL with Friendica
     
     * [Home](help)
     
    -Disclaimer
    ----
    +## Disclaimer
    +
     **This document has been updated in November 2016.
     SSL encryption is relevant for security.
     This means that recommended settings change fast.
     Keep your setup up to date and do not rely on this document being updated as fast as technologies change!**
     
    -Intro
    ----
    +## Intro
    +
     If you are running your own Friendica site, you may want to use SSL (https) to encrypt communication between servers and between yourself and your server.
     
     There are basically two sorts of SSL certificates: Self-signed certificates and certificates signed by a certificate authority (CA).
    @@ -26,15 +26,13 @@ Normally, you have to pay for them - and they are valid for a limited period of
     
     There are ways to get a trusted certificate for free.
     
    -Chose your domain name
    ----
    +## Choose your domain name
     
     Your SSL certificate will be valid for a domain or even only for a subdomain.
     Make your final decision about your domain resp. subdomain *before* ordering the certificate.
     Once you have it, changing the domain name means getting a new certificate.
     
    -Shared hosts
    ----
    +### Shared hosts
     
     If your Friendica instance is running on a shared hosting platform, you should first check with your hosting provider.
     They have instructions for you on how to do it there.
    @@ -45,8 +43,7 @@ They need the certificate, the key and the CA's intermediate certificate.
     To be sure, send those three files.
     **You should send them to your provider via an encrypted channel!**
     
    -Own server
    ----
    +### Own server
     
     If you run your own server, we recommend to check out the ["Let's Encrypt" initiative](https://letsencrypt.org/).
     Not only do they offer free SSL certificates, but also a way to automate their renewal.
    @@ -54,14 +51,48 @@ You need to install a client software on your server to use it.
     Instructions for the official client are [here](https://certbot.eff.org/).
     Depending on your needs, you might want to look at the [list of alternative letsencrypt clients](https://letsencrypt.org/docs/client-options/).
     
    -
    -Web server settings
    ----
    +## Web server settings
     
     Visit the [Mozilla's wiki](https://wiki.mozilla.org/Security/Server_Side_TLS) for instructions on how to configure a secure webserver.
     They provide recommendations for [different web servers](https://mozilla.github.io/server-side-tls/ssl-config-generator/).
     
    -Test your SSL settings
    ----
    +## Test your SSL settings
     
     When you are done, visit the test site [SSL Labs](https://www.ssllabs.com/ssltest/) to have them check if you succeeded.
    +
    +## Configure Friendica
    +
    +If you can successfully access your Friendica instance through https, there are a number of steps you can take to ensure your users will use SSL to access your instance.
    +
    +### Web server redirection
    +
    +This is the simplest way to enforce site-wide secure access.
    +Every time a user tries to access any Friendica page by any mean (manual address bar entry or link), the web server issues a Permanent Redirect response with the secure protocol prepended to the requested URL.
    +
    +With Apache, simply add the following lines to the [code].htaccess[/code] file in the root folder of your Friendica instance (thanks to [url=https://github.com/AlfredSK]AlfredSK[/url]):
    +
    +[code]
    +#Force SSL connections
    +
    +RewriteEngine On
    +RewriteCond %{SERVER_PORT} 80
    +RewriteRule ^(.*)$ https://your.friendica.domain/$1 [R=301,L]
    +[/code]
    +
    +With nginx, configure your [code]server[/code] directive this way (thanks to [url=https://bjornjohansen.no/redirect-to-https-with-nginx/]Bjørn Johansen[/url]):
    +
    +[code]
    +server {
    +	listen 80;
    +	listen [::]:80;
    +	server_name your.friendica.domain;
    +	return 301 https://$server_name$request_uri;
    +}
    +[/code]
    +
    +### SSL Settings
    +
    +In the Admin Settings, there are three SSL-related settings:
    +- **SSL link policy**: this affects how Friendica generates internal links. If your SSL installation was successful, we recommend "Force all links to SSL" just in case your web server configuration can't be altered like described above.
    +- **Force SSL**: This forces all external links to HTTPS, which may solve Mixed-Content issues, but not all websites support HTTPS yet. Use at your own risk.
    +- **Verify SSL**: Enabling this will prevent Friendica to interact with self-signed SSL sites. We recommend you leave it on as a self-signed SSL certificate can be a vectorfor a man-in-the-middle attack.
    \ No newline at end of file