24 error_reporting(E_ALL);
25 if ((php_sapi_name() !=
'cli')) trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
27 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
28 if (empty($SYSTEM_ROOT)) {
29 echo
"ERROR: You need to supply the path to the System Root as the first argument\n";
33 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
34 echo
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
38 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
41 $root_user = &$GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
42 if (!$GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user)) {
43 echo
"Failed login in as root user\n";
47 $ROOT_ASSETID = (isset($_SERVER[
'argv'][2])) ? $_SERVER[
'argv'][2] :
'1';
48 if ($ROOT_ASSETID == 1) {
49 echo
"\nWARNING: You are running this integrity checker on the whole system.\nThis is fine but it may take a long time\n\nYOU HAVE 5 SECONDS TO CANCEL THIS SCRIPT... ";
50 for ($i = 1; $i <= 5; $i++) {
59 $wysiwygids = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($ROOT_ASSETID,
'content_type_wysiwyg',
false);
60 foreach ($wysiwygids as $wysiwygid => $type_code_data) {
61 $type_code = $type_code_data[0][
'type_code'];
62 $wysiwyg = &$GLOBALS[
'SQ_SYSTEM']->am->getAsset($wysiwygid, $type_code);
63 $html = $wysiwyg->attr(
'html');
66 $e =
'/\\.\\/\\?a=([0-9]+)/';
68 preg_match_all($e, $html, $matches);
69 $internal_assetids = $matches[1];
71 foreach ($internal_assetids as $assetid) {
72 printWYSIWYGName(
'WYSIWYG #'.$wysiwyg->id.
' - LINK #'.$assetid);
73 if(!empty($assetid)) {
74 $asset = &$GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid,
'',
true);
80 if (is_null($asset)) {
82 printUpdateStatus(
'INVALID');
83 }
else if ($GLOBALS[
'SQ_SYSTEM']->am->assetInTrash($assetid,
true)) {
85 printUpdateStatus(
'TRASH');
87 printUpdateStatus(
'OK');
89 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
92 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($wysiwyg);
107 function printWYSIWYGName($name)
109 printf (
'%s%'.(35 - strlen($name)).
's', $name,
'');
122 function printUpdateStatus($status)
124 echo
"[ $status ]\n";