Exemplo n.º 1
0
function SingleInstance()
{
    $sock = new sockets();
    $unix = new unix();
    $php5 = $unix->LOCATE_PHP5_BIN();
    $miltergreybin = $unix->find_program("milter-greylist");
    $MilterGreyListEnabled = $sock->GET_INFO("MilterGreyListEnabled");
    if (!is_numeric($MilterGreyListEnabled)) {
        $MilterGreyListEnabled = 0;
    }
    if ($MilterGreyListEnabled == 0) {
        echo "{$GLOBALS["deflog_start"]} Milter-greylist is not enabled\n";
        return;
    }
    $nohup = $unix->find_program("nohup");
    echo "{$GLOBALS["deflog_start"]} single instance execute exec.white-black-central.php\n";
    shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.white-black-central.php >/dev/null 2>&1 &");
    $mg = new milter_greylist(false, "master", "master");
    $datas = $mg->BuildConfig();
    if ($datas != null) {
        $conf_path = SingleInstanceConfPath();
        @mkdir(dirname($conf_path), 0666, true);
        echo "{$GLOBALS["deflog_start"]} single instance {$conf_path}\n";
        $tbl = explode("\n", $datas);
        echo "{$GLOBALS["deflog_start"]} cleaning {$conf_path} with " . count($tbl) . " lines\n";
        while (list($num, $ligne) = each($tbl)) {
            $ligne = trim($ligne);
            if ($ligne == null) {
                continue;
            }
            $newf[] = $ligne;
        }
        $newf[] = "";
        echo "{$GLOBALS["deflog_start"]} writing {$conf_path} (" . count($newf) . " lines)\n";
        @file_put_contents($conf_path, @implode("\n", $newf));
    }
    TestConfigFile($conf_path);
    echo "{$GLOBALS["deflog_start"]} notify administrator\n";
    $unix->send_email_events("Milter-greylist has been reconfigured", "By {$GLOBALS["WHOPROCESS"]}\nSettings:\n" . @implode("\n", $newf), "postfix");
    echo "{$GLOBALS["deflog_start"]} done.\n";
}
Exemplo n.º 2
0
function SingleInstance()
{
    $sock = new sockets();
    $MilterGreyListEnabled = $sock->GET_INFO("MilterGreyListEnabled");
    if (!is_numeric($MilterGreyListEnabled)) {
        $MilterGreyListEnabled = 0;
    }
    if ($MilterGreyListEnabled == 0) {
        echo "Starting......: Milter-greylist is not enabled\n";
        return;
    }
    $mg = new milter_greylist(false, "master", "master");
    $datas = $mg->BuildConfig();
    if ($datas != null) {
        $conf_path = SingleInstanceConfPath();
        @mkdir(dirname($conf_path), 0666, true);
        echo "Starting......: single instance {$conf_path}\n";
        echo "Starting......: cleaning {$conf_path}\n";
        $tbl = explode("\n", $datas);
        while (list($num, $ligne) = each($tbl)) {
            $ligne = trim($ligne);
            if ($ligne == null) {
                continue;
            }
            $newf[] = $ligne;
        }
        $newf[] = "";
        echo "Starting......: writing {$conf_path}\n";
        @file_put_contents($conf_path, @implode("\n", $newf));
    }
    if (!$GLOBALS["NORESTART"]) {
        shell_exec("/etc/init.d/artica-postfix restart mgreylist --noconfig >/tmp/start.miltergreylist.tmp 2>&1");
        if ($GLOBALS["DEBUG"]) {
            echo "\n" . @file_get_contents("/tmp/start.miltergreylist.tmp") . "\n";
        }
        @unlink("/tmp/start.miltergreylist.tmp");
    }
}