]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/HTTPException/PageNotFound.php
Changes:
[friendica.git] / src / Module / HTTPException / PageNotFound.php
index ae156f05c81e53deba5552ad9766acc16100a6b7..ba18d23e6b6cee45126eba241bac4e56ad37d49f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2024, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
 
 namespace Friendica\Module\HTTPException;
 
+use Friendica\App;
 use Friendica\BaseModule;
-use Friendica\DI;
+use Friendica\Core\L10n;
+use Friendica\Core\System;
+use Friendica\Module\Response;
+use Friendica\Module\Special\HTTPException as ModuleHTTPException;
 use Friendica\Network\HTTPException;
+use Friendica\Util\Profiler;
 use Psr\Http\Message\ResponseInterface;
+use Psr\Log\LoggerInterface;
 
 class PageNotFound extends BaseModule
 {
+       /** @var string */
+       private $remoteAddress;
+
+       public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, App\Request $request, array $server, array $parameters = [])
+       {
+               parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
+
+               $this->remoteAddress = $request->getRemoteAddress();
+       }
+
        protected function content(array $request = []): string
        {
-               throw new HTTPException\NotFoundException(DI::l10n()->t('Page not found.'));
+               throw new HTTPException\NotFoundException($this->t('Page not found.'));
        }
 
-       public function run(array $post = [], array $request = []): ResponseInterface
+       public function run(ModuleHTTPException $httpException, array $request = []): ResponseInterface
        {
                /* The URL provided does not resolve to a valid module.
                 *
@@ -45,9 +61,9 @@ class PageNotFound extends BaseModule
                 * Otherwise we are going to emit a 404 not found.
                 */
                $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.
+               // 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) {
-                       exit();
+                       System::exit();
                }
 
                if (!empty($queryString) && ($queryString === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
@@ -57,10 +73,10 @@ class PageNotFound extends BaseModule
 
                $this->logger->debug('index.php: page not found.', [
                        'request_uri' => $this->server['REQUEST_URI'],
-                       'address'     => $this->server['REMOTE_ADDR'],
+                       'address'     => $this->remoteAddress,
                        'query'       => $this->server['QUERY_STRING']
                ]);
 
-               return parent::run($post, $request); // TODO: Change the autogenerated stub
+               return parent::run($httpException, $request);
        }
 }