28 ini_set(
'memory_limit', -1);
29 error_reporting(E_ALL);
32 if ((php_sapi_name() ==
'cli')) {
33 if (isset($_SERVER[
'argv'][1])) {
34 $SYSTEM_ROOT = $_SERVER[
'argv'][1];
37 $err_msg =
"ERROR: You need to supply the path to the System Root as the first argument\n";
40 if (isset($_GET[
'SYSTEM_ROOT'])) {
41 $SYSTEM_ROOT = $_GET[
'SYSTEM_ROOT'];
45 <div style="background-color: red; color: white; font-weight: bold;">
46 You need to supply the path to the System Root as a query string variable called SYSTEM_ROOT
51 if (empty($SYSTEM_ROOT)) {
52 $err_msg .=
"Usage: php install/step_01.php <PATH_TO_MATRIX>\n";
57 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
58 $err_msg =
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
59 $err_msg .=
"Usage: php install/step_01.php <PATH_TO_MATRIX>\n";
64 $SYSTEM_ROOT = realpath($SYSTEM_ROOT);
66 if (!defined(
'SQ_SYSTEM_ROOT')) {
67 define(
'SQ_SYSTEM_ROOT', $SYSTEM_ROOT);
69 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
70 require_once $SYSTEM_ROOT.
'/install/install.inc';
71 require_once $SYSTEM_ROOT.
'/core/include/general_occasional.inc';
72 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
74 echo
'Updating new Squiz Logo for login design, password change design, EES login design ...'.
"\n";
77 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
79 $design_folder = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'designs_folder');
80 $children = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($design_folder->id,
'design', FALSE);
81 $fv = $GLOBALS[
'SQ_SYSTEM']->getFileVersioning();
83 foreach ($children as $id => $content) {
84 if(!isset($content[0][
'type_code'])) {
85 trigger_error(
'can not find type code of designs');
88 switch ($content[0][
'type_code']) {
90 $file_name =
'login_image.gif';
91 $path = $SYSTEM_ROOT.
'/core/assets/system/login_design/design_files/files/'.$file_name;
92 $md5 =
'99029df0982274ce2f1c3404b6902f0f';
94 case 'password_change_design':
95 $file_name =
'login_image.gif';
96 $path = $SYSTEM_ROOT.
'/core/assets/system/password_change_design/design_files/files/'.$file_name;
97 $md5 =
'99029df0982274ce2f1c3404b6902f0f';
99 case 'ees_login_design':
100 $file_name =
'matrix-logo.png';
101 $path = $SYSTEM_ROOT.
'/core/assets/system/ees_login_design/design_files/files/'.$file_name;
102 $md5 =
'9ade1af14bab1611aef70b91f1401d3e';
104 $new_parse_file = $SYSTEM_ROOT.
'/core/assets/system/ees_login_design/design_files/index.html';
105 $parse_file_md5_3_28 =
'cd9c6761bae67fdc78474a540a096e58';
106 $parse_file_md5_3_29 =
'15c8ab31d536fac3c6035da4d601e690';
112 $design = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($id);
113 $design_edit_fns = $design->getEditFns();
114 $type_code = $design->type();
118 if($type_code ===
'ees_login_design') {
119 $parse_file = $design->data_path.
'/parse.txt';
120 $parse_file_md5 = md5(file_get_contents($parse_file));
121 if($parse_file_md5 !== $parse_file_md5_3_28 && $parse_file_md5 !== $parse_file_md5_3_29) {
122 echo
'Parse file in '.$type_code.
' was modified. Skip...'.
"\n";
124 else if (!is_file($parse_file) || !is_file($new_parse_file)) {
125 trigger_error (
'parse file is not available');
130 if(!_updateFile($new_parse_file,
'parse.txt', $design->data_path, $design->data_path_suffix)) {
131 trigger_error(
'failed to update ees parse file '.$file_name);
135 $design_edit_fns->parseAndProcessFile($design);
136 $design->generateDesignFile();
138 echo
'Parse file in ees_login_design. Successfully updated...'.
"\n";
144 $existing_ids = Array();
145 $existing = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($design->id, SQ_LINK_TYPE_2,
'file', FALSE);
147 foreach ($existing as $link) {
148 $existing_ids[$link[
'minorid']] = $link[
'linkid'];
151 $existing_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_keys($existing_ids));
155 $file_name = make_valid_web_paths(Array($file_name));
156 $file_name = array_shift($file_name);
158 $existing_fileid = 0;
160 foreach ($existing_info as $asset_id => $asset_info) {
161 if ($asset_info[
'name'] == $file_name) {
162 $existing_fileid = $asset_id;
167 if(empty($existing_fileid)) {
168 trigger_error(
'Can not find original logo image');
173 $file = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($existing_fileid);
176 $file_info = $file->getExistingFile();
177 if(md5_file($file_info[
'path']) !== $md5) {
178 echo $file_name.
' in '.$type_code.
' was modified. Skip...'.
"\n";
183 if(!_updateFile($path, $file_name, $file->data_path, $file->data_path_suffix)) {
184 trigger_error(
'failed to update logo '.$file_name);
189 echo $file_name.
' in '.$type_code.
'. Successfully updated...'.
"\n";
195 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
206 function _updateFile ($new_file, $file_name, $data_path, $data_path_suffix) {
207 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
208 $fv = $GLOBALS[
'SQ_SYSTEM']->getFileVersioning();
210 $file_path = $data_path.
'/'.$file_name;
212 if (!unlink($file_path)) {
213 trigger_error(
'failed to remove old file '.$file_name);
218 if (string_to_file(file_get_contents($new_file), $file_path)) {
220 $file_status = $fv->upToDate($file_path);
221 if (FUDGE_FV_MODIFIED & $file_status) {
222 if (!$fv->commit($file_path,
'')) {
223 trigger_localised_error(
'CORE0160', E_USER_WARNING);
227 trigger_error(
'Can not overwrite old file '.$file_name);
231 if (!$fv->checkOut($data_path_suffix.
'/'.$file_name, $data_path)) {
232 trigger_localised_error(
'CORE0032', E_USER_WARNING);