]> git.mxchange.org Git - friendica.git/blobdiff - mod/poco.php
Merge pull request #4170 from MrPetovan/bug/4155-remove-proxy-oembed
[friendica.git] / mod / poco.php
index 97f518a1a55cbcc1a8fc02b6f605f5e35a824a17..2e2791fc1ee6b763c008d79364dfb4192a59d36d 100644 (file)
@@ -4,7 +4,10 @@
 // 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) {
        $system_mode = false;
@@ -18,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;
@@ -30,9 +33,8 @@ function poco_init(App $a) {
        $global = false;
 
        if ($a->argc > 1 && $a->argv[1] === '@server') {
-               require_once 'include/socgraph.php';
                // 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,12 +57,12 @@ function poco_init(App $a) {
                $cid = intval($a->argv[4]);
        }
 
-       if (! $system_mode AND ! $global) {
+       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($users) || $users[0]['hidewall'] || $users[0]['hide-friends']) {
+               if (! DBM::is_result($users) || $users[0]['hidewall'] || $users[0]['hide-friends']) {
                        http_status_exit(404);
                }
 
@@ -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'])) {
@@ -306,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;
                                        }
                                }