function LOG_ADDED_CATZ($category_table, $rownumbers)
 {
     //webfilters_bigcatzlogs
     if (function_exists("debug_backtrace")) {
         $trace = @debug_backtrace();
         if (isset($trace[1])) {
             $called = "called by " . basename($trace[1]["file"]) . " {$trace[1]["function"]}() line {$trace[1]["line"]}";
         }
     }
     if ($rownumbers == 0) {
         return;
     }
     if (!is_numeric($rownumbers)) {
         return;
     }
     if ($category_table == null) {
         if (function_exists("WriteToSyslog")) {
             WriteToSyslog("Fatal: No category Table set {$called}", basename(__FILE__));
         }
     }
     if ($this->TABLE_EXISTS("webfilters_bigcatzlogs")) {
         $this->CheckTables();
     }
     $categoryname = $this->tablename_tocat($category_table);
     if ($categoryname == null) {
         if (function_exists("WriteToSyslog")) {
             WriteToSyslog("Warning: Unable to find category for {$categoryname} {$called}", basename(__FILE__));
         }
     }
     $sql = "INSERT IGNORE INTO webfilters_bigcatzlogs (zDate,category_table,category,AddedItems) \n\t\tVALUES (NOW(),'{$category_table}','{$categoryname}','{$rownumbers}')";
     $this->QUERY_SQL($sql);
     if (!$this->ok) {
         if (function_exists("WriteToSyslogMail")) {
             WriteToSyslogMail(__FUNCTION__ . "::{$q->mysql_error}", basename(__FILE__));
         }
         return;
     }
     //if(function_exists("WriteToSyslogMail")){WriteToSyslogMail("$category_table $rownumbers new items", basename(__FILE__));}
     $ID = time();
     $sql = "INSERT IGNORE INTO instant_updates (ID,zDate,CountItems) VALUES('{$ID}',NOW(),'{$rownumbers}')";
     $this->QUERY_SQL($sql);
 }
Пример #2
0
function kill_process()
{
    $SERV_NAME = $GLOBALS["SERV_NAME"];
    $sock = new sockets();
    $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 "Stopping......: " . date("H:i:s") . " [INIT]:{$SERV_NAME} Already task running PID {$pid} since {$time}mn\n";
        }
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $MirrorDebianMaxExecTime = $sock->GET_INFO("MirrorDebianMaxExecTime");
    if (!is_numeric($MirrorDebianMaxExecTime)) {
        die;
    }
    if ($MirrorDebianMaxExecTime == 0) {
        die;
    }
    if ($MirrorDebianMaxExecTime < 5) {
        die;
    }
    $pid = RSYNC_PID();
    $processtime = $unix->PROCCESS_TIME_MIN($pid);
    if ($processtime < $MirrorDebianMaxExecTime) {
        die;
    }
    WriteToSyslog("rsync, killing pid {$pid} TTL = {$processtime}mn, exceed {$MirrorDebianMaxExecTime}mn");
    $kill = $unix->find_program("kill");
    unix_system_kill_force($pid);
}
Пример #3
0
function ufdbguardConstruct()
{
    $binary = "/usr/bin/ufdbgclient";
    $moinsC = null;
    $moinsd = null;
    $log = "-l /var/log/pdns";
    if ($GLOBALS["VERBOSE"]) {
        $moinsd = " -d ";
    }
    @mkdir("/var/log/pdns", 0755, true);
    $GLOBALS["PDSNInUfdbWebsite"] = @file_get_contents("/etc/artica-postfix/settings/Daemons/PDSNInUfdbWebsite");
    if ($GLOBALS["PDSNInUfdbWebsite"] == null) {
        $GLOBALS["PDSNInUfdbWebsite"] = "www.google.com";
    }
    $datas = unserialize(base64_decode(@file_get_contents("/etc/artica-postfix/settings/Daemons/ufdbguardConfig")));
    if (!isset($datas["UseRemoteUfdbguardService"])) {
        $datas["UseRemoteUfdbguardService"] = 0;
    }
    if (!isset($datas["remote_port"])) {
        $datas["remote_port"] = 3977;
    }
    if (!isset($datas["remote_server"])) {
        $datas["remote_server"] = null;
    }
    if (!isset($datas["listen_addr"])) {
        $datas["listen_addr"] = "127.0.0.1";
    }
    if (!isset($datas["listen_port"])) {
        $datas["listen_port"] = "3977";
    }
    if (!isset($datas["tcpsockets"])) {
        $datas["tcpsockets"] = 1;
    }
    $EnableRemoteStatisticsAppliance = @file_get_contents("/etc/artica-postfix/settings/Daemons/EnableRemoteStatisticsAppliance");
    if (!is_numeric($EnableRemoteStatisticsAppliance)) {
        $EnableRemoteStatisticsAppliance = 0;
    }
    if ($EnableRemoteStatisticsAppliance == 1) {
        $RemoteStatisticsApplianceSettings = unserialize(base64_decode(@file_get_contents("/etc/artica-postfix/settings/Daemons/RemoteStatisticsApplianceSettings")));
        $datas["remote_server"] = $RemoteStatisticsApplianceSettings["SERVER"];
        $datas["UseRemoteUfdbguardService"] = 1;
        $datas["remote_port"] = $datas["listen_port"];
    }
    if ($datas["UseRemoteUfdbguardService"] == 1) {
        if (trim($datas["remote_server"] == null)) {
            $datas["remote_server"] = "127.0.0.1";
        }
        $address = "-S {$datas["remote_server"]} -p {$datas["remote_port"]} ";
        WriteToSyslog("Use remote ufdbguard service: {$datas["remote_server"]}:{$datas["remote_port"]}");
        return "{$binary} {$moinsd}{$moinsC}{$address} {$log}";
    }
    if ($datas["remote_port"] == null) {
        $datas["UseRemoteUfdbguardService"] = 0;
    }
    if ($datas["listen_addr"] == null) {
        $datas["listen_addr"] = "127.0.0.1";
    }
    if ($datas["listen_addr"] == "all") {
        $datas["listen_addr"] = "127.0.0.1";
    }
    $effective_port = ufdbguard_value("port");
    WriteToSyslog("ufdbguardd: Effective port:`{$effective_port}`");
    if (is_numeric($effective_port)) {
        $datas["tcpsockets"] = 1;
    }
    if ($datas["tcpsockets"] == 1) {
        if (trim($datas["listen_addr"] == null)) {
            $datas["listen_addr"] = "127.0.0.1";
        }
        WriteToSyslog("ufdbguardd: Use remote ufdbguard service: {$datas["listen_addr"]}:{$datas["remote_port"]}");
        $address = "-S {$datas["listen_addr"]} -p {$datas["listen_port"]} ";
        return "{$binary} {$moinsd}{$moinsC}{$address} {$log}";
    }
    WriteToSyslog("ufdbguardd: Use remote ufdbguard service: {$binary} {$moinsC}{$log}");
    return "{$binary} {$moinsd}{$moinsC}{$log}";
}