25 if (ini_get(
'memory_limit') !=
'-1') ini_set(
'memory_limit',
'-1');
27 error_reporting(E_ALL);
28 if (count($_SERVER[
'argv']) < 3 || php_sapi_name() !=
'cli') {
29 echo
"This script needs to be run in the following format:\n\n";
30 echo
"\tphp system_integrity_fix_public_files.php SYSTEM_ROOT ROOT_ID\n\n";
34 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
35 if (empty($SYSTEM_ROOT)) {
36 echo
"ERROR: You need to supply the path to the System Root as the first argument\n";
40 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
41 echo
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
45 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
47 $ROOT_ID = (isset($_SERVER[
'argv'][2])) ? $_SERVER[
'argv'][2] :
'';
48 assert_valid_assetid($ROOT_ID,
"The ROOT_ID '$ROOT_ID' specified is invalid");
50 $root_user = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
51 if (!$GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user)) {
52 echo
"ERROR: Failed login in as root user\n";
57 $assetids = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($ROOT_ID,
'file', FALSE);
59 if ($ROOT_ID !=
'1') {
60 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($ROOT_ID);
61 if ($GLOBALS[
'SQ_SYSTEM']->am->isTypeDecendant($asset->type(),
'file')) {
62 $assetids[$asset->id] = Array(0 => Array(
'type_code' => $asset->type()));
66 foreach ($assetids as $assetid => $asset_info) {
67 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
70 $asset->permissionsUpdated();
71 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
74 $GLOBALS[
'SQ_SYSTEM']->restoreCurrentUser();