call_hooks($a->module . '_pre_' . $selname, $arr);
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected))
$selected = " selected=\"selected\" ";
else
call_hooks($a->module . '_pre_' . $selname, $arr);
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected))
$selected = " selected=\"selected\" ";
else
$receiverlist = array();
if (dbm::is_result($r)) {
- foreach($r as $rr) {
- if((is_array($preselected)) && in_array($rr['id'], $preselected))
+ foreach ($r as $rr) {
+ if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
$selected = " selected=\"selected\" ";
- else
+ }
+ else {
$selected = '';
+ }
- if($privmail)
+ if ($privmail) {
$trimmed = GetProfileUsername($rr['url'], $rr['name'], false);
- else
+ }
+ else {
$trimmed = mb_substr($rr['name'],0,20);
+ }
$receiverlist[] = $trimmed;
return $arr;
$str = dbesc(implode(',',$arr));
$r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 ");
- if($r) {
+ if ($r) {
$ret = array();
foreach($r as $rr)
$ret[] = intval($rr['id']);
// autocomplete for global contact search (e.g. navbar search)
$r = navbar_complete($a);
$contacts = array();
- if($r) {
+ if ($r) {
foreach($r as $g) {
$contacts[] = array(
"photo" => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
'image/gif' => 'gif'
);
$data = array('photo'=>array());
- if($r) {
- foreach($r as $rr) {
+ if ($r) {
+ foreach ($r as $rr) {
$photo = array();
$photo['id'] = $rr['resource-id'];
$photo['album'] = $rr['album'];
$newbody = $body;
$cnt = 0;
- foreach($images as $image) {
+ foreach ($images as $image) {
// We're depending on the property of 'foreach' (specified on the PHP website) that
// it loops over the array starting from the first element and going sequentially
// to the last element
intval($_SESSION['uid']));
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$selected = (($rr['id'] == $current) ? " selected=\"selected\" " : "");
$o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";
}
$nets = array();
if (dbm::is_result($r)) {
require_once('include/contact_selectors.php');
- foreach($r as $rr) {
- if($rr['network'])
- $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
+ foreach ($r as $rr) {
+ /// @TODO If 'network' is not there, this triggers an E_NOTICE
+ if ($rr['network']) {
+ $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
+ }
}
}
$newbody .= $origbody;
$cnt = 0;
- foreach($images as $image) {
+ foreach ($images as $image) {
// We're depending on the property of 'foreach' (specified on the PHP website) that
// it loops over the array starting from the first element and going sequentially
// to the last element
$r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` != '0000-00-00' AND SUBSTRING(`bd`,1,4) != `bdyear` ");
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
logger('update_contact_birthday: ' . $rr['bd']);
dbesc(NETWORK_DIASPORA),
dbesc($msg["author"])
);
- if($r) {
- foreach($r as $rr) {
+ if ($r) {
+ foreach ($r as $rr) {
logger("delivering to: ".$rr["username"]);
self::dispatch($rr,$msg);
}
dbesc($guid)
);
- if($r) {
+ if ($r) {
logger("message ".$guid." already exists for user ".$uid);
return $r[0]["id"];
}
dbesc($message_uri),
intval($importer["uid"])
);
- if($r) {
+ if ($r) {
logger("duplicate message already delivered.", LOGGER_DEBUG);
return false;
}
FROM `item` WHERE `guid` = '%s' AND `visible` AND NOT `deleted` AND `body` != '' LIMIT 1",
dbesc($guid));
- if($r) {
+ if ($r) {
logger("reshared message ".$guid." already exists on system.");
// Maybe it is already a reshared item?
logger("transmit: ".$logid."-".$guid." returns: ".$return_code);
- if(!$return_code || (($return_code == 503) && (stristr($a->get_curl_headers(), "retry-after")))) {
+ if (!$return_code || (($return_code == 503) && (stristr($a->get_curl_headers(), "retry-after")))) {
logger("queue message");
$r = q("SELECT `id` FROM `queue` WHERE `cid` = %d AND `network` = '%s' AND `content` = '%s' AND `batch` = %d LIMIT 1",
dbesc($slap),
intval($public_batch)
);
- if($r) {
+ if ($r) {
logger("add_to_queue ignored - identical item already in queue");
} else {
// queue message for redelivery
$r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
item_expire($rr['uid'],$rr['expire']);
}
$r = q("SELECT def_gid, allow_gid, deny_gid FROM user WHERE uid = %d LIMIT 1",
intval($uid)
);
- if($r) {
+ if ($r) {
$user_info = $r[0];
$change = false;
);
$grps[] = array('name' => '', 'id' => '0', 'selected' => '');
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$grps[] = array('name' => $rr['name'], 'id' => $rr['id'], 'selected' => (($gid == $rr['id']) ? 'true' : ''));
}
}
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$selected = (($group_id == $rr['id']) ? ' group-selected' : '');
if ($editmode == "full") {
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$profile['menu']['entries'][] = array(
'photo' => $rr['thumb'],
'id' => $rr['id'],
$cids = array();
$istoday = false;
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if(strlen($rr['name']))
$total ++;
if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now))
if (dbm::is_result($r)) {
$now = strtotime('now');
$istoday = false;
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if(strlen($rr['name']))
$total ++;
$match = null;
- if(preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) {
+ if (preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) {
$images = $match[1];
- if(count($images)) {
- foreach($images as $image) {
- if(! stristr($image,App::get_baseurl() . '/photo/'))
+ if (count($images)) {
+ foreach ($images as $image) {
+ if (! stristr($image,App::get_baseurl() . '/photo/')) {
continue;
+ }
$image_uri = substr($image,strrpos($image,'/') + 1);
$image_uri = substr($image_uri,0, strpos($image_uri,'-'));
$r = q("UPDATE `photo` SET `allow_cid` = '%s'
}
}
- if($post_id) {
+ if ($post_id) {
proc_run(PRIORITY_HIGH, "include/notifier.php", "mail", $post_id);
return intval($post_id);
- } else {
+ }
+ else {
return -3;
}
}
-
-
-
-
function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
- if(! $recipient) return -1;
+ if (! $recipient) {
+ return -1;
+ }
- if(! strlen($subject))
+ if (! strlen($subject)) {
$subject = t('[no subject]');
+ }
$guid = get_guid(32);
$uri = 'urn:X-dfrn:' . App::get_baseurl() . ':' . local_user() . ':' . $guid;
$me = probe_url($replyto);
- if(! $me['name'])
+ if (! $me['name']) {
return -2;
+ }
$conv_guid = get_guid(32);
$handles = $recip_handle . ';' . $sender_handle;
- $r = q("insert into conv (uid,guid,creator,created,updated,subject,recips) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ",
+ $r = q("INSERT INTO `conv` (`uid`,`guid`,`creator`,`created`,`updated`,`subject`,`recips`) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ",
intval($recipient['uid']),
dbesc($conv_guid),
dbesc($sender_handle),
dbesc($handles)
);
- $r = q("select * from conv where guid = '%s' and uid = %d limit 1",
+ $r = q("SELECT * FROM `conv` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($conv_guid),
intval($recipient['uid'])
);
- if (dbm::is_result($r))
- $convid = $r[0]['id'];
- if(! $convid) {
+
+ if (! dbm::is_result($r)) {
logger('send message: conversation not found.');
return -4;
}
+ $convid = $r[0]['id'];
+
$r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`,
`contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`, `unknown`)
VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s', %d )",
// throw everything into the queue in case we get killed
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if((! $mail) && (! $fsuggest) && (! $followup)) {
q("INSERT INTO `deliverq` (`cmd`,`item`,`contact`) VALUES ('%s', %d, %d)
ON DUPLICATE KEY UPDATE `cmd` = '%s', `item` = %d, `contact` = %d",
}
}
- foreach($r as $rr) {
+ foreach ($r as $rr) {
// except for Diaspora batch jobs
// Don't deliver to folks who have already been delivered to
$a = get_app();
$a->hooks = array();
$r = q("SELECT * FROM `hook` WHERE 1 ORDER BY `priority` DESC, `file`");
+
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if(! array_key_exists($rr['hook'],$a->hooks))
$a->hooks[$rr['hook']] = array();
$a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
load_config('system');
// Don't check this stuff if the function is called by the poller
- if (App::callstack() != "poller_run")
- if (App::is_already_running("pubsubpublish", "include/pubsubpublish.php", 540))
+ if (App::callstack() != "poller_run") {
+ if (App::is_already_running("pubsubpublish", "include/pubsubpublish.php", 540)) {
return;
+ }
+ }
$a->set_baseurl(get_config('system','url'));
load_hooks();
- if($argc > 1)
+ if ($argc > 1) {
$pubsubpublish_id = intval($argv[1]);
+ }
else {
// We'll push to each subscriber that has push > 0,
// i.e. there has been an update (set in notifier.php).
$interval = Config::get("system", "delivery_interval", 2);
// If we are using the worker we don't need a delivery interval
- if (get_config("system", "worker"))
+ if (get_config("system", "worker")) {
$interval = false;
+ }
- foreach($r as $rr) {
+ foreach ($r as $rr) {
logger("Publish feed to ".$rr["callback_url"], LOGGER_DEBUG);
proc_run(PRIORITY_HIGH, 'include/pubsubpublish.php', $rr["id"]);
$interval = false;
$r = q("select * from deliverq where 1");
- if($r) {
- foreach($r as $rr) {
+ if ($r) {
+ foreach ($r as $rr) {
logger('queue: deliverq');
proc_run(PRIORITY_HIGH,'include/delivery.php',$rr['cmd'],$rr['item'],$rr['contact']);
- if($interval)
- @time_sleep_until(microtime(true) + (float) $interval);
+ if($interval) {
+ time_sleep_until(microtime(true) + (float) $interval);
+ }
}
}
$r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`
INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
- if($r) {
- foreach($r as $rr) {
+ if ($r) {
+ foreach ($r as $rr) {
logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']);
logger('Expired queue data :' . $rr['content'], LOGGER_DATA);
}
if (dbm::is_result($r)) {
$contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
$micropro = Array();
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$micropro[] = micropro($rr,true,'mpfriend');
}
}
$matches = null;
$r = preg_match_all("/\[video\](.*?)\[\/video\]/ism",$s,$matches,PREG_SET_ORDER);
- if($r) {
+ if ($r) {
foreach($matches as $mtch) {
if((stristr($mtch[1],'youtube')) || (stristr($mtch[1],'youtu.be')))
$s = str_replace($mtch[0],'[youtube]' . $mtch[1] . '[/youtube]',$s);
dbesc($default_service_class)
);
- if($r) {
+ if ($r) {
$r = q("SELECT * FROM `user`
WHERE `username` = '%s' AND `password` = '%s' LIMIT 1",
dbesc($username),