--- /dev/null
+<?php
+
+namespace wcf\http\middleware;
+
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestInterface;
+use Psr\Http\Server\MiddlewareInterface;
+use Psr\Http\Server\RequestHandlerInterface;
+use wcf\system\application\ApplicationHandler;
+use wcf\system\exception\NamedUserException;
+use wcf\system\request\RequestHandler;
+use wcf\system\WCF;
+
+/**
+ * Checks whether the accessed app is an evaluation version that is expired.
+ *
+ * @author Tim Duesterhus
+ * @copyright 2001-2022 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\Http\Middleware
+ * @since 5.6
+ */
+final class CheckForExpiredAppEvaluation implements MiddlewareInterface
+{
+ /**
+ * @inheritDoc
+ */
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
+ {
+ [$abbreviation] = \explode('\\', RequestHandler::getInstance()->getActiveRequest()->getClassName(), 2);
+
+ if ($abbreviation !== 'wcf') {
+ $application = ApplicationHandler::getInstance()->getApplication($abbreviation);
+ $applicationObject = WCF::getApplicationObject($application);
+ $endDate = $applicationObject->getEvaluationEndDate();
+
+ if ($endDate && $endDate < TIME_NOW) {
+ $package = $application->getPackage();
+
+ $pluginStoreFileID = $applicationObject->getEvaluationPluginStoreID();
+ $isWoltLab = false;
+ if ($pluginStoreFileID === 0 && \str_starts_with($package->package, 'com.woltlab.')) {
+ $isWoltLab = true;
+ }
+
+ throw new NamedUserException(WCF::getLanguage()->getDynamicVariable(
+ 'wcf.acp.package.evaluation.expired',
+ [
+ 'packageName' => $package->getName(),
+ 'pluginStoreFileID' => $pluginStoreFileID,
+ 'isWoltLab' => $isWoltLab,
+ ]
+ ));
+ }
+ }
+
+ return $handler->handle($request);
+ }
+}
use Laminas\HttpHandlerRunner\Emitter\SapiEmitter;
use wcf\http\LegacyPlaceholderResponse;
use wcf\http\middleware\AddAcpSecurityHeaders;
+use wcf\http\middleware\CheckForExpiredAppEvaluation;
use wcf\http\middleware\CheckForOfflineMode;
use wcf\http\middleware\EnforceCacheControlPrivate;
use wcf\http\middleware\EnforceFrameOptions;
throw new IllegalLinkException();
}
- $this->checkAppEvaluation();
-
$pipeline = new Pipeline([
new AddAcpSecurityHeaders(),
new EnforceCacheControlPrivate(),
new EnforceFrameOptions(),
+ new CheckForExpiredAppEvaluation(),
new CheckForOfflineMode(),
]);
}
}
- /**
- * @since 5.5
- */
- private function checkAppEvaluation()
- {
- // check if the controller matches an app that has an expired evaluation date
- [$abbreviation] = \explode('\\', $this->getActiveRequest()->getClassName(), 2);
- if ($abbreviation !== 'wcf') {
- $applicationObject = ApplicationHandler::getInstance()->getApplication($abbreviation);
- $endDate = WCF::getApplicationObject($applicationObject)->getEvaluationEndDate();
- if ($endDate && $endDate < TIME_NOW) {
- $package = $applicationObject->getPackage();
-
- $pluginStoreFileID = WCF::getApplicationObject($applicationObject)->getEvaluationPluginStoreID();
- $isWoltLab = false;
- if ($pluginStoreFileID === 0 && \strpos($package->package, 'com.woltlab.') === 0) {
- $isWoltLab = true;
- }
-
- throw new NamedUserException(WCF::getLanguage()->getDynamicVariable(
- 'wcf.acp.package.evaluation.expired',
- [
- 'packageName' => $package->getName(),
- 'pluginStoreFileID' => $pluginStoreFileID,
- 'isWoltLab' => $isWoltLab,
- ]
- ));
- }
- }
- }
-
/**
* Redirects to the actual URL, e.g. controller has been aliased or mistyped (boardlist instead of board-list).
*