function rules_list() { $tpl = new templates(); $MyPage = CurrentPageName(); $table = "ufdb_page_rules"; $q = new mysql_squid_builder(); $FORCE = 1; $t = $_GET["t"]; if ($_POST["query"] != null) { $search = str_replace("*", ".*?", $_POST["query"]); } $total = 0; if ($q->COUNT_ROWS($table, "artica_backup") == 0) { json_error_show("no data [" . __LINE__ . "]", 0); } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } if (!is_numeric($page)) { $page = 1; } $searchstring = string_to_flexquery(); if ($searchstring != null) { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE {$FORCE} {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_events")); $total = $ligne["TCOUNT"]; } else { $total = $q->COUNT_ROWS($table, "artica_events"); } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } if (!is_numeric($rp)) { $rp = 50; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM `{$table}` WHERE {$FORCE} {$searchstring} {$ORDER} {$limitSql}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql, "artica_events"); if (!$q->ok) { json_error_show($q->mysql_error . "<br>{$sql}", 0); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $CurrentPage = CurrentPageName(); if (mysql_num_rows($results) == 0) { json_error_show("no data"); } $searchstring = string_to_flexquery(); $automatically_add_to = $tpl->javascript_parse_text("{automatically_add_to}"); $unlock_during = $tpl->javascript_parse_text("{unlock_during}"); $results = $q->QUERY_SQL($sql, 'artica_backup'); if (!$q->ok) { json_error_show($q->mysql_error . "<br>{$sql}"); } $q1 = new mysql(); $t = time(); $fontsize = 22; $span = "<span style='font-size:{$fontsize}px'>"; $everyone = $tpl->javascript_parse_text("{everyone}"); $all_categories = $tpl->javascript_parse_text("{all_categories}"); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $red = "32-red.png"; $ok = "ok-32.png"; $warn = "warning32.png"; $zmd5 = $ligne["zmd5"]; $category = $ligne["category"]; $webruleid = intval($ligne["webruleid"]); $deny = $ligne["deny"]; $adgroup = $ligne["adgroup"]; $noauth = $ligne["noauth"]; $infinite = $ligne["infinite"]; $addTocat = $ligne["addTocat"]; $username = $ligne["username"]; $maxtime = $ligne["maxtime"]; $allow = $ligne["allow"]; $automatically_add_to_text = null; $unlock_during = null; $icon = "ok32-grey.png"; $icon_allow = "ok32-grey.png"; $icon_ticket = "ok32-grey.png"; $groupname = null; if ($allow == 1) { $icon_allow = $ok; $icon = "ok32-grey.png"; } if ($deny == 1) { $icon = $red; $icon_allow = "ok32-grey.png"; } if ($username != null) { $adgroup = $username; } if ($addTocat != null) { $automatically_add_to_text = "<br><i>{$automatically_add_to} {$addTocat}</i>"; } if ($noauth == 1) { $icon_allow = $warn; } if ($ligne["ticket"] == 1) { $icon_ticket = $ok; $icon_allow = "ok32-grey.png"; } if ($adgroup == "*") { $adgroup = "{$everyone}"; } if (preg_match("#EXTLDAP:(.+)#", $adgroup, $re)) { $ldap = new ldap_extern(); $hash = $ldap->DNInfos($re[1]); $DNENC = urlencode($re[1]); if (isset($hash[0]["cn"])) { $adgroup = $hash[0]["cn"][0]; if (isset($hash[0][$ldap->ldap_filter_group_attribute]["count"])) { $CountOfUsers = " (<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('browse-extldap-users.php?DN={$DNENC}');\" style='text-decoration:underline'>" . intval($hash[0][$ldap->ldap_filter_group_attribute]["count"]) . " {members}</a>)"; } if (isset($hash[0]["description"])) { $description = "<br><i>{$hash[0]["description"][0]}</i>"; } $adgroup = $tpl->_ENGINE_parse_body("{ldap_group}: {$adgroup} {$CountOfUsers}{$description}"); } } $delete = imgsimple("delete-42.png", null, "Loadjs('{$MyPage}?delete-js={$zmd5}')"); $link = "Loadjs('{$MyPage}?rule-js={$zmd5}')"; $href = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$link}\"\n\t\tstyle='text-decoration:underline;font-size:{$fontsize}px'>"; if ($maxtime > 0) { $automatically_add_to_text = $automatically_add_to_text . "<br><i>{$unlock_during} {$maxtime} minutes</i>"; } if ($category == null) { $category = $all_categories; } if ($webruleid > 0) { $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT groupname FROM webfilter_rules WHERE ID={$webruleid}")); $groupname = "<br>{$href}<i style='font-size:18px'>" . utf8_encode($ligne["groupname"]) . "</i></a>"; } $data['rows'][] = array('id' => $zmd5, 'cell' => array("{$href}{$category}</a>{$groupname}{$automatically_add_to_text}", "<center><img src='img/{$icon}'></center>", "<center><img src='img/{$icon_allow}'></center>", "<center><img src='img/{$icon_ticket}'></center>", "{$span}{$adgroup}</span>", "<center>{$delete}</center>")); } echo json_encode($data); }
function popup_search() { $icon = "user-32.png"; $ldap = new ldap_extern(); 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; } $hash = $ldap->DNInfos($_GET["DN"]); if (!$ldap->ok) { json_error_show($ldap->ldap_error, 1); } if ($hash[0][$ldap->ldap_filter_group_attribute]["count"] == 0) { json_error_show("No item", 1); } $data = array(); $data['page'] = 1; $data['total'] = $hash[0][$ldap->ldap_filter_group_attribute]["count"]; $data['rows'] = array(); if ($_POST["rp"] > $hash[0][$ldap->ldap_filter_group_attribute]["count"]) { $_POST["rp"] = $hash[0][$ldap->ldap_filter_group_attribute]["count"]; } $attr = $ldap->ldap_filter_group_attribute; $searchstring = string_to_flexregex(); $tz = 0; for ($i = 0; $i < $_POST["rp"]; $i++) { $member = $hash[0][$attr][$i]; if (preg_match("#^uid=(.+?),#", $member, $re)) { $member = $re[1]; } if ($searchstring != null) { if (!preg_match("#{$searchstring}#", $member)) { continue; } } $tz++; $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;'>{$member}</a></span>", "<center></center>")); } $data['total'] = $tz; echo json_encode($data); }