Beispiel #1
0
include_once dirname(__FILE__) . '/ressources/class.maincf.multi.inc';
include_once dirname(__FILE__) . '/ressources/class.amavis.inc';
$GLOBALS["CMDLINES"] = @implode(" ", $argv);
if (preg_match("#--verbose#", implode(" ", $argv))) {
    $GLOBALS["VERBOSE"] = true;
}
if (preg_match("#--force#", implode(" ", $argv))) {
    $GLOBALS["FORCE"] = true;
}
$user = new usersMenus();
if (!$user->spamassassin_installed) {
    write_syslog("want to change spamassassin settings but not installed", __FILE__);
    die;
}
if ($argv[1] == '--sa-update') {
    sa_update();
    die;
}
if (!is_file($user->spamassassin_conf_path)) {
    write_syslog("want to change spamassassin settings but could not stat main configuration file", __FILE__);
}
if ($argv[1] == '--sa-update-check') {
    sa_update_check();
    die;
}
x_headers();
x_bounce();
if ($argv[1] == '--spf') {
    spf();
    die;
}
function sa_update_check()
{
    $unix = new unix();
    $saupdate = $unix->find_program("sa-update");
    if (!is_file($saupdate)) {
        return null;
    }
    $statusFile = "/usr/share/artica-postfix/ressources/logs/sa-update-status.html";
    $statusFileContent = "/usr/share/artica-postfix/ressources/logs/sa-update-status.txt";
    $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    if (!$GLOBALS["FORCE"]) {
        if ($unix->file_time_min($timefile) < 120) {
            return;
        }
    }
    @file_put_contents($timefile, time());
    @unlink($statusFile);
    $cmd = "{$saupdate} --checkonly -D --channel sought.rules.yerp.org --channel updates.spamassassin.org 2>&1";
    exec($cmd, $results);
    if ($GLOBALS["VERBOSE"]) {
        echo "{$cmd} " . count($results) . " rows\n";
    }
    $UPDATE = false;
    while (list($index, $line) = each($results)) {
        if (preg_match("#channel:\\s+(.+?):\\s+update available#", $line, $re)) {
            $UPDATE = TRUE;
        }
    }
    if ($UPDATE) {
        sa_update();
    }
}
// misc "y"
// -----------------------------------------------------------------------------
if (isset($_REQUEST["y"])) {
    sa_misc(tfb_getRequestVar("y"));
}
// -----------------------------------------------------------------------------
// tfb "z"
// -----------------------------------------------------------------------------
if (isset($_REQUEST["z"])) {
    sa_tfb(tfb_getRequestVar("z"));
}
// -----------------------------------------------------------------------------
// update "u"
// -----------------------------------------------------------------------------
if (isset($_REQUEST["u"])) {
    sa_update(tfb_getRequestVar("u"));
}
// -----------------------------------------------------------------------------
// fluxd "f"
// -----------------------------------------------------------------------------
if (isset($_REQUEST["f"])) {
    sa_fluxd(tfb_getRequestVar("f"));
}
// -----------------------------------------------------------------------------
// fluazu "a"
// -----------------------------------------------------------------------------
if (isset($_REQUEST["a"])) {
    sa_fluazu(tfb_getRequestVar("a"));
}
// -----------------------------------------------------------------------------
// default