function groups_list() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $tpl = new templates(); $dump_group_text = $tpl->_ENGINE_parse_body("{dump_group}"); $page = 1; $t = $_GET["t"]; $table = "(SELECT webfilter_assoc_groups.ID,webfilter_assoc_groups.webfilter_id,\n\twebfilter_group.groupname,\n\twebfilter_group.description,\n\twebfilter_group.gpid,\n\twebfilter_group.localldap,\n\twebfilter_group.ID as webfilter_group_ID,\n\twebfilter_group.dn as webfilter_group_dn,\n\twebfilter_group.enabled\n\tFROM webfilter_group,webfilter_assoc_groups \n\tWHERE webfilter_assoc_groups.webfilter_id={$_GET["rule-id"]}\n\tAND webfilter_assoc_groups.group_id=webfilter_group.ID\n\tORDER BY webfilter_group.groupname) as t"; if ($_GET["QuotaID"] > 0) { if (!$q->TABLE_EXISTS("webfilter_assoc_quota_groups")) { $q->CheckTables(null, true); } $table = "(SELECT webfilter_assoc_quota_groups.ID,webfilter_assoc_quota_groups.webfilter_id,\n\t\twebfilter_group.groupname,\n\t\twebfilter_group.description,\n\t\twebfilter_group.gpid,\n\t\twebfilter_group.localldap,\n\t\twebfilter_group.ID as webfilter_group_ID,\n\t\twebfilter_group.dn as webfilter_group_dn,\n\t\twebfilter_group.enabled\n\t\tFROM webfilter_group,webfilter_assoc_quota_groups\n\t\tWHERE webfilter_assoc_quota_groups.webfilter_id={$_GET["QuotaID"]}\n\t\tAND webfilter_assoc_quota_groups.group_id=webfilter_group.ID\n\t\tORDER BY webfilter_group.groupname) as t"; } $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, 1); } $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, 1); } $total = $ligne["TCOUNT"]; } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } $localldap[0] = "{ldap_group}"; $localldap[1] = "{virtual_group}"; $localldap[2] = "{active_directory_group}"; $localldap[3] = "{remote_ladp_group}"; $isDynamic = isDynamic($_GET["rule-id"]); 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}"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { json_error_show($q->mysql_error, 1); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); 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 "<strong>" . __LINE__ . " </strong><br>\n"; } if (mysql_num_rows($results) == 0) { json_error_show("no data", 1); } while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $textExplainGroup = null; $KEY_ID_GROUP = $ligne["webfilter_group_ID"]; $delete = "<a href=\"javascript:blur();\" \n\t\tOnClick=\"javascript:UnlinkFilterGroup('{$ligne["ID"]}')\"><img src='img/delete-32.png' style='border:0px'></a>"; $color = "black"; $CountDeMembers = "??"; $Textdynamic = null; if ($GLOBALS["VERBOSE"]) { echo "<strong>" . __LINE__ . " localldap:{$ligne["localldap"]}</strong><br>\n"; } if ($ligne["localldap"] == 0) { $gp = new groups($ligne["gpid"]); $groupadd_text = "(" . $gp->groupName . ")"; $CountDeMembers = count($gp->members); } if ($ligne["localldap"] == 1) { $sql = "SELECT COUNT(ID) as tcount FROM webfilter_members WHERE `groupid`='{$KEY_ID_GROUP}'"; $COUNLIGNE = mysql_fetch_array($q->QUERY_SQL($sql)); $CountDeMembers = $COUNLIGNE["tcount"]; if ($isDynamic) { $color = "#9A9A9A"; $Textdynamic = $tpl->_ENGINE_parse_body("<div style='font-weight:bold;color:#E40F0F'>{ufdb_no_dynamic_group}</div>"); } } if ($GLOBALS["VERBOSE"]) { print_r($ligne); } if ($ligne["enabled"] == 0) { $color = "#9A9A9A"; } if ($ligne["localldap"] == 2) { if (preg_match("#AD:(.*?):(.+)#", $ligne["webfilter_group_dn"], $re)) { $dnEnc = $re[2]; $LDAPID = $re[1]; $ad = new ActiveDirectory($LDAPID); if ($ad->UseDynamicGroupsAcls == 1) { if (preg_match("#^CN=(.+?),.*#i", base64_decode($dnEnc), $re)) { $groupname = _ActiveDirectoryToName($re[1]); $CountDeMembers = '-'; $Debug = " <a href=\"javascript:Loadjs('dansguardian2.explodeadgroup.php?rule-id={$_GET["rule-id"]}&groupid={$KEY_ID_GROUP}');\"\n\t\t\t\t\t\tstyle=\"text-decoration:underline\">{$dump_group_text}</a>"; } } else { $tty = $ad->ObjectProperty(base64_decode($dnEnc)); $CountDeMembers = $tty["MEMBERS"]; } $description = htmlentities($tty["description"]); $description = str_replace("'", "`", $description); if (trim($ligne["description"]) == null) { $ligne["description"] = $description; } } } if ($ligne["localldap"] == 0) { if (preg_match("#^ExtLdap:(.+)#", $ligne["webfilter_group_dn"], $re)) { $CountDeMembers = '-'; $groupadd_text = " {$re[1]}"; } } if ($ligne["localldap"] == 3) { if (preg_match("#ExtLDAP:(.+?):(.+)#", $ligne["groupname"], $re)) { $ligne["groupname"] = $re[1]; } $DN = base64_decode($re[2]); $ldap_ext = new ldap_extern(); $CountDeMembers = $ldap_ext->CountDeUsersByGroupDN($DN); } $imgGP = "win7groups-32.png"; if ($ligne["localldap"] < 2) { $imgGP = "group-32.png"; } if ($Textdynamic != null) { $imgGP = "warning-panneau-32.png"; } $TextGroupType = $tpl->_ENGINE_parse_body($localldap[$ligne["localldap"]]); $jsSelect = "Loadjs('dansguardian2.edit.group.php?ID-js={$KEY_ID_GROUP}&t={$t}&YahooWin=4');"; $data['rows'][] = array('id' => "group{$ligne["ID"]}", 'cell' => array("<a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:{$jsSelect}\" \n\t\t\t\tstyle='font-size:22px;text-decoration:underline;color:{$color}'>{$ligne['groupname']}</span></a>\n\t\t\t\t<span style='font-size:22px'>{$groupadd_text}{$Textdynamic}</span><br>\n\t\t\t\t<span style='font-size:18px'>{$textExplainGroup}<i>«{$ligne["description"]} <i>{$TextGroupType}</i>»</i>{$Debug}</span>", "<span style='font-size:22px;color:{$color}'>{$CountDeMembers}</span>", "<center>{$delete}</center>")); } echo json_encode($data); }
function popup_search() { $icon = "win7groups-32.png"; $ldap = new ldap_extern(); if ($_POST["query"] == null) { $_POST["query"] = "*"; } if (strpos(" {$_POST["query"]}", "*") == 0) { $_POST["query"] = "*{$_POST["query"]}*"; } $_POST["query"] = str_replace("**", "*", $_POST["query"]); $_POST["query"] = str_replace("**", "*", $_POST["query"]); if (!is_numeric($_POST["rp"])) { $_POST["rp"] = 50; } $Array = $ldap->SearchGroups($_POST["query"], $_POST["rp"]); if (!$ldap->ok) { json_error_show($ldap->ldap_error, 1); } if (count($Array) == 0) { json_error_show("No item", 1); } $data = array(); $data['page'] = 1; $data['total'] = count($Array); $data['rows'] = array(); while (list($dn, $itemname) = each($Array)) { $GroupxSourceName = $itemname; $GroupxName = $itemname; $GroupxName = replace_accents($GroupxName); $GroupxName = str_replace("'", "`", $itemname); $addtitile = null; $select = null; $dn_enc = base64_encode($dn); $DN_base64 = base64_encode($dn); $itemnameenc = base64_encode($itemname); $CountDeUsers = $ldap->CountDeUsersByGroupDN($dn); $js = "EditField{$_GET["t"]}('{$DN_base64}','{$GroupxSourceName}');"; if ($_GET["MainFunction"] != null) { $js = "{$_GET["MainFunction"]}('{$dn}');YahooWinBrowseHide();"; } $image = imgsimple($icon, null, $js); $select = imgsimple("arrow-right-32.png", null, $js); $md5 = md5($dn); $data['rows'][] = array('id' => $md5, 'cell' => array("<center>{$image}</center>", "<span style='font-size:20px;'>{$GroupxName}</a></span>", "<center style='font-size:20px;'>{$CountDeUsers}</center>", "<center>{$select}</center>")); } echo json_encode($data); }
function group_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(); $RULEID = $_GET["RULEID"]; $FORCE_FILTER = null; $search = '%'; $table = "webfilters_sqgroups"; $page = 1; if ($q->COUNT_ROWS($table) == 0) { json_error_show("No data"); } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } if ($_POST["query"] != null) { $_POST["query"] = str_replace("*", "%", $_POST["query"]); $search = $_POST["query"]; $searchstring = "AND (`{$_POST["qtype"]}` LIKE '{$search}')"; $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} {$FORCE_FILTER} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { json_error_show($q->mysql_error); } if (mysql_num_rows($results) == 0) { json_error_show("no data"); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $GroupType = $q->acl_GroupType; $GroupType["src"] = "{addr}"; $GroupType["arp"] = "{ComputerMacAddress}"; $GroupType["dstdomain"] = "{dstdomain}"; $GroupType["proxy_auth"] = "{members}"; $GroupType["port"] = "{remote_ports}"; $GroupType["maxconn"] = "{max_connections}"; $font_size = "15px"; $delet_img = "delete-24.png"; if (isset($_GET["as-big"])) { $font_size = "26px;"; $delet_img = "delete-42.png"; } while ($ligne = mysql_fetch_assoc($results)) { $val = 0; $ligne2['tcount'] = 0; $disable = Field_checkbox("groupid_{$ligne['ID']}", 1, $ligne["enabled"], "EnableDisableGroup('{$ligne['ID']}')"); $ligne['GroupName'] = utf8_encode($ligne['GroupName']); $GroupTypeText = $tpl->_ENGINE_parse_body($GroupType[$ligne["GroupType"]]); $delete = imgsimple($delet_img, null, "DeleteSquidAclGroup('{$ligne['ID']}')"); if ($ligne["GroupType"] == "proxy_auth_ads") { $p = new external_ad_search(); $ligne2['tcount'] = $p->CountDeUsersByGroupName($ligne['GroupName']); } if ($ligne["GroupType"] == "proxy_auth_statad") { $p = new external_ad_search(); $ligne2['tcount'] = $p->CountDeUsersByGroupName($ligne['GroupName']); } if ($ligne["GroupType"] == "proxy_auth_ldap") { $p = new ldap_extern(); preg_match("#^ExtLDAP:(.+?):(.+)#", $ligne['GroupName'], $re); $ligne['GroupName'] = $re[1]; $DN = base64_decode($re[2]); $ligne2['tcount'] = $p->CountDeUsersByGroupDN($DN); } if ($ligne2['tcount'] == 0) { $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(ID) as tcount FROM webfilters_sqitems WHERE gpid='{$ligne['ID']}'")); } if ($ligne["GroupType"] == "all") { $ligne2['tcount'] = "*"; } $CountOfRules = 0; $ligne3 = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(webfilters_sqacls.ID) as tcount FROM webfilters_sqacllinks,webfilters_sqacls WHERE webfilters_sqacllinks.gpid='{$ligne['ID']}' AND webfilters_sqacllinks.aclid=webfilters_sqacls.ID")); $CountOfRules = $ligne3["tcount"]; if ($CountOfRules > 0) { $CountOfRules = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.acls.groups.rules.php?ID={$ligne['ID']}');\" style='font-size:{$font_size};text-decoration:underline'>{$CountOfRules}</a>"; } $data['rows'][] = array('id' => "group{$ligne['ID']}", 'cell' => array("<a href=\"javascript:blur();\" \n\t\tOnClick=\"javascript:Loadjs('{$MyPage}?AddGroup-js=yes&ID={$ligne['ID']}');\" \n\t\tstyle='font-size:{$font_size};text-decoration:underline'>{$ligne['GroupName']}</span>", "<span style='font-size:{$font_size};'>{$GroupTypeText}</span>", "<center style='font-size:{$font_size};'>{$ligne2['tcount']}</center>", "<center style='font-size:{$font_size};'>{$CountOfRules}</center>", "<center>{$disable}</center>", "<center>{$delete}</center>")); } echo json_encode($data); }