diff --git a/include/Contact.php b/include/Contact.php index 9fd61f8d5e..de76789e8c 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -5,7 +5,7 @@ // authorisation to do this. function user_remove($uid) { - if(! $uid) + if (! $uid) return; logger('Removing user: ' . $uid); @@ -49,7 +49,7 @@ function user_remove($uid) { // Send an update to the directory proc_run(PRIORITY_LOW, "include/directory.php", $r[0]['url']); - if($uid == local_user()) { + if ($uid == local_user()) { unset($_SESSION['authenticated']); unset($_SESSION['uid']); goaway(App::get_baseurl()); @@ -124,10 +124,10 @@ function terminate_friendship($user,$self,$contact) { function mark_for_death($contact) { - if($contact['archive']) + if ($contact['archive']) return; - if($contact['term-date'] == '0000-00-00 00:00:00') { + if ($contact['term-date'] == '0000-00-00 00:00:00') { q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d", dbesc(datetime_convert()), intval($contact['id']) @@ -151,7 +151,7 @@ function mark_for_death($contact) { /// Check for contact vitality via probing $expiry = $contact['term-date'] . ' + 32 days '; - if(datetime_convert() > datetime_convert('UTC','UTC',$expiry)) { + if (datetime_convert() > datetime_convert('UTC','UTC',$expiry)) { // relationship is really truly dead. // archive them rather than delete @@ -483,7 +483,7 @@ function random_profile() { function contacts_not_grouped($uid,$start = 0,$count = 0) { - if(! $count) { + if (! $count) { $r = q("select count(*) as total from contact where uid = %d and self = 0 and id not in (select distinct(`contact-id`) from group_member where uid = %d) ", intval($uid), intval($uid) @@ -775,18 +775,18 @@ function posts_from_contact_url(App $a, $contact_url) { function formatted_location($profile) { $location = ''; - if($profile['locality']) + if ($profile['locality']) $location .= $profile['locality']; - if($profile['region'] AND ($profile['locality'] != $profile['region'])) { - if($location) + if ($profile['region'] AND ($profile['locality'] != $profile['region'])) { + if ($location) $location .= ', '; $location .= $profile['region']; } - if($profile['country-name']) { - if($location) + if ($profile['country-name']) { + if ($location) $location .= ', '; $location .= $profile['country-name']; @@ -808,7 +808,7 @@ function account_type($contact) { // "page-flags" is a field in the user table, // "forum" and "prv" are used in the contact table. They stand for PAGE_COMMUNITY and PAGE_PRVGROUP. // "community" is used in the gcontact table and is true if the contact is PAGE_COMMUNITY or PAGE_PRVGROUP. - if((isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_COMMUNITY)) + if ((isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_COMMUNITY)) || (isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_PRVGROUP)) || (isset($contact['forum']) && intval($contact['forum'])) || (isset($contact['prv']) && intval($contact['prv'])) diff --git a/include/DirSearch.php b/include/DirSearch.php index 5968608236..da32358c1c 100644 --- a/include/DirSearch.php +++ b/include/DirSearch.php @@ -20,7 +20,7 @@ class DirSearch { */ public static function global_search_by_name($search, $mode = '') { - if($search) { + if ($search) { // check supported networks if (get_config('system','diaspora_enabled')) $diaspora = NETWORK_DIASPORA; @@ -33,10 +33,11 @@ class DirSearch { $ostatus = NETWORK_DFRN; // check if we search only communities or every contact - if($mode === "community") + if ($mode === "community") { $extra_sql = " AND `community`"; - else + } else { $extra_sql = ""; + } $search .= "%"; diff --git a/include/ForumManager.php b/include/ForumManager.php index c2a20df29f..3fae9f3d81 100644 --- a/include/ForumManager.php +++ b/include/ForumManager.php @@ -76,7 +76,7 @@ class ForumManager { */ public static function widget($uid,$cid = 0) { - if(! intval(feature_enabled(local_user(),'forumlist_widget'))) + if (! intval(feature_enabled(local_user(),'forumlist_widget'))) return; $o = ''; @@ -136,7 +136,7 @@ class ForumManager { public static function profile_advanced($uid) { $profile = intval(feature_enabled($uid,'forumlist_profile')); - if(! $profile) + if (! $profile) return; $o = ''; @@ -154,13 +154,17 @@ class ForumManager { foreach($contacts as $contact) { $forumlist .= micropro($contact,false,'forumlist-profile-advanced'); $total_shown ++; - if($total_shown == $show_total) + + if ($total_shown == $show_total) { break; + } } - if(count($contacts) > 0) + if (count($contacts) > 0) { $o .= $forumlist; - return $o; + } + + return $o; } /** diff --git a/include/NotificationsManager.php b/include/NotificationsManager.php index 611860f9d0..c75407993e 100644 --- a/include/NotificationsManager.php +++ b/include/NotificationsManager.php @@ -81,7 +81,7 @@ class NotificationsManager { } $order_sql = implode(", ", $asOrder); - if($limit!="") + if ($limit!="") $limit = " LIMIT ".$limit; $r = q("SELECT * FROM `notify` WHERE `uid` = %d $filter_sql ORDER BY $order_sql $limit", @@ -369,7 +369,7 @@ class NotificationsManager { private function networkTotal($seen = 0) { $sql_seen = ""; - if($seen === 0) + if ($seen === 0) $sql_seen = " AND `item`.`unseen` = 1 "; $r = q("SELECT COUNT(*) AS `total` @@ -406,7 +406,7 @@ class NotificationsManager { $notifs = array(); $sql_seen = ""; - if($seen === 0) + if ($seen === 0) $sql_seen = " AND `item`.`unseen` = 1 "; @@ -445,7 +445,7 @@ class NotificationsManager { private function systemTotal($seen = 0) { $sql_seen = ""; - if($seen === 0) + if ($seen === 0) $sql_seen = " AND `seen` = 0 "; $r = q("SELECT COUNT(*) AS `total` FROM `notify` WHERE `uid` = %d $sql_seen", @@ -478,7 +478,7 @@ class NotificationsManager { $notifs = array(); $sql_seen = ""; - if($seen === 0) + if ($seen === 0) $sql_seen = " AND `seen` = 0 "; $r = q("SELECT `id`, `url`, `photo`, `msg`, `date`, `seen` FROM `notify` @@ -530,7 +530,7 @@ class NotificationsManager { $sql_seen = ""; $sql_extra = $this->_personal_sql_extra(); - if($seen === 0) + if ($seen === 0) $sql_seen = " AND `item`.`unseen` = 1 "; $r = q("SELECT COUNT(*) AS `total` @@ -569,7 +569,7 @@ class NotificationsManager { $notifs = array(); $sql_seen = ""; - if($seen === 0) + if ($seen === 0) $sql_seen = " AND `item`.`unseen` = 1 "; $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, `item`.`unseen`, @@ -608,7 +608,7 @@ class NotificationsManager { private function homeTotal($seen = 0) { $sql_seen = ""; - if($seen === 0) + if ($seen === 0) $sql_seen = " AND `item`.`unseen` = 1 "; $r = q("SELECT COUNT(*) AS `total` FROM `item` @@ -644,7 +644,7 @@ class NotificationsManager { $notifs = array(); $sql_seen = ""; - if($seen === 0) + if ($seen === 0) $sql_seen = " AND `item`.`unseen` = 1 "; $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, `item`.`unseen`, @@ -682,7 +682,7 @@ class NotificationsManager { private function introTotal($all = false) { $sql_extra = ""; - if(!$all) + if (!$all) $sql_extra = " AND `ignore` = 0 "; $r = q("SELECT COUNT(*) AS `total` FROM `intro` @@ -716,7 +716,7 @@ class NotificationsManager { $notifs = array(); $sql_extra = ""; - if(!$all) + if (!$all) $sql_extra = " AND `ignore` = 0 "; /// @todo Fetch contact details by "get_contact_details_by_url" instead of queries to contact, fcontact and gcontact @@ -761,7 +761,7 @@ class NotificationsManager { // We have to distinguish between these two because they use different data. // Contact suggestions - if($it['fid']) { + if ($it['fid']) { $return_addr = bin2hex($this->a->user['nickname'] . '@' . $this->a->get_hostname() . (($this->a->path) ? '/' . $this->a->path : '')); @@ -793,7 +793,7 @@ class NotificationsManager { $it['gnetwork'] = $ret["network"]; // Don't show these data until you are connected. Diaspora is doing the same. - if($it['gnetwork'] === NETWORK_DIASPORA) { + if ($it['gnetwork'] === NETWORK_DIASPORA) { $it['glocation'] = ""; $it['gabout'] = ""; $it['ggender'] = ""; diff --git a/include/Probe.php b/include/Probe.php index 1b6feb107f..ac7fe712f0 100644 --- a/include/Probe.php +++ b/include/Probe.php @@ -564,15 +564,15 @@ class Probe { */ public static function valid_dfrn($data) { $errors = 0; - if(!isset($data['key'])) + if (!isset($data['key'])) $errors ++; - if(!isset($data['dfrn-request'])) + if (!isset($data['dfrn-request'])) $errors ++; - if(!isset($data['dfrn-confirm'])) + if (!isset($data['dfrn-confirm'])) $errors ++; - if(!isset($data['dfrn-notify'])) + if (!isset($data['dfrn-notify'])) $errors ++; - if(!isset($data['dfrn-poll'])) + if (!isset($data['dfrn-poll'])) $errors ++; return $errors; } @@ -1133,15 +1133,17 @@ class Probe { $password = ''; openssl_private_decrypt(hex2bin($r[0]['pass']), $password,$x[0]['prvkey']); $mbox = email_connect($mailbox,$r[0]['user'], $password); - if(!mbox) + if (!$mbox) { return false; + } } $msgs = email_poll($mbox, $uri); logger('searching '.$uri.', '.count($msgs).' messages found.', LOGGER_DEBUG); - if (!count($msgs)) + if (!count($msgs)) { return false; + } $data = array(); @@ -1157,13 +1159,14 @@ class Probe { $data["poll"] = 'email '.random_string(); $x = email_msg_meta($mbox, $msgs[0]); - if(stristr($x[0]->from, $uri)) + if (stristr($x[0]->from, $uri)) { $adr = imap_rfc822_parse_adrlist($x[0]->from, ''); - elseif(stristr($x[0]->to, $uri)) + } elseif (stristr($x[0]->to, $uri)) { $adr = imap_rfc822_parse_adrlist($x[0]->to, ''); - if(isset($adr)) { + } + if (isset($adr)) { foreach($adr as $feadr) { - if((strcasecmp($feadr->mailbox, $data["name"]) == 0) + if ((strcasecmp($feadr->mailbox, $data["name"]) == 0) &&(strcasecmp($feadr->host, $phost) == 0) && (strlen($feadr->personal))) { diff --git a/include/Smilies.php b/include/Smilies.php index d67b92d8b0..fd8ea60af0 100644 --- a/include/Smilies.php +++ b/include/Smilies.php @@ -125,7 +125,7 @@ class Smilies { * @return string HML Output of the Smilie */ public static function replace($s, $sample = false) { - if(intval(get_config('system','no_smilies')) + if (intval(get_config('system','no_smilies')) || (local_user() && intval(get_pconfig(local_user(),'system','no_smilies')))) return $s; @@ -135,7 +135,7 @@ class Smilies { $params = self::get_list(); $params['string'] = $s; - if($sample) { + if ($sample) { $s = '
'; $s = str_replace(array('', '', ''), array($mailquote, $mailquote, $mailquote), $s); @@ -1293,23 +1293,23 @@ function prepare_body(&$item,$attach = false, $preview = false) { $as = ''; $vhead = false; $arr = explode('[/attach],',$item['attach']); - if(count($arr)) { + if (count($arr)) { $as .= ''; foreach($arr as $r) { $matches = false; $icon = ''; $cnt = preg_match_all('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"|',$r,$matches, PREG_SET_ORDER); - if($cnt) { + if ($cnt) { foreach($matches as $mtch) { $mime = $mtch[3]; - if((local_user() == $item['uid']) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == NETWORK_DFRN)) + if ((local_user() == $item['uid']) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == NETWORK_DFRN)) $the_url = 'redir/' . $item['contact-id'] . '?f=1&url=' . $mtch[1]; else $the_url = $mtch[1]; - if(strpos($mime, 'video') !== false) { - if(!$vhead) { + if (strpos($mime, 'video') !== false) { + if (!$vhead) { $vhead = true; $a->page['htmlhead'] .= replace_macros(get_markup_template('videos_head.tpl'), array( '$baseurl' => z_root(), @@ -1331,7 +1331,7 @@ function prepare_body(&$item,$attach = false, $preview = false) { } $filetype = strtolower(substr( $mime, 0, strpos($mime,'/') )); - if($filetype) { + if ($filetype) { $filesubtype = strtolower(substr( $mime, strpos($mime,'/') + 1 )); $filesubtype = str_replace('.', '-', $filesubtype); } @@ -1366,7 +1366,7 @@ function prepare_body(&$item,$attach = false, $preview = false) { $s = $s . $as; // map - if(strpos($s,'') !== false && $item['coord']) { + if (strpos($s,'') !== false && $item['coord']) { $x = generate_map(trim($item['coord'])); if ($x) { $s = preg_replace('/\/','$0' . $x,$s); @@ -1418,7 +1418,7 @@ function prepare_body(&$item,$attach = false, $preview = false) { }} -if(! function_exists('prepare_text')) { +if (! function_exists('prepare_text')) { /** * Given a text string, convert from bbcode to html and add smilie icons. * @@ -1429,7 +1429,7 @@ function prepare_text($text) { require_once('include/bbcode.php'); - if(stristr($text,'[nosmile]')) + if (stristr($text,'[nosmile]')) $s = bbcode($text); else $s = Smilies::replace(bbcode($text)); @@ -1474,7 +1474,7 @@ function get_cats_and_terms($item) { $matches = false; $first = true; $cnt = preg_match_all('/<(.*?)>/',$item['file'],$matches,PREG_SET_ORDER); - if($cnt) { + if ($cnt) { foreach($matches as $mtch) { $categories[] = array( 'name' => xmlify(file_tag_decode($mtch[1])), @@ -1489,10 +1489,10 @@ function get_cats_and_terms($item) { if (count($categories)) $categories[count($categories)-1]['last'] = true; - if(local_user() == $item['uid']) { + if (local_user() == $item['uid']) { $matches = false; $first = true; $cnt = preg_match_all('/\[(.*?)\]/',$item['file'],$matches,PREG_SET_ORDER); - if($cnt) { + if ($cnt) { foreach($matches as $mtch) { $folders[] = array( 'name' => xmlify(file_tag_decode($mtch[1])), @@ -1511,7 +1511,7 @@ function get_cats_and_terms($item) { return array($categories, $folders); } -if(! function_exists('get_plink')) { +if (! function_exists('get_plink')) { /** * get private link for item * @param array $item @@ -1548,7 +1548,7 @@ function get_plink($item) { return($ret); }} -if(! function_exists('unamp')) { +if (! function_exists('unamp')) { /** * replace html amp entity with amp char * @param string $s @@ -1559,7 +1559,7 @@ function unamp($s) { }} -if(! function_exists('return_bytes')) { +if (! function_exists('return_bytes')) { /** * return number of bytes in size (K, M, G) * @param string $size_str @@ -1584,7 +1584,7 @@ function generate_user_guid() { $x = q("SELECT `uid` FROM `user` WHERE `guid` = '%s' LIMIT 1", dbesc($guid) ); - if(! count($x)) + if (! count($x)) $found = false; } while ($found == true ); return $guid; @@ -1600,7 +1600,7 @@ function base64url_encode($s, $strip_padding = false) { $s = strtr(base64_encode($s),'+/','-_'); - if($strip_padding) + if ($strip_padding) $s = str_replace('=','',$s); return $s; @@ -1612,7 +1612,7 @@ function base64url_encode($s, $strip_padding = false) { */ function base64url_decode($s) { - if(is_array($s)) { + if (is_array($s)) { logger('base64url_decode: illegal input: ' . print_r(debug_backtrace(), true)); return $s; } @@ -1623,11 +1623,11 @@ function base64url_decode($s) { * // Uncomment if you find you need it. * * $l = strlen($s); - * if(! strpos($s,'=')) { + * if (! strpos($s,'=')) { * $m = $l % 4; - * if($m == 2) + * if ($m == 2) * $s .= '=='; - * if($m == 3) + * if ($m == 3) * $s .= '='; * } * @@ -1720,9 +1720,9 @@ function bb_translate_video($s) { $r = preg_match_all("/\[video\](.*?)\[\/video\]/ism",$s,$matches,PREG_SET_ORDER); if ($r) { foreach($matches as $mtch) { - if((stristr($mtch[1],'youtube')) || (stristr($mtch[1],'youtu.be'))) + if ((stristr($mtch[1],'youtube')) || (stristr($mtch[1],'youtu.be'))) $s = str_replace($mtch[0],'[youtube]' . $mtch[1] . '[/youtube]',$s); - elseif(stristr($mtch[1],'vimeo')) + elseif (stristr($mtch[1],'vimeo')) $s = str_replace($mtch[0],'[vimeo]' . $mtch[1] . '[/vimeo]',$s); } } @@ -1800,13 +1800,13 @@ function reltoabs($text, $base) { * @return string */ function item_post_type($item) { - if(intval($item['event-id'])) + if (intval($item['event-id'])) return t('event'); - if(strlen($item['resource-id'])) + if (strlen($item['resource-id'])) return t('photo'); - if(strlen($item['verb']) && $item['verb'] !== ACTIVITY_POST) + if (strlen($item['verb']) && $item['verb'] !== ACTIVITY_POST) return t('activity'); - if($item['id'] != $item['parent']) + if ($item['id'] != $item['parent']) return t('comment'); return t('post'); } @@ -1826,7 +1826,7 @@ function file_tag_decode($s) { function file_tag_file_query($table,$s,$type = 'file') { - if($type == 'file') + if ($type == 'file') $str = preg_quote( '[' . str_replace('%','%%',file_tag_encode($s)) . ']' ); else $str = preg_quote( '<' . str_replace('%','%%',file_tag_encode($s)) . '>' ); @@ -1836,9 +1836,9 @@ function file_tag_file_query($table,$s,$type = 'file') { // ex. given music,video return