42 ini_set(
'memory_limit', -1);
43 if (!defined(
'PHP_VERSION_ID')) {
44 $version = explode(
'.', PHP_VERSION);
45 define(
'PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
51 if (PHP_VERSION_ID < 50300) {
54 error_reporting(E_ALL);
57 error_reporting(E_ALL ^ E_DEPRECATED);
64 if ((php_sapi_name() ==
'cli')) {
65 if (isset($_SERVER[
'argv'][1])) {
66 $SYSTEM_ROOT = $_SERVER[
'argv'][1];
69 $err_msg =
"ERROR: You need to supply the path to the System Root as the first argument.\n";
73 if (isset($_GET[
'SYSTEM_ROOT'])) {
74 $SYSTEM_ROOT = $_GET[
'SYSTEM_ROOT'];
78 <div style="background-color: red; color: white; font-weight: bold;">
79 You need to supply the path to the System Root as a query string variable called SYSTEM_ROOT
84 if (empty($SYSTEM_ROOT)) {
85 $err_msg .=
"Usage: php install/step_03.php <PATH_TO_MATRIX>\n";
90 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
91 $err_msg =
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
92 $err_msg .=
"Usage: php install/step_03.php <PATH_TO_MATRIX>\n";
99 require_once
'Console/Getopt.php';
102 $longopt = Array(
'package=');
104 $con =
new Console_Getopt;
105 $args = $con->readPHPArgv();
107 $options = $con->getopt($args, $shortopt, $longopt);
109 if (is_array($options[0])) {
110 $package_list = get_console_list($options[0]);
114 if (!defined(
'SQ_SYSTEM_ROOT')) {
115 define(
'SQ_SYSTEM_ROOT', $SYSTEM_ROOT);
118 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
122 require_once SQ_FUDGE_PATH.
'/general/www.inc';
124 $SQ_CONF_DEFAULT_EMAIL = SQ_CONF_DEFAULT_EMAIL;
125 if (!empty($SQ_CONF_DEFAULT_EMAIL) && !valid_email($SQ_CONF_DEFAULT_EMAIL)) {
126 echo
"Value '$SQ_CONF_DEFAULT_EMAIL' configued for 'SQ_CONF_DEFAULT_EMAIL' in main.inc is not valid.\nPlease fix it and try running the script again.\n";
129 $SQ_CONF_TECH_EMAIL = SQ_CONF_TECH_EMAIL;
130 if (!empty($SQ_CONF_TECH_EMAIL) && !valid_email($SQ_CONF_TECH_EMAIL)) {
131 echo
"Value '$SQ_CONF_TECH_EMAIL' configured for 'SQ_CONF_TECH_EMAIL' in main.inc is not valid.\nPlease fix it and try running the script again.\n";
136 require_once $SYSTEM_ROOT.
'/core/include/deja_vu.inc';
138 if ($deja_vu->enabled()) $deja_vu->forgetAll();
141 require_once $SYSTEM_ROOT.
'/install/install.inc';
143 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
144 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
147 if (version_compare(PHP_VERSION, SQ_REQUIRED_PHP_VERSION,
'<')) {
148 trigger_error(
'<i>'.SQ_SYSTEM_LONG_NAME.
'</i> requires PHP Version '.SQ_REQUIRED_PHP_VERSION.
'.<br/> You may need to upgrade.<br/> Your current version is '.PHP_VERSION, E_USER_ERROR);
152 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
155 install_dal_core_queries();
156 $packages = get_package_list();
157 foreach ($packages as $package) {
158 install_dal_package_queries($package);
162 if (!regenerate_configs()) {
163 trigger_error(
'Config Generation Failed', E_USER_ERROR);
165 require_once $SYSTEM_ROOT.
'/install/generate_install_key.php';
168 if (!isset($package_list)) $package_list = Array();
171 generate_lang_char_map();
173 generate_import_tools_manager_config();
175 uninstall_asset_types();
176 uninstall_packages();
178 install_core($package_list);
179 $deferred = install_packages($package_list);
181 if (is_array($deferred)) {
185 $deferred = install_deferred($deferred);
186 if (is_array($deferred)) {
187 trigger_error(
'The following assets could not be installed due to dependency failures (see previous warnings for details): '.
"\n".format_deferred_packages($deferred), E_USER_ERROR);
191 install_authentication_types();
192 generate_global_preferences();
193 install_event_listeners();
195 generate_performance_config();
196 generate_file_bridge_config();
199 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
201 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
202 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
215 function get_console_list($options)
219 foreach ($options as $option) {
221 if (!isset($option[0]) || !isset($option[1])) {
225 if ($option[0] !=
'--package')
continue;
228 $parts = explode(
'-', $option[1]);
231 if (count($parts) == 2 && strlen($parts[1])) {
232 $types = explode(
',', $parts[1]);
235 $list[$parts[0]] = $types;