X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fpoco.php;h=2e2791fc1ee6b763c008d79364dfb4192a59d36d;hb=c54a2c1e83822f6e043b449468570d2c9ed3ab3a;hp=84fdcd325d5d09a24a9f008264260b4c99097598;hpb=70cc2ccc7a5294c43fb73f55a71c06d9bb4390c4;p=friendica.git diff --git a/mod/poco.php b/mod/poco.php index 84fdcd325d..2e2791fc1e 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -4,13 +4,15 @@ // https://web.archive.org/web/20160405005550/http://portablecontacts.net/draft-spec.html use Friendica\App; +use Friendica\Core\Cache; +use Friendica\Core\Config; +use Friendica\Database\DBM; +use Friendica\Protocol\PortableContact; function poco_init(App $a) { - require_once 'include/bbcode.php'; - $system_mode = false; - if (intval(get_config('system', 'block_public')) || (get_config('system', 'block_local_dir'))) { + if (intval(Config::get('system', 'block_public')) || (Config::get('system', 'block_local_dir'))) { http_status_exit(401); } @@ -19,7 +21,7 @@ function poco_init(App $a) { } if (! x($user)) { $c = q("SELECT * FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1"); - if (! dbm::is_result($c)) { + if (! DBM::is_result($c)) { http_status_exit(401); } $system_mode = true; @@ -32,7 +34,7 @@ function poco_init(App $a) { if ($a->argc > 1 && $a->argv[1] === '@server') { // List of all servers that this server knows - $ret = poco_serverlist(); + $ret = PortableContact::serverlist(); header('Content-type: application/json'); echo json_encode($ret); killme(); @@ -55,16 +57,16 @@ function poco_init(App $a) { $cid = intval($a->argv[4]); } - if (! $system_mode AND ! $global) { - $contacts = q("SELECT `user`.*,`profile`.`hide-friends` from user left join profile on `user`.`uid` = `profile`.`uid` + if (! $system_mode && ! $global) { + $users = q("SELECT `user`.*,`profile`.`hide-friends` from user left join profile on `user`.`uid` = `profile`.`uid` where `user`.`nickname` = '%s' and `profile`.`is-default` = 1 limit 1", dbesc($user) ); - if (! dbm::is_result($contacts) || $contacts[0]['hidewall'] || $contacts[0]['hide-friends']) { + if (! DBM::is_result($users) || $users[0]['hidewall'] || $users[0]['hide-friends']) { http_status_exit(404); } - $user = $contacts[0]; + $user = $users[0]; } if ($justme) { @@ -100,7 +102,7 @@ function poco_init(App $a) { dbesc(NETWORK_STATUSNET) ); } - if (dbm::is_result($contacts)) { + if (DBM::is_result($contacts)) { $totalResults = intval($contacts[0]['total']); } else { $totalResults = 0; @@ -157,7 +159,7 @@ function poco_init(App $a) { if (x($_GET, 'filtered')) { $ret['filtered'] = false; } - if (x($_GET, 'updatedSince') AND ! $global) { + if (x($_GET, 'updatedSince') && ! $global) { $ret['updatedSince'] = false; } $ret['startIndex'] = (int) $startIndex; @@ -195,7 +197,7 @@ function poco_init(App $a) { } if (is_array($contacts)) { - if (dbm::is_result($contacts)) { + if (DBM::is_result($contacts)) { foreach ($contacts as $contact) { if (! isset($contact['generation'])) { if ($global) { @@ -207,21 +209,21 @@ function poco_init(App $a) { } } - if (($contact['about'] == "") AND isset($contact['pabout'])) { + if (($contact['about'] == "") && isset($contact['pabout'])) { $contact['about'] = $contact['pabout']; } if ($contact['location'] == "") { if (isset($contact['plocation'])) { $contact['location'] = $contact['plocation']; } - if (isset($contact['pregion']) AND ( $contact['pregion'] != "")) { + if (isset($contact['pregion']) && ( $contact['pregion'] != "")) { if ($contact['location'] != "") { $contact['location'] .= ", "; } $contact['location'] .= $contact['pregion']; } - if (isset($contact['pcountry']) AND ( $contact['pcountry'] != "")) { + if (isset($contact['pcountry']) && ( $contact['pcountry'] != "")) { if ($contact['location'] != "") { $contact['location'] .= ", "; } @@ -229,10 +231,10 @@ function poco_init(App $a) { } } - if (($contact['gender'] == "") AND isset($contact['pgender'])) { + if (($contact['gender'] == "") && isset($contact['pgender'])) { $contact['gender'] = $contact['pgender']; } - if (($contact['keywords'] == "") AND isset($contact['pub_keywords'])) { + if (($contact['keywords'] == "") && isset($contact['pub_keywords'])) { $contact['keywords'] = $contact['pub_keywords']; } if (isset($contact['account-type'])) { @@ -240,6 +242,7 @@ function poco_init(App $a) { } $about = Cache::get("about:" . $contact['updated'] . ":" . $contact['nurl']); if (is_null($about)) { + require_once 'include/bbcode.php'; $about = bbcode($contact['about'], false, false); Cache::set("about:" . $contact['updated'] . ":" . $contact['nurl'], $about); } @@ -305,7 +308,7 @@ function poco_init(App $a) { if ($entry['network'] == NETWORK_STATUSNET) { $entry['network'] = NETWORK_OSTATUS; } - if (($entry['network'] == "") AND ($contact['self'])) { + if (($entry['network'] == "") && ($contact['self'])) { $entry['network'] = NETWORK_DFRN; } }