$img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
- while (($img_st_close !== false) && ($img_end !== false)) {
+ while(($img_st_close !== false) && ($img_end !== false)) {
$img_st_close++; // make it point to AFTER the closing bracket
$img_end += $img_start;
"#$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]);
return true;
}
-function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
+function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
$url = notags(trim($datarray['author-link']));
$name = notags(trim($datarray['author-name']));
$photo = notags(trim($datarray['author-avatar']));
if (is_object($item)) {
$rawtag = $item->get_item_tags(NAMESPACE_ACTIVITY,'actor');
- if ($rawtag && $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data'])
+ if ($rawtag && $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data']) {
$nick = $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data'];
- } else
+ }
+ } else {
$nick = $item;
+ }
if (is_array($contact)) {
if (($contact['network'] == NETWORK_OSTATUS && $contact['rel'] == CONTACT_IS_SHARING)
update_contact_avatar($photo, $importer["uid"], $contact_record["id"], true);
}
-
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($importer['uid'])
);
- $a = get_app();
if (dbm::is_result($r) AND !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
$def_gid = get_default_group($importer['uid'], $contact_record["network"]);
- if (intval($def_gid))
- group_add_member($importer['uid'],'',$contact_record['id'],$def_gid);
+ if (intval($def_gid)) {
+ group_add_member($importer['uid'], '', $contact_record['id'], $def_gid);
+ }
if (($r[0]['notify-flags'] & NOTIFY_INTRO) &&
in_array($r[0]['page-flags'], array(PAGE_NORMAL))) {
}
}
-function lose_follower($importer,$contact,$datarray = array(),$item = "") {
+function lose_follower($importer, $contact, array $datarray = array(), $item = "") {
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) {
q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d",
}
}
-function lose_sharer($importer,$contact,$datarray = array(),$item = "") {
+function lose_sharer($importer, $contact, array $datarray = array(), $item = "") {
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) {
q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d",
}
}
-function subscribe_to_hub($url,$importer,$contact,$hubmode = 'subscribe') {
+function subscribe_to_hub($url, $importer, $contact, $hubmode = 'subscribe') {
$a = get_app();
$img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
$img_len = ($img_start !== false ? strpos(substr($orig_body, $img_start + $img_st_close + 1), '[/img]') : false);
- while ( ($img_st_close !== false) && ($img_len !== false) ) {
+ while( ($img_st_close !== false) && ($img_len !== false) ) {
$img_st_close++; // make it point to AFTER the closing bracket
$image = substr($orig_body, $img_start + $img_st_close, $img_len);
$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]),
// Starting with the current month, get the first and last days of every
// month down to and including the month of the first post
- while (substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
+ while(substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
$dyear = intval(substr($dnow,0,4));
$dstart = substr($dnow,0,8) . '01';
$dend = substr($dnow,0,8) . get_dim(intval($dnow),intval(substr($dnow,5)));
$ret = array();
// Starting with the current month, get the first and last days of every
// month down to and including the month of the first post
- while (substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
+ while(substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
$dstart = substr($dnow,0,8) . '01';
$dend = substr($dnow,0,8) . get_dim(intval($dnow),intval(substr($dnow,5)));
$start_month = datetime_convert('','',$dstart,'Y-m-d');