Esempio n. 1
0
function build()
{
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, building configuration.\n";
    }
    @mkdir("/var/lib/shorewall", 0755, true);
    $unix = new unix();
    if (!isset($GLOBALS["INTERFACES"])) {
        $GLOBALS["INTERFACES"] = $unix->NETWORK_ALL_INTERFACES();
    }
    shorewall_conf();
    build_providers();
    build_zones();
    build_interfaces();
    build_policies();
    build_rules();
    build_rtrules();
    build_masq();
    CheckConf();
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, BUILD DONE.\n";
    }
}
function build()
{
    $q = new mysql_squid_builder();
    $sql = "SELECT * FROM computers_time WHERE `enabled`=1";
    build_progress("Starting query", 10);
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        build_progress("MySQL error", 110);
        echo $q->mysql_error;
        die;
    }
    $ARRAYF["MONDAY"] = 1;
    $ARRAYF["TUESDAY"] = 2;
    $ARRAYF["WEDNESDAY"] = 3;
    $ARRAYF["THURSDAY"] = 4;
    $ARRAYF["FRIDAY"] = 5;
    $ARRAYF["SATURDAY"] = 6;
    $ARRAYF["SUNDAY"] = 0;
    $c = 0;
    while ($ligne = mysql_fetch_assoc($results)) {
        $MAC = $ligne["MAC"];
        $c++;
        reset($ARRAYF);
        build_progress("Settings for {$MAC}", 15);
        while (list($DAY, $indexDay) = each($ARRAYF)) {
            $AM = explode(";", $ligne["{$DAY}_AM"]);
            $PM = explode(";", $ligne["{$DAY}_PM"]);
            $array[$MAC][$indexDay]["AM"][0] = $AM[0];
            $array[$MAC][$indexDay]["AM"][1] = $AM[1];
            $array[$MAC][$indexDay]["PM"][0] = $PM[0];
            $array[$MAC][$indexDay]["PM"][1] = $PM[1];
        }
    }
    @unlink("/etc/squid3/MacRestrictAccess.db");
    if ($c > 0) {
        build_progress("Building configuration", 50);
        @file_put_contents("/etc/squid3/MacRestrictAccess.db", serialize($array));
        if (!$GLOBALS["nocheck"]) {
            build_progress("Checking configuration", 55);
            if (!CheckConf()) {
                return;
            }
        }
    } else {
        build_progress("{no_activated_rule}", 110);
        return;
    }
    build_progress("{done}", 100);
}