function table_main()
{
    if ($_GET["table"] == "STATUS") {
        iptables_status();
        exit;
    }
    $button = "\tbuttons : [\n\t{name: '{$new}', bclass: 'add', onpress : NewRule{$t}},\n\t{name: '{$apply}', bclass: 'Apply', onpress : Apply{$t}},\n\n\t],";
    $page = CurrentPageName();
    $tpl = new templates();
    $eth = $_GET["eth"];
    $ethC = new system_nic($eth);
    $iptable = $_GET["table"];
    $title = $tpl->javascript_parse_text("{$eth} «{$ethC->NICNAME}»");
    $new = $tpl->javascript_parse_text("{new_rule}");
    $rule = $tpl->javascript_parse_text("{rule}");
    $enabled = $tpl->javascript_parse_text("{enabled}");
    $type = $tpl->javascript_parse_text("{type}");
    $delete = $tpl->javascript_parse_text("{delete}");
    $date = $tpl->javascript_parse_text("{zDate}");
    $from = $tpl->javascript_parse_text("{from}");
    $interface = $tpl->javascript_parse_text("{interface}");
    $to = $tpl->javascript_parse_text("{to}");
    $PROTO = $tpl->javascript_parse_text("{proto}");
    $action = $tpl->javascript_parse_text("{action}");
    $t = time();
    $button = null;
    $html = "\n\t<table class='flexRT{$t}' style='display: none' id='flexRT{$t}' style='width:99%'></table>\n\t<script>\n\n\tfunction LoadTable{$t}(){\n\t\$('#flexRT{$t}').flexigrid({\n\turl: '{$page}?logs=yes&eth={$eth}',\n\tdataType: 'json',\n\tcolModel : [\n\t{display: '{$date}', name : 'date', width :152, sortable : false, align: 'left'},\n\t{display: '{$action}', name : 'type1', width : 55, sortable : true, align: 'center'},\n\t{display: 'TABLE', name : 'TABLE', width : 55, sortable : true, align: 'center'},\n\t{display: '{$rule}', name : 'rule', width : 55, sortable : true, align: 'center'},\n\t{display: '{$from} {$interface}', name : 'IN', width : 58, sortable : true, align: 'left'},\n\t{display: '{$from}', name : 'MACIN', width : 190, sortable : true, align: 'left'},\n\t{display: '{$to} {$interface}', name : 'OUT', width : 58, sortable : true, align: 'left'},\n\t{display: '{$to}', name : 'OUTIP', width : 190, sortable : true, align: 'left'},\n\t{display: '{$PROTO}', name : 'proto', width : 70, sortable : true, align: 'center'},\n\n\n\t],\n\n\tsearchitems : [\n\t{display: '{$rulename}', name : 'rulename'},\n\t],\n\tsortname: 'zOrder',\n\tsortorder: 'asc',\n\tusepager: true,\n\ttitle: '{$title}',\n\tuseRp: true,\n\trp: 50,\n\tshowTableToggleBtn: false,\n\twidth: '99%',\n\theight: 550,\n\tsingleSelect: true,\n\trpOptions: [30, 50,100,200,500]\n\n});\n}\nvar xRuleGroupUpDown{$t}= function (obj) {\nvar res=obj.responseText;\nif(res.length>3){alert(res);return;}\n\$('#flexRT{$t}').flexReload();\nExecuteByClassName('SearchFunction');\n}\n\nfunction RuleGroupUpDown{$t}(ID,direction){\nvar XHR = new XHRConnection();\nXHR.appendData('rule-order', ID);\nXHR.appendData('direction', direction);\nXHR.appendData('eth', '{$eth}');\nXHR.appendData('table', '{$iptable}');\nXHR.sendAndLoad('{$page}', 'POST',xRuleGroupUpDown{$t});\n}\n\nfunction DeleteRule{$t}(ID){\nif(!confirm('{$delete} '+ID+' ?')){return;}\nvar XHR = new XHRConnection();\nXHR.appendData('rule-delete', ID);\nXHR.sendAndLoad('{$page}', 'POST',xRuleGroupUpDown{$t});\n}\n\nfunction Apply{$t}(){\nLoadjs('firehol.progress.php');\n}\n\nfunction ChangEnabled{$t}(ID){\nvar XHR = new XHRConnection();\nXHR.appendData('rule-enable', ID);\nXHR.sendAndLoad('{$page}', 'POST',xRuleGroupUpDown{$t});\n}\n\nfunction NewRule{$t}() {\nLoadjs('{$page}?ruleid=0&eth={$eth}&t={$t}&table={$iptable}',true);\n}\nLoadTable{$t}();\n</script>\n";
    echo $html;
}
function iptables_table(){
	
	if($_GET["table"]=="STATUS"){iptables_status();exit;}
	
	$page=CurrentPageName();
	$tpl=new templates();
	$eth=$_GET["eth"];
	$ethC=new system_nic($eth);
	$iptable=$_GET["table"];
	$title=$tpl->javascript_parse_text("$eth $ethC->NICNAME {{$iptable}}");
	$new=$tpl->javascript_parse_text("{new_rule}");
	$rulename=$tpl->javascript_parse_text("{rulename}");
	$enabled=$tpl->javascript_parse_text("{enabled}");
	$type=$tpl->javascript_parse_text("{type}");
	$delete=$tpl->javascript_parse_text("{delete}");
	$apply=$tpl->javascript_parse_text("{apply}");
	
	$t=time();
$html="
<table class='flexRT$t' style='display: none' id='flexRT$t' style='width:99%'></table>
<script>

function LoadTable$t(){
	$('#flexRT$t').flexigrid({
	url: '$page?rules=yes&eth=$eth&t=$t&table=$iptable',
	dataType: 'json',
	colModel : [
		{display: '&nbsp;', name : 'zOrder', width :20, sortable : true, align: 'center'},
		{display: '$rulename', name : 'rulename', width : 423, sortable : true, align: 'left'},
		{display: '$enabled', name : 'enabled', width : 70, sortable : true, align: 'center'},
		{display: '$type', name : 'accepttype', width : 70, sortable : true, align: 'center'},
		{display: '&nbsp;', name : 'up', width : 70, sortable : true, align: 'center'},
		{display: '&nbsp;', name : 'down', width : 70, sortable : true, align: 'center'},
		{display: '$delete', name : 'del', width : 70, sortable : false, align: 'center'},
	
	],
	buttons : [
		{name: '$new', bclass: 'add', onpress : NewRule$t},
		{name: '$apply', bclass: 'Apply', onpress : Apply$t},
		
	],
	searchitems : [
		{display: '$rulename', name : 'rulename'},
	],
	sortname: 'zOrder',
	sortorder: 'asc',
	usepager: true,
	title: '$title',
	useRp: true,
	rp: 15,
	showTableToggleBtn: false,
	width: '99%',
	height: 550,
	singleSelect: true
	
	});
}
var xRuleGroupUpDown$t= function (obj) {
	var res=obj.responseText;
	if(res.length>3){alert(res);return;}
	$('#flexRT$t').flexReload();
	ExecuteByClassName('SearchFunction');
}

function RuleGroupUpDown$t(ID,direction){
	var XHR = new XHRConnection();
	XHR.appendData('rule-order', ID);
	XHR.appendData('direction', direction);
	XHR.appendData('eth', '$eth');
	XHR.appendData('table', '$iptable');
	XHR.sendAndLoad('$page', 'POST',xRuleGroupUpDown$t);
}

function DeleteRule$t(ID){
	if(!confirm('$delete '+ID+' ?')){return;}
	var XHR = new XHRConnection();
	XHR.appendData('rule-delete', ID);
	XHR.sendAndLoad('$page', 'POST',xRuleGroupUpDown$t);
}

function Apply$t(){
	Loadjs('firewall.restart.php');
}

function ChangEnabled$t(ID){
	var XHR = new XHRConnection();
	XHR.appendData('rule-enable', ID);
	XHR.sendAndLoad('$page', 'POST',xRuleGroupUpDown$t);
}

function NewRule$t() {
	Loadjs('$page?ruleid=0&eth=$eth&t=$t&table=$iptable',true);
}	
LoadTable$t();
</script>
";
echo $html;	
	
}
function table_main(){

	if($_GET["table"]=="STATUS"){iptables_status();exit;}
$button="	buttons : [
	{name: '$new', bclass: 'add', onpress : NewRule$t},
	{name: '$apply', bclass: 'Apply', onpress : Apply$t},

	],";
	$page=CurrentPageName();
	$tpl=new templates();
	$eth=$_GET["eth"];
	$ethC=new system_nic($eth);
	$iptable=$_GET["table"];
	$title=$tpl->javascript_parse_text("$eth &laquo;$ethC->NICNAME&raquo;");
	$new=$tpl->javascript_parse_text("{new_rule}");
	$rule=$tpl->javascript_parse_text("{rule}");
	$enabled=$tpl->javascript_parse_text("{enabled}");
	$type=$tpl->javascript_parse_text("{type}");
	$delete=$tpl->javascript_parse_text("{delete}");
	$date=$tpl->javascript_parse_text("{zDate}");
	$from=$tpl->javascript_parse_text("{from}");
	$interface=$tpl->javascript_parse_text("{interface}");
	$to=$tpl->javascript_parse_text("{to}");
	$PROTO=$tpl->javascript_parse_text("{proto}");
	$action=$tpl->javascript_parse_text("{action}");
	$t=time();
	$button=null;
	$html="
	<table class='flexRT$t' style='display: none' id='flexRT$t' style='width:99%'></table>
	<script>

	function LoadTable$t(){
	$('#flexRT$t').flexigrid({
	url: '$page?logs=yes&eth=$eth',
	dataType: 'json',
	colModel : [
	{display: '$date', name : 'date', width :152, sortable : false, align: 'left'},
	{display: '$action', name : 'type1', width : 55, sortable : true, align: 'center'},
	{display: 'TABLE', name : 'TABLE', width : 55, sortable : true, align: 'center'},
	{display: '$rule', name : 'rule', width : 55, sortable : true, align: 'center'},
	{display: '$from $interface', name : 'IN', width : 58, sortable : true, align: 'left'},
	{display: '$from', name : 'MACIN', width : 190, sortable : true, align: 'left'},
	{display: '$to $interface', name : 'OUT', width : 58, sortable : true, align: 'left'},
	{display: '$to', name : 'OUTIP', width : 190, sortable : true, align: 'left'},
	{display: '$PROTO', name : 'proto', width : 70, sortable : true, align: 'center'},


	],

	searchitems : [
	{display: '$rulename', name : 'rulename'},
	],
	sortname: 'zOrder',
	sortorder: 'asc',
	usepager: true,
	title: '$title',
	useRp: true,
	rp: 50,
	showTableToggleBtn: false,
	width: '99%',
	height: 550,
	singleSelect: true,
	rpOptions: [30, 50,100,200,500]

});
}
var xRuleGroupUpDown$t= function (obj) {
var res=obj.responseText;
if(res.length>3){alert(res);return;}
$('#flexRT$t').flexReload();
ExecuteByClassName('SearchFunction');
}

function RuleGroupUpDown$t(ID,direction){
var XHR = new XHRConnection();
XHR.appendData('rule-order', ID);
XHR.appendData('direction', direction);
XHR.appendData('eth', '$eth');
XHR.appendData('table', '$iptable');
XHR.sendAndLoad('$page', 'POST',xRuleGroupUpDown$t);
}

function DeleteRule$t(ID){
if(!confirm('$delete '+ID+' ?')){return;}
var XHR = new XHRConnection();
XHR.appendData('rule-delete', ID);
XHR.sendAndLoad('$page', 'POST',xRuleGroupUpDown$t);
}

function Apply$t(){
Loadjs('firewall.restart.php');
}

function ChangEnabled$t(ID){
var XHR = new XHRConnection();
XHR.appendData('rule-enable', ID);
XHR.sendAndLoad('$page', 'POST',xRuleGroupUpDown$t);
}

function NewRule$t() {
Loadjs('$page?ruleid=0&eth=$eth&t=$t&table=$iptable',true);
}
LoadTable$t();
</script>
";
	echo $html;

}
function iptables_table()
{
    if ($_GET["table"] == "STATUS") {
        iptables_status();
        exit;
    }
    $page = CurrentPageName();
    $tpl = new templates();
    $eth = $_GET["eth"];
    $ethC = new system_nic($eth);
    $iptable = $_GET["table"];
    $title = $tpl->javascript_parse_text("{$eth} {$ethC->NICNAME} {{$iptable}}");
    $new = $tpl->javascript_parse_text("{new_rule}");
    $rulename = $tpl->javascript_parse_text("{rulename}");
    $enabled = $tpl->javascript_parse_text("{enabled}");
    $type = $tpl->javascript_parse_text("{type}");
    $delete = $tpl->javascript_parse_text("{delete}");
    $apply = $tpl->javascript_parse_text("{apply}");
    $t = time();
    $html = "\n<table class='flexRT{$t}' style='display: none' id='flexRT{$t}' style='width:99%'></table>\n<script>\n\nfunction LoadTable{$t}(){\n\t\$('#flexRT{$t}').flexigrid({\n\turl: '{$page}?rules=yes&eth={$eth}&t={$t}&table={$iptable}',\n\tdataType: 'json',\n\tcolModel : [\n\t\t{display: '&nbsp;', name : 'zOrder', width :20, sortable : true, align: 'center'},\n\t\t{display: '{$rulename}', name : 'rulename', width : 423, sortable : true, align: 'left'},\n\t\t{display: '{$enabled}', name : 'enabled', width : 70, sortable : true, align: 'center'},\n\t\t{display: '{$type}', name : 'accepttype', width : 70, sortable : true, align: 'center'},\n\t\t{display: '&nbsp;', name : 'up', width : 70, sortable : true, align: 'center'},\n\t\t{display: '&nbsp;', name : 'down', width : 70, sortable : true, align: 'center'},\n\t\t{display: '{$delete}', name : 'del', width : 70, sortable : false, align: 'center'},\n\t\n\t],\n\tbuttons : [\n\t\t{name: '{$new}', bclass: 'add', onpress : NewRule{$t}},\n\t\t{name: '{$apply}', bclass: 'Apply', onpress : Apply{$t}},\n\t\t\n\t],\n\tsearchitems : [\n\t\t{display: '{$rulename}', name : 'rulename'},\n\t],\n\tsortname: 'zOrder',\n\tsortorder: 'asc',\n\tusepager: true,\n\ttitle: '{$title}',\n\tuseRp: true,\n\trp: 15,\n\tshowTableToggleBtn: false,\n\twidth: '99%',\n\theight: 550,\n\tsingleSelect: true\n\t\n\t});\n}\nvar xRuleGroupUpDown{$t}= function (obj) {\n\tvar res=obj.responseText;\n\tif(res.length>3){alert(res);return;}\n\t\$('#flexRT{$t}').flexReload();\n\t\n}\n\nfunction RuleGroupUpDown{$t}(ID,direction){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('rule-order', ID);\n\tXHR.appendData('direction', direction);\n\tXHR.appendData('eth', '{$eth}');\n\tXHR.appendData('table', '{$iptable}');\n\tXHR.sendAndLoad('{$page}', 'POST',xRuleGroupUpDown{$t});\n}\n\nfunction DeleteRule{$t}(ID){\n\tif(!confirm('{$delete} '+ID+' ?')){return;}\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('rule-delete', ID);\n\tXHR.sendAndLoad('{$page}', 'POST',xRuleGroupUpDown{$t});\n}\n\nfunction Apply{$t}(){\n\tLoadjs('firehol.progress.php');\n}\n\nfunction ChangEnabled{$t}(ID){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('rule-enable', ID);\n\tXHR.sendAndLoad('{$page}', 'POST',xRuleGroupUpDown{$t});\n}\n\nfunction NewRule{$t}() {\n\tLoadjs('{$page}?ruleid=0&eth={$eth}&t={$t}&table={$iptable}',true);\n}\t\nLoadTable{$t}();\n</script>\n";
    echo $html;
}