function Save() { $acl = new squid_acls_groups(); $DATAS = url_decode_special_tool($_POST["Save"]); $MAIN = explode("\n", $DATAS); while (list($index, $ligne) = each($MAIN)) { if (strpos($ligne, ";") == 0) { echo "{$ligne} -> FALSE ERR." . __LINE__ . "\n"; continue; } $tr = explode(";", $ligne); if (count($tr) < 2) { echo "{$ligne} -> FALSE\n"; continue; } $GroupName = $tr[0]; $Categories = explode(",", $tr[1]); if ($Categories[0] == null) { echo "{$ligne} -> FALSE ERR." . __LINE__ . "\n"; continue; } $gpid = GetADGroupID($GroupName); echo "{$GroupName} ID {$gpid}\n"; if ($gpid == 0) { echo "{$ligne} -> FALSE ERR." . __LINE__ . "\n"; continue; } $Category_groupnane = "{$GroupName} - categories"; $CategoryID = GetCategoryGroupID($GroupName); if ($CategoryID == 0) { echo "{$ligne} -> FALSE ERR." . __LINE__ . "\n"; continue; } FillCategoryItems($CategoryID, $Categories); $RuleName = "{$GroupName} - categories"; $RuleID = GetRuleID($RuleName); if ($RuleID == 0) { echo "{$ligne} -> FALSE ERR." . __LINE__ . "\n"; continue; } AssociatesG($RuleID, $gpid, 0); AssociatesG($RuleID, $CategoryID, 1); if (!$acl->aclrule_edittype($RuleID, "url_rewrite_access_allow", 1)) { echo "{$ligne} -> FALSE ERR." . __LINE__ . "\n"; continue; } if (!$acl->aclrule_edittype($RuleID, "url_rewrite_access_deny", 1)) { echo "{$ligne} -> FALSE ERR." . __LINE__ . "\n"; continue; } echo "Associates {$RuleName}[{$RuleID}] to {$CategoryID},{$gpid} ({$Category_groupnane},{$GroupName}) [OK]\n"; } }
function rules_whitelisted_search(){ //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(); $acl=new squid_acls(); $ID=$_GET["ID"]; $t0=$_GET["t"]; $t=$_GET["tt"]; $linked_table="wpad_white_link"; $search='%'; $table="(SELECT $linked_table.gpid, $linked_table.negation, $linked_table.zmd5 as mkey, webfilters_sqgroups.* FROM $linked_table,webfilters_sqgroups WHERE $linked_table.gpid=webfilters_sqgroups.ID AND $linked_table.aclid=$ID) as t"; $page=1; if($q->COUNT_ROWS($linked_table)==0){json_error_show("No datas");} 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 $searchstring"; $ligne=mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; }else{ $sql="SELECT COUNT(*) as TCOUNT FROM $table"; $ligne=mysql_fetch_array($q->QUERY_SQL($sql)); $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); if(!$q->ok){json_error_show($q->mysql_error."\n$sql");} $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if(mysql_num_rows($results)==0){json_error_show($q->mysql_error);} $rules=$tpl->_ENGINE_parse_body("{rules}"); $acl=new squid_acls_groups(); while ($ligne = mysql_fetch_assoc($results)) { $val=0; $mkey=$ligne["mkey"]; $arrayF=$acl->FlexArray($ligne['ID']); $delete=imgsimple("delete-24.png",null,"DeleteObjectLinks$t('$mkey')"); $negation=Field_checkbox("negation-$mkey", 1,$ligne["negation"],"ChangeNegation$t('$mkey')"); $data['rows'][] = array( 'id' => "$mkey", 'cell' => array($arrayF["ROW"], $negation,"<span style='font-size:14px;font-weight:bold'>{$arrayF["ITEMS"]}</span>", $delete) ); } echo json_encode($data); }
function quota_destination_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(); $ID = $_GET["ID"]; $acl = new squid_acls(); $t0 = $_GET["t"]; $search = '%'; $table = "(SELECT webfilters_quotas_grp.gpid,webfilters_quotas_grp.zmd5, webfilters_quotas_grp.ID as LINKID, webfilters_sqgroups.* FROM webfilters_quotas_grp, webfilters_sqgroups WHERE webfilters_quotas_grp.gpid=webfilters_sqgroups.ID AND webfilters_quotas_grp.ruleid={$ID}) as t"; $page = 1; if (!$q->TABLE_EXISTS("webfilters_quotas_grp")) { $q->CheckTables(null, true); } if ($q->COUNT_ROWS("webfilters_quotas_grp") == 0) { json_error_show("No datas"); } 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"]; } 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); if (!$q->ok) { json_error_show($q->mysql_error . "\n{$sql}"); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (mysql_num_rows($results) == 0) { json_error_show("No item"); } $rules = $tpl->_ENGINE_parse_body("{rules}"); $acl = new squid_acls_groups(); while ($ligne = mysql_fetch_assoc($results)) { $val = 0; $ID = $ligne["ID"]; $md5 = $ligne["zmd5"]; $arrayF = $acl->FlexArray($ligne['gpid']); $delete = imgsimple("delete-24.png", null, "DeleteObjectLinks{$t0}('{$md5}')"); $data['rows'][] = array('id' => "{$md5}", 'cell' => array($arrayF["ROW"], "<span style='font-size:14px;font-weight:bold'>{$arrayF["ITEMS"]}</span>", $delete)); } echo json_encode($data); }
function groups($ID) { $q = new mysql_squid_builder(); if ($q->COUNT_ROWS("transparent_networks_groups") == 0) { return array(null, null); } $sql = "SELECT transparent_networks_groups.gpid,\n\ttransparent_networks_groups.zmd5 as mkey,\n\twebfilters_sqgroups.* FROM transparent_networks_groups,webfilters_sqgroups\n\tWHERE transparent_networks_groups.gpid=webfilters_sqgroups.ID \n\tAND transparent_networks_groups.ruleid={$ID}\n\tAND webfilters_sqgroups.enabled=1\n\tAND transparent_networks_groups.enabled=1\n\t"; $results = $q->QUERY_SQL($sql); $acl = new squid_acls_groups(); while ($ligne = mysql_fetch_assoc($results)) { $arrayF = $acl->FlexArray($ligne['ID']); $GroupType = $ligne["GroupType"]; if ($GroupType == "dst") { $f1[] = $arrayF["ROW"]; continue; } if ($GroupType == "port") { $f1[] = $arrayF["ROW"]; continue; } $f[] = $arrayF["ROW"]; } return array(@implode($f, "\n"), @implode($f1, "\n")); }
function items_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(); $ID = $_GET["aclid"]; $t0 = $_GET["t"]; $rp = 50; $search = '%'; $table = "(SELECT meta_webfilters_sqacllinks.gpid,\n\t\tmeta_webfilters_sqacllinks.ID as tid,\n\t\tmeta_webfilters_sqacllinks.negation,\n\t\tmeta_webfilters_sqacllinks.zorder,\n\t\twebfilters_sqgroups.* FROM meta_webfilters_sqacllinks,webfilters_sqgroups\n\t\tWHERE meta_webfilters_sqacllinks.gpid=webfilters_sqgroups.ID AND meta_webfilters_sqacllinks.aclid={$ID}\n\t\tORDER BY meta_webfilters_sqacllinks.zorder\n\t\t) as t"; $page = 1; if ($q->COUNT_ROWS("meta_webfilters_sqacllinks") == 0) { json_error_show("No datas meta_webfilters_sqacllinks Empty"); } 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 {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); if (!$q->ok) { json_error_show($q->mysql_error . "\n{$sql}"); } $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); if (!$q->ok) { json_error_show($q->mysql_error . "\n{$sql}"); } $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); if ($GLOBALS["VERBOSE"]) { echo "{$sql}<br>\n"; } if (!$q->ok) { json_error_show($q->mysql_error . "\n{$sql}"); } $acl = new squid_acls_groups(); $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $CountofRows = mysql_num_rows($results); if ($GLOBALS["VERBOSE"]) { echo "CountofRows = {$CountofRows}<br>\n"; } if ($CountofRows == 0) { json_error_show("No data"); } $rules = $tpl->_ENGINE_parse_body("{rules}"); while ($ligne = mysql_fetch_assoc($results)) { $val = 0; $mkey = $ligne["tid"]; $arrayF = $acl->FlexArray($ligne['ID']); $delete = imgsimple("delete-24.png", null, "DeleteObjectLinks('{$mkey}')"); $negation = Field_checkbox("negation-{$mkey}", 1, $ligne["negation"], "ChangeMetaNegation('{$mkey}')"); $up = imgsimple("arrow-up-16.png", "", "AclGroupUpDown('{$mkey}',0)"); $down = imgsimple("arrow-down-18.png", "", "AclGroupUpDown('{$mkey}',1)"); if ($ligne["torder"] == 1) { $up = null; } if ($ligne["torder"] == 0) { $up = null; } $data['rows'][] = array('id' => "{$mkey}", 'cell' => array($ligne["torder"], $arrayF["ROW"], "<center>{$negation}</center>", "<span style='font-size:14px;font-weight:bold'>{$arrayF["ITEMS"]}</span>", $up, $down, $delete)); } echo json_encode($data); }
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 items_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(); $ID = $_GET["aclid"]; $aclid = $_GET["aclid"]; $acl = new squid_acls(); $t0 = $_GET["t"]; $database = "artica_backup"; $search = '%'; $table = "ext_time_quota_acl_link"; $FORCE_FILTER = null; $page = 1; if ($q->COUNT_ROWS($table, $database) == 0) { json_error_show("No datas"); } $table = "(SELECT * FROM ext_time_quota_acl_link WHERE ruleid={$aclid}) as t"; if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; if (!is_numeric($rp)) { $rp = 50; } $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM {$table} WHERE 1 {$FORCE_FILTER} {$ORDER} {$limitSql}"; if ($GLOBALS["VERBOSE"]) { echo $sql . "<br>\n"; } $results = $q->QUERY_SQL($sql, $database); $total = mysql_num_rows($results); if (!$q->ok) { json_error_show($q->mysql_error . "\n{$sql}"); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (mysql_num_rows($results) == 0) { json_error_show("No item"); } $rules = $tpl->_ENGINE_parse_body("{rules}"); $q2 = new mysql_squid_builder(); $acl = new squid_acls_groups(); if ($_POST["qtype"] == "GroupName") { if ($_POST["query"] != null) { $searchGroupName = string_to_flexregex(); } } while ($ligne = mysql_fetch_assoc($results)) { $val = 0; $mkey = $ligne["zmd5"]; $color = "black"; if ($ligne["enabled"] == 0) { $color = "#8a8a8a"; } $arrayF = $acl->FlexArray($ligne["groupid"], $ligne["enabled"]); $delete = imgsimple("delete-24.png", null, "DeleteObjectLinks{$t0}('{$mkey}')"); $enable = Field_checkbox("enable-{$mkey}", 1, $ligne["enabled"], "ChangeEnabled{$t0}('{$mkey}')"); $data['rows'][] = array('id' => "{$mkey}", 'cell' => array($arrayF["ROW"], "<span style='font-size:14px;font-weight:bold;color:{$color}'>{$arrayF["ITEMS"]}</span>", $enable, $delete)); } echo json_encode($data); }
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); }
function GetGroupsList($ID) { $q = new mysql(); $tpl = new templates(); $sql = "SELECT groupid FROM ext_time_quota_acl_link WHERE ruleid='{$ID}' AND enabled=1"; $results = $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { return $q->mysql_error; } $acl = new squid_acls_groups(); $f = array(); while ($ligne = mysql_fetch_assoc($results)) { $arrayF = $acl->FlexArray($ligne["groupid"], 1, 10); $f[] = "<div style='font-size:9px;margin-left:15px'>{$arrayF["ROW"]} ({$arrayF["ITEMS"]} " . $tpl->_ENGINE_parse_body('{items}') . ")</div>"; } return @implode("\n", $f); }
function buildacls_fromgroup($gpid, $ACLS) { $q = new mysql(); $sql = "SELECT * FROM meta_webfilters_acls WHERE metagroup={$gpid} AND enabled=1 ORDER BY xORDER"; $results = $q->QUERY_SQL($sql, "metaclient"); $mysql_num_rows = mysql_num_rows($results); if ($mysql_num_rows == 0) { echo "Group ID:{$gpid} -> no acls...\n"; return; } $IpClass = new IP(); $aclsGroups = new squid_acls_groups(); $aclsGroups->AsMeta = true; $unix = new unix(); while ($ligne = mysql_fetch_assoc($results)) { $aclname = $ligne["aclname"]; $httpaccess = $ligne["httpaccess"]; $httpaccess_data = $ligne["httpaccess_data"]; $reverse = false; $ID = $ligne["ID"]; $valueToAdd = null; if ($httpaccess == "deny_access_except") { $reverse = true; } echo "aclname[{$ID}]: {$aclname}/{$httpaccess}\n"; if (isset($GLOBALS["ACLRULEXEC"][$ID])) { echo "aclname[{$ID}]: Already executed, skip\n"; continue; } $Groups = $aclsGroups->buildacls_bytype_items($ID, $reverse); if (count($Groups) == 0) { echo "aclname[{$ID}]: no group, skip...\n"; continue; } $GLOBALS["ACLRULEXEC"][$ID] = true; $firstToken = getFirstToken($httpaccess, $httpaccess_data, $ID); $ACLS[] = "{$firstToken} {$valueToAdd}" . @implode(" ", $Groups); } return $ACLS; }
function import_acls_extacl($filename = null, $ARRAY, $aclgpid = 0) { $q = new mysql_squid_builder(); $acl = new squid_acls_groups(); if ($filename != null) { if (is_file($filename)) { $ARRAY = unserialize(base64_decode(@file_get_contents($filename))); } } if (!is_array($ARRAY)) { echo "{$filename}, unable to decode Array()\n"; return; } if (!isset($ARRAY["webfilters_sqacls"])) { echo "{$filename}, unable to decode webfilters_sqacls (" . __LINE__ . ")\n"; return; } if (!is_array($ARRAY["webfilters_sqacls"])) { echo "{$filename}, unable to decode webfilters_sqacls\n"; return; } if (isset($ARRAY["webfilters_sqaclaccess"])) { if (!is_array($ARRAY["webfilters_sqaclaccess"])) { if (!isset($ARRAY["SUBRULES"])) { echo "{$filename}, unable to decode webfilters_sqaclaccess\n"; return; } } } if (!isset($ARRAY["SUBRULES"])) { if (!is_array($ARRAY["webfilters_sqgroups"])) { echo "{$filename}, unable to decode webfilters_sqgroups\n"; return; } } $keys = array(); $values = array(); while (list($key, $value) = each($ARRAY["webfilters_sqacls"])) { $keys[] = "`{$key}`"; $values[] = "'" . mysql_escape_string2($value) . "'"; } if ($aclgpid > 0) { echo "Prepare SUB-ACL Master ACL:{$aclgpid}\n"; $keys[] = "`aclgpid`"; $values[] = "'{$aclgpid}'"; } $sql = "INSERT IGNORE INTO webfilters_sqacls (" . @implode(",", $keys) . ") VALUES (" . @implode(",", $values) . ")"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error . "\n{$sql}\n"; return; } $ACLID = $q->last_id; echo "*** New ACL {$ACLID} ***\n"; if (isset($ARRAY["SUBRULES"])) { if (is_array($ARRAY["SUBRULES"])) { while (list($index, $arrayrule) = each($ARRAY["SUBRULES"])) { if ($GLOBALS["VERBOSE"]) { echo "import_acls_extacl(null,{$arrayrule},{$ACLID})\n"; } import_acls_extacl(null, $arrayrule, $ACLID); } } } $keys = array(); $values = array(); if (isset($ARRAY["webfilters_sqaclaccess"])) { $acl->aclrule_edittype($ACLID, $ARRAY["webfilters_sqaclaccess"]["httpaccess"], $ARRAY["webfilters_sqaclaccess"]["httpaccess_value"]); echo "New sqaclaccess for {$ACLID} {$ARRAY["webfilters_sqaclaccess"]["httpaccess"]}\n"; } if (isset($ARRAY["webfilters_sqgroups"])) { while (list($index, $grouparray) = each($ARRAY["webfilters_sqgroups"])) { $GROUP_ARRAY = $grouparray["GROUP"]; $GROUP_ITEMS = $grouparray["ITEMS"]; $GROUP_DYN = $grouparray["DYN"]; $keys = array(); $values = array(); while (list($key, $value) = each($GROUP_ARRAY)) { $keys[] = "`{$key}`"; $values[] = "'" . mysql_escape_string2($value) . "'"; } $sql = "INSERT IGNORE INTO webfilters_sqgroups (" . @implode(",", $keys) . ") VALUES (" . @implode(",", $values) . ")"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error . "\n{$sql}\n"; return; } $GPID = $q->last_id; $GROUPSACLS[$GPID] = true; while (list($index, $itemsArray) = each($GROUP_ITEMS)) { $keys = array(); $values = array(); while (list($key, $value) = each($itemsArray)) { $keys[] = "`{$key}`"; $values[] = "'" . mysql_escape_string2($value) . "'"; } $keys[] = "`gpid`"; $values[] = "{$GPID}"; $sql = "INSERT IGNORE INTO webfilters_sqitems (" . @implode(",", $keys) . ") VALUES (" . @implode(",", $values) . ")"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error . "\n{$sql}\n"; return; } } if (count($GROUP_DYN) > 0) { $keys = array(); $values = array(); while (list($key, $value) = each($GROUP_DYN)) { $keys[] = "`{$key}`"; $values[] = "'" . mysql_escape_string2($value) . "'"; } $keys[] = "`gpid`"; $values[] = "{$GPID}"; $sql = "INSERT IGNORE INTO webfilter_aclsdynamic (" . @implode(",", $keys) . ") VALUES (" . @implode(",", $values) . ")"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error . "\n{$sql}\n"; return; } } } while (list($gpid, $value) = each($GROUPSACLS)) { echo "Linking ACL {$ACLID} with group {$gpid}\n"; $md5 = md5($ACLID . $gpid); $sql = "INSERT IGNORE INTO webfilters_sqacllinks (zmd5,aclid,gpid) VALUES('{$md5}','{$ACLID}','{$gpid}')"; $q->QUERY_SQL($sql); } } }
function items_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(); $ID = $_GET["aclid"]; $acl = new squid_acls(); $t0 = $_GET["t"]; $FORCE_FILTER = null; $search = '%'; $table = "(SELECT firewallfilter_sqacllinks.gpid,firewallfilter_sqacllinks.negation,\n\tfirewallfilter_sqacllinks.zOrder,firewallfilter_sqacllinks.zmd5 as mkey,\n\twebfilters_sqgroups.* FROM firewallfilter_sqacllinks,webfilters_sqgroups \n\tWHERE firewallfilter_sqacllinks.gpid=webfilters_sqgroups.ID \n\tAND firewallfilter_sqacllinks.aclid={$ID}\n\tAND firewallfilter_sqacllinks.direction='{$_GET["direction"]}'\n\tORDER BY firewallfilter_sqacllinks.zOrder\n\t) as t"; $page = 1; if ($q->COUNT_ROWS("firewallfilter_sqacllinks") == 0) { json_error_show("No datas"); } 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"]; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; if ($OnlyEnabled) { $limitSql = null; } $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { json_error_show($q->mysql_error . "\n{$sql}"); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (mysql_num_rows($results) == 0) { json_error_show($q->mysql_error); } $rules = $tpl->_ENGINE_parse_body("{rules}"); $acl = new squid_acls_groups(); while ($ligne = mysql_fetch_assoc($results)) { $val = 0; $mkey = $ligne["mkey"]; $arrayF = $acl->FlexArray($ligne['ID'], 1, 18); $delete = imgsimple("delete-32.png", null, "DeleteObjectLinks('{$mkey}')"); $negation = Field_checkbox("negation-{$mkey}", 1, $ligne["negation"], "ChangeNegation('{$mkey}')"); $up = imgsimple("arrow-up-32.png", "", "AclGroupUpDown('{$mkey}',0)"); $down = imgsimple("arrow-down-32.png", "", "AclGroupUpDown('{$mkey}',1)"); if ($ligne["zOrder"] == 1) { $up = null; } if ($ligne["zOrder"] == 0) { $up = null; } $data['rows'][] = array('id' => "{$mkey}", 'cell' => array("<center style='font-size:18px;font-weight:bold'>{$ligne["zOrder"]}</center>", $arrayF["ROW"], $negation, "<span style='font-size:18px;font-weight:bold'>{$arrayF["ITEMS"]}</span>", "<center>{$up}</center>", "<center>{$down}</center>", "<center>{$delete}</center>")); } echo json_encode($data); }
function search() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $sock = new sockets(); $t = $_GET["t"]; $search = '%'; $table = "ssl_rules"; $page = 1; $FORCE_FILTER = null; $total = 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 { $total = $q->COUNT_ROWS($table); } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; if (is_numeric($rp)) { $limitSql = "LIMIT {$pageStart}, {$rp}"; } $sql = "SELECT * FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql); $no_rule = $tpl->_ENGINE_parse_body("{no_rule}"); $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { json_error_show($q->mysql_error . "<br>{$sql}"); } if (mysql_num_rows($results) == 0) { json_error_show("!!! no data"); } $uncrypt_ssl = $tpl->javascript_parse_text("{uncrypt_ssl}"); $pass_ssl = $tpl->javascript_parse_text("{pass_connect_ssl}"); $error_firwall_not_configured = $tpl->javascript_parse_text("{error_firwall_not_configuredisquid}"); $trust_ssl = $tpl->javascript_parse_text("{trust_ssl}"); $tpl = new templates(); $all = $tpl->javascript_parse_text("{all}"); $and_text = $tpl->javascript_parse_text("{and}"); $edit = $tpl->javascript_parse_text("{edit}"); $squid_acls_groups = new squid_acls_groups(); while ($ligne = mysql_fetch_assoc($results)) { $color = "black"; $ID = $ligne["ID"]; $explain = null; $delete = imgsimple("delete-32.png", null, "Loadjs('{$MyPage}?delete-rule-js=yes&ID={$ID}&t={$_GET["t"]}',true)"); $edit_group = null; $crypt = $ligne["crypt"]; $rulename = utf8_encode($ligne["description"]); $uncrypt_ssl_text = $pass_ssl; $ssl_img = "ok32-grey.png"; $enabled_img = "ok-32.png"; $TTEXT = array(); if ($crypt == 1) { $uncrypt_ssl_text = $uncrypt_ssl; $ssl_img = "ok-32.png"; } if ($ligne["enabled"] == 0) { $color = "#A0A0A0"; $enabled_img = "ok32-grey.png"; $ssl_img = "ok32-grey.png"; } $EditJs = "<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:Loadjs('{$MyPage}?rule-id-js={$ID}&t={$_GET["t"]}');\"\n\t\t\tstyle='font-size:18px;font-weight:normal;color:{$color};text-decoration:underline'>"; $TTEXT[] = $uncrypt_ssl_text; if ($ligne["trust"] == 1) { $TTEXT[] = $trust_ssl; } $objects = $squid_acls_groups->getobjectsNameFromAclrule($ID, $color, "sslrules_sqacllinks", 16); if ($objects > 0) { $explain = $tpl->_ENGINE_parse_body("{for_objects} " . @implode(" <br>{and} ", $objects) . "<br>{then} {$EditJs}" . @implode($and_text, $TTEXT) . "</a>"); } $data['rows'][] = array('id' => $ID, 'cell' => array("<span style='font-size:18px;font-weight:normal;color:{$color}'>{$EditJs}{$rulename}</a>:<br><span style='font-size:16px !important'>{$explain}</span></span>", "<center style='margin-top:3px;font-size:30px;font-weight:normal;color:{$color}'><img src='img/{$ssl_img}'></a></center>", "<center style='margin-top:3px;font-size:30px;font-weight:normal;color:{$color}'><img src='img/{$enabled_img}'></center>", "<center style='margin-top:3px;font-size:30px;font-weight:normal;color:{$color}'>{$delete}</center>")); } echo json_encode($data); }
function import_http_access($line, $xORDER) { if (!preg_match("#(http_access|http_reply_access)\\s+(allow|deny)\\s+(.+)#", $line, $re)) { echo "`{$line}` -ERR- unable to understand this rule\n"; return; } $PortDirectionS["proxy_auth_ads"] = 1; $q = new mysql_squid_builder(); $PortDirection = 0; $re[2] = trim($re[2]); $re[3] = trim($re[3]); $GroupsX = explode(" ", $re[3]); $GPS = array(); while (list($index, $gptmp) = each($GroupsX)) { $gptmp = trim($gptmp); $gpName = null; $negation = false; $Alternate = null; if ($gptmp == null) { continue; } if (substr($gptmp, 0, 1) == "!") { $gptmp = substr($gptmp, 1, strlen($gptmp)); $negation = true; } if ($gptmp == "all") { continue; } $sql = "SELECT ID,GroupType FROM webfilters_sqgroups WHERE GroupName='{$gptmp}'"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); if ($ligne["ID"] == 0) { $Alternate = external_acl_find($gptmp); if ($Alternate != null) { $gptmp = $Alternate; $sql = "SELECT ID,GroupType FROM webfilters_sqgroups WHERE GroupName='{$Alternate}'"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); } } if ($ligne["ID"] == 0) { echo " -ERR- Unable to find group id from `{$gptmp}`\n"; continue; } if (isset($PortDirectionS[$ligne["GroupType"]])) { $PortDirection = $PortDirectionS[$ligne["GroupType"]]; } $GroupLogs[] = " {$gptmp} id:{$ligne["ID"]}"; $Groups[$ligne["ID"]] = $negation; if ($negation) { $gpName = "not "; } $gpName = $gpName . $gptmp; $GPS[] = $gpName; } if (count($GPS) == 0) { echo "`{$line}` -ERR- no associated groups\n"; return; } $DenyAllow = $re[2]; $aclType = trim($re[1]); $aclname2 = trim(@implode(" ", $GPS)); $aclname = "{$DenyAllow} {$aclname2}"; $TRANS["http_access"]["deny"] = "access_deny"; $TRANS["http_access"]["allow"] = "access_allow"; $TRANS["http_reply_access"]["deny"] = "http_reply_access_deny"; $TRANS["http_reply_access"]["allow"] = "http_reply_access_allow"; $acl_type = $TRANS[$aclType][$DenyAllow]; if ($acl_type == null) { echo " {$aclname} -> -ERR- Unable to understand {$aclType}/{$DenyAllow}\n"; return; } echo "Acl Name `{$aclname}`"; $sql = "SELECT ID FROM webfilters_sqacls WHERE aclname='{$aclname}'"; //if(isset($_POST["PortDirection"])){$PortDirection=",`PortDirection`='{$_POST["PortDirection"]}'";} $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); if ($ligne["ID"] > 0) { $aclid = $ligne["ID"]; $q->QUERY_SQL("UPDATE webfilters_sqacls SET xORDER='{$xORDER}',PortDirection={$PortDirection} WHERE ID='{$aclid}'"); echo " {$aclid} (edited) [" . @implode(" ", $GroupLogs) . "]"; } else { $sql = "INSERT INTO webfilters_sqacls (aclname,enabled,acltpl,xORDER,aclport,aclgroup,aclgpid,PortDirection) VALUES ('{$aclname}',1,'','{$xORDER}','0','0','0','{$PortDirection}')"; $q->QUERY_SQL($sql); if (!$q->ok) { echo " {$aclname} -> -ERR- !!\n{$q->mysql_error}\n"; return; } $aclid = $q->last_id; echo " ID:{$aclid} (added) [" . @implode(" ", $GroupLogs) . "]"; } $acl = new squid_acls_groups(); if (!$acl->aclrule_edittype($aclid, $acl_type, 1)) { echo " {$aclname} -> aclrule_edittype -> -ERR- !!\n{$q->mysql_error}\n"; return; } $c = 0; while (list($gpid, $negation) = each($Groups)) { $xnegation = 0; $md5 = md5($aclid . $gpid); if ($negation) { $xnegation = 1; } $sql = "INSERT IGNORE INTO webfilters_sqacllinks (zmd5,aclid,gpid,negation) VALUES('{$md5}','{$aclid}','{$gpid}','{$xnegation}')"; $q->QUERY_SQL($sql); if (!$q->ok) { echo " -ERR- Group:{$gpid} on rule {$aclid} Line:" . __LINE__ . " {$q->mysql_error}\n"; continue; } $c++; } echo " Linked to {$c} Group(s) Done..\n"; }