]> git.mxchange.org Git - friendica.git/commitdiff
New function to exit the program
authorMichael <heluecht@pirati.ca>
Wed, 18 May 2022 02:13:54 +0000 (02:13 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 18 May 2022 02:13:54 +0000 (02:13 +0000)
27 files changed:
mod/fbrowser.php
mod/photos.php
mod/pubsub.php
mod/pubsubhubbub.php
mod/share.php
mod/tagger.php
mod/wall_attach.php
mod/wall_upload.php
src/App.php
src/App/Page.php
src/Core/System.php
src/Module/Admin/PhpInfo.php
src/Module/Attach.php
src/Module/Contact/Hovercard.php
src/Module/Debug/ItemBody.php
src/Module/Group.php
src/Module/HTTPException/PageNotFound.php
src/Module/Oembed.php
src/Module/PermissionTooltip.php
src/Module/Photo.php
src/Module/Proxy.php
src/Module/RobotsTxt.php
src/Module/Settings/UserExport.php
src/Module/Theme.php
src/Module/ThemeDetails.php
src/Module/Update/Network.php
src/Util/JsonLD.php

index 4e887c7eb0456a99a31452345ff79775d3d01c63..81284d6b91ef27d654d9c078d2333ab295b41176 100644 (file)
@@ -39,13 +39,11 @@ use Friendica\Util\Strings;
 function fbrowser_content(App $a)
 {
        if (!local_user()) {
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        if (DI::args()->getArgc() == 1) {
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        // Needed to match the correct template in a module that uses a different theme than the user/site/default
index fa8a434c44a14382e0eaebca3344298145abdc6f..52d749bb46f841f3f37e93fc91d76506ba261dd5 100644 (file)
@@ -158,8 +158,7 @@ function photos_post(App $a)
 
        if (!$can_post) {
                notice(DI::l10n()->t('Permission denied.'));
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        $owner_record = User::getOwnerDataById($page_owner_uid);
@@ -167,8 +166,7 @@ function photos_post(App $a)
        if (!$owner_record) {
                notice(DI::l10n()->t('Contact information unavailable'));
                DI::logger()->info('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid);
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        $aclFormatter = DI::aclFormatter();
index 630b68f50428403f013eaaf08c95ffef157a9b0a..918c55ee14cb817f192232c675ff112ea79792c9 100644 (file)
@@ -22,6 +22,7 @@
 use Friendica\App;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
+use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
@@ -38,8 +39,7 @@ function hub_return($valid, $body)
        } else {
                throw new \Friendica\Network\HTTPException\NotFoundException();
        }
-       DI::page()->logRuntime();
-       exit();
+       System::exit();
 }
 
 // when receiving an XML feed, always return OK
index 5300f783d4acdc0944d7ca980b0ae1fb95f5c7ec..5dda9ee0af966fc9a97da01049317d8d594fb889 100644 (file)
@@ -21,6 +21,7 @@
 
 use Friendica\App;
 use Friendica\Core\Logger;
+use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\PushSubscriber;
@@ -142,6 +143,5 @@ function pubsubhubbub_init(App $a) {
 
                throw new \Friendica\Network\HTTPException\AcceptedException();
        }
-       DI::page()->logRuntime();
-       exit();
+       System::exit();
 }
index dde3864bc4ccf9d4b0fc7623527903633b96ef4e..2f836c5aa06cc64aed2e9e2eedce9c88c59ecca9 100644 (file)
@@ -21,6 +21,7 @@
 
 use Friendica\App;
 use Friendica\Content\Text\BBCode;
+use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Item;
@@ -30,8 +31,7 @@ function share_init(App $a) {
        $post_id = ((DI::args()->getArgc() > 1) ? intval(DI::args()->getArgv()[1]) : 0);
 
        if (!$post_id || !local_user()) {
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        $fields = ['private', 'body', 'author-name', 'author-link', 'author-avatar',
@@ -39,8 +39,7 @@ function share_init(App $a) {
        $item = Post::selectFirst($fields, ['id' => $post_id]);
 
        if (!DBA::isResult($item) || $item['private'] == Item::PRIVATE) {
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        if (strpos($item['body'], "[/share]") !== false) {
@@ -58,6 +57,5 @@ function share_init(App $a) {
        }
 
        echo $o;
-       DI::page()->logRuntime();
-       exit();
+       System::exit();
 }
index 4c0af4a53227692da3b079554ad3cf4fd837c7bc..1acce4b0b60e2cd56c150c62207bcdb0a6a028a2 100644 (file)
@@ -167,6 +167,5 @@ EOT;
        $post = Post::selectFirst(['uri-id', 'uid'], ['id' => $post_id]);
 
        Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $post['uri-id'], $post['uid']);
-       DI::page()->logRuntime();
-       exit();
+       System::exit();
 }
index 6dfa40b09588da9b58132deb82dddaca7966ec76..43f4681df336e226c346f559f22bbf5ba66157d5 100644 (file)
@@ -67,16 +67,14 @@ function wall_attach_post(App $a) {
                        System::jsonExit(['error' => DI::l10n()->t('Permission denied.')]);
                }
                notice(DI::l10n()->t('Permission denied.') . EOL );
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        if (empty($_FILES['userfile'])) {
                if ($r_json) {
                        System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
                }
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        $src      = $_FILES['userfile']['tmp_name'];
@@ -99,8 +97,7 @@ function wall_attach_post(App $a) {
                } else {
                        notice($msg);
                }
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        if ($maxfilesize && $filesize > $maxfilesize) {
@@ -111,8 +108,7 @@ function wall_attach_post(App $a) {
                } else {
                        echo $msg . EOL;
                }
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        $newid = Attach::storeFile($src, $page_owner_uid, $filename, '<' . $page_owner_cid . '>');
@@ -126,8 +122,7 @@ function wall_attach_post(App $a) {
                } else {
                        echo $msg . EOL;
                }
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        if ($r_json) {
@@ -137,7 +132,6 @@ function wall_attach_post(App $a) {
        $lf = "\n";
 
        echo  $lf . $lf . '[attachment]' . $newid . '[/attachment]' . $lf;
-       DI::page()->logRuntime();
-       exit();
+       System::exit();
        // NOTREACHED
 }
index 8b8b1df9a43958da032bebc3cb69526c4158b974..36e313cecef2e4fd5b60bee68ee1eac1c5e0ef5e 100644 (file)
@@ -89,16 +89,14 @@ function wall_upload_post(App $a, $desktopmode = true)
                        System::jsonExit(['error' => DI::l10n()->t('Permission denied.')]);
                }
                notice(DI::l10n()->t('Permission denied.'));
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        if (empty($_FILES['userfile']) && empty($_FILES['media'])) {
                if ($r_json) {
                        System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
                }
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        $src = '';
@@ -150,8 +148,7 @@ function wall_upload_post(App $a, $desktopmode = true)
                        System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
                }
                notice(DI::l10n()->t('Invalid request.'));
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        $filetype = Images::getMimeTypeBySource($src, $filename, $filetype);
@@ -170,8 +167,7 @@ function wall_upload_post(App $a, $desktopmode = true)
                } else {
                        echo  $msg. EOL;
                }
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        $Image->orient($src);
@@ -209,8 +205,7 @@ function wall_upload_post(App $a, $desktopmode = true)
                        } else {
                                echo  $msg. EOL;
                        }
-                       DI::page()->logRuntime();
-                       exit();
+                       System::exit();
                }
        }
 
@@ -234,8 +229,7 @@ function wall_upload_post(App $a, $desktopmode = true)
                } else {
                        echo  $msg. EOL;
                }
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        if ($width > 640 || $height > 640) {
@@ -287,7 +281,6 @@ function wall_upload_post(App $a, $desktopmode = true)
        }
 
        echo  "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id . '][img]' . DI::baseUrl() . "/photo/{$resource_id}-{$smallest}.".$Image->getExt()."[/img][/url]\n\n";
-       DI::page()->logRuntime();
-       exit();
+       System::exit();
        // NOTREACHED
 }
index d85de3670975c1990c9beefe3090368a78f42c35..07296cecf08fb45e6f0b4b7f26e388ada2a9cd95 100644 (file)
@@ -713,13 +713,13 @@ class App
                        $this->profiler->set(microtime(true) - $timestamp, 'content');
                        if ($response->getHeaderLine(ICanCreateResponses::X_HEADER) === ICanCreateResponses::TYPE_HTML) {
                                $page->run($this, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig);
-                               $page->logRuntime();
                        } else {
                                $page->exit($response);
                        }
                } catch (HTTPException $e) {
                        (new ModuleHTTPException())->rawContent($e);
                }
+               $page->logRuntime();
        }
 
        /**
index 16c4934e315e4f1a229385bf3dfbf8fd18dbd9c3..305b2962b9c70e856ba31c67ab28394e82d1c457 100644 (file)
@@ -419,7 +419,6 @@ class Page implements ArrayAccess
                }
 
                echo $response->getBody();
-               $this->logRuntime();
        }
 
        /**
index 7b0a887cdff60ccc837c6e27deb1adc86821b34b..10fc5c7d4e335e6cdc725affb1672f93c572ea8d 100644 (file)
@@ -295,7 +295,7 @@ class System
                DI::apiResponse()->addContent(XML::fromArray(["result" => $result], $xml));
                DI::page()->exit(DI::apiResponse()->generate());
 
-               exit();
+               self::exit();
        }
 
        /**
@@ -315,7 +315,7 @@ class System
                DI::apiResponse()->addContent($content);
                DI::page()->exit(DI::apiResponse()->generate());
 
-               exit();
+               self::exit();
        }
 
        /**
@@ -331,7 +331,8 @@ class System
                DI::apiResponse()->setType($responce, $content_type);
                DI::apiResponse()->addContent($content);
                DI::page()->exit(DI::apiResponse()->generate());
-               exit();
+
+               self::exit();
        }
 
        public static function jsonError($httpCode, $content, $content_type = 'application/json')
@@ -359,6 +360,16 @@ class System
                DI::apiResponse()->setType(Response::TYPE_JSON, $content_type);
                DI::apiResponse()->addContent(json_encode($content, $options));
                DI::page()->exit(DI::apiResponse()->generate());
+
+               self::exit();
+       }
+
+       /**
+        * Exit the program execution.
+        */
+       public static function exit()
+       {
+               DI::page()->logRuntime();
                exit();
        }
 
@@ -448,8 +459,7 @@ class System
                        case 307:
                                throw new TemporaryRedirectException();
                }
-               DI::page()->logRuntime();
-               exit();
+               self::exit();
        }
 
        /**
@@ -522,8 +532,7 @@ class System
                echo str_replace("\t", "       ", $o);
                echo "</section>";
                echo "</body></html>\r\n";
-               DI::page()->logRuntime();
-               exit();
+               self::exit();
        }
 
        /**
index feaa9de237f21e4b8845974c17b226377f9a01b9..c51ed27c011d00664312ffb38711c2d3e0cfe2a5 100644 (file)
@@ -21,7 +21,7 @@
 
 namespace Friendica\Module\Admin;
 
-use Friendica\DI;
+use Friendica\Core\System;
 use Friendica\Module\BaseAdmin;
 
 class PhpInfo extends BaseAdmin
@@ -31,7 +31,6 @@ class PhpInfo extends BaseAdmin
                self::checkAdminAccess();
 
                phpinfo();
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 }
index fc7ba74d5948ba1582ea8474434a5a94cf43c3af..a73beb2b8dd03585c1e4c498a196bf0a2ccbb2a0 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module;
 
 use Friendica\BaseModule;
 use Friendica\Core\Logger;
+use Friendica\Core\System;
 use Friendica\DI;
 use Friendica\Model\Attach as MAttach;
 
@@ -72,8 +73,7 @@ class Attach extends BaseModule
                }
 
                echo $data;
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
                // NOTREACHED
        }
 }
index 2bf6f63ed271eade063ec38cf2d4cb5c86d9f804..440c46c5023400e4a5013a3ec1f08e208b2a23af 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Module\Contact;
 use Friendica\BaseModule;
 use Friendica\Core\Renderer;
 use Friendica\Core\Session;
+use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
@@ -107,7 +108,6 @@ class Hovercard extends BaseModule
                ]);
 
                echo $o;
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 }
index e066e7656a028c0fd00b035e1d2d7283bc2a961c..a9a3c0b50b0f593022b59568b562cb1d324d79ef 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Module\Debug;
 
 use Friendica\BaseModule;
+use Friendica\Core\System;
 use Friendica\DI;
 use Friendica\Model\Post;
 use Friendica\Network\HTTPException;
@@ -48,8 +49,7 @@ class ItemBody extends BaseModule
                if (!empty($item)) {
                        if (DI::mode()->isAjax()) {
                                echo str_replace("\n", '<br />', $item['body']);
-                               DI::page()->logRuntime();
-                               exit();
+                               System::exit();
                        } else {
                                return str_replace("\n", '<br />', $item['body']);
                        }
index 4825debd02942ca58504895a123885ab2113fd66..cd07e978123b7a2db3cdebac8b4614a2a4bfb4cc 100644 (file)
@@ -360,8 +360,7 @@ class Group extends BaseModule
                if ($change) {
                        $tpl = Renderer::getMarkupTemplate('groupeditor.tpl');
                        echo Renderer::replaceMacros($tpl, $context);
-                       DI::page()->logRuntime();
-                       exit();
+                       System::exit();
                }
 
                return Renderer::replaceMacros($tpl, $context);
index ba34df8544db7780cb2eca9688fcac0f170a4b82..4cfa35276d24aeeb8b7fe4838eb98d83e5dbc361 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Module\HTTPException;
 
 use Friendica\BaseModule;
+use Friendica\Core\System;
 use Friendica\DI;
 use Friendica\Network\HTTPException;
 use Psr\Http\Message\ResponseInterface;
@@ -47,8 +48,7 @@ class PageNotFound extends BaseModule
                $queryString = $this->server['QUERY_STRING'];
                // Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit.
                if (!empty($queryString) && preg_match('/{[0-9]}/', $queryString) !== 0) {
-                       DI::page()->logRuntime();
-                       exit();
+                       System::exit();
                }
 
                if (!empty($queryString) && ($queryString === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
index 49b479204299b59eed3993f66e1752aff1670bd6..be8168271b3ece9964a48090d78f9ea8536a41fb 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module;
 
 use Friendica\BaseModule;
 use Friendica\Content;
+use Friendica\Core\System;
 use Friendica\DI;
 use Friendica\Util\Strings;
 
@@ -43,16 +44,14 @@ class Oembed extends BaseModule
                if (DI::args()->getArgv()[1] == 'b2h') {
                        $url = ["", trim(hex2bin($_REQUEST['url']))];
                        echo Content\OEmbed::replaceCallback($url);
-                       DI::page()->logRuntime();
-                       exit();
+                       System::exit();
                }
 
                // Unused form: /oembed/h2b?text=...
                if (DI::args()->getArgv()[1] == 'h2b') {
                        $text = trim(hex2bin($_REQUEST['text']));
                        echo Content\OEmbed::HTML2BBCode($text);
-                       DI::page()->logRuntime();
-                       exit();
+                       System::exit();
                }
 
                // @TODO: Replace with parameter from router
@@ -70,7 +69,6 @@ class Oembed extends BaseModule
                        echo $j->html;
                        echo '</body></html>';
                }
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 }
index edc839a38e052da3e637fa7fe858b4a114f63840..07faa72e3e1a63b0fd7df5962ae4b2ba14944b68 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Module;
 
 use Friendica\Core\Hook;
+use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\APContact;
@@ -164,8 +165,7 @@ class PermissionTooltip extends \Friendica\BaseModule
                } else {
                        echo $o . $receivers;
                }
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        /**
index d050188aacceac3a49008aed6f51056d5c2e0bb6..134cade65021696b3f8cc2461ca48287e5e15c8f 100644 (file)
@@ -32,6 +32,7 @@ use Friendica\Model\Post;
 use Friendica\Model\Profile;
 use Friendica\Core\Storage\Type\ExternalResource;
 use Friendica\Core\Storage\Type\SystemResource;
+use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Model\User;
 use Friendica\Network\HTTPClient\Client\HttpClientAccept;
@@ -224,8 +225,7 @@ class Photo extends BaseModule
                                'output' => number_format($output, 3), 'rest' => number_format($rest, 3)]);
                }
 
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 
        private static function getPhotoByid(int $id, $type, $customsize)
index 0af49762e9d572d440ab847ff7cc69b6f417c5f0..90f118580026a055c008b0154de7cd0df41c2156 100644 (file)
@@ -202,7 +202,6 @@ class Proxy extends BaseModule
                header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (31536000)) . ' GMT');
                header('Cache-Control: max-age=31536000');
                echo $img->asString();
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 }
index afc8ebf8f0dfb4ad4fdea41d15f3d79b94ed7c70..3651382a00b4f5f7c3aeb397840a97e58b389458 100644 (file)
@@ -22,7 +22,7 @@
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
-use Friendica\DI;
+use Friendica\Core\System;
 
 /**
  * Return the default robots.txt
@@ -45,7 +45,6 @@ class RobotsTxt extends BaseModule
                foreach ($allDisalloweds as $disallowed) {
                        echo 'Disallow: ' . $disallowed . PHP_EOL;
                }
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 }
index 6af321a0b7d3dee49512fd20066470c29aba1e6b..2d29f4d647fe524fa53d158f04f94fa944a74f03 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module\Settings;
 
 use Friendica\Core\Hook;
 use Friendica\Core\Renderer;
+use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Database\DBStructure;
 use Friendica\DI;
@@ -112,8 +113,7 @@ class UserExport extends BaseSettings
                                        self::exportContactsAsCSV(local_user());
                                        break;
                        }
-                       DI::page()->logRuntime();
-                       exit();
+                       System::exit();
                }
        }
 
index 8d14d82dadbaf3862f64f5abf49e44b971034cbd..50a4f6c55aff82be959f048acb01a00d8492d419 100644 (file)
@@ -22,7 +22,7 @@
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
-use Friendica\DI;
+use Friendica\Core\System;
 use Friendica\Util\Strings;
 
 /**
@@ -45,7 +45,6 @@ class Theme extends BaseModule
                if (file_exists("view/theme/$theme/style.php")) {
                        require_once "view/theme/$theme/style.php";
                }
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 }
index c69c93b03f0422a5dcd025514f477c99d978c92a..cbb9357c016c4a854648cf8ff205dcdfd6c6134d 100644 (file)
@@ -49,7 +49,6 @@ class ThemeDetails extends BaseModule
                                'credits' => $credits,
                        ]);
                }
-               DI::page()->logRuntime();
-               exit();
+               System::exit();
        }
 }
index 2b71d23c4e4c9ea7973afe71aaef772f9df046fc..6282028e692792f9304003166698a59fa297c44a 100644 (file)
@@ -31,8 +31,7 @@ class Network extends NetworkModule
        protected function rawContent(array $request = [])
        {
                if (!isset($_GET['p']) || !isset($_GET['item'])) {
-                       DI::page()->logRuntime();
-                       exit();
+                       System::exit();
                }
 
                $this->parseRequest($_GET);
index c2271565c273bdd48e2dc0d256594822f5b6cdce..732b4b985d4d5bdabde47d1891652bbb893cbdec 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Util;
 use Friendica\Core\Cache\Enum\Duration;
 use Friendica\Core\Logger;
 use Exception;
+use Friendica\Core\System;
 use Friendica\DI;
 
 /**
@@ -69,8 +70,7 @@ class JsonLD
 
                if ($recursion > 5) {
                        Logger::error('jsonld bomb detected at: ' . $url);
-                       DI::page()->logRuntime();
-                       exit();
+                       System::exit();
                }
 
                $result = DI::cache()->get('documentLoader:' . $url);