Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
step_03.php
1 <?php
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]));
46 }
47 
48 
49 // set the level of PHP reported errors and some other
50 // PHP thingies we want done OUR way
51 if (PHP_VERSION_ID < 50300) {
52  // pear http/client module contains deprecated syntax which will cause trouble
53  // E_DEPRECATED is introduced in PHP 5.3 and included in E_ALL, so has to remove E_DEPRECATED for php 5.3 and above
54  error_reporting(E_ALL);
55 }
56 else {
57  error_reporting(E_ALL ^ E_DEPRECATED);
58 }
59 $SYSTEM_ROOT = '';
60 
61 $cli = TRUE;
62 
63 // from cmd line
64 if ((php_sapi_name() == 'cli')) {
65  if (isset($_SERVER['argv'][1])) {
66  $SYSTEM_ROOT = $_SERVER['argv'][1];
67  }
68 
69  $err_msg = "ERROR: You need to supply the path to the System Root as the first argument.\n";
70 
71 } else {
72  $cli = FALSE;
73  if (isset($_GET['SYSTEM_ROOT'])) {
74  $SYSTEM_ROOT = $_GET['SYSTEM_ROOT'];
75  }
76 
77  $err_msg = '
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
80  </div>
81  ';
82 }
83 
84 if (empty($SYSTEM_ROOT)) {
85  $err_msg .= "Usage: php install/step_03.php <PATH_TO_MATRIX>\n";
86  echo $err_msg;
87  exit();
88 }
89 
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";
93  echo $err_msg;
94  exit();
95 }
96 
97 // only use console stuff if we're running from the command line
98 if ($cli) {
99  require_once 'Console/Getopt.php';
100 
101  $shortopt = '';
102  $longopt = Array('package=');
103 
104  $con = new Console_Getopt;
105  $args = $con->readPHPArgv();
106  array_shift($args);
107  $options = $con->getopt($args, $shortopt, $longopt);
108 
109  if (is_array($options[0])) {
110  $package_list = get_console_list($options[0]);
111  }
112 }
113 
114 if (!defined('SQ_SYSTEM_ROOT')) {
115  define('SQ_SYSTEM_ROOT', $SYSTEM_ROOT);
116 }
117 
118 require_once $SYSTEM_ROOT.'/core/include/init.inc';
119 
120 // check to see if the default/ tech email in main.inc are provided and are correct
121 // for more info see bug report 5804 Default and Tech Emails shouldnt break install
122 require_once SQ_FUDGE_PATH.'/general/www.inc';
123 
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";
127  exit(1);
128 }
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";
132  exit(1);
133 }
134 
135 // Clean up any remembered data.
136 require_once $SYSTEM_ROOT.'/core/include/deja_vu.inc';
137 $deja_vu = new Deja_Vu();
138 if ($deja_vu->enabled()) $deja_vu->forgetAll();
139 
140 // get the list of functions used during install
141 require_once $SYSTEM_ROOT.'/install/install.inc';
142 
143 $GLOBALS['SQ_SYSTEM']->changeDatabaseConnection('db2');
144 $GLOBALS['SQ_SYSTEM']->doTransaction('BEGIN');
145 
146 // firstly let's check that we are OK for the version
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);
149 }
150 
151 // let everyone know we are installing
152 $GLOBALS['SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
153 
154 // Install all DAL core and package queries upfront
155 install_dal_core_queries();
156 $packages = get_package_list();
157 foreach ($packages as $package) {
158  install_dal_package_queries($package);
159 }
160 
161 // call all the steps
162 if (!regenerate_configs()) {
163  trigger_error('Config Generation Failed', E_USER_ERROR);
164 }
165 require_once $SYSTEM_ROOT.'/install/generate_install_key.php';
166 
167 // check if the $packageList variable has been defined at all
168 if (!isset($package_list)) $package_list = Array();
169 
170 // generate the char map first, creating asset will need this
171 generate_lang_char_map();
172 
173 generate_import_tools_manager_config();
174 
175 uninstall_asset_types();
176 uninstall_packages();
177 
178 install_core($package_list);
179 $deferred = install_packages($package_list);
180 // if there were deferred packages, try to reinstall them.
181 if (is_array($deferred)) {
182  // try and install the deferred packages again in a loop until the result
183  // package is the same as the install package, at which point we know
184  // the dependency has failed.
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);
188  }
189 }
190 
191 install_authentication_types();
192 generate_global_preferences();
193 install_event_listeners();
194 cache_asset_types();
195 generate_performance_config();
196 generate_file_bridge_config();
197 minify_css_files();
198 
199 $GLOBALS['SQ_SYSTEM']->restoreRunLevel();
200 
201 $GLOBALS['SQ_SYSTEM']->doTransaction('COMMIT');
202 $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
203 
204 
215 function get_console_list($options)
216 {
217  $list = Array();
218 
219  foreach ($options as $option) {
220  // if nothing set, skip this entry
221  if (!isset($option[0]) || !isset($option[1])) {
222  continue;
223  }
224 
225  if ($option[0] != '--package') continue;
226 
227  // Now process the list
228  $parts = explode('-', $option[1]);
229 
230  $types = Array();
231  if (count($parts) == 2 && strlen($parts[1])) {
232  $types = explode(',', $parts[1]);
233  }
234 
235  $list[$parts[0]] = $types;
236  }
237 
238  return $list;
239 
240 }//end get_console_list()
241 
242 
243 ?>