X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fpoco.php;h=422bfe5b7c88e0957b3842c54840fefb869d2fa0;hb=fbb84ee219678d7f8a0f2fde6c8d00358c3fc931;hp=ae03aef2cdba27e352834301bde64db12b1149dc;hpb=2f47d63a296821ac2cb34d0f31fe84e30fe58841;p=friendica.git diff --git a/mod/poco.php b/mod/poco.php index ae03aef2cd..422bfe5b7c 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -1,6 +1,8 @@ argc > 1 && $a->argv[1] === '@server') { + $ret = poco_serverlist(); + header('Content-type: application/json'); + echo json_encode($ret); + killme(); + } if($a->argc > 1 && $a->argv[1] === '@global') { $global = true; $update_limit = date("Y-m-d H:i:s", time() - 30 * 86400); @@ -43,7 +52,7 @@ function poco_init(&$a) { where `user`.`nickname` = '%s' and `profile`.`is-default` = 1 limit 1", dbesc($user) ); - if(! count($r) || $r[0]['hidewall'] || $r[0]['hide-friends']) + if(! dbm::is_result($r) || $r[0]['hidewall'] || $r[0]['hide-friends']) http_status_exit(404); $user = $r[0]; @@ -61,8 +70,7 @@ function poco_init(&$a) { $update_limit = date("Y-m-d H:i:s",strtotime($_GET['updatedSince'])); if ($global) { - //$r = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `updated` >= '%s' AND ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND `network` IN ('%s')", - $r = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `updated` >= '%s' AND `updated` >= `last_failure` AND `network` IN ('%s', '%s', '%s')", + $r = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `updated` >= '%s' AND `updated` >= `last_failure` AND NOT `hide` AND `network` IN ('%s', '%s', '%s')", dbesc($update_limit), dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), @@ -82,7 +90,7 @@ function poco_init(&$a) { dbesc(NETWORK_STATUSNET) ); } - if(count($r)) + if (dbm::is_result($r)) $totalResults = intval($r[0]['total']); else $totalResults = 0; @@ -94,8 +102,7 @@ function poco_init(&$a) { if ($global) { logger("Start global query", LOGGER_DEBUG); - //$r = q("SELECT * FROM `gcontact` WHERE `updated` > '%s' AND `network` IN ('%s') AND ((`last_contact` >= `last_failure`) OR (`updated` > `last_failure`)) LIMIT %d, %d", - $r = q("SELECT * FROM `gcontact` WHERE `updated` > '%s' AND `network` IN ('%s', '%s', '%s') AND `updated` > `last_failure` + $r = q("SELECT * FROM `gcontact` WHERE `updated` > '%s' AND NOT `hide` AND `network` IN ('%s', '%s', '%s') AND `updated` > `last_failure` ORDER BY `updated` DESC LIMIT %d, %d", dbesc($update_limit), dbesc(NETWORK_DFRN), @@ -106,9 +113,11 @@ function poco_init(&$a) { ); } elseif($system_mode) { logger("Start system mode query", LOGGER_DEBUG); - $r = q("SELECT `contact`.*, `profile`.`about` AS `pabout`, `profile`.`locality` AS `plocation`, `profile`.`pub_keywords`, `profile`.`gender` AS `pgender`, - `profile`.`address` AS `paddress`, `profile`.`region` AS `pregion`, `profile`.`postal-code` AS `ppostalcode`, `profile`.`country-name` AS `pcountry` + $r = q("SELECT `contact`.*, `profile`.`about` AS `pabout`, `profile`.`locality` AS `plocation`, `profile`.`pub_keywords`, + `profile`.`gender` AS `pgender`, `profile`.`address` AS `paddress`, `profile`.`region` AS `pregion`, + `profile`.`postal-code` AS `ppostalcode`, `profile`.`country-name` AS `pcountry`, `user`.`account-type` FROM `contact` INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid` + INNER JOIN `user` ON `user`.`uid` = `contact`.`uid` WHERE `self` = 1 AND `profile`.`is-default` AND `contact`.`uid` IN (SELECT `uid` FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1) LIMIT %d, %d", intval($startIndex), @@ -157,6 +166,7 @@ function poco_init(&$a) { 'gender' => false, 'tags' => false, 'address' => false, + 'contactType' => false, 'generation' => false ); @@ -170,8 +180,8 @@ function poco_init(&$a) { } if(is_array($r)) { - if(count($r)) { - foreach($r as $rr) { + if (dbm::is_result($r)) { + foreach ($r as $rr) { if (!isset($rr['generation'])) { if ($global) $rr['generation'] = 3; @@ -209,6 +219,9 @@ function poco_init(&$a) { if (($rr['keywords'] == "") AND isset($rr['pub_keywords'])) $rr['keywords'] = $rr['pub_keywords']; + if (isset($rr['account-type'])) + $rr['contact-type'] = $rr['account-type']; + $about = Cache::get("about:".$rr['updated'].":".$rr['nurl']); if (is_null($about)) { $about = bbcode($rr['about'], false, false); @@ -302,13 +315,14 @@ function poco_init(&$a) { $entry['address']['country'] = $rr['pcountry']; } + if($fields_ret['contactType']) + $entry['contactType'] = intval($rr['contact-type']); + $ret['entry'][] = $entry; } - } - else + } else $ret['entry'][] = array(); - } - else + } else http_status_exit(500); logger("End of poco", LOGGER_DEBUG); @@ -322,8 +336,7 @@ function poco_init(&$a) { header('Content-type: application/json'); echo json_encode($ret); killme(); - } - else + } else http_status_exit(500);