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 groups_list() { $search = $_POST["query"]; $search = "*{$search}*"; $search = str_replace("**", "*", $search); $search = str_replace("**", "*", $search); $search = str_replace("*", "%", $search); $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"]; $sqlCount = "SELECT COUNT(*) as tcount,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 WHERE ((webfilter_group.groupname LIKE '{$search}' AND webfilter_assoc_groups.webfilter_id={$_GET["rule-id"]}) \n\tOR (webfilter_group.description LIKE '{$search}' AND webfilter_assoc_groups.webfilter_id={$_GET["rule-id"]}))\n\tAND webfilter_assoc_groups.group_id=webfilter_group.ID"; $COUNLIGNE = mysql_fetch_array($q->QUERY_SQL($sqlCount, "artica_backup")); if (!$q->ok) { writelogs($q->mysql_error, __FUNCTION__, __FILE__, __LINE__); } 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}"; $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}"; $sql = "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 WHERE ((webfilter_group.groupname LIKE '{$search}' AND webfilter_assoc_groups.webfilter_id={$_GET["rule-id"]}) \n\tOR (webfilter_group.description LIKE '{$search}' AND webfilter_assoc_groups.webfilter_id={$_GET["rule-id"]}))\n\tAND webfilter_assoc_groups.group_id=webfilter_group.ID\t\n\tORDER BY webfilter_group.groupname {$_POST["sortorder"]} {$limitSql}"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { echo "<H2>{$q->mysql_error}</H2><code style='font-size:11px'>{$sql}</code>"; } writelogs("search:{$search} webfilter_id={$_GET["rule-id"]} countline:{$COUNLIGNE["tcount"]}", __FUNCTION__, __FILE__, __LINE__); $data = array(); $data['page'] = $page; $data['total'] = $COUNLIGNE["tcount"]; $data['rows'] = array(); if (mysql_num_rows($results) == 0) { json_error_show("no data"); } while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $textExplainGroup = null; $KEY_ID_GROUP = $ligne["webfilter_group_ID"]; $delete = "<a href=\"javascript:blur();\" OnClick=\"javascript:UnlinkFilterGroup('{$ligne["ID"]}')\"><img src='img/delete-24.png' style='border:0px'></a>"; $color = "black"; $CountDeMembers = "??"; $Textdynamic = null; 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"]}');\"\n\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]}"; } } $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 = "YahooWin4('712','dansguardian2.edit.group.php?ID={$KEY_ID_GROUP}&t={$t}&YahooWin=4','{$KEY_ID_GROUP}::{$ligne['groupname']}');"; $data['rows'][] = array('id' => "group{$ligne["ID"]}", 'cell' => array("<img src='img/{$imgGP}'>", "<a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:{$jsSelect}\" \n\t\t\t\tstyle='font-size:16px;text-decoration:underline;color:{$color}'>{$ligne['groupname']}</span></a>{$groupadd_text}{$Textdynamic}<div style='font-size:10px'>{$textExplainGroup}<i>«{$ligne["description"]} <i>{$TextGroupType}</i>»</i>{$Debug}", "<span style='font-size:16px;color:{$color}'>{$CountDeMembers}</span>", $delete)); } echo json_encode($data); }