예제 #1
0
function quick_bann()
{
    $unix = new unix();
    $EXEC_PID_FILE = "/etc/artica-postfix/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    $pid = $unix->get_pid_from_file($EXEC_PID_FILE);
    if (!$GLOBALS["VERBOSE"]) {
        if ($unix->process_exists($pid, basename(__FILE__))) {
            return;
        }
    }
    @file_put_contents($EXEC_PID_FILE, getmypid());
    $squid = new squidbee();
    $returned = $squid->ACL_BANNED_COMPUTERS_IP();
    $f = explode("\n", @file_get_contents("/etc/squid3/squid.conf"));
    $compile = false;
    if (isset($GLOBALS["HTTP_ACCESS"]["BANNED_COMPUTERS_MAC"])) {
        if ($GLOBALS["VERBOSE"]) {
            echo "MAC Blacklisted detected\n";
        }
        $MAC = false;
        while (list($index, $line) = each($f)) {
            if (preg_match("#deny.*?banned_mac_computers#", $line)) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "{$line} FOUND\n";
                }
                $MAC = true;
                break;
            }
        }
        if (!$MAC) {
            $compile = true;
        }
    }
    if (isset($GLOBALS["HTTP_ACCESS"]["BANNED_COMPUTERS"])) {
        if ($GLOBALS["VERBOSE"]) {
            echo "IP Blacklisted detected\n";
        }
        $MAC = false;
        reset($f);
        while (list($index, $line) = each($f)) {
            if (preg_match("#deny.*?banned_computers#", $line)) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "{$line} FOUND\n";
                }
                $MAC = true;
                break;
            }
        }
        if (!$MAC) {
            $compile = true;
        }
    }
    if (!$compile) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Just reload ok\n";
        }
        Reload_Squid();
        return;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "Just reconfigure ok\n";
    }
    $php = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    shell_exec("{$nohup} {$php} " . __FILE__ . " --build >/dev/null 2>&1 &");
}