Example #1
0
function popup_rules_list()
{
    $tpl = new templates();
    $page = CurrentPageName();
    if (strlen($_GET["delete"]) > 0) {
        if (is_numeric($_GET["delete"])) {
            $dans = new dansguardian($hostname);
            $dans->delete_rule($_GET["delete"]);
        }
    }
    $dans2 = new dansguardian($hostname);
    $rules = $dans2->RulesList;
    $squid = new squidbee();
    if (!is_array($rules)) {
        return null;
    }
    writelogs("Rules number: " . count($rules), __FUNCTION__, __FILE__);
    //48-notes.png
    $count = 0;
    $html = "\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n<thead class='thead'>\n\t<tr>\n\t<th colspan=2>{rules}</th>\n\t<th>{groups}</th>\n\t<th colspan=2>{restrictions}</th>\n\t<th>&nbsp;</th>\n\t<th>&nbsp;</th>\n\t</tr>\n</thead>\n<tbody class='tbody'>";
    while (list($num, $val) = each($rules)) {
        $users = new usersMenus();
        $page = CurrentPageName();
        if (preg_match('#(.+?);(.+)#', $val, $re)) {
            $rulename = $re[1];
        } else {
            $rulename = $val;
        }
        $rule_settings = "YahooWin2(650,'{$page}?rule_main={$num}&tab=mainsettings&hostname={$_GET["hostname"]}','{$rulename}: {rule_behavior}');";
        $restrictions = "YahooWin2(730,'{$page}?popup-restrictions={$num}&hostname={$_GET["hostname"]}','{$rulename}: {restrictions}');";
        $delete = imgtootltip('delete-32.png', '{delete}', "LoadAjax('rules_lists','dansguardian.index.php?pop-rules-list=yes&delete={$num}');");
        $files = "YahooWin2(720,'{$page}?popup-files={$num}&hostname={$_GET["hostname"]}','{$rulename}: {files_restrictions}');";
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $restrictions = "LoadAjax('rules_list_contents','{$page}?popup-restrictions={$num}&hostname={$_GET["hostname"]}')";
        $files = "LoadAjax('rules_list_contents','{$page}?popup-files={$num}&hostname={$_GET["hostname"]}');";
        //https://192.168.1.19:9000/squid.webfilter.users.php?table=yes&rule=3 //
        if (!$users->EnableManageUsersTroughActiveDirectory) {
            $tr_groups = imgtootltip("members-priv-32.png", "{$rulename}::{privileges}", "Loadjs('dansguardian.groups.php?ID={$num}')");
        }
        $tr_rule_settings = imgtootltip("script-32.png", "{$rulename}::{rule_behavior}", $rule_settings);
        $tr_rule_restrictions = imgtootltip("banned-template-32.png", "{$rulename}::{restrictions}", $restrictions);
        $tr_auth = imgtootltip("view_members-32.png ", "{$rulename}::{groups}", "LoadAjax('rules_list_contents','squid.webfilter.users.php?table=yes&rule={$num}')");
        if ($count == 0) {
            $delete = "&nbsp;";
            $tr_rule_settings = "&nbsp;";
            $tr_auth = "&nbsp;";
            $tr_groups = "&nbsp;";
        }
        if ($squid->enable_squidguard == 1) {
            $files = "Loadjs('dansguardian.banned-extensions.php?rule_main={$num}')";
        }
        if (!$users->DANSGUARDIAN_INSTALLED) {
            $files = "Loadjs('dansguardian.banned-extensions.php?rule_main={$num}')";
        }
        if (!$squid->enable_dansguardian == 0) {
            $files = "Loadjs('dansguardian.banned-extensions.php?rule_main={$num}')";
        }
        $sql = "SELECT count(*) as tcount FROM dansguardian_ipgroups WHERE RuleID={$num}";
        $q = new mysql();
        $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
        $count_ip = $ligne["tcount"];
        $sql = "SELECT count(*) as tcount FROM dansguardian_groups WHERE RuleID={$num}";
        $q = new mysql();
        $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
        $count_groups = $ligne["tcount"];
        $tr_filerestrictions = imgtootltip("bg_forbiden-attachmt-32.png", "{$rulename}::{files_restrictions}", $files);
        $text = "<div style='text-align:right;font-size:10px;padding-top:3px;'><i><strong>{$count_ip}</strong> {filter_ip_group}, <strong>{$count_groups}</strong> {groups}</div>";
        $html = $html . "\n\t\t<tr class={$classtr}>\n\t\t\t<td width=1%>{$tr_rule_settings}</td>\n\t\t\t<td width=99% nowrap style='font-size:14px'><strong style='letter-spacing:2px'>{$rulename}</strong>{$text}</td>\n\t\t\t<td  width=1% valign='middle' align='center'>{$tr_auth}</td>\n\t\t\t<td  width=1% valign='middle' align='center'>{$tr_rule_restrictions}</td>\n\t\t\t<td  width=1% valign='middle' align='center'>{$tr_filerestrictions}</td>\n\t\t\t<td  width=1% valign='middle' align='center'>{$tr_groups}</td>\n\t\t\t<td  width=1% valign='middle' align='center'>{$delete}</td>\n\t\t</tr>\n\t\t\n\t\t";
        $count = $count + 1;
    }
    $users = new usersMenus();
    $button_ufdb = "&nbsp;";
    $button_addrtules = button("{add_rule}", "dansguardian_addrule('');");
    $compile_rule_text = $tpl->javascript_parse_text("{WARNING_UFDBGUARD_COMPILES_RULES_ASK}");
    if ($users->APP_UFDBGUARD_INSTALLED) {
        $button_ufdb = button("{compile_rules}", "dansguardian_compileMyrulesUFDB('');");
    }
    $html = $html . "\n\t<tr class={$classtr}>\n\t\t\t<td colspan=7 align='right' valign='middle' style='padding:3px'>\n\t\t\t\t<table>\n\t\t\t\t<tr>\n\t\t\t\t<td>{$button_ufdb}</td>\n\t\t\t\t<td>{$button_addrtules}</td>\n\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t</tr>\n\t\t\t</tbody>\n\t\t</table>\n\t\t\n<script>\n\t\t\n\tvar x_dansguardian_compileMyrulesUFDB=function(obj){\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>0){alert(results);}\n\t\t}\t\t\n\t\t\n\tfunction dansguardian_compileMyrulesUFDB(){\n\t\t\tif(confirm('{$compile_rule_text}')){\n\t\t\t\tvar XHR = new XHRConnection();\n\t\t\t\tXHR.appendData('compile-ufdb-total','yes');\n\t\t\t\tXHR.sendAndLoad('{$page}', 'GET',x_dansguardian_compileMyrulesUFDB);\n\t\t\t}\n\t\t\t\n\t\t}\n</script>\n\t";
    return $tpl->_ENGINE_parse_body($html);
}
function popup_rules_list()
{
    if (strlen($_GET["delete"]) > 0) {
        if (is_numeric($_GET["delete"])) {
            $dans = new dansguardian($hostname);
            $dans->delete_rule($_GET["delete"]);
        }
    }
    $dans2 = new dansguardian($hostname);
    $rules = $dans2->RulesList;
    $squid = new squidbee();
    if (!is_array($rules)) {
        return null;
    }
    writelogs("Rules number: " . count($rules), __FUNCTION__, __FILE__);
    //48-notes.png
    $count = 0;
    while (list($num, $val) = each($rules)) {
        $page = CurrentPageName();
        if (preg_match('#(.+?);(.+)#', $val, $re)) {
            $rulename = $re[1];
        } else {
            $rulename = $val;
        }
        $rule_settings = "YahooWin2(650,'{$page}?rule_main={$num}&tab=mainsettings&hostname={$_GET["hostname"]}','{$rulename}: {rule_behavior}');";
        $restrictions = "YahooWin2(730,'{$page}?popup-restrictions={$num}&hostname={$_GET["hostname"]}','{$rulename}: {restrictions}');";
        $delete = imgtootltip('ed_delete.gif', '{delete}', "LoadAjax('rules_lists','dansguardian.index.php?pop-rules-list=yes&delete={$num}');");
        $files = "YahooWin2(720,'{$page}?popup-files={$num}&hostname={$_GET["hostname"]}','{$rulename}: {files_restrictions}');";
        $tr_rule_settings = "\n\t\t<tr>\n\t\t\t<td valign='top' width=1% align='center'><img src='img/service-view.gif'></td>\n\t\t\t<td>" . texttooltip('{rule_behavior}', '{rule_behavior}', $rule_settings) . "</td>\n\t\t</tr>";
        $tr_rule_restrictions = "\n\t\t<tr>\n\t\t\t<td valign='top' width=1% align='center'><img src='img/status_service_removed.png'></td>\n\t\t\t<td>" . texttooltip('{restrictions}', '{restrictions}', $restrictions) . "</td>\n\t\t</tr>";
        $tr_groups = "\n\t\t<tr>\n\t\t\t<td valign='top' width=1% align='center'><img src='img/20-group-icon.png'></td>\n\t\t\t<td>" . texttooltip('{groups}', '{groups}', "Loadjs('dansguardian.groups.php?ID={$num}')") . "</td>\n\t\t</tr>";
        if ($count == 0) {
            $delete = null;
            $tr_rule_settings = null;
            $tr_groups = null;
        }
        if ($squid->enable_squidguard == 1) {
            $files = "Loadjs('dansguardian.banned-extensions.php?rule_main={$num}')";
        }
        $tr_filerestrictions = "\n\t\t<tr>\n\t\t\t<td valign='top' width=1% align='center'><img src='img/zip_small.gif'></td>\n\t\t\t<td>" . texttooltip('{files_restrictions}', '{files_restrictions}', $files) . "</td>\n\t\t</tr>";
        $html = $html . "\n\t\t<div style='float:left;width:130px;\n\t\tmargin:3px;\n\t\tbackground-image:url(img/128-empty-rule.png);\n\t\tbackground-position:0% 0%;\n\t\tbackground-repeat:no-repeat;\n\t\theight:192px;\n\t\tpadding-left:40px'\n\t\t\n\t\tOnMouseOver=\"javascript:this.style.backgroundImage='url(img/128-empty-rule-1.png)';\"\n\t\tOnMouseOut=\"javascript:this.style.backgroundImage='url(img/128-empty-rule.png)';\"\n\t\t128-empty-rule-1.png\n\t\t>\n\t\t<div>\n\t\t<div style='height:40px;padding-right:20px;padding-top:9px;width:140px'>\n\t\t<div style='float:right;margin-right:20px'>{$delete}</div>\n\t\t\t<H3>{$rulename}</H3>\n\t\t</div>\n\t\t\n\t\t\t\t<table style='width:120px;border:0px solid black'>\n\t\t\t\t\t{$tr_rule_settings}\n\t\t\t\t\t{$tr_rule_restrictions}\n\t\t\t\t\t{$tr_filerestrictions}\n\t\t\t\t\t{$tr_groups}\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t</div>\n\t\t";
        $count = $count + 1;
    }
    $tpl = new templates();
    return $tpl->_ENGINE_parse_body($html);
}