29 ini_set(
'memory_limit', -1);
30 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_01.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_01.php <PATH_TO_MATRIX>\n";
65 $SYSTEM_ROOT = realpath($SYSTEM_ROOT);
67 if (!defined(
'SQ_SYSTEM_ROOT')) {
68 define(
'SQ_SYSTEM_ROOT', $SYSTEM_ROOT);
70 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
71 require_once $SYSTEM_ROOT.
'/install/install.inc';
72 require_once $SYSTEM_ROOT.
'/core/include/general_occasional.inc';
73 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
75 echo
'Updating parse files of login designs for #5038'.
"\n";
78 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
80 $design_folder = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'designs_folder');
81 $children = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($design_folder->id,
'design', FALSE);
82 $fv = $GLOBALS[
'SQ_SYSTEM']->getFileVersioning();
84 foreach ($children as $id => $content) {
85 if(!isset($content[0][
'type_code'])) {
86 trigger_error(
'can not find type code of designs');
90 echo
"Updating design #".$id.
"\n";
92 switch ($content[0][
'type_code']) {
94 $new_parse_file = $SYSTEM_ROOT.
'/core/assets/system/login_design/design_files/index.html';
95 $source_parse_file_md5 =
'38c31c49d16ae6dee3e2a47e693ba003';
97 case 'password_change_design':
98 $new_parse_file = $SYSTEM_ROOT.
'/core/assets/system/password_change_design/design_files/index.html';
99 $source_parse_file_md5 =
'228a10aa65433b652f32f1c3b4037b3e';
101 case 'ees_login_design':
102 $new_parse_file = $SYSTEM_ROOT.
'/core/assets/system/ees_login_design/design_files/index.html';
103 $source_parse_file_md5 =
'f0acced582b5b9d355ce2a4b22595cc1';
109 $new_file = file_get_contents($new_parse_file);
110 $design = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($id);
111 $design_edit_fns = $design->getEditFns();
112 $type_code = ucwords(str_replace(
'_',
' ', $design->type()));
116 $parse_file = $design->data_path.
'/parse.txt';
117 $ext_file = file_get_contents($parse_file);
118 $parse_file_md5 = md5(file_get_contents($parse_file));
119 if ($parse_file_md5 != $source_parse_file_md5) {
120 echo
'Parse file in '.$type_code.
' was modified. Skipping.'.
"\n";
122 else if (!is_file($parse_file) || !is_file($new_parse_file)) {
123 trigger_error (
'parse file is not available');
128 if(!_updateFile($new_parse_file,
'parse.txt', $design->data_path, $design->data_path_suffix)) {
129 trigger_error(
'failed to update parse file '.$new_parse_file);
133 $design_edit_fns->parseAndProcessFile($design);
134 $design->generateDesignFile();
136 echo
'Parse file in '.$type_code.
' Successfully updated...'.
"\n";
140 echo
"\n".
'All desings updated successfully'.
"\n";
142 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
143 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($design_folder->id, TRUE);
153 function _updateFile ($new_file, $file_name, $data_path, $data_path_suffix) {
154 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
155 $fv = $GLOBALS[
'SQ_SYSTEM']->getFileVersioning();
157 $file_path = $data_path.
'/'.$file_name;
159 if (!unlink($file_path)) {
160 trigger_error(
'failed to remove old file '.$file_name);
164 if (string_to_file(file_get_contents($new_file), $file_path)) {
166 $file_status = $fv->upToDate($file_path);
167 if (FUDGE_FV_MODIFIED & $file_status) {
168 if (!$fv->commit($file_path,
'')) {
169 trigger_localised_error(
'CORE0160', E_USER_WARNING);
173 trigger_error(
'Can not overwrite old file '.$file_name);
177 if (!$fv->checkOut($data_path_suffix.
'/'.$file_name, $data_path)) {
178 trigger_localised_error(
'CORE0032', E_USER_WARNING);