Update installer to use new config format

This commit is contained in:
Kijin Sung 2016-02-03 15:39:58 +09:00
parent 28af7b95cf
commit 0b1fa79f43
15 changed files with 287 additions and 424 deletions

View file

@ -7,8 +7,7 @@
*/
class installView extends install
{
public $install_enable = false;
public static $checkEnv = false;
public static $rewriteCheckFilePath = 'files/cache/tmpRewriteCheck.txt';
public static $rewriteCheckString = '';
@ -17,81 +16,56 @@ class installView extends install
*/
function init()
{
// Set browser title
// Stop if already installed.
if (Context::isInstalled())
{
return $this->stop('msg_already_installed');
}
// Set the browser title.
Context::setBrowserTitle(Context::getLang('introduce_title'));
// Specify the template path
// Specify the template path.
$this->setTemplatePath($this->module_path.'tpl');
// Error occurs if already installed
if(Context::isInstalled()) return $this->stop('msg_already_installed');
// Install a controller
// Check the environment.
$oInstallController = getController('install');
$this->install_enable = $oInstallController->checkInstallEnv();
// If the environment is installable, execute installController::makeDefaultDirectory()
if($this->install_enable) $oInstallController->makeDefaultDirectory();
self::$checkEnv = $oInstallController->checkInstallEnv();
if (self::$checkEnv)
{
$oInstallController->makeDefaultDirectory();
}
}
/**
* @brief Display license messages
* @brief Index page
*/
function dispInstallIntroduce()
function dispInstallIndex()
{
$install_config_file = FileHandler::getRealPath('./config/install.config.php');
if(file_exists($install_config_file))
// If there is an autoinstall config file, use it.
if (file_exists(RX_BASEDIR . 'config/install.config.php'))
{
/**
* If './config/install.config.php' file created and write array shown in the example below, XE installed using config file.
* ex )
$install_config = array(
'db_type' =>'mysqli_innodb',
'db_port' =>'3306',
'db_hostname' =>'localhost',
'db_userid' =>'root',
'db_password' =>'root',
'db_database' =>'rx_database',
'db_table_prefix' =>'rx',
'user_rewrite' =>'N',
'time_zone' =>'0000',
'email_address' =>'admin@admin.net',
'password' =>'pass',
'password2' =>'pass',
'nick_name' =>'admin',
'user_id' =>'admin',
'lang_type' =>'ko', // en, jp, ...
);
*/
include $install_config_file;
if(is_array($install_config))
include RX_BASEDIR . 'config/install.config.php';
if (isset($install_config) && is_array($install_config))
{
foreach($install_config as $k => $v)
{
$v = ($k == 'db_table_prefix') ? $v.'_' : $v;
Context::set($k,$v,true);
}
unset($GLOBALS['__DB__']);
Context::set('install_config', true, true);
$oInstallController = getController('install');
$output = $oInstallController->procInstall();
if (!$output->toBool()) return $output;
header("location: ./");
Context::close();
exit;
$output = $oInstallController->procInstall($install_config);
if (!$output->toBool())
{
return $output;
}
else
{
header("location: ./");
exit;
}
}
}
Context::set('l', Context::getLangType());
return $this->dispInstallLicenseAgreement();
//$this->setTemplateFile('introduce');
}
/**
* @brief License agreement
*/
function dispInstallLicenseAgreement()
{
// Otherwise, display the license agreement screen.
Context::set('lang_type', Context::getLangType());
$this->setTemplateFile('license_agreement');
$lang_type = Context::getLangType();
Context::set('lang_type', $lang_type);
}
/**
@ -99,111 +73,82 @@ class installView extends install
*/
function dispInstallCheckEnv()
{
$oInstallController = getController('install');
// Create a temporary file for mod_rewrite check.
self::$rewriteCheckString = Password::createSecureSalt(32);
FileHandler::writeFile(_XE_PATH_ . self::$rewriteCheckFilePath, self::$rewriteCheckString);;
Context::set('use_rewrite', $_SESSION['use_rewrite'] = 'N');
Context::set('use_nginx', stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false);
// Check if the web server is nginx.
Context::set('use_nginx', stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false);
$this->setTemplateFile('check_env');
}
/**
* @brief Choose a DB
* @brief Configure the database
*/
function dispInstallSelectDB()
function dispInstallDBConfig()
{
// Display check_env if it is not installable
if(!$this->install_enable) return $this->dispInstallCheckEnv();
if(!self::$checkEnv)
{
return $this->dispInstallCheckEnv();
}
// Delete mod_rewrite check file
FileHandler::removeFile(_XE_PATH_ . self::$rewriteCheckFilePath);
// Save mod_rewrite check status
// Save mod_rewrite check status.
if(Context::get('rewrite') === 'Y')
{
Context::set('use_rewrite', $_SESSION['use_rewrite'] = 'Y');
}
// Enter ftp information
// FTP config is disabled in Rhymix.
/*
if(ini_get('safe_mode') && !Context::isFTPRegisted())
{
Context::set('progressMenu', '3');
Context::set('server_ip_address', $_SERVER['SERVER_ADDR']);
Context::set('server_ftp_user', get_current_user());
$this->setTemplateFile('ftp');
return;
}
else
*/
$defaultDatabase = 'mysqli_innodb';
$disableList = DB::getDisableList();
if(is_array($disableList))
{
$defaultDatabase = 'mysqli_innodb';
$disableList = DB::getDisableList();
if(is_array($disableList))
foreach($disableList as $key => $value)
{
foreach($disableList AS $key=>$value)
if($value->db_type == $defaultDatabase)
{
if($value->db_type == $defaultDatabase)
{
$defaultDatabase = 'mysql';
break;
}
$defaultDatabase = 'mysqli';
break;
}
}
Context::set('defaultDatabase', $defaultDatabase);
Context::set('progressMenu', '4');
$error_return_url = getNotEncodedUrl('', 'act', Context::get('act'), 'db_type', Context::get('db_type'));
if(RX_SSL)
{
// Error occured when using https protocol at "ModuleHandler::init() '
$parsedUrl = parse_url($error_return_url);
$error_return_url = '';
if(isset($parsedUrl['path'])) $error_return_url .= $parsedUrl['path'];
if(isset($parsedUrl['query'])) $error_return_url .= '?' . $parsedUrl['query'];
if(isset($parsedUrl['fragment'])) $error_return_url .= '?' . $parsedUrl['fragment'];
}
Context::set('error_return_url', $error_return_url);
$this->setTemplateFile('select_db');
}
Context::set('defaultDatabase', $defaultDatabase);
Context::set('progressMenu', '4');
Context::set('error_return_url', getNotEncodedUrl('', 'act', Context::get('act'), 'db_type', Context::get('db_type')));
$this->setTemplateFile('db_config');
}
/**
* @brief Display a screen to enter DB and administrator's information
*/
function dispInstallManagerForm()
function dispInstallOtherConfig()
{
// Display check_env if not installable
if(!$this->install_enable)
if(!self::$checkEnv)
{
return $this->dispInstallCheckEnv();
}
include _XE_PATH_.'files/config/tmpDB.config.php';
Context::set('use_rewrite', $_SESSION['use_rewrite']);
Context::set('use_ssl', RX_SSL ? 'always' : 'none');
Context::set('time_zone', $GLOBALS['time_zone']);
Context::set('db_type', $db_info->db_type);
$this->setTemplateFile('admin_form');
}
/**
* @brief Check whether this server supports mod_rewrite
*/
function useRewriteModule()
{
if(function_exists('apache_get_modules') && in_array('mod_rewrite',apache_get_modules()))
{
return true;
}
require_once(_XE_PATH_.'classes/httprequest/XEHttpRequest.class.php');
$httpRequest = new XEHttpRequest($_SERVER['HTTP_HOST'], $_SERVER['SERVER_PORT']);
$xeInstallPath = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'index.php', 1));
$output = $httpRequest->send($xeInstallPath.'modules/install/conf/info.xml');
return (strpos($output->body, '<?xml') !== 0);
$this->setTemplateFile('other_config');
}
}
/* End of file install.view.php */