added spaces + some curly braces

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2017-01-26 16:01:56 +01:00 committed by Roland Haeder
parent 0cd241bcbe
commit 41a36606c6
No known key found for this signature in database
GPG Key ID: B72F8185C6C7BD78
60 changed files with 1018 additions and 930 deletions

View File

@ -33,10 +33,11 @@ class DirSearch {
$ostatus = NETWORK_DFRN;
// check if we search only communities or every contact
if($mode === "community")
if ($mode === "community") {
$extra_sql = " AND `community`";
else
} else {
$extra_sql = "";
}
$search .= "%";

View File

@ -154,12 +154,16 @@ class ForumManager {
foreach($contacts as $contact) {
$forumlist .= micropro($contact,false,'forumlist-profile-advanced');
$total_shown ++;
if($total_shown == $show_total)
if ($total_shown == $show_total) {
break;
}
}
if(count($contacts) > 0)
if (count($contacts) > 0) {
$o .= $forumlist;
}
return $o;
}

View File

@ -1133,15 +1133,17 @@ class Probe {
$password = '';
openssl_private_decrypt(hex2bin($r[0]['pass']), $password,$x[0]['prvkey']);
$mbox = email_connect($mailbox,$r[0]['user'], $password);
if(!mbox)
if (!$mbox) {
return false;
}
}
$msgs = email_poll($mbox, $uri);
logger('searching '.$uri.', '.count($msgs).' messages found.', LOGGER_DEBUG);
if (!count($msgs))
if (!count($msgs)) {
return false;
}
$data = array();
@ -1157,10 +1159,11 @@ class Probe {
$data["poll"] = 'email '.random_string();
$x = email_msg_meta($mbox, $msgs[0]);
if(stristr($x[0]->from, $uri))
if (stristr($x[0]->from, $uri)) {
$adr = imap_rfc822_parse_adrlist($x[0]->from, '');
elseif(stristr($x[0]->to, $uri))
} elseif (stristr($x[0]->to, $uri)) {
$adr = imap_rfc822_parse_adrlist($x[0]->to, '');
}
if (isset($adr)) {
foreach($adr as $feadr) {
if ((strcasecmp($feadr->mailbox, $data["name"]) == 0)

View File

@ -170,11 +170,13 @@ class Smilies {
* @todo: Rework because it doesn't work correctly
*/
private function preg_heart($x) {
if(strlen($x[1]) == 1)
if (strlen($x[1]) == 1) {
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]);
return $r;
}

View File

@ -215,9 +215,9 @@ function common_friends_visitor_widget($profile_uid) {
dbesc(normalise_link(get_my_url())),
intval($profile_uid)
);
if (dbm::is_result($r))
if (dbm::is_result($r)) {
$cid = $r[0]['id'];
else {
} else {
$r = q("select id from gcontact where nurl = '%s' limit 1",
dbesc(normalise_link(get_my_url()))
);
@ -227,22 +227,26 @@ function common_friends_visitor_widget($profile_uid) {
}
}
if($cid == 0 && $zcid == 0)
if ($cid == 0 && $zcid == 0) {
return;
}
require_once('include/socgraph.php');
if($cid)
if ($cid) {
$t = count_common_friends($profile_uid,$cid);
else
} else {
$t = count_common_friends_zcid($profile_uid,$zcid);
if(! $t)
}
if (! $t) {
return;
}
if($cid)
if ($cid) {
$r = common_friends($profile_uid,$cid,0,5,true);
else
} else {
$r = common_friends_zcid($profile_uid,$zcid,0,5,true);
}
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
'$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),

View File

@ -1418,9 +1418,11 @@ function sort_thr_commented($a,$b) {
}
function find_thread_parent_index($arr,$x) {
foreach($arr as $k => $v)
if($v['id'] == $x['parent'])
foreach($arr as $k => $v) {
if ($v['id'] == $x['parent']) {
return $k;
}
}
return false;
}
@ -1443,8 +1445,7 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
$ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS);
array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-'
. (($ob) ? $ob->get_id() : $item['id']) . '"><b>' . t('View all') . '</b></a>');
}
else {
} else {
$ret[$v]['list_part'] = '';
}
$ret[$v]['button'] = get_response_button_text($v,$ret[$v]['count']);

View File

@ -290,11 +290,13 @@ function cron_clear_cache(App $a) {
if ($last) {
$next = $last + (3600); // Once per hour
$clear_cache = ($next <= time());
} else
} else {
$clear_cache = true;
}
if (!$clear_cache)
if (!$clear_cache) {
return;
}
// clear old cache
Cache::clear();
@ -313,7 +315,9 @@ function cron_clear_cache(App $a) {
clear_cache($a->get_basepath(), $a->get_basepath()."/proxy");
$cachetime = get_config('system','proxy_cache_time');
if (!$cachetime) $cachetime = PROXY_DEFAULT_TIME;
if (!$cachetime) {
$cachetime = PROXY_DEFAULT_TIME;
}
q('DELETE FROM `photo` WHERE `uid` = 0 AND `resource-id` LIKE "pic:%%" AND `created` < NOW() - INTERVAL %d SECOND', $cachetime);
}
@ -326,26 +330,30 @@ function cron_clear_cache(App $a) {
// Maximum table size in megabyte
$max_tablesize = intval(get_config('system','optimize_max_tablesize')) * 1000000;
if ($max_tablesize == 0)
if ($max_tablesize == 0) {
$max_tablesize = 100 * 1000000; // Default are 100 MB
}
if ($max_tablesize > 0) {
// Minimum fragmentation level in percent
$fragmentation_level = intval(get_config('system','optimize_fragmentation')) / 100;
if ($fragmentation_level == 0)
if ($fragmentation_level == 0) {
$fragmentation_level = 0.3; // Default value is 30%
}
// Optimize some tables that need to be optimized
$r = q("SHOW TABLE STATUS");
foreach($r as $table) {
// Don't optimize tables that are too large
if ($table["Data_length"] > $max_tablesize)
if ($table["Data_length"] > $max_tablesize) {
continue;
}
// Don't optimize empty tables
if ($table["Data_length"] == 0)
if ($table["Data_length"] == 0) {
continue;
}
// Calculate fragmentation
$fragmentation = $table["Data_free"] / ($table["Data_length"] + $table["Index_length"]);
@ -353,8 +361,9 @@ function cron_clear_cache(App $a) {
logger("Table ".$table["Name"]." - Fragmentation level: ".round($fragmentation * 100, 2), LOGGER_DEBUG);
// Don't optimize tables that needn't to be optimized
if ($fragmentation < $fragmentation_level)
if ($fragmentation < $fragmentation_level) {
continue;
}
// So optimize it
logger("Optimize Table ".$table["Name"], LOGGER_DEBUG);
@ -414,9 +423,11 @@ function cron_repair_database() {
// Update the global contacts for local users
$r = q("SELECT `uid` FROM `user` WHERE `verified` AND NOT `blocked` AND NOT `account_removed` AND NOT `account_expired`");
if (dbm::is_result($r))
foreach ($r AS $user)
if (dbm::is_result($r)) {
foreach ($r AS $user) {
update_gcontact_for_user($user["uid"]);
}
}
/// @todo
/// - remove thread entries without item

View File

@ -8,19 +8,21 @@ function cronhooks_run(&$argv, &$argc){
require_once('include/datetime.php');
if (($argc == 2) AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
foreach ($a->hooks["cron"] as $hook)
foreach ($a->hooks["cron"] as $hook) {
if ($hook[1] == $argv[1]) {
logger("Calling cron hook '".$hook[1]."'", LOGGER_DEBUG);
call_single_hook($a, $name, $hook, $data);
}
}
return;
}
$last = get_config('system', 'last_cronhook');
$poll_interval = intval(get_config('system','cronhook_interval'));
if(! $poll_interval)
if (! $poll_interval) {
$poll_interval = 9;
}
if ($last) {
$next = $last + ($poll_interval * 60);

View File

@ -486,10 +486,12 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
$thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
if(! $y)
if (! $y) {
$y = $thisyear;
if(! $m)
}
if (! $m) {
$m = intval($thismonth);
}
$dn = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
$f = get_first_dim($y,$m);
@ -498,29 +500,33 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
$dow = 0;
$started = false;
if(($y == $thisyear) && ($m == $thismonth))
if (($y == $thisyear) && ($m == $thismonth)) {
$tddate = intval(datetime_convert('UTC',date_default_timezone_get(),'now','j'));
}
$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>';
}
$o .= '</tr><tr>';
while ($d <= $l) {
if(($dow == $f) && (! $started))
if (($dow == $f) && (! $started)) {
$started = true;
}
$today = (((isset($tddate)) && ($tddate == $d)) ? "class=\"today\" " : '');
$o .= "<td $today>";
$day = str_replace(' ','&nbsp;',sprintf('%2.2d', $d));
if ($started) {
if(is_array($links) && isset($links[$d]))
if (is_array($links) && isset($links[$d])) {
$o .= "<a href=\"{$links[$d]}\">$day</a>";
else
} else {
$o .= $day;
}
$d ++;
} else {
@ -534,9 +540,11 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
$o .= '</tr><tr>';
}
}
if($dow)
for($a = $dow; $a < 7; $a ++)
if ($dow) {
for ($a = $dow; $a < 7; $a ++) {
$o .= '<td>&nbsp;</td>';
}
}
$o .= '</tr></table>'."\r\n";

View File

@ -3632,17 +3632,20 @@ class Diaspora {
}
$r = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval($contact['uid']));
if(!$r)
if (!dbm::is_result($r)) {
return false;
}
$contact["uprvkey"] = $r[0]['prvkey'];
$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($post_id));
if (!$r)
if (!dbm::is_result($r)) {
return false;
}
if (!in_array($r[0]["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE)))
if (!in_array($r[0]["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE))) {
return false;
}
$message = self::construct_like($r[0], $contact);
$message["author_signature"] = self::signature($contact, $message);

View File

@ -177,7 +177,7 @@ function discover_directory($search) {
foreach ($j->results as $jj) {
// Check if the contact already exists
$exists = q("SELECT `id`, `last_contact`, `last_failure`, `updated` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($jj->url));
if ($exists) {
if (dbm::is_result($exists)) {
logger("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG);
if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) AND

View File

@ -411,10 +411,12 @@ function notification($params) {
$hash = random_string();
$r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
dbesc($hash));
if (dbm::is_result($r))
if (dbm::is_result($r)) {
$dups = true;
}
} while ($dups == true);
/// @TODO One statement is enough
$datarray = array();
$datarray['hash'] = $hash;
$datarray['name'] = $params['source_name'];

View File

@ -750,12 +750,14 @@ function event_format_export ($events, $format = 'ical', $timezone) {
* @return array Query results
*/
function events_by_uid($uid = 0, $sql_extra = '') {
if($uid == 0)
if ($uid == 0) {
return;
}
// The permission condition if no condition was transmitted
if($sql_extra == '')
if ($sql_extra == '') {
$sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' ";
}
// does the user who requests happen to be the owner of the events
// requested? then show all of your events, otherwise only those that
@ -772,9 +774,10 @@ function events_by_uid($uid = 0, $sql_extra = '') {
);
}
if (dbm::is_result($r))
if (dbm::is_result($r)) {
return $r;
}
}
/**
*
@ -795,20 +798,23 @@ function event_export($uid, $format = 'ical') {
// we are allowed to show events
// get the timezone the user is in
$r = q("SELECT `timezone` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid));
if (dbm::is_result($r))
if (dbm::is_result($r)) {
$timezone = $r[0]['timezone'];
}
// get all events which are owned by a uid (respects permissions);
$events = events_by_uid($uid);
// we have the events that are available for the requestor
// now format the output according to the requested format
if(count($events))
if (count($events)) {
$res = event_format_export($events, $format, $timezone);
}
// If there are results the precess was successfull
if(x($res))
if (x($res)) {
$process = true;
}
// get the file extension for the format
switch ($format) {
@ -851,8 +857,9 @@ function widget_events() {
// The permission testing is a little bit tricky because we have to respect many cases
// It's not the private events page (we don't get the $owner_uid for /events)
if(! local_user() && ! $owner_uid)
if (! local_user() && ! $owner_uid) {
return;
}
// Cal logged in user (test permission at foreign profile page)
// If the $owner uid is available we know it is part of one of the profile pages (like /cal)
@ -860,13 +867,15 @@ function widget_events() {
// or a foreign one. For foreign profile pages we need to check if the feature
// for exporting the cal is enabled (otherwise the widget would appear for logged in users
// on foreigen profile pages even if the widget is disabled)
if(intval($owner_uid) && local_user() !== $owner_uid && ! feature_enabled($owner_uid, "export_calendar"))
if (intval($owner_uid) && local_user() !== $owner_uid && ! feature_enabled($owner_uid, "export_calendar")) {
return;
}
// If it's a kind of profile page (intval($owner_uid)) return if the user not logged in and
// export feature isn't enabled
if(intval($owner_uid) && ! local_user() && ! feature_enabled($owner_uid, "export_calendar"))
if (intval($owner_uid) && ! local_user() && ! feature_enabled($owner_uid, "export_calendar")) {
return;
}
return replace_macros(get_markup_template("events_aside.tpl"), array(
'$etitle' => t("Export"),

View File

@ -11,12 +11,13 @@ function expire_run(&$argv, &$argc){
// physically remove anything that has been deleted for more than two months
$r = q("delete from item where deleted = 1 and changed < UTC_TIMESTAMP() - INTERVAL 60 DAY");
$r = q("DELETE FROM `item` WHERE `deleted` = 1 AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY");
// make this optional as it could have a performance impact on large sites
if(intval(get_config('system','optimize_items')))
q("optimize table item");
if (intval(get_config('system','optimize_items'))) {
q("OPTIMIZE TABLE `item`");
}
logger('expire: start');

View File

@ -289,8 +289,9 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
$type = $attributes->textContent;
}
}
if(strlen($item["attach"]))
if (strlen($item["attach"])) {
$item["attach"] .= ',';
}
$attachments[] = array("link" => $href, "type" => $type, "length" => $length);

View File

@ -878,16 +878,20 @@ function zrl_init(App $a) {
}
function zrl($s,$force = false) {
if(! strlen($s))
if (! strlen($s)) {
return $s;
if((! strpos($s,'/profile/')) && (! $force))
}
if ((! strpos($s,'/profile/')) && (! $force)) {
return $s;
if($force && substr($s,-1,1) !== '/')
}
if ($force && substr($s,-1,1) !== '/') {
$s = $s . '/';
}
$achar = strpos($s,'?') ? '&' : '?';
$mine = get_my_url();
if($mine and ! link_compare($mine,$s))
if ($mine and ! link_compare($mine,$s)) {
return $s . $achar . 'zrl=' . urlencode($mine);
}
return $s;
}
@ -908,9 +912,10 @@ function zrl($s,$force = false) {
function get_theme_uid() {
$uid = (($_REQUEST['puid']) ? intval($_REQUEST['puid']) : 0);
if (local_user()) {
if((get_pconfig(local_user(),'system','always_my_theme')) || (! $uid))
if ((get_pconfig(local_user(),'system','always_my_theme')) || (! $uid)) {
return local_user();
}
}
return $uid;
}

View File

@ -57,8 +57,9 @@ function block_on_function_lock($fn_name, $wait_sec = 2, $timeout = 30) {
dbesc($fn_name)
);
if (dbm::is_result($r) && $r[0]['locked'])
if (dbm::is_result($r) && $r[0]['locked']) {
sleep($wait_sec);
}
} while (dbm::is_result($r) && $r[0]['locked'] && ((time() - $start) < $timeout));

View File

@ -316,7 +316,9 @@ function oembed_html2bbcode($text) {
$xattr = "@rel='oembed'";//oe_build_xpath("rel","oembed");
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 (!is_null($href)) {
$e->parentNode->replaceChild(new DOMText("[embed]".$href."[/embed]"), $e);
}
}
return oe_get_inner_html( $dom->getElementsByTagName("body")->item(0) );
} else {

View File

@ -61,7 +61,7 @@ function onepoll_run(&$argv, &$argc){
intval($contact_id)
);
if (! count($contacts)) {
if (! dbm::is_result($contacts)) {
return;
}

View File

@ -524,12 +524,14 @@ function service_class_fetch($uid,$property) {
function upgrade_link($bbcode = false) {
$l = get_config('service_class','upgrade_link');
if(! $l)
if (! $l) {
return '';
if($bbcode)
}
if ($bbcode) {
$t = sprintf('[url=%s]' . t('Click here to upgrade.') . '[/url]', $l);
else
} else {
$t = sprintf('<a href="%s">' . t('Click here to upgrade.') . '</div>', $l);
}
return $t;
}
@ -556,13 +558,15 @@ function upgrade_bool_message($bbcode = false) {
*/
function theme_include($file, $root = '') {
// Make sure $root ends with a slash / if it's not blank
if($root !== '' && $root[strlen($root)-1] !== '/')
if ($root !== '' && $root[strlen($root)-1] !== '/') {
$root = $root . '/';
}
$theme_info = $a->theme_info;
if(is_array($theme_info) AND array_key_exists('extends',$theme_info))
if (is_array($theme_info) AND array_key_exists('extends',$theme_info)) {
$parent = $theme_info['extends'];
else
} else {
$parent = 'NOPATH';
}
$theme = current_theme();
$thname = $theme;
$ext = substr($file,strrpos($file,'.')+1);
@ -573,10 +577,11 @@ function theme_include($file, $root = '') {
);
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)
if (strpos($p,'NOPATH') !== false) {
continue;
if(file_exists($p))
} elseif (file_exists($p)) {
return $p;
}
}
return '';
}

View File

@ -28,9 +28,11 @@ function handle_pubsubhubbub($id) {
global $a;
$r = q("SELECT * FROM `push_subscriber` WHERE `id` = %d", intval($id));
if (!$r)
if (!dbm::is_result($r)) {
return;
else
}
$rr = $r[0];
logger("Generate feed of user ".$rr['nickname']." to ".$rr['callback_url']." - last updated ".$rr['last_update'], LOGGER_DEBUG);
@ -65,8 +67,10 @@ function handle_pubsubhubbub($id) {
// increment this until some upper limit where we give up
$new_push = intval($rr['push']) + 1;
if ($new_push > 30) // OK, let's give up
if ($new_push > 30) {
// OK, let's give up
$new_push = 0;
}
q("UPDATE `push_subscriber` SET `push` = %d WHERE id = %d",
$new_push,

View File

@ -49,12 +49,14 @@ function was_recently_delayed($cid) {
function add_to_queue($cid,$network,$msg,$batch = false) {
$max_queue = get_config('system','max_contact_queue');
if($max_queue < 1)
if ($max_queue < 1) {
$max_queue = 500;
}
$batch_queue = get_config('system','max_batch_queue');
if($batch_queue < 1)
if ($batch_queue < 1) {
$batch_queue = 1000;
}
$r = q("SELECT COUNT(*) AS `total` FROM `queue` INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
WHERE `queue`.`cid` = %d AND `contact`.`self` = 0 ",
@ -64,8 +66,7 @@ function add_to_queue($cid,$network,$msg,$batch = false) {
if ($batch && ($r[0]['total'] > $batch_queue)) {
logger('add_to_queue: too many queued items for batch server ' . $cid . ' - discarding message');
return;
}
elseif((! $batch) && ($r[0]['total'] > $max_queue)) {
} elseif ((! $batch) && ($r[0]['total'] > $max_queue)) {
logger('add_to_queue: too many queued items for contact ' . $cid . ' - discarding message');
return;
}

View File

@ -69,8 +69,9 @@ function slapper($owner,$url,$slap) {
// does contact have a salmon endpoint?
if(! strlen($url))
if (! strlen($url)) {
return;
}
if (! $owner['sprvkey']) {
@ -169,10 +170,12 @@ function slapper($owner,$url,$slap) {
}
}
logger('slapper for '.$url.' returned ' . $return_code);
if(! $return_code)
if (! $return_code) {
return(-1);
if(($return_code == 503) && (stristr($a->get_curl_headers(),'retry-after')))
}
if (($return_code == 503) && (stristr($a->get_curl_headers(),'retry-after'))) {
return(-1);
}
return ((($return_code >= 200) && ($return_code < 300)) ? 0 : 1);
}

View File

@ -105,10 +105,11 @@ function create_tags_from_itemuri($itemuri, $uid) {
$messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
if (count($messages)) {
foreach ($messages as $message)
foreach ($messages as $message) {
create_tags_from_item($message["id"]);
}
}
}
function update_items() {
global $db;

View File

@ -174,29 +174,34 @@ function add_shadow_entry($itemid) {
function update_thread_uri($itemuri, $uid) {
$messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
if (dbm::is_result($messages))
foreach ($messages as $message)
if (dbm::is_result($messages)) {
foreach ($messages as $message) {
update_thread($message["id"]);
}
}
}
function update_thread($itemid, $setmention = false) {
$items = q("SELECT `uid`, `guid`, `title`, `body`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`, `moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`, `gcontact-id`,
`deleted`, `origin`, `forum_mode`, `network`, `rendered-html`, `rendered-hash` FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid));
if (!dbm::is_result($items))
if (!dbm::is_result($items)) {
return;
}
$item = $items[0];
if ($setmention)
if ($setmention) {
$item["mention"] = 1;
}
$sql = "";
foreach ($item AS $field => $data)
if (!in_array($field, array("guid", "title", "body", "rendered-html", "rendered-hash"))) {
if ($sql != "")
if ($sql != "") {
$sql .= ", ";
}
$sql .= "`".$field."` = '".dbesc($data)."'";
}
@ -208,8 +213,9 @@ function update_thread($itemid, $setmention = false) {
// Updating a shadow item entry
$items = q("SELECT `id` FROM `item` WHERE `guid` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item["guid"]));
if (!$items)
if (!dbm::is_result($items)) {
return;
}
$result = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `rendered-html` = '%s', `rendered-hash` = '%s' WHERE `id` = %d",
dbesc($item["title"]),
@ -224,10 +230,12 @@ function update_thread($itemid, $setmention = false) {
function delete_thread_uri($itemuri, $uid) {
$messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
if(count($messages))
foreach ($messages as $message)
if (dbm::is_result($messages)) {
foreach ($messages as $message) {
delete_thread($message["id"], $itemuri);
}
}
}
function delete_thread($itemid, $itemuri = "") {
$item = q("SELECT `uid` FROM `thread` WHERE `iid` = %d", intval($itemid));

View File

@ -21,35 +21,41 @@ function update_gcontact_run(&$argv, &$argc){
$r = q("SELECT * FROM `gcontact` WHERE `id` = %d", intval($contact_id));
if (!$r)
if (!dbm::is_result($r)) {
return;
}
if (!in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)))
if (!in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) }
return;
}
$data = probe_url($r[0]["url"]);
if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
if ($r[0]["server_url"] != "")
if ($r[0]["server_url"] != "") {
poco_check_server($r[0]["server_url"], $r[0]["network"]);
}
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `id` = %d",
dbesc(datetime_convert()), intval($contact_id));
return;
}
if (($data["name"] == "") AND ($r[0]['name'] != ""))
if (($data["name"] == "") AND ($r[0]['name'] != "")) {
$data["name"] = $r[0]['name'];
}
if (($data["nick"] == "") AND ($r[0]['nick'] != ""))
if (($data["nick"] == "") AND ($r[0]['nick'] != "")) {
$data["nick"] = $r[0]['nick'];
}
if (($data["addr"] == "") AND ($r[0]['addr'] != ""))
if (($data["addr"] == "") AND ($r[0]['addr'] != "")) {
$data["addr"] = $r[0]['addr'];
}
if (($data["photo"] == "") AND ($r[0]['photo'] != ""))
if (($data["photo"] == "") AND ($r[0]['photo'] != "")) {
$data["photo"] = $r[0]['photo'];
}
q("UPDATE `gcontact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `photo` = '%s'
WHERE `id` = %d",