function popup() { $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $q = new mysql_squid_builder(); $t = time(); $SquidMikroTikTOS = intval($sock->GET_INFO("SquidMikroTikTOS")); $SquidMikrotikMaskerade = intval($sock->GET_INFO("SquidMikrotikMaskerade")); if ($SquidMikroTikTOS == 0) { $SquidMikroTikTOS = 12; } $ip = new networking(); $interfaces = $ip->Local_interfaces(); $MAIN_INTERFACES = $ip->NETWORK_ALL_INTERFACES(); unset($interfaces["lo"]); $ayDscp = array(0 => '0x00', 8 => '0x20', 10 => '0x28', 12 => '0x30', 14 => '0x38', 16 => '0x40', 18 => '0x48', 20 => '0x50', 22 => '0x58', 24 => '0x60', 26 => '0x68', 28 => '0x70', 30 => '0x78', 32 => '0x80', 34 => '0x88', 36 => '0x90', 38 => '0x98', 40 => '0xA0', 46 => '0xB8', 48 => '0xC0', 56 => '0xE0'); while (list($eth, $none) = each($interfaces)) { if (preg_match("#^gre#", $eth)) { continue; } $nic = new system_nic($eth); $arrayIP[$eth] = "{$nic->IPADDR}"; } $results = $q->QUERY_SQL("SELECT * FROM proxy_ports WHERE MIKROTIK_PORT=1 and enabled=1"); $f[] = "/ip firewall filter add action=reject chain=forward comment=\"Artica: Deny QUIC protocol HTTP/UDP\" dst-address=0.0.0.0 dst-port=80 protocol=udp src-address=0.0.0.0"; $f[] = "/ip firewall nat add action=masquerade chain=srcnat comment=\"Artica: Mandatory masquerade for Proxy\""; while ($ligne = mysql_fetch_assoc($results)) { $ID = $ligne["ID"]; $port = $ligne["port"]; $IPADDR = $arrayIP[$ligne["nic"]]; $MAC = $MAIN_INTERFACES[$ligne["nic"]]["MAC"]; $ALLIP[$IPADDR] = $MAC; $UseSSL = $ligne["UseSSL"]; $f[] = "/queue tree add name=ProxyPort{$port} packet-mark=ProxyCached{$port} parent=global queue=default comment=\"Artica: Full bandwidth for Cached content marked as {$SquidMikroTikTOS} {$ayDscp[$SquidMikroTikTOS]}\""; if ($UseSSL == 0) { $f[] = "/ip firewall mangle add action=mark-routing chain=prerouting comment=\"Artica: HTTP mark ProxyPort{$port}\" dst-port=80 src-mac-address=!{$MAC} new-routing-mark=ProxyPort{$port} passthrough=no protocol=tcp"; } if ($UseSSL == 1) { $f[] = "/ip firewall mangle add action=mark-routing chain=prerouting comment=\"Artica: HTTPS 80 mark ProxyPort{$port}\" dst-port=443 src-mac-address=!{$MAC} new-routing-mark=ProxyPort{$port} passthrough=no protocol=tcp"; } $f[] = "/ip firewall mangle add action=mark-packet chain=forward comment=\"Artica: Marked cached packets from Proxy\" dscp={$SquidMikroTikTOS} new-packet-mark=ProxyPort{$port} passthrough=no"; $f[] = "/ip route add check-gateway=ping distance=1 gateway={$IPADDR} routing-mark=ProxyPort{$port} comment=\"Artica: mark ProxyPort{$port} to proxy gateway\""; if ($SquidMikrotikMaskerade == 0) { if ($UseSSL == 0) { $f[] = "/ip firewall mangle add action=mark-connection chain=prerouting comment=\"Artica: Mark HTTP Connections to Connect{$port}\" dst-port=80 new-connection-mark=Connect{$port} passthrough=no protocol=tcp src-mac-address={$MAC}"; $f[] = "/ip firewall mangle add action=mark-routing chain=prerouting comment=\"Mangle Proxy HTTP to Internet mark Connect{$port}\" connection-mark=Connect{$port} new-routing-mark=ProxyPort{$port} passthrough=no protocol=tcp src-mac-address=!{$MAC} src-port=80"; } if ($UseSSL == 1) { $f[] = "/ip firewall mangle add action=mark-connection chain=prerouting comment=\"Artica: Mark SSL Connections to Connect{$port}\" dst-port=443 new-connection-mark=Connect{$port} passthrough=no protocol=tcp src-mac-address={$MAC}"; $f[] = "/ip firewall mangle add action=mark-routing chain=prerouting comment=\"Mangle Proxy SSL to Internet mark Connect{$port}\" connection-mark=Connect{$port} new-routing-mark=ProxyPort{$port} passthrough=no protocol=tcp src-mac-address=!{$MAC} src-port=443"; } } } while (list($a, $b) = each($ayDscp)) { if ($a == 0) { continue; } $DSCP[$a] = $a; } $description = "<textarea name='category_text'\n\tid='category_text-{$t}' style='height:250px;overflow:auto;font-family:Courier New;width:99%;\n\tfont-size:12px !important'>" . @implode("\n", $f) . "</textarea>"; $html = "\n<div style='font-size:36px'>Mikrotik</div>\n<div style='font-size:18px' class=explain>{mikrotik_cmd_line_explain}</div>\n\t{$description}\t\n\t\t\n<div id='SquidAVParamWCCP' style='width:98%' class=form>\n<table style='width:100%'>\n\t<tr>\n\t\t<td style='font-size:22px' class=legend nowrap>DSCP:</td>\n\t\t<td>" . Field_array_Hash($DSCP, "SquidMikroTikTOS-{$t}", $SquidMikroTikTOS, "style:font-size:22px") . "</td>\n\t\t<td> </td>\n\t</tr>\n\t<tr>\n\t\t<td style='font-size:22px' class=legend nowrap>MASQUERADE:</td>\n\t\t<td>" . Field_checkbox_design("SquidMikrotikMaskerade-{$t}", 1, "{$SquidMikrotikMaskerade}") . "</td>\n\t\t<td> </td>\n\t</tr>\t\n\t\t\n\t<tr>\n\t\t<td colspan=3 align='right'>\n\t\t\t<hr>\n\t\t\t\t" . button("{apply}", "Save{$t}()", 32) . "\n\t\t</td>\n\t</tr>\n\t</table>\n</div>\n<script>\nvar xSave{$t}= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>3){alert(results);}\n\tYahooWin3Hide();\n\tLoadjs('{$page}');\n}\n\nfunction Save{$t}(){\n\tvar XHR = new XHRConnection();\n\tvar SquidMikrotikMaskerade=0;\n\tXHR.appendData('SquidMikroTikTOS',\n\tdocument.getElementById('SquidMikroTikTOS-{$t}').value);\n\tif( document.getElementById('SquidMikrotikMaskerade-{$t}').checked){SquidMikrotikMaskerade=1;}\n\tXHR.appendData('SquidMikrotikMaskerade',SquidMikrotikMaskerade);\n\tXHR.sendAndLoad('{$page}', 'POST',xSave{$t});\n}\n</script>"; echo $tpl->_ENGINE_parse_body($html); }