function build_whitelist()
{
    build_progress_wb("{compiling}", 30);
    urlrewriteaccessdeny();
    build_progress_wb("{compiling}", 35);
    urlrewriteaccessdeny_squid();
    build_progress_wb("{compiling}", 40);
    build_blacklists();
    build_progress_wb("{done}", 100);
    $unix = new unix();
    $php5 = $unix->LOCATE_PHP5_BIN();
    shell_exec("{$php5} /usr/share/artica-postfix/exec.ufdbclient.reload.php");
}
function build_whitelist()
{
    build_progress_wb("{compiling}", 30);
    urlrewriteaccessdeny();
    build_progress_wb("{compiling}", 35);
    urlrewriteaccessdeny_squid();
    build_progress_wb("{compiling}", 40);
    build_blacklists();
    $unix = new unix();
    $php5 = $unix->LOCATE_PHP5_BIN();
    $squidbin = $unix->LOCATE_SQUID_BIN();
    squid_admin_mysql(2, "Reloading proxy service for whitelist domains", null, __FILE__, __LINE__);
    build_progress_wb("{reloading}", 90);
    system("{$squidbin} -k reconfigure");
    build_progress_wb("{done}", 100);
}
Exemplo n.º 3
0
function build_whitelist()
{
    $sock = new sockets();
    $unix = new unix();
    $UfdbUseArticaClient = $sock->GET_INFO("UfdbUseArticaClient");
    if (!is_numeric($UfdbUseArticaClient)) {
        $UfdbUseArticaClient = 1;
    }
    if ($UfdbUseArticaClient == 1) {
        build_progress_wb("Use Artica Whitelist", 20);
        $php = $unix->LOCATE_PHP5_BIN();
        system("{$php} /usr/share/artica-postfix/exec.ufdbgclient.whitelists.php");
        return;
    }
    build_progress_wb("{compiling}", 30);
    urlrewriteaccessdeny();
    build_blacklists();
    build_denycaches(true);
    build_progress_wb("{reloading}", 50);
    system("/etc/init.d/squid reload --script=" . basename(__FILE__));
    $sock = new sockets();
    $EnableTransparent27 = intval($sock->GET_INFO("EnableTransparent27"));
    if ($EnableTransparent27 == 1) {
        build_progress_wb("{reloading} NAT", 60);
        system("/etc/init.d/squid-nat reload --script=" . basename(__FILE__));
    }
    build_progress_wb("{success}", 100);
}
function build_blacklists($aspid = false)
{
    $unix = new unix();
    $FINALARRAY = array();
    $f = array();
    $PidFile = "/etc/artica-postfix/pids/squid_build_blacklists.pid";
    $dbfile = "/var/log/squid/ufdbgclient.black.db";
    if ($aspid) {
        $pid = $unix->get_pid_from_file($PidFile);
        if ($pid != getmypid()) {
            if ($unix->process_exists($pid, basename(__FILE__))) {
                echo "Starting......: " . date("H:i:s") . " Blacklists: Another artica script running pid {$pid}, aborting ...\n";
                WriteToSyslogMail("build_blacklists():: Another artica script running pid {$pid}, aborting ...", basename(__FILE__));
                return;
            }
        }
    }
    build_progress_wb("{compiling}", 41);
    @unlink($dbfile);
    try {
        echo "berekley_db:: Creating {$dbfile} database\n";
        $db_desttmp = @dba_open($dbfile, "c", "db4");
        @dba_close($db_desttmp);
    } catch (Exception $e) {
        $error = $e->getMessage();
        echo "berekley_db::FATAL ERROR {$error} on {$dbfile}\n";
        return;
    }
    @file_put_contents("/etc/squid3/ip-blacklists.db", "#");
    @file_put_contents("/etc/squid3/www-blacklists.db", "#");
    $ARRAY_IPS = array();
    $ip = new IP();
    $q = new mysql_squid_builder();
    $array = array();
    $db_con = @dba_open($dbfile, "c", "db4");
    $sql = "SELECT * FROM deny_websites";
    $results = $q->QUERY_SQL($sql);
    if ($GLOBALS["VERBOSE"]) {
        echo "BLACK " . mysql_num_rows($results) . " items SQL\n";
    }
    if (!$q->ok) {
        echo "Starting......: " . date("H:i:s") . " [ACLS]: {$q->mysql_error}\n";
        return;
    }
    @unlink("/etc/squid3/www-blacklists.db");
    build_progress_wb("{compiling}", 42);
    while ($ligne = mysql_fetch_assoc($results)) {
        if ($ligne["items"] == null) {
            continue;
        }
        $item = $ligne["items"];
        if (preg_match("#^http:\\/\\/([0-9\\.]+)(\\/|\$)#", $item, $re)) {
            $ARRAY_IPS[$re[1]] = true;
            continue;
        }
        if ($ip->isValid($item)) {
            $ARRAY_IPS[$item] = true;
            continue;
        }
        $item = str_replace("/", "\\/", $item);
        $item = str_replace(".", "\\.", $item);
        $item = str_replace("*", ".*?", $item);
        @dba_replace($item, $item, $db_con);
        if ($GLOBALS["VERBOSE"]) {
            echo "BLACK {$item}\n";
        }
        $array[] = $ligne["items"];
    }
    @dba_close($db_con);
    build_progress_wb("{compiling}", 43);
    @file_put_contents("/var/log/squid/ufdbgclient.reload", "#");
    @chown("/var/log/squid/ufdbgclient.reload", "squid");
    @chgrp("/var/log/squid/ufdbgclient.reload", "squid");
    $acl = new squid_acls();
    $url_rewrite_program = $acl->clean_dstdomains($array);
    echo "Starting......: " . date("H:i:s") . " [ACLS]: " . count($url_rewrite_program) . " blacklisted webistes\n";
    @file_put_contents("/etc/squid3/www-blacklists.db", @implode("\n", $url_rewrite_program) . "\n");
    @chown("/etc/squid3/www-blacklists.db", "squid");
    @chgrp("/etc/squid3/www-blacklists.db", "squid");
    if (count($ARRAY_IPS) > 0) {
        while (list($item, $line) = each($ARRAY_IPS)) {
            $zips[] = $item;
        }
        @file_put_contents("/etc/squid3/ip-blacklists.db", @implode("\n", $zips) . "\n");
        @chown("/etc/squid3/ip-blacklists.db", "squid");
        @chgrp("/etc/squid3/ip-blacklists.db", "squid");
    }
    build_progress_wb("{compiling}", 44);
    $php = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    $DenyBlacksites = false;
    $f = explode("\n", @file_get_contents("/etc/squid3/squid.conf"));
    while (list($num, $line) = each($f)) {
        if (preg_match("#DenyBlacksites dstdomain#", $line, $re)) {
            $DenyBlacksites = true;
        }
    }
    if (!$DenyBlacksites) {
        system("{$php} /usr/share/artica-postfix/exec.squid.php --build --force --noufdbg");
        return;
    }
    build_progress_wb("{compiling}", 44);
    shell_exec("{$nohup} /etc/init.d/squid reload --script=" . basename(__FILE__));
}
Exemplo n.º 5
0
function build_whitelist()
{
    $sock = new sockets();
    $unix = new unix();
    $UfdbUseArticaClient = $sock->GET_INFO("UfdbUseArticaClient");
    if (!is_numeric($UfdbUseArticaClient)) {
        $UfdbUseArticaClient = 1;
    }
    $PrivoxyEnabled = intval($sock->GET_INFO("PrivoxyEnabled"));
    if ($UfdbUseArticaClient == 1) {
        if (!$GLOBALS["NOUFDBG"]) {
            build_progress_wb("* * * Use Whitelist * * *", 20);
            $php = $unix->LOCATE_PHP5_BIN();
            system("{$php} /usr/share/artica-postfix/exec.ufdbgclient.whitelists.php");
        }
        return;
    }
    build_progress_wb("{compiling}", 30);
    urlrewriteaccessdeny();
    build_progress_wb("{building} {blacklists}", 31);
    build_blacklists();
    build_progress_wb("{building} deny cache", 32);
    build_denycaches(true);
    build_progress_wb("{building} {APP_PRIVOXY} = {$PrivoxyEnabled}", 33);
    if ($PrivoxyEnabled == 1) {
        build_progress_wb("{compiling} {APP_PRIVOXY}", 40);
        shell_exec("/etc/init.d/privoxy restart");
        build_progress_wb("{compiling} {APP_PRIVOXY} {done}", 45);
    }
    build_progress_wb("{reloading}", 50);
    system("/etc/init.d/squid reload --script=" . basename(__FILE__));
    $sock = new sockets();
    $EnableTransparent27 = intval($sock->GET_INFO("EnableTransparent27"));
    $PrivoxyEnabled = intval($sock->GET_INFO("PrivoxyEnabled"));
    if ($EnableTransparent27 == 1) {
        build_progress_wb("{reloading} NAT", 60);
        system("/etc/init.d/squid-nat reload --script=" . basename(__FILE__));
    }
    build_progress_wb("{success}", 100);
}