8 define(
'CH_INSTALL_DO_NOT_EXIT_ON_ERROR', 1);
13 require_once(
$aPathInfo[
'dirname'] .
'/index.php');
24 'success' => array (
'code' => 0,
'msg' =>
'Success.'),
25 'already installed' => array (
'code' => 0,
'msg' =>
'Script is already installed. Can\'t perform install.'),
26 'requirements failed' => array (
'code' => 2,
'msg' =>
'Requirements aren\'t met.'),
27 'permissions failed' => array (
'code' => 3,
'msg' =>
'Folders and/or files permissions aren\'t correct.'),
28 'create config failed' => array (
'code' => 4,
'msg' =>
'Form data was not submitted.'),
29 'lang compile failed' => array (
'code' => 5,
'msg' =>
'Language compilation failed.'),
36 $this->_aSiteConfig = array (
37 'site_url' =>
'localhost',
38 'site_dir' => str_replace(
'/install',
'/',
$aPathInfo[
'dirname']),
39 'php_path' =>
'/usr/bin/php',
41 'site_config' =>
true,
44 'db_password' =>
'root',
45 'site_title' =>
'Cheetah',
46 'site_email' =>
'no-reply@example.com',
47 'admin_email' =>
'admin@example.com',
48 'admin_username' =>
'admin',
49 'admin_password' =>
'cheetah',
52 $this->_sHeaderPath = $this->_aSiteConfig[
'site_dir'] .
'inc/header.inc.php';
62 $this->
finish($this->_aReturnCodes[
'success'][
'code'], $this->
getHelp());
65 $this->_isQuiet =
true;
67 $this->_aSiteConfig = array_merge($this->_aSiteConfig, $a);
80 $this->
finish($this->_aReturnCodes[
'success'][
'code'], $this->_aReturnCodes[
'success'][
'msg']);
86 foreach ($this->_aSiteConfig
as $sKey => $sValue)
87 if (
'site_config' != $sKey)
94 $s =
"Usage: php cmd.php [options]\n";
96 $s .= str_pad(
"\t -h", 35) .
"Print this help\n";
97 $s .= str_pad(
"\t -q", 35) .
"Quiet\n";
99 foreach ($this->_aSiteConfig
as $sKey => $sVal)
100 if (
'site_config' != $sKey)
101 $s .= str_pad(
"\t --{$sKey}=<value>", 35) .
"Default value: {$sVal}\n";
104 $s .=
"Return codes:\n";
105 foreach ($this->_aReturnCodes
as $r)
106 $s .= str_pad(
"\t {$r['code']}", 5) .
"{$r['msg']}\n";
113 if (!$this->_isQuiet)
114 fwrite($iCode ? STDERR : STDOUT,
$sMsg .
"\n");
122 if (file_exists($this->_sHeaderPath))
123 $this->
finish($this->_aReturnCodes[
'already installed'][
'code'], $this->_aReturnCodes[
'already installed'][
'msg']);
129 $this->
finish($this->_aReturnCodes[
'requirements failed'][
'code'], $this->_aReturnCodes[
'requirements failed'][
'msg']);
138 $this->
finish($this->_aReturnCodes[
'permissions failed'][
'code'], $this->_aReturnCodes[
'permissions failed'][
'msg']);
146 if (!file_exists($this->_sHeaderPath))
147 $this->
finish($this->_aReturnCodes[
'create config failed'][
'code'], $this->_aReturnCodes[
'create config failed'][
'msg']);
153 require_once(
$GLOBALS[
'aPathInfo'][
'dirname'] .
'/../inc/header.inc.php');
154 require_once(CH_DIRECTORY_PATH_INC .
'design.inc.php');
157 $sLang =
db_value(
"SELECT `Name` FROM `sys_localization_languages` LIMIT 1");
158 if (
empty($sLang) || !file_exists(
$GLOBALS[
'aPathInfo'][
'dirname'] .
'/../langs/lang-' . $sLang .
'.php'))
159 $this->
finish($this->_aReturnCodes[
'lang compile failed'][
'code'], $this->_aReturnCodes[
'lang compile failed'][
'msg']);
164 $aSiteConfigMapVars = array (
165 'site_url' => &$this->_aSiteConfig[
'site_url'],
166 'dir_root' => &$this->_aSiteConfig[
'site_dir'],
167 'dir_php' => &$this->_aSiteConfig[
'php_path'],
170 'sql_file' => eval(
$GLOBALS[
'aDbConf'][
'sql_file'][
'def_exp']),
171 'db_host' =>
$GLOBALS[
'aDbConf'][
'db_host'][
'def'],
172 'db_port' =>
$GLOBALS[
'aDbConf'][
'db_port'][
'def'],
173 'db_sock' =>
$GLOBALS[
'aDbConf'][
'db_sock'][
'def'],
174 'db_name' => &$this->_aSiteConfig[
'db_name'],
175 'db_user' => &$this->_aSiteConfig[
'db_user'],
176 'db_password' => &$this->_aSiteConfig[
'db_password'],
179 'site_title' => &$this->_aSiteConfig[
'site_title'],
181 'site_email' => &$this->_aSiteConfig[
'admin_email'],
182 'notify_email' => &$this->_aSiteConfig[
'site_email'],
183 'bug_report_email' => &$this->_aSiteConfig[
'admin_email'],
184 'admin_username' => &$this->_aSiteConfig[
'admin_username'],
185 'admin_password' => &$this->_aSiteConfig[
'admin_password'],
188 foreach ($aSiteConfigMapVars
as $k => $v)