function run() { $sock = new sockets(); $PhileSizeCpuLimit = $sock->GET_INFO("PhileSizeCpuLimit"); if ($PhileSizeCpuLimit == null) { $PhileSizeCpuLimit = 0; } if (InMemQUestion()) { writelogs("Already running, aborting", __FUNCTION__, __FILE__, __LINE__); return null; } chdir("/usr/share/artica-postfix/bin"); $unix = new unix(); $tmpfile = $unix->FILE_TEMP(); $cmd = $unix->find_program("nohup") . " /usr/share/artica-postfix/bin/philesight --db /opt/artica/philesight/database.db --index / >{$tmpfile} &"; echo $cmd . "\n"; shell_exec($cmd); sleep(3); $f = explode("\n", @file_get_contents($tmpfile)); @unlink($tmpfile); while (list($num, $ligne) = each($f)) { if (preg_match("#run database recovery#", $ligne)) { $corrupted = true; } } if ($corrupted) { @unlink("/opt/artica/philesight/database.db"); shell_exec($cmd); } if ($PhileSizeCpuLimit == 0) { return; } sleep(3); $pid = getPID(); echo "Pid={$pid}\n"; if ($pid > 2) { $cpulimit = $unix->find_program("cpulimit"); echo "cpulimit={$cpulimit}\n"; if (is_file($cpulimit)) { $cmd_limit = "{$cpulimit} -p {$pid} -l {$PhileSizeCpuLimit} -z >>/var/log/cpulimit 2>&1 &"; sleep(1); echo $cmd_limit . "\n"; shell_exec($cmd_limit); } } }
if ($GLOBALS["VERBOSE"]) { ini_set('html_errors', 0); ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); } include_once dirname(__FILE__) . '/ressources/class.ldap.inc'; include_once dirname(__FILE__) . '/ressources/class.samba.inc'; include_once dirname(__FILE__) . '/ressources/class.templates.inc'; include_once dirname(__FILE__) . '/ressources/class.ini.inc'; include_once dirname(__FILE__) . '/framework/class.unix.inc'; if ($argv[1] == '--check') { check(); die; } if ($argv[1] == '--exists') { InMemQUestion(); die; } if ($argv[1] == '--rebuild') { run(); die; } if ($argv[1] == '--pid') { echo getPID() . "\n"; die; } if ($argv[1] == '--run') { echo run() . "\n"; die; } if ($argv[1] == '--directories') {