mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Update installer to use new config format
This commit is contained in:
parent
28af7b95cf
commit
0b1fa79f43
15 changed files with 287 additions and 424 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,7 +1,8 @@
|
|||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
config.user.inc.php
|
||||
/config/config.user.inc.php
|
||||
/config/install.config.php
|
||||
/files/
|
||||
/build/
|
||||
/libs/
|
||||
|
|
|
|||
|
|
@ -487,11 +487,14 @@ class Context
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function loadDBInfo()
|
||||
public static function loadDBInfo($config = null)
|
||||
{
|
||||
// Load new configuration format.
|
||||
if ($config === null)
|
||||
{
|
||||
$config = Rhymix\Framework\Config::init();
|
||||
if(!count($config))
|
||||
}
|
||||
if (!count($config))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -620,11 +623,18 @@ class Context
|
|||
{
|
||||
$supported = Rhymix\Framework\Lang::getSupportedList();
|
||||
$selected = Rhymix\Framework\Config::get('locale.enabled_lang');
|
||||
if ($selected)
|
||||
{
|
||||
foreach ($selected as $lang)
|
||||
{
|
||||
$lang_selected[$lang] = $supported[$lang];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$lang_selected = $supported;
|
||||
}
|
||||
}
|
||||
return $lang_selected;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,9 +136,16 @@ class ModuleHandler extends Handler
|
|||
$urlInfo = parse_url($url);
|
||||
$host = $urlInfo['host'];
|
||||
|
||||
$dbInfo = Context::getDBInfo();
|
||||
$defaultUrlInfo = parse_url($dbInfo->default_url);
|
||||
$defaultUrl = Context::getDBInfo()->default_url;
|
||||
if($defaultUrl)
|
||||
{
|
||||
$defaultUrlInfo = parse_url($defaultUrl);
|
||||
$defaultHost = $defaultUrlInfo['host'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$defaultHost = $_SERVER['HTTP_HOST'];
|
||||
}
|
||||
|
||||
if($host && ($host != $defaultHost && $host != $site_module_info->domain))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -43,6 +43,16 @@ class 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.
|
||||
*
|
||||
|
|
@ -332,15 +342,13 @@ class Config
|
|||
/**
|
||||
* Save the current system configuration.
|
||||
*
|
||||
* @param array $config (optional)
|
||||
* @return bool
|
||||
*/
|
||||
public static function save()
|
||||
public static function save($config = null)
|
||||
{
|
||||
if (!count(self::$_config))
|
||||
{
|
||||
self::init();
|
||||
}
|
||||
$buff = '<?php' . "\n" . '// Rhymix System Configuration' . "\n" . 'return ' . self::serialize(self::$_config) . ';' . "\n";
|
||||
$config = ($config === null) ? self::$_config : $config;
|
||||
$buff = '<?php' . "\n" . '// Rhymix System Configuration' . "\n" . 'return ' . self::serialize($config) . ';' . "\n";
|
||||
return \FileHandler::writeFile(RX_BASEDIR . 'files/config/config.php', $buff) ? true : false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
<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="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="XE_VALIDATOR_ID" value="modules/admin/tpl/index/1">
|
||||
|
||||
|
|
|
|||
|
|
@ -3,15 +3,13 @@
|
|||
<grants />
|
||||
<permissions />
|
||||
<actions>
|
||||
<action name="dispInstallIntroduce" type="view" index="true" />
|
||||
<action name="dispInstallLicenseAgreement" type="view" />
|
||||
<action name="dispInstallIndex" type="view" index="true" />
|
||||
<action name="dispInstallCheckEnv" type="view" />
|
||||
<action name="dispInstallSelectDB" type="view" />
|
||||
<action name="dispInstallDBForm" type="view" />
|
||||
<action name="dispInstallManagerForm" type="view" />
|
||||
<action name="procDBSetting" type="controller" />
|
||||
<action name="dispInstallDBConfig" type="view" />
|
||||
<action name="dispInstallOtherConfig" type="view" />
|
||||
<action name="procDBConfig" type="controller" />
|
||||
<action name="procInstall" type="controller" ruleset="install" />
|
||||
<action name="procInstallLicenseAggrement" type="controller" />
|
||||
<action name="procInstallLicenseAgreement" type="controller" />
|
||||
<action name="procInstallFTP" type="controller" />
|
||||
<action name="procInstallCheckFTP" type="controller" />
|
||||
<action name="procInstallAdminInstall" type="controller" />
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@
|
|||
*/
|
||||
class installController extends install
|
||||
{
|
||||
var $db_tmp_config_file = '';
|
||||
var $etc_tmp_config_file = '';
|
||||
var $flagLicenseAgreement = './files/env/license_agreement';
|
||||
|
||||
/**
|
||||
|
|
@ -16,8 +14,8 @@ class installController extends install
|
|||
*/
|
||||
function init()
|
||||
{
|
||||
// Error occurs if already installed
|
||||
if(Context::isInstalled())
|
||||
// Stop if already installed.
|
||||
if (Context::isInstalled())
|
||||
{
|
||||
return new Object(-1, 'msg_already_installed');
|
||||
}
|
||||
|
|
@ -29,30 +27,37 @@ class installController extends install
|
|||
/**
|
||||
* @brief division install step... DB Config temp file create
|
||||
*/
|
||||
function procDBSetting()
|
||||
function procDBConfig()
|
||||
{
|
||||
// Get DB-related variables
|
||||
$con_string = Context::gets('db_type','db_port','db_hostname','db_userid','db_password','db_database','db_table_prefix');
|
||||
$con_string->db_table_prefix = rtrim($con_string->db_table_prefix, '_');
|
||||
// Get DB config variables.
|
||||
$config = Context::gets('db_type', 'db_host', 'db_port', 'db_user', 'db_pass', 'db_database', 'db_prefix');
|
||||
|
||||
// Create a temporary setting object.
|
||||
$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->default_url = Context::getRequestUri();
|
||||
$db_info->lang_type = Context::getLangType();
|
||||
$db_info->use_mobile_view = 'Y';
|
||||
|
||||
// Set DB type and information
|
||||
Context::setDBInfo($db_info);
|
||||
|
||||
// Check if available to connect to the DB
|
||||
$oDB = &DB::getInstance();
|
||||
// Check connection to the DB.
|
||||
$oDB = DB::getInstance();
|
||||
$output = $oDB->getError();
|
||||
if(!$output->toBool()) return $output;
|
||||
if(!$oDB->isConnected()) return $oDB->getError();
|
||||
if (!$output->toBool() || !$oDB->isConnected())
|
||||
{
|
||||
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;
|
||||
$show_engines = $oDB->_fetch($oDB->_query('SHOW ENGINES'));
|
||||
|
|
@ -64,99 +69,143 @@ class installController extends install
|
|||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
$con_string->db_type = str_ireplace('_innodb', '', $con_string->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);
|
||||
$config->db_type = str_ireplace('_innodb', '', $config->db_type);
|
||||
}
|
||||
}
|
||||
|
||||
// Create a db temp config file
|
||||
if(!$this->makeDBConfigFile()) return new Object(-1, 'msg_install_failed');
|
||||
|
||||
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON')))
|
||||
// Check if MySQL server supports utf8mb4.
|
||||
if(stripos($config->db_type, 'mysql') !== false)
|
||||
{
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'act', 'dispInstallManagerForm');
|
||||
header('location:'.$returnUrl);
|
||||
return;
|
||||
$oDB->charset = $oDB->getBestSupportedCharset();
|
||||
$config->db_charset = $oDB->charset;
|
||||
}
|
||||
|
||||
// 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
|
||||
*/
|
||||
function procInstall()
|
||||
function procInstall($install_config = null)
|
||||
{
|
||||
// Check if it is already installed
|
||||
if(Context::isInstalled())
|
||||
if (Context::isInstalled())
|
||||
{
|
||||
return new Object(-1, 'msg_already_installed');
|
||||
}
|
||||
|
||||
// Save rewrite and time zone settings
|
||||
if(!Context::get('install_config'))
|
||||
// Get install parameters.
|
||||
$config = Rhymix\Framework\Config::getDefaults();
|
||||
if ($install_config)
|
||||
{
|
||||
$config_info = Context::gets('use_rewrite','time_zone', 'use_ssl');
|
||||
if($config_info->use_rewrite!='Y') $config_info->use_rewrite = 'N';
|
||||
if(!$this->makeEtcConfigFile($config_info))
|
||||
{
|
||||
return new Object(-1, 'msg_install_failed');
|
||||
$install_config = (array)$install_config;
|
||||
$config['db']['master']['type'] = str_replace('_innodb', '', $install_config['db_type']);
|
||||
$config['db']['master']['host'] = $install_config['db_hostname'];
|
||||
$config['db']['master']['port'] = $install_config['db_port'];
|
||||
$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
|
||||
{
|
||||
if(FileHandler::exists($this->db_tmp_config_file)) include $this->db_tmp_config_file;
|
||||
if(FileHandler::exists($this->etc_tmp_config_file)) include $this->etc_tmp_config_file;
|
||||
$config['db']['master']['type'] = str_replace('_innodb', '', $_SESSION['db_config']->db_type);
|
||||
$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
|
||||
Context::setDBInfo($db_info);
|
||||
// Create DB Instance
|
||||
$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']))
|
||||
// Fix the database table prefix.
|
||||
$config['db']['master']['prefix'] = rtrim($config['db']['master']['prefix'], '_');
|
||||
if ($config['db']['master']['prefix'] !== '')
|
||||
{
|
||||
$oDB->charset = $oDB->getBestSupportedCharset();
|
||||
$db_info->master_db['db_charset'] = $oDB->charset;
|
||||
$db_info->slave_db[0]['db_charset'] = $oDB->charset;
|
||||
Context::setDBInfo($db_info);
|
||||
$config['db']['master']['prefix'] .= '_';
|
||||
}
|
||||
|
||||
// Install all the modules
|
||||
try {
|
||||
// Set the default language.
|
||||
$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();
|
||||
$this->installDownloadedModule();
|
||||
$oDB->commit();
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$oDB->rollback();
|
||||
return new Object(-1, $e->getMessage());
|
||||
}
|
||||
|
||||
// Create a config file
|
||||
if(!$this->makeConfigFile()) return new Object(-1, 'msg_install_failed');
|
||||
|
||||
// load script
|
||||
// Execute the install script.
|
||||
$scripts = FileHandler::readDir(_XE_PATH_ . 'modules/install/script', '/(\.php)$/');
|
||||
if(count($scripts)>0)
|
||||
if(count($scripts))
|
||||
{
|
||||
sort($scripts);
|
||||
foreach($scripts as $script)
|
||||
|
|
@ -166,48 +215,23 @@ class installController extends install
|
|||
}
|
||||
}
|
||||
|
||||
// save selected lang info
|
||||
$oInstallAdminController = getAdminController('install');
|
||||
$oInstallAdminController->saveLangSelected(array(Context::getLangType()));
|
||||
|
||||
// Display a message that installation is completed
|
||||
$this->setMessage('msg_install_completed');
|
||||
// Save the new configuration.
|
||||
Rhymix\Framework\Config::save($config);
|
||||
|
||||
// Unset temporary session variables.
|
||||
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')))
|
||||
{
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('');
|
||||
header('location:'.$returnUrl);
|
||||
$this->setRedirectUrl($returnUrl);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set FTP Information
|
||||
|
|
@ -436,7 +460,7 @@ class installController extends install
|
|||
/**
|
||||
* @brief License agreement
|
||||
*/
|
||||
function procInstallLicenseAggrement()
|
||||
function procInstallLicenseAgreement()
|
||||
{
|
||||
$vars = Context::getRequestVars();
|
||||
|
||||
|
|
@ -575,134 +599,6 @@ class installController extends install
|
|||
if(method_exists($oModule, 'moduleInstall')) $oModule->moduleInstall();
|
||||
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 */
|
||||
/* Location: ./modules/install/install.controller.php */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
$output = $oInstallController->procInstall($install_config);
|
||||
if (!$output->toBool())
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
else
|
||||
{
|
||||
header("location: ./");
|
||||
Context::close();
|
||||
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))
|
||||
{
|
||||
foreach($disableList AS $key=>$value)
|
||||
foreach($disableList as $key => $value)
|
||||
{
|
||||
if($value->db_type == $defaultDatabase)
|
||||
{
|
||||
$defaultDatabase = 'mysql';
|
||||
$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('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 */
|
||||
|
|
|
|||
|
|
@ -8,6 +8,5 @@
|
|||
<field name="password2" required="true" length="1:60" equalto="password" />
|
||||
<field name="nick_name" required="true" length="2:20" />
|
||||
<field name="user_id" required="true" length="2:20" rule="userid" />
|
||||
<field name="time_zone" required="true" />
|
||||
</fields>
|
||||
</ruleset>
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ $obj->email_address = $logged_info->email_address;
|
|||
|
||||
$obj->module_srl = $module_srl;
|
||||
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);
|
||||
|
||||
|
|
@ -279,7 +279,7 @@ if(!$output->toBool()) return $output;
|
|||
$document_srl = $output->get('document_srl');
|
||||
|
||||
unset($obj->document_srl);
|
||||
$obj->title = 'Welcome mobile Rhymix';
|
||||
$obj->title = 'Welcome to Mobile Rhymix';
|
||||
$output = $oDocumentController->insertDocument($obj, true);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
<tr id="mod_rewrite_no_support" style="display:none">
|
||||
<td colspan="2" class="error_description">
|
||||
{$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>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -53,7 +53,7 @@
|
|||
<a href="{getUrl('', 'act','dispInstallLicenseAgreement')}" class="button grey">« {$lang->cmd_back}</a>
|
||||
</div>
|
||||
<div class="align-right">
|
||||
<a cond="$install_enable" class="button" id="task-checklist-confirm" href="{getUrl('','act','dispInstallSelectDB')}">{$lang->cmd_next} »</a>
|
||||
<a cond="$install_enable" class="button" id="task-checklist-confirm" href="{getUrl('','act','dispInstallDBConfig')}">{$lang->cmd_next} »</a>
|
||||
<a cond="!$install_enable" class="button" id="task-checklist-fix" href="{getUrl('','act',$act)}">{$lang->cmd_install_refresh_page} »</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
</div>
|
||||
<input type="hidden" value="{$error_return_url}" name="error_return_url">
|
||||
<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">
|
||||
<label for="db_type" class="x_control-label">{$lang->db_type}</label>
|
||||
<div class="x_controls">
|
||||
|
|
@ -27,28 +27,28 @@
|
|||
</div>
|
||||
<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">
|
||||
<label for="dbHostName" class="x_control-label">{$lang->db_hostname}</label>
|
||||
<div class="x_controls"><input name="db_hostname" value="localhost" type="text" id="dbHostName" required /></div>
|
||||
<label for="db_host" class="x_control-label">{$lang->db_hostname}</label>
|
||||
<div class="x_controls"><input name="db_host" value="localhost" type="text" id="db_host" required /></div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label for="dbPort" class="x_control-label">{$lang->db_port}</label>
|
||||
<div class="x_controls"><input name="db_port" value="3306" type="text" id="dbPort" required /></div>
|
||||
<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="db_port" required /></div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label for="dbId" class="x_control-label">{$lang->db_userid}</label>
|
||||
<div class="x_controls"><input name="db_userid" type="text" id="dbId" class="focus" required /></div>
|
||||
<label for="db_user" class="x_control-label">{$lang->db_userid}</label>
|
||||
<div class="x_controls"><input name="db_user" type="text" id="db_user" class="focus" required /></div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label for="dbPw" class="x_control-label">{$lang->db_password}</label>
|
||||
<div class="x_controls"><input name="db_password" type="password" id="dbPw" required /></div>
|
||||
<label for="db_pass" class="x_control-label">{$lang->db_password}</label>
|
||||
<div class="x_controls"><input name="db_pass" type="password" id="db_pass" required /></div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label for="dbName" class="x_control-label">{$lang->db_name}</label>
|
||||
<div class="x_controls"><input name="db_database" type="text" id="dbName" required /></div>
|
||||
<label for="db_database" class="x_control-label">{$lang->db_name}</label>
|
||||
<div class="x_controls"><input name="db_database" type="text" id="db_database" required /></div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label for="dbPrefix" 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>
|
||||
<label for="db_prefix" class="x_control-label">{$lang->db_table_prefix}</label>
|
||||
<div class="x_controls"><input name="db_prefix" type="text" id="db_prefix" value="rx" required /></div>
|
||||
</div>
|
||||
<p class="install_help">
|
||||
{$lang->db_info_desc}<br />{$lang->db_prefix_desc}
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
<div cond="$XE_VALIDATOR_MESSAGE" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
|
||||
<p>{$XE_VALIDATOR_MESSAGE}</p>
|
||||
</div>
|
||||
<input type="hidden" name="act" value="procInstallLicenseAggrement">
|
||||
<input type="hidden" name="act" value="procInstallLicenseAgreement">
|
||||
<input type="hidden" name="module" value="install">
|
||||
<div class="content-license">
|
||||
<include target="license_text.ko.html" cond="$lang_type === 'ko'" />
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
<!--<a href="{getUrl('', 'act','')}" class="button grey">« {$lang->cmd_back}</a>-->
|
||||
</div>
|
||||
<div class="align-right">
|
||||
<button type="submit" id="task-license-aggrement" value="">{$lang->cmd_next} »</button>
|
||||
<button type="submit" id="task-license-agreement" value="">{$lang->cmd_next} »</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
<p>{$XE_VALIDATOR_MESSAGE}</p>
|
||||
</div>
|
||||
<input type="hidden" name="act" value="procInstall" />
|
||||
<input type="hidden" name="use_rewrite" value="{$use_rewrite}" />
|
||||
<div class="x_control-group">
|
||||
<label for="aMail" class="x_control-label">{$lang->email_address}</label>
|
||||
<div class="x_controls">
|
||||
|
|
@ -61,7 +60,7 @@
|
|||
</div>
|
||||
<div id="buttons">
|
||||
<div class="align-left">
|
||||
<a href="{getUrl('', 'act','dispInstallSelectDB')}" class="button grey">« {$lang->cmd_back}</a>
|
||||
<a href="{getUrl('', 'act','dispInstallDBConfig')}" class="button grey">« {$lang->cmd_back}</a>
|
||||
</div>
|
||||
<div class="align-right">
|
||||
<button type="submit" id="task-done" value="">{$lang->cmd_complete} »</button>
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
<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 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=='dispInstallManagerForm'">{$lang->install_progress_menu['adminInfo']}</li>
|
||||
<li class="active"|cond="$act=='dispInstallDBConfig' && $progressMenu == '4'">{$lang->install_progress_menu['dbInfo']}</li>
|
||||
<li class="active"|cond="$act=='dispInstallAdminConfig'">{$lang->install_progress_menu['adminInfo']}</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue