more spaces + some curly spaces added

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2017-01-26 16:07:30 +01:00 committed by Roland Haeder
parent 41a36606c6
commit 951006dd10
No known key found for this signature in database
GPG key ID: B72F8185C6C7BD78
42 changed files with 206 additions and 187 deletions

View file

@ -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 ++;

View file

@ -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.

View file

@ -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"]);
}

View file

@ -137,7 +137,7 @@ class Smilies {
if ($sample) {
$s = '<div class="smiley-sample">';
for($x = 0; $x < count($params['texts']); $x ++) {
for ($x = 0; $x < count($params['texts']); $x ++) {
$s .= '<dl><dt>' . $params['texts'][$x] . '</dt><dd>' . $params['icons'][$x] . '</dd></dl>';
}
}
@ -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 .= '<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-heart.gif" alt="&lt;3" />';
}
$r = str_replace($x[0],$t,$x[0]);

View file

@ -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",

View file

@ -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']));

View file

@ -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." ";

View file

@ -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)

View file

@ -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 .= "<option value=\"$k\" $selected >$v</option>\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 .= "<option value=\"$k\" $selected >$v</option>\r\n";
}

View file

@ -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;

View file

@ -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;

View file

@ -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) {

View file

@ -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<strlen($ky);$a++)
for ($a=0;$a<strlen($ky);$a++)
$key[$a%16]=chr(ord($key[$a%16]) ^ ord($ky[$a]));
$mode = MCRYPT_MODE_ECB;
$enc = MCRYPT_RIJNDAEL_128;
@ -205,7 +205,7 @@ if (! function_exists('aes_encrypt')) {
function aes_encrypt($val,$ky)
{
$key="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
for($a=0;$a<strlen($ky);$a++)
for ($a=0;$a<strlen($ky);$a++)
$key[$a%16]=chr(ord($key[$a%16]) ^ ord($ky[$a]));
$mode=MCRYPT_MODE_ECB;
$enc=MCRYPT_RIJNDAEL_128;

View file

@ -39,7 +39,7 @@ function select_timezone($current = 'America/Los_Angeles') {
usort($timezone_identifiers, 'timezone_cmp');
$continent = '';
foreach($timezone_identifiers as $value) {
foreach ($timezone_identifiers as $value) {
$ex = explode("/", $value);
if (count($ex) > 1) {
if ($ex[0] != $continent) {
@ -48,12 +48,12 @@ function select_timezone($current = 'America/Los_Angeles') {
$continent = $ex[0];
$o .= '<optgroup label="' . t($continent) . '">';
}
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 .= '</optgroup>';
@ -507,7 +507,7 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
$str_month = day_translate($mtab[$m]);
$o = '<table class="calendar' . $class . '">';
$o .= "<caption>$str_month $y</caption><tr>";
for($a = 0; $a < 7; $a ++) {
for ($a = 0; $a < 7; $a ++) {
$o .= '<th>' . mb_substr(day_translate($dn[$a]),0,3,'UTF-8') . '</th>';
}

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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;

View file

@ -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;
}

View file

@ -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));

View file

@ -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;

View file

@ -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") {

View file

@ -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);
}

View file

@ -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;

View file

@ -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) {

View file

@ -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)

View file

@ -1099,7 +1099,7 @@ function item_body_set_hashtags(&$item) {
"&num;$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]),

View file

@ -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) == '>')

View file

@ -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;

View file

@ -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);

View file

@ -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

View file

@ -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;

View file

@ -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];
}

View file

@ -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;

View file

@ -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);
}
}
}

View file

@ -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);

View file

@ -8,7 +8,7 @@ function gender_selector($current="",$suffix="") {
call_hooks('gender_selector', $select);
$o .= "<select name=\"gender$suffix\" id=\"gender-select$suffix\" size=\"1\" >";
foreach($select as $selection) {
foreach ($select as $selection) {
if ($selection !== 'NOTRANSLATION') {
$selected = (($selection == $current) ? ' selected="selected" ' : '');
$o .= "<option value=\"$selection\" $selected >$selection</option>";
@ -26,7 +26,7 @@ function sexpref_selector($current="",$suffix="") {
call_hooks('sexpref_selector', $select);
$o .= "<select name=\"sexual$suffix\" id=\"sexual-select$suffix\" size=\"1\" >";
foreach($select as $selection) {
foreach ($select as $selection) {
if ($selection !== 'NOTRANSLATION') {
$selected = (($selection == $current) ? ' selected="selected" ' : '');
$o .= "<option value=\"$selection\" $selected >$selection</option>";
@ -44,7 +44,7 @@ function marital_selector($current="",$suffix="") {
call_hooks('marital_selector', $select);
$o .= "<select name=\"marital\" id=\"marital-select\" size=\"1\" >";
foreach($select as $selection) {
foreach ($select as $selection) {
if ($selection !== 'NOTRANSLATION') {
$selected = (($selection == $current) ? ' selected="selected" ' : '');
$o .= "<option value=\"$selection\" $selected >$selection</option>";

View file

@ -11,13 +11,12 @@ function get_salmon_key($uri,$keyhash) {
$arr = Probe::lrdd($uri);
if (is_array($arr)) {
foreach($arr as $a) {
foreach ($arr as $a) {
if ($a['@attributes']['rel'] === 'magic-public-key') {
$ret[] = $a['@attributes']['href'];
}
}
}
else {
} else {
return '';
}

View file

@ -276,7 +276,7 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) {
$gs = '<<>>'; // should be impossible to match
if (is_array($groups) && count($groups)) {
foreach($groups as $g)
foreach ($groups as $g)
$gs .= '|<' . intval($g) . '>';
}
@ -358,7 +358,7 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null)
$gs = '<<>>'; // should be impossible to match
if (is_array($groups) && count($groups)) {
foreach($groups as $g)
foreach ($groups as $g)
$gs .= '|<' . intval($g) . '>';
}
@ -460,7 +460,7 @@ function init_groups_visitor($contact_id) {
intval($contact_id)
);
if (dbm::is_result($r)) {
foreach($r as $rr)
foreach ($r as $rr)
$groups[] = $rr['gid'];
}
return $groups;

View file

@ -73,7 +73,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
return;
$total = 0;
foreach($j->entry as $entry) {
foreach ($j->entry as $entry) {
$total ++;
$profile_url = '';
@ -137,7 +137,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
}
if (isset($entry->tags)) {
foreach($entry->tags as $tag) {
foreach ($entry->tags as $tag) {
$keywords = implode(", ", $tag);
}
}
@ -1647,20 +1647,22 @@ function poco_discover_federation() {
}
}
// Currently disabled, since the service isn't available anymore.
// It is not removed since I hope that there will be a successor.
// Discover GNU Social Servers.
//if (!get_config('system','ostatus_disabled')) {
// $serverdata = "http://gstools.org/api/get_open_instances/";
/*
* Currently disabled, since the service isn't available anymore.
* It is not removed since I hope that there will be a successor.
* Discover GNU Social Servers.
if (!get_config('system','ostatus_disabled')) {
$serverdata = "http://gstools.org/api/get_open_instances/";
// $result = z_fetch_url($serverdata);
// if ($result["success"]) {
// $servers = json_decode($result["body"]);
$result = z_fetch_url($serverdata);
if ($result["success"]) {
$servers = json_decode($result["body"]);
// foreach($servers->data AS $server)
// poco_check_server($server->instance_address);
// }
//}
foreach($servers->data AS $server)
poco_check_server($server->instance_address);
}
}
*/
set_config('poco','last_federation_discovery', time());
}
@ -1749,7 +1751,7 @@ function poco_discover_server_users($data, $server) {
foreach ($data->entry AS $entry) {
$username = "";
if (isset($entry->urls)) {
foreach($entry->urls as $url)
foreach ($entry->urls as $url)
if ($url->type == 'profile') {
$profile_url = $url->value;
$urlparts = parse_url($profile_url);
@ -1793,7 +1795,7 @@ function poco_discover_server($data, $default_generation = 0) {
$name = $entry->displayName;
if (isset($entry->urls)) {
foreach($entry->urls as $url) {
foreach ($entry->urls as $url) {
if ($url->type == 'profile') {
$profile_url = $url->value;
continue;

View file

@ -95,7 +95,7 @@ class Template implements ITemplateEngine {
* {{ for <$var> as $name }}...{{ endfor }}
* {{ for <$var> as $key=>$name }}...{{ endfor }}
*/
private function _replcb_for($args) {
private function _replcb_for ($args) {
$m = array_map('trim', explode(" as ", $args[2]));
$x = explode("=>", $m[1]);
if (count($x) == 1) {
@ -109,14 +109,16 @@ class Template implements ITemplateEngine {
//$vals = $this->r[$m[0]];
$vals = $this->_get_var($m[0]);
$ret = "";
if (!is_array($vals))
if (!is_array($vals)) {
return $ret;
}
foreach ($vals as $k => $v) {
$this->_push_stack();
$r = $this->r;
$r[$varname] = $v;
if ($keyname != '')
if ($keyname != '') {
$r[$keyname] = (($k === 0) ? '0' : $k);
}
$ret .= $this->replace($args[3], $r);
$this->_pop_stack();
}

View file

@ -163,7 +163,7 @@ function autoname($len) {
$word = substr($word,0,$len);
foreach($noend as $noe) {
foreach ($noend as $noe) {
if ((strlen($word) > 2) && (substr($word,-2) == $noe)) {
$word = substr($word,0,-1);
break;
@ -188,7 +188,7 @@ function xmlify($str) {
/* $buffer = '';
$len = mb_strlen($str);
for($x = 0; $x < $len; $x ++) {
for ($x = 0; $x < $len; $x ++) {
$char = mb_substr($str,$x,1);
switch( $char ) {
@ -420,7 +420,7 @@ function expand_acl($s) {
if (strlen($s)) {
$t = str_replace('<','',$s);
$a = explode('>',$t);
foreach($a as $aa) {
foreach ($a as $aa) {
if (intval($aa))
$ret[] = intval($aa);
}
@ -817,7 +817,7 @@ function get_tags($string) {
// and #hash tags.
if (preg_match_all('/([!#@][^\^ \x0D\x0A,;:?]+)([ \x0D\x0A,;:?]|$)/', $string, $matches)) {
foreach($matches[1] as $match) {
foreach ($matches[1] as $match) {
if (strstr($match, ']')) {
// we might be inside a bbcode color tag - leave it alone
continue;
@ -1249,7 +1249,7 @@ function prepare_body(&$item,$attach = false, $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"]);
@ -1295,12 +1295,12 @@ function prepare_body(&$item,$attach = false, $preview = false) {
$arr = explode('[/attach],',$item['attach']);
if (count($arr)) {
$as .= '<div class="body-attach">';
foreach($arr as $r) {
foreach ($arr as $r) {
$matches = false;
$icon = '';
$cnt = preg_match_all('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"|',$r,$matches, PREG_SET_ORDER);
if ($cnt) {
foreach($matches as $mtch) {
foreach ($matches as $mtch) {
$mime = $mtch[3];
if ((local_user() == $item['uid']) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == NETWORK_DFRN))
@ -1475,7 +1475,7 @@ function get_cats_and_terms($item) {
$matches = false; $first = true;
$cnt = preg_match_all('/<(.*?)>/',$item['file'],$matches,PREG_SET_ORDER);
if ($cnt) {
foreach($matches as $mtch) {
foreach ($matches as $mtch) {
$categories[] = array(
'name' => xmlify(file_tag_decode($mtch[1])),
'url' => "#",
@ -1493,7 +1493,7 @@ function get_cats_and_terms($item) {
$matches = false; $first = true;
$cnt = preg_match_all('/\[(.*?)\]/',$item['file'],$matches,PREG_SET_ORDER);
if ($cnt) {
foreach($matches as $mtch) {
foreach ($matches as $mtch) {
$folders[] = array(
'name' => xmlify(file_tag_decode($mtch[1])),
'url' => "#",
@ -1719,7 +1719,7 @@ function bb_translate_video($s) {
$matches = null;
$r = preg_match_all("/\[video\](.*?)\[\/video\]/ism",$s,$matches,PREG_SET_ORDER);
if ($r) {
foreach($matches as $mtch) {
foreach ($matches as $mtch) {
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'))
@ -1847,7 +1847,7 @@ function file_tag_list_to_file($list,$type = 'file') {
$rbracket = '>';
}
foreach($list_array as $item) {
foreach ($list_array as $item) {
if (strlen($item)) {
$tag_list .= $lbracket . file_tag_encode(trim($item)) . $rbracket;
}
@ -1867,7 +1867,7 @@ function file_tag_file_to_list($file,$type = 'file') {
$cnt = preg_match_all('/<(.*?)>/',$file,$matches,PREG_SET_ORDER);
}
if ($cnt) {
foreach($matches as $mtch) {
foreach ($matches as $mtch) {
if (strlen($list))
$list .= ',';
$list .= file_tag_decode($mtch[1]);
@ -1906,7 +1906,7 @@ function file_tag_update_pconfig($uid,$file_old,$file_new,$type = 'file') {
$new_tags = array();
$check_new_tags = explode(",",file_tag_file_to_list($file_new,$type));
foreach($check_new_tags as $tag) {
foreach ($check_new_tags as $tag) {
if (! stristr($saved,$lbracket . file_tag_encode($tag) . $rbracket))
$new_tags[] = $tag;
}
@ -1917,12 +1917,12 @@ function file_tag_update_pconfig($uid,$file_old,$file_new,$type = 'file') {
$deleted_tags = array();
$check_deleted_tags = explode(",",file_tag_file_to_list($file_old,$type));
foreach($check_deleted_tags as $tag) {
foreach ($check_deleted_tags as $tag) {
if (! stristr($file_new,$lbracket . file_tag_encode($tag) . $rbracket))
$deleted_tags[] = $tag;
}
foreach($deleted_tags as $key => $tag) {
foreach ($deleted_tags as $key => $tag) {
$r = q("SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d",
dbesc($tag),
intval(TERM_OBJ_POST),
@ -2039,7 +2039,7 @@ function undo_post_tagging($s) {
$matches = null;
$cnt = preg_match_all('/([!#@])\[url=(.*?)\](.*?)\[\/url\]/ism',$s,$matches,PREG_SET_ORDER);
if ($cnt) {
foreach($matches as $mtch) {
foreach ($matches as $mtch) {
$s = str_replace($mtch[0], $mtch[1] . $mtch[3],$s);
}
}

View file

@ -50,7 +50,7 @@ class xml {
}
}
foreach($array as $key => $value) {
foreach ($array as $key => $value) {
if (!isset($element) AND isset($xml)) {
$element = $xml;
}