function acl_list() { //ini_set('html_errors',0);ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string','');ini_set('error_append_string',''); $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $boot = new boostrap_form(); $RULEID = $_GET["RULEID"]; $t = $_GET["t"]; $search = '%'; $table = "webfilters_sqacls"; $page = 1; $data = array(); $data['rows'] = array(); $sock = new sockets(); $gliff = "<i class='icon-ok'></i>"; $EnableSquidPortsRestrictions = $sock->GET_INFO("EnableSquidPortsRestrictions"); if (!is_numeric($EnableSquidPortsRestrictions)) { $EnableSquidPortsRestrictions = 0; } $ORDER = "ORDER BY xORDER ASC"; if (!is_numeric($_GET["t"])) { $_GET["t"] = time(); } $searchstring = string_to_flexquery("search-rule"); $default = $tpl->_ENGINE_parse_body("{default}"); $ports_restrictions = $tpl->_ENGINE_parse_body("{ports_restrictions}"); $http_safe_ports = $tpl->_ENGINE_parse_body("{http_safe_ports}"); $deny_ports_expect = $tpl->_ENGINE_parse_body("{deny_ports_expect}"); $q2 = new mysql(); $items = $q2->COUNT_ROWS("urlrewriteaccessdeny", "artica_backup"); $explain = $tpl->_ENGINE_parse_body("{urlrewriteaccessdeny_explain} <br><strong>{$items} {items}</strong>"); $delete_rule_ask = $tpl->javascript_parse_text("{delete_rule_ask}"); $WHERE = "`aclport`=0 AND aclgpid=0"; if (!is_numeric($_GET["listen-port"])) { $_GET["listen-port"] = 0; } if ($_GET["listen-port"] > 0) { $q = new mysql_squid_builder(); $WHERE = "`aclport`={$_GET["listen-port"]}"; $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT enabled FROM webfilters_sqaclsports WHERE aclport='{$_GET["listen-port"]}'")); if (!$q->ok) { if (preg_match("#Unknown column#", $q->mysql_error)) { $q->CheckTables(); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT enabled FROM webfilters_sqaclsports WHERE aclport='{$_GET["listen-port"]}'")); } } if (!$q->ok) { $error_explain = "<p class=text-error>{$q->mysql_error}</p>"; } if ($ligne["enabled"] == 0) { $error_explain = "<p class=text-error>{this_rule_is_disabled}</p>"; } } if ($searchstring == null) { if ($_GET["listen-port"] == 0) { $link = $boot->trswitch("Loadjs('squid.urlrewriteaccessdeny.php?t={$_GET["t"]}')"); $tr[] = "\n\t\t\t<tr id='aclNone1'>\n\t\t\t\t<td {$link}>{$gliff} {$default}</td>\n\t\t\t\t<td {$link}><i class='icon-info-sign'></i> {$explain}</td>\n\t\t\t\t<td {$link}> </td>\n\t\t\t\t<td {$link}> </td>\n\t\t\t\t<td> </td>\n\t\t\t\t<td> </td>\n\t\t\t\t<td> </td>\n\t\t\t</tr>"; $ports = unserialize(base64_decode($sock->GET_INFO("SquidSafePortsSSLList"))); if (is_array($ports)) { while (list($port, $explain) = each($ports)) { $bbcSSL[] = $port; } } $ports = unserialize(base64_decode($sock->GET_INFO("SquidSafePortsList"))); if (is_array($ports)) { while (list($port, $explain) = each($ports)) { $bbcHTTP[] = $port; } } $color = "black"; $colored = "#A71A05"; if ($EnableSquidPortsRestrictions == 0) { $color = "#8a8a8a"; $colored = $color; } $sslp = "{$deny_ports_expect}: {$http_safe_ports} SSL: " . @implode(", ", $bbcSSL); $http = "{$deny_ports_expect}: {$http_safe_ports}: " . @implode(", ", $bbcHTTP); $enableSSL = Field_checkbox("EnableSquidPortsRestrictions", 1, $EnableSquidPortsRestrictions, "EnableSquidPortsRestrictionsCK()"); $link = $boot->trswitch("Loadjs('squid.advParameters.php?t={$_GET["t"]}&OnLyPorts=yes');"); $tr[] = "\n\t\t\t<tr id='aclNone2'>\n\t\t\t\t<td {$link}>{$gliff} <span style='color:{$color}'>{$default}</span></td>\n\t\t\t\t<td {$link}><i class='icon-info-sign'></i> <span style='color:{$color}'> {$ports_restrictions}\n\t\t\t\t<span style='color:{$colored};font-weight:bold'><div>{$sslp}</div><div>{$http}</div></span>\n\t\t\t\t</td>\n\t\t\t\t<td {$link}> </td>\n\t\t\t\t<td {$link}> </td>\n\t\t\t\t<td> </td>\n\t\t\t\t<td> </td>\n\t\t\t\t<td> </td>\n\t\t\t</tr>"; } } $rp = 50; $sql = "SELECT * FROM `{$table}` WHERE {$WHERE} {$searchstring} {$ORDER}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql); if (!$q->ok) { json_error_show("{$q->mysql_error}"); } $acls = new squid_acls_groups(); $order = $tpl->_ENGINE_parse_body("{order}:"); while ($ligne = mysql_fetch_assoc($results)) { $gliff = "<i class='icon-ok'></i>"; $val = 0; $color = "black"; $disable = Field_checkbox("aclid_{$ligne['ID']}", 1, $ligne["enabled"], "EnableDisableAclRule{$t}('{$ligne['ID']}')"); $ligne['aclname'] = utf8_encode($ligne['aclname']); $delete = imgsimple("delete-24.png", null, "DeleteSquidAclRule('{$ligne['ID']}')"); if ($ligne["enabled"] == 0) { $color = "#8a8a8a"; $gliff = null; } $explain = $tpl->_ENGINE_parse_body($acls->ACL_MULTIPLE_EXPLAIN($ligne['ID'], $ligne["enabled"], $ligne["aclgroup"], true)); $up = imgsimple("arrow-up-16.png", "", ""); $down = imgsimple("arrow-down-18.png", "", ""); $export = imgsimple("24-export.png", "", "Loadjs('squid.acls.export.php?single-id={$ligne['ID']}')"); $link = $boot->trswitch("Loadjs('squid.acls-rules.php?Addacl-js=yes&ID={$ligne['ID']}&t={$_GET["t"]}');"); $tr[] = "\n\t\t<tr id='acl{$ligne['ID']}'>\n\t\t<td {$link} nowrap>{$gliff} <span style='color:{$color}'>{$ligne['aclname']}</span></td>\n\t\t<td ><i class='icon-info-sign'></i> <span style='color:{$color}'> {$explain}</td>\n\t\t<td width=1% " . $boot->trswitch("AclUpDown('{$ligne['ID']}',1)") . ">{$up}</td>\n\t\t<td width=1% " . $boot->trswitch("AclUpDown('{$ligne['ID']}',0)") . ">{$down}</td>\n\t\t<td width=1% align='center' style='text-align:center'>{$disable}</td>\n\t\t<td width=1% align='center' style='text-align:center'>{$export}</td>\n\t\t<td width=1% align='center' style='text-align:center'>{$delete}</td>\n\t\t</tr>"; } echo $tpl->_ENGINE_parse_body("\n\t{$error_explain}\n\t\t<table class='table table-bordered table-hover'>\n\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{rule}</th>\n\t\t\t\t\t<th>{description}</th>\n\t\t\t\t\t<th colspan=2>{order}</th>\n\t\t\t\t\t<th> </th>\n\t\t\t\t\t<th> </th>\n\t\t\t\t\t<th> </th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t") . @implode("\n", $tr) . " </tbody>\n\t\t\t\t</table>\n<script>\nvar DeleteSquidAclGroupTemp='';\n\n\tvar x_EnableDisableAclRule{$t}= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif(res.length>3){alert(res);return;}\n\t\tExecuteByClassName('SearchFunction');\n\t}\n\t\n\tvar x_DeleteSquidAclRule{$t}= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif(res.length>3){alert(res);return;}\n\t\t\$('#acl'+DeleteSquidAclGroupTemp).remove();\n\t}\t\n\t\n\t\n\tfunction DeleteSquidAclRule(ID){\n\t\tDeleteSquidAclGroupTemp=ID;\n\t\tif(confirm('{$delete_rule_ask} :'+ID)){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('acl-rule-delete', ID);\n\t\t\tXHR.sendAndLoad('squid.acls-rules.php', 'POST',x_DeleteSquidAclRule{$t});\n\t\t} \t\t\n\t}\n\n\tfunction AclUpDown(ID,dir){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('acl-rule-move', ID);\n\t\t\tXHR.appendData('acl-rule-dir', dir);\n\t\t\tXHR.sendAndLoad('squid.acls-rules.php', 'POST',x_EnableDisableAclRule{$t}); \t\n\t\t}\t\n\n\tfunction EnableDisableAclRule{$t}(ID){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('acl-rule-enable', ID);\n\t\tif(document.getElementById('aclid_'+ID).checked){XHR.appendData('enable', '1');}else{XHR.appendData('enable', '0');}\n\t\tXHR.sendAndLoad('squid.acls-rules.php', 'POST',x_EnableDisableAclRule{$t}); \t\t\n\t}\t\n\n</script>"; }
function acl_list() { //ini_set('html_errors',0);ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string','');ini_set('error_append_string',''); $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $sock = new sockets(); $RULEID = $_GET["RULEID"]; $GROUPE_RULE_ID = $_GET["aclgroup-id"]; if (!is_numeric($GROUPE_RULE_ID)) { $GROUPE_RULE_ID = 0; } $t = $_GET["t"]; $search = '%'; $table = "webfilters_sqacls"; $GROUPE_RULE_ID_NEW_RULE = null; $page = 1; $data = array(); $data['rows'] = array(); $sock = new sockets(); $EnableSquidPortsRestrictions = $sock->GET_INFO("EnableSquidPortsRestrictions"); if (!is_numeric($EnableSquidPortsRestrictions)) { $EnableSquidPortsRestrictions = 0; } if ($GROUPE_RULE_ID > 0) { $FORCE_FILTER = " AND aclgpid={$GROUPE_RULE_ID}"; } else { $FORCE_FILTER = " AND aclgpid=0"; } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } $searchstring = string_to_flexquery(); if ($searchstring != null) { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER} {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"] + 1; $default = $tpl->_ENGINE_parse_body("{default}"); $default2 = $tpl->_ENGINE_parse_body("{blacklist}"); $ports_restrictions = $tpl->_ENGINE_parse_body("{ports_restrictions}"); $http_safe_ports = $tpl->_ENGINE_parse_body("{http_safe_ports}"); $deny_ports_expect = $tpl->_ENGINE_parse_body("{deny_ports_expect}"); $q2 = new mysql(); $items = $q2->COUNT_ROWS("urlrewriteaccessdeny", "artica_backup"); $items2 = $q->COUNT_ROWS("deny_websites"); $explain = $tpl->_ENGINE_parse_body("{urlrewriteaccessdeny_explain} <strong>{$items} {items}</strong>"); $explain2 = $tpl->_ENGINE_parse_body("{blocked_sites_acl_explain} <strong>{$items2} {items}</strong>"); $font_size = 20; $data['rows'][] = array('id' => "aclNone1", 'cell' => array("<a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:Loadjs('squid.urlrewriteaccessdeny.php?t={$_GET["t"]}');\"\n\t\t\t\tstyle='font-size:20px;text-decoration:underline;color:black'>{$default}</span></A>\n\t\t\t\t", "<span style='font-size:18px;color:black'>{$explain}</span>", " ", " ", " ", " ", " ")); $data['rows'][] = array('id' => "aclNone2", 'cell' => array("<a href=\"javascript:blur();\"\n\t\t\t\t\t\tOnClick=\"javascript:Loadjs('squid.www-blacklist.php?t={$_GET["t"]}');\"\n\t\t\t\t\t\tstyle='font-size:20px;text-decoration:underline;color:black'>{$default2}</span></A>\n\t\t\t\t\t\t", "<span style='font-size:18px;color:black'>{$explain2}</span>", " ", " ", " ", " ", " ")); $color = "black"; $colored = "#0AAB3D"; $ports = unserialize(base64_decode($sock->GET_INFO("SquidSafePortsSSLList"))); if (is_array($ports)) { while (list($port, $explain) = each($ports)) { $bbcSSL[] = $port; } } $ports = unserialize(base64_decode($sock->GET_INFO("SquidSafePortsList"))); if (is_array($ports)) { while (list($port, $explain) = each($ports)) { $bbcHTTP[] = $port; } } $color = "black"; $colored = "#A71A05"; if ($EnableSquidPortsRestrictions == 0) { $color = "#8a8a8a"; $colored = $color; } $sslp = "{$deny_ports_expect}: {$http_safe_ports} SSL: " . @implode(", ", $bbcSSL); $http = "{$deny_ports_expect}: {$http_safe_ports}: " . @implode(", ", $bbcHTTP); $enableSSL = Field_checkbox("EnableSquidPortsRestrictions", 1, $EnableSquidPortsRestrictions, "EnableSquidPortsRestrictionsCK()"); $data['rows'][] = array('id' => "aclNone2", 'cell' => array("<a href=\"javascript:blur();\"\n\t\t\t\t\t\tOnClick=\"javascript:Loadjs('squid.advParameters.php?t={$_GET["t"]}&OnLyPorts=yes');\"\n\t\t\t\t\t\tstyle='font-size:20px;text-decoration:underline;color:{$color}'>{$ports_restrictions}</span></A>\n\t\t\t\t\t\t", "<span style='font-size:18px;color:{$colored};font-weight:bold'><div>{$sslp}</div><div>{$http}</div></span>", " ", " ", "{$enableSSL}", " ", " ")); } $rp = 50; if (isset($_POST['rp'])) { $rp = $_POST['rp']; } // Reset for acl group if ($GROUPE_RULE_ID > 0) { $data['rows'] = array(); $total = 0; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql); if (!$q->ok) { json_error_show("{$q->mysql_error}"); } $font_size = 18; if (isset($_GET["aclgroup-id"])) { if (is_numeric($_GET["aclgroup-id"])) { if ($_GET["aclgroup-id"] > 0) { $font_size = 15; } } } $data['page'] = $page; $data['total'] = $total; $c = 0; $acls = new squid_acls_groups(); $order = $tpl->_ENGINE_parse_body("{order}:"); while ($ligne = mysql_fetch_assoc($results)) { $c++; $val = 0; $color = "black"; $disable = Field_checkbox("aclid_{$ligne['ID']}", 1, $ligne["enabled"], "EnableDisableAclRule{$t}('{$ligne['ID']}')"); $ligne['aclname'] = utf8_encode($ligne['aclname']); $delete = imgsimple("delete-42.png", null, "DeleteSquidAclRule('{$ligne['ID']}')"); if ($ligne["enabled"] == 0) { $color = "#8a8a8a"; } $explain = $tpl->_ENGINE_parse_body($acls->ACL_MULTIPLE_EXPLAIN($ligne['ID'], $ligne["enabled"], $ligne["aclgroup"])); $up = imgsimple("arrow-up-42.png", "", "AclUpDown('{$ligne['ID']}',1)"); $down = imgsimple("arrow-down-42.png", "", "AclUpDown('{$ligne['ID']}',0)"); $export = imgsimple("42-export.png", "", "Loadjs('squid.acls.export.php?single-id={$ligne['ID']}')"); if ($GROUPE_RULE_ID > 0) { $export = null; } $data['rows'][] = array('id' => "acl{$ligne['ID']}", 'cell' => array("<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('{$MyPage}?Addacl-js=yes&ID={$ligne['ID']}&t={$_GET["t"]}');\" \n\t\tstyle='font-size:{$font_size}px;text-decoration:underline;color:{$color}'>{$ligne['aclname']}</span></A>\n\t\t<div style='font-size:14px'><i>{$order}«<a href=\"javascript:blur();\"\n\t\tOnclick=\"javascript:ChangeRuleOrder({$ligne['ID']},{$ligne["xORDER"]});\"\n\t\tstyle=\"text-decoration:underline\">{$ligne["xORDER"]}</a>»</i></div>", "<span style='font-size:{$font_size}px;color:{$color}'>{$explain}</span>", "<center>{$up}</center>", "<center>{$down}</center>", "<center>{$disable}</center>", "<center>{$export}</center>", "<center>{$delete}</center>")); } if ($GROUPE_RULE_ID > 0) { $data['total'] = $c; } echo json_encode($data); }