/** * Install all the tables and return the messages generated. * * @param array $params Array with options for the install. * * @return array Array with messages of what was installed. */ public function install($params) { $options = array(); $options['useExtraData'] = (bool) $params['useExtraData']; $db = $this->_getDb(); // Install tables $dbParser = new Phprojekt_DbParser($options, $db); $dbParser->parseData(PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'application'); // Update users passwords $usersNamespace = new Zend_Session_Namespace('usersData'); // Update admin Pass $db->update('setting', array('value' => md5('phprojektmd5' . $usersNamespace->data['adminPass'])), 'id = 1'); // Update test Pass $db->update('setting', array('value' => md5('phprojektmd5' . $usersNamespace->data['testPass'])), 'user_id = 2 AND key_value = \'password\''); return $dbParser->getMessages(); }
/** * 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(); }