28 ini_set(
'memory_limit', -1);
29 error_reporting(E_ALL);
33 if ((php_sapi_name() ==
'cli')) {
34 if (isset($_SERVER[
'argv'][1])) {
35 $SYSTEM_ROOT = $_SERVER[
'argv'][1];
38 $err_msg =
"ERROR: You need to supply the path to the System Root as the first argument.\n";
41 if (isset($_GET[
'SYSTEM_ROOT'])) {
42 $SYSTEM_ROOT = $_GET[
'SYSTEM_ROOT'];
46 <div style="background-color: red; color: white; font-weight: bold;">
47 You need to supply the path to the System Root as a query string variable called SYSTEM_ROOT
52 if (empty($SYSTEM_ROOT)) {
53 $err_msg .=
"Usage: php install/step_02.php <PATH_TO_MATRIX>\n";
58 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
59 $err_msg =
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
60 $err_msg .=
"Usage: php install/step_02.php <PATH_TO_MATRIX>\n";
65 define(
'SQ_SYSTEM_ROOT', $SYSTEM_ROOT);
66 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
67 require_once $SYSTEM_ROOT.
'/install/install.inc';
68 require_once SQ_LIB_PATH.
'/db_install/db_install.inc';
69 require_once SQ_INCLUDE_PATH.
'/system_config.inc';
70 require_once SQ_LIB_PATH.
'/file_versioning/file_versioning.inc';
73 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
78 $cfg->save(Array(), FALSE);
81 if (!(SQ_CONF_TECH_EMAIL) && !(SQ_CONF_DEFAULT_EMAIL)) {
82 trigger_error(
'Neither the System Default nor Tech email addresses have been set', E_USER_WARNING);
84 if (!SQ_CONF_TECH_EMAIL) {
85 trigger_error(
'The System Tech email address has not been set', E_USER_WARNING);
87 if (!SQ_CONF_DEFAULT_EMAIL) {
88 trigger_error(
'The System Default email address has not been set', E_USER_WARNING);
93 $query =
"SELECT value FROM nls_session_parameters WHERE parameter='NLS_DATE_FORMAT'";
95 $nls_format = $value[0];
96 $expected =
'YYYY-MM-DD HH24:MI:SS';
97 if ($nls_format !== $expected) {
98 trigger_error(
'NLS_DATE_FORMAT has not been set correctly. It needs to be '.$expected, E_USER_ERROR);
102 $cached_table_columns = Array();
106 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
107 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
108 $db =& $GLOBALS[
'SQ_SYSTEM']->db;
110 install_stored_relations(
'functions');
112 if (file_exists(SQ_DATA_PATH.
'/private/db/table_columns.inc')) {
113 unlink(SQ_DATA_PATH.
'/private/db/table_columns.inc');
116 if (!db_install(SQ_CORE_PACKAGE_PATH.
'/tables.xml')) {
117 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
118 trigger_error(
'TABLE INSTALL FAILURE', E_USER_ERROR);
122 $packages = get_package_list();
124 foreach ($packages as $package) {
125 $xml_file = SQ_PACKAGES_PATH.
'/'.$package.
'/tables.xml';
126 if (file_exists($xml_file)) {
127 echo
"\n".
'*** Package: '.$package.
"\n";
128 if (!db_install($xml_file)) {
129 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
130 trigger_error(
'TABLE INSTALL FAILURE', E_USER_ERROR);
132 install_stored_relations(
'functions', $package);
137 install_stored_relations(
'views');
139 $fv = $GLOBALS[
'SQ_SYSTEM']->getFileVersioning();
141 if (!$fv->initRepository()) {
142 trigger_error(
'Unable to initialise File Versioning Repository', E_USER_ERROR);
145 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
155 if (!defined(
'SQ_CONF_ENABLE_ROLES_PERM_SYSTEM') && !defined(
'SQ_CONF_ENABLE_ROLES_WF_SYSTEM')) {
156 if(defined(
'SQ_CONF_ENABLE_ROLES_SYSTEM') && SQ_CONF_ENABLE_ROLES_SYSTEM ==
'1' ) {
157 $vars[
'SQ_CONF_ENABLE_ROLES_PERM_SYSTEM'] =
'1';
158 $vars[
'SQ_CONF_ENABLE_ROLES_WF_SYSTEM'] =
'1';
161 $vars[
'SQ_CONF_ENABLE_ROLES_PERM_SYSTEM'] =
'0';
162 $vars[
'SQ_CONF_ENABLE_ROLES_WF_SYSTEM'] =
'0';
165 $cfg->save($vars, FALSE);
167 $enabled = ((SQ_CONF_ENABLE_ROLES_PERM_SYSTEM ==
'1' ) || (SQ_CONF_ENABLE_ROLES_WF_SYSTEM ==
'1'));
171 if (!defined(
'SQ_CONF_COOKIE_OPTION_HTTP_ONLY') || !defined(
'SQ_CONF_COOKIE_OPTION_SECURE')) {
172 if (!defined(
'SQ_CONF_COOKIE_OPTION_HTTP_ONLY')) {
173 $vars[
'SQ_CONF_COOKIE_OPTION_HTTP_ONLY'] = FALSE;
175 if (!defined(
'SQ_CONF_COOKIE_OPTION_SECURE')) {
176 $vars[
'SQ_CONF_COOKIE_OPTION_SECURE'] = FALSE;
181 echo
"\n".
'Configuring Roles Views... ';
182 $roles_configured = $cfg->configureRoleTables($enabled, SQ_CONF_ENABLE_GLOBAL_ROLES);
183 if ($roles_configured) {
186 echo
"FAILED! Existing definition retained\n\n";
190 grant_secondary_user_perms();
192 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
193 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();