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["ID"]; $FORCE_FILTER=null; $search='%'; $table="webfilters_sqitems"; $page=1; if($q->COUNT_ROWS($table)==0){$data['page'] = $page;$data['total'] = $total;$data['rows'] = array();echo json_encode($data);return ;} 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 gpid=$ID $FORCE_FILTER $searchstring"; $ligne=mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; }else{ $sql="SELECT COUNT(*) as TCOUNT FROM `$table` WHERE gpid=$ID $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 gpid=$ID $searchstring $FORCE_FILTER $ORDER $limitSql"; writelogs($sql,__FUNCTION__,__FILE__,__LINE__); $results = $q->QUERY_SQL($sql); if(!$q->ok){json_error_show($q->mysql_error);} $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if(mysql_num_rows($results)==0){json_error_show("no data");} while ($ligne = mysql_fetch_assoc($results)) { $val=0; $disable=Field_checkbox("itemid_{$ligne['ID']}", 1,$ligne["enabled"],"EnableDisableItem('{$ligne['ID']}')"); $macname=$q->MAC_TO_NAME($ligne['pattern']); $ligne['pattern']=utf8_encode($ligne['pattern']); $delete=imgtootltip("delete-24.png","{delete} {$ligne['pattern']}","DeleteGroupItem('{$ligne['ID']}')"); $additional_text=null; if($macname){ $additional_text="<div style='font-size:10px'>$macname</div>"; } if(preg_match("#AD:(.*?):(.+)#", $ligne["pattern"],$re)){ $dnEnc=$re[2]; $LDAPID=$re[1]; $ad=new ActiveDirectory($LDAPID); $tty=$ad->ObjectProperty(base64_decode($dnEnc)); $entries=$ad->search_users_from_group(base64_decode($dnEnc),0); $ligne['pattern']="Active Directory: ".$tty["cn"]." - ".count($entries)." items"; } $data['rows'][] = array( 'id' => "item{$ligne['ID']}", 'cell' => array("<span style='font-size:13px;font-weight:bold'>{$ligne['pattern']}</span>$additional_text", "<div style='padding-top:5px'>$disable</div>", $delete) ); } echo json_encode($data); }
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["ID"]; $FORCE_FILTER = null; $search = '%'; $table = "webfilters_sqitems"; $page = 1; if ($q->COUNT_ROWS($table) == 0) { json_error_show("no item"); } 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 gpid={$ID} {$FORCE_FILTER} {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE gpid={$ID} {$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 gpid={$ID} {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql); if (!$q->ok) { json_error_show($q->mysql_error); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (mysql_num_rows($results) == 0) { json_error_show("no item"); } while ($ligne = mysql_fetch_assoc($results)) { $val = 0; $disable = Field_checkbox("itemid_{$ligne['ID']}", 1, $ligne["enabled"], "EnableDisableItem('{$ligne['ID']}')"); $macname = $q->MAC_TO_NAME($ligne['pattern']); $ligne['pattern'] = utf8_encode($ligne['pattern']); $delete = imgtootltip("delete-24.png", "{delete} {$ligne['pattern']}", "DeleteGroupItem('{$ligne['ID']}')"); $additional_text = null; if ($macname) { $additional_text = "<div style='font-size:10px'>{$macname}</div>"; } $data['rows'][] = array('id' => "item{$ligne['ID']}", 'cell' => array("<span style='font-size:14px;font-weight:bold'>{$ligne['pattern']}</span>{$additional_text}", "<div style='padding-top:5px'>{$disable}</div>", $delete)); } echo json_encode($data); }
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["ID"]; $FORCE_FILTER = null; $search = '%'; $table = "webfilters_sqitems"; $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']; } $searchstring = string_to_flexquery(); if ($searchstring != null) { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE gpid={$ID} {$FORCE_FILTER} {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE gpid={$ID} {$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 gpid={$ID} {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql); if (!$q->ok) { json_error_show($q->mysql_error); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (mysql_num_rows($results) == 0) { json_error_show("no data"); } while ($ligne = mysql_fetch_assoc($results)) { $val = 0; $disable = Field_checkbox("itemid_{$ligne['ID']}", 1, $ligne["enabled"], "EnableDisableItem('{$ligne['ID']}')"); $macname = $q->MAC_TO_NAME($ligne['pattern']); $ligne['pattern'] = utf8_encode($ligne['pattern']); $delete = imgtootltip("delete-24.png", "{delete} {$ligne['pattern']}", "DeleteGroupItem('{$ligne['ID']}')"); $additional_text = null; if ($macname) { $additional_text = "<div style='font-size:10px'>{$macname}</div>"; } if (preg_match("#MyPortNameID([0-9]+)#", $ligne["pattern"], $re)) { $ligne_myportname = @mysql_fetch_array($q->QUERY_SQL("SELECT * FROM proxy_ports WHERE ID={$re[1]}")); $ssl = null; $PortName = $ligne_myportname["PortName"]; $port = $ligne_myportname["port"]; $eth = $ligne_myportname["nic"]; if ($ligne_myportname["FTP"] == 1) { continue; } if ($ligne_myportname["ICP"] == 1) { continue; } if ($ligne_myportname["WANPROXY"] == 1) { continue; } if ($ligne_myportname["UseSSL"] == 1) { $ssl = " SSL"; } $PortName = $PortName . "{$ssl} ({$port})"; if ($eth != null) { $nic = new system_nic($eth); $test_ip = $nic->IPADDR; $PortName = "{$PortName}{$ssl} ({$nic->IPADDR}:{$port})"; } $ligne['pattern'] = $tpl->javascript_parse_text($PortName); } if (preg_match("#AD:(.*?):(.+)#", $ligne["pattern"], $re)) { $dnEnc = $re[2]; $LDAPID = $re[1]; $ad = new ActiveDirectory($LDAPID); $tty = $ad->ObjectProperty(base64_decode($dnEnc)); $entries = $ad->search_users_from_group(base64_decode($dnEnc), 0); $ligne['pattern'] = "Active Directory: " . $tty["cn"] . " - " . count($entries) . " items"; } $data['rows'][] = array('id' => "item{$ligne['ID']}", 'cell' => array("<span style='font-size:13px;font-weight:bold'>{$ligne['pattern']}</span>{$additional_text}", "<div style='padding-top:5px'>{$disable}</div>", $delete)); } echo json_encode($data); }