31 if (ini_get(
'memory_limit') !=
'-1') ini_set(
'memory_limit', -1);
32 error_reporting(E_ALL);
33 if ((php_sapi_name() !=
'cli')) trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
35 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
36 $report_only = (isset($_SERVER[
'argv'][2]) && $_SERVER[
'argv'][2]!=
'y') ? FALSE : TRUE;
38 if (empty($SYSTEM_ROOT)) {
39 echo
"ERROR: You need to supply the path to the System Root as the first argument\n";
43 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
44 echo
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
48 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
51 echo
"Following Bodycopy Div asset(s) contains unsafe keywords in the content file:\n\n";
53 echo
"Fixing the unsafe keyword(s) in content file for following Bodycopy Div asset(s):\n\n";
57 $assetids = array_keys($GLOBALS[
'SQ_SYSTEM']->am->getChildren(1,
'bodycopy_div'));
59 foreach($assetids as $assetid) {
61 $data_dir = $SYSTEM_ROOT.
'/data/private/'.asset_data_path_suffix(
'bodycopy_div', $assetid).
'/content_file.php';
62 if (!is_file($data_dir)) {
66 $file_content = file_get_contents($data_dir);
68 preg_match_all(
'|echo \(isset\(\$keyword_replacements\["(.*?)\]\)\) \?|mis', $file_content, $matches);
69 if (empty($matches[1])) {
75 foreach($matches[1] as $keyword) {
76 $keywords_str .= trim($keyword,
'"');
80 if ($keywords_str != htmlentities(html_entity_decode($keywords_str))) {
81 echo
"#".$assetid.
"\n";
84 $bodycopy_div = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
85 $bodycopy_div_edit_fns = $bodycopy_div->getEditFns();
86 $bodycopy_div_edit_fns->generateContentFile($bodycopy_div);
87 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($bodycopy_div);
94 echo $report_only ? $count.
" asset(s) requires fixing" : $count.
" asset(s) were fixed";