123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- /**
- * This file is part of the ForkBB <https://github.com/forkbb>.
- *
- * @copyright (c) Visman <mio.visman@yandex.ru, https://github.com/MioVisman>
- * @license The MIT License (MIT)
- */
- declare(strict_types=1);
- namespace ForkBB\Controllers;
- use ForkBB\Core\Container;
- use ForkBB\Models\Page;
- class Update
- {
- /**
- * Контейнер
- * @var Container
- */
- protected $c;
- public function __construct(Container $container)
- {
- $this->c = $container;
- }
- /**
- * Маршрутиризация
- */
- public function routing(): Page
- {
- // fix for Router
- if ($this->c->config->i_fork_revision < 17) {
- $confChange = [
- 'shared' => [
- 'Router' => [
- 'class' => \ForkBB\Core\Router::class,
- 'base_url' => '%BASE_URL%',
- 'csrf' => '@Csrf'
- ],
- ],
- ];
- $this->c->config($confChange);
- }
- if ($this->c->config->i_fork_revision < 20) {
- $confChange = [
- 'shared' => [
- 'Cache' => [
- 'class' => \ForkBB\Core\Cache\FileCache::class,
- 'cache_dir' => '%DIR_CACHE%',
- ],
- ],
- ];
- $this->c->config($confChange);
- }
- if ($this->c->config->i_fork_revision < 35) {
- $confChange = [
- 'shared' => [
- 'HTMLCleaner' => [
- 'calss' => \ForkBB\Core\HTMLCleaner::class,
- 'config' => '%DIR_APP%/config/jevix.default.php',
- ],
- 'VLhtml' => \ForkBB\Models\Validators\Html::class,
- ],
- ];
- $this->c->config($confChange);
- }
- $uri = $_SERVER['REQUEST_URI'];
- if (false !== ($pos = \strpos($uri, '?'))) {
- $uri = \substr($uri, 0, $pos);
- }
- $uri = \rawurldecode($uri);
- $this->c->user = $this->c->users->create(['id' => 2, 'group_id' => $this->c->GROUP_ADMIN]); //???? id?
- $this->c->Lang->load('common');
- $r = $this->c->Router;
- $r->add(
- $r::GET,
- '/admin/update/{uid}/{stage|i:\d+}[/{start|i:\d+}]',
- 'AdminUpdate:stage',
- 'AdminUpdateStage'
- );
- $r->add(
- $r::DUO,
- '/admin/update',
- 'AdminUpdate:view',
- 'AdminUpdate'
- );
- $method = $_SERVER['REQUEST_METHOD'];
- $route = $r->route($method, $uri);
- $page = null;
- switch ($route[0]) {
- case $r::OK:
- // ... 200 OK
- list($page, $action) = \explode(':', $route[1], 2);
- $page = $this->c->$page->$action($route[2], $method);
- break;
- default:
- $page = $this->c->AdminUpdate->view([], 'GET');
- break;
- }
- return $page;
- }
- }
|