示例#1
0
function rules()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $q = new mysql_squid_builder();
    $action_delete_rule = $tpl->javascript_parse_text("{action_delete_rule}");
    $rule_text = $tpl->_ENGINE_parse_body("{rule}");
    $sql = "SELECT ID,enabled,groupmode,groupname FROM webfilter_rules ORDER BY groupname";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2>";
    }
    $add = imgtootltip("plus-24.png", "{add} {rule}", "DansGuardianEditRule(-1)");
    $select = imgtootltip("32-parameters.png", "{edit}", "DansGuardianEditRule('0','default')");
    $style = "style='font-size:14px;font-weight:bold;color:black'";
    $html = "<center><span id='DansAnimate'></span>\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:99%'>\n<thead class='thead'>\n\t<tr>\n\t\t<th width=1%>{$add}</th>\n\t\t<th width=99%>{rules}</th>\n\t\t<th width=1%>{groups}</th>\n\t\t<th width=1%>{blacklists}</th>\n\t\t<th width=1%>{whitelists}</th>\n\t\t<th width=1%>&nbsp;</th>\n\t</tr>\n</thead>\n<tbody class='tbody'>\n\t\t<tr class=oddRow>\n\t\t\t<td width=1%>{$select}</td>\n\t\t\t<td {$style} width=99%>" . texthref("Default", "DansGuardianEditRule('0','default')") . "<div><i style='font-size:10px'>{$ligne["ipaddr"]}</i></div></a></td>\n\t\t\t<td width=1% align='center' {$style}>-</td>\n\t\t\t<td width=1% align='center' {$style}>" . COUNTDEGBLKS(0) . "</td>\n\t\t\t<td width=1% align='center' {$style}>" . COUNTDEGBWLS(0) . "</td>\n\t\t\t<td width=1% >&nbsp;</td>\n\t\t</tr>\n";
    $classtr = "oddRow";
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $select = imgtootltip("32-parameters.png", "{edit}", "DansGuardianEditRule('{$ligne["ID"]}','{$ligne["groupname"]}')");
        $delete = imgtootltip("delete-32.png", "{delete}", "DansGuardianDeleteMainRule('{$ligne["ID"]}')");
        $color = "black";
        if ($ligne["enabled"] == 0) {
            $color = "#CCCCCC";
        }
        $style = "style='font-size:14px;font-weight:bold;color:{$color}'";
        $html = $html . "\n\t\t<tr class={$classtr}>\n\t\t\t<td width=1%>{$select}</td>\n\t\t\t<td {$style} width=99%>" . texthref($ligne["groupname"], "DansGuardianEditRule('{$ligne["ID"]}','{$ligne["groupname"]}')") . "<div><i style='font-size:10px'>{$ligne["ipaddr"]}</i></div></a></td>\n\t\t\t<td width=1% align='center' {$style}>" . COUNTDEGROUPES($ligne["ID"]) . "</td>\n\t\t\t<td width=1% align='center' {$style}>" . COUNTDEGBLKS($ligne["ID"]) . "</td>\n\t\t\t<td width=1% align='center' {$style}>" . COUNTDEGBWLS($ligne["ID"]) . "</td>\n\t\t\t<td width=1% >{$delete}</td>\n\t\t</tr>\n\t\t";
    }
    $html = $html . "</table>\n\t</center>\n\t<script>\n\t\tfunction DansGuardianEditRule(ID,rname){\n\t\t\tYahooWin3('600','dansguardian2.edit.php?ID='+ID,'{$rule_text}::'+ID+'::'+rname);\n\t\t}\n\t\t\n\t\tvar x_DansGuardianDeleteMainRule= function (obj) {\n\t\t\tvar res=obj.responseText;\n\t\t\tif (res.length>3){alert(res);}\n\t\t\tif(document.getElementById('main_dansguardian_tabs')){RefreshTab('main_dansguardian_tabs');}\n\t\t\tGroupsDansRuleSearch();\t\t\n\t\t\t\n\t\t\t\n\t\t}\t\t\n\t\t\n\t\tfunction DansGuardianDeleteMainRule(ID){\n\t\t\tif(confirm('{$action_delete_rule}')){\n\t\t\t\tvar XHR = new XHRConnection();\n\t\t\t\tAnimateDiv('DansAnimate');\n\t\t     \tXHR.appendData('DansGuardianDeleteMainRule', ID);\n\t\t      \tXHR.sendAndLoad('{$page}', 'POST',x_DansGuardianDeleteMainRule);  \n\t\t\t}\n\t\t}\n\t\n\t\n\t</script>";
    echo $tpl->_ENGINE_parse_body($html);
}
示例#2
0
function rule_list()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_squid_builder();
    $search = '%';
    $table = "webfilter_quotas";
    $page = 1;
    $FORCE_FILTER = null;
    $total = 0;
    if ($q->COUNT_ROWS($table) == 0) {
        json_error_show("no data");
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $searchstring = string_to_flexquery();
    if ($searchstring != null) {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        $total = $ligne["TCOUNT"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT *  FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    $Timez[0] = $tpl->javascript_parse_text("{by_hour}");
    $Timez[1] = $tpl->javascript_parse_text("{by_hour}");
    $Timez[2] = $tpl->javascript_parse_text("{by_day}");
    $Timez[3] = $tpl->javascript_parse_text("{by_week}");
    $all_text = $tpl->javascript_parse_text("{all}");
    $only_size = $tpl->javascript_parse_text("{only_size}");
    if (!$q->ok) {
        json_error_show($q->mysql_error);
    }
    if (mysql_num_rows($results) == 0) {
        json_error_show("no data");
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $ID = $ligne["ID"];
        $md5 = md5($ligne["ID"]);
        $color = "black";
        $ligne["rulename"] = utf8_encode($ligne["rulename"]);
        $delete = imgsimple("delete-32.png", "", "Loadjs('{$MyPage}?delete-js={$ligne["ID"]}')");
        $enable = Field_checkbox($md5, 1, $ligne["enabled"], "Loadjs('{$MyPage}?enable-js={$ligne["ID"]}')");
        $js = "Loadjs('{$MyPage}?rule-js=yes&ID={$ligne["ID"]}');";
        if ($ligne["enabled"] == 0) {
            $color = "#9A9A9A";
        }
        $CountOfCategories = COUNTDEGBLKS($ligne["ID"]);
        $CountOfMembers = COUNTDEGROUPES($ligne["ID"]);
        $Quota = "{$ligne["quotasize"]}MB " . $Timez[$ligne["quotaPeriod"]];
        if (intval($ligne["AllSystems"]) == 1) {
            $CountOfMembers = $all_text;
        }
        if ($CountOfCategories == 0) {
            $CountOfCategories = $all_text;
        }
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\" \n\t\t\t\t\t\t\tstyle='font-size:22px;text-decoration:underline;color:{$color}'>{$ligne["groupname"]}</a>", "<span style='font-size:22px;color:{$color}'>{$CountOfMembers}</span>", "<span style='font-size:22px;color:{$color}'>{$CountOfCategories}</span>", "<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\"\n\t\t\t\t\t\t\tstyle='font-size:22px;text-decoration:underline;color:{$color}'>{$Quota}</a>", $enable, "<center>{$delete}</center>"));
    }
    echo json_encode($data);
}