本文整理汇总了PHP中Installer::createConfigFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Installer::createConfigFile方法的具体用法?PHP Installer::createConfigFile怎么用?PHP Installer::createConfigFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Installer
的用法示例。
在下文中一共展示了Installer::createConfigFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeSaveData
/**
* Create the config file with the database settings and write email settings
*
* @param sfWebRequest $request
* @return <type>
*/
public function executeSaveData(sfWebRequest $request) {
$sysObj = new SystemSetting();
$installer = new Installer();
$data = $request->getPostParameters();
$installer->createConfigFile($data); // write settings in database.yml
// create DB
$task = new sfDoctrineBuildAllReLoadTask(sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
chdir(sfConfig::get('sf_root_dir'));
$task->run(array(),array('--no-confirmation', '--env=all', '--dir='.sfConfig::get('sf_root_dir').'/data/fixtures/'.$data['productive_data'].''));
$data = $sysObj->buildEmailSetting($data);
UserLoginTable::instance()->updateEmail($data['productive_emailadresse']);
EmailConfigurationTable::instance()->updateEmailConfiguration($data);
// clear cache
$taskCC = new sfCacheClearTask(sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
$taskCC->run(array(), array());
// create JS Cache
$ccCache = new TemplateCaching();
$ccCache->checkCacheDir();
$ccCache->setFiles();
$lastModified = $ccCache->getLastModifiedFile();
$cacheCreated = $ccCache->getCurrentCacheStamp();
if($lastModified > $cacheCreated OR $cacheCreated == '') {
if($cacheCreated == '') {
$cacheCreated = $lastModified;
}
$ccCache->createCache($lastModified, $cacheCreated);
}
// return success, then JS redirect
$this->renderText('{success:true}');
return sfView::NONE;
}
示例2: step3
//.........这里部分代码省略.........
$this->addErrorMessage("Please choose a password.", "password");
} else {
if (!preg_match("/(?=.{8,})(?=.*[a-zA-Z])(?=.*[0-9])/", $password)) {
$this->addErrorMessage("Password must be at least 8 characters and contain both numbers and letters.", "password");
}
}
}
$display_errors = true;
}
if ($_POST['db_name'] == '') {
$this->addErrorMessage("Please enter a database name.", "database_name");
$display_errors = true;
}
if ($_POST['db_host'] == '') {
$this->addErrorMessage("Please enter a database host.", "database_host");
$display_errors = true;
}
if ($_POST['timezone'] == '') {
$this->addErrorMessage("Please select a time zone.", "timezone");
$display_errors = true;
}
if (($error = $this->installer->checkDb($db_config)) !== true) {
//check db
if (($p = strpos($error->getMessage(), "Unknown MySQL server host")) !== false || ($p = strpos($error->getMessage(), "Can't connect to MySQL server")) !== false || ($p = strpos($error->getMessage(), "Can't connect to local MySQL server through socket")) !== false || ($p = strpos($error->getMessage(), "Access denied for user")) !== false) {
$db_error = substr($error->getMessage(), $p);
} else {
$db_error = $error->getMessage();
}
$disable_xss = true;
$db_error = filter_var($db_error, FILTER_SANITIZE_SPECIAL_CHARS);
$this->addErrorMessage("ThinkUp couldn't connect to your database. The error message is:<br /> " . " <strong>{$db_error}</strong><br />Please correct your database information and try again.", "database", $disable_xss);
$display_errors = true;
}
if ($display_errors) {
$this->setViewTemplate('install.step2.tpl');
$this->addToView('db_name', $db_config['db_name']);
$this->addToView('db_user', $db_config['db_user']);
$this->addToView('db_passwd', $db_config['db_password']);
$this->addToView('db_host', $db_config['db_host']);
$this->addToView('db_prefix', $db_config['table_prefix']);
$this->addToView('db_socket', $db_config['db_socket']);
$this->addToView('db_port', $db_config['db_port']);
$this->addToView('db_type', $db_config['db_type']);
$this->addToView('current_tz', $_POST['timezone']);
$this->addToView('tz_list', $this->getTimeZoneList());
$this->addToView('site_email', $email);
$this->addToView('full_name', $full_name);
return;
}
$admin_user = array('email' => $email, 'password' => $password, 'confirm_password' => $confirm_password);
// trying to create config file
if (!$config_file_exists && !$this->installer->createConfigFile($db_config, $admin_user)) {
$config_file_contents_arr = $this->installer->generateConfigFile($db_config, $admin_user);
$config_file_contents_str = '';
foreach ($config_file_contents_arr as $line) {
$config_file_contents_str .= htmlentities($line);
}
$whoami = @exec('whoami');
$disable_xss = true;
if (!empty($whoami)) {
$whoami = filter_var($whoami, FILTER_SANITIZE_SPECIAL_CHARS);
$this->addErrorMessage("ThinkUp couldn't write the <code>config.inc.php</code> file.<br /><br />" . "Use root (or sudo) to create the file manually, and allow PHP to write to it, by executing the " . "following commands:<br /><code>sudo touch " . escapeshellcmd(THINKUP_WEBAPP_PATH . "config.inc.php") . "</code><br /><code>sudo chown {$whoami} " . escapeshellcmd(THINKUP_WEBAPP_PATH . "config.inc.php") . "</code><br /><br />If you don't have root access, create the <code>" . THINKUP_WEBAPP_PATH . "config.inc.php</code> file, show the contents of your config file below," . " and copy and paste the text into the <code>config.inc.php</code> file.", null, $disable_xss);
} else {
$this->addErrorMessage("ThinkUp couldn't write the <code>config.inc.php</code> file.<br /><br />" . "You will need to create the <code>" . THINKUP_WEBAPP_PATH . "config.inc.php</code> file manually, and paste the following text into it.", null, $disable_xss);
}
$this->addToView('config_file_contents', $config_file_contents_str);
$this->addToView('_POST', $_POST);
$this->setViewTemplate('install.config.tpl');
return;
}
unset($admin_user['confirm_password']);
// check tables
$this->installer->checkTable($db_config);
// if empty, we're ready to populate the database with ThinkUp tables
$this->installer->populateTables($db_config);
//Set the application server name in app settings for access by command-line scripts
Installer::storeServerName();
$owner_dao = DAOFactory::getDAO('OwnerDAO', $db_config);
if (!$owner_dao->doesAdminExist() && !$owner_dao->doesOwnerExist($email)) {
// create admin if not exists
$activation_code = $owner_dao->createAdmin($email, $password, $full_name);
// view for email
$cfg_array = array('site_root_path' => Utils::getSiteRootPathFromFileSystem(), 'source_root_path' => THINKUP_ROOT_PATH, 'debug' => false, 'app_title_prefix' => "", 'cache_pages' => false);
$email_view = new ViewManager($cfg_array);
$email_view->caching = false;
$email_view->assign('application_url', Utils::getApplicationURL());
$email_view->assign('email', urlencode($email));
$email_view->assign('activ_code', $activation_code);
$message = $email_view->fetch('_email.registration.tpl');
Mailer::mail($email, "Activate Your New ThinkUp Account", $message);
} else {
$email = 'Use your old email admin';
$password = 'Use your old password admin';
}
unset($THINKUP_CFG);
$this->addToView('errors', $this->installer->getErrorMessages());
$this->addToView('username', $email);
$this->addToView('password', $password);
$this->addToView('login_url', Utils::getSiteRootPathFromFileSystem() . 'session/login.php');
}
示例3: step3
//.........这里部分代码省略.........
}
$db_config['db_type'] = 'mysql';
//default for now
$password = $_POST['password'];
$confirm_password = $_POST['confirm_password'];
$full_name = $_POST['full_name'];
$display_errors = false;
// check email
if (!Utils::validateEmail($email)) {
$this->addErrorMessage("Please enter a valid email address.");
$this->setViewTemplate('install.step2.tpl');
$display_errors = true;
} else {
if ($password != $confirm_password || $password == '') {
//check password
if ($password != $confirm_password) {
$this->addErrorMessage("Your passwords did not match.");
} else {
$this->addErrorMessage("Please choose a password.");
}
$this->setViewTemplate('install.step2.tpl');
$display_errors = true;
} elseif (($error = $this->installer->checkDb($db_config)) !== true) {
//check db
if (($p = strpos($error->getMessage(), "Unknown MySQL server host")) !== false || ($p = strpos($error->getMessage(), "Can't connect to MySQL server")) !== false || ($p = strpos($error->getMessage(), "Can't connect to local MySQL server through socket")) !== false || ($p = strpos($error->getMessage(), "Access denied for user")) !== false) {
$db_error = substr($error->getMessage(), $p);
} else {
$db_error = $error->getMessage();
}
$this->addErrorMessage("ThinkUp couldn't connect to your database. The error message is:<br /> " . " <strong>{$db_error}</strong><br />Please correct your database information and try again.");
$this->setViewTemplate('install.step2.tpl');
$display_errors = true;
}
}
if ($display_errors) {
$this->addToView('db_name', $db_config['db_name']);
$this->addToView('db_user', $db_config['db_user']);
$this->addToView('db_passwd', $db_config['db_password']);
$this->addToView('db_host', $db_config['db_host']);
$this->addToView('db_prefix', $db_config['table_prefix']);
$this->addToView('db_socket', $db_config['db_socket']);
$this->addToView('db_port', $db_config['db_port']);
$this->addToView('db_type', $db_config['db_type']);
$this->addToView('current_tz', $_POST['timezone']);
$this->addToView('tz_list', $this->getTimeZoneList());
$this->addToView('site_email', $email);
$this->addToView('full_name', $full_name);
return;
}
$admin_user = array('email' => $email, 'password' => $password, 'confirm_password' => $confirm_password);
// trying to create config file
if (!$config_file_exists && !$this->installer->createConfigFile($db_config, $admin_user)) {
$config_file_contents_arr = $this->installer->generateConfigFile($db_config, $admin_user);
$config_file_contents_str = '';
foreach ($config_file_contents_arr as $line) {
$config_file_contents_str .= htmlentities($line);
}
$whoami = exec('whoami');
if (!empty($whoami)) {
$this->addErrorMessage("ThinkUp couldn't write the <code>config.inc.php</code> file.<br /><br />" . "Use root (or sudo) to create the file manually, and allow PHP to write to it, by executing the " . "following commands:<br /><code>touch " . escapeshellcmd(THINKUP_WEBAPP_PATH . "config.inc.php") . "</code><br /><code>chown {$whoami} " . escapeshellcmd(THINKUP_WEBAPP_PATH . "config.inc.php") . "</code><br /><br />If you don't have root access, create the <code>" . THINKUP_WEBAPP_PATH . "config.inc.php</code> file manually, and paste the following text into it." . "<br /><br />Click the <strong>Next Step</strong> button below once you did either.");
} else {
$this->addErrorMessage("ThinkUp couldn't write the <code>config.inc.php</code> file.<br /><br />" . "You will need to create the <code>" . THINKUP_WEBAPP_PATH . "config.inc.php</code> file manually, and paste the following text into it." . "<br /><br />Click the <strong>Next Step</strong> button once this is done.");
}
$this->addToView('config_file_contents', $config_file_contents_str);
$this->addToView('_POST', $_POST);
$this->setViewTemplate('install.config.tpl');
return;
}
unset($admin_user['confirm_password']);
// check tables
$this->installer->checkTable($db_config);
// if empty, we're ready to populate the database with ThinkUp tables
$this->installer->populateTables($db_config);
$owner_dao = DAOFactory::getDAO('OwnerDAO', $db_config);
if (!$owner_dao->doesAdminExist() && !$owner_dao->doesOwnerExist($email)) {
// create admin if not exists
$session = new Session();
$activation_code = rand(1000, 9999);
$crypt_pass = $session->pwdcrypt($password);
//$owner_dao->insertActivatedAdmin($email, $crypt_pass, $full_name);
$owner_dao->createAdmin($email, $crypt_pass, $activation_code, $full_name);
// view for email
$cfg_array = array('site_root_path' => THINKUP_BASE_URL, 'source_root_path' => THINKUP_ROOT_PATH, 'debug' => false, 'app_title' => "ThinkUp", 'cache_pages' => false);
$email_view = new SmartyThinkUp($cfg_array);
$email_view->caching = false;
$email_view->assign('server', $_SERVER['HTTP_HOST']);
$email_view->assign('email', urlencode($email));
$email_view->assign('activ_code', $activation_code);
$message = $email_view->fetch('_email.registration.tpl');
Mailer::mail($email, "Activate Your New ThinkUp Account", $message);
} else {
$email = 'Use your old email admin';
$password = 'Use your old password admin';
}
unset($THINKUP_CFG);
$this->addToView('errors', $this->installer->getErrorMessages());
$this->addToView('username', $email);
$this->addToView('password', $password);
$this->addToView('login_url', THINKUP_BASE_URL . 'session/login.php');
}