示例#1
0
 public function init($params)
 {
     if (Installer::getStatus() !== Installer::CREATE_CONFIG) {
         InstallationPage::redirectToCorrectStep();
         exit;
     }
 }
示例#2
0
 private function tryProcessPostData($postData)
 {
     $reqfields = array('username', 'password', 'rptpassword', 'email');
     if (!$postData->hasValues($reqfields)) {
         $this->errorMessage = 'Please specify at least:
                                <ul>
                                  <li>Administrator username, password and email</li>
                                </ul>';
         return;
     }
     $fields = $reqfields;
     extract($postData->filter($fields));
     $usernamepattern = '/^[a-z][-a-z0-9_.]*$/i';
     if (!preg_match($usernamepattern, $username)) {
         $this->errorMessage = 'The submitted username is invalid.';
         return;
     }
     if ($password !== $rptpassword) {
         $this->errorMessage = 'The submitted passwords do not match.';
         return;
     }
     $dbc = Application::dbConnection();
     $dbc->installDatabase();
     $dbc->setDefaultOptions();
     $uid = $dbc->users()->addUser($username, $username, $email, $password);
     $dbc->users()->setFlags($uid, \tniessen\tinyIt\Database\UsersTableAdapter::FLAG_ALMIGHTY);
     Installer::completeInstallation();
     $this->redirectTo('home');
     exit;
 }
示例#3
0
 public static function redirectToCorrectStep()
 {
     $status = Installer::getStatus();
     if ($status === Installer::INSTALLED) {
         self::redirectTo('home');
     } else {
         if ($status === Installer::CREATE_CONFIG) {
             self::redirectTo('installation/config');
         } else {
             if ($status === Installer::INIT_DATABASE) {
                 self::redirectTo('installation/database');
             } else {
                 die("Invalid installer status: {$status}");
             }
         }
     }
 }
示例#4
0
 private function tryProcessPostData($postData)
 {
     $reqfields = array('server', 'port', 'username', 'password', 'dbname', 'adminpath', 'requrlkey');
     if (!$postData->hasValues($reqfields)) {
         $this->errorMessage = 'Please specify at least:
                                <ul>
                                  <li>MySQL host, port, username, password and database name</li>
                                  <li>WebUI path</li>
                                  <li>Secret .htaccess key</li>
                                </ul>';
         return;
     }
     $fields = $reqfields;
     $fields[] = 'tblprefix';
     extract($postData->filter($fields));
     $result = DatabaseConnection::test($server, $port, $dbname, $username, $password);
     if ($result !== true) {
         $this->errorMessage = 'Unable to connect to database:
                                <pre>' . WebRenderer::escapeHtml($result->getMessage()) . '</pre>';
         return;
     }
     $result = Installer::testRequiredPermissions();
     if (!$result) {
         $this->errorMessage = 'Insufficient file system permissions';
         return;
     }
     $htaccessCode = Installer::createHtaccessCode($requrlkey);
     Installer::saveHtaccessFile($htaccessCode);
     $configCode = Installer::createConfigCode($server, $port, $username, $password, $dbname, $tblprefix, $adminpath, $requrlkey);
     Installer::saveConfigFile($configCode);
     define('TI_ADMIN_PATH', $adminpath);
     define('TI_URLBASEPATH', $urlbasepath);
     define('TI_ROUTING_ENABLED', true);
     $this->redirectTo('installation', 'database');
     exit;
 }
示例#5
0
文件: Page.php 项目: tniessen/tinyIt
 /**
  * Requires the installation to be complete.
  *
  * If the installation has not been completed, this function will redirect
  * the client to the `installation` page.
  *
  * @see \tniessen\tinyIt\Installer::getStatus
  */
 public static final function requireInstallationComplete()
 {
     if (Installer::getStatus() !== Installer::INSTALLED) {
         self::redirectTo('installation');
         exit;
     }
 }