if (!$contacts)
return($forumlist);
- foreach($contacts as $contact) {
+ foreach ($contacts as $contact) {
$forumlist[] = array(
'url' => $contact['url'],
'name' => $contact['name'],
$id = 0;
- foreach($contacts as $contact) {
+ foreach ($contacts as $contact) {
$selected = (($cid == $contact['id']) ? ' forum-selected' : '');
$total_shown = 0;
- foreach($contacts as $contact) {
+ foreach ($contacts as $contact) {
$forumlist .= micropro($contact,false,'forumlist-profile-advanced');
$total_shown ++;
*/
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']);
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) {
$aOrder = explode(" ", $order);
$asOrder = array();
- foreach($aOrder as $o) {
+ foreach ($aOrder as $o) {
$dir = "asc";
if ($o[0]==="-") {
$dir = "desc";
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.
$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);
$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"]);
}
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>';
}
}
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="<3" />';
}
$r = str_replace($x[0],$t,$x[0]);
$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 ) ";
}
$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']) )
}
}
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']) )
intval($count)
);
- foreach($r as $g){
+ foreach ($r as $g){
// logger('acl: group: ' . $g['name'] . ' members: ' . $g['uids']);
$groups[] = array(
"type" => "g",
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.")";
$ret = Array();
- foreach($r as $item) {
+ foreach ($r as $item) {
localize_item($item);
list($status_user, $owner_user) = api_item_get_user($a,$item);
);
$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"]);
return;
$ids = array();
- foreach($r as $rr)
+ foreach ($r as $rr)
if ($stringify_ids)
$ids[] = $rr['id'];
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']));
$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']));
// 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." ";
// 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) {
$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 );
$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)
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";
}
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";
}
$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' : ''));
}
$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' : ''));
}
$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;
}
$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']);
}
$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);
// 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;
}
$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]);
+ }
}
}
// $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;
$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"]);
// 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;
*/
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 = '';
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
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']);
}
}
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);
// 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;
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)
}
}*/
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'];
$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;*/
}
}
}
function find_thread_parent_index($arr,$x) {
- foreach($arr as $k => $v) {
+ foreach ($arr as $k => $v) {
if ($v['id'] == $x['parent']) {
return $k;
}
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'] : '');
}
$count = 0;
- foreach($ret as $key) {
- if ($key['count'] == true)
+ foreach ($ret as $key) {
+ if ($key['count'] == true) {
$count++;
+ }
}
$ret['count'] = $count;
// 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']));
}
continue;
}
- foreach($res as $contact) {
+ foreach ($res as $contact) {
$xml = false;
// 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) {
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;
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;
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) {
$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>';
$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>';
}
$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;
$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;
}
$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";
return;
}
- foreach($messages as $mesg)
+ foreach ($messages as $mesg)
self::receive_conversation_message($importer, $contact, $data, $msg, $mesg, $conversation);
return true;
$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";
}
}
$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]) .' ';
}
"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);
}
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;
$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);
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;
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;
}
$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'))
$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));
*/
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];
}
// 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;
$type = "";
$title = "";
- foreach($enclosure->attributes AS $attributes) {
+ foreach ($enclosure->attributes AS $attributes) {
if ($attributes->name == "url") {
$href = $attributes->textContent;
} elseif ($attributes->name == "length") {
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);
}
$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');
$ret = array();
if (dbm::is_result($r)) {
- foreach($r as $rr)
+ foreach ($r as $rr) {
$ret[] = $rr['gid'];
+ }
}
return $ret;
$newlines = array();
$level = 0;
- foreach($lines as $line) {;
+ foreach ($lines as $line) {;
$line = trim($line);
$startquote = false;
while (strpos("*".$line, '[quote]') > 0) {
*/
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'])
// 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;
}
$p = array();
- foreach($profile as $k => $v) {
+ foreach ($profile as $k => $v) {
$k = str_replace('-','_',$k);
$p[$k] = $v;
}
}
$classtoday = $istoday ? ' birthday-today ' : '';
if ($total) {
- foreach($r as &$rr) {
+ foreach ($r as &$rr) {
if (! strlen($rr['name']))
continue;
$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)
"#$2", $item["body"]);
- foreach($tags as $tag) {
+ foreach ($tags as $tag) {
if (strpos($tag,'#') !== 0)
continue;
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
$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]);
$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]);
}
$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]);
}
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
return;
if (count($items)) {
- foreach($items as $item) {
+ foreach ($items as $item) {
$owner = drop_item($item,false);
if ($owner && ! $uid)
$uid = $owner;
// 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;
// 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]);
$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);
}
}
$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);
}
}
// 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]),
$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) == '>')
$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;
*/
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;
$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;
$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);
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
$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;
// 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");
$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];
}
$parr = explode(',',$plugins);
if (count($parr)) {
- foreach($parr as $pl) {
+ foreach ($parr as $pl) {
$pl = trim($pl);
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);
$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;
}
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));
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));
*/
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);
}
"{$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;
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
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);
+ }
}
}
}
// 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",
}
// 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);
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>";
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>";
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>";
$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 '';
}
$gs = '<<>>'; // should be impossible to match
if (is_array($groups) && count($groups)) {
- foreach($groups as $g)
+ foreach ($groups as $g)
$gs .= '|<' . intval($g) . '>';
}
$gs = '<<>>'; // should be impossible to match
if (is_array($groups) && count($groups)) {
- foreach($groups as $g)
+ foreach ($groups as $g)
$gs .= '|<' . intval($g) . '>';
}
intval($contact_id)
);
if (dbm::is_result($r)) {
- foreach($r as $rr)
+ foreach ($r as $rr)
$groups[] = $rr['gid'];
}
return $groups;
return;
$total = 0;
- foreach($j->entry as $entry) {
+ foreach ($j->entry as $entry) {
$total ++;
$profile_url = '';
}
if (isset($entry->tags)) {
- foreach($entry->tags as $tag) {
+ foreach ($entry->tags as $tag) {
$keywords = implode(", ", $tag);
}
}
}
}
- // 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());
}
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);
$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;
* {{ 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) {
//$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();
}
$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;
/* $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 ) {
if (strlen($s)) {
$t = str_replace('<','',$s);
$a = explode('>',$t);
- foreach($a as $aa) {
+ foreach ($a as $aa) {
if (intval($aa))
$ret[] = intval($aa);
}
// 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;
$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"]);
$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))
$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' => "#",
$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' => "#",
$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'))
$rbracket = '>';
}
- foreach($list_array as $item) {
+ foreach ($list_array as $item) {
if (strlen($item)) {
$tag_list .= $lbracket . file_tag_encode(trim($item)) . $rbracket;
}
$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]);
$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;
}
$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),
$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);
}
}
}
}
- foreach($array as $key => $value) {
+ foreach ($array as $key => $value) {
if (!isset($element) AND isset($xml)) {
$element = $xml;
}