18 if (ini_get(
'memory_limit') !=
'-1') ini_set(
'memory_limit',
'-1');
19 error_reporting(E_ALL);
20 if ((php_sapi_name() !=
'cli')) {
21 trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
24 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
25 if (empty($SYSTEM_ROOT) || !is_dir($SYSTEM_ROOT)) {
26 trigger_error(
"You need to supply the path to the System Root as the first argument\n", E_USER_ERROR);
28 define(
'SQ_SYSTEM_ROOT', $SYSTEM_ROOT);
29 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
31 $root_user =& $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
32 $GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user);
33 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
35 $ROOT_NODE_ID = (isset($_SERVER[
'argv'][2])) ? $_SERVER[
'argv'][2] :
'1';
38 if (($ROOT_NODE_ID > 1) && !$GLOBALS[
'SQ_SYSTEM']->am->assetExists($ROOT_NODE_ID)) {
39 trigger_error(
"The asset #".$ROOT_NODE_ID.
" is not VALID\n", E_USER_ERROR);
43 $fm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'funnelback_manager');
45 trigger_localised_error(
'FNB0020', E_USER_WARNING);
48 if (!$fm->attr(
'indexing')) {
49 echo
"\n\nBEFORE RUNNING THE SCRIPT, PLEASE CHECK THAT THE INDEXING STATUS IS TURNED ON\n";
50 echo
'Note: You can change this option from the backend "System Management" > "Funnelback Manager" > "Details"'.
"\n\n";
55 if (file_exists(SQ_TEMP_PATH.
'/funnelback.rebuilder')) {
56 trigger_localised_error(
'FNB0019', E_USER_WARNING);
61 touch(SQ_TEMP_PATH.
'/funnelback.rebuilder');
64 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
65 $vars = Array(
'root_assetid'=> $ROOT_NODE_ID);
66 $errors = $hh->freestyleHipo(
'hipo_job_funnelback_rebuild_cache', $vars, SQ_PACKAGES_PATH.
'/funnelback/hipo_jobs');
67 if (!empty($errors)) {
68 echo
'Funnelback Cache Rebuild FAILED'.
"\n";
69 foreach ($errors as $error) {
70 $line = array_get_index($error,
'message',
'');
78 if (file_exists(SQ_TEMP_PATH.
'/funnelback.rebuilder')) {
79 unlink(SQ_TEMP_PATH.
'/funnelback.rebuilder');
82 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();