function page()
{
    $sock = new sockets();
    $page = CurrentPageName();
    $tpl = new templates();
    $MikrotikTransparent = intval($sock->GET_INFO('MikrotikTransparent'));
    $MikrotikHTTPSquidPort = intval($sock->GET_INFO('MikrotikHTTPSquidPort'));
    $MikrotikVirtualIP = $sock->GET_INFO('MikrotikVirtualIP');
    $MikrotikLocalInterface = $sock->GET_INFO('MikrotikLocalInterface');
    $MikrotikNetMask = $sock->GET_INFO('MikrotikNetMask');
    $MikrotikIPAddr = $sock->GET_INFO('MikrotikIPAddr');
    $MikrotikLAN = $sock->GET_INFO('MikrotikLAN');
    $MikrotikSSLTransparent = intval($sock->GET_INFO("MikrotikSSLTransparent"));
    $MikrotikHTTPSSquidPort = intval($sock->GET_INFO("MikrotikHTTPSSquidPort"));
    $ip = new networking();
    $ipsH = $ip->Local_interfaces();
    $t = time();
    if ($MikrotikHTTPSquidPort == 0) {
        $MikrotikHTTPSquidPort = rand(9090, 63000);
    }
    if ($MikrotikHTTPSSquidPort == 0) {
        $MikrotikHTTPSSquidPort = rand(9190, 63000);
    }
    if ($MikrotikVirtualIP == null) {
        $MikrotikVirtualIP = "172.16.24.2";
    }
    if ($MikrotikNetMask == null) {
        $MikrotikNetMask = "255.255.255.252";
    }
    if ($MikrotikIPAddr == null) {
        $MikrotikIPAddr = "172.16.24.1";
    }
    if ($MikrotikLAN == null) {
        $MikrotikLAN = "192.168.1.0/24";
    }
    if ($MikrotikLocalInterface == null) {
        $MikrotikLocalInterface = "eth0";
    }
    $ARRAYBT["{apply}"] = "Apply{$t}";
    $ARRAYBT["{save}"] = "Save{$t}";
    $p = Paragraphe_switch_img("{mikrotik_compliance}", "{mikrotik_compliance_explain}", "MikrotikTransparent", $MikrotikTransparent, null, 760);
    $p2 = Paragraphe_switch_img("{mikrotik_ssl_compliance}", "{mikrotik_ssl_compliance_explain}", "MikrotikSSLTransparent", $MikrotikSSLTransparent, null, 760);
    $html = "\n\t<div style='text-align:right'><img src='img/mikrotik-150.png'></div>\n\t<div style='width:95%;padding:30px' class=form>\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td style='vertical-align:top;width:220px'><div id='mikrotik-ipface'></div></td>\n\t\t<td style='vertical-align:top;width:99%;padding-left:30px'>\n\t\n\t\t\t{$p}{$p2}\n\t\t</td>\n\t</table>\n\t<table style='width:100%'>\n\t" . Field_text_table("MikrotikHTTPSquidPort", "{proxy_listen_port}", $MikrotikHTTPSquidPort, 22, null) . Field_text_table("MikrotikHTTPSSquidPort", "{proxy_listen_port} (SSL)", $MikrotikHTTPSSquidPort, 22, null) . Field_list_table("MikrotikLocalInterface", "{local_interface}", $MikrotikLocalInterface, 22, $ipsH) . Field_ipv4_table("MikrotikVirtualIP", "{local_ip_address}", $MikrotikVirtualIP, 22, "{MikrotikVirtualIP}", null) . Field_text_table("MikrotikNetMask", "{netmask}", $MikrotikNetMask, 22) . Field_ipv4_table("MikrotikIPAddr", "{mikrotik_address}", $MikrotikIPAddr, 22, "{mikrotik_address_explain}") . Field_area_table("MikrotikLAN", "{your_network}", $MikrotikLAN, 22, null) . Field_buttons_table_autonome($ARRAYBT, 32) . "\n\t</table>\n\t<div id='mikrotik-config'></div>\n</div>\n\n\n<script>\n\n\tvar xSave{$t}= function (obj) {\n\t\tvar res=obj.responseText;\n\t\t\n\t\tdocument.getElementById('mikrotik-config').innerHTML=res;\n\n\t}\t\n\t\n\t\n\t\n\t\n\n\n\tfunction Save{$t}(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('MikrotikSSLTransparent',document.getElementById('MikrotikSSLTransparent').value);\n\t\tXHR.appendData('MikrotikLocalInterface',document.getElementById('MikrotikLocalInterface').value);\n\t\tXHR.appendData('MikrotikTransparent',document.getElementById('MikrotikTransparent').value);\n\t\tXHR.appendData('MikrotikHTTPSquidPort',document.getElementById('MikrotikHTTPSquidPort').value);\n\t\tXHR.appendData('MikrotikHTTPSSquidPort',document.getElementById('MikrotikHTTPSSquidPort').value);\n\t\tXHR.appendData('MikrotikVirtualIP',document.getElementById('MikrotikVirtualIP').value);\n\t\tXHR.appendData('MikrotikNetMask',document.getElementById('MikrotikNetMask').value);\n\t\tXHR.appendData('MikrotikIPAddr',document.getElementById('MikrotikIPAddr').value);\n\t\tXHR.appendData('MikrotikLAN',document.getElementById('MikrotikLAN').value);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xSave{$t});\t\n\t}\n\t\nfunction Apply{$t}(){\t\n\tSave{$t}();\n\tLoadjs('squid.compile.progress.php?restart=yes&ask=yes');\n}\n\t\nSave{$t}();\nLoadAjax('mikrotik-ipface','{$page}?mikrotik-ipface=yes');\n</script>\t\t\t\t\t\n\t\n";
    echo $tpl->_ENGINE_parse_body($html);
}
function item_popup()
{
    $ID = $_GET["ID"];
    $q = new mysql_squid_builder();
    $title = "{new_item}";
    $bt = "{add}";
    $t = time();
    $tpl = new templates();
    $page = CurrentPageName();
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM nginx_exploits_groups WHERE ID='{$_GET["groupid"]}'"));
    $groupname = $ligne["groupname"];
    $ligne["enabled"] = 1;
    if ($ID > 0) {
        $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM nginx_exploits_items WHERE ID='{$ID}'"));
        $bt = "{apply}";
        $title = "{$groupname}::{{$ligne["token"]}}";
    }
    $array["http_user_agent"] = "{http_user_agent}";
    $array["query_string"] = "{query_string}";
    $html[] = "<div style='width:98%' class=form>";
    $html[] = "<table style='width:100%'>";
    $html[] = "<tr style='height:75px'><td colspan=2 style='font-size:36px;margin-bottom:40px'>{$title}</td></tr>";
    $html[] = Field_checkbox_table("enabled-{$t}", "{enabled}", $ligne["enabled"], 26);
    $html[] = Field_checkbox_table("reverse-{$t}", "{reverse}", $ligne["reverse"], 26);
    $html[] = Field_list_table("token-{$t}", "{token}", $ligne["token"], 26, $array);
    $html[] = Field_area_table("pattern-{$t}", "{pattern}", $ligne["pattern"], 26, null, 200);
    $html[] = Field_button_table_autonome($bt, "ItemSubmit{$t}", 30);
    $html[] = "</table>";
    $html[] = "</div>\n\t<script>\nvar xItemSubmit{$t}= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>3){alert(results);return;}\n\t\$('#NGINX_ANTI_EXPLOITS').flexReload();\n\t\$('#NGINX_ITEMS_SECTION_{$_GET["groupid"]}').flexReload();\n\tvar ID={$ID};\n\tif(ID==0){ YahooWin6Hide();}\n}\n\t\n\t\nfunction ItemSubmit{$t}(){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('edititem','{$ID}');\n\tXHR.appendData('groupid','{$_GET["groupid"]}');\n\tXHR.appendData('pattern',encodeURIComponent(document.getElementById('pattern-{$t}').value));\n\tXHR.appendData('token',document.getElementById('token-{$t}').value);\n\tif(document.getElementById('reverse-{$t}').checked){ XHR.appendData('reverse',1); }else{ XHR.appendData('reverse',0); }\n\tXHR.sendAndLoad('{$page}', 'POST',xItemSubmit{$t});\n}\n</script>";
    echo $tpl->_ENGINE_parse_body(@implode("\n", $html));
}
function websites_popup_webserver_replace_popup()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $servername = $_GET["servername"];
    $q = new mysql_squid_builder();
    $title = "{new_rule}";
    $bt = "{add}";
    $ID = intval($_GET["replaceid"]);
    $boot = new boostrap_form();
    $sock = new sockets();
    $servername = $_GET["servername"];
    $t = time();
    $fields_size = 22;
    if ($ID > 0) {
        $q = new mysql_squid_builder();
        $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM nginx_replace_www WHERE ID='{$ID}'"));
        $bt = "{apply}";
        $title = "{$ligne["rulename"]}";
        $ligne["stringtosearch"] = stripslashes($ligne["stringtosearch"]);
        $ligne["replaceby"] = stripslashes($ligne["replaceby"]);
        $servername = $ligne["servername"];
    }
    if ($ligne["tokens"] == null) {
        $ligne["tokens"] = "gir";
    }
    if ($ligne["rulename"] == null) {
        $ligne["rulename"] = time();
    }
    $html[] = "<div style='width:98%' class=form><div style='font-size:30px;margin-bottom:20px'>{$title}</div>\n\t<div class=explain style='font-size:18px'>{nginx_subst_explain}</div>";
    $html[] = "<table style='width:100%'>";
    $html[] = Field_text_table("rulename-{$t}", "{rulename}", $ligne["rulename"], $fields_size, null, 450);
    $html[] = Field_text_table("zorder-{$t}", "{order}", intval($ligne["zorder"]), $fields_size, null, 110);
    $html[] = Field_area_table("stringtosearch-{$t}", "{search}", $ligne["stringtosearch"], $fields_size, null, 145);
    $html[] = Field_checkbox_table("AsRegex-{$t}", "{regex}", $ligne["AsRegex"], $fields_size, "{replace_regex_explain}");
    $html[] = Field_area_table("replaceby-{$t}", "{replace}", $ligne["replaceby"], $fields_size, null, 145);
    $html[] = Field_text_table("tokens-{$t}", "{flags}", $ligne["tokens"], $fields_size, null);
    $html[] = Field_button_table_autonome($bt, "Submit{$t}", 30);
    $html[] = "</table>";
    $html[] = "</div>\n<script>\n\tvar xSubmit{$t}= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>3){alert(results);}\n\t\$('#NGINX_MAIN_TABLE').flexReload();\n\t\$('#NGINX_REPLACE_RULES').flexReload();\n\tvar ID={$ID}\n\tif(ID==0){ YahooWin3Hide();}\n\t\n}\n\t\n\t\nfunction Submit{$t}(){\n\tvar AsRegex=0\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('replaceid','{$ID}');\n\tif(document.getElementById('AsRegex-{$t}').checked){AsRegex=1;}\n\tXHR.appendData('servername','{$servername}');\n\tXHR.appendData('rulename',encodeURIComponent(document.getElementById('rulename-{$t}').value));\n\tXHR.appendData('zorder',document.getElementById('zorder-{$t}').value);\n\tXHR.appendData('stringtosearch',encodeURIComponent(document.getElementById('stringtosearch-{$t}').value));\n\tXHR.appendData('replaceby',encodeURIComponent(document.getElementById('replaceby-{$t}').value));\n\tXHR.appendData('AsRegex',AsRegex);\n\tXHR.appendData('tokens',document.getElementById('tokens-{$t}').value);\n\tXHR.sendAndLoad('{$page}', 'POST',xSubmit{$t});\n}\n</script>\n\t\n\t";
    echo $tpl->_ENGINE_parse_body(@implode("\n", $html));
}