]> git.mxchange.org Git - friendica.git/blobdiff - mod/poco.php
Preparation for being able to comment every public item
[friendica.git] / mod / poco.php
index 9e88c4ac41ba2209c26fd801774f5d36b8605c0c..2e2791fc1ee6b763c008d79364dfb4192a59d36d 100644 (file)
@@ -4,14 +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';
-       require_once 'include/socgraph.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);
        }
 
@@ -20,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;
@@ -33,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();
@@ -56,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) {
@@ -101,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;
@@ -158,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;
@@ -196,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) {
@@ -208,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'] .= ", ";
                                                }
@@ -230,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'])) {
@@ -241,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);
                                }
@@ -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;
                                        }
                                }