本文整理汇总了PHP中unix::file_time_min方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::file_time_min方法的具体用法?PHP unix::file_time_min怎么用?PHP unix::file_time_min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::file_time_min方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ParseMainDir
function ParseMainDir()
{
$unix = new unix();
$mypid = getmypid();
$kill = $unix->find_program("kill");
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
@mkdir("/etc/artica-postfix/pids", 0755, true);
$pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
$pidtime_hour = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".hours.time";
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
$pid = @file_get_contents($pidfile);
if ($pid < 100) {
$pid = null;
}
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($time > 60) {
unix_system_kill_force($pid);
} else {
events("Already executed pid {$pid} since {$time}mn-> DIE");
if ($GLOBALS["VERBOSE"]) {
echo "Already executed pid {$pid} since {$time}mn\n";
}
die;
}
}
$timeP = $unix->file_time_min($pidtime);
if ($timeP < 3) {
events("Main::Line: " . __LINE__ . " 3Mn minimal current: {$timeP}mn-> DIE");
die;
}
@unlink($pidtime);
@file_put_contents($pidtime, time());
@file_put_contents($pidfile, $mypid);
$dirs = $unix->dirdir("/var/log/artica-postfix/squid/queues");
while (list($directory, $array) = each($dirs)) {
$dirs2 = $unix->dirdir($directory);
if (count($dirs2) == 0) {
events("{$dirs2} 0 elements, remove...", __LINE__);
@rmdir($directory);
continue;
}
if (is_dir("{$directory}/SearchWords")) {
events("Scanning {$directory}/SearchWords", __LINE__);
ParseSubDir("{$directory}/SearchWords");
}
}
$timeP = $unix->file_time_min($pidtime_hour);
if ($timeP > 30) {
@unlink($pidtime_hour);
@file_put_contents($pidtime_hour, time());
shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.squid-searchwords.php --hour >/dev/null 2>&1");
}
}
示例2: status
function status()
{
$cache_file = "/usr/share/artica-postfix/ressources/logs/web/monit.status.all";
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
$time = $unix->file_time_min($cache_file);
if ($time < 2) {
return;
}
$monit = new monit_unix();
$array = $monit->all_status();
if (count($array) < 2) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} array returned less than 2 items\n";
}
return;
}
@unlink($cache_file);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Saving {$cache_file}\n";
}
@file_put_contents($cache_file, serialize($array));
@chmod($cache_file, 0755);
}
示例3: check
function check()
{
$EnablePhileSight = GET_INFO_DAEMON("EnablePhileSight");
if ($EnablePhileSight == null) {
$EnablePhileSight = 0;
}
if ($EnablePhileSight == 0) {
writelogs("feature disabled, aborting...", __FUNCTION__, __FILE__, __LINE__);
die;
}
if (system_is_overloaded()) {
writelogs("System overloaded, aborting this feature for the moment", __FUNCTION__, __FILE__, __LINE__);
die;
}
@mkdir("/opt/artica/philesight");
$unix = new unix();
$min = $unix->file_time_min("/opt/artica/philesight/database.db");
$sock = new sockets();
$rr = $sock->GET_INFO("PhileSizeRefreshEach");
if ($rr == null) {
$rr = 120;
}
if ($rr == "disable") {
die;
}
writelogs("/opt/artica/philesight/database.db = {$min} minutes, {$rr} minutes to run", __FUNCTION__, __FILE__, __LINE__);
if ($min >= $rr) {
run();
}
}
示例4: xstart
function xstart()
{
$unix = new unix();
$sock = new sockets();
$GLOBALS["CLASS_SOCKETS"] = $sock;
$FORCED_TEXT = null;
$NOTIFY = false;
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pidTime = "/usr/share/artica-postfix/ressources/logs/ARTICA_DBS_STATUS_FULL.db";
$pid = $unix->get_pid_from_file($pidfile);
$GLOBALS["CLASS_UNIX"] = $unix;
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
echo "Already executed\n";
return;
}
if (!$GLOBALS["FORCE"]) {
if ($unix->file_time_min($pidTime) < 30) {
return;
}
}
$GLOBALS["MAIN_ARRAY"] = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/ARTICA_DBS_STATUS.db"));
ArticaWebFilter();
ArticaUfdb();
@mkdir("/usr/share/artica-postfix/ressources/logs", 0755, true);
@unlink($pidTime);
@file_put_contents($pidTime, serialize($GLOBALS["MAIN_ARRAY"]));
if ($GLOBALS["VERBOSE"]) {
echo "Saving {$pidTime}\n";
}
@chmod($pidTime, 0755);
}
示例5: parse
function parse()
{
$TimeFile = "/etc/artica-postfix/pids/exec.squid.stats.mime.proto.php.time";
$pidfile = "/etc/artica-postfix/pids/exec.squid.stats.mime.proto.php.pid";
$GLOBALS["LogFileDeamonLogDir"] = @file_get_contents("/etc/artica-postfix/settings/Daemons/LogFileDeamonLogDir");
if ($GLOBALS["LogFileDeamonLogDir"] == null) {
$GLOBALS["LogFileDeamonLogDir"] = "/home/artica/squid/realtime-events";
}
$unix = new unix();
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["VERBOSE"]) {
echo "{$pid} already executed since {$timepid}Mn\n";
}
if ($timepid < 14) {
return;
}
$kill = $unix->find_program("kill");
unix_system_kill_force($pid);
}
@file_put_contents($pidfile, getmypid());
$TimeExec = $unix->file_time_min($TimeFile);
if (!$GLOBALS["FORCE"]) {
if ($TimeExec < 20) {
return;
}
}
@unlink($TimeFile);
@file_put_contents($TimeFile, time());
parsedb("/var/log/squid");
parsedb($GLOBALS["LogFileDeamonLogDir"]);
}
示例6: detect_kernels
function detect_kernels()
{
$unix = new unix();
if (!$GLOBALS["VERBOSE"]) {
if (is_file("/usr/share/artica-postfix/ressources/logs/kernel.lst")) {
if ($unix->file_time_min("/usr/share/artica-postfix/ressources/logs/kernel.lst") < 360) {
die;
}
}
}
$users = new usersMenus();
if ($users->LinuxDistriCode != "DEBIAN" && $users->LinuxDistriCode != "UBUNTU") {
die;
}
$unix = new unix();
$apt_cache = $unix->find_program("apt-cache");
if ($apt_cache == null) {
echo "Could not find apt-cache\n";
die;
}
if (system_is_overloaded(basename(__FILE__))) {
$unix->send_email_events("apt-cache aborted, system is overloaded..", "will restart analyzis in next cycle", "system");
die;
}
echo "{$apt_cache} search linux-image\n";
exec("{$apt_cache} search linux-image", $results);
while (list($num, $val) = each($results)) {
if (preg_match("#linux-image-([0-9\\.]+)-([0-9]+)-(.+?)\\s+-\\s+(.+?)\$#", $val, $re)) {
$array["DPKG"][] = array("VERSION" => $re[1], "BUILD" => $re[2], "ARCH" => $re[3], "INFOS" => $re[4], "PACKAGE" => "linux-image-{$re[1]}-{$re[2]}-{$re[3]}", "FULL_VERSION" => "{$re[1]}-{$re[2]}-{$re[3]}");
}
}
$array["INFOS"] = CpuFamilyInfos();
@file_put_contents("/usr/share/artica-postfix/ressources/logs/kernel.lst", base64_encode(serialize($array)));
}
示例7: xstart
function xstart()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
$pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
return;
}
$TimeExec = $unix->file_time_min($pidtime);
if ($TimeExec < 360) {
return;
}
@unlink($pidtime);
@file_put_contents($pidtime, time());
@file_put_contents($pidfile, getmypid());
$php5 = $unix->LOCATE_PHP5_BIN();
$q = new mysql_squid_builder();
$q->CreateCategoryUrisTable("malware");
$COUNT1 = $q->COUNT_ROWS("categoryuris_malware");
vxvault();
malwareurls_joxeankoret();
clean_mx_de();
$COUNT2 = $q->COUNT_ROWS("categoryuris_malware");
$URLS_ADDED = $COUNT2 - $COUNT1;
if ($URLS_ADDED > 0) {
system("{$php5} /usr/share/artica-postfix/exec.squidguard.php --compile-category malware");
squid_admin_mysql(2, "{$URLS_ADDED} malware URLs added", null, __FILE__, __LINE__);
}
}
示例8: xstart
function xstart()
{
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
$pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
$pid = @file_get_contents($pidfile);
if ($GLOBALS["VERBOSE"]) {
echo "{$pidtime}\n";
}
$unix = new unix();
$squid = $unix->LOCATE_SQUID_BIN();
if (!$GLOBALS["FORCE"]) {
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["VERBOSE"]) {
echo "Already executed pid {$pid} since {$time}mn\n";
}
die;
}
}
$mypid = getmypid();
@file_put_contents($pidfile, $mypid);
$timefile = $unix->file_time_min($pidtime);
if ($GLOBALS["VERBOSE"]) {
echo "Timelock:{$pidtime} {$timefile} Mn\n";
}
if (!$GLOBALS["FORCE"]) {
if ($timefile < 5) {
if ($GLOBALS["VERBOSE"]) {
echo "{$timefile}mn require 5mn\n";
}
return;
}
}
@unlink($pidtime);
@file_put_contents($pidtime, time());
if (!is_file("/home/ufdb/smtp-events/ACCESS_LOG")) {
if ($GLOBALS["VERBOSE"]) {
echo "/home/ufdb/smtp-events/ACCESS_LOG no such file\n";
}
}
$array = explode("\n", @file_get_contents("/home/ufdb/smtp-events/ACCESS_LOG"));
@unlink("/home/ufdb/smtp-events/ACCESS_LOG");
$body = array();
$mmstp = new ufdb_msmtp();
$Subject = count($array) . " Web filtering blocked event(s)";
$body[] = "Return-Path: <{$mmstp->smtp_sender}>";
$body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)";
$body[] = "From: {$mmstp->smtp_sender}";
$body[] = "Subject: {$Subject}";
$body[] = "To: {$mmstp->recipient}";
$body[] = "";
$body[] = "";
$body[] = @implode("\r\n", $array);
$body[] = "";
$body[] = "";
$finalbody = @implode("\r\n", $body);
if (!$mmstp->Send($finalbody)) {
squid_admin_mysql(0, "Unable to send notification {$Subject} to {$mmstp->recipient}", "{$Subject} to {$mmstp->recipient}\n------------------\n" . @implode("\n", $array) . "\n\t\tThe following error encountered\n" . $mmstp->logs . "\n", __FILE__, __LINE__);
}
}
示例9: visited_sites_by_cron
function visited_sites_by_cron()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/squid.visited_sites_by_cron.pid";
$TimeFile = "/etc/artica-postfix/settings/Daemons/exec.squid.visited.sites.php.time";
$pid = @file_get_contents($pidfile);
if ($pid < 100) {
$pid = null;
}
$t = time();
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["VERBOSE"]) {
echo "Already executed pid {$pid} since {$time}mn\n";
}
die;
}
$mypid = getmypid();
@file_put_contents($pidfile, $mypid);
$TimeExec = $unix->file_time_min($TimeFile);
if ($TimeExec < 240) {
return;
}
visited_sites(true, true);
}
示例10: start_parse
function start_parse()
{
if ($GLOBALS["VERBOSE"]) {
"echo Loading...\n";
}
$unix = new unix();
if ($GLOBALS["VERBOSE"]) {
"echo Loading done...\n";
}
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$pid = @file_get_contents($pidfile);
if (!$GLOBALS["FORCE"]) {
if ($pid < 100) {
$pid = null;
}
$unix = new unix();
if ($unix->process_exists($pid, basename(__FILE__))) {
if ($GLOBALS["VERBOSE"]) {
echo "Already executed pid {$pid}\n";
}
return;
}
$timeexec = $unix->file_time_min($timefile);
if ($timeexec < 10) {
return;
}
$mypid = getmypid();
@file_put_contents($pidfile, $mypid);
}
@unlink($timefile);
@file_put_contents($timefile, time());
$ldap = new clladp();
if (!$ldap->IsKerbAuth()) {
return;
}
$q = new mysql_squid_builder();
$sql = "SELECT ID,GroupName FROM webfilters_sqgroups WHERE `enabled`=1 AND `GroupType`='proxy_auth_statad'";
$results = $q->QUERY_SQL($sql);
$REFRESH = false;
$Count = mysql_num_rows($results);
$UPDATED = array();
while ($ligne = mysql_fetch_assoc($results)) {
if (parse_object($ligne["ID"], $ligne["GroupName"])) {
$UPDATED[] = $ligne["GroupName"];
$REFRESH = true;
}
}
if ($REFRESH) {
squid_admin_mysql(1, "Reloading proxy service after updating " . count($UPDATED) . " Active Directory group(s)", @implode("\n", $UPDATED), __FILE__, __LINE__);
$squid = $unix->LOCATE_SQUID_BIN();
system("/etc/init.d/squid reload --force --script=exec.squid.static.ad.groups.php/" . __LINE__);
$sock = new sockets();
$EnableTransparent27 = intval($sock->GET_INFO("EnableTransparent27"));
if ($EnableTransparent27 == 1) {
system("/etc/init.d/squid-nat reload --script=" . basename(__FILE__));
}
}
}
示例11: importActivedirectoryusers
function importActivedirectoryusers()
{
$sock = new sockets();
$EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
if (!is_numeric($EnableKerbAuth)) {
$EnableKerbAuth = 0;
}
if ($EnableKerbAuth == 0) {
return;
}
$unix = new unix();
$user = new settings_inc();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
$pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
WriteMyLogs("Process {$pid} already exists", __FUNCTION__, __FILE__, __LINE__);
return;
}
if (system_is_overloaded(basename(__FILE__))) {
WriteMyLogs("Overloaded system, aborting", __FUNCTION__, __FILE__, __LINE__);
return;
}
@file_put_contents($pidfile, getmypid());
$TImeStamp = $unix->file_time_min($pidTime);
if (!$GLOBALS["FORCE"]) {
if ($TImeStamp < 20) {
WriteMyLogs("Need 20mn, current={$TImeStamp}Mn executed by:{$GLOBALS["EXECUTOR"]} Params:{$GLOBALS["PARAMS"]}", __FUNCTION__, __FILE__, __LINE__);
return;
}
}
@unlink($pidTime);
@file_put_contents($pidTime, time());
$netbin = $unix->LOCATE_NET_BIN_PATH();
$usermod = $unix->find_program("usermod");
$chmod = $unix->find_program("chmod");
if (!is_file($netbin)) {
WriteMyLogs("net no such binary, aborting", __FUNCTION__, __FILE__, __LINE__);
return;
}
if (is_dir("/var/run/samba/winbindd_privileged")) {
shell_exec("{$usermod} -G winbindd_priv squid >/dev/null 2>&1");
shell_exec("{$chmod} 0750 /var/run/samba/winbindd_privileged/ >/dev/null 2>&1");
}
$array = unserialize(base64_decode($sock->GET_INFO("KerbAuthInfos")));
$domainUp = strtoupper($array["WINDOWS_DNS_SUFFIX"]);
$domain_lower = strtolower($array["WINDOWS_DNS_SUFFIX"]);
$adminpassword = $array["WINDOWS_SERVER_PASS"];
$adminpassword = $unix->shellEscapeChars($adminpassword);
$adminname = $array["WINDOWS_SERVER_ADMIN"];
$ad_server = $array["WINDOWS_SERVER_NETBIOSNAME"];
$GLOBALS["AUTHCMD"] = " -U {$adminname}%{$adminpassword}";
getNetInfos();
if (!isset($GLOBALS["LDAP_HOST"])) {
WriteMyLogs("Unable to get ldap infos, aborting", __FUNCTION__, __FILE__, __LINE__);
return;
}
GetUsersArray();
}
示例12: start
function start()
{
$pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$pidFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$unix = new unix();
$pid = $unix->get_pid_from_file($pidFile);
if ($unix->process_exists($pid)) {
return;
}
@file_put_contents($pidFile, getmypid());
$time = $unix->file_time_min($pidtime);
if ($time < 5) {
return;
}
@file_put_contents($pidtime, time());
$free = $unix->find_program("free");
$echo = $unix->find_program("echo");
$sync = $unix->find_program("sync");
$swapoff = $unix->find_program("swapoff");
$swapon = $unix->find_program("swapon");
exec("{$free} 2>&1", $results);
$used = 0;
$total = 0;
while (list($num, $ligne) = each($results)) {
if (preg_match("#Swap:\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)#", $ligne, $re)) {
$total = $re[1];
$used = $re[2];
}
}
if (!is_numeric($total)) {
return;
}
if ($total == 0) {
return;
}
if ($used == 0) {
return;
}
if ($total == $used) {
return;
}
$tot1 = $used / $total;
$tot1 = $tot1 * 100;
if ($GLOBALS["VERBOSE"]) {
echo "Swap:{$used}/{$total} - {$tot1}\n";
}
$perc = round($tot1);
if ($GLOBALS["VERBOSE"]) {
echo "Swap:{$used}/{$total} {$perc}%\n";
}
$t = time();
$GLOBALS["ALL_SCORES"]++;
shell_exec("{$swapoff} -a && {$swapon} -a");
$usedTXT = FormatBytes($used);
$report = $unix->ps_mem_report();
$distance = $unix->distanceOfTimeInWords($t, time(), true);
squid_admin_mysql(0, "System swap exceed rule: {$perc}%", "Used {$usedTXT}\nSystem cache was flushed took {$distance}\nThis means you did have enough memory for this computer.\n{$report}", __FILE__, __LINE__);
}
示例13: BuildDHCP
function BuildDHCP($nopid = false)
{
$LOGBIN = "DHCP Server";
$timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$unix = new unix();
if (!$nopid) {
if (!$GLOBALS["FORCE"]) {
if ($unix->file_time_min($timefile) < 2) {
if ($GLOBALS["VERBOSE"]) {
echo "{$timefile} -> is less than 2mn\n";
}
return;
}
}
}
build_progress("{starting_service}", 65);
$ldap = new clladp();
if ($ldap->ldapFailed) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$LOGBIN} ldap connection failed,aborting\n";
return;
}
if (!$ldap->ExistsDN("dc=organizations,{$ldap->suffix}")) {
echo "Starting......: " . date("H:i:s") . " DHCP SERVER dc=organizations,{$ldap->suffix} no such branch, aborting\n";
return;
}
echo "Starting......: " . date("H:i:s") . " [INIT]: {$LOGBIN} ldap connection success\n";
$dhcpd = new dhcpd();
$conf = $dhcpd->BuildConf();
$confpath = dhcp3Config();
$unix = new unix();
@mkdir(dirname($confpath), null, true);
@file_put_contents($confpath, $conf);
echo "Starting......: " . date("H:i:s") . " [INIT]: {$LOGBIN} saving \"{$confpath}\" (" . strlen($conf) . " bytes) done\n";
if (!$unix->UnixUserExists("dhcpd")) {
$unix->CreateUnixUser("dhcpd", "dhcpd");
}
if (!is_dir("/var/lib/dhcp3")) {
@mkdir("/var/lib/dhcp3", 0755, true);
}
$unix->chown_func("dhcpd", "dhcpd", "/var/lib/dhcp3/*");
$unix->chmod_func(0755, "/var/lib/dhcp3");
$complain = $unix->find_program("aa-complain");
if (is_file($complain)) {
$dhcpd3 = $unix->DHCPD_BIN_PATH();
if (is_file($dhcpd3)) {
shell_exec("{$complain} {$dhcpd3} >/dev/null 2>&1");
}
}
@unlink($timefile);
@file_put_contents($timefile, time());
build_progress("{starting_service}", 70);
$sock = new sockets();
$sock->getFrameWork("dnsmasq.php?restart=yes");
$sock->getFrameWork("services.php?restart-monit=yes");
$sock->getFrameWork("cmd.php?restart-artica-status=yes");
}
示例14: scan_stored_items
function scan_stored_items($nopid = true)
{
$sock = new sockets();
$SquidPerformance = intval($sock->GET_INFO("SquidPerformance"));
if ($SquidPerformance < 3) {
die;
}
$unix = new unix();
if (system_is_overloaded(basename(__FILE__))) {
$php = $unix->LOCATE_PHP5_BIN();
ufdbguard_admin_events("Overloaded system... ask to run this task later...", __FUNCTION__, __FILE__, __LINE__, "proxy");
$unix->THREAD_COMMAND_SET("{$php} " . __FILE__ . " --scan");
}
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
if ($nopid) {
$pid = @file_get_contents($pidfile);
$myfile = basename(__FILE__);
if ($unix->process_exists($pid, $myfile)) {
ufdbguard_admin_events("Task already running PID: {$pid}, aborting current task", __FUNCTION__, __FILE__, __LINE__, "proxy");
return;
}
}
$TimePid = $unix->file_time_min($pidTime);
if ($TimePid < 1440) {
ufdbguard_admin_events("Task cannot be used less than 14h currently ({$TimePid}Mn)", __FUNCTION__, __FILE__, __LINE__, "proxy");
return;
}
if (ScanPurgeexc()) {
ufdbguard_admin_events("Already Executed...", __FUNCTION__, __FILE__, __LINE__, "proxy");
return;
}
@unlink($pidTime);
@file_put_contents($pidTime, time());
$mypid = getmypid();
@file_put_contents($pidfile, $mypid);
$purge = $unix->find_program("purge");
if (strlen($purge) < 5) {
ufdbguard_admin_events("purge no such file, aborting task", __FUNCTION__, __FILE__, __LINE__, "proxy");
return;
}
$nice = EXEC_NICE();
$cmd = "{$nice}{$purge} -c /etc/squid3/squid.conf -e \".\" -P 0 -n >/var/cache/purge.calculated.db 2>&1";
if ($GLOBALS["VERBOSE"]) {
echo $cmd . "\n";
}
$t1 = time();
system(trim($cmd));
$took = $unix->distanceOfTimeInWords($t1, time());
if ($GLOBALS["VERBOSE"]) {
echo "done {$took}\n";
}
squid_admin_mysql(2, "Stored items: Extracting items information from cache done took:{$took}", null, __FILE__, __LINE__, "proxy");
inject_stored_items(true);
}
示例15: ScanFoldders
function ScanFoldders()
{
$sock = new sockets();
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$pid = file_get_contents("{$pidfile}");
if ($GLOBALS["VERBOSE"]) {
echo "{$timefile}\n";
}
if (system_is_overloaded(basename(__FILE__))) {
die;
}
if ($unix->process_exists($pid, basename(__FILE__))) {
$timeMin = $unix->PROCCESS_TIME_MIN($pid);
if ($timeMin > 240) {
system_admin_events("Too many TTL, {$pid} will be killed", __FUNCTION__, __FILE__, __LINE__, "logrotate");
$kill = $unix->find_program("kill");
unix_system_kill_force($pid);
} else {
die;
}
}
if (!$GLOBALS["FORCE"]) {
$TimeExec = $unix->file_time_min($timefile);
if ($TimeExec < 240) {
return;
}
}
@unlink($timefile);
@file_put_contents($timefile, time());
$LogRotatePath = $sock->GET_INFO("LogRotatePath");
$SystemLogsPath = $sock->GET_INFO("SystemLogsPath");
$BackupMaxDaysDir = $sock->GET_INFO("BackupMaxDaysDir");
$maillogStoragePath = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/maillogStoragePath"));
if ($GLOBALS["VERBOSE"]) {
echo "Starting Main\n";
}
$q = new mysql();
$q->QUERY_SQL("DROP TABLE `sysstorestatus`", "artica_events");
$sql = "CREATE TABLE IF NOT EXISTS `sysstorestatus` (\n\t\t\t `filepath` VARCHAR(255) NOT NULL,\n\t\t\t `filesize` BIGINT UNSIGNED NOT NULL,\n\t\t\t `zDate` DATETIME,\n\t\t\t PRIMARY KEY (`filepath`),\n\t\t\t KEY `zDate` (`zDate`),\n\t\t\t KEY `filesize` (`filesize`)\n\t\t\n\t\t\t)";
$q->QUERY_SQL($sql, "artica_events");
if (!$q->ok) {
echo $q->mysql_error;
return;
}
ScanThis("/home/postfix/maillog");
ScanThis("/home/logrotate");
ScanThis("/home/logrotate_backup");
ScanThis("/home/logs-backup");
ScanThis("/home/backup/postfix");
ScanThis($LogRotatePath);
ScanThis($SystemLogsPath);
ScanThis($maillogStoragePath);
}