예제 #1
0
 /**
  * Install itself.
  *
  * @param array $params Array with the POST values.
  *
  * @return void
  */
 public function install($params)
 {
     $options = array();
     $options['useExtraData'] = (bool) $params['useExtraData'];
     $dbParser = new Phprojekt_DbParser($options, $this->_db);
     $dbParser->parseData(PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'application');
     // Update admin Pass
     $this->_db->update('setting', array('value' => md5('phprojektmd5' . $params['adminPass'])), 'id = 1');
     // Update test Pass
     $this->_db->update('setting', array('value' => md5('phprojektmd5' . $params['testPass'])), 'user_id = 2 AND key_value = \'password\'');
     // Migration
     if (file_exists($params['migrationConfigFile'])) {
         try {
             $migration = new Setup_Models_Migration($params['migrationConfigFile'], $params['diffToUtc'], $this->_db);
             $migration->migrateTables();
         } catch (Exception $error) {
             echo $error->getMessage();
         }
     }
     // Create config file
     $config = new Setup_Models_Config();
     $content = $config->getDefaultProduction($params['dbUser'], $params['dbPass'], $params['dbName'], 'Pdo_Mysql', $params['dbHost']);
     $baseDir = str_replace('htdocs/setup.php', '', $_SERVER['SCRIPT_FILENAME']);
     $configFile = $baseDir . "configuration.ini";
     file_put_contents($configFile, $content);
     // Delete a session if exists
     $_SESSION = array();
     foreach ($_COOKIE as $key => $value) {
         setcookie($key, "", 1);
     }
     Zend_Session::writeClose();
 }
예제 #2
0
 /**
  * Complete the installation writing the config file.
  *
  * @return void
  */
 public function finish()
 {
     // Create config file
     $databaseNamespace = new Zend_Session_Namespace('databaseData');
     $config = new Setup_Models_Config();
     $content = $config->getDefaultProduction($databaseNamespace->data['dbUser'], $databaseNamespace->data['dbPass'], $databaseNamespace->data['dbName'], 'Pdo_Mysql', $databaseNamespace->data['dbHost']);
     $baseDir = str_replace('htdocs/setup.php', '', $_SERVER['SCRIPT_FILENAME']);
     $configFile = $baseDir . "configuration.php";
     file_put_contents($configFile, $content);
     // Set access
     $baseDir = str_replace('htdocs/setup.php', '', $_SERVER['SCRIPT_FILENAME']);
     if (PHP_OS == 'WIN32' || PHP_OS == 'WINNT') {
         $this->_error[] = '"' . $baseDir . '" should have the next rights: 0750 for folders, 0640 for files';
     } else {
         // Root
         if (!$this->chmodRecursive($baseDir, 0750, 0640)) {
             $this->_error[] = '"' . $baseDir . '" should have the next rights: 0750 for folders, 0640 for files';
         }
     }
     // Delete a session if exists
     $_SESSION = array();
     foreach ($_COOKIE as $key => $value) {
         setcookie($key, "", 1);
     }
     Zend_Session::writeClose();
 }
예제 #3
0
 public function writeConfigFile()
 {
     $databaseNamespace = new Zend_Session_Namespace('databaseData');
     $config = new Setup_Models_Config();
     $content = $config->getDefaultProduction($databaseNamespace->data['dbUser'], $databaseNamespace->data['dbPass'], $databaseNamespace->data['dbName'], 'Pdo_Mysql', $databaseNamespace->data['dbHost'], $databaseNamespace->data['dbPort']);
     $baseDir = $this->getBaseDir();
     $configFile = $baseDir . "configuration.php";
     file_put_contents($configFile, $content);
 }