From: Roland Häder Date: Thu, 26 Jan 2017 15:07:30 +0000 (+0100) Subject: more spaces + some curly spaces added X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=951006dd10628151c8f108f82c3260f13846e557;p=friendica.git more spaces + some curly spaces added Signed-off-by: Roland Häder --- diff --git a/include/ForumManager.php b/include/ForumManager.php index 3fae9f3d81..47a4d55a47 100644 --- a/include/ForumManager.php +++ b/include/ForumManager.php @@ -50,7 +50,7 @@ class ForumManager { if (!$contacts) return($forumlist); - foreach($contacts as $contact) { + foreach ($contacts as $contact) { $forumlist[] = array( 'url' => $contact['url'], 'name' => $contact['name'], @@ -92,7 +92,7 @@ class ForumManager { $id = 0; - foreach($contacts as $contact) { + foreach ($contacts as $contact) { $selected = (($cid == $contact['id']) ? ' forum-selected' : ''); @@ -151,7 +151,7 @@ class ForumManager { $total_shown = 0; - foreach($contacts as $contact) { + foreach ($contacts as $contact) { $forumlist .= micropro($contact,false,'forumlist-profile-advanced'); $total_shown ++; diff --git a/include/NotificationsManager.php b/include/NotificationsManager.php index c75407993e..bd2236a5aa 100644 --- a/include/NotificationsManager.php +++ b/include/NotificationsManager.php @@ -33,7 +33,7 @@ class NotificationsManager { */ private function _set_extra($notes) { $rets = array(); - foreach($notes as $n) { + foreach ($notes as $n) { $local_time = datetime_convert('UTC',date_default_timezone_get(),$n['date']); $n['timestamp'] = strtotime($local_time); $n['date_rel'] = relative_date($n['date']); @@ -58,7 +58,7 @@ class NotificationsManager { public function getAll($filter = array(), $order="-date", $limit="") { $filter_str = array(); $filter_sql = ""; - foreach($filter as $column => $value) { + foreach ($filter as $column => $value) { $filter_str[] = sprintf("`%s` = '%s'", $column, dbesc($value)); } if (count($filter_str)>0) { @@ -67,7 +67,7 @@ class NotificationsManager { $aOrder = explode(" ", $order); $asOrder = array(); - foreach($aOrder as $o) { + foreach ($aOrder as $o) { $dir = "asc"; if ($o[0]==="-") { $dir = "desc"; @@ -756,7 +756,7 @@ class NotificationsManager { private function formatIntros($intros) { $knowyou = ''; - foreach($intros as $it) { + foreach ($intros as $it) { // There are two kind of introduction. Contacts suggested by other contacts and normal connection requests. // We have to distinguish between these two because they use different data. diff --git a/include/Probe.php b/include/Probe.php index ac7fe712f0..10a0ce2358 100644 --- a/include/Probe.php +++ b/include/Probe.php @@ -858,7 +858,7 @@ class Probe { $data = array(); if (is_array($webfinger["aliases"])) - foreach($webfinger["aliases"] AS $alias) + foreach ($webfinger["aliases"] AS $alias) if (strstr($alias, "@")) $data["addr"] = str_replace('acct:', '', $alias); @@ -1165,18 +1165,20 @@ class Probe { $adr = imap_rfc822_parse_adrlist($x[0]->to, ''); } if (isset($adr)) { - foreach($adr as $feadr) { + foreach ($adr as $feadr) { if ((strcasecmp($feadr->mailbox, $data["name"]) == 0) &&(strcasecmp($feadr->host, $phost) == 0) && (strlen($feadr->personal))) { $personal = imap_mime_header_decode($feadr->personal); $data["name"] = ""; - foreach($personal as $perspart) - if ($perspart->charset != "default") + foreach ($personal as $perspart) { + if ($perspart->charset != "default") { $data["name"] .= iconv($perspart->charset, 'UTF-8//IGNORE', $perspart->text); - else + } else { $data["name"] .= $perspart->text; + } + } $data["name"] = notags($data["name"]); } diff --git a/include/Smilies.php b/include/Smilies.php index fd8ea60af0..74d87d1bd0 100644 --- a/include/Smilies.php +++ b/include/Smilies.php @@ -137,7 +137,7 @@ class Smilies { if ($sample) { $s = '
'; - for($x = 0; $x < count($params['texts']); $x ++) { + for ($x = 0; $x < count($params['texts']); $x ++) { $s .= '
' . $params['texts'][$x] . '
' . $params['icons'][$x] . '
'; } } @@ -174,7 +174,7 @@ class Smilies { return $x[0]; } $t = ''; - for($cnt = 0; $cnt < strlen($x[1]); $cnt ++) { + for ($cnt = 0; $cnt < strlen($x[1]); $cnt ++) { $t .= '<3'; } $r = str_replace($x[0],$t,$x[0]); diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 5eb54edf31..dc21a1e179 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -121,8 +121,9 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { $sql_extra .= sprintf(" AND `id` != %d ", intval($x['exclude'])); if (is_array($x['networks']) && count($x['networks'])) { - for($y = 0; $y < count($x['networks']) ; $y ++) + for ($y = 0; $y < count($x['networks']) ; $y ++) { $x['networks'][$y] = "'" . dbesc($x['networks'][$y]) . "'"; + } $str_nets = implode(',',$x['networks']); $sql_extra .= " AND `network` IN ( $str_nets ) "; } @@ -380,7 +381,7 @@ function construct_acl_data(App $a, $user) { $user_defaults = get_acl_permissions($user); if ($acl_data['groups']) { - foreach($acl_data['groups'] as $key=>$group) { + foreach ($acl_data['groups'] as $key=>$group) { // Add a "selected" flag to groups that are posted to by default if ($user_defaults['allow_gid'] && in_array($group['id'], $user_defaults['allow_gid']) && !in_array($group['id'], $user_defaults['deny_gid']) ) @@ -390,7 +391,7 @@ function construct_acl_data(App $a, $user) { } } if ($acl_data['contacts']) { - foreach($acl_data['contacts'] as $key=>$contact) { + foreach ($acl_data['contacts'] as $key=>$contact) { // Add a "selected" flag to groups that are posted to by default if ($user_defaults['allow_cid'] && in_array($contact['id'], $user_defaults['allow_cid']) && !in_array($contact['id'], $user_defaults['deny_cid']) ) @@ -510,7 +511,7 @@ function acl_lookup(App $a, $out_type = 'json') { intval($count) ); - foreach($r as $g){ + foreach ($r as $g){ // logger('acl: group: ' . $g['name'] . ' members: ' . $g['uids']); $groups[] = array( "type" => "g", diff --git a/include/api.php b/include/api.php index 66703bd6ca..78cf5f6805 100644 --- a/include/api.php +++ b/include/api.php @@ -334,7 +334,7 @@ use \Friendica\Core\Config; break; case "json": header ("Content-Type: application/json"); - foreach($r as $rr) + foreach ($r as $rr) $json = json_encode($rr); if ($_GET['callback']) $json = $_GET['callback']."(".$json.")"; @@ -2469,7 +2469,7 @@ use \Friendica\Core\Config; $ret = Array(); - foreach($r as $item) { + foreach ($r as $item) { localize_item($item); list($status_user, $owner_user) = api_item_get_user($a,$item); @@ -2655,7 +2655,7 @@ use \Friendica\Core\Config; ); $ret = array(); - foreach($r as $cid){ + foreach ($r as $cid){ $user = api_get_user($a, $cid['nurl']); // "uid" and "self" are only needed for some internal stuff, so remove it from here unset($user["uid"]); @@ -2761,7 +2761,7 @@ use \Friendica\Core\Config; return; $ids = array(); - foreach($r as $rr) + foreach ($r as $rr) if ($stringify_ids) $ids[] = $rr['id']; else @@ -2985,7 +2985,7 @@ use \Friendica\Core\Config; } $ret = Array(); - foreach($r as $item) { + foreach ($r as $item) { if ($box == "inbox" || $item['from-url'] != $profile_url){ $recipient = $user_info; $sender = api_get_user($a,normalise_link($item['contact-url'])); @@ -3927,7 +3927,7 @@ use \Friendica\Core\Config; $success = array('success' => false, 'search_results' => 'nothing found'); else { $ret = Array(); - foreach($r as $item) { + foreach ($r as $item) { if ($box == "inbox" || $item['from-url'] != $profile_url){ $recipient = $user_info; $sender = api_get_user($a,normalise_link($item['contact-url'])); diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index eaf418510b..ce03084799 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -141,7 +141,7 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) { // Add all tags that maybe were removed if (preg_match_all("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",$OriginalText, $tags)) { $tagline = ""; - foreach($tags[2] as $tag) { + foreach ($tags[2] as $tag) { $tag = html_entity_decode($tag, ENT_QUOTES, 'UTF-8'); if (!strpos(html_entity_decode($Text, ENT_QUOTES, 'UTF-8'), "#".$tag)) $tagline .= "#".$tag." "; diff --git a/include/bbcode.php b/include/bbcode.php index 46daaae93f..948ffadaca 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -206,10 +206,10 @@ function bb_spacefy($st) { // returning [i]italic[/i] function bb_unspacefy_and_trim($st) { - $whole_match = $st[0]; - $captured = $st[1]; - $unspacefied = preg_replace("/\[ (.*?)\ ]/", "[$1]", $captured); - return $unspacefied; + $whole_match = $st[0]; + $captured = $st[1]; + $unspacefied = preg_replace("/\[ (.*?)\ ]/", "[$1]", $captured); + return $unspacefied; } function bb_find_open_close($s, $open, $close, $occurance = 1) { @@ -218,18 +218,21 @@ function bb_find_open_close($s, $open, $close, $occurance = 1) { $occurance = 1; $start_pos = -1; - for($i = 1; $i <= $occurance; $i++) { - if ( $start_pos !== false) + for ($i = 1; $i <= $occurance; $i++) { + if ( $start_pos !== false) { $start_pos = strpos($s, $open, $start_pos + 1); + } } - if ( $start_pos === false) + if ( $start_pos === false) { return false; + } $end_pos = strpos($s, $close, $start_pos); - if ( $end_pos === false) + if ( $end_pos === false) { return false; + } $res = array( 'start' => $start_pos, 'end' => $end_pos ); @@ -242,9 +245,10 @@ function get_bb_tag_pos($s, $name, $occurance = 1) { $occurance = 1; $start_open = -1; - for($i = 1; $i <= $occurance; $i++) { - if ( $start_open !== false) + for ($i = 1; $i <= $occurance; $i++) { + if ( $start_open !== false) { $start_open = strpos($s, '[' . $name, $start_open + 1); // allow [name= type tags + } } if ( $start_open === false) diff --git a/include/contact_selectors.php b/include/contact_selectors.php index 62d79d877a..bf2523e845 100644 --- a/include/contact_selectors.php +++ b/include/contact_selectors.php @@ -37,7 +37,7 @@ function contact_reputation($current) { 5 => t('Reputable, has my trust') ); - foreach($rep as $k => $v) { + foreach ($rep as $k => $v) { $selected = (($k == $current) ? " selected=\"selected\" " : ""); $o .= "\r\n"; } @@ -61,7 +61,7 @@ function contact_poll_interval($current, $disabled = false) { 5 => t('Monthly') ); - foreach($rep as $k => $v) { + foreach ($rep as $k => $v) { $selected = (($k == $current) ? " selected=\"selected\" " : ""); $o .= "\r\n"; } diff --git a/include/contact_widgets.php b/include/contact_widgets.php index 0f6f46ef6d..7a5fd6f5f6 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -140,7 +140,7 @@ function fileas_widget($baseurl,$selected = '') { $terms = array(); $cnt = preg_match_all('/\[(.*?)\]/',$saved,$matches,PREG_SET_ORDER); if ($cnt) { - foreach($matches as $mtch) { + foreach ($matches as $mtch) { $unescaped = xmlify(file_tag_decode($mtch[1])); $terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? 'selected' : '')); } @@ -174,7 +174,7 @@ function categories_widget($baseurl,$selected = '') { $terms = array(); $cnt = preg_match_all('/<(.*?)>/',$saved,$matches,PREG_SET_ORDER); if ($cnt) { - foreach($matches as $mtch) { + foreach ($matches as $mtch) { $unescaped = xmlify(file_tag_decode($mtch[1])); $terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? 'selected' : '')); } @@ -201,7 +201,7 @@ function common_friends_visitor_widget($profile_uid) { $cid = $zcid = 0; if (is_array($_SESSION['remote'])) { - foreach($_SESSION['remote'] as $visitor) { + foreach ($_SESSION['remote'] as $visitor) { if ($visitor['uid'] == $profile_uid) { $cid = $visitor['cid']; break; diff --git a/include/conversation.php b/include/conversation.php index 424f60bb49..d29b434504 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -308,7 +308,7 @@ function localize_item(&$item){ } $matches = null; if (preg_match_all('/@\[url=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) { - foreach($matches as $mtch) { + foreach ($matches as $mtch) { if (! strpos($mtch[1],'zrl=')) $item['body'] = str_replace($mtch[0],'@[url=' . zrl($mtch[1]). ']',$item['body']); } @@ -344,7 +344,7 @@ function count_descendants($item) { $total = count($item['children']); if ($total > 0) { - foreach($item['children'] as $child) { + foreach ($item['children'] as $child) { if (! visible_activity($child)) $total --; $total += count_descendants($child); @@ -360,7 +360,7 @@ function visible_activity($item) { // in which case we handle them specially $hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE); - foreach($hidden_activities as $act) { + foreach ($hidden_activities as $act) { if (activity_match($item['verb'],$act)) { return false; } @@ -484,8 +484,9 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { $str_blocked = get_pconfig(local_user(),'system','blocked'); if ($str_blocked) { $arr_blocked = explode(',',$str_blocked); - for($x = 0; $x < count($arr_blocked); $x ++) + for ($x = 0; $x < count($arr_blocked); $x ++) { $arr_blocked[$x] = trim($arr_blocked[$x]); + } } } @@ -604,11 +605,11 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { // $tpl = get_markup_template('search_item.tpl'); $tpl = 'search_item.tpl'; - foreach($items as $item) { + foreach ($items as $item) { if ($arr_blocked) { $blocked = false; - foreach($arr_blocked as $b) { + foreach ($arr_blocked as $b) { if ($b && link_compare($item['author-link'],$b)) { $blocked = true; break; @@ -652,7 +653,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { $taglist = q("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d) ORDER BY `tid`", intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION)); - foreach($taglist as $tag) { + foreach ($taglist as $tag) { if ($tag["url"] == "") $tag["url"] = $searchpath.strtolower($tag["term"]); @@ -818,11 +819,11 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { // But for now, this array respects the old style, just in case $threads = array(); - foreach($items as $item) { + foreach ($items as $item) { if ($arr_blocked) { $blocked = false; - foreach($arr_blocked as $b) { + foreach ($arr_blocked as $b) { if ($b && link_compare($item['author-link'],$b)) { $blocked = true; @@ -1014,7 +1015,7 @@ function item_photo_menu($item) */ if (! function_exists('builtin_activity_puller')) { function builtin_activity_puller($item, &$conv_responses) { - foreach($conv_responses as $mode => $v) { + foreach ($conv_responses as $mode => $v) { $url = ''; $sparkle = ''; @@ -1302,7 +1303,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { function get_item_children($arr, $parent) { $children = array(); $a = get_app(); - foreach($arr as $item) { + foreach ($arr as $item) { if ($item['id'] != $item['parent']) { if (get_config('system','thread_allow') && $a->theme_thread_allow) { // Fallback to parent-uri if thr-parent is not set @@ -1326,7 +1327,7 @@ function get_item_children($arr, $parent) { function sort_item_children($items) { $result = $items; usort($result,'sort_thr_created_rev'); - foreach($result as $k => $i) { + foreach ($result as $k => $i) { if (count($result[$k]['children'])) { $result[$k]['children'] = sort_item_children($result[$k]['children']); } @@ -1335,7 +1336,7 @@ function sort_item_children($items) { } function add_children_to_list($children, &$arr) { - foreach($children as $y) { + foreach ($children as $y) { $arr[] = $y; if (count($y['children'])) add_children_to_list($y['children'], $arr); @@ -1353,13 +1354,13 @@ function conv_sort($arr,$order) { // This is a preparation for having two different items with the same uri in one thread // This will otherwise lead to an endless loop. - foreach($arr as $x) + foreach ($arr as $x) if (!isset($newarr[$x['uri']])) $newarr[$x['uri']] = $x; $arr = $newarr; - foreach($arr as $x) + foreach ($arr as $x) if ($x['id'] == $x['parent']) $parents[] = $x; @@ -1369,10 +1370,10 @@ function conv_sort($arr,$order) { usort($parents,'sort_thr_commented'); if (count($parents)) - foreach($parents as $i=>$_x) + foreach ($parents as $i=>$_x) $parents[$i]['children'] = get_item_children($arr, $_x); - /*foreach($arr as $x) { + /*foreach ($arr as $x) { if ($x['id'] != $x['parent']) { $p = find_thread_parent_index($parents,$x); if ($p !== false) @@ -1380,7 +1381,7 @@ function conv_sort($arr,$order) { } }*/ if (count($parents)) { - foreach($parents as $k => $v) { + foreach ($parents as $k => $v) { if (count($parents[$k]['children'])) { $parents[$k]['children'] = sort_item_children($parents[$k]['children']); /*$y = $parents[$k]['children']; @@ -1392,11 +1393,11 @@ function conv_sort($arr,$order) { $ret = array(); if (count($parents)) { - foreach($parents as $x) { + foreach ($parents as $x) { $ret[] = $x; if (count($x['children'])) add_children_to_list($x['children'], $ret); - /*foreach($x['children'] as $y) + /*foreach ($x['children'] as $y) $ret[] = $y;*/ } } @@ -1418,7 +1419,7 @@ function sort_thr_commented($a,$b) { } function find_thread_parent_index($arr,$x) { - foreach($arr as $k => $v) { + foreach ($arr as $k => $v) { if ($v['id'] == $x['parent']) { return $k; } @@ -1436,7 +1437,7 @@ function render_location_dummy($item) { function get_responses($conv_responses,$response_verbs,$ob,$item) { $ret = array(); - foreach($response_verbs as $v) { + foreach ($response_verbs as $v) { $ret[$v] = array(); $ret[$v]['count'] = ((x($conv_responses[$v],$item['uri'])) ? $conv_responses[$v][$item['uri']] : ''); $ret[$v]['list'] = ((x($conv_responses[$v],$item['uri'])) ? $conv_responses[$v][$item['uri'] . '-l'] : ''); @@ -1453,9 +1454,10 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) { } $count = 0; - foreach($ret as $key) { - if ($key['count'] == true) + foreach ($ret as $key) { + if ($key['count'] == true) { $count++; + } } $ret['count'] = $count; diff --git a/include/cron.php b/include/cron.php index 552121746d..1c47c94992 100644 --- a/include/cron.php +++ b/include/cron.php @@ -126,7 +126,7 @@ function cron_expire_and_remove_users() { // delete user and contact records for recently removed accounts $r = q("SELECT * FROM `user` WHERE `account_removed` AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 3 DAY"); if ($r) { - foreach($r as $user) { + foreach ($r as $user) { q("DELETE FROM `contact` WHERE `uid` = %d", intval($user['uid'])); q("DELETE FROM `user` WHERE `uid` = %d", intval($user['uid'])); } @@ -210,7 +210,7 @@ function cron_poll_contacts($argc, $argv) { continue; } - foreach($res as $contact) { + foreach ($res as $contact) { $xml = false; @@ -343,7 +343,7 @@ function cron_clear_cache(App $a) { // Optimize some tables that need to be optimized $r = q("SHOW TABLE STATUS"); - foreach($r as $table) { + foreach ($r as $table) { // Don't optimize tables that are too large if ($table["Data_length"] > $max_tablesize) { diff --git a/include/crypto.php b/include/crypto.php index 5eb0bc6e19..7c931107c2 100644 --- a/include/crypto.php +++ b/include/crypto.php @@ -191,7 +191,7 @@ if (! function_exists('aes_decrypt')) { function aes_decrypt($val,$ky) { $key="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; - for($a=0;$a 1) { if ($ex[0] != $continent) { @@ -48,12 +48,12 @@ function select_timezone($current = 'America/Los_Angeles') { $continent = $ex[0]; $o .= ''; } - if (count($ex) > 2) + if (count($ex) > 2) { $city = substr($value,strpos($value,'/')+1); - else + } else { $city = $ex[1]; - } - else { + } + } else { $city = $ex[0]; if ($continent != t('Miscellaneous')) { $o .= ''; @@ -507,7 +507,7 @@ function cal($y = 0,$m = 0, $links = false, $class='') { $str_month = day_translate($mtab[$m]); $o = ''; $o .= ""; - for($a = 0; $a < 7; $a ++) { + for ($a = 0; $a < 7; $a ++) { $o .= ''; } diff --git a/include/dbstructure.php b/include/dbstructure.php index 10db66bd6c..7a2a80b285 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -398,7 +398,7 @@ function db_create_table($name, $fields, $charset, $verbose, $action, $indexes=n $sql_rows = array(); $primary_keys = array(); - foreach($fields AS $fieldname => $field) { + foreach ($fields AS $fieldname => $field) { $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field); if (x($field,'primary') and $field['primary']!=''){ $primary_keys[] = $fieldname; @@ -1644,7 +1644,7 @@ function dbstructure_run(&$argv, &$argc) { $current = intval(DB_UPDATE_VERSION); // run any left update_nnnn functions in update.php - for($x = $stored; $x < $current; $x ++) { + for ($x = $stored; $x < $current; $x ++) { $r = run_update_function($x); if (!$r) break; } diff --git a/include/diaspora.php b/include/diaspora.php index 6f189f9c07..12cb9b4361 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -45,7 +45,7 @@ class Diaspora { $servers = explode(",", $serverdata); - foreach($servers AS $server) { + foreach ($servers AS $server) { $server = trim($server); $addr = "relay@".str_replace("http://", "", normalise_link($server)); $batch = $server."/receive/public"; @@ -1507,7 +1507,7 @@ class Diaspora { return; } - foreach($messages as $mesg) + foreach ($messages as $mesg) self::receive_conversation_message($importer, $contact, $data, $msg, $mesg, $conversation); return true; @@ -3094,7 +3094,7 @@ class Diaspora { $cnt = preg_match_all('/href=\"(.*?)\"(.*?)title=\"(.*?)\"/ism', $item["attach"], $matches, PREG_SET_ORDER); if (cnt) { $body .= "\n".t("Attachments:")."\n"; - foreach($matches as $mtch) + foreach ($matches as $mtch) $body .= "[".$mtch[3]."](".$mtch[1].")\n"; } } @@ -3587,7 +3587,7 @@ class Diaspora { $kw = str_replace(' ',' ',$kw); $arr = explode(' ',$profile['pub_keywords']); if (count($arr)) { - for($x = 0; $x < 5; $x ++) { + for ($x = 0; $x < 5; $x ++) { if (trim($arr[$x])) $tags .= '#'. trim($arr[$x]) .' '; } @@ -3609,7 +3609,7 @@ class Diaspora { "searchable" => $searchable, "tag_string" => $tags); - foreach($recips as $recip) { + foreach ($recips as $recip) { logger("Send updated profile data for user ".$uid." to contact ".$recip["id"], LOGGER_DEBUG); self::build_and_transmit($profile, $recip, "profile", $message, false, "", true); } diff --git a/include/discover_poco.php b/include/discover_poco.php index c13f898944..e0838ee2cc 100644 --- a/include/discover_poco.php +++ b/include/discover_poco.php @@ -230,12 +230,14 @@ function gs_search_user($search) { if (!$result["success"]) { return false; } + $contacts = json_decode($result["body"]); if ($contacts->status == 'ERROR') { return false; } - foreach($contacts->data AS $user) { + + foreach ($contacts->data AS $user) { $contact = probe_url($user->site_address."/".$user->name); if ($contact["network"] != NETWORK_PHANTOM) { $contact["about"] = $user->description; diff --git a/include/email.php b/include/email.php index ffd93bc256..b8d99433e1 100644 --- a/include/email.php +++ b/include/email.php @@ -58,7 +58,7 @@ function email_msg_headers($mbox,$uid) { $ret = array(); $h = explode("\n",$raw_header); if (count($h)) - foreach($h as $line ) { + foreach ($h as $line ) { if (preg_match("/^[a-zA-Z]/", $line)) { $key = substr($line,0,strpos($line,':')); $value = substr($line,strpos($line,':')+1); @@ -94,7 +94,7 @@ function email_get_msg($mbox,$uid, $reply) { else { $text = ''; $html = ''; - foreach($struc->parts as $ptop => $p) { + foreach ($struc->parts as $ptop => $p) { $x = email_get_part($mbox,$uid,$p,$ptop + 1, 'plain'); if ($x) { $text .= $x; @@ -206,10 +206,10 @@ function email_get_part($mbox,$uid,$p,$partno, $subtype) { function email_header_encode($in_str, $charset) { - $out_str = $in_str; + $out_str = $in_str; $need_to_convert = false; - for($x = 0; $x < strlen($in_str); $x ++) { + for ($x = 0; $x < strlen($in_str); $x ++) { if ((ord($in_str[$x]) == 0) || ((ord($in_str[$x]) > 128))) { $need_to_convert = true; } diff --git a/include/event.php b/include/event.php index 1aa3abb2f3..44261b3691 100644 --- a/include/event.php +++ b/include/event.php @@ -97,10 +97,10 @@ function parse_event($h) { $items = $dom->getElementsByTagName('*'); - foreach($items as $item) { + foreach ($items as $item) { if (attribute_contains($item->getAttribute('class'), 'vevent')) { $level2 = $item->getElementsByTagName('*'); - foreach($level2 as $x) { + foreach ($level2 as $x) { if (attribute_contains($x->getAttribute('class'),'dtstart') && $x->getAttribute('title')) { $ret['start'] = $x->getAttribute('title'); if (! strpos($ret['start'],'Z')) @@ -595,7 +595,7 @@ function process_events($arr) { $last_date = ''; $fmt = t('l, F j'); if (count($arr)) { - foreach($arr as $rr) { + foreach ($arr as $rr) { $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j')); $d = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], $fmt) : datetime_convert('UTC','UTC',$rr['start'],$fmt)); diff --git a/include/features.php b/include/features.php index c49680cb87..07dcced0e6 100644 --- a/include/features.php +++ b/include/features.php @@ -36,8 +36,8 @@ function feature_enabled($uid, $feature) { */ function get_feature_default($feature) { $f = get_features(); - foreach($f as $cat) { - foreach($cat as $feat) { + foreach ($f as $cat) { + foreach ($cat as $feat) { if (is_array($feat) && $feat[0] === $feature) return $feat[3]; } @@ -117,10 +117,10 @@ function get_features($filtered = true) { // removed any locked features and remove the entire category if this makes it empty if ($filtered) { - foreach($arr as $k => $x) { + foreach ($arr as $k => $x) { $has_items = false; $kquantity = count($arr[$k]); - for($y = 0; $y < $kquantity; $y ++) { + for ($y = 0; $y < $kquantity; $y ++) { if (is_array($arr[$k][$y])) { if ($arr[$k][$y][4] === false) { $has_items = true; diff --git a/include/feed.php b/include/feed.php index 1fb766fcce..317f6bee7d 100644 --- a/include/feed.php +++ b/include/feed.php @@ -280,7 +280,7 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) { $type = ""; $title = ""; - foreach($enclosure->attributes AS $attributes) { + foreach ($enclosure->attributes AS $attributes) { if ($attributes->name == "url") { $href = $attributes->textContent; } elseif ($attributes->name == "length") { diff --git a/include/friendica_smarty.php b/include/friendica_smarty.php index 9a224534e1..f497fbee01 100644 --- a/include/friendica_smarty.php +++ b/include/friendica_smarty.php @@ -71,7 +71,7 @@ class FriendicaSmartyEngine implements ITemplateEngine { call_hooks("template_vars", $arr); $r = $arr['vars']; - foreach($r as $key=>$value) { + foreach ($r as $key=>$value) { if ($key[0] === '$') { $key = substr($key, 1); } diff --git a/include/group.php b/include/group.php index dee0d30c24..fa0e8f59a6 100644 --- a/include/group.php +++ b/include/group.php @@ -318,7 +318,7 @@ function expand_groups($a,$check_dead = false, $use_gcontact = false) { $ret = array(); if (dbm::is_result($r)) - foreach($r as $rr) + foreach ($r as $rr) $ret[] = $rr['contact-id']; if ($check_dead AND !$use_gcontact) { require_once('include/acl_selectors.php'); @@ -347,8 +347,9 @@ function groups_containing($uid,$c) { $ret = array(); if (dbm::is_result($r)) { - foreach($r as $rr) + foreach ($r as $rr) { $ret[] = $rr['gid']; + } } return $ret; diff --git a/include/html2plain.php b/include/html2plain.php index 1d5910d83b..dc2cb137c4 100644 --- a/include/html2plain.php +++ b/include/html2plain.php @@ -49,7 +49,7 @@ function quotelevel($message, $wraplength = 75) $newlines = array(); $level = 0; - foreach($lines as $line) {; + foreach ($lines as $line) {; $line = trim($line); $startquote = false; while (strpos("*".$line, '[quote]') > 0) { diff --git a/include/identity.php b/include/identity.php index a85b78e717..099d8b3acc 100644 --- a/include/identity.php +++ b/include/identity.php @@ -134,7 +134,7 @@ function profile_load(App $a, $nickname, $profile = 0, $profiledata = array()) { */ function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0) { if (remote_user() && count($_SESSION['remote'])) { - foreach($_SESSION['remote'] as $visitor) { + foreach ($_SESSION['remote'] as $visitor) { if ($visitor['uid'] == $uid) { $r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1", intval($visitor['cid']) @@ -220,7 +220,7 @@ function profile_sidebar($profile, $block = 0) { // don't show connect link to authenticated visitors either if (remote_user() && count($_SESSION['remote'])) { - foreach($_SESSION['remote'] as $visitor) { + foreach ($_SESSION['remote'] as $visitor) { if ($visitor['uid'] == $profile['uid']) { $connect = false; break; @@ -390,7 +390,7 @@ function profile_sidebar($profile, $block = 0) { } $p = array(); - foreach($profile as $k => $v) { + foreach ($profile as $k => $v) { $k = str_replace('-','_',$k); $p[$k] = $v; } @@ -486,7 +486,7 @@ function get_birthdays() { } $classtoday = $istoday ? ' birthday-today ' : ''; if ($total) { - foreach($r as &$rr) { + foreach ($r as &$rr) { if (! strlen($rr['name'])) continue; @@ -570,7 +570,7 @@ function get_events() { $skip = 0; - foreach($r as &$rr) { + foreach ($r as &$rr) { $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8')); if (strlen($title) > 35) diff --git a/include/items.php b/include/items.php index 03503f26ac..6f94037011 100644 --- a/include/items.php +++ b/include/items.php @@ -1099,7 +1099,7 @@ function item_body_set_hashtags(&$item) { "#$2", $item["body"]); - foreach($tags as $tag) { + foreach ($tags as $tag) { if (strpos($tag,'#') !== 0) continue; @@ -1170,7 +1170,7 @@ function get_item_id($guid, $uid = 0) { function get_item_contact($item,$contacts) { if (! count($contacts) || (! is_array($item))) return false; - foreach($contacts as $contact) { + foreach ($contacts as $contact) { if ($contact['id'] == $item['contact-id']) { return $contact; break; // NOTREACHED @@ -1224,7 +1224,7 @@ function tag_deliver($uid,$item_id) { $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('tag_deliver: mention found: ' . $mtch[2]); @@ -1810,7 +1810,7 @@ function item_getfeedtags($item) { $matches = false; $cnt = preg_match_all('|\#\[url\=(.*?)\](.*?)\[\/url\]|',$item['tag'],$matches); if ($cnt) { - for($x = 0; $x < $cnt; $x ++) { + for ($x = 0; $x < $cnt; $x ++) { if ($matches[1][$x]) $ret[$matches[2][$x]] = array('#',$matches[1][$x], $matches[2][$x]); } @@ -1818,7 +1818,7 @@ function item_getfeedtags($item) { $matches = false; $cnt = preg_match_all('|\@\[url\=(.*?)\](.*?)\[\/url\]|',$item['tag'],$matches); if ($cnt) { - for($x = 0; $x < $cnt; $x ++) { + for ($x = 0; $x < $cnt; $x ++) { if ($matches[1][$x]) $ret[] = array('@',$matches[1][$x], $matches[2][$x]); } @@ -1876,7 +1876,7 @@ function item_expire($uid, $days, $network = "", $force = false) { logger('expire: # items=' . count($r). "; expire items: $expire_items, expire notes: $expire_notes, expire starred: $expire_starred, expire photos: $expire_photos"); - foreach($r as $item) { + foreach ($r as $item) { // don't expire filed items @@ -1909,7 +1909,7 @@ function drop_items($items) { return; if (count($items)) { - foreach($items as $item) { + foreach ($items as $item) { $owner = drop_item($item,false); if ($owner && ! $uid) $uid = $owner; @@ -1949,7 +1949,7 @@ function drop_item($id,$interactive = true) { // check if logged in user is either the author or owner of this item if (is_array($_SESSION['remote'])) { - foreach($_SESSION['remote'] as $visitor) { + foreach ($_SESSION['remote'] as $visitor) { if ($visitor['uid'] == $item['uid'] && $visitor['cid'] == $item['contact-id']) { $contact_id = $visitor['cid']; break; @@ -1966,7 +1966,7 @@ function drop_item($id,$interactive = true) { // so add any arguments as hidden inputs $query = explode_querystring($a->query_string); $inputs = array(); - foreach($query['args'] as $arg) { + foreach ($query['args'] as $arg) { if (strpos($arg, 'confirm=') === false) { $arg_parts = explode('=', $arg); $inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]); @@ -2005,7 +2005,7 @@ function drop_item($id,$interactive = true) { $matches = false; $cnt = preg_match_all('/<(.*?)>/',$item['file'],$matches,PREG_SET_ORDER); if ($cnt) { - foreach($matches as $mtch) { + foreach ($matches as $mtch) { file_tag_unsave_file($item['uid'],$item['id'],$mtch[1],true); } } @@ -2014,7 +2014,7 @@ function drop_item($id,$interactive = true) { $cnt = preg_match_all('/\[(.*?)\]/',$item['file'],$matches,PREG_SET_ORDER); if ($cnt) { - foreach($matches as $mtch) { + foreach ($matches as $mtch) { file_tag_unsave_file($item['uid'],$item['id'],$mtch[1],false); } } @@ -2044,7 +2044,7 @@ function drop_item($id,$interactive = true) { // If item has attachments, drop them - foreach(explode(",",$item['attach']) as $attach){ + foreach (explode(",",$item['attach']) as $attach){ preg_match("|attach/(\d+)|", $attach, $matches); q("DELETE FROM `attach` WHERE `id` = %d AND `uid` = %d", intval($matches[1]), diff --git a/include/msgclean.php b/include/msgclean.php index 3b5ed5487d..de7dacca29 100644 --- a/include/msgclean.php +++ b/include/msgclean.php @@ -154,7 +154,7 @@ function removelinebreak($message) $lines = array(); $lineno = 0; - foreach($arrbody as $i => $line) { + foreach ($arrbody as $i => $line) { $currquotelevel = 0; $currline = $line; while ((strlen($currline)>0) and ((substr($currline, 0, 1) == '>') diff --git a/include/network.php b/include/network.php index 2ec306472c..5f533ae96e 100644 --- a/include/network.php +++ b/include/network.php @@ -475,7 +475,7 @@ function allowed_url($url) { $allowed = explode(',',$str_allowed); if (count($allowed)) { - foreach($allowed as $a) { + foreach ($allowed as $a) { $pat = strtolower(trim($a)); if (($fnmatch && fnmatch($pat,$host)) || ($pat == $host)) { $found = true; @@ -497,14 +497,15 @@ function allowed_url($url) { */ function allowed_email($email) { - $domain = strtolower(substr($email,strpos($email,'@') + 1)); - if (! $domain) + if (! $domain) { return false; + } $str_allowed = get_config('system','allowed_email'); - if (! $str_allowed) + if (! $str_allowed) { return true; + } $found = false; @@ -512,7 +513,7 @@ function allowed_email($email) { $allowed = explode(',',$str_allowed); if (count($allowed)) { - foreach($allowed as $a) { + foreach ($allowed as $a) { $pat = strtolower(trim($a)); if (($fnmatch && fnmatch($pat,$domain)) || ($pat == $domain)) { $found = true; diff --git a/include/oembed.php b/include/oembed.php index 2490e5ecaa..06c2520d14 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -314,7 +314,7 @@ function oembed_html2bbcode($text) { $entries = $xpath->query("//span[$xattr]"); $xattr = "@rel='oembed'";//oe_build_xpath("rel","oembed"); - foreach($entries as $e) { + foreach ($entries as $e) { $href = $xpath->evaluate("a[$xattr]/@href", $e)->item(0)->nodeValue; if (!is_null($href)) { $e->parentNode->replaceChild(new DOMText("[embed]".$href."[/embed]"), $e); diff --git a/include/onepoll.php b/include/onepoll.php index e6cbd34f45..dfb0db9e37 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -437,16 +437,18 @@ function onepoll_run(&$argv, &$argc){ if ($raw_refs) { $refs_arr = explode(' ', $raw_refs); if (count($refs_arr)) { - for($x = 0; $x < count($refs_arr); $x ++) + for ($x = 0; $x < count($refs_arr); $x ++) { $refs_arr[$x] = "'" . msgid2iri(str_replace(array('<','>',' '),array('','',''),dbesc($refs_arr[$x]))) . "'"; + } } $qstr = implode(',',$refs_arr); $r = q("SELECT `uri` , `parent-uri` FROM `item` USE INDEX (`uid_uri`) WHERE `uri` IN ($qstr) AND `uid` = %d LIMIT 1", intval($importer_uid) ); - if (dbm::is_result($r)) + if (dbm::is_result($r)) { $datarray['parent-uri'] = $r[0]['parent-uri']; // Set the parent as the top-level item - // $datarray['parent-uri'] = $r[0]['uri']; + //$datarray['parent-uri'] = $r[0]['uri']; + } } // Decoding the header diff --git a/include/ostatus.php b/include/ostatus.php index 26be15a020..37f79cb5cc 100644 --- a/include/ostatus.php +++ b/include/ostatus.php @@ -50,7 +50,7 @@ class ostatus { $alternate = $xpath->query("atom:author/atom:link[@rel='alternate']", $context)->item(0)->attributes; if (is_object($alternate)) { - /// @TODO foreach() may only later work on objects that have iterator interface implemented, please check this + /// @TODO foreach () may only later work on objects that have iterator interface implemented, please check this foreach ($alternate AS $attributes) { if ($attributes->name == "href") { $author["author-link"] = $attributes->textContent; diff --git a/include/pgettext.php b/include/pgettext.php index 21d95e3249..79b341c0da 100644 --- a/include/pgettext.php +++ b/include/pgettext.php @@ -106,7 +106,7 @@ function load_translation_table($lang) { // load enabled plugins strings $plugins = q("SELECT name FROM addon WHERE installed=1;"); if ($plugins!==false) { - foreach($plugins as $p) { + foreach ($plugins as $p) { $name = $p['name']; if (file_exists("addon/$name/lang/$lang/strings.php")) { include("addon/$name/lang/$lang/strings.php"); @@ -185,7 +185,7 @@ function get_available_languages() { $strings_file_paths[] = 'view/lang/en/strings.php'; } asort($strings_file_paths); - foreach($strings_file_paths as $strings_file_path) { + foreach ($strings_file_paths as $strings_file_path) { $path_array = explode('/', $strings_file_path); $langs[$path_array[2]] = $path_array[2]; } diff --git a/include/plugin.php b/include/plugin.php index c75441bf9e..c5364822ec 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -87,7 +87,7 @@ function reload_plugins() { $parr = explode(',',$plugins); if (count($parr)) { - foreach($parr as $pl) { + foreach ($parr as $pl) { $pl = trim($pl); @@ -95,7 +95,7 @@ function reload_plugins() { if (file_exists($fname)) { $t = @filemtime($fname); - foreach($installed as $i) { + foreach ($installed as $i) { if (($i['name'] == $pl) && ($i['timestamp'] != $t)) { logger('Reloading plugin: ' . $i['name']); @include_once($fname); @@ -249,7 +249,7 @@ function plugin_is_app($name) { $a = get_app(); if (is_array($a->hooks) && (array_key_exists('app_menu',$a->hooks))) { - foreach($a->hooks['app_menu'] as $hook) { + foreach ($a->hooks['app_menu'] as $hook) { if ($hook[0] == 'addon/'.$name.'/'.$name.'.php') return true; } @@ -297,7 +297,7 @@ function get_plugin_info($plugin){ if ($r){ $ll = explode("\n", $m[0]); - foreach( $ll as $l ) { + foreach ( $ll as $l ) { $l = trim($l,"\t\n\r */"); if ($l!=""){ list($k,$v) = array_map("trim", explode(":",$l,2)); @@ -368,7 +368,7 @@ function get_theme_info($theme){ if ($r){ $ll = explode("\n", $m[0]); - foreach( $ll as $l ) { + foreach ( $ll as $l ) { $l = trim($l,"\t\n\r */"); if ($l!=""){ list($k,$v) = array_map("trim", explode(":",$l,2)); @@ -412,7 +412,7 @@ function get_theme_info($theme){ */ function get_theme_screenshot($theme) { $exts = array('.png','.jpg'); - foreach($exts as $ext) { + foreach ($exts as $ext) { if (file_exists('view/theme/' . $theme . '/screenshot' . $ext)) { return(App::get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext); } @@ -575,7 +575,7 @@ function theme_include($file, $root = '') { "{$root}view/theme/$parent/$ext/$file", "{$root}view/$ext/$file", ); - foreach($paths as $p) { + foreach ($paths as $p) { // strpos() is faster than strstr when checking if one string is in another (http://php.net/manual/en/function.strstr.php) if (strpos($p,'NOPATH') !== false) { continue; diff --git a/include/poller.php b/include/poller.php index b9dadb1fcc..2f9e726110 100644 --- a/include/poller.php +++ b/include/poller.php @@ -364,11 +364,11 @@ function poller_kill_stale_workers() { return; } - foreach($r AS $pid) - if (!posix_kill($pid["pid"], 0)) + foreach ($r AS $pid) + if (!posix_kill($pid["pid"], 0)) { q("UPDATE `workerqueue` SET `executed` = '0000-00-00 00:00:00', `pid` = 0 WHERE `pid` = %d", intval($pid["pid"])); - else { + } else { // Kill long running processes // Check if the priority is in a valid range @@ -396,8 +396,9 @@ function poller_kill_stale_workers() { dbesc(datetime_convert()), intval(PRIORITY_NEGLIGIBLE), intval($pid["pid"])); - } else + } else { logger("Worker process ".$pid["pid"]." (".implode(" ", $argv).") now runs for ".round($duration)." of ".$max_duration." allowed minutes. That's okay.", LOGGER_DEBUG); + } } } diff --git a/include/post_update.php b/include/post_update.php index f9649961d9..45bcb16d3a 100644 --- a/include/post_update.php +++ b/include/post_update.php @@ -68,7 +68,7 @@ function post_update_1192() { } // Set the "gcontact-id" in the item table and add a new gcontact entry if needed - foreach($item_arr AS $item) { + foreach ($item_arr AS $item) { $gcontact_id = get_gcontact_id(array("url" => $item['author-link'], "network" => $item['network'], "photo" => $item['author-avatar'], "name" => $item['author-name'])); q("UPDATE `item` SET `gcontact-id` = %d WHERE `uid` = %d AND `author-link` = '%s' AND `gcontact-id` = 0", @@ -204,7 +204,7 @@ function post_update_1198() { } // Set the "gcontact-id" in the item table and add a new gcontact entry if needed - foreach($item_arr AS $item) { + foreach ($item_arr AS $item) { $author_id = get_contact($item["author-link"], 0); $owner_id = get_contact($item["owner-link"], 0); diff --git a/include/profile_selectors.php b/include/profile_selectors.php index ad47c0ba6c..af6c0d96c4 100644 --- a/include/profile_selectors.php +++ b/include/profile_selectors.php @@ -8,7 +8,7 @@ function gender_selector($current="",$suffix="") { call_hooks('gender_selector', $select); $o .= ""; - foreach($select as $selection) { + foreach ($select as $selection) { if ($selection !== 'NOTRANSLATION') { $selected = (($selection == $current) ? ' selected="selected" ' : ''); $o .= ""; @@ -44,7 +44,7 @@ function marital_selector($current="",$suffix="") { call_hooks('marital_selector', $select); $o .= "
$str_month $y
' . mb_substr(day_translate($dn[$a]),0,3,'UTF-8') . '