]> git.mxchange.org Git - friendica.git/blobdiff - mod/poco.php
Move /profile_photo to Module\Settings\Profile\Photo
[friendica.git] / mod / poco.php
index 064e0e9a85f919178aefcd6372a4092efd324a69..8e7d63418afba2271c32b294fa15a2cef2240277 100644 (file)
@@ -6,13 +6,11 @@
 
 use Friendica\App;
 use Friendica\Content\Text\BBCode;
-use Friendica\Core\Cache;
-use Friendica\Core\Config;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
-use Friendica\Core\System;
 use Friendica\Database\DBA;
+use Friendica\DI;
 use Friendica\Protocol\PortableContact;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Strings;
@@ -21,8 +19,8 @@ use Friendica\Util\XML;
 function poco_init(App $a) {
        $system_mode = false;
 
-       if (intval(Config::get('system', 'block_public')) || (Config::get('system', 'block_local_dir'))) {
-               System::httpExit(401);
+       if (intval(DI::config()->get('system', 'block_public')) || (DI::config()->get('system', 'block_local_dir'))) {
+               throw new \Friendica\Network\HTTPException\ForbiddenException();
        }
 
        if ($a->argc > 1) {
@@ -31,12 +29,12 @@ function poco_init(App $a) {
        if (empty($nickname)) {
                $c = q("SELECT * FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1");
                if (!DBA::isResult($c)) {
-                       System::httpExit(401);
+                       throw new \Friendica\Network\HTTPException\ForbiddenException();
                }
                $system_mode = true;
        }
 
-       $format = defaults($_GET, 'format', 'json');
+       $format = ($_GET['format'] ?? '') ?: 'json';
 
        $justme = false;
        $global = false;
@@ -73,7 +71,7 @@ function poco_init(App $a) {
                        DBA::escape($nickname)
                );
                if (! DBA::isResult($users) || $users[0]['hidewall'] || $users[0]['hide-friends']) {
-                       System::httpExit(404);
+                       throw new \Friendica\Network\HTTPException\NotFoundException();
                }
 
                $user = $users[0];
@@ -255,10 +253,10 @@ function poco_init(App $a) {
                                if (isset($contact['account-type'])) {
                                        $contact['contact-type'] = $contact['account-type'];
                                }
-                               $about = Cache::get("about:" . $contact['updated'] . ":" . $contact['nurl']);
+                               $about = DI::cache()->get("about:" . $contact['updated'] . ":" . $contact['nurl']);
                                if (is_null($about)) {
                                        $about = BBCode::convert($contact['about'], false);
-                                       Cache::set("about:" . $contact['updated'] . ":" . $contact['nurl'], $about);
+                                       DI::cache()->set("about:" . $contact['updated'] . ":" . $contact['nurl'], $about);
                                }
 
                                // Non connected persons can only see the keywords of a Diaspora account
@@ -371,8 +369,9 @@ function poco_init(App $a) {
                        $ret['entry'][] = [];
                }
        } else {
-               System::httpExit(500);
+               throw new \Friendica\Network\HTTPException\InternalServerErrorException();
        }
+
        Logger::log("End of poco", Logger::DEBUG);
 
        if ($format === 'xml') {
@@ -385,6 +384,6 @@ function poco_init(App $a) {
                echo json_encode($ret);
                exit();
        } else {
-               System::httpExit(500);
+               throw new \Friendica\Network\HTTPException\InternalServerErrorException();
        }
 }