Kaynağa Gözat

Sketch for updating the config on the Update page

Visman 5 yıl önce
ebeveyn
işleme
ecd81bfc99

+ 60 - 10
app/Models/Pages/Admin/Update.php

@@ -113,6 +113,30 @@ class Update extends Admin
         return $uid;
     }
 
+    /**
+     * Содержимое файла main.php
+     * @var string
+     */
+    protected $configFile;
+
+    /**
+     * Начальная позиция массива конфига в файле main.php
+     */
+    protected $configArrPos;
+
+    protected function loadAndCheckConfig(): bool
+    {
+        $this->configFile = \file_get_contents($this->c->DIR_CONFIG . '/main.php');
+
+        if (\preg_match('%\[\s+\'BASE_URL\'\s+=>%', $this->configFile, $matches, \PREG_OFFSET_CAPTURE)) {
+            $this->configArrPos = $matches[0][1];
+
+            return true;
+        }
+
+        return false;
+    }
+
     /**
      * Подготавливает данные для страницы обновления форума
      *
@@ -127,16 +151,6 @@ class Update extends Admin
             return $this->returnMaintenance(false);
         }
 
-        // версия PHP
-        if (\version_compare(\PHP_VERSION, self::PHP_MIN, '<')) {
-            $this->fIswev = ['e', __('You are running error', 'PHP', \PHP_VERSION, $this->c->FORK_REVISION, self::PHP_MIN)];
-        }
-
-        // база не от ForkBB
-        if ($this->c->config->i_fork_revision < 1) {
-            $this->fIswev = ['e', __('Version mismatch error')];
-        }
-
         if (
             'POST' === $method
             && empty($this->fIswev)
@@ -155,6 +169,33 @@ class Update extends Admin
                 ]);
 
                 if ($v->validation($_POST)) {
+                    // версия PHP
+                    if (\version_compare(\PHP_VERSION, self::PHP_MIN, '<')) {
+                        return $this->c->Message->message(
+                            __('You are running error', 'PHP', \PHP_VERSION, $this->c->FORK_REVISION, self::PHP_MIN),
+                            true,
+                            503
+                        );
+                    }
+
+                    // база не от ForkBB ????
+                    if ($this->c->config->i_fork_revision < 1) {
+                        return $this->c->Message->message(
+                            'Version mismatch error',
+                            true,
+                            503
+                        );
+                    }
+
+                    // загрузка и проверка конфига
+                    if (true !== $this->loadAndCheckConfig()) {
+                        return $this->c->Message->message(
+                            'The structure of the main.php file is undefined',
+                            true,
+                            503
+                        );
+                    }
+
                     $uid = $this->setLock();
 
                     if (null === $uid) {
@@ -312,6 +353,15 @@ class Update extends Admin
 #     */
 #    protected function stageNumber1(array $args): ?int
 #    {
+#        $this->configAdd(
+#            [
+#                'multiple' => [
+#                    'AdminUsersRecalculate' => '\ForkBB\Models\Pages\Admin\Users\Recalculate::class'
+#                ],
+#            ],
+#            'after:AdminUsersNew'
+#        );
 #
+#        return null;
 #    }
 }

+ 3 - 0
app/lang/en/admin_update.po

@@ -203,3 +203,6 @@ msgstr "Someone is already registered with the username %s. The username you ent
 
 msgid "Stage %1$s (%2$s)"
 msgstr "Stage %1$s (%2$s)"
+
+msgid "The structure of the main.php file is undefined"
+msgstr "The structure of the main.php file is undefined."

+ 3 - 0
app/lang/ru/admin_update.po

@@ -203,3 +203,6 @@ msgstr "Есть очень похожее имя - %s. Имена должны
 
 msgid "Stage %1$s (%2$s)"
 msgstr "Шаг %1$s (%2$s)"
+
+msgid "The structure of the main.php file is undefined"
+msgstr "Структура файла main.php не определена."