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

3
.gitignore vendored
View file

@ -1,7 +1,8 @@
.DS_Store .DS_Store
Thumbs.db Thumbs.db
config.user.inc.php /config/config.user.inc.php
/config/install.config.php
/files/ /files/
/build/ /build/
/libs/ /libs/

View file

@ -487,11 +487,14 @@ class Context
* *
* @return void * @return void
*/ */
public static function loadDBInfo() public static function loadDBInfo($config = null)
{ {
// Load new configuration format. // Load new configuration format.
$config = Rhymix\Framework\Config::init(); if ($config === null)
if(!count($config)) {
$config = Rhymix\Framework\Config::init();
}
if (!count($config))
{ {
return; return;
} }
@ -620,9 +623,16 @@ class Context
{ {
$supported = Rhymix\Framework\Lang::getSupportedList(); $supported = Rhymix\Framework\Lang::getSupportedList();
$selected = Rhymix\Framework\Config::get('locale.enabled_lang'); $selected = Rhymix\Framework\Config::get('locale.enabled_lang');
foreach ($selected as $lang) if ($selected)
{ {
$lang_selected[$lang] = $supported[$lang]; foreach ($selected as $lang)
{
$lang_selected[$lang] = $supported[$lang];
}
}
else
{
$lang_selected = $supported;
} }
} }
return $lang_selected; return $lang_selected;

View file

@ -132,14 +132,21 @@ class ModuleHandler extends Handler
{ {
continue; continue;
} }
$urlInfo = parse_url($url); $urlInfo = parse_url($url);
$host = $urlInfo['host']; $host = $urlInfo['host'];
$dbInfo = Context::getDBInfo(); $defaultUrl = Context::getDBInfo()->default_url;
$defaultUrlInfo = parse_url($dbInfo->default_url); if($defaultUrl)
$defaultHost = $defaultUrlInfo['host']; {
$defaultUrlInfo = parse_url($defaultUrl);
$defaultHost = $defaultUrlInfo['host'];
}
else
{
$defaultHost = $_SERVER['HTTP_HOST'];
}
if($host && ($host != $defaultHost && $host != $site_module_info->domain)) if($host && ($host != $defaultHost && $host != $site_module_info->domain))
{ {
throw new Exception('msg_default_url_is_null'); throw new Exception('msg_default_url_is_null');

View file

@ -43,6 +43,16 @@ class Config
return self::$_config; return self::$_config;
} }
/**
* Get default system configuration.
*
* @return array
*/
public static function getDefaults()
{
return (include RX_BASEDIR . 'common/defaults/config.php');
}
/** /**
* Get a system configuration value. * Get a system configuration value.
* *
@ -332,15 +342,13 @@ class Config
/** /**
* Save the current system configuration. * Save the current system configuration.
* *
* @param array $config (optional)
* @return bool * @return bool
*/ */
public static function save() public static function save($config = null)
{ {
if (!count(self::$_config)) $config = ($config === null) ? self::$_config : $config;
{ $buff = '<?php' . "\n" . '// Rhymix System Configuration' . "\n" . 'return ' . self::serialize($config) . ';' . "\n";
self::init();
}
$buff = '<?php' . "\n" . '// Rhymix System Configuration' . "\n" . 'return ' . self::serialize(self::$_config) . ';' . "\n";
return \FileHandler::writeFile(RX_BASEDIR . 'files/config/config.php', $buff) ? true : false; return \FileHandler::writeFile(RX_BASEDIR . 'files/config/config.php', $buff) ? true : false;
} }

View file

@ -27,7 +27,7 @@
<form action="./" method="post" class="message info x_clearfix" cond="!$isLicenseAgreement"> <form action="./" method="post" class="message info x_clearfix" cond="!$isLicenseAgreement">
<input type="hidden" name="success_return_url" value="{getUrl('', 'module', 'admin')}" /> <input type="hidden" name="success_return_url" value="{getUrl('', 'module', 'admin')}" />
<input type="hidden" name="module" value="install" /> <input type="hidden" name="module" value="install" />
<input type="hidden" name="act" value="procInstallLicenseAggrement" /> <input type="hidden" name="act" value="procInstallLicenseAgreement" />
<input type="hidden" name="license_agreement" value="Y" /> <input type="hidden" name="license_agreement" value="Y" />
<input type="hidden" name="XE_VALIDATOR_ID" value="modules/admin/tpl/index/1"> <input type="hidden" name="XE_VALIDATOR_ID" value="modules/admin/tpl/index/1">

View file

@ -3,15 +3,13 @@
<grants /> <grants />
<permissions /> <permissions />
<actions> <actions>
<action name="dispInstallIntroduce" type="view" index="true" /> <action name="dispInstallIndex" type="view" index="true" />
<action name="dispInstallLicenseAgreement" type="view" />
<action name="dispInstallCheckEnv" type="view" /> <action name="dispInstallCheckEnv" type="view" />
<action name="dispInstallSelectDB" type="view" /> <action name="dispInstallDBConfig" type="view" />
<action name="dispInstallDBForm" type="view" /> <action name="dispInstallOtherConfig" type="view" />
<action name="dispInstallManagerForm" type="view" /> <action name="procDBConfig" type="controller" />
<action name="procDBSetting" type="controller" />
<action name="procInstall" type="controller" ruleset="install" /> <action name="procInstall" type="controller" ruleset="install" />
<action name="procInstallLicenseAggrement" type="controller" /> <action name="procInstallLicenseAgreement" type="controller" />
<action name="procInstallFTP" type="controller" /> <action name="procInstallFTP" type="controller" />
<action name="procInstallCheckFTP" type="controller" /> <action name="procInstallCheckFTP" type="controller" />
<action name="procInstallAdminInstall" type="controller" /> <action name="procInstallAdminInstall" type="controller" />

View file

@ -7,8 +7,6 @@
*/ */
class installController extends install class installController extends install
{ {
var $db_tmp_config_file = '';
var $etc_tmp_config_file = '';
var $flagLicenseAgreement = './files/env/license_agreement'; var $flagLicenseAgreement = './files/env/license_agreement';
/** /**
@ -16,12 +14,12 @@ class installController extends install
*/ */
function init() function init()
{ {
// Error occurs if already installed // Stop if already installed.
if(Context::isInstalled()) if (Context::isInstalled())
{ {
return new Object(-1, 'msg_already_installed'); return new Object(-1, 'msg_already_installed');
} }
$this->db_tmp_config_file = _XE_PATH_.'files/config/tmpDB.config.php'; $this->db_tmp_config_file = _XE_PATH_.'files/config/tmpDB.config.php';
$this->etc_tmp_config_file = _XE_PATH_.'files/config/tmpEtc.config.php'; $this->etc_tmp_config_file = _XE_PATH_.'files/config/tmpEtc.config.php';
} }
@ -29,30 +27,37 @@ class installController extends install
/** /**
* @brief division install step... DB Config temp file create * @brief division install step... DB Config temp file create
*/ */
function procDBSetting() function procDBConfig()
{ {
// Get DB-related variables // Get DB config variables.
$con_string = Context::gets('db_type','db_port','db_hostname','db_userid','db_password','db_database','db_table_prefix'); $config = Context::gets('db_type', 'db_host', 'db_port', 'db_user', 'db_pass', 'db_database', 'db_prefix');
$con_string->db_table_prefix = rtrim($con_string->db_table_prefix, '_');
// Create a temporary setting object.
$db_info = new stdClass(); $db_info = new stdClass();
$db_info->master_db = get_object_vars($con_string); $db_info->master_db = array();
$db_info->master_db['db_type'] = $config->db_type;
$db_info->master_db['db_hostname'] = $config->db_host;
$db_info->master_db['db_port'] = $config->db_port;
$db_info->master_db['db_userid'] = $config->db_user;
$db_info->master_db['db_password'] = $config->db_pass;
$db_info->master_db['db_database'] = $config->db_database;
$db_info->master_db['db_table_prefix'] = $config->db_prefix;
$db_info->slave_db = array($db_info->master_db); $db_info->slave_db = array($db_info->master_db);
$db_info->default_url = Context::getRequestUri(); $db_info->default_url = Context::getRequestUri();
$db_info->lang_type = Context::getLangType(); $db_info->lang_type = Context::getLangType();
$db_info->use_mobile_view = 'Y'; $db_info->use_mobile_view = 'Y';
// Set DB type and information
Context::setDBInfo($db_info); Context::setDBInfo($db_info);
// Check if available to connect to the DB // Check connection to the DB.
$oDB = &DB::getInstance(); $oDB = DB::getInstance();
$output = $oDB->getError(); $output = $oDB->getError();
if(!$output->toBool()) return $output; if (!$output->toBool() || !$oDB->isConnected())
if(!$oDB->isConnected()) return $oDB->getError(); {
return $output;
// Check if MySQL server supports InnoDB }
if(stripos($con_string->db_type, 'innodb') !== false)
// Check if MySQL server supports InnoDB.
if(stripos($config->db_type, 'innodb') !== false)
{ {
$innodb_supported = false; $innodb_supported = false;
$show_engines = $oDB->_fetch($oDB->_query('SHOW ENGINES')); $show_engines = $oDB->_fetch($oDB->_query('SHOW ENGINES'));
@ -63,100 +68,144 @@ class installController extends install
$innodb_supported = true; $innodb_supported = true;
} }
} }
// If server does not support InnoDB, fall back to default storage engine (usually MyISAM) // If server does not support InnoDB, fall back to default storage engine (usually MyISAM).
if(!$innodb_supported) if(!$innodb_supported)
{ {
$con_string->db_type = str_ireplace('_innodb', '', $con_string->db_type); $config->db_type = str_ireplace('_innodb', '', $config->db_type);
$db_info->master_db['db_type'] = $con_string->db_type;
$db_info->slave_db[0]['db_type'] = $con_string->db_type;
Context::set('db_type', $con_string->db_type);
Context::setDBInfo($db_info);
} }
} }
// Create a db temp config file // Check if MySQL server supports utf8mb4.
if(!$this->makeDBConfigFile()) return new Object(-1, 'msg_install_failed'); if(stripos($config->db_type, 'mysql') !== false)
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON')))
{ {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'act', 'dispInstallManagerForm'); $oDB->charset = $oDB->getBestSupportedCharset();
header('location:'.$returnUrl); $config->db_charset = $oDB->charset;
return; }
// Save DB config in session.
$_SESSION['db_config'] = $config;
// Continue the installation.
if(!in_array(Context::getRequestMethod(), array('XMLRPC','JSON')))
{
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'act', 'dispInstallOtherConfig');
$this->setRedirectUrl($returnUrl);
} }
} }
/** /**
* @brief Install with received information * @brief Install with received information
*/ */
function procInstall() function procInstall($install_config = null)
{ {
// Check if it is already installed // Check if it is already installed
if(Context::isInstalled()) if (Context::isInstalled())
{ {
return new Object(-1, 'msg_already_installed'); return new Object(-1, 'msg_already_installed');
} }
// Save rewrite and time zone settings // Get install parameters.
if(!Context::get('install_config')) $config = Rhymix\Framework\Config::getDefaults();
if ($install_config)
{ {
$config_info = Context::gets('use_rewrite','time_zone', 'use_ssl'); $install_config = (array)$install_config;
if($config_info->use_rewrite!='Y') $config_info->use_rewrite = 'N'; $config['db']['master']['type'] = str_replace('_innodb', '', $install_config['db_type']);
if(!$this->makeEtcConfigFile($config_info)) $config['db']['master']['host'] = $install_config['db_hostname'];
{ $config['db']['master']['port'] = $install_config['db_port'];
return new Object(-1, 'msg_install_failed'); $config['db']['master']['user'] = $install_config['db_userid'];
} $config['db']['master']['pass'] = $install_config['db_password'];
$config['db']['master']['database'] = $install_config['db_database'];
$config['db']['master']['prefix'] = $install_config['db_table_prefix'];
$config['db']['master']['charset'] = $install_config['db_charset'];
$config['db']['master']['engine'] = strpos($install_config['db_type'], 'innodb') !== false ? 'innodb' : (strpos($install_config['db_type'], 'mysql') !== false ? 'myisam' : null);
$config['use_rewrite'] = $install_config['use_rewrite'] === 'Y' ? true : false;
$config['url']['ssl'] = $install_config['use_ssl'] ?: 'none';
$time_zone = $install_config['time_zone'];
$user_info = new stdClass;
$user_info->email_address = $install_config['email_address'];
$user_info->password = $install_config['password'];
$user_info->nick_name = $install_config['nick_name'];
$user_info->user_id = $install_config['user_id'];
} }
// Assign a temporary administrator when installing
$logged_info = new stdClass();
$logged_info->is_admin = 'Y';
Context::set('logged_info', $logged_info);
// check install config
if(Context::get('install_config'))
{
$db_info = $this->_makeDbInfoByInstallConfig();
}
// install by default XE UI
else else
{ {
if(FileHandler::exists($this->db_tmp_config_file)) include $this->db_tmp_config_file; $config['db']['master']['type'] = str_replace('_innodb', '', $_SESSION['db_config']->db_type);
if(FileHandler::exists($this->etc_tmp_config_file)) include $this->etc_tmp_config_file; $config['db']['master']['host'] = $_SESSION['db_config']->db_host;
$config['db']['master']['port'] = $_SESSION['db_config']->db_port;
$config['db']['master']['user'] = $_SESSION['db_config']->db_user;
$config['db']['master']['pass'] = $_SESSION['db_config']->db_pass;
$config['db']['master']['database'] = $_SESSION['db_config']->db_database;
$config['db']['master']['prefix'] = $_SESSION['db_config']->db_prefix;
$config['db']['master']['charset'] = $_SESSION['db_config']->db_charset;
$config['db']['master']['engine'] = strpos($_SESSION['db_config']->db_type, 'innodb') !== false ? 'innodb' : (strpos($_SESSION['db_config']->db_type, 'mysql') !== false ? 'myisam' : null);
$config['use_rewrite'] = $_SESSION['use_rewrite'] === 'Y' ? true : false;
$config['url']['ssl'] = Context::get('use_ssl') ?: 'none';
$time_zone = Context::get('time_zone');
$user_info = Context::gets('email_address', 'password', 'nick_name', 'user_id');
} }
// Set DB type and information // Fix the database table prefix.
Context::setDBInfo($db_info); $config['db']['master']['prefix'] = rtrim($config['db']['master']['prefix'], '_');
// Create DB Instance if ($config['db']['master']['prefix'] !== '')
$oDB = &DB::getInstance();
// Check if available to connect to the DB
if(!$oDB->isConnected()) return $oDB->getError();
// Check DB charset if using MySQL
if(stripos($db_info->master_db['db_type'], 'mysql') !== false && !isset($db_info->master_db['db_charset']))
{ {
$oDB->charset = $oDB->getBestSupportedCharset(); $config['db']['master']['prefix'] .= '_';
$db_info->master_db['db_charset'] = $oDB->charset;
$db_info->slave_db[0]['db_charset'] = $oDB->charset;
Context::setDBInfo($db_info);
} }
// Install all the modules // Set the default language.
try { $config['locale']['default_lang'] = Context::getLangType();
$config['locale']['enabled_lang'] = array($config['locale']['default_lang']);
// Set the internal and default time zones.
$user_timezone = intval(get_time_zone_offset($time_zone ?: '+0900') / 3600);
switch ($user_timezone)
{
case 9:
$config['locale']['default_timezone'] = 'Asia/Seoul'; break;
case 0:
$config['locale']['default_timezone'] = 'Etc/UTC'; break;
default:
$config['locale']['default_timezone'] = 'Etc/GMT' . ($user_timezone > 0 ? '-' : '+') . abs($user_timezone);
}
$config['locale']['internal_timezone'] = intval(date('Z'));
// Set the default URL.
$config['url']['default'] = Context::getRequestUri();
// Load the new configuration.
Context::loadDBInfo($config);
// Check DB.
$oDB = DB::getInstance();
if (!$oDB->isConnected())
{
return $oDB->getError();
}
// Assign a temporary administrator while installing.
foreach ($user_info as $key => $val)
{
Context::set($key, $val, true);
}
$user_info->is_admin = 'Y';
Context::set('logged_info', $user_info);
// Install all the modules.
try
{
$oDB->begin(); $oDB->begin();
$this->installDownloadedModule(); $this->installDownloadedModule();
$oDB->commit(); $oDB->commit();
} catch(Exception $e) { }
catch(Exception $e)
{
$oDB->rollback(); $oDB->rollback();
return new Object(-1, $e->getMessage()); return new Object(-1, $e->getMessage());
} }
// Create a config file // Execute the install script.
if(!$this->makeConfigFile()) return new Object(-1, 'msg_install_failed');
// load script
$scripts = FileHandler::readDir(_XE_PATH_ . 'modules/install/script', '/(\.php)$/'); $scripts = FileHandler::readDir(_XE_PATH_ . 'modules/install/script', '/(\.php)$/');
if(count($scripts)>0) if(count($scripts))
{ {
sort($scripts); sort($scripts);
foreach($scripts as $script) foreach($scripts as $script)
@ -165,48 +214,23 @@ class installController extends install
$output = include($script_path . $script); $output = include($script_path . $script);
} }
} }
// save selected lang info // Save the new configuration.
$oInstallAdminController = getAdminController('install'); Rhymix\Framework\Config::save($config);
$oInstallAdminController->saveLangSelected(array(Context::getLangType()));
// Unset temporary session variables.
// Display a message that installation is completed
$this->setMessage('msg_install_completed');
unset($_SESSION['use_rewrite']); unset($_SESSION['use_rewrite']);
unset($_SESSION['db_config']);
// Redirect to the home page.
$this->setMessage('msg_install_completed');
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON')))
{ {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl(''); $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('');
header('location:'.$returnUrl); $this->setRedirectUrl($returnUrl);
return new Object();
} }
}
return new Object();
/**
* @brief Make DB Information by Install Config
*/
function _makeDbInfoByInstallConfig()
{
$db_info = new stdClass();
$db_info->master_db = array(
'db_type' => Context::get('db_type'),
'db_port' => Context::get('db_port'),
'db_hostname' => Context::get('db_hostname'),
'db_userid' => Context::get('db_userid'),
'db_password' => Context::get('db_password'),
'db_database' => Context::get('db_database'),
'db_table_prefix' => Context::get('db_table_prefix'),
'db_charset' => Context::get('db_charset'),
);
$db_info->slave_db = array($db_info->master_db);
$db_info->default_url = Context::getRequestUri();
$db_info->lang_type = Context::get('lang_type') ? Context::get('lang_type') : Context::getLangType();
Context::setLangType($db_info->lang_type);
$db_info->use_rewrite = Context::get('use_rewrite');
$db_info->time_zone = Context::get('time_zone');
return $db_info;
} }
/** /**
@ -436,7 +460,7 @@ class installController extends install
/** /**
* @brief License agreement * @brief License agreement
*/ */
function procInstallLicenseAggrement() function procInstallLicenseAgreement()
{ {
$vars = Context::getRequestVars(); $vars = Context::getRequestVars();
@ -575,134 +599,6 @@ class installController extends install
if(method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall(); if(method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall();
return new Object(); return new Object();
} }
function _getDBConfigFileContents($db_info)
{
if(substr($db_info->master_db['db_table_prefix'], -1) != '_')
{
$db_info->master_db['db_table_prefix'] .= '_';
}
foreach($db_info->slave_db as &$slave)
{
if(substr($slave['db_table_prefix'], -1) != '_')
{
$slave['db_table_prefix'] .= '_';
}
}
$buff = array();
$buff[] = '<?php if(!defined("__XE__")) exit();';
$buff[] = '$db_info = (object)' . var_export(get_object_vars($db_info), TRUE) . ';';
return implode(PHP_EOL, $buff);
}
/**
* @brief Create DB temp config file
* Create the config file when all settings are completed
*/
function makeDBConfigFile()
{
$db_tmp_config_file = $this->db_tmp_config_file;
$db_info = Context::getDBInfo();
if(!$db_info) return;
$buff = $this->_getDBConfigFileContents($db_info);
FileHandler::writeFile($db_tmp_config_file, $buff);
if(@file_exists($db_tmp_config_file)) return true;
return false;
}
/**
* @brief Create etc config file
* Create the config file when all settings are completed
*/
function makeEtcConfigFile($config_info)
{
$etc_tmp_config_file = $this->etc_tmp_config_file;
$buff = '<?php if(!defined("__XE__")) exit();'."\n";
foreach($config_info as $key => $val)
{
$buff .= sprintf("\$db_info->%s = '%s';\n", $key, str_replace("'","\\'",$val));
}
FileHandler::writeFile($etc_tmp_config_file, $buff);
if(@file_exists($etc_tmp_config_file)) return true;
return false;
}
/**
* @brief Create config file
* Create the config file when all settings are completed
*/
function makeConfigFile()
{
try {
$config_file = Context::getConfigFile();
//if(file_exists($config_file)) return;
$db_info = Context::getDBInfo();
if(!$db_info) return;
$buff = $this->_getDBConfigFileContents($db_info);
FileHandler::writeFile($config_file, $buff);
if(@file_exists($config_file))
{
FileHandler::removeFile($this->db_tmp_config_file);
FileHandler::removeFile($this->etc_tmp_config_file);
return true;
}
return false;
} catch (Exception $e) {
return false;
}
}
function installByConfig($install_config_file)
{
include $install_config_file;
if(!is_array($auto_config)) return false;
$auto_config['module'] = 'install';
$auto_config['act'] = 'procInstall';
$fstr = "<%s><![CDATA[%s]]></%s>\r\n";
$fheader = "POST %s HTTP/1.1\r\nHost: %s\r\nContent-Type: application/xml\r\nContent-Length: %s\r\n\r\n%s\r\n";
$body = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<methodCall>\r\n<params>\r\n";
foreach($auto_config as $k => $v)
{
if(!in_array($k,array('host','port','path'))) $body .= sprintf($fstr,$k,$v,$k);
}
$body .= "</params>\r\n</methodCall>";
$header = sprintf($fheader,$auto_config['path'],$auto_config['host'],strlen($body),$body);
$fp = @fsockopen($auto_config['host'], $auto_config['port'], $errno, $errstr, 5);
if($fp)
{
fputs($fp, $header);
while(!feof($fp))
{
$line = trim(fgets($fp, 4096));
if(strncmp('<error>', $line, 7) === 0)
{
fclose($fp);
return false;
}
}
fclose($fp);
}
return true;
}
} }
/* End of file install.controller.php */ /* End of file install.controller.php */
/* Location: ./modules/install/install.controller.php */ /* Location: ./modules/install/install.controller.php */

View file

@ -7,8 +7,7 @@
*/ */
class installView extends install class installView extends install
{ {
public $install_enable = false; public static $checkEnv = false;
public static $rewriteCheckFilePath = 'files/cache/tmpRewriteCheck.txt'; public static $rewriteCheckFilePath = 'files/cache/tmpRewriteCheck.txt';
public static $rewriteCheckString = ''; public static $rewriteCheckString = '';
@ -17,81 +16,56 @@ class installView extends install
*/ */
function init() 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')); Context::setBrowserTitle(Context::getLang('introduce_title'));
// Specify the template path
// Specify the template path.
$this->setTemplatePath($this->module_path.'tpl'); $this->setTemplatePath($this->module_path.'tpl');
// Error occurs if already installed
if(Context::isInstalled()) return $this->stop('msg_already_installed'); // Check the environment.
// Install a controller
$oInstallController = getController('install'); $oInstallController = getController('install');
$this->install_enable = $oInstallController->checkInstallEnv(); self::$checkEnv = $oInstallController->checkInstallEnv();
// If the environment is installable, execute installController::makeDefaultDirectory() if (self::$checkEnv)
if($this->install_enable) $oInstallController->makeDefaultDirectory(); {
$oInstallController->makeDefaultDirectory();
}
} }
/** /**
* @brief Display license messages * @brief Index page
*/ */
function dispInstallIntroduce() function dispInstallIndex()
{ {
$install_config_file = FileHandler::getRealPath('./config/install.config.php'); // If there is an autoinstall config file, use it.
if(file_exists($install_config_file)) if (file_exists(RX_BASEDIR . 'config/install.config.php'))
{ {
/** include 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 ) if (isset($install_config) && is_array($install_config))
$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))
{ {
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'); $oInstallController = getController('install');
$output = $oInstallController->procInstall(); $output = $oInstallController->procInstall($install_config);
if (!$output->toBool()) return $output; if (!$output->toBool())
header("location: ./"); {
Context::close(); return $output;
exit; }
else
{
header("location: ./");
exit;
}
} }
} }
Context::set('l', Context::getLangType()); // Otherwise, display the license agreement screen.
return $this->dispInstallLicenseAgreement(); Context::set('lang_type', Context::getLangType());
//$this->setTemplateFile('introduce');
}
/**
* @brief License agreement
*/
function dispInstallLicenseAgreement()
{
$this->setTemplateFile('license_agreement'); $this->setTemplateFile('license_agreement');
$lang_type = Context::getLangType();
Context::set('lang_type', $lang_type);
} }
/** /**
@ -99,111 +73,82 @@ class installView extends install
*/ */
function dispInstallCheckEnv() function dispInstallCheckEnv()
{ {
$oInstallController = getController('install'); // Create a temporary file for mod_rewrite check.
self::$rewriteCheckString = Password::createSecureSalt(32); self::$rewriteCheckString = Password::createSecureSalt(32);
FileHandler::writeFile(_XE_PATH_ . self::$rewriteCheckFilePath, self::$rewriteCheckString);; 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'); $this->setTemplateFile('check_env');
} }
/** /**
* @brief Choose a DB * @brief Configure the database
*/ */
function dispInstallSelectDB() function dispInstallDBConfig()
{ {
// Display check_env if it is not installable // 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 // Delete mod_rewrite check file
FileHandler::removeFile(_XE_PATH_ . self::$rewriteCheckFilePath); FileHandler::removeFile(_XE_PATH_ . self::$rewriteCheckFilePath);
// Save mod_rewrite check status // Save mod_rewrite check status.
if(Context::get('rewrite') === 'Y') if(Context::get('rewrite') === 'Y')
{ {
Context::set('use_rewrite', $_SESSION['use_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()) if(ini_get('safe_mode') && !Context::isFTPRegisted())
{ {
Context::set('progressMenu', '3'); Context::set('progressMenu', '3');
Context::set('server_ip_address', $_SERVER['SERVER_ADDR']); Context::set('server_ip_address', $_SERVER['SERVER_ADDR']);
Context::set('server_ftp_user', get_current_user()); Context::set('server_ftp_user', get_current_user());
$this->setTemplateFile('ftp'); $this->setTemplateFile('ftp');
return;
} }
else */
$defaultDatabase = 'mysqli_innodb';
$disableList = DB::getDisableList();
if(is_array($disableList))
{ {
$defaultDatabase = 'mysqli_innodb'; foreach($disableList as $key => $value)
$disableList = DB::getDisableList();
if(is_array($disableList))
{ {
foreach($disableList AS $key=>$value) if($value->db_type == $defaultDatabase)
{ {
if($value->db_type == $defaultDatabase) $defaultDatabase = 'mysqli';
{ break;
$defaultDatabase = 'mysql';
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 * @brief Display a screen to enter DB and administrator's information
*/ */
function dispInstallManagerForm() function dispInstallOtherConfig()
{ {
// Display check_env if not installable // Display check_env if not installable
if(!$this->install_enable) if(!self::$checkEnv)
{ {
return $this->dispInstallCheckEnv(); return $this->dispInstallCheckEnv();
} }
include _XE_PATH_.'files/config/tmpDB.config.php';
Context::set('use_rewrite', $_SESSION['use_rewrite']); Context::set('use_rewrite', $_SESSION['use_rewrite']);
Context::set('use_ssl', RX_SSL ? 'always' : 'none'); Context::set('use_ssl', RX_SSL ? 'always' : 'none');
Context::set('time_zone', $GLOBALS['time_zone']); Context::set('time_zone', $GLOBALS['time_zone']);
Context::set('db_type', $db_info->db_type); $this->setTemplateFile('other_config');
$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);
} }
} }
/* End of file install.view.php */ /* End of file install.view.php */

View file

@ -8,6 +8,5 @@
<field name="password2" required="true" length="1:60" equalto="password" /> <field name="password2" required="true" length="1:60" equalto="password" />
<field name="nick_name" required="true" length="2:20" /> <field name="nick_name" required="true" length="2:20" />
<field name="user_id" required="true" length="2:20" rule="userid" /> <field name="user_id" required="true" length="2:20" rule="userid" />
<field name="time_zone" required="true" />
</fields> </fields>
</ruleset> </ruleset>

View file

@ -269,7 +269,7 @@ $obj->email_address = $logged_info->email_address;
$obj->module_srl = $module_srl; $obj->module_srl = $module_srl;
Context::set('version', __XE_VERSION__); Context::set('version', __XE_VERSION__);
$obj->title = 'Welcome Rhymix'; $obj->title = 'Welcome to Rhymix';
$obj->content = $oTemplateHandler->compile(_XE_PATH_ . 'modules/install/script/welcome_content', 'welcome_content_'.$lang); $obj->content = $oTemplateHandler->compile(_XE_PATH_ . 'modules/install/script/welcome_content', 'welcome_content_'.$lang);
@ -279,7 +279,7 @@ if(!$output->toBool()) return $output;
$document_srl = $output->get('document_srl'); $document_srl = $output->get('document_srl');
unset($obj->document_srl); unset($obj->document_srl);
$obj->title = 'Welcome mobile Rhymix'; $obj->title = 'Welcome to Mobile Rhymix';
$output = $oDocumentController->insertDocument($obj, true); $output = $oDocumentController->insertDocument($obj, true);
if(!$output->toBool()) return $output; if(!$output->toBool()) return $output;

View file

@ -42,7 +42,7 @@
<tr id="mod_rewrite_no_support" style="display:none"> <tr id="mod_rewrite_no_support" style="display:none">
<td colspan="2" class="error_description"> <td colspan="2" class="error_description">
{$lang->disable_rewrite} {$lang->disable_rewrite}
<block cond="$use_nginx == 'Y'"><br />{$lang->about_nginx_rewrite}</block> <block cond="$use_nginx"><br />{$lang->about_nginx_rewrite}</block>
<br /><strong>{$lang->disable_rewrite_can_proceed}</strong> <br /><strong>{$lang->disable_rewrite_can_proceed}</strong>
</td> </td>
</tr> </tr>
@ -53,7 +53,7 @@
<a href="{getUrl('', 'act','dispInstallLicenseAgreement')}" class="button grey">&laquo; {$lang->cmd_back}</a> <a href="{getUrl('', 'act','dispInstallLicenseAgreement')}" class="button grey">&laquo; {$lang->cmd_back}</a>
</div> </div>
<div class="align-right"> <div class="align-right">
<a cond="$install_enable" class="button" id="task-checklist-confirm" href="{getUrl('','act','dispInstallSelectDB')}">{$lang->cmd_next} &raquo;</a> <a cond="$install_enable" class="button" id="task-checklist-confirm" href="{getUrl('','act','dispInstallDBConfig')}">{$lang->cmd_next} &raquo;</a>
<a cond="!$install_enable" class="button" id="task-checklist-fix" href="{getUrl('','act',$act)}">{$lang->cmd_install_refresh_page} &raquo;</a> <a cond="!$install_enable" class="button" id="task-checklist-fix" href="{getUrl('','act',$act)}">{$lang->cmd_install_refresh_page} &raquo;</a>
</div> </div>
</div> </div>

View file

@ -8,7 +8,7 @@
</div> </div>
<input type="hidden" value="{$error_return_url}" name="error_return_url"> <input type="hidden" value="{$error_return_url}" name="error_return_url">
<input type="hidden" name="module" value="{$module}" /> <input type="hidden" name="module" value="{$module}" />
<input type="hidden" name="act" value="procDBSetting" /> <input type="hidden" name="act" value="procDBConfig" />
<div class="x_control-group"> <div class="x_control-group">
<label for="db_type" class="x_control-label">{$lang->db_type}</label> <label for="db_type" class="x_control-label">{$lang->db_type}</label>
<div class="x_controls"> <div class="x_controls">
@ -27,28 +27,28 @@
</div> </div>
<p loop="DB::getEnableList() => $key,$val" class="install_help db_type db_type_{$val->db_type}">{$lang->db_desc[$val->db_type]}</p> <p loop="DB::getEnableList() => $key,$val" class="install_help db_type db_type_{$val->db_type}">{$lang->db_desc[$val->db_type]}</p>
<div class="x_control-group"> <div class="x_control-group">
<label for="dbHostName" class="x_control-label">{$lang->db_hostname}</label> <label for="db_host" class="x_control-label">{$lang->db_hostname}</label>
<div class="x_controls"><input name="db_hostname" value="localhost" type="text" id="dbHostName" required /></div> <div class="x_controls"><input name="db_host" value="localhost" type="text" id="db_host" required /></div>
</div> </div>
<div class="x_control-group"> <div class="x_control-group">
<label for="dbPort" class="x_control-label">{$lang->db_port}</label> <label for="db_port" class="x_control-label">{$lang->db_port}</label>
<div class="x_controls"><input name="db_port" value="3306" type="text" id="dbPort" required /></div> <div class="x_controls"><input name="db_port" value="3306" type="text" id="db_port" required /></div>
</div> </div>
<div class="x_control-group"> <div class="x_control-group">
<label for="dbId" class="x_control-label">{$lang->db_userid}</label> <label for="db_user" class="x_control-label">{$lang->db_userid}</label>
<div class="x_controls"><input name="db_userid" type="text" id="dbId" class="focus" required /></div> <div class="x_controls"><input name="db_user" type="text" id="db_user" class="focus" required /></div>
</div> </div>
<div class="x_control-group"> <div class="x_control-group">
<label for="dbPw" class="x_control-label">{$lang->db_password}</label> <label for="db_pass" class="x_control-label">{$lang->db_password}</label>
<div class="x_controls"><input name="db_password" type="password" id="dbPw" required /></div> <div class="x_controls"><input name="db_pass" type="password" id="db_pass" required /></div>
</div> </div>
<div class="x_control-group"> <div class="x_control-group">
<label for="dbName" class="x_control-label">{$lang->db_name}</label> <label for="db_database" class="x_control-label">{$lang->db_name}</label>
<div class="x_controls"><input name="db_database" type="text" id="dbName" required /></div> <div class="x_controls"><input name="db_database" type="text" id="db_database" required /></div>
</div> </div>
<div class="x_control-group"> <div class="x_control-group">
<label for="dbPrefix" class="x_control-label">{$lang->db_table_prefix}</label> <label for="db_prefix" class="x_control-label">{$lang->db_table_prefix}</label>
<div class="x_controls"><input name="db_table_prefix" type="text" id="dbPrefix" value="rx" required /></div> <div class="x_controls"><input name="db_prefix" type="text" id="db_prefix" value="rx" required /></div>
</div> </div>
<p class="install_help"> <p class="install_help">
{$lang->db_info_desc}<br />{$lang->db_prefix_desc} {$lang->db_info_desc}<br />{$lang->db_prefix_desc}

View file

@ -7,7 +7,7 @@
<div cond="$XE_VALIDATOR_MESSAGE" class="message {$XE_VALIDATOR_MESSAGE_TYPE}"> <div cond="$XE_VALIDATOR_MESSAGE" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
<p>{$XE_VALIDATOR_MESSAGE}</p> <p>{$XE_VALIDATOR_MESSAGE}</p>
</div> </div>
<input type="hidden" name="act" value="procInstallLicenseAggrement"> <input type="hidden" name="act" value="procInstallLicenseAgreement">
<input type="hidden" name="module" value="install"> <input type="hidden" name="module" value="install">
<div class="content-license"> <div class="content-license">
<include target="license_text.ko.html" cond="$lang_type === 'ko'" /> <include target="license_text.ko.html" cond="$lang_type === 'ko'" />
@ -22,7 +22,7 @@
<!--<a href="{getUrl('', 'act','')}" class="button grey">&laquo; {$lang->cmd_back}</a>--> <!--<a href="{getUrl('', 'act','')}" class="button grey">&laquo; {$lang->cmd_back}</a>-->
</div> </div>
<div class="align-right"> <div class="align-right">
<button type="submit" id="task-license-aggrement" value="">{$lang->cmd_next} &raquo;</button> <button type="submit" id="task-license-agreement" value="">{$lang->cmd_next} &raquo;</button>
</div> </div>
</div> </div>
</form> </form>

View file

@ -7,7 +7,6 @@
<p>{$XE_VALIDATOR_MESSAGE}</p> <p>{$XE_VALIDATOR_MESSAGE}</p>
</div> </div>
<input type="hidden" name="act" value="procInstall" /> <input type="hidden" name="act" value="procInstall" />
<input type="hidden" name="use_rewrite" value="{$use_rewrite}" />
<div class="x_control-group"> <div class="x_control-group">
<label for="aMail" class="x_control-label">{$lang->email_address}</label> <label for="aMail" class="x_control-label">{$lang->email_address}</label>
<div class="x_controls"> <div class="x_controls">
@ -61,7 +60,7 @@
</div> </div>
<div id="buttons"> <div id="buttons">
<div class="align-left"> <div class="align-left">
<a href="{getUrl('', 'act','dispInstallSelectDB')}" class="button grey">&laquo; {$lang->cmd_back}</a> <a href="{getUrl('', 'act','dispInstallDBConfig')}" class="button grey">&laquo; {$lang->cmd_back}</a>
</div> </div>
<div class="align-right"> <div class="align-right">
<button type="submit" id="task-done" value="">{$lang->cmd_complete} &raquo;</button> <button type="submit" id="task-done" value="">{$lang->cmd_complete} &raquo;</button>

View file

@ -3,7 +3,7 @@
<li class="active"|cond="($act==''||$act=='dispInstallLicenseAgreement')">{$lang->install_progress_menu['license_agreement']}</li> <li class="active"|cond="($act==''||$act=='dispInstallLicenseAgreement')">{$lang->install_progress_menu['license_agreement']}</li>
<li class="active"|cond="$act=='dispInstallCheckEnv'">{$lang->install_progress_menu['condition']}</li> <li class="active"|cond="$act=='dispInstallCheckEnv'">{$lang->install_progress_menu['condition']}</li>
<li cond="ini_get('safe_mode')" class="active"|cond="$act=='dispInstallSelectDB' && $progressMenu == '3'">{$lang->install_progress_menu['ftp']}</li> <li cond="ini_get('safe_mode')" class="active"|cond="$act=='dispInstallSelectDB' && $progressMenu == '3'">{$lang->install_progress_menu['ftp']}</li>
<li class="active"|cond="$act=='dispInstallSelectDB' && $progressMenu == '4'">{$lang->install_progress_menu['dbInfo']}</li> <li class="active"|cond="$act=='dispInstallDBConfig' && $progressMenu == '4'">{$lang->install_progress_menu['dbInfo']}</li>
<li class="active"|cond="$act=='dispInstallManagerForm'">{$lang->install_progress_menu['adminInfo']}</li> <li class="active"|cond="$act=='dispInstallAdminConfig'">{$lang->install_progress_menu['adminInfo']}</li>
</ul> </ul>
</div> </div>