Пример #1
0
function SingleDebug($ID)
{
    $q = new mysql();
    $q->BuildTables();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".{$ID}.pid";
    $unix = new unix();
    $pid = $unix->get_pid_from_file($pidfile);
    $fetchmail = $unix->find_program("fetchmail");
    if ($unix->process_exists($pid)) {
        SingleDebugEvents("Task aborted", "This task is aborted, it already running PID {$pid}, please wait before executing a new task", $ID);
        return;
    }
    @file_put_contents($pidfile, getmypid());
    SingleDebugEvents("Task executed", "Starting rule number {$ID}\nThis task is executed please wait before executing a new task", $ID);
    $fetch = new fetchmail();
    $output = array();
    $fetch = new fetchmail();
    $l[] = "set logfile /var/log/fetchmail-rule-{$ID}.log";
    $l[] = "set daemon {$fetch->FetchmailPoolingTime}";
    $l[] = "set postmaster \"{$fetch->FetchmailDaemonPostmaster}\"";
    $l[] = "set idfile \"/var/log/fetchmail.{$ID}.id\"";
    $l[] = "";
    $GLOBALS["SINGLE_DEBUG"] = true;
    BuildRules();
    $pattern = $GLOBALS["FETCHMAIL_RULES_ID"][$ID];
    $l[] = $pattern;
    @file_put_contents("/tmp/fetchmailrc.{$ID}", @implode("\n", $l));
    shell_exec("/bin/chmod 600 /tmp/fetchmailrc.{$ID}");
    $cmd = "{$fetchmail} -v -N -f /tmp/fetchmailrc.{$ID} --pidfile /tmp/fetcmailrc.{$ID}.pid 2>&1";
    exec($cmd, $output);
    SingleDebugEvents("Task finish with " . count($output) . " event(s)", @implode("\n", $output), $ID);
}
if (!$q->test_mysql_connection()) {
    echo "Starting......: Dansguardian Mysql error\n";
    die;
}
$q->CheckTable_dansguardian();
LoadGlobal_exceptionsitelist();
$dans = new dansguardian();
$dans->SaveSettings();
$cmd = LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.web-community-filter.php --patterns{$GLOBALS["cmdlineadd"]}";
events("MAIN:: {$cmd}");
system($cmd);
HtmlTemplate();
BuildPersonalCategories();
bannedsitelist_userdefined();
weightedphraselist_userdefined();
BuildRules();
BuildWhiteIpList();
BuildBannedIPList();
FixMissingGroupsFiles();
FixMissingFiles();
BuildMasterRule();
echo "Starting......: Dansguardian reconfigure settings done\n";
function HtmlTemplate()
{
    $sock = new sockets();
    $DansGuardianHTMLTemplate = $sock->GET_INFO("DansGuardianHTMLTemplate");
    if (strlen($DansGuardianHTMLTemplate) > 100) {
        @file_put_contents("/etc/dansguardian/languages/ukenglish", $DansGuardianHTMLTemplate);
    }
}
function FixMissingFiles()