Beispiel #1
0
<?php

ini_set('error_reporting', E_ALL);
include_once dirname(__FILE__) . '/ressources/class.users.menus.inc';
include_once dirname(__FILE__) . '/ressources/class.mysql.inc';
include_once dirname(__FILE__) . '/ressources/class.user.inc';
include_once dirname(__FILE__) . '/ressources/class.ini.inc';
include_once dirname(__FILE__) . "/ressources/class.squid.inc";
include_once dirname(__FILE__) . "/ressources/class.squid.acls.inc";
$GLOBALS["VERBOSE"] = true;
$array[] = "^microsoft.com";
$array[] = "update.microsoft.com";
$array[] = "nttdata.com";
$array[] = "kds.keane.com";
$array[] = "mail703.kds.keane.com";
$array[] = "outlookanywhere.keane.com";
$array[] = "toto.titi.tata.com";
$squid = new squid_acls();
print_r($squid->clean_dstdomains($array));
Beispiel #2
0
function urlrewriteaccessdeny()
{
    $q = new mysql();
    $q2 = new mysql_squid_builder();
    $acl = new squid_acls();
    $sql = "SELECT * FROM urlrewriteaccessdeny";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo "Starting......: " . date("H:i:s") . " [ACLS]: {$q->mysql_error}\n";
        return;
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $ligne["items"] = trim($ligne["items"]);
        if ($ligne["items"] == null) {
            continue;
        }
        $array[] = $ligne["items"];
    }
    $acl = new squid_acls();
    $url_rewrite_program = $acl->clean_dstdomains($array);
    echo "Starting......: " . date("H:i:s") . " [ACLS]: " . count($url_rewrite_program) . " Whitelisted webistes from webfiltering\n";
    @file_put_contents("/etc/squid3/url_rewrite_program.deny.db", @implode("\n", $url_rewrite_program) . "\n");
    @chown("/etc/squid3/url_rewrite_program.deny.db", "squid");
    @chgrp("/etc/squid3/url_rewrite_program.deny.db", "squid");
}
Beispiel #3
0
function InSquid($reconfigure_squid = false)
{
    $unix = new unix();
    $sock = new sockets();
    $ipClass = new IP();
    $q = new mysql_squid_builder();
    $acls = new squid_acls();
    $acls->clean_dstdomains();
    build_progress_squidr("{checking} {whitelist}", 30);
    $sql = "CREATE TABLE IF NOT EXISTS `privoxy_whitelist` (\n\t\t\t\t`items` VARCHAR(256) NOT NULL PRIMARY KEY\n\t\t\t\t) ENGINE=MYISAM;";
    $q->QUERY_SQL($sql);
    $results = $q->QUERY_SQL("SELECT * FROM privoxy_whitelist");
    $ACLS = array();
    $ACLS["IPS"] = array();
    $ACLS["DOMS"] = array();
    while ($ligne = mysql_fetch_assoc($results)) {
        $items = trim(strtolower($ligne["items"]));
        if ($ipClass->isIPAddressOrRange($items)) {
            $ACLS["IPS"][$items] = $items;
        }
        $ACLS["DOMS"][$items] = $items;
    }
    $ipacls = array();
    $ACLS["DOMS"]["apple.com"] = "apple.com";
    $ACLS["DOMS"]["windowsupdate.com"] = "windowsupdate.com";
    $ACLS["DOMS"]["googleapis.com"] = "googleapis.com";
    $ACLS["DOMS"]["mozilla.net"] = "mozilla.net";
    $ACLS["DOMS"]["teamviewer.com"] = "teamviewer.com";
    $ACLS["DOMS"]["microsoft.com"] = "microsoft.com";
    $ACLS["DOMS"]["artica.fr"] = "artica.fr";
    if (count($ACLS["IPS"]) > 0) {
        while (list($num, $line) = each($ACLS["IPS"])) {
            $ipacls[] = $line;
        }
    }
    if (count($ACLS["DOMS"]) > 0) {
        while (list($num, $line) = each($ACLS["DOMS"])) {
            $domacls[] = $line;
        }
    }
    if (count($domacls) > 0) {
        $domacls = $acls->clean_dstdomains($domacls);
    }
    $PrivoxyPort = intval($sock->GET_INFO("PrivoxyPort"));
    $f = explode("\n", @file_get_contents("/etc/squid3/squid.conf"));
    $privoxyInSquid = false;
    while (list($num, $line) = each($f)) {
        if (preg_match("#include.*?privoxy\\.conf#", $line)) {
            $privoxyInSquid = true;
            break;
        }
    }
    $InSquid[] = "acl AntiAdsPost method POST";
    if (count($domacls) > 0) {
        @file_put_contents("/etc/squid3/AntiAdsDenyWeb.acl", @implode("\n", $domacls));
        $InSquid[] = "acl AntiAdsDenyWeb dstdomain \"/etc/squid3/AntiAdsDenyWeb.acl\"";
    }
    if (count($ipacls) > 0) {
        @file_put_contents("/etc/squid3/AntiAdsDenyIP.acl", @implode("\n", $ipacls));
        $InSquid[] = "acl AntiAdsDenyIP dst \"/etc/squid3/AntiAdsDenyIP.acl\"";
    }
    $InSquid[] = "cache_peer 127.0.0.1 parent {$PrivoxyPort} 7 no-query no-digest no-netdb-exchange name=AntiAds";
    $InSquid[] = "always_direct allow FTP";
    if (count($ipacls) > 0) {
        $InSquid[] = "cache_peer_access AntiAds deny AntiAdsDenyIP";
    }
    if (count($domacls) > 0) {
        $InSquid[] = "cache_peer_access AntiAds deny AntiAdsDenyWeb";
    }
    $InSquid[] = "cache_peer_access AntiAds deny AntiAdsPost";
    $InSquid[] = "cache_peer_access AntiAds allow all";
    @file_put_contents("/etc/squid3/privoxy.conf", @implode("\n", $InSquid));
    if ($GLOBALS["OUTPUT"]) {
        echo "Configuring...: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} /etc/squid3/privoxy.conf done\n";
    }
    build_progress_squidr("{reconfiguring}", 50);
    if ($privoxyInSquid == false) {
        $php = $unix->LOCATE_PHP5_BIN();
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Reconfiguring Squid-cache\n";
        }
        shell_exec("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
    }
    if ($reconfigure_squid) {
        build_progress_squidr("{reloading}", 90);
        $squidbin = $unix->LOCATE_SQUID_BIN();
        system("{$squidbin} -f /etc/squid3/squid.conf -k reconfigure");
    }
    build_progress_squidr("{done}", 100);
}