本文整理汇总了PHP中Installer::storeServerName方法的典型用法代码示例。如果您正苦于以下问题:PHP Installer::storeServerName方法的具体用法?PHP Installer::storeServerName怎么用?PHP Installer::storeServerName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Installer
的用法示例。
在下文中一共展示了Installer::storeServerName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authControl
public function authControl()
{
$show_try_again_button = false;
if (isset($_GET['run_update'])) {
try {
$backup_info = $this->runUpdate(dirname(__FILE__));
//var_dump($backup_info);
$site_root_path = Config::getInstance()->getValue('site_root_path');
$redir = $site_root_path . 'install/upgrade-application.php?ran_update=1';
$this->redirect($redir);
} catch (Exception $e) {
$this->addErrorMessage($e->getMessage(), null, true);
}
} else {
if (isset($_GET['ran_update'])) {
//Update the application server name in app settings for access by command-line scripts
Installer::storeServerName();
//Clear Smarty's compiled templates and cache to start fresh with newly upgraded app
$this->view_mgr->clear_compiled_tpl();
$this->view_mgr->clear_all_cache();
$this->addToView('updated', true);
} else {
$verify_updatable = true;
try {
$update_info = $this->runUpdate(dirname(__FILE__), $verify_updatable);
if (isset($update_info['latest_version'])) {
$this->addToView('latest_version', $update_info['latest_version']);
}
$this->addToView('updateable', true);
} catch (Exception $e) {
$this->addErrorMessage($e->getMessage(), null, true);
$show_try_again_button = true;
}
}
}
$this->addToView('show_try_again_button', $show_try_again_button);
return $this->generateView();
}
示例2: testStoreServerName
public function testStoreServerName()
{
$option_dao = DAOFactory::getDAO('OptionDAO');
$current_stored_server_name = $option_dao->getOptionByName(OptionDAO::APP_OPTIONS, 'server_name');
$this->assertNull($current_stored_server_name);
$_SERVER['HTTP_HOST'] = 'mytestthinkup';
Installer::storeServerName();
$current_stored_server_name = $option_dao->getOptionByName(OptionDAO::APP_OPTIONS, 'server_name');
$this->assertNotNull($current_stored_server_name);
$this->assertEqual($current_stored_server_name->option_value, 'mytestthinkup');
$this->assertEqual($current_stored_server_name->option_name, 'server_name');
$_SERVER['SERVER_NAME'] = 'myreallygoodtest';
Installer::storeServerName();
$current_stored_server_name = $option_dao->getOptionByName(OptionDAO::APP_OPTIONS, 'server_name');
$this->assertNotNull($current_stored_server_name);
$this->assertEqual($current_stored_server_name->option_value, 'myreallygoodtest');
$this->assertEqual($current_stored_server_name->option_name, 'server_name');
}
示例3: 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');
}