currentStep(); $maxStep = $install->maxStep(); if (!$install->canAccessStep($currentStep)) { $install->gotoStep(1); } $error = $copy = ''; //step 1 if ($currentStep == 1) { $requirements = $install->listRequirementTableRows(); $pass = $requirements['pass']; if ($isPost) { $install->nextStep(); } } if ($currentStep == 2) { $envExampleFile = "$rootpath.env.example"; $envExampleData = readEnvFile($envExampleFile); $envFormControls = $install->listEnvFormControls(); $newData = array_column($envFormControls, 'value', 'name'); while ($isPost) { try { $install->createEnvFile($_POST); $install->nextStep(); } catch (\Exception $exception) { $error = $exception->getMessage(); break; } break; } $tableRows = [ [ 'label' => '.env.example', 'required' => 'exists && readable', 'current' => $envExampleFile, 'result' => $install->yesOrNo(file_exists($envExampleFile) && is_readable($envExampleFile)), ], ]; $fails = array_filter($tableRows, function ($value) {return $value['result'] == 'NO';}); $pass = empty($fails); } if ($currentStep == 3) { $pass = true; $shouldCreateTable = $install->listShouldCreateTable(); while ($isPost) { try { $install->createTable($shouldCreateTable); $install->nextStep(); } catch (\Exception $exception) { $error = $exception->getMessage(); break; } break; } } //if ($currentStep == 4) { // $pass = true; // while (true) { // $shouldAlterTable = listShouldAlterTable(); // if ($isPost) { // if (!empty($shouldAlterTable)) { // try { // sql_query('SET sql_mode=(SELECT REPLACE(@@sql_mode,"NO_ZERO_DATE", ""));'); // foreach ($shouldAlterTable as $table => $fields) { // $sqlAlter = "alter table $table"; // $sqlUpdate = "update $table"; // $updateWhere = []; // foreach ($fields as $field) { // $sqlAlter .= " modify $field datetime default null,"; // $sqlUpdate .= " set $field = null,"; // $updateWhere[] = "$field = '0000-00-00 00:00:00'"; // } // $sqlAlter = rtrim($sqlAlter, ','); // $sqlUpdate = rtrim($sqlUpdate, ',') . " where " . implode(' or ', $updateWhere); // sql_query($sqlUpdate); // sql_query($sqlAlter); // } // } catch (\Exception $e) { // $error = $e->getMessage(); // break; // } // } // goStep($currentStep + 1); // } // break; // } //} if ($currentStep == 4) { $settingTableRows = $install->listSettingTableRows(); $settings = $settingTableRows['settings']; $symbolicLinks = $settingTableRows['symbolic_links']; $tableRows = $settingTableRows['table_rows']; $pass = $settingTableRows['pass']; while ($isPost) { try { $install->createSymbolicLinks($symbolicLinks); $install->saveSettings($settings); $install->importInitialData(); $install->nextStep(); } catch (\Exception $e) { $error = $e->getMessage(); break; } break; } } if ($currentStep == 5) { if ($isPost) { try { $install->createAdministrator($_POST['username'], $_POST['email'], $_POST['password'], $_POST['confirm_password']); $install->nextStep(); } catch (\Exception $exception) { $error = $exception->getMessage(); } } $pass = true; $userFormControls = [ ['label' => '用户名', 'name' => 'username', 'value' => $_POST['username'] ?? ''], ['label' => '邮箱', 'name' => 'email', 'value' => $_POST['email'] ?? ''], ['label' => '密码', 'name' => 'password', 'value' => $_POST['password'] ?? ''], ['label' => '确认密码', 'name' => 'confirm_password', 'value' => $_POST['confirm_password'] ?? ''], ]; } ?>