function popup() { $ID = $_GET["ID"]; $page = CurrentPageName(); $tpl = new templates(); $t = time(); $q = new mysql(); if (!$q->FIELD_EXISTS("squid_parents", "WanProxyMemory", "artica_backup")) { $q->QUERY_SQL("ALTER TABLE `squid_parents` ADD `WanProxyMemory` SMALLINT(10) NOT NULL DEFAULT '256'", "artica_backup"); if (!$q->ok) { echo $q->mysql_error . "\n"; } } if (!$q->FIELD_EXISTS("squid_parents", "WanProxyCache", "artica_backup")) { $q->QUERY_SQL("ALTER TABLE `squid_parents` ADD `WanProxyCache` SMALLINT(10) NOT NULL DEFAULT '1'", "artica_backup"); if (!$q->ok) { echo $q->mysql_error . "\n"; } } $sql = "SELECT * FROM squid_parents WHERE ID={$ID}"; $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); if (!$q->ok) { echo $q->mysql_error_html(); } $html = "\n<div style='width:98%' class=form>\n<table style='width:100%'>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{memory_cache} (MB):</td>\n\t\t<td style='font-size:18px'>" . field_text("WanProxyMemory-{$t}", $ligne["WanProxyMemory"], "font-size:20px;width:120px") . "</td>\n\t\t<td> </td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{caches_on_disk} (GB):</td>\n\t\t<td style='font-size:18px'>" . field_text("WanProxyCache-{$t}", $ligne["WanProxyCache"], "font-size:20px;width:120px") . "</td>\n\t\t<td> </td>\n\t</tr>\t\t\t\t\n\t\n\t\n<tr>\n\t<td colspan=2 align='right'><hr>" . button("{apply}", "Save{$t}()", 32) . "</td>\n</tr>\n</table>\n</div>\n<script>\nvar xSave{$t}= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>3){ alert(results); return; }\n\tRefreshTab('main_proxy_listen_ports');\n}\n\nfunction Save{$t}(){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('ID','{$ID}');\n\tXHR.appendData('WanProxyMemory',document.getElementById('WanProxyMemory-{$t}').value);\n\tXHR.appendData('WanProxyCache',document.getElementById('WanProxyCache-{$t}').value);\n\tXHR.sendAndLoad('{$page}', 'POST',xSave{$t});\n}\n</script>\n"; echo $tpl->_ENGINE_parse_body($html); }
function page() { $tpl = new templates(); $page = CurrentPageName(); $q = new mysql(); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM relay_host WHERE hostname='{$_GET["hostname"]}'", "artica_backup")); if (!$q->ok) { echo $q->mysql_error_html(); } $t = time(); if (!is_numeric($ligne["relay_port"])) { $ligne["relay_port"] = 25; } $form = "<div style='font-size:30px'>{relayhost}</div>\n\t<div class=explain style='font-size:18px'>{relayhost_text}</div>\n\t<div style='width:98%' class=form>\n\t<table style='width:100%'>\n\t\t</tr>\n\t\t\t<td align='right' nowrap class=legend style='font-size:22px'>{enabled}:</strong></td>\n\t\t\t<td style='font-size:12px'>" . Field_checkbox_design("enabled-{$t}", 1, $ligne["enabled"], "CheckEnabled{$t}()") . "</td>\n\t\t</tr>\n\t\t\t\t\t\t\t\t\n\t\t<tr>\n\t\t\t<td align='right' nowrap class=legend style='font-size:22px'>{relay_address}:</strong></td>\n\t\t\t<td style='font-size:22px'>" . Field_text("relay_address-{$t}", $ligne["relay"], "font-size:22px;padding:3px") . "</td>\n\t\t</tr>\n\t\t</tr>\n\t\t\t<td align='right' nowrap class=legend style='font-size:22px'>{smtp_port}:</strong></td>\n\t\t\t<td style='font-size:12px'>" . Field_text("relay_port-{$t}", $ligne["relay_port"], "font-size:22px;padding:3px;width:110px") . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style='font-size:22px' class=legend>{MX_lookups}</td>\n\t\t\t<td>" . Field_checkbox_design("lookups-{$t}", 1, $ligne["lookups"]) . "</td>\n\t\t</tr>\t\t\t\t\t\n\t\t</tr>\n\t\t\t<td align='right' nowrap class=legend style='font-size:22px'>{authenticate}:</strong></td>\n\t\t\t<td style='font-size:12px'>" . Field_checkbox_design("enabledauth-{$t}", 1, $ligne["enabledauth"], "Checkenabledauth{$t}()") . "</td>\n\t\t</tr>\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t<tR>\n\t\t\t<td align='right' nowrap class=legend style='font-size:22px'>{username}:</strong></td>\n\t\t\t<td style='font-size:12px'>" . Field_text("relay_username-{$t}", $ligne["username"], "font-size:22px;padding:3px") . "</td>\n\t\t</tr>\n\t<tr>\n\t\t<td align='right' nowrap class=legend style='font-size:22px'>{password}:</strong></td>\n\t\t<td style='font-size:12px'>" . Field_password("relay_password-{$t}", $ligne["password"], "font-size:22px;padding:3px;") . "</td>\n\t</tr>\n\t<tr>\n\t<td align='right' colspan=2 align='right' style='font-size:22px'>\n\t\t\t\t<p> </p>" . button("{apply}", "Loadjs('postfix.sender.routing.progress.php?hostname={$_GET["hostname"]}')", 40) . " | " . button("{save}", "PostfixSaveRelayHost{$t}()", 40) . "</td>\n\t</tr>\n\t</table>\n\t</div>\n<script>\nvar X_PostfixSaveRelayHost{$t}= function (obj) {\n\tvar results=trim(obj.responseText);\n\tif(results.length>2){alert(results);}\n}\nfunction PostfixSaveRelayHost{$t}(){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('hostname','{$_GET["hostname"]}');\n\tXHR.appendData('relay_address',document.getElementById('relay_address-{$t}').value);\n\tXHR.appendData('relay_username',document.getElementById('relay_username-{$t}').value);\n\t\n\t\n\t\n\t\n\tXHR.appendData('relay_password',encodeURIComponent(document.getElementById('relay_password-{$t}').value));\n\tif(document.getElementById('enabled-{$t}').checked){XHR.appendData('enabled','1');}else{XHR.appendData('enabled','0');}\n\tif(document.getElementById('enabledauth-{$t}').checked){XHR.appendData('enabledauth','1');}else{XHR.appendData('enabledauth','0');}\n\tif(document.getElementById('lookups-{$t}').checked){XHR.appendData('lookups','1');}else{XHR.appendData('lookups','0');}\n\t\n\tXHR.appendData('relay_port',document.getElementById('relay_port-{$t}').value);\n\tXHR.sendAndLoad('{$page}', 'POST',X_PostfixSaveRelayHost{$t});\n\t\n\t}\nfunction CheckEnabled{$t}(){\n\tdocument.getElementById('relay_address-{$t}').disabled=true;\n\tdocument.getElementById('relay_port-{$t}').disabled=true;\n\tdocument.getElementById('relay_username-{$t}').disabled=true;\n\tdocument.getElementById('relay_password-{$t}').disabled=true;\n\tdocument.getElementById('lookups-{$t}').disabled=true;\n\n\tif(document.getElementById('enabled-{$t}').checked){\n\t\tdocument.getElementById('relay_address-{$t}').disabled=false;\n\t\tdocument.getElementById('relay_port-{$t}').disabled=false;\n\t\tdocument.getElementById('relay_username-{$t}').disabled=false;\n\t\tdocument.getElementById('relay_password-{$t}').disabled=false;\n\t\tdocument.getElementById('lookups-{$t}').disabled=false;\n\t}\n\tCheckenabledauth{$t}();\n}\n\nfunction Checkenabledauth{$t}(){\n\tdocument.getElementById('relay_username-{$t}').disabled=true;\n\tdocument.getElementById('relay_password-{$t}').disabled=true;\n\tif(!document.getElementById('enabled-{$t}').checked){return;}\n\tif(document.getElementById('enabledauth-{$t}').checked){\n\t\tdocument.getElementById('relay_username-{$t}').disabled=false;\n\t\tdocument.getElementById('relay_password-{$t}').disabled=false;\n\t}\n}\n\nCheckEnabled{$t}();\n\n</script>"; echo $tpl->_ENGINE_parse_body("{$form}"); }
function smtpd_client_restrictions_popup() { $ou = $_GET["ou"]; $sock = new sockets(); $users = new usersMenus(); $q = new mysql(); if (!$q->TABLE_EXISTS("smptd_client_access", "artica_backup")) { $q->check_storage_table(true); } $sql = "SELECT `configuration` FROM smptd_client_access WHERE `ou`='{$ou}'"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); if (!$q->ok) { echo $q->mysql_error_html(); die; } $MAIN = unserialize(base64_decode($ligne["configuration"])); $reject_unknown_client_hostname = $MAIN['reject_unknown_client_hostname']; $reject_unknown_reverse_client_hostname = $MAIN['reject_unknown_reverse_client_hostname']; $reject_unknown_sender_domain = $MAIN['reject_unknown_sender_domain']; $reject_invalid_hostname = $MAIN['reject_invalid_hostname']; $reject_non_fqdn_sender = $MAIN['reject_non_fqdn_sender']; $disable_vrfy_command = $MAIN['disable_vrfy_command']; $enforce_helo_restrictions = intval($MAIN['enforce_helo_restrictions']); if (!$users->POSTFIX_PCRE_COMPLIANCE) { $EnableGenericrDNSClients = 0; $EnableGenericrDNSClientsDisabled = 1; $EnableGenericrDNSClientsDisabledText = "<br><i><span style='color:#d32d2d;font-size:11px'>{EnableGenericrDNSClientsDisabledText}</span></i>"; } $t = time(); $page = CurrentPageName(); $html = "\n\n\n\n\t\n\t<div style='font-size:30px;margin-bottom:50px'>{safety_standards}</div>\n\t<div class=explain style='font-size:18px'>{smtpd_client_restrictions_text}</div>\n\t<div id='smtpd_client_restrictions_div' style='width:98%' class=form>\n\t" . Paragraphe_switch_img("{reject_unknown_client_hostname}", "{reject_unknown_client_hostname_text}", "reject_unknown_client_hostname-{$t}", $reject_unknown_client_hostname, null, 1400) . "\n\t" . Paragraphe_switch_img("{reject_unknown_reverse_client_hostname}", "{reject_unknown_reverse_client_hostname_text}", "reject_unknown_reverse_client_hostname-{$t}", $reject_unknown_reverse_client_hostname, null, 1400) . "\n\t" . Paragraphe_switch_img("{reject_unknown_sender_domain}", "{reject_unknown_sender_domain_text}", "reject_unknown_sender_domain-{$t}", $reject_unknown_sender_domain, null, 1400) . "\n\t" . Paragraphe_switch_img("{reject_invalid_hostname}", "{reject_invalid_hostname_text}", "reject_invalid_hostname-{$t}", $reject_invalid_hostname, null, 1400) . "\n\t" . Paragraphe_switch_img("{reject_non_fqdn_sender}", "{reject_non_fqdn_sender_text}", "reject_non_fqdn_sender-{$t}", $reject_non_fqdn_sender, null, 1400) . "\n\t</table>\n\t</div>\n\n\t<div style='width:100%;text-align:right'><hr>\n\t" . button("{apply}", "Save{$t}()", 45) . "\n\t\n\t</div>\n<script>\nvar xSave{$t}= function (obj) {\n\tvar tempvalue=obj.responseText;\n\tif(tempvalue.length>3){alert(tempvalue);}\n\t\n}\n\t\nfunction Save{$t}(){\n\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('ou','{$ou}');\n\t\tXHR.appendData('reject_unknown_client_hostname',document.getElementById('reject_unknown_client_hostname-{$t}').value);\n\t\tXHR.appendData('reject_unknown_reverse_client_hostname',document.getElementById('reject_unknown_reverse_client_hostname-{$t}').value);\n\t\tXHR.appendData('reject_unknown_sender_domain',document.getElementById('reject_unknown_sender_domain-{$t}').value);\n\t\tXHR.appendData('reject_invalid_hostname',document.getElementById('reject_invalid_hostname-{$t}').value);\n\t\tXHR.appendData('reject_non_fqdn_sender',document.getElementById('reject_non_fqdn_sender-{$t}').value);\n\t\tXHR.sendAndLoad('{$page}', 'GET',xSave{$t});\t\n\t}\n</script>\t\t\t\n\t"; //smtpd_client_connection_rate_limit = 100 //smtpd_client_recipient_rate_limit = 20 $tpl = new templates(); echo $tpl->_ENGINE_parse_body($html, "postfix.index.php"); }
function table() { $page = CurrentPageName(); $tpl = new templates(); $method = $tpl->_ENGINE_parse_body("{method}"); $type = $tpl->_ENGINE_parse_body("{action}"); $pattern = $tpl->_ENGINE_parse_body("{pattern}"); $description = $tpl->_ENGINE_parse_body("{description}"); $hostname = $_GET["hostname"]; $add = $tpl->_ENGINE_parse_body("{add}"); $rule = $tpl->_ENGINE_parse_body("{rule}"); $about = $tpl->javascript_parse_text("{about2}"); $blacklist = $tpl->javascript_parse_text("{blacklist}"); $whitelist = $tpl->javascript_parse_text("{whitelist}"); $discard = $tpl->javascript_parse_text("{discard}"); $all = $tpl->javascript_parse_text("{all}"); $zDate = $tpl->javascript_parse_text("{zDate}"); $q = new mysql(); if (!$q->FIELD_EXISTS("milterregex_acls", "reverse", "artica_backup")) { $sql = "ALTER TABLE `milterregex_acls` ADD `reverse` smallint(1) NOT NULL,ADD INDEX ( `reverse` )"; $q->QUERY_SQL($sql, 'artica_backup'); } if (!$q->FIELD_EXISTS("milterregex_acls", "extended", "artica_backup")) { $sql = "ALTER TABLE `milterregex_acls` ADD `extended` smallint(1) NOT NULL,ADD INDEX ( `extended` )"; $q->QUERY_SQL($sql, 'artica_backup'); } if (!$q->TABLE_EXISTS('milterregex_acls', 'artica_backup')) { $sql = "CREATE TABLE IF NOT EXISTS `milterregex_acls` (\n\t\t\t `zmd5` varchar(90) NOT NULL PRIMARY KEY,\n\t\t\t `instance` varchar(128) NOT NULL,\n\t\t\t `method` varchar(50) NOT NULL,\n\t\t\t `type` varchar(50) NOT NULL,\n\t\t\t `enabled` smallint(1) NOT NULL,\n\t\t\t `pattern` varchar(256) NOT NULL,\n\t\t\t `description` varchar(255) NOT NULL,\n\t\t\t `reverse` smallint(1) NOT NULL,\n\t\t\t `extended` smallint(1) NOT NULL,\n\t\t\t `zDate` DATETIME,\n\t\t\t KEY `instance` (`instance`),\n\t\t\t KEY `enabled` (`enabled`),\n\t\t\t KEY `reverse` (`reverse`),\n\t\t\t KEY `extended` (`extended`),\n\t\t\t KEY `zDate` (`zDate`),\n\t\t\t KEY `method` (`method`),\n\t\t\t KEY `type` (`type`),\n\t\t\t KEY `pattern` (`pattern`)\n\t\t\t)"; $q->QUERY_SQL($sql, 'artica_backup'); if (!$q->ok) { echo $q->mysql_error_html(); } } if ($q->COUNT_ROWS("milterregex_acls", "artica_backup") == 0) { $sock = new sockets(); $sock->getFrameWork("milter-regex.php?defaults=yes"); } $t = time(); if (trim($hostname) == null) { $hostname = "master"; $_GET["hostname"] = "master"; } $about_text = $tpl->javascript_parse_text("{acl_text}"); $POSTFIX_MULTI_INSTANCE_INFOS = $tpl->javascript_parse_text("{milter_regex}: {acls}"); $html = "\n\t<table class='MILTERREGEX_TABLE' style='display: none' id='MILTERREGEX_TABLE' style='width:99%'></table>\n\t\n\t<script>\n\tvar idtmp='';\n\t\$(document).ready(function(){\n\t\$('#MILTERREGEX_TABLE').flexigrid({\n\turl: '{$page}?acl-table-list=yes&hostname={$hostname}&t={$t}&ou={$_GET["ou"]}',\n\tdataType: 'json',\n\tcolModel : [\n\t\n\t{display: '<span style=font-size:18px>{$zDate}</span>', name : 'zDate', width :144, sortable : true, align: 'left'},\n\t{display: '<span style=font-size:18px>{$type}</span>', name : 'type', width : 174, sortable : true, align: 'left'},\n\t{display: '<span style=font-size:18px>{$method}</span>', name : 'method', width :145, sortable : true, align: 'left'},\n\t{display: '<span style=font-size:18px>{$pattern}</span>', name : 'pattern', width : 419, sortable : true, align: 'left'},\n\t{display: '<span style=font-size:18px>{$description}</span>', name : 'description', width : 424, sortable : false, align: 'left'},\n\t{display: ' ', name : 'delete', width : 50, sortable : false, align: 'center'},\n\t],\n\tbuttons : [\n\t{name: '<strong style=font-size:18px>{$add}</strong>', bclass: 'add', onpress : addcallistrule{$t}},\n\t{separator: true},\n\t{name: '<strong style=font-size:18px>{$blacklist}</strong>', bclass: 'Search', onpress : blacklist{$t}},\n\t{name: '<strong style=font-size:18px>{$whitelist}</strong>', bclass: 'Search', onpress : whitelist{$t}},\n\t{name: '<strong style=font-size:18px>{$discard}</strong>', bclass: 'Search', onpress : discard{$t}},\n\t\n\t{name: '<strong style=font-size:18px>{$all}</strong>', bclass: 'Search', onpress : all{$t}},\n\t\n\t],\n\tsearchitems : [\n\t{display: '{$pattern}', name : 'pattern'},\n\t{display: '{$description}', name : 'description'},\n\t{display: '{$method}', name : 'method'},\n\t{display: '{$type}', name : 'type'},\n\t\n\t\n\t],\n\tsortname: 'zDate',\n\tsortorder: 'desc',\n\tusepager: true,\n\ttitle: '<span style=font-size:30px>{$POSTFIX_MULTI_INSTANCE_INFOS}</span>',\n\tuseRp: true,\n\trp: 20,\n\tshowTableToggleBtn: true,\n\twidth: '99%',\n\theight: 550,\n\tsingleSelect: true\n\t\n\t});\n\t});\n\t\n\tfunction about{$t}(){\n\talert('{$about_text}');\n\t}\n\t\n\tfunction addcallistrule{$t}(){\n\t\tLoadjs('{$page}?acl-js=yes&zmd5=');\n\t}\n\t\n\tfunction LoadMilterGreyListAcl{$t}(index){\n\tYahooWin4(750,'{$page}?add_acl=true&num='+index+'&hostname={$_GET["hostname"]}&ou={$_GET["ou"]}','{$acl} {$rule} '+index);\n\t}\n\t\n\tfunction blacklist{$t}(){\n\t\$('#MILTERREGEX_TABLE').flexOptions({url: '{$page}?acl-table-list=yes&hostname={$hostname}&t={$t}&ou={$_GET["ou"]}&filterby=reject'}).flexReload();\n\t}\n\tfunction whitelist{$t}(){\n\t\$('#MILTERREGEX_TABLE').flexOptions({url: '{$page}?acl-table-list=yes&hostname={$hostname}&t={$t}&ou={$_GET["ou"]}&filterby=accept'}).flexReload();\n\t}\n\tfunction discard{$t}(){\n\t\$('#MILTERREGEX_TABLE').flexOptions({url: '{$page}?acl-table-list=yes&hostname={$hostname}&t={$t}&ou={$_GET["ou"]}&filterby=discard'}).flexReload();\n\t}\n\tfunction all{$t}(){\n\t\$('#MILTERREGEX_TABLE').flexOptions({url: '{$page}?acl-table-list=yes&hostname={$hostname}&t={$t}&ou={$_GET["ou"]}&filterby='}).flexReload();\n\t}\n\t\n\tvar X_DeleteAclIDNewFunc= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>1){alert(results);return;}\n\t\$('#row'+idtmp).remove();\n\t}\n\t\n\tfunction DeleteAclIDNewFunc(ID){\n\tidtmp=ID;\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('DeleteAclID',ID);\n\tXHR.appendData('hostname','{$hostname}');\n\tXHR.sendAndLoad('{$page}', 'POST',X_DeleteAclIDNewFunc);\n\t}\n\t\n\t\n\t</script>\n\t\n\t"; echo $html; }
function search() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql(); $database = "artica_backup"; $search = '%'; $table = "nics"; $page = 1; $ORDER = null; $allow = null; $total = 0; if ($q->COUNT_ROWS($table, $database) == 0) { json_error_show("no data"); } $searchstring = string_to_flexquery(); if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } $table = "(SELECT * FROM nics WHERE isFW=1) as t"; $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database)); $total = $ligne["TCOUNT"]; if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM {$table} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql, $database); if (!$q->ok) { json_error_show($q->mysql_error_html(), 1); } if (mysql_num_rows($results) == 0) { json_error_show("no data {$sql}"); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { json_error_show($q->mysql_error); } $fontsize = 18; $firehole = new firehol(); while ($ligne = mysql_fetch_assoc($results)) { $mouse = "OnMouseOver=\"this.style.cursor='pointer'\" OnMouseOut=\"this.style.cursor='default'\""; $linkstyle = "style='text-decoration:underline'"; $Interface = $ligne["Interface"]; $NICNAME = $ligne["NICNAME"]; $netzone = $ligne["netzone"]; $CountDelocal = $firehole->interface_count_local_services($Interface); $CountServices = $firehole->interface_count_allowed_services($Interface); $js = "Loadjs('system.nic.edit.php?nic={$Interface}')"; $link = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\" style='font-size:{$fontsize}px;text-decoration:underline'>"; $data['rows'][] = array('id' => $ligne["Interface"], 'cell' => array("<img src='img/folder-network-32.png' valign='middle'>", "<span style='font-size:18px'>{$link}{$Interface}</a></span>", "<span style='font-size:18px'>{$link}{$NICNAME}</a></span>", "<span style='font-size:18px'>{$netzone}</span>", "<span style='font-size:18px'>{$CountDelocal}</span>", "<span style='font-size:18px'>{$CountServices}</span>")); } echo json_encode($data); }
function containers_from_bridge($eth){ $q=new mysql(); $sql="SELECT `nics`.BridgedTo,`nics`.QOS,`qos_containers`.* FROM `nics`,`qos_containers` WHERE `qos_containers`.`eth`=`nics`.`Interface` AND `nics`.`QOS`=1 AND `nics`.`BridgedTo`='$eth' AND `qos_containers`.`enabled`=1 ORDER BY `qos_containers`.prio"; $results=$q->QUERY_SQL($sql,"artica_backup"); if(!$q->ok){echo $q->mysql_error_html();} $HASH[0]="{select}"; while ($ligne = mysql_fetch_assoc($results)) { $HASH[$ligne["ID"]]=$ligne["name"]." {$ligne["rate"]}{$ligne["rate_unit"]}/{$ligne["ceil"]}{$ligne["ceil_unit"]}"; } return $HASH; }
function popup() { $q = new mysql(); $sock = new sockets(); $tpl = new templates(); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT max_size FROM squid_caches_center WHERE `enabled`=1 AND `remove`=0 ORDER BY max_size DESC", "artica_backup")); $max_size = $ligne["max_size"]; $ssl_text = null; $TP = false; $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(cache_size) as SumOfCache FROM squid_caches_center WHERE `enabled`=1 AND `remove`=0", "artica_backup")); if (!$q->ok) { echo $q->mysql_error_html(); } $SumOfCache = $ligne["SumOfCache"] * 1024; $SumOfCacheExplain = $tpl->_ENGINE_parse_body("{SumOfCacheExplain}"); $SumOfCacheExplain = str_replace("%s", FormatBytes($SumOfCache), $SumOfCacheExplain) . "<br><br>"; $SquidDNSUseSystem = intval($sock->GET_INFO("SquidDNSUseSystem")); $SquidDNSUseLocalDNSService = intval($sock->GET_INFO("SquidDNSUseLocalDNSService")); $SquidCacheLevel = $sock->GET_INFO("SquidCacheLevel"); $q = new mysql_squid_builder(); $sql = "SELECT * FROM proxy_ports WHERE enabled=1"; $results = $q->QUERY_SQL($sql); while ($ligne = mysql_fetch_assoc($results)) { if (intval($ligne["ICP"]) == 1) { continue; } if (intval($ligne["Parent"]) == 1) { continue; } if (intval($ligne["FTP_TRANSPARENT"]) == 1) { continue; } if (intval($ligne["SOCKS"]) == 1) { continue; } if (intval($ligne["ProxyProtocol"]) == 1) { continue; } if (intval($ligne["FTP"]) == 1) { continue; } if (intval($ligne["WANPROXY"]) == 1) { continue; } if (intval($ligne["WCCP"]) == 1) { $PORTS_TEXT[] = "{your_cisco_is_able_ports}"; continue; } if (intval($ligne["transparent"]) == 1) { if (!$TP) { $TP = true; $PORTS_TEXT[] = "{your_proxy_transparent_explain}"; } continue; } if (intval($ligne["TProxy"]) == 1) { if (!$TP) { $TP = true; $PORTS_TEXT[] = "{your_proxy_transparent_explain}"; } continue; } if (intval($ligne["is_nat"]) == 1) { $your_proxy_is_nat = $tpl->_ENGINE_parse_body("{your_proxy_is_nat}"); $your_proxy_is_nat = str_replace("%port", $ligne["port"], $your_proxy_is_nat); $PORTS_TEXT[] = $your_proxy_is_nat; continue; } $your_proxy_normal = $tpl->_ENGINE_parse_body("{your_proxy_normal}"); $your_proxy_normal = str_replace("%port", $ligne["port"], $your_proxy_normal); $PORTS_TEXT[] = $your_proxy_normal; if ($ligne["UseSSL"] == 1) { $ssl_text = "<br>{explain_proxy_ssl_cert}"; } } if ($SquidDNSUseSystem == 1) { $resolv = new resolv_conf(); $EnableDNSMASQ = intval($sock->GET_INFO("EnableDNSMASQ")); if ($EnableDNSMASQ == 1) { $dns[] = "127.0.0.1"; $dns[] = $resolv->MainArray["DNS1"]; } else { $dns[] = $resolv->MainArray["DNS1"]; $dns[] = $resolv->MainArray["DNS2"]; } } else { if ($SquidDNSUseLocalDNSService == 1) { $dns[] = "127.0.0.1"; } $q = new mysql_squid_builder(); $results = $q->QUERY_SQL("SELECT * FROM dns_servers ORDER BY zOrder"); while ($ligne = mysql_fetch_assoc($results)) { if ($ligne["dnsserver"] == null) { continue; } $dns[] = $ligne["dnsserver"]; } } $proxy_store_max_files = $tpl->_ENGINE_parse_body("{proxy_store_max_files}"); $proxy_store_max_files = str_replace("%F", FormatBytes($max_size), $proxy_store_max_files) . "<br><br>"; if ($SquidCacheLevel == 0) { $proxy_store_max_files = null; $SumOfCacheExplain = null; } $html = "\n<div style='width:98%' class=form>\n<div style='font-size:30px'>{how_to_use_this_proxy}:</div>\n<div style='font-size:18px;margin:20px'>" . @implode("<br>{or} ", $PORTS_TEXT) . "{$ssl_text}</div>\n<div style='font-size:30px;margin-top:30px'>{performance}:</div>\n<div style='font-size:18px;margin:20px'>{proxy_using_the_dns} " . @implode(" {or} ", $dns) . "</div>\n<div style='font-size:30px;margin-top:30px'>{caching}:</div>\n<div style='font-size:18px;margin:20px'>{$proxy_store_max_files}\n{$SumOfCacheExplain}\n{SquidCacheLevel{$SquidCacheLevel}}</div>\t\t\n</div>\t\n"; echo $tpl->_ENGINE_parse_body($html); }
function items_popup() { $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $users = new usersMenus(); $max_size_explain = null; $ID = intval($_GET["ID"]); $DisableAnyCache = intval($sock->GET_INFO("DisableAnyCache")); $SquidForceCacheTypes = $sock->GET_INFO("SquidForceCacheTypes"); if ($SquidForceCacheTypes == null) { $SquidForceCacheTypes = "aufs"; } if ($DisableAnyCache == 1) { FATAL_ERROR_SHOW_128("{DisableAnyCache_enabled_warning}"); return; } $cpunumber = $users->CPU_NUMBER - 1; if ($cpunumber < 1) { $cpunumber = 1; } for ($i = 1; $i < $cpunumber + 1; $i++) { $CPUZ[$i] = "{process} {$i}"; } $t = time(); $bt = "{add}"; $cpu = 1; $cachename = time(); $squid = new squidbee(); if (preg_match("#([0-9]+)#", $squid->global_conf_array["minimum_object_size"], $re)) { $minimum_object_size = $re[1]; if (preg_match("#([A-Z]+)#", $squid->global_conf_array["minimum_object_size"], $re)) { $minimum_object_size_unit = $re[1]; } if ($minimum_object_size_unit == null) { $minimum_object_size_unit = "KB"; } if (!is_numeric($minimum_object_size)) { $minimum_object_size = 0; } if ($minimum_object_size_unit == "MB") { $minimum_object_size = $minimum_object_size * 1024; } } if (preg_match("#([0-9]+)#", $squid->global_conf_array["maximum_object_size"], $re)) { $maximum_object_size = $re[1]; if (preg_match("#([A-Z]+)#", $squid->global_conf_array["maximum_object_size"], $re)) { $maximum_object_size_unit = $re[1]; } if ($maximum_object_size_unit == null) { $maximum_object_size_unit = "KB"; } if ($maximum_object_size_unit == "KB") { if ($maximum_object_size < 4096) { $maximum_object_size = 4096; } } if ($maximum_object_size_unit == "MB") { if ($maximum_object_size < 4) { $maximum_object_size = 4; } $maximum_object_size = $maximum_object_size * 1024; } } $min_size = $minimum_object_size; $max_size = $maximum_object_size; if ($ID > 0) { $q = new mysql(); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM squid_caches_center WHERE ID='{$ID}'", "artica_backup")); if (!$q->ok) { echo $q->mysql_error_html(); } $cachename = $ligne["cachename"]; $cache_directory = $ligne["cache_dir"]; $cache_type = $ligne["cache_type"]; $cache_size = $ligne["cache_size"]; $cache_dir_level1 = $ligne["cache_dir_level1"]; $cache_dir_level2 = $ligne["cache_dir_level2"]; $cache_type = $ligne["cache_type"]; $enabled = $ligne["enabled"]; $cachename = $ligne["cachename"]; $cpu = $ligne["cpu"]; $min_size = intval($ligne["min_size"]); $max_size = intval($ligne["max_size"]); $bt = "{apply}"; } if ($max_size == 0) { $max_size_explain = "<u style='font-size:11px'>{default}: {$maximum_object_size} KB</u>"; } //default if ($cache_directory == null) { $cache_directory = "/home/squid/caches/cache-" . time(); } if (!is_numeric($cache_size)) { $cache_size = 5000; } if (!is_numeric($cache_dir_level1)) { $cache_dir_level1 = 16; } if (!is_numeric($cache_dir_level2)) { $cache_dir_level2 = 256; } if (!is_numeric($enabled)) { $enabled = 1; } if ($cache_size < 1) { $cache_size = 5000; } if ($cache_dir_level1 < 16) { $cache_dir_level1 = 16; } if ($cache_dir_level2 < 64) { $cache_dir_level2 = 64; } if ($cache_type == null) { $cache_type = $SquidForceCacheTypes; } $caches_types = unserialize(base64_decode($sock->getFrameWork("squid.php?caches-types=yes"))); $caches_types[null] = '{select}'; $caches_types["tmpfs"] = "{squid_cache_memory}"; $caches_types["Cachenull"] = "{without_cache}"; unset($caches_types["rock"]); $type = $tpl->_ENGINE_parse_body(Field_array_Hash($caches_types, "cache_type-{$t}", $cache_type, "CheckCachesTypes{$t}()", null, 0, "font-size:16px;padding:3px")); $cpus = $tpl->_ENGINE_parse_body(Field_array_Hash($CPUZ, "CPU-{$t}", $cpu, "blur()", null, 0, "font-size:16px;padding:3px")); $browse = button("{browse}...", "Loadjs('SambaBrowse.php?no-shares=yes&field=cache_directory-{$t}')", 16); if ($ID > 0) { $browse = null; $perr = "<p class=text-error>{cannot_modify_a_created_cache}</p>"; } $html = "\n\t<div id='waitcache-{$t}'></div>\n\t<div style='width:98%' class=form>\n\t{$perr}\n\t<table style='width:99%'>\n\t<tr>\n\t\t<td class=legend style='font-size:16px' nowrap>{enabled}:</td>\n\t\t<td style='font-size:16px'>" . Field_checkbox("enabled-{$t}", 1, $enabled, "EnableCheck{$t}()") . "</td>\n\t\t<td> </td>\n\t\t<td> </td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:16px' nowrap>{name}:</td>\n\t\t<td>" . Field_text("cachename-{$t}", $cachename, "width:350px;font-size:16px;padding:3px") . "</td>\n\t\t<td></td>\n\t\t<td> </td>\n\t</tr>\t\n\t\t\t\t\n\t<tr>\n\t\t<td class=legend style='font-size:16px' nowrap>{process}:</td>\n\t\t<td>{$cpus}</td>\n\t\t<td> </td>\n\t\t<td> </td>\n\t</tr>\t\t\t\t\n\t\n\t<tr>\n\t\t<td class=legend style='font-size:16px' nowrap>{directory}:</td>\n\t\t<td>" . Field_text("cache_directory-{$t}", $cache_directory, "width:350px;font-size:16px;padding:3px") . "</td>\n\t\t<td>{$browse}</td>\n\t\t<td> </td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:16px' nowrap>{type}:</td>\n\t\t<td>{$type}</td>\n\t\t<td> </td>\n\t\t<td> </td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:16px' nowrap>{cache_size}:</td>\n\t\t<td style='font-size:16px'>" . Field_text("squid-cache-size-{$t}", $cache_size, "width:60px;font-size:16px;padding:3px") . " MB</td>\n\t\t<td> </td>\n\t\t<td>" . help_icon('{cache_size_text}', false, 'squid.index.php') . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:16px'>{cache_dir_level1}:</td>\n\t\t<td>" . Field_text("cache_dir_level1-{$t}", $cache_dir_level1, 'width:50px;font-size:16px;padding:3px') . "</td>\n\t\t<td> </td>\n\t\t<td>" . help_icon('{cache_dir_level1_text}', false, 'squid.index.php') . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:16px'>{cache_dir_level2}:</td>\n\t\t<td>" . Field_text("cache_dir_level2-{$t}", $cache_dir_level2, 'width:50px;font-size:16px;padding:3px') . "</td>\n\t\t<td> </td>\n\t\t<td>" . help_icon('{cache_dir_level2_text}', false, 'squid.index.php') . "</td>\n\t</tr>\n\t<tr><td colspan=4><hr></td></tr>\n\t\t\t\t\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:16px'>{min_size}:</td>\n\t\t<td width=1% nowrap>" . Field_text("min_size-{$t}", $min_size, 'width:120px;font-size:16px;padding:3px') . "</td>\n\t\t<td style='font-size:16px' width=1% nowrap> KB</td>\n\t\t<td>" . help_icon('{cache_dir_min_size_text}', false, 'squid.index.php') . "</td>\n\t</tr>\t\t\t\t\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:16px'>{max_size}:</td>\n\t\t<td width=1% nowrap>" . Field_text("max_size-{$t}", $max_size, 'width:120px;font-size:16px;padding:3px') . "</td>\n\t\t<td style='font-size:16px' width=1% nowrap> KB {$max_size_explain}</td>\n\t\t<td>" . help_icon('{cache_dir_max_size_text}', false, 'squid.index.php') . "</td>\n\t</tr>\t\t\t\t\n\t\t\t\t\n\t<tr>\n\t\t<td align='right' colspan=4><hr>" . button($bt, "AddNewCacheSave{$t}()", 22) . "</td>\n\t</tr>\n\t</table>\n\t<p> </p>\n\t<div id='CacheTypeExplain-{$t}'></div>\n\t<div style='font-size:12px'><i>{warn_calculate_nothdsize}</i></div>\n\t<script>\nfunction CheckCachesTypes{$t}(){\n\tcachetypes=document.getElementById('cache_type-{$t}').value;\n\tCacheTypeExplain{$t}();\n}\n\nfunction CacheTypeExplain{$t}(){\n\tcachetype=document.getElementById('cache_type-{$t}').value;\n\tLoadAjaxTiny('CacheTypeExplain-{$t}','{$page}?t={$t}&ID={$ID}&CacheTypeExplain='+cachetype);\n}\n\t\nvar x_AddNewCacheSave{$t}= function (obj) {\n\tvar cacheid={$ID};\n\tvar results=obj.responseText;\n\tdocument.getElementById('waitcache-{$t}').innerHTML='';\n\tif(results.length>3){ alert(results); return; }\n\tif(cacheid==0){YahooWin2Hide();}\n\tif(document.getElementById('proxy-store-caches')){\n\t\tLoadAjaxRound('proxy-store-caches','admin.dashboard.proxy.caches.php');\n\t}\n\tif(document.getElementById('flexRT{$_GET["t"]}')){\n\t\t\$('#flexRT{$_GET["t"]}').flexReload();\n\t}\n}\n\t\nfunction AddNewCacheSave{$t}(){\n\tvar enabled=1;\n\tvar XHR = new XHRConnection();\n\tif(!document.getElementById('enabled-{$t}').checked){enabled=0;}\n\tXHR.appendData('cache_directory',document.getElementById('cache_directory-{$t}').value);\n\tXHR.appendData('cache_type',document.getElementById('cache_type-{$t}').value);\n\tXHR.appendData('size',document.getElementById('squid-cache-size-{$t}').value);\n\tXHR.appendData('cache_dir_level1',document.getElementById('cache_dir_level1-{$t}').value);\n\tXHR.appendData('cache_dir_level2',document.getElementById('cache_dir_level2-{$t}').value);\n\tXHR.appendData('CPU',document.getElementById('CPU-{$t}').value);\n\tXHR.appendData('cachename',document.getElementById('cachename-{$t}').value);\n\tXHR.appendData('min_size',document.getElementById('min_size-{$t}').value);\n\tXHR.appendData('max_size',document.getElementById('max_size-{$t}').value);\n\t\n\tXHR.appendData('ID','{$ID}');\n\tXHR.appendData('enabled',enabled);\n\tAnimateDiv('waitcache-{$t}');\n\tXHR.sendAndLoad('{$page}', 'POST',x_AddNewCacheSave{$t});\n}\n\t\nfunction CheckCacheid(){\n\tvar cacheid={$ID};\n\tif(cacheid>0){\n\t\tdocument.getElementById('cache_type-{$t}').disabled=true;\n\t\tdocument.getElementById('cache_directory-{$t}').disabled=true;\n\t\tdocument.getElementById('squid-cache-size-{$t}').disabled=true;\n\t\tdocument.getElementById('cache_type-{$t}').disabled=true;\n\t\tdocument.getElementById('cache_dir_level1-{$t}').disabled=true;\n\t\tdocument.getElementById('cache_dir_level2-{$t}').disabled=true;\n\t}\n}\n\t\nfunction EnableCheck{$t}(){\n\tvar enabled=1;\n\tvar cacheid={$ID};\n\tif(!document.getElementById('enabled-{$t}').checked){enabled=0;}\n\t\n\tdocument.getElementById('cache_directory-{$t}').disabled=true;\n\tdocument.getElementById('squid-cache-size-{$t}').disabled=true;\n\tdocument.getElementById('cache_type-{$t}').disabled=true;\n\tdocument.getElementById('cache_dir_level1-{$t}').disabled=true;\n\tdocument.getElementById('cache_dir_level2-{$t}').disabled=true;\n\t\n\tif(enabled==1){\n\t\tif(cacheid==0){\n\t\t\tdocument.getElementById('cache_directory-{$t}').disabled=false;\n\t\t\tdocument.getElementById('squid-cache-size-{$t}').disabled=false;\n\t\t\tdocument.getElementById('cache_type-{$t}').disabled=false;\n\t\t\tdocument.getElementById('cache_dir_level1-{$t}').disabled=false;\n\t\t\tdocument.getElementById('cache_dir_level2-{$t}').disabled=false;\n\t\t}\n\t}\n\t\n}\n\n\nCacheTypeExplain{$t}();\nEnableCheck{$t}();\nCheckCacheid();\n</script>\n"; echo $tpl->_ENGINE_parse_body($html); }
function parseTemplate_unlock_save($noauth = false, $ARRAYCMD = array(), $noredirect = false) { include_once dirname(__FILE__) . "/ressources/class.sockets.inc"; include_once dirname(__FILE__) . "/ressources/class.mysql.squid.builder.php"; include_once dirname(__FILE__) . "/ressources/class.tcpip.inc"; include_once dirname(__FILE__) . "/ressources/class.templates.inc"; $tpl = new templates(); $cssform = " -moz-border-radius: 5px;\n border-radius: 5px;\n border:1px solid #DDDDDD;\n background:url(\"/img/gr-greybox.gif\") repeat-x scroll 0 0 #FBFBFA;\n background:-moz-linear-gradient(center top , #F1F1F1 0px, #FFFFFF 45px) repeat scroll 0 0 transparent;\n margin:5px;padding:5px;\n -webkit-border-radius: 5px;\n -o-border-radius: 5px;\n -moz-box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.6);\n -webkit-box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.6);\n box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.6);"; if (!$noauth) { if (!parseTemplate_unlock_checkcred()) { parseTemplate_unlock("{wrong_password_or_username}"); die; } } $ARRAY = unserialize(base64_decode($_REQUEST["serialize"])); $sock = new sockets(); $sock->BuildTemplatesConfig($ARRAY); $q = new mysql_squid_builder(); $finalhost = $_POST["finalhost"]; $IPADDR = $_REQUEST["ipaddr"]; $user = $_REQUEST["username"]; $url = $_REQUEST["url"]; $SquidGuardIPWeb = $_REQUEST["SquidGuardIPWeb"]; if (count($ARRAYCMD) > 3) { $IPADDR = $ARRAY["IPADDR"]; $user = $ARRAY["clientname"]; $url = $ARRAY["URL"]; $H = parse_url($url); $finalhost = $H["host"]; } $MAX = intval($GLOBALS["UfdbGuardHTTP"]["UnbblockMaxTime"]); if (isset($ARRAY["RULE_MAX_TIME"])) { if (intval($ARRAY["RULE_MAX_TIME"]) > 0) { $MAX = $ARRAY["RULE_MAX_TIME"]; } } $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`ufdbunlock` (\n\t\t\t`md5` VARCHAR( 90 ) NOT NULL ,\n\t\t\t`logintime` BIGINT UNSIGNED ,\n\t\t\t`finaltime` INT UNSIGNED ,\n\t\t\t`uid` VARCHAR(128) NOT NULL,\n\t\t\t`MAC` VARCHAR( 90 ) NULL,\n\t\t\t`www` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`ipaddr` VARCHAR( 128 ) ,\n\t\t\tPRIMARY KEY ( `md5` ) ,\n\t\t\tKEY `MAC` (`MAC`),\n\t\t\tKEY `logintime` (`logintime`),\n\t\t\tKEY `finaltime` (`finaltime`),\n\t\t\tKEY `uid` (`uid`),\n\t\t\tKEY `www` (`www`),\n\t\t\tKEY `ipaddr` (`ipaddr`)\n\t\t\t) ENGINE = MEMORY;"; $q->QUERY_SQL($sql); if (!$q->ok) { parseTemplate_unlock($q->mysql_error); return; } if ($MAX == 0) { $MAX = 60; } $familysite = $q->GetFamilySites($finalhost); include_once dirname(__FILE__) . "/ressources/class.ufdb.parsetemplate.inc"; $unlock = new parse_template_ufdb(); $addTocategory = $unlock->parseTemplate_unlock_privs($ARRAY, "addTocat=1", null); if (!isset($ARRAY["RULE_MAX_TIME"])) { if (isset($GLOBALS["RULE_MAX_TIME"])) { if (intval($GLOBALS["RULE_MAX_TIME"]) > 0) { $MAX = $GLOBALS["RULE_MAX_TIME"]; } } } $md5 = md5($finalhost . $IPADDR . $user); $time = time(); $EnOfLife = strtotime("+{$MAX} minutes", $time); $NextLogs = $EnOfLife - $time; writelogs("{$finalhost} {$IPADDR} {$user} Alowed for {$MAX} minutes, EndofLife={$EnOfLife} in {$NextLogs} seconds", __FUNCTION__, __FILE__, __LINE__); $q->QUERY_SQL("INSERT IGNORE INTO `ufdbunlock` (`md5`,`logintime`,`finaltime`,`uid`,`www`,`ipaddr`)\n\t\t\tVALUES('{$md5}','{$time}','{$EnOfLife}','{$user}','{$familysite}','{$IPADDR}')"); if (!$q->ok) { writelogs($q->mysql_error, __FUNCTION__, __FILE__, __LINE__); parseTemplate_unlock($q->mysql_error); return; } if ($addTocategory != null) { writelogs("Saving {$familysite} into {$addTocategory}", __FUNCTION__, __FILE__, __LINE__); $q->ADD_CATEGORYZED_WEBSITE($familysite, $addTocategory); } $q->QUERY_SQL("INSERT IGNORE INTO webfilters_usersasks (zmd5,ipaddr,sitename,uid) \n\t\t\tVALUES ('{$md5}','{$IPADDR}','{$familysite}','{$user}')"); $function = __FUNCTION__; $file = basename(__FILE__); $line = __LINE__; $subject = "Unlocked website {$finalhost}/{$familysite} from {$user}/{$IPADDR}"; $redirect = "<META http-equiv=\"refresh\" content=\"10; URL={$url}?ufdbtime=" . time() . "\">"; $redirecting_text = $tpl->javascript_parse_text("{redirecting}"); $redirect_text = "{please_wait_redirecting_to}<br>{$url}<br><{for} {$MAX} {minutes}"; if ($noredirect == true) { $redirect = null; $redirect_text = "{unlock}<br>{$url}<br><{for} {$MAX} {minutes}"; $redirecting_text = $tpl->javascript_parse_text("{done}"); } $MAIN_BODY = "<center>\n\t<div id='maincountdown' style='width:100%'>\n\t<center style='margin:20px;padding:20px;{$cssform};color:black;width:80%' >\n\t\t<input type='hidden' id='countdownvalue' value='10'>\n\t\t<span id='countdown' style='font-size:70px'></span>\n\t</center>\n\t</div>\n\t<p style='font-size:22px'>\n\t\t\t<center style='margin:50px;{$cssform};color:black;width:80%'>\n\t\t\t\t{$redirect_text}\n\t\t\t\t<center style='margin:20px;font-size:70px' id='wait_verybig_mini_red'>\n\t\t\t\t\t<img src='img/wait_verybig_mini_red.gif'>\n\t\t\t\t</center>\n\t\t\t</center>\n\t</p> \n\t</center>\n\t<script>\n\n\t\n \nsetInterval(function () {\n\tvar countdown = document.getElementById('countdownvalue').value\n\tcountdown=countdown-1;\n\tif(countdown==0){\n\t\tdocument.getElementById('countdownvalue').value=0;\n\t\tdocument.getElementById('wait_verybig_mini_red').innerHTML='{$redirecting_text}';\n\t\tdocument.getElementById('maincountdown').innerHTML='';\n\t\t\n\t\treturn;\n\t}\n\tdocument.getElementById('countdownvalue').value=countdown;\n\tdocument.getElementById('countdown').innerHTML=countdown\n \n}, 1000);\n</script>"; $q = new mysql(); $q->QUERY_SQL("INSERT IGNORE INTO `squid_admin_mysql`\n\t\t\t(`zDate`,`content`,`subject`,`function`,`filename`,`line`,`severity`,`hostname`) VALUES\n\t\t\t(NOW(),'','{$subject}','{$function}','{$file}','{$line}','1','{$_SERVER["SERVER_NAME"]}')", "artica_events"); if (!$q->ok) { $redirect = null; $MAIN_BODY = "<center style='margin:20px;padding:20px;{$cssform};color:black;width:80%'>\n\t\t<H1>Oups!</H1><hr>" . $q->mysql_error_html() . "</center>"; } if ($redirect != null) { $sock = new sockets(); if ($GLOBALS["VERBOSE"]) { echo "<H1 style='color:white'>squid.php?reconfigure-unlock=yes</H1>"; } $sock->getFrameWork("squid.php?reconfigure-unlock=yes"); } if ($noredirect) { $sock = new sockets(); if ($GLOBALS["VERBOSE"]) { echo "<H1 style='color:white'>squid.php?reconfigure-unlock=yes</H1>"; } $sock->getFrameWork("squid.php?reconfigure-unlock=yes"); } $UFDBGUARD_UNLOCK_LINK = $GLOBALS["UfdbGuardHTTP"]["UFDBGUARD_UNLOCK_LINK"]; $unlock_web_site_text = "{unlock_web_site}"; if ($UFDBGUARD_UNLOCK_LINK != null) { $unlock_web_site_text = $UFDBGUARD_UNLOCK_LINK; } $f[] = parseTemplate_headers($unlock_web_site_text, $redirect); if (!isset($GLOBALS["UfdbGuardHTTP"]["FOOTER"])) { $GLOBALS["UfdbGuardHTTP"]["FOOTER"] = null; } $FOOTER = $GLOBALS["UfdbGuardHTTP"]["FOOTER"]; $f[] = $MAIN_BODY; $f[] = $FOOTER; $f[] = "</div>"; $f[] = "</body>"; $f[] = "</html>"; $tpl = new templates(); echo $tpl->_ENGINE_parse_body(@implode("\n", $f)); }
function route_dump() { $q = new mysql(); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM routing_rules WHERE ID='{$_GET["ID"]}'", "artica_backup")); if (!$q->ok) { echo $q->mysql_error_html(); } $title = $ligne["RouteName"]; exec("/sbin/ip rule show |grep {$title} 2>&1", $results1); exec("/sbin/ip route show table {$title} 2>&1", $results2); $route = "# Rules *************************************************************************\n" . @implode("\n", $results1) . "\n\n\n# Table *************************************************************************\n\n" . @implode("\n", $results2); echo "<textarea style='width: 843px; height: 373px;;font-family:Courier New;font-size:16px !important'>{$route}</textarea>"; }
function nic_infos() { $sock = new sockets(); $q = new mysql(); $tpl = new templates(); $datas = unserialize(base64_decode($sock->getFrameWork("cmd.php?list-nics=yes"))); $tcp = new networking(); $IPBANS = unserialize(base64_decode($sock->GET_INFO("ArticaIpListBanned"))); $sql = "SELECT Interface FROM nics"; $results = $q->QUERY_SQL($sql, 'artica_backup'); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $MYSQL_NIC[$ligne["Interface"]] = $ligne["Interface"]; } while (list($num, $val) = each($datas)) { writelogs("Found: {$val}", __FUNCTION__, __FILE__, __LINE__); $val = trim($val); $wire = ''; $defaultroute_text = null; $color = "black"; $error = null; $MUST_CHANGE = false; $WCCP_INTERFACE = false; $routing_rules_TR = array(); $icon = "network-128-ok.png"; if (preg_match('#master#', $val)) { continue; } if (preg_match("#^veth.+?#", $val)) { continue; } if (preg_match("#^tunl[0-9]+#", $val)) { continue; } if (preg_match("#^dummy[0-9]+#", $val)) { continue; } if (preg_match("#^gre[0-9]+#", $val)) { continue; } if (preg_match("#^ip6tnl[0-9]+#", $val)) { continue; } if (preg_match("#^sit[0-9]+#", $val)) { continue; } if (preg_match("#^vlan[0-9]+#", $val)) { continue; } if (preg_match("#^virt[0-9]+#", $val)) { continue; } if (preg_match("#^.*?-ifb\$#", $val)) { continue; } if (preg_match("#wccp[0-9]+#", $val)) { $WCCP_INTERFACE = true; } $radius = "-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;/* behavior:url(/css/border-radius.htc); */"; unset($MYSQL_NIC[$val]); $nicinfos = $sock->getFrameWork("cmd.php?nicstatus={$val}"); $TCP_NIC_STATUS = $nicinfos; $tbl = explode(";", $nicinfos); if ($IPBANS[$tbl[0]]) { continue; } $nicz = new system_nic($val); if (trim($val) == null) { continue; } if ($nicz->Bridged == 1) { continue; } $qos_text = "{disabled}"; $qos_color = "#8E8E8E"; $tcp->ifconfig(trim($val)); if (trim($tbl[5]) == "yes") { $wire = " (wireless)"; } $gateway = trim($tbl[4]); if ($gateway == null) { $gateway = $nicz->GATEWAY; } if ($nicz->defaultroute == 1) { $defaultroute_text = "<i style='font-weight:blod;font-size:14px'>{default_route}</i>"; } if ($nicz->FireQOS == 1) { $qos_text = "{enabled}"; $qos_color = "black"; } if ($nicz->enabled == 0) { $color = "#8E8E8E"; $qos_color = "#8E8E8E"; } if ($nicz->UseSPAN == 1) { $defaultroute_text = null; } $sql = "SELECT * FROM routing_rules WHERE enabled=1 and nic='{$val}'"; $routing_rules = $q->QUERY_SQL($sql, "artica_backup"); $gateway_tr = "<tr>\n\t\t<td class=legend nowrap style='color:{$color};vertical-align:top;font-size:16px'>{gateway}:</td>\n\t\t<td style='font-weight:bold;font-size:16px;color:{$color}'>{$gateway}</a></td>\n\t\t</tr>"; while ($ligneRoute = mysql_fetch_assoc($routing_rules)) { $RouteName = $ligneRoute["RouteName"]; $ID = $ligneRoute["ID"]; $js = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('system.routing.rules.php?route-js=yes&ID={$ID}&lock=yes');\"\n\t\t\tstyle='font-weight:bold;font-size:16px;color:{$color};text-decoration:underline'>"; $routing_rules_TR[] = "<tr>\n\t\t<td class=legend nowrap style='color:{$color};vertical-align:top;font-size:16px'>{routing_rule}:</td>\n\t\t<td style='font-weight:bold;font-size:16px;color:{$color}'>{$js}{$RouteName}</a></td>\n\t\t</tr>"; } if ($nicz->IPADDR != $tbl[0]) { $MUST_CHANGE = true; } if ($nicz->NETMASK != $tbl[2]) { $MUST_CHANGE = true; } if (count($routing_rules_TR) > 0) { $gateway_tr = @implode("", $routing_rules_TR); $defaultroute_text = null; } else { if ($nicz->GATEWAY != $gateway) { $MUST_CHANGE = true; } } if ($tbl[0] == null) { $error = "<span style='color:#BA0000'>{waiting_network_reload}</span>"; $icon = "network-128-warn.png"; } if ($nicz->dhcp == 1) { $ip = new IP(); if ($ip->isValid($tbl[0])) { $MUST_CHANGE = false; } } if ($nicz->enabled == 0) { $MUST_CHANGE = false; } if ($nicz->UseSPAN == 1) { $nicz->IPADDR = " - - - "; $nicz->NETMASK = " - - - "; $tbl[0] = " - - - "; $tbl[2] = " - - - "; $nicz->metric = " - - - "; $gateway_tr = null; $MUST_CHANGE = false; $error = null; } if ($MUST_CHANGE) { $icon = "network-128-warn.png"; $error = "<span style='color:#BA0000;font-size:16px'>{need_to_apply_network_settings_interface}</span>"; } if ($nicz->enabled == 0) { $icon = "network-128-disabled.png"; $color = "#8E8E8E"; $error = null; } if ($tbl[0] == null) { $tbl[0] = "<span style='color:#8a8a8a'>{$nicz->IPADDR}</span>"; } if ($tbl[2] == null) { $tbl[2] = "<span style='color:#8a8a8a'>{$nicz->NETMASK}</span>"; } $button = button("{modify}", "Loadjs('system.nic.edit.php?nic={$val}')", 16, 150); if (preg_match("#^br([0-9]+)#", $val, $re)) { $button = button("{modify}", "Loadjs('system.network.bridges.interfaces.php?network-bridge-js=yes&ID={$re[1]}')", 16, 150); } if ($WCCP_INTERFACE) { $error = null; $button = null; } $tr[] = "\n\t\t<table style='width:100%;border:2px solid #CCCCCC;margin-bottom:10x;{$radius}'>\n\t\t\n\t\t<tr>\n\t\t\t<td style='font-size:22px;font-weight:bold' colspan=2>\n\t\t\t<div style='margin-top:10px;margin-bottom:10px;color:{$color}'>{$nicz->netzone}</span>: {$nicz->NICNAME} ({$val})\n\t\t\t<div style='text-align:right;width:80%;margin-top:-2px;\n\t\t\tpadding-top:5px;margin-bottom:10px'>{$defaultroute_text} {$error}</div>\n\t\t\t</div>\n\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td colspan=2>\n\t\t<table style='width:100%'>\n\t\t<td valign='top'><img src='img/{$icon}'></td>\n\t\t<td valign='top'>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td style='font-size:16px;color:{$color}' class=legend>{tcp_address}:</td>\n\t\t\t\t<td style='font-weight:bold;font-size:16px;color:{$color}'>{$tbl[0]}</td>\n\t\t\t</tr>\t\n\t"; $sql = "SELECT ipaddr,ID FROM nics_virtuals WHERE nic='{$val}'"; $q = new mysql(); $resultsVirtuals = $q->QUERY_SQL($sql, 'artica_backup'); if (!$q->ok) { $tr[] = "\n\t\t\t<tr>\n\t\t\t<td class=legend nowrap style='color:{$color};font-size:16px'>{tcp_address}:</td>\n\t\t\t<td style='font-weight:bold;font-size:16px;color:{$color}'>" . $q->mysql_error_html() . "</td>\n\t\t\t\t</tr>"; } while ($virtuals = @mysql_fetch_array($resultsVirtuals, MYSQL_ASSOC)) { $js = "YahooWin2(725,'system.nic.config.php?virtual-popup-add=yes&t=0&ID={$virtuals["ID"]}','{$val}:{$virtuals["ID"]} {$virtuals["ipaddr"]}');"; $tr[] = "\n\t\t\t<tr>\n\t\t\t<td class=legend nowrap style='color:{$color};font-size:16px'>{tcp_address}:</td>\n\t\t\t<td style='font-weight:bold;font-size:16px;color:{$color}'>\n\t\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\" style='font-weight:bold;text-decoration:underline;color:{$color}'>\n\t\t\t{$virtuals["ipaddr"]}</a></td>\n\t\t\t</tr>"; } $tr[] = "<tr>\n\t\t\t\t<td class=legend nowrap style='color:{$color};font-size:16px'>{netmask}:</td>\n\t\t\t\t<td style='font-weight:bold;font-size:16px;color:{$color}'>{$tbl[2]}</a></td>\n\t\t\t</tr>\t\n\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend nowrap style='color:{$color};vertical-align:top;font-size:16px'>{metric}:</td>\n\t\t\t\t<td style='font-weight:bold;font-size:16px;color:{$color}'>{$nicz->metric}</a></td>\n\t\t\t</tr>\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend nowrap style='color:{$color};font-size:16px'>{mac_addr}:</td>\n\t\t\t\t<td style='font-weight:bold;font-size:16px;color:{$color}'>{$tbl[1]}</a></td>\n\t\t\t</tr>\t\n\t\t\t{$gateway_tr}\n\t\t\t<tr>\n\t\t\t\t<td class=legend nowrap style='color:{$qos_color};font-size:16px'>{Q.O.S}:</td>\n\t\t\t\t<td style='font-weight:bold;font-size:16px;color:{$qos_color}'>{$qos_text}</a></td>\n\t\t\t</tr>\t\t\t\n\t\t\t</table>\n\t\t</td>\n\t\t</tr>\n\t\t</table>\n\t\t</td>\n\t\t\n\t\t<tr>\n\t\t\t<td colspan=2 align='right' style='padding-bottom:9px'>{$button}</td>\n\t\t</tr>\t\t\n\t\t</table><p> </p>\n\t\t"; } if (count($MYSQL_NIC) > 0) { while (list($num, $val) = each($MYSQL_NIC)) { $nicz = new system_nic($val); $tr[] = "\n\t\t\t<table style='width:100%;border:2px solid #CCCCCC;margin-bottom:10x;{$radius}'>\n\t\t\t\n\t\t\t<tr>\n\t\t\t<td style='font-size:22px;font-weight:bold' colspan=2>\n\t\t\t<div style='margin-top:10px;margin-bottom:10px'>{$nicz->netzone}</span>: {$nicz->NICNAME} ({$val})\n\t\t\t<div style='font-size:18px;color:#d32d2d'>{hardware_error}</div>\n\t\t\t</div>\n\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t<td colspan=2>\n\t\t\t<table style='width:100%'>\n\t\t\t<td valign='top'><img src='img/network-128-fatal.png'></td>\n\t\t\t<td valign='top'>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t<td style='font-size:16px;color:{$color}' class=legend>{tcp_address}:</td>\n\t\t\t<td style='font-weight:bold;font-size:16px;color:{$color}'>{$nicz->IPADDR}</td>\n\t\t\t</tr>"; $sql = "SELECT ipaddr,ID FROM nics_virtuals WHERE nic='{$val}'"; $q = new mysql(); $resultsVirtuals = $q->QUERY_SQL($sql, 'artica_backup'); if (!$q->ok) { $tr[] = "\n\t\t\t\t<tr>\n\t\t\t\t<td class=legend nowrap style='color:{$color};font-size:16px'>{tcp_address}:</td>\n\t\t\t\t<td style='font-weight:bold;font-size:16px;color:{$color}'>" . $q->mysql_error_html() . "</td>\n\t\t\t\t</tr>"; } while ($virtuals = @mysql_fetch_array($resultsVirtuals, MYSQL_ASSOC)) { $js = "YahooWin2(725,'system.nic.config.php?virtual-popup-add=yes&t=0&ID={$virtuals["ID"]}','{$val}:{$virtuals["ID"]} {$virtuals["ipaddr"]}');"; $tr[] = "\n\t\t\t\t<tr>\n\t\t\t\t<td class=legend nowrap style='color:{$color};font-size:16px'>{tcp_address}:</td>\n\t\t\t\t<td style='font-weight:bold;font-size:16px;color:{$color}'>\n\t\t\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\" style='font-weight:bold;text-decoration:underline;;color:{$color}'>\n\t\t\t\t{$virtuals["ipaddr"]}</a></td>\n\t\t\t\t</tr>"; } $tr[] = "<tr>\n\t\t\t<td class=legend nowrap style='color:{$color};font-size:16px'>{netmask}:</td>\n\t\t\t<td style='font-weight:bold;font-size:16px;color:{$color}'>{$nicz->NETMASK}</a></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t<td class=legend nowrap style='color:{$color};vertical-align:top;font-size:16px'>{gateway}:</td>\n\t\t\t<td style='font-weight:bold;font-size:16px;color:{$color}'>{$nicz->GATEWAY}</a></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t<td class=legend nowrap style='color:{$color};vertical-align:top;font-size:16px'>{metric}:</td>\n\t\t\t<td style='font-weight:bold;font-size:16px;color:{$color}'>{$nicz->metric}</a></td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t</td>\n\t\t\t\n\t\t\t<tr>\n\t\t\t<td colspan=2 align='right' style='padding-bottom:9px'>" . button("{delete}", "Loadjs('system.nic.edit.php?nic-delete-js={$val}')", 16, 150) . "</td>\n\t\t\t</tr>\n\t\t\t</table><p> </p>\n\t\t"; } } $tr[] = "\n\t<center>" . button("{apply_network_configuration}", "Loadjs('network.restart.php')", 18, 390) . "</center>\n\t<center style='margin-top:10px'>" . button("{network_status}", "Loadjs('network.status.php')", 18, 390) . "</center>"; $i = 0; $datas = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/usb.scan.serialize")); while (list($HDS, $MAIN_HD) = each($datas)) { if ($HDS == "UUID") { continue; } $HDSENC = urlencode($HDS); $tr[] = "\n\t\t<p> </p>\n\t\t<table style='width:100%;border:2px solid #CCCCCC;margin-bottom:10x;{$radius}'>\n\t\t\n\t\t<tr>\n\t\t<td style='font-size:22px;font-weight:bold'>\n\t\t<div style='margin-top:10px;margin-bottom:10px'>{disk} \n\t\t\n\t\t<a href=\"javascript:blur();\"\n\t\tOnClick=\"javascript:Loadjs('system.internal.disks.php?partinfos-js={$HDSENC}')\"\n\t\tstyle='text-decoration:underline;font-weight:bold'>{$HDS}</a> - {$MAIN_HD["SIZE"]}</div></td>\n\t\t</tr>\n\t\t"; while (list($dev, $MAIN_PART) = each($MAIN_HD["PARTITIONS"])) { $i++; $ID_FS_LABEL = $MAIN_PART["ID_FS_LABEL"]; if ($ID_FS_LABEL == null) { $ID_FS_LABEL = $MAIN_PART["MOUNTED"]; } $SIZE = round($MAIN_PART["INFO"]["SIZE"] / 1024); if ($SIZE == 0) { continue; } $UTIL = round($MAIN_PART["INFO"]["UTIL"] / 1024); $ID_FS_UUID = $MAIN_PART["ID_FS_UUID"]; $script[] = "\nvar g{$i} = new JustGage({\n\tid: '{$ID_FS_UUID}',\n\tvalue: {$UTIL},\n\tmin: 0,\n\tmax: {$SIZE},\n\ttitle: '{$ID_FS_LABEL}',\n\tlabel: 'MB',\n\tlevelColorsGradient: true\n});"; $icz[] = "<div style='width:130px;height:100px' id='{$ID_FS_UUID}'></div>\n\t\t\t\t\n\t\t"; } $tr[] = "\n\t\t<tr>\n\t\t<td>" . CompileTr3($icz, true) . "</td>\n\t\t\t\t\n\t\t</table><p> </p>"; } echo $tpl->_ENGINE_parse_body(@implode("\n", $tr)) . "\n\n<script>\n" . @implode("\n", $script) . "\n</script>"; }
function search() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql(); $database = "artica_backup"; $search = '%'; $table = "nics"; $page = 1; $ORDER = null; $allow = null; $total = 0; if ($q->COUNT_ROWS($table, $database) == 0) { json_error_show("no data"); } $searchstring = string_to_flexquery(); if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } $table = "firehol_services_def"; $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE enabled=1 {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database)); $total = $ligne["TCOUNT"]; if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM {$table} WHERE enabled=1 {$searchstring} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql, $database); if (!$q->ok) { json_error_show($q->mysql_error_html(), 1); } if (mysql_num_rows($results) == 0) { json_error_show("no data {$sql}"); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { json_error_show($q->mysql_error); } $fontsize = 18; $firehole = new firehol(); // //service,server_port,client_port,helper,enabled while ($ligne = mysql_fetch_assoc($results)) { $color = "black"; $mouse = "OnMouseOver=\"this.style.cursor='pointer'\" OnMouseOut=\"this.style.cursor='default'\""; $linkstyle = "style='text-decoration:underline'"; $service = $ligne["service"]; $server_port = $ligne["server_port"]; $client_port = $ligne["client_port"]; $enabled = $ligne["enabled"]; $js = "Loadjs('firehole.services.php?service-js={$service}')"; if ($enabled == 0) { $color = "#909090"; } $delete = imgsimple("arrow-right-24.png", null, "{$_GET["CallBack"]}('{$service}')"); $link = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\" style='color:{$color};font-size:{$fontsize}px;text-decoration:underline'>"; $data['rows'][] = array('id' => $ligne["Interface"], 'cell' => array("<span style='font-size:{$fontsize}px;color:{$color}'>{$link}{$service}</a></span>", "<span style='font-size:{$fontsize}px;color:{$color}'>{$link}{$server_port}</a></span>", "<span style='font-size:{$fontsize}px;color:{$color}'>{$client_port}</span>", "<center style='font-size:{$fontsize}px;color:{$color}'>{$delete}</center>")); } echo json_encode($data); }
function search() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql(); $database = "artica_backup"; $search = '%'; $table = "nics"; $page = 1; $ORDER = null; $allow = null; $total = 0; if ($q->COUNT_ROWS($table, $database) == 0) { json_error_show("no data"); } $searchstring = string_to_flexquery(); if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } $table = "(select * from `{$_GET["xtable"]}` WHERE `interface`='{$_GET["nic"]}') as t"; $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database)); $total = $ligne["TCOUNT"]; if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql, $database); if (!$q->ok) { json_error_show($q->mysql_error_html(), 1); } if (mysql_num_rows($results) == 0) { json_error_show("no data {$sql}"); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { json_error_show($q->mysql_error); } $fontsize = 18; $firehole = new firehol(); $allow_type[0] = "cloud-deny-42.png"; $allow_type[1] = "cloud-goto-42.png"; while ($ligne = mysql_fetch_assoc($results)) { $mouse = "OnMouseOver=\"this.style.cursor='pointer'\" OnMouseOut=\"this.style.cursor='default'\""; $linkstyle = "style='text-decoration:underline'"; $service = $ligne["service"]; $allow_typez = $ligne["allow_type"]; $netzone = $ligne["netzone"]; $zmd5 = $ligne["zmd5"]; $icon = $allow_type[$allow_typez]; $allow = imgsimple($icon, null, "Loadjs('{$MyPage}?revert-js=yes&zmd5={$zmd5}&nic={$_GET["nic"]}&xtable={$_GET["xtable"]}')"); $delete = imgsimple("delete-42.png", null, "Loadjs('{$MyPage}?delete-js=yes&zmd5={$zmd5}&nic={$_GET["nic"]}&xtable={$_GET["xtable"]}')"); $data['rows'][] = array('id' => $service, 'cell' => array("<span style='font-size:22px'>{$service}</a></span>", "<center style='font-size:18px'>{$allow}</center>", "<center style='font-size:18px'>{$delete}</center>")); } echo json_encode($data); }
function route_popup() { $page = CurrentPageName(); $tpl = new templates(); $t = time(); $btname = "{add}"; $zmd5 = $_GET["zmd5"]; $t = $_GET["t"]; $title = "{new_route}"; if ($zmd5 != null) { $btname = "{apply}"; $q = new mysql(); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM nic_routes WHERE zmd5='{$zmd5}'", "artica_backup")); if (!$q->ok) { echo $q->mysql_error_html(); } $title = $ligne["pattern"]; } $net = new networking(); $ETHs = $net->Local_interfaces(); unset($ETHs["lo"]); while (list($int, $none) = each($ETHs)) { $nic = new system_nic($int); $ETHZ[$int] = "{$int} - {$nic->NICNAME} - {$nic->IPADDR}"; } $types[1] = "{network_nic}"; $types[2] = "{host}"; if (!is_numeric($ligne["zOrder"])) { $ligne["zOrder"] = 0; } if (!is_numeric($ligne["metric"])) { $ligne["metric"] = 0; } $html = "\n\t\t<div style='font-size:24px;margin-bottom:20px'>{$ligne["pattern"]}</div>\n\t\t<div style='width:98%' class=form>\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:24px'>{nic}:</td>\n\t\t\t<td>" . Field_array_Hash($ETHZ, "nic-{$t}", $ligne["nic"], "style:font-size:24px") . "</td>\n\t\t</tr>\t\t\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:24px'>{type}:</td>\n\t\t\t<td>" . Field_array_Hash($types, "type-{$t}", $ligne["type"], "style:font-size:24px") . "</td>\n\t\t</tr>\t\n\t\t\t\t\t\t\t\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:24px'>{item} <span style='font-size:14px'>({address}/{network2})</span>:</td>\n\t\t\t<td>" . Field_text("pattern-{$t}", $ligne["pattern"], "font-size:24px;width:95%") . "</td>\n\t\t</tr>\n\t\t\t\t\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:24px'>{gateway}:</td>\n\t\t\t<td>" . Field_ipv4("gateway-{$t}", $ligne["gateway"], "font-size:24px;width:95%") . "</td>\n\t\t</tr>\t\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:24px'>{order}:</td>\n\t\t\t<td>" . Field_text("zOrder-{$t}", $ligne["zOrder"], "font-size:24px;width:90px") . "</td>\n\t\t</tr>\t\t\t\t\t\t\t\t\t\t\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:24px'>{metric}:</td>\n\t\t\t<td>" . Field_text("metric-{$t}", $ligne["metric"], "font-size:24px;width:90px") . "</td>\n\t\t</tr>\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t<tr>\n\t\t\t<td colspan=2 align='right'><hr>" . button($btname, "Save{$t}()", 32) . "</td>\n\t\t</tr>\n\t\t</table>\n\t\t</div>\n<script>\nvar xSave{$t}= function (obj) {\n\tvar results=obj.responseText;\n\tvar ID='{$zmd5}';\n\tif(results.length>5){alert(results);return;}\n\tif(ID.length==0){YahooWinHide();}\n\t\$('#flexRT{$_GET["t"]}').flexReload();\n}\n\nfunction Save{$t}(){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('zmd5','{$zmd5}');\n\tXHR.appendData('zOrder',document.getElementById('zOrder-{$t}').value);\n\tXHR.appendData('type',document.getElementById('type-{$t}').value);\n\tXHR.appendData('pattern',document.getElementById('pattern-{$t}').value);\n\tXHR.appendData('gateway',document.getElementById('gateway-{$t}').value);\n\tXHR.appendData('metric',document.getElementById('metric-{$t}').value);\n\tXHR.appendData('nic',document.getElementById('nic-{$t}').value);\n\tXHR.sendAndLoad('{$page}', 'POST',xSave{$t});\t\n}\n\nfunction check{$t}(){\n\tvar ID='{$zmd5}';\n\tif(ID.length==0){return;}\n\tdocument.getElementById('pattern-{$t}').disabled=true;\n\tdocument.getElementById('gateway-{$t}').disabled=true;\n\tdocument.getElementById('nic-{$t}').disabled=true;\n}\ncheck{$t}();\n</script>\n\t\t\n\t"; echo $tpl->_ENGINE_parse_body($html); }
function table() { $page = CurrentPageName(); $sock = new sockets(); $tpl = new templates(); $enabled = $tpl->javascript_parse_text("{enabled}"); $port = $tpl->javascript_parse_text("{port}"); $delete = $tpl->javascript_parse_text("{delete}"); $identifier = $tpl->javascript_parse_text("{identifier}"); $add = $tpl->javascript_parse_text("{new_member}"); $object_name = $tpl->javascript_parse_text("{PortName}"); $new_quota_object = $tpl->_ENGINE_parse_body("{new_whitelist_port}"); $title = $tpl->javascript_parse_text("{whitelisted_ports}"); $apply_params = $tpl->_ENGINE_parse_body("{apply}"); $protocol = $tpl->_ENGINE_parse_body("{protocol}"); $apply_firewall_rules = $tpl->javascript_parse_text("{apply_firewall_rules}"); $tablewidht = 883; $t = time(); $q = new mysql(); $sql = "CREATE TABLE IF NOT EXISTS `gateway_secure` \n\t( ID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t `dport` INT(10) NOT NULL, `portname` varchar(256) NOT NULL, `dproto` smallint(1) NOT NULL, `enabled` smallint(1) NOT NULL, KEY `portname` (`portname`), KEY `enabled` (`enabled`) ) ENGINE=MYISAM;"; $q->QUERY_SQL($sql, "artica_backup"); if ($q->COUNT_ROWS("gateway_secure", "artica_backup") == 0) { AddDefaults(); } if (!$q->ok) { echo $q->mysql_error_html(); } $apply_paramsbt = "{separator: true},{name: '<strong style=font-size:18px>{$apply_params}</strong>', bclass: 'apply', onpress : SquidBuildNow{$t}},"; $buttons = "buttons : [\n\t{name: '<strong style=font-size:18px>{$new_quota_object}</strong>', bclass: 'Add', onpress : AddQuota{$t}},\n\t{name: '<strong style=font-size:18px>{$apply_firewall_rules}</strong>', bclass: 'Apply', onpress : FW{$t}},\n\t],\t"; echo "\n\n\t<table class='{$t}' style='display: none' id='TABLE_GWSECURE_OBJECT' style='width:99%;text-align:left'></table>\n\t<script>\n\t\$(document).ready(function(){\n\t\$('#TABLE_GWSECURE_OBJECT').flexigrid({\n\turl: '{$page}?search=yes&t={$t}',\n\tdataType: 'json',\n\tcolModel : [\n\t{display: '<span style=font-size:22px>{$port}</span>', name : 'dport', width : 130, sortable : false, align: 'right'},\n\t{display: '<span style=font-size:22px>{$object_name}</span>', name : 'portname', width : 450, sortable : false, align: 'left'},\n\t{display: '<span style=font-size:22px>{$protocol}</span>', name : 'dproto', width : 138, sortable : false, align: 'left'},\n\t{display: '<span style=font-size:22px>{$enabled}</span>', name : 'enabled', width : 83, sortable : false, align: 'center'},\n\t{display: ' ', name : 'none3', width : 60, sortable : false, align: 'center'},\n\t],\n\t{$buttons}\n\tsearchitems : [\n\t{display: '{$object_name}', name : 'objectname'},\n\n\n\t],\n\tsortname: 'dport',\n\tsortorder: 'asc',\n\tusepager: true,\n\ttitle: '<span style=font-size:26px>{$title}</span>',\n\tuseRp: true,\n\trp: 50,\n\tshowTableToggleBtn: false,\n\twidth: '99%',\n\theight: 450,\n\tsingleSelect: true\n});\n});\n\nfunction SquidBuildNow{$t}(){\nLoadjs('squid.compile.php');\n}\nfunction AddQuota{$t}(){\nLoadjs('{$page}?port-js=yes&t={$t}&ID=0');\n}\nfunction FW{$t}(){\n\tLoadjs('firehol.progress.php');\n}\n</script>\n"; }
function route_popup() { $page = CurrentPageName(); $q = new mysql(); $tpl = new templates(); $t = time(); $btname = "{add}"; $ID = intval($_GET["ID"]); $ruleid = $_GET["ruleid"]; $t = $_GET["t"]; $title = "{new_route}"; $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT `RouteName`,nic FROM routing_rules WHERE ID='{$_GET["ruleid"]}'", "artica_backup")); $RouteName = $ligne["RouteName"]; $nic = $ligne["nic"]; if ($ID > 0) { $btname = "{apply}"; $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM routing_rules_dest WHERE ID='{$ID}'", "artica_backup")); if (!$q->ok) { echo $q->mysql_error_html(); } $title = $ligne["pattern"]; } $types[1] = "{network_nic}"; $types[2] = "{host}"; $types[3] = "{default_gateway}"; if (!is_numeric($ligne["zOrder"])) { $ligne["zOrder"] = 0; } if (!is_numeric($ligne["metric"])) { $ligne["metric"] = 0; } $html = "\n\t\t<div style='font-size:24px;margin-bottom:20px'>{$nic}: {$RouteName}: {$ligne["pattern"]}</div>\n\t\t<div style='width:98%' class=form>\n\t\t<table style='width:100%'>\n\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:24px'>{type}:</td>\n\t\t\t<td>" . Field_array_Hash($types, "type-{$t}", $ligne["type"], "NextRuleCheck{$t}()", '', 0, "font-size:24px") . "</td>\n\t\t</tr>\t\n\t\t\t\t\t\t\t\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:24px'>{item} <span style='font-size:14px'>({address}/{network2})</span>:</td>\n\t\t\t<td>" . Field_text("pattern-{$t}", $ligne["pattern"], "font-size:24px;width:95%") . "</td>\n\t\t</tr>\n\t\t\t\t\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:24px'>{gateway} <span style='font-size:14px'>({next_hope})</span>:</td>\n\t\t\t<td>" . Field_ipv4("gateway-{$t}", $ligne["gateway"], "font-size:24px;width:95%") . "</td>\n\t\t</tr>\t\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:24px'>{order}:</td>\n\t\t\t<td>" . Field_text("zOrder-{$t}", $ligne["zOrder"], "font-size:24px;width:90px") . "</td>\n\t\t</tr>\t\t\t\t\t\t\t\t\t\t\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:24px'>{metric}:</td>\n\t\t\t<td>" . Field_text("metric-{$t}", $ligne["metric"], "font-size:24px;width:90px") . "</td>\n\t\t</tr>\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t<tr>\n\t\t\t<td colspan=2 align='right'><hr>" . button($btname, "Save{$t}()", 32) . "</td>\n\t\t</tr>\n\t\t</table>\n\t\t</div>\n<script>\nvar xSave{$t}= function (obj) {\n\tvar results=obj.responseText;\n\tvar ID={$ID};\n\tif(results.length>5){alert(results);return;}\n\tif(ID==0){YahooWin3Hide();}\n\t\$('#TABLE_IPDST_RULE_{$_GET["ruleid"]}').flexReload();\n}\n\nfunction Save{$t}(){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('ID','{$ID}');\n\tXHR.appendData('zOrder',document.getElementById('zOrder-{$t}').value);\n\tXHR.appendData('type',document.getElementById('type-{$t}').value);\n\tXHR.appendData('pattern',document.getElementById('pattern-{$t}').value);\n\tXHR.appendData('gateway',document.getElementById('gateway-{$t}').value);\n\tXHR.appendData('metric',document.getElementById('metric-{$t}').value);\n\tXHR.appendData('ruleid','{$ruleid}');\n\t\n\tXHR.sendAndLoad('{$page}', 'POST',xSave{$t});\t\n}\n\nfunction NextRuleCheck{$t}(){\n\tvar type=document.getElementById('type-{$t}').value;\n\t\n\tif(type==3){\n\t\tdocument.getElementById('pattern-{$t}').value='';\n\t\tdocument.getElementById('pattern-{$t}').disabled=true;\n\t}\t\n}\nNextRuleCheck{$t}();\n</script>\n\t\t\n\t"; echo $tpl->_ENGINE_parse_body($html); }
function status(){ $page=CurrentPageName(); $sock=new sockets(); $tpl=new templates(); $q=new mysql(); $APP_SARG=$tpl->_ENGINE_parse_body("{APP_SARG}"); $EnableSargGenerator=intval($sock->GET_INFO("EnableSargGenerator")); $EnableSargWeb=intval($sock->GET_INFO("EnableSargWeb")); $SargWebPort=intval($sock->GET_INFO("SargWebPort")); if($SargWebPort==0){$SargWebPort=rand(55600,59000);$sock->SET_INFO("SargWebPort", $SargWebPort);} $t=time(); $disabled=$tpl->_ENGINE_parse_body("{disabled}"); if($EnableSargGenerator==0){ $version=Paragraphe32("noacco:$APP_SARG", "$disabled", "blur()", "warning-panneau-32.png"); }else{ $version=$sock->getFrameWork("sarg.php?version=yes"); $status=unserialize($sock->GET_INFO("SargDirStatus")); $ff[]="version: $version"; $ff[]="{size}: ".FormatBytes($status["SIZE"]); $ff[]="{files}: ".FormatNumber($status["FILES"])." {free}: ".FormatNumber($array["F_FREE"]); $ff[]="{free}: {$status["FREE"]}M"; $version=Paragraphe32("noacco:$APP_SARG", "noacco:<div style='font-size:12px'>".$tpl->_ENGINE_parse_body(@implode("<br>", $ff))."</div>", "blur()", "ok32.png"); } $sql="SELECT COUNT(*) as tcount FROM freeweb WHERE `groupware`='SARG'"; $ligne=@mysql_fetch_array($q->QUERY_SQL($sql,"artica_backup")); if(!$q->ok){echo $q->mysql_error_html();} $count=$ligne["tcount"]; if($count==0){ $tr[]=Paragraphe32("no_website", "no_freeweb_service_explain", "Loadjs('freeweb.edit.php?hostname=&force-groupware=SARG');", "warning-panneau-32.png"); } $tr[]=Paragraphe32("build_index_page", "build_index_page_sarg", "Loadjs('$page?index-run-js=yes');", "48-run.png"); $tr[]=Paragraphe32("weekly_reports", "weekly_reports_execute", "Loadjs('$page?weekly-run-js=yes');", "48-run.png"); $tr[]=Paragraphe32("monthly_reports", "monthly_reports_execute", "Loadjs('$page?monthly-run-js=yes');", "48-run.png"); $tr[]=$version; $tableau=CompileTr3($tr,true); $html=" <table style='width:100%'> <tr> <td style='width:340px;vertical-align:top'><div id='status-sarg'></div></td> <td style='width:98%'> <div style='width:98%' class=form> ". Paragraphe_switch_img("{enable_sarg_service}", "{APP_SARG_TXT}<br>{enable_sarg_service_text}", "EnableSargGenerator-$t",$EnableSargGenerator,null,780) . Paragraphe_switch_img("{enable_sarg_webservice}", "{enable_sarg_webservice_text}","EnableSargWeb-$t" ,$EnableSargWeb,null,780). " <table style='width:100%'> <tr> <td class=legend style='font-size:22px'>{listen_port}</td> <td>". Field_text("SargWebPort-$t",$SargWebPort,"font-size:22px;width:120px")."</td> </tR> <tr> <td colspan=2 align='right' style='font-size:18px'> <a href=\"http://{$_SERVER["SERVER_NAME"]}:$SargWebPort\" style='text-decoration:underline' _target=_new>http://{$_SERVER["SERVER_NAME"]}:$SargWebPort</a></td> </tr> </table> <p><hr></p> <div style='text-align:right'>". button("{apply}","Save$t()",26)."</div> </div> </td> </tr> </table> $tableau <script> var xSave$t= function (obj) { var tempvalue=obj.responseText; if(tempvalue.length>3){alert(tempvalue)}; Loadjs('squid.restart.php?ApplyConfToo=yes&ask=yes'); } function Save$t(){ var XHR = new XHRConnection(); XHR.appendData('EnableSargGenerator',document.getElementById('EnableSargGenerator-$t').value); XHR.appendData('EnableSargWeb',document.getElementById('EnableSargWeb-$t').value); XHR.appendData('SargWebPort',document.getElementById('SargWebPort-$t').value); XHR.sendAndLoad('$page', 'POST',xSave$t); } LoadAjax('status-sarg','$page?status-sarg=yes') </script> "; echo $tpl->_ENGINE_parse_body($html); }
include_once 'ressources/class.html.pages.inc'; include_once 'ressources/class.cyrus.inc'; include_once 'ressources/class.main_cf.inc'; include_once 'ressources/charts.php'; include_once 'ressources/class.syslogs.inc'; include_once 'ressources/class.system.network.inc'; include_once 'ressources/class.os.system.inc'; include_once 'ressources/class.stats-appliance.inc'; if (isset($_GET["pfx"])) { pfx(); exit; } $q = new mysql(); $results = $q->QUERY_SQL("SELECT CommonName,pks12 FROM sslcertificates ORDER BY CommonName", "artica_backup"); if (!$q->ok) { echo FATAL_ERROR_SHOW_128($q->mysql_error_html()); } while ($ligne = mysql_fetch_assoc($results)) { if (strlen($ligne["pks12"]) < 10) { continue; } $f[] = "<div style='float:left;width:128px;margin:10px;width:350px;' class=form>\n\t\t<center><a href=\"pfx.php?pfx={$ligne["CommonName"]}\"><img src='img/pfx-128.png'></center>\n\t\t<center style='font-size:30px;text-decoration:underline'>{$ligne["CommonName"]}</center>\n\t\t</div>"; } $tpl = new template_users("{certificate}", @implode("\n", $f), $_SESSION, 0, 0, 0, $cfg); $html = $tpl->web_page; echo $html; function pfx() { $CommonName = $_GET["pfx"]; $q = new mysql(); $sql = "SELECT pks12 FROM sslcertificates WHERE CommonName='{$CommonName}'";
function search_filename_from_catz(){ $q=new mysql(); $tpl=new templates(); $t=$_GET["t"]; if($_GET["search_filename_from_catz"]<>null){ $HAVING=" HAVING category='{$_GET["search_filename_from_catz"]}'";} $sql="SELECT category,filename FROM `{$_GET["table"]}` GROUP BY category,filename $HAVING ORDER BY filename"; $results = $q->QUERY_SQL($sql,"artica_events"); if(!$q->ok){echo $q->mysql_error_html();} $filze[null]="{select}"; while ($ligne = mysql_fetch_assoc($results)) { $filze[$ligne["filename"]]=$ligne["filename"]; } echo $tpl->_ENGINE_parse_body(field_array_Hash($filze, "filename-$t",null,"style:font-size:18px")); }