function start($port_id)
{
    $unix = new unix();
    $squid = new squidbee();
    $q = new mysql_squid_builder();
    $INCLUDE = false;
    $f = explode("\n", @file_get_contents("/etc/squid3/squid.conf"));
    build_progress_bandwidth("{limit_rate} {analyze}", 20);
    while (list($www, $line) = each($f)) {
        if (!preg_match("#acls_bandwidth\\.conf#", $line)) {
            continue;
        }
        echo "Include OK\n";
        $INCLUDE = TRUE;
        break;
    }
    if (!$INCLUDE) {
        echo "Include False, reconfigure\n";
        build_progress_bandwidth("{limit_rate} {reconfigure}", 80);
        $php = $unix->LOCATE_PHP5_BIN();
        system("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
        build_progress_bandwidth("{limit_rate} {done}", 100);
        return;
    }
    $md51 = md5_file("/etc/squid3/acls_bandwidth.conf");
    build_progress_bandwidth("{limit_rate} {reconfigure}", 50);
    $band = new squid_bandwith_builder();
    if (!$band->compile()) {
        build_progress_bandwidth("{limit_rate} {failed}", 110);
        return;
    }
    $md52 = md5_file("/etc/squid3/acls_bandwidth.conf");
    if ($md51 == $md52) {
        build_progress_bandwidth("{limit_rate} {done} {unmodified}", 100);
        return;
    }
    $squidbin = $unix->LOCATE_SQUID_BIN();
    build_progress_bandwidth("{limit_rate} {reloading}", 97);
    system("{$squidbin} -k reconfigure");
    build_progress_bandwidth("{limit_rate} {done} OK", 100);
    // FATAL: No valid signing SSL certificate
}
示例#2
0
function bandwith_rules()
{
    $bandwith = new squid_bandwith_builder();
    echo "\n-----------------\n\n";
    echo $bandwith->compile() . "\n";
}
示例#3
0
function rule_panel()
{
    $sql = "SELECT * FROM squid_pools WHERE ID={$_GET["rule-id"]}";
    $q = new mysql();
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
    $edit = Paragraphe("bandwith-limit-edit-64.png", "{edit_the_rule}", "{edit_the_rule} {$ligne["rulename"]}", "javascript:EditBandRule({$_GET["rule-id"]})");
    $delete = Paragraphe("bandwith-limit-del-64.png", "{delete_rule}", "{delete_rule} {$ligne["rulename"]}", "javascript:DeleteBandRule({$_GET["rule-id"]})");
    $time = Paragraphe("64-planning.png", "{time_restriction}", "{squid_band_time_restriction_text}", "javascript:BandAclTime({$_GET["rule-id"]})");
    $net = Paragraphe("bandwith-limit-user-64.png", "{networks}", "{squid_band_net_restriction_text}", "javascript:BandAclNet({$_GET["rule-id"]})");
    $domains = Paragraphe("bandwith-limit-www-64.png", "{websites}", "{squid_band_www_restriction_text}", "javascript:BandAclWWW({$_GET["rule-id"]})");
    $file = Paragraphe("64-filetype.png", "{by_file_type}", "{squid_band_file_restriction_text}", "javascript:BandAclFILE({$_GET["rule-id"]})");
    $tr[] = $edit;
    $tr[] = $delete;
    $tr[] = $net;
    $tr[] = $domains;
    $tr[] = $file;
    $tr[] = $time;
    $tables[] = "<table style='width:100%'><tr>";
    $t = 0;
    while (list($key, $line) = each($tr)) {
        $line = trim($line);
        if ($line == null) {
            continue;
        }
        $t = $t + 1;
        $tables[] = "<td valign='top'>{$line}</td>";
        if ($t == 2) {
            $t = 0;
            $tables[] = "</tr><tr>";
        }
    }
    if ($t < 2) {
        for ($i = 0; $i <= $t; $i++) {
            $tables[] = "<td valign='top'>&nbsp;</td>";
        }
    }
    $tables[] = "</table>";
    $maintext = rule_format_text($ligne["total_net"], $ligne["total_users"]);
    $s = new squid_bandwith_builder();
    $s->compile();
    $html = implode("\n", $tables) . "\n\t<hr>\n\t<div class=explain>" . @implode("<br>", $s->rules_explain[$_GET["rule-id"]]) . " {then} {$maintext}</div>\n\t<input type='hidden' id='right-panel-id' value='{$_GET["rule-id"]}'>";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body("{$html}");
}
示例#4
0
function bandwith_check_config()
{
    include_once dirname(__FILE__) . "/class.squid.bandwith.inc";
    $ruleid = $_GET["ID"];
    $sql = "SELECT * FROM squid_pools WHERE ID={$ruleid}";
    $q = new mysql();
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
    $band = new squid_bandwith_builder(true);
    $delay_class = $band->get_delay_class($ligne);
    $get_delay_parameters = $band->get_delay_parameters(1, $delay_class, $ligne);
    $content = "\n\n# * * * * {$ligne["rulename"]} * * * *\ndelay_class 1 {$delay_class}\n{$get_delay_parameters}\n";
    echo "<textarea style='margin-top:5px;font-family:Courier New;font-weight:bold;width:100%;height:450px;border:5px solid #8E8E8E;overflow:auto;font-size:20px !important' id='textToParseCats{$t}'>{$content}</textarea>";
}