function category_table()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $webfilter = new webfilter_rules();
    $t = $_GET["t"];
    $new_group = $tpl->javascript_parse_text("{new_group}");
    $groups = $tpl->_ENGINE_parse_body("{groups2}");
    $TimeSpace = $webfilter->TimeToText(unserialize(base64_decode($ligne["TimeSpace"])));
    $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
    if (!is_numeric($EnableWebProxyStatsAppliance)) {
        $EnableWebProxyStatsAppliance = 0;
    }
    $groups = $tpl->_ENGINE_parse_body("{groups}");
    $categories = $tpl->_ENGINE_parse_body("{categories}");
    $whitelists = $tpl->_ENGINE_parse_body("{whitelists}");
    $delete = $tpl->_ENGINE_parse_body("{delete}");
    $action_delete_group = $tpl->javascript_parse_text("{action_delete_group}");
    $compile_rules = $tpl->_ENGINE_parse_body("{compile_rules}");
    $service_events = $tpl->_ENGINE_parse_body("{service_events}");
    $global_parameters = $tpl->_ENGINE_parse_body("{global_parameters}");
    $ldap_parameters = $tpl->_ENGINE_parse_body("{ldap_parameters2}");
    $config_file = $tpl->_ENGINE_parse_body("{config_file}");
    $categories_group = $tpl->_ENGINE_parse_body("{categories_groups}");
    $enabled = $tpl->javascript_parse_text("{enabled}");
    $tSource = $_GET["tSource"];
    $tt = time();
    $error_ldap = null;
    $MainRuleID = $_GET["RULEID"];
    $title = null;
    if (is_numeric($MainRuleID) > 0) {
        $name = "{default}";
        $white = $tpl->_ENGINE_parse_body("{blacklist}");
        if ($_GET["modeblk"] == 1) {
            $white = $tpl->_ENGINE_parse_body("{whitelist}");
        }
        if ($MainRuleID > 0) {
            $q = new mysql_squid_builder();
            $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT groupname FROM webfilter_rules WHERE ID={$MainRuleID}"));
            $title = $tpl->javascript_parse_text("{rule}") . " " . utf8_encode($ligne["groupname"]) . " | " . $tpl->javascript_parse_text("{$white}");
        }
    }
    $table_size = 670;
    $group_size = 445;
    if (is_numeric($_GET["table-size"])) {
        $table_size = $_GET["table-size"];
    }
    if (is_numeric($_GET["group-size"])) {
        $group_size = $_GET["group-size"];
    }
    $buttons = "\n\tbuttons : [\n\t{name: '{$new_group}', bclass: 'add', onpress : AddCategoryGroup{$tt}},\n\t{name: '{$compile_rules}', bclass: 'Reconf', onpress : CompileUfdbGuardRules},\n\t{name: 'Sync', bclass: 'Reload', onpress : Sync{$t}},\n\t],";
    //{display: ' ', name : 'dup', width :31, sortable : false, align: 'center'},
    $html = "\n<div>\n{$error_ldap}\n<table class='flexRT{$tt}' style='display: none' id='flexRT{$tt}' style='width:100%'></table>\n</div>\n<script>\nvar rowid{$tt}='';\n\$(document).ready(function(){\n\t\$('#flexRT{$tt}').flexigrid({\n\t\turl: '{$page}?groups-table-list=yes&t={$tt}&tSource={$_GET["tSource"]}&RULEID={$_GET["RULEID"]}&modeblk={$_GET["modeblk"]}',\n\t\tdataType: 'json',\n\t\tcolModel : [\n\t\t{display: '{$groups}', name : 'groupname', width : {$group_size}, sortable : true, align: 'left'},\n\t\t{display: '{$categories}', name : 'none', width :87, sortable : false, align: 'center'},\n\t\t{display: '{$enabled}', name : 'enabled', width : 31, sortable : false, align: 'center'},\n\t\t{display: '{$delete}', name : 'delete', width : 31, sortable : false, align: 'center'},\n\t\t],\n\t\t{$buttons}\n\t\tsearchitems : [\n\t\t{display: '{$groups}', name : 'groupname'},\n\t\t],\n\t\tsortname: 'groupname',\n\t\tsortorder: 'asc',\n\t\tusepager: true,\n\t\ttitle: '{$title}',\n\t\tuseRp: true,\n\t\trp: 100,\n\t\tshowTableToggleBtn: false,\n\t\twidth: {$table_size},\n\t\theight: 450,\n\t\tsingleSelect: true,\n\t\trpOptions: [10, 20, 30, 50,100,200,500,1000]\n\t});\n});\n\nvar xAddCategoryGroup{$tt}= function (obj) {\n\tvar res=obj.responseText;\n\tif(res.length>3){alert(res);}\n\t\$('#flexRT{$_GET["t"]}').flexReload();\n\t\$('#flexRT{$tt}').flexReload();\n\t\$('#flexRT{$tSource}').flexReload();\n\tExecuteByClassName('SearchFunction');\n\t\n\t\n}\n\nfunction AddCategoryGroup{$tt}(){\n\tvar groupname=prompt('{$new_group}','New category group');\n\tif(!groupname){return;}\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('new-category-group', groupname);\n\tXHR.sendAndLoad('{$page}', 'POST',xAddCategoryGroup{$tt});\t\n\t\t\n\t\n}\n\nfunction Sync{$t}(){\n      var XHR = new XHRConnection();\n      XHR.appendData('SyncTable','yes');\n      XHR.sendAndLoad('{$page}', 'POST',xAddCategoryGroup{$tt});\n}\n\nfunction CategoryGroupEnable{$tt}(ID){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('enable-category-group', ID);\n\tXHR.sendAndLoad('{$page}', 'POST',xAddCategoryGroup{$tt});\n}\nfunction CategoryRuleGroupEnable{$tt}(ID,ruleid){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('enable-category-rule', ID);\n\tXHR.appendData('ruleid', ruleid);\n\tXHR.appendData('modeblk', '{$_GET["modeblk"]}');\n\tXHR.sendAndLoad('{$page}', 'POST',xAddCategoryGroup{$tt});\n}\n\n\n\nvar xCategoryGroupDelete{$tt}= function (obj) {\n\tvar res=obj.responseText;\n\tif (res.length>3){alert(res);return;}\n\t\$('#row'+rowid{$tt}).remove();\n\t\$('#flexRT{$tt}').flexReload();\n\t\$('#flexRT{$_GET["t"]}').flexReload();\n\t\$('#flexRT{$tSource}').flexReload();\t\n\tExecuteByClassName('SearchFunction');\n}\n\nfunction CategoryGroupDelete{$tt}(ID,md){\n\trowid{$tt}=md;\n\tif(confirm('{$action_delete_group}')){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('delete-category-group', ID);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xCategoryGroupDelete{$tt});\n\t}\n}\n</script>\n\n\t\t";
    echo $html;
}
예제 #2
0
function rules_table()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $webfilter = new webfilter_rules();
    $t = time();
    $add_rule = $tpl->_ENGINE_parse_body("{new_rule}");
    $rule_text = $tpl->_ENGINE_parse_body("{rule}");
    $TimeSpace = $webfilter->TimeToText(unserialize(base64_decode($ligne["TimeSpace"])));
    $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
    if (!is_numeric($EnableWebProxyStatsAppliance)) {
        $EnableWebProxyStatsAppliance = 0;
    }
    $groups = $tpl->_ENGINE_parse_body("{groups2}");
    $blacklists = $tpl->_ENGINE_parse_body("{blacklists}");
    $whitelists = $tpl->_ENGINE_parse_body("{whitelists}");
    $delete = $tpl->_ENGINE_parse_body("{delete}");
    $action_delete_rule = $tpl->javascript_parse_text("{action_delete_rule}");
    $compile_rules = $tpl->_ENGINE_parse_body("{compile_rules}");
    $service_events = $tpl->_ENGINE_parse_body("{service_events}");
    $webfiltering_groups = $tpl->_ENGINE_parse_body("{webfiltering_groups}");
    $ldap_parameters = $tpl->_ENGINE_parse_body("{ldap_parameters2}");
    $config_file = $tpl->_ENGINE_parse_body("{config_file}");
    $categories_group = $tpl->_ENGINE_parse_body("{categories_groups}");
    $config_status = $tpl->javascript_parse_text("{config_status}");
    $apply_restart = $tpl->javascript_parse_text("{apply_restart}");
    $verify_rules = $tpl->javascript_parse_text("{verify_rules}");
    $main_title = "<span style=font-size:30px>" . $tpl->javascript_parse_text("{main_webfiltering_rules}") . "</span>";
    $paranoid_mode = $tpl->javascript_parse_text("{paranoid_mode}");
    $UseRemoteUfdbguardService = $sock->GET_INFO("UseRemoteUfdbguardService");
    $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
    if (!is_numeric($UseRemoteUfdbguardService)) {
        $UseRemoteUfdbguardService = 0;
    }
    $compile_bt = "{name: '<strong style=font-size:18px;font-weight:bold>{$compile_rules}</strong>', bclass: 'Reconf', onpress : CompileUfdbGuardRules},";
    $restart_bt = "{name: '<strong style=font-size:18px;font-weight:bold>{$apply_restart}</strong>', bclass: 'Reconf', onpress : ApplyAndRestartWebf},";
    $verify_rules = "{name: '<strong style=font-size:18px;font-weight:bold>{$verify_rules}</strong>', bclass: 'Search', onpress : VerifyRulesWebf},";
    if ($UseRemoteUfdbguardService == 1) {
        $compile_bt = null;
    }
    $error_ldap = null;
    $buttons = "\n\tbuttons : [\n\t{name: '<strong style=font-size:18px;>{$add_rule}</strong>', bclass: 'add', onpress : DansGuardianNewRule},\n\t{name: '<strong style=font-size:18px;font-weight:bold>{$categories_group}</strong>', bclass: 'group', onpress : CategoriesGroups},\n\t{name: '<strong style=font-size:18px;font-weight:bold>{$webfiltering_groups}</strong>', bclass: 'Groups', onpress : UfdbGuardConfigs},\n\t{name: '<strong style=font-size:18px;font-weight:bold>{$config_status}</strong>', bclass: 'Search', onpress : DansGuardianConfStatus},\n\t\n\t\n\t\n\t\n\t{$verify_rules}\n\t{$compile_bt}\t\n\t{$restart_bt}\n\t\n\t\n\t],";
    $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
    if (!is_numeric($EnableKerbAuth)) {
        $EnableKerbAuth = 0;
    }
    if ($EnableKerbAuth == 1) {
        $ad = new ActiveDirectory();
        if ($ad->ldapFailed) {
            $ad->ldap_last_error = nl2br($ad->ldap_last_error);
            echo FATAL_ERROR_SHOW_128_DESIGN("{error_ad_ldap}", "{error}:LDAP&nbsp;&raquo;&nbsp;Active Directory ({$ad->ldap_host}:{$ad->ldap_port})</strong><hr>{$ad->ldap_last_error}", "GotoActiveDirectoryLDAPParams()");
        }
    }
    $TBSIZE = 350;
    $TBWIDTH = 823;
    if ($tpl->language == "fr") {
        $TBSIZE = 350;
        $TBWIDTH = 823;
    }
    //{display: '&nbsp;', name : 'dup', width :31, sortable : false, align: 'center'},
    $html = "\n<center id='rules-toolbox' style='margin-bottom:5px'></center>\n{$error_ldap}\n<input type='hidden' id='WebFilteringMainTableID' value='flexRT{$t}'>\n<table class='flexRT{$t}' style='display: none' id='flexRT{$t}' style='width:100%'></table>\n</div>\n<script>\nvar rowid=0;\nfunction flexRTStart{$t}(){\n\$('#flexRT{$t}').flexigrid({\n\turl: '{$page}?rules-table-list=yes&t={$t}',\n\tdataType: 'json',\n\tcolModel : [\n\t\t{display: '<span style=font-size:18px>{$rule_text}</span>', name : 'groupname', width : 659, sortable : true, align: 'left'},\t\n\t\t{display: '<span style=font-size:18px>{$groups}</span>', name : 'topattern', width :123, sortable : false, align: 'center'},\n\t\t{display: '<span style=font-size:18px>{$blacklists}</span>', name : 'enabled', width : 162, sortable : false, align: 'center'},\n\t\t{display: '<span style=font-size:18px>{$whitelists}</span>', name : 'delete', width : 162, sortable : false, align: 'center'},\n\t\t{display: '<span style=font-size:18px>&nbsp;</span>', name : 'zOrder', width :90, sortable : true, align: 'center'},\n\t\t{display: '<span style=font-size:18px>&nbsp;</span>', name : 'dup', width :65, sortable : false, align: 'center'},\n\t\t{display: '<span style=font-size:18px>{$delete}</span>', name : 'delete', width : 119, sortable : false, align: 'center'},\n\t\t],\n\t{$buttons}\n\tsearchitems : [\n\t\t{display: '{$rule_text}', name : 'groupname'},\n\t\t],\n\tsortname: 'zOrder',\n\tsortorder: 'asc',\n\tusepager: true,\n\ttitle: '',\n\tuseRp: true,\n\trp: 50,\n\tshowTableToggleBtn: false,\n\twidth: '99%',\n\theight: 600,\n\tsingleSelect: true,\n\trpOptions: [10, 20, 30, 50,100,200]\n\t\n\t});   \n\t\n\t\n}\nfunction DansGuardianConfStatus(){\n\tLoadjs('ufdbguard.conf.php');\n\n}\nfunction DansGuardianNewRule(){\n\tDansGuardianEditRule(-1)\n}\n\nfunction ApplyAndRestartWebf(){\n\tLoadjs('ufdb.restart.progress.php');\n\n}\n\nfunction VerifyRulesWebf(){\n\tLoadjs('ufdbguard.tests.php');\n}\n\n\n\tfunction DansGuardianEditRule(ID,rname){\n\t\tYahooWin3('1100','dansguardian2.edit.php?ID='+ID+'&t={$t}','{$rule_text}::'+ID+'::'+rname);\n\t}\n\t\n\tfunction CompileUfdbGuardRules(){\n\t\tLoadjs('dansguardian2.compile.php');\n\t}\n\t\n\tfunction CategoriesGroups(){\n\t\tLoadjs('dansguardian2.categories.group.php?tSource={$t}');\n\t}\n\t\n\tfunction UfdbGuardConfigs(){\n\t\tGotoUfdbGroups();\n\t}\n\t\n\tfunction UfdbguardEvents(){\n\t\tLoadjs('{$page}?UfdbguardEvents=yes');\n\t}\n\tvar x_RuleDansUpDown{$t}= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif(res.length>3){alert(res);return;}\n\t\t\$('#flexRT{$t}').flexReload();\n\t}\t\n\n\t\t\n\tfunction RuleDansUpDown(ID,dir){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('rule-move', ID);\n\t\tXHR.appendData('rule-dir', dir);\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_RuleDansUpDown{$t});\t\n\t}\n\t\n\n\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\t\$('#row'+rowid).remove();\n\t\t}\t\t\n\t\t\n\t\tfunction DansGuardianDeleteMainRule(ID){\n\t\t\trowid=ID;\n\t\t\tif(confirm('{$action_delete_rule}')){\n\t\t\t\tvar XHR = new XHRConnection();\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\t\n\n\t\n\n\tsetTimeout('flexRTStart{$t}()',800);\t\n\t\n</script>\n\n";
    echo $html;
}
예제 #3
0
function ipconfig_routes(){
	$page=CurrentPageName();
	$tpl=new templates();
	$sock=new sockets();
	$webfilter=new webfilter_rules();
	$t=time();
	$new_route=$tpl->_ENGINE_parse_body("{new_route}");
	$rule_text=$tpl->_ENGINE_parse_body("{rule}");
	$TimeSpace=$webfilter->TimeToText(unserialize(base64_decode($ligne["TimeSpace"])));
	$EnableWebProxyStatsAppliance=$sock->GET_INFO("EnableWebProxyStatsAppliance");
	if(!is_numeric($EnableWebProxyStatsAppliance)){$EnableWebProxyStatsAppliance=0;}
	$groups=$tpl->_ENGINE_parse_body("{groups}");
	$gateway=$tpl->_ENGINE_parse_body("{gateway}");
	$whitelists=$tpl->_ENGINE_parse_body("{whitelists}");
	$delete=$tpl->_ENGINE_parse_body("{delete}");
	$action_delete_rule=$tpl->javascript_parse_text("{action_delete_rule}");
	$from_ip_address=$tpl->_ENGINE_parse_body("{from_ip_address}");
	$service_events=$tpl->_ENGINE_parse_body("{service_events}");
	$global_parameters=$tpl->_ENGINE_parse_body("{global_parameters}");
	$ldap_parameters=$tpl->_ENGINE_parse_body("{ldap_parameters2}");
	$config_file=$tpl->_ENGINE_parse_body("{config_file}");
	$categories_group=$tpl->_ENGINE_parse_body("{categories_groups}");
	
	$error_ldap=null;
	$buttons="
	buttons : [
	{name: '<strong style=font-size:12px;>$new_route</strong>', bclass: 'add', onpress : NewRoute$t},
	
	
	],";
	
	
	
	$html="
	<table class='flexRT$t' style='display: none' id='flexRT$t' style='width:100%'></table>
	</div>
	<script>
var rowid$t=0;
function flexRTStart$t(){
	$('#flexRT$t').flexigrid({
		url: '$page?ifconfig-route-list=yes&t=$t&nic={$_GET["nic"]}',
		dataType: 'json',
		colModel : [
		{display: '$from_ip_address', name : 'from_ip_address', width : 221, sortable : false, align: 'left'},
		{display: '$gateway', name : 'gateway', width :115, sortable : false, align: 'left'},
		{display: '$delete', name : 'delete', width : 31, sortable : false, align: 'center'},
		],
		$buttons
		searchitems : [
		{display: '$from_ip_address', name : 'from_ip_address'},
		],
		sortname: 'zOrder',
		sortorder: 'asc',
		usepager: true,
		title: '',
		useRp: true,
		rp: 50,
		showTableToggleBtn: false,
		width: 430,
		height: 300,
		singleSelect: true,
		rpOptions: [10, 20, 30, 50,100,200]
		});
}
	
	
	function NewRoute$t(){
		Loadjs('$page?ifconfig-route-add-js=yes&t=$t&nic={$_GET["nic"]}');
	}
	

var xDeleteRoute$t= function (obj) {
		var res=obj.responseText;
		if (res.length>3){alert(res);}
		$('#row'+rowid$t).remove();
	}
	
function DeleteRoute$t(ip,id){
	rowid$t=id;
	if(confirm('$delete '+ip)){
		var XHR = new XHRConnection();		
		XHR.appendData('del-routes','yes');
		XHR.appendData('nic','{$_GET["nic"]}');
		XHR.appendData('IP',ip);
		XHR.sendAndLoad('$page', 'GET',xDeleteRoute$t);	
	}
}
	
setTimeout('flexRTStart$t()',800);
</script>
	
	";
	
	echo $html;
	
	}
예제 #4
0
function rules_search()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $page = CurrentPageName();
    $rule_text = $tpl->_ENGINE_parse_body("{rule}");
    $action_delete_rule = $tpl->javascript_parse_text("{action_delete_rule}");
    $q = new mysql_squid_builder();
    if (!$q->FIELD_EXISTS("webfilter_rules", "zOrder")) {
        $q->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `zOrder` SMALLINT(2) NOT NULL,ADD INDEX ( `zOrder` )");
    }
    if (!$q->ok) {
        json_error_show("{$q->mysql_error}");
    }
    if (!$q->FIELD_EXISTS("webfilter_rules", "AllSystems")) {
        $q->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `AllSystems` smallint(1),ADD INDEX ( `AllSystems` )");
    }
    if (!$q->ok) {
        json_error_show("{$q->mysql_error}");
    }
    $t = $_GET["t"];
    $search = '%';
    $table = "webfilter_rules";
    $page = CurrentPageName();
    $FORCE_FILTER = null;
    $total = 0;
    if (!$q->TABLE_EXISTS($table)) {
        $q->CheckTables();
    }
    $searchstring = string_to_flexquery("rules-search");
    $webfilter = new webfilter_rules();
    $styleTD = "style='font-size:16px;font-weight:bold'";
    $styleTDCenter = "style='font-size:16px;font-weight:bold;text-align:center !important'";
    $sql = "SELECT *  FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} ORDER by zOrder";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        senderror("{$q->mysql_error}");
    }
    $sock = new sockets();
    $ligne = unserialize(base64_decode($sock->GET_INFO("DansGuardianDefaultMainRule")));
    $DefaultPosition = $ligne["defaultPosition"];
    if (!is_numeric($DefaultPosition)) {
        $DefaultPosition = 0;
    }
    $AllSystems = $tpl->_ENGINE_parse_body("{AllSystems}");
    $boot = new boostrap_form();
    if ($DefaultPosition == 0) {
        $tr[] = DefaultRule();
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $ID = $ligne["ID"];
        $md5 = md5($ligne["ID"]);
        $ligne["groupname"] = utf8_encode($ligne["groupname"]);
        $delete = imgtootltip("delete-24.png", "{delete}", "DansGuardianDeleteMainRule('{$ligne["ID"]}')");
        $js = "DansGuardianEditRule('{$ligne["ID"]}','{$ligne["groupname"]}');";
        $link = $boot->trswitch($js);
        $link_blacklist = $boot->trswitch("Loadjs('dansguardian2.edit.php?js-blacklist-list=yes&RULEID={$ligne['ID']}&modeblk=0&group=&TimeID=&t={$t}');");
        $link_whitelist = $boot->trswitch("Loadjs('dansguardian2.edit.php?js-blacklist-list=yes&RULEID={$ligne['ID']}&modeblk=1&group=&TimeID=&t={$t}');");
        $link_group = $boot->trswitch("Loadjs('dansguardian2.edit.php?js-groups={$ligne["ID"]}&ID={$ligne["ID"]}&t={$t}')");
        $TimeSpace = $webfilter->TimeToText(unserialize(base64_decode($ligne["TimeSpace"])));
        $color = "black";
        if ($ligne["enabled"] == 0) {
            $color = "#8a8a8a";
        }
        $rules_dans_time_rule = $webfilter->rules_dans_time_rule($ligne["ID"]);
        if ($ligne["groupmode"] == 0) {
            $warn = "<div style='float:right'><img src='img/stop-24.png'></div>";
        }
        $duplicate = imgsimple("duplicate-24.png", null, "Loadjs('dansguardian2.duplicate.php?from={$ligne['ID']}&t={$t}')");
        $TimeSpace = $webfilter->rule_time_list_explain($ligne["TimeSpace"], $ligne["ID"], $t);
        $styleupd = "style='border:0px;margin:0px;padding:0px;background-color:transparent'";
        $up = imgsimple("arrow-up-32.png", "", "RuleDansUpDown('{$ligne['ID']}',1)");
        $down = imgsimple("arrow-down-32.png", "", "RuleDansUpDown('{$ligne['ID']}',0)");
        $zorder = "<table {$styleupd}><tr><td {$styleupd}>{$down}</td {$styleupd}><td {$styleupd}>{$up}</td></tr></table>";
        $CountDeGroups = "&laquo;&nbsp;" . $webfilter->COUNTDEGROUPES($ligne["ID"]) . "&nbsp;&raquo;";
        $templatejs = $boot->trswitch("Loadjs('dansguardian.template.php?js=yes&ID={$ligne["ID"]}')");
        if ($ligne["AllSystems"] == 1) {
            $jsGroups = "*";
            $CountDeGroups = "*";
        }
        $tr[] = "\n\t\t\t<tr id='{$ligne['ID']}'>\n\t\t\t<td {$styleTD} {$link} width=99% ><span id='anim-img-0'>{$ligne["groupname"]}</span> {$TimeSpace}</td>\n\t\t\t<td {$styleTDCenter} {$link_group} width=1% align=center>{$CountDeGroups}</td>\n\t\t\t<td {$styleTDCenter} {$link_blacklist} width=1% align=center>" . $webfilter->COUNTDEGBLKS($ligne['ID']) . "</td>\n\t\t\t<td {$styleTDCenter} {$link_whitelist} width=1% align=center>" . $webfilter->COUNTDEGBWLS($ligne['ID']) . "</td>\n\t\t\t<td {$styleTDCenter} width=35px align=center nowrap>{$zorder}</td>\n\t\t\t<td {$styleTDCenter} {$templatejs} width=35px align=center nowrap><img src='img/banned-template-32.png'></td>\n\t\t\t<td {$styleTDCenter} width=35px align=center nowrap>{$duplicate}</td>\n\t\t\t<td width=35px align='center' nowrap {$styleTDCenter}>{$delete}</td>\n\t\t\t</tr>";
    }
    if ($DefaultPosition == 1) {
        $tr[] = DefaultRule();
    }
    $table = $tpl->_ENGINE_parse_body("\n\t\t\t<table class='table table-bordered table-hover'>\n\t\t\t<thead>\n\t\t\t<tr>\n\t\t\t<th>{rule}</th>\n\t\t\t<th>{groups2}</th>\n\t\t\t<th>{blacklists}</th>\n\t\t\t<th>{whitelists}</th>\n\t\t\t<th>{order}</th>\n\t\t\t<th>{template}</th>\n\t\t\t<th>&nbsp;</th>\n\t\t\t<th>&nbsp;</th>\n\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>\n\t\t\t") . @implode("\n", $tr);
    $js = "\n<script>\t\t\t\nfunction DansGuardianNewRule(){\n\t\tDansGuardianEditRule(-1)\n\t}\n\n\tfunction DansGuardianEditRule(ID,rname){\n\t\tYahooWin3('1010','dansguardian2.edit.php?ID='+ID+'&t={$t}','{$rule_text}::'+ID+'::'+rname);\n\t}\n\t\n\tfunction CompileUfdbGuardRules(){\n\t\tLoadjs('dansguardian2.compile.php');\n\t}\n\t\n\tfunction UfdbGuardConfigs(){\n\t\tLoadjs('ufdbguard.php');\n\t}\n\t\n\tfunction UfdbguardEvents(){\n\t\tLoadjs('dansguardian2.mainrules.php?UfdbguardEvents=yes');\n\t}\n\tvar x_RuleDansUpDown{$t}= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif(res.length>3){alert(res);return;}\n\t\tExecuteByClassName('SearchFunction');\n\t}\t\n\n\t\t\n\tfunction RuleDansUpDown(ID,dir){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('rule-move', ID);\n\t\tXHR.appendData('rule-dir', dir);\n\t\tXHR.sendAndLoad('dansguardian2.mainrules.php', 'POST',x_RuleDansUpDown{$t});\t\n\t}\n\t\n\n\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\t\$('#'+rowid).remove();\n\t\t}\t\t\n\t\t\n\t\tfunction DansGuardianDeleteMainRule(ID){\n\t\t\trowid=ID;\n\t\t\tif(confirm('{$action_delete_rule}')){\n\t\t\t\tvar XHR = new XHRConnection();\n\t\t     \tXHR.appendData('DansGuardianDeleteMainRule', ID);\n\t\t      \tXHR.sendAndLoad('dansguardian2.mainrules.php', 'POST',x_DansGuardianDeleteMainRule);  \n\t\t\t}\n\t\t}\n\t\t\n\t\tfunction RulesToolBox(){\n\t\t\tLoadAjaxTiny('rules-toolbox','dansguardian2.mainrules.php?rules-toolbox=yes');\n\t\t}\n\t\n\tRulesToolBox();\t\n\tLoadAjaxTiny('rules-toolbox-left','dansguardian2.mainrules.php?rules-toolbox-left=yes');\n\t\n</script>";
    echo $table . "\n" . $js;
}
function rules_table()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $webfilter = new webfilter_rules();
    $t = time();
    $add_rule = $tpl->_ENGINE_parse_body("{new_rule}");
    $rule_text = $tpl->_ENGINE_parse_body("{rule}");
    $TimeSpace = $webfilter->TimeToText(unserialize(base64_decode($ligne["TimeSpace"])));
    $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
    if (!is_numeric($EnableWebProxyStatsAppliance)) {
        $EnableWebProxyStatsAppliance = 0;
    }
    $groups = $tpl->_ENGINE_parse_body("{groups2}");
    $blacklists = $tpl->_ENGINE_parse_body("{blacklists}");
    $whitelists = $tpl->_ENGINE_parse_body("{whitelists}");
    $delete = $tpl->_ENGINE_parse_body("{delete}");
    $action_delete_rule = $tpl->javascript_parse_text("{action_delete_rule}");
    $compile_rules = $tpl->_ENGINE_parse_body("{compile_rules}");
    $service_events = $tpl->_ENGINE_parse_body("{service_events}");
    $global_parameters = $tpl->_ENGINE_parse_body("{global_parameters}");
    $ldap_parameters = $tpl->_ENGINE_parse_body("{ldap_parameters2}");
    $config_file = $tpl->_ENGINE_parse_body("{config_file}");
    $categories_group = $tpl->_ENGINE_parse_body("{categories_groups}");
    $main_title = "<span style=font-size:18px>" . $tpl->javascript_parse_text("{main_webfiltering_rules}") . "</span>";
    $UseRemoteUfdbguardService = $sock->GET_INFO("UseRemoteUfdbguardService");
    $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
    if (!is_numeric($UseRemoteUfdbguardService)) {
        $UseRemoteUfdbguardService = 0;
    }
    $compile_bt = "{name: '<strong style=font-size:16px;font-weight:bold>{$compile_rules}</strong>', bclass: 'Reconf', onpress : CompileUfdbGuardRules},";
    if ($UseRemoteUfdbguardService == 1) {
        $compile_bt = null;
    }
    $error_ldap = null;
    $buttons = "\n\tbuttons : [\n\t{name: '<strong style=font-size:16px;>{$add_rule}</strong>', bclass: 'add', onpress : DansGuardianNewRule},\n\t{name: '<strong style=font-size:16px;font-weight:bold>{$categories_group}</strong>', bclass: 'group', onpress : CategoriesGroups},\n\t{name: '<strong style=font-size:16px;font-weight:bold>{$global_parameters}</strong>', bclass: 'Settings', onpress : UfdbGuardConfigs},\n\t{$compile_bt}\t\n\t\n\t\n\t\n\t],";
    $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
    if (!is_numeric($EnableKerbAuth)) {
        $EnableKerbAuth = 0;
    }
    if ($EnableKerbAuth == 1) {
        $ad = new ActiveDirectory();
        if ($ad->ldapFailed) {
            $ad->ldap_last_error = nl2br($ad->ldap_last_error);
            $error_ldap = $tpl->_ENGINE_parse_body("\n\t\t<div id='{$t}'>\n\t<table style='width:98%' class=form>\n\t<tr>\n\t<td valign='top' width=95%>\n\t\t<div style='font-size:14px;color:#CC0A0A'>\n\t\t<img src='img/error-64.png' style='float:left;margin:3px'>\n\t\t<strong style='font-size:14px'>{error}:LDAP&nbsp;&raquo;&nbsp;Active Directory ({$ad->ldap_host}:{$ad->ldap_port})</strong><hr>\n\t\t<span style='font-size:11px'>{$ad->ldap_last_error}</span>\n\t\t</div>\n\t\t<div style='text-align:right;width:100%'>\n\t\t<table style='width:5%' align='right'>\n\t\t\t<tr>\n\t\t\t<td width=1%><img src='img/arrow-right-24.png'></td>\n\t\t\t<td nowrap>\t\t\n\t\t\t\t<a href=\"javascript:blur();\" \n\t\t\t\t\tOnClick=\"javascript:YahooSearchUser('800','squid.adker.php?ldap-params=yes','{$ldap_parameters}');\" \n\t\t\t\t\tstyle='font-size:14px;text-decoration:underline;font-weight:bold'>{$ldap_parameters}</a>\n\t\t\t\t</td>\n\t\t</tr>\n\t\t</table>\n\t\t</div>\n\t</td>\n\t</tr>\n\t</table>\n\t</div>");
        }
    }
    $TBSIZE = 350;
    $TBWIDTH = 823;
    if ($tpl->language == "fr") {
        $TBSIZE = 350;
        $TBWIDTH = 823;
    }
    //{display: '&nbsp;', name : 'dup', width :31, sortable : false, align: 'center'},
    $html = "\n<center id='rules-toolbox' style='margin-bottom:5px'></center>\n{$error_ldap}\n<input type='hidden' id='WebFilteringMainTableID' value='flexRT{$t}'>\n<table class='flexRT{$t}' style='display: none' id='flexRT{$t}' style='width:100%'></table>\n</div>\n<script>\nvar rowid=0;\nfunction flexRTStart{$t}(){\n\$('#flexRT{$t}').flexigrid({\n\turl: '{$page}?rules-table-list=yes&t={$t}',\n\tdataType: 'json',\n\tcolModel : [\n\t\t{display: '{$rule_text}', name : 'groupname', width : 411, sortable : true, align: 'left'},\t\n\t\t{display: '{$groups}', name : 'topattern', width :123, sortable : false, align: 'center'},\n\t\t{display: '{$blacklists}', name : 'enabled', width : 123, sortable : false, align: 'center'},\n\t\t{display: '{$whitelists}', name : 'delete', width : 123, sortable : false, align: 'center'},\n\t\t{display: '&nbsp;', name : 'zOrder', width :90, sortable : true, align: 'center'},\n\t\t{display: '&nbsp;', name : 'dup', width :65, sortable : false, align: 'center'},\n\t\t{display: '{$delete}', name : 'delete', width : 90, sortable : false, align: 'center'},\n\t\t],\n\t{$buttons}\n\tsearchitems : [\n\t\t{display: '{$rule_text}', name : 'groupname'},\n\t\t],\n\tsortname: 'zOrder',\n\tsortorder: 'asc',\n\tusepager: true,\n\ttitle: '{$main_title}',\n\tuseRp: true,\n\trp: 50,\n\tshowTableToggleBtn: false,\n\twidth: '99%',\n\theight: 600,\n\tsingleSelect: true,\n\trpOptions: [10, 20, 30, 50,100,200]\n\t\n\t});   \n\t\n\t\n}\n\tfunction DansGuardianNewRule(){\n\t\tDansGuardianEditRule(-1)\n\t}\n\n\tfunction DansGuardianEditRule(ID,rname){\n\t\tYahooWin3('1100','dansguardian2.edit.php?ID='+ID+'&t={$t}','{$rule_text}::'+ID+'::'+rname);\n\t}\n\t\n\tfunction CompileUfdbGuardRules(){\n\t\tLoadjs('dansguardian2.compile.php');\n\t}\n\t\n\tfunction CategoriesGroups(){\n\t\tLoadjs('dansguardian2.categories.group.php?tSource={$t}');\n\t}\n\t\n\tfunction UfdbGuardConfigs(){\n\t\tLoadjs('ufdbguard.php');\n\t}\n\t\n\tfunction UfdbguardEvents(){\n\t\tLoadjs('{$page}?UfdbguardEvents=yes');\n\t}\n\tvar x_RuleDansUpDown{$t}= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif(res.length>3){alert(res);return;}\n\t\t\$('#flexRT{$t}').flexReload();\n\t}\t\n\n\t\t\n\tfunction RuleDansUpDown(ID,dir){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('rule-move', ID);\n\t\tXHR.appendData('rule-dir', dir);\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_RuleDansUpDown{$t});\t\n\t}\n\t\n\n\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\t\$('#row'+rowid).remove();\n\t\t}\t\t\n\t\t\n\t\tfunction DansGuardianDeleteMainRule(ID){\n\t\t\trowid=ID;\n\t\t\tif(confirm('{$action_delete_rule}')){\n\t\t\t\tvar XHR = new XHRConnection();\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\t\n\n\t\n\n\tsetTimeout('flexRTStart{$t}()',800);\t\n\t\n</script>\n\n";
    echo $html;
}