35 if (ini_get(
'memory_limit') !=
'-1') ini_set(
'memory_limit',
'-1');
36 error_reporting(E_ALL);
42 if ((php_sapi_name() ==
'cli')) {
43 if (isset($_SERVER[
'argv'][1])) {
44 $SYSTEM_ROOT = $_SERVER[
'argv'][1];
46 $err_msg =
"You need to supply the path to the System Root as the first argument\n";
50 if (isset($_GET[
'SYSTEM_ROOT'])) {
51 $SYSTEM_ROOT = $_GET[
'SYSTEM_ROOT'];
54 <div style="background-color: red; color: white; font-weight: bold;">
55 You need to supply the path to the System Root as a query string variable called SYSTEM_ROOT
60 if (empty($SYSTEM_ROOT)) {
65 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
66 echo
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
72 require_once
'Console/Getopt.php';
75 $longopt = Array(
'package=');
77 $con =
new Console_Getopt;
78 $args = $con->readPHPArgv();
80 $options = $con->getopt($args, $shortopt, $longopt);
82 if (is_array($options[0])) {
83 $package_list = get_console_list($options[0]);
87 if (!defined(
'SQ_SYSTEM_ROOT')) {
88 define(
'SQ_SYSTEM_ROOT', $SYSTEM_ROOT);
91 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
94 require_once $SYSTEM_ROOT.
'/install/install.inc';
96 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
97 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
100 if (version_compare(PHP_VERSION, SQ_REQUIRED_PHP_VERSION,
'<')) {
101 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);
104 $old_path = ini_get(
'include_path');
105 ini_set(
'include_path', SQ_LIB_PATH);
106 require_once SQ_LIB_PATH.
'/MatrixDAL/MatrixDALBaker.inc';
108 $packages = $GLOBALS[
'SQ_SYSTEM']->getInstalledPackages();
110 $asset_sql =
'SELECT type_code FROM sq_ast_typ';
113 print_status_name(
'Installing queries for MySource Matrix core...');
117 print_status_result(
'OK');
118 }
catch (Exception $e) {
119 print_status_result(
'FAILED');
120 echo
'(Exception: '.$e->getMessage().
')'.
"\n";
124 if (count($packages) === 0) {
125 print_status_name(
'No packages currently installed...');
126 print_status_result(
'SKIPPED');
128 print_status_name(
'Installing queries for installed packages ('.count($packages).
' packages)...');
130 foreach ($packages as $package) {
131 $package_name = $package[
'code_name'];
132 if ($package_name ==
'__core__') {
133 $package_name =
'core';
138 print_status_result(
'OK');
139 }
catch (Exception $e) {
140 print_status_result(
'FAILED');
141 echo
'(Exception at '.$package_name.
' package: '.$e->getMessage().
')'.
"\n";
146 if (count($asset_types) === 0) {
147 print_status_name(
'No assets currently installed...');
148 print_status_result(
'SKIPPED');
150 print_status_name(
'Installing queries for installed assets ('.count($asset_types).
' assets)...');
152 foreach ($asset_types as $type_code) {
156 print_status_result(
'OK');
157 }
catch (Exception $e) {
158 print_status_result(
'FAILED');
159 echo
'(Exception at '.$type_code.
' asset: '.$e->getMessage().
')'.
"\n";
164 ini_set(
'include_path', $old_path);
165 pre_echo(
'Query Installation Complete');
181 function get_console_list($options)
185 foreach ($options as $option) {
187 if (!isset($option[0]) || !isset($option[1])) {
191 if ($option[0] !=
'--package')
continue;
194 $parts = explode(
'-', $option[1]);
197 if (count($parts) == 2 && strlen($parts[1])) {
198 $types = explode(
',', $parts[1]);
201 $list[$parts[0]] = $types;
217 function print_status_name($name)
219 printf (
'%s%'.(60 - strlen($name)).
's', $name,
'');
232 function print_status_result($status)
234 echo
"[ $status ]\n";