32 error_reporting(E_ALL);
33 if (ini_get(
'memory_limit') !=
'-1') ini_set(
'memory_limit',
'-1');
35 if (php_sapi_name() !=
'cli') {
36 trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
39 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
40 if (empty($SYSTEM_ROOT)) {
41 echo
"ERROR: You need to supply the path to the System Root as the first argument\n";
45 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
46 echo
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
50 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
51 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
53 $root_user = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
54 if (!$GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user)) {
55 echo
"ERROR: Failed logging in as root user\n";
62 $purge_rootnode = (isset($_SERVER[
'argv'][2])) ? $_SERVER[
'argv'][2] : 0;
63 if (!empty($purge_rootnode)) {
65 $trash_folder = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'trash_folder');
66 $db = $GLOBALS[
'SQ_SYSTEM']->db;
74 majorid = :trash_assetid';
81 if (!empty($linkid)) {
83 $vars[
'purge_root_linkid'] = $linkid;
87 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
88 $errors = $hh->freestyleHipo(
'hipo_job_purge_trash', $vars);
90 trigger_error(print_r($errors, TRUE), E_USER_WARNING);
93 echo
"\npurge_trash.php: Completed.\n";