X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=mod%2Fping.php;h=00ee848dc419883cd4270074ed2174782598f870;hb=2336fa9d74ff395439066e9ffcf77a83fb0a35c1;hp=00620ddeb5936096a02233fea1992c9fc7661668;hpb=2ad162f991fdd32122b029398b9ab9e8801c0462;p=friendica.git diff --git a/mod/ping.php b/mod/ping.php index 00620ddeb5..00ee848dc4 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -1,18 +1,20 @@ array('invalid' => 1)); if ($format == 'json') { @@ -113,14 +114,15 @@ function ping_init(App $a) } } else { header("Content-type: text/xml"); - echo xml::from_array($data, $xml); + echo XML::from_array($data, $xml); } killme(); } $notifs = ping_get_notifications(local_user()); - $items_unseen = q("SELECT `item`.`id`, `item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`, + $items_unseen = q( + "SELECT `item`.`id`, `item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`, `item`.`contact-id`, `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`, `pitem`.`author-name` AS `pname`, `pitem`.`author-link` AS `plink` FROM `item` INNER JOIN `item` AS `pitem` ON `pitem`.`id` = `item`.`parent` @@ -128,7 +130,8 @@ function ping_init(App $a) `item`.`deleted` = 0 AND `item`.`uid` = %d AND `pitem`.`parent` != 0 AND `item`.`contact-id` != %d ORDER BY `item`.`created` DESC", - intval(local_user()), intval(local_user()) + intval(local_user()), + intval(local_user()) ); if (DBM::is_result($items_unseen)) { @@ -169,13 +172,15 @@ function ping_init(App $a) } } - $intros1 = q("SELECT `intro`.`id`, `intro`.`datetime`, + $intros1 = q( + "SELECT `intro`.`id`, `intro`.`datetime`, `fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo` FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id` WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid` != 0", intval(local_user()) ); - $intros2 = q("SELECT `intro`.`id`, `intro`.`datetime`, + $intros2 = q( + "SELECT `intro`.`id`, `intro`.`datetime`, `contact`.`name`, `contact`.`url`, `contact`.`photo` FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id` WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id` != 0", @@ -186,17 +191,20 @@ function ping_init(App $a) $intros = $intros1 + $intros2; $myurl = System::baseUrl() . '/profile/' . $a->user['nickname'] ; - $mails = q("SELECT `id`, `from-name`, `from-url`, `from-photo`, `created` FROM `mail` + $mails = q( + "SELECT `id`, `from-name`, `from-url`, `from-photo`, `created` FROM `mail` WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ", intval(local_user()), dbesc($myurl) ); $mail_count = count($mails); - if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){ - $regs = q("SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created`, COUNT(*) AS `total` + if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()) { + $regs = q( + "SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created`, COUNT(*) AS `total` FROM `contact` RIGHT JOIN `register` ON `register`.`uid` = `contact`.`uid` - WHERE `contact`.`self` = 1"); + WHERE `contact`.`self` = 1" + ); if (DBM::is_result($regs)) { $register_count = $regs[0]['total']; @@ -206,7 +214,8 @@ function ping_init(App $a) $cachekey = "ping_init:".local_user(); $ev = Cache::get($cachekey); if (is_null($ev)) { - $ev = q("SELECT type, start, adjust FROM `event` + $ev = q( + "SELECT type, start, adjust FROM `event` WHERE `event`.`uid` = %d AND `start` < '%s' AND `finish` > '%s' and `ignore` = 0 ORDER BY `start` ASC ", intval(local_user()), @@ -223,21 +232,21 @@ function ping_init(App $a) if ($all_events) { $str_now = datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d'); - foreach($ev as $x) { + foreach ($ev as $x) { $bd = false; if ($x['type'] === 'birthday') { $birthdays ++; $bd = true; - } - else { + } else { $events ++; } if (datetime_convert('UTC', ((intval($x['adjust'])) ? $a->timezone : 'UTC'), $x['start'], 'Y-m-d') === $str_now) { $all_events_today ++; - if ($bd) + if ($bd) { $birthdays_today ++; - else + } else { $events_today ++; + } } } } @@ -311,7 +320,7 @@ function ping_init(App $a) } // sort notifications by $[]['date'] - $sort_function = function($a, $b) { + $sort_function = function ($a, $b) { $adate = strtotime($a['date']); $bdate = strtotime($b['date']); @@ -402,7 +411,7 @@ function ping_init(App $a) $data = ping_format_xml_data($data, $sysnotify_count, $notifications, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen); header("Content-type: text/xml"); - echo xml::from_array(array("result" => $data), $xml); + echo XML::from_array(array("result" => $data), $xml); } killme(); @@ -426,7 +435,8 @@ function ping_get_notifications($uid) $a = get_app(); do { - $r = q("SELECT `notify`.*, `item`.`visible`, `item`.`spam`, `item`.`deleted` + $r = q( + "SELECT `notify`.*, `item`.`visible`, `item`.`spam`, `item`.`deleted` FROM `notify` LEFT JOIN `item` ON `item`.`id` = `notify`.`iid` WHERE `notify`.`uid` = %d AND `notify`.`msg` != '' AND NOT (`notify`.`type` IN (%d, %d)) @@ -448,7 +458,7 @@ function ping_get_notifications($uid) $offset += 50; } - foreach ($r AS $notification) { + foreach ($r as $notification) { if (is_null($notification["visible"])) { $notification["visible"] = true; } @@ -468,7 +478,8 @@ function ping_get_notifications($uid) $notification["name"] = strip_tags(bbcode($notification["name"])); $notification["message"] = format_notification_message($notification["name"], strip_tags(bbcode($notification["msg"]))); - q("UPDATE `notify` SET `name_cache` = '%s', `msg_cache` = '%s' WHERE `id` = %d", + q( + "UPDATE `notify` SET `name_cache` = '%s', `msg_cache` = '%s' WHERE `id` = %d", dbesc($notification["name"]), dbesc($notification["message"]), intval($notification["id"]) @@ -477,8 +488,9 @@ function ping_get_notifications($uid) $notification["href"] = System::baseUrl() . "/notify/view/" . $notification["id"]; - if ($notification["visible"] && !$notification["spam"] && - !$notification["deleted"] && !is_array($result[$notification["parent"]])) { + if ($notification["visible"] && !$notification["spam"] + && !$notification["deleted"] && !is_array($result[$notification["parent"]]) + ) { // Should we condense the notifications or show them all? if (PConfig::get(local_user(), 'system', 'detailed_notif')) { $result[$notification["id"]] = $notification; @@ -496,19 +508,19 @@ function ping_get_notifications($uid) * @brief Backward-compatible XML formatting for ping.php output * @deprecated * - * @param array $data The initial ping data array - * @param int $sysnotify_count Number of unseen system notifications - * @param array $notifs Complete list of notification - * @param array $sysmsgs List of system notice messages - * @param array $sysmsgs_info List of system info messages - * @param int $groups_unseen Number of unseen group items - * @param int $forums_unseen Number of unseen forum items + * @param array $data The initial ping data array + * @param int $sysnotify Number of unseen system notifications + * @param array $notifs Complete list of notification + * @param array $sysmsgs List of system notice messages + * @param array $sysmsgs_info List of system info messages + * @param int $groups_unseen Number of unseen group items + * @param int $forums_unseen Number of unseen forum items * @return array XML-transform ready data array */ function ping_format_xml_data($data, $sysnotify, $notifs, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen) { $notifications = array(); - foreach($notifs as $key => $notif) { + foreach ($notifs as $key => $notif) { $notifications[$key . ':note'] = $notif['message']; $notifications[$key . ':@attributes'] = array( @@ -524,10 +536,10 @@ function ping_format_xml_data($data, $sysnotify, $notifs, $sysmsgs, $sysmsgs_inf } $sysmsg = array(); - foreach ($sysmsgs as $key => $m){ + foreach ($sysmsgs as $key => $m) { $sysmsg[$key . ':notice'] = $m; } - foreach ($sysmsgs_info as $key => $m){ + foreach ($sysmsgs_info as $key => $m) { $sysmsg[$key . ':info'] = $m; }