function youtube_array_to_sql($array) { $q = new mysql_squid_builder(); while (list($key, $val) = each($array)) { $val = str_replace("'", "`", $val); $val = mysql_escape_string2($val); $array[$key] = addslashes($val); } $VIDEOID = $array["VIDEOID"]; $clientip = $array["clientip"]; $username = $array["username"]; $time = $array["time"]; $mac = $array["mac"]; $hostname = $array["hostname"]; if ($username == "-") { $username = null; } if (strlen($username) < 3) { $username = null; } if (!__IsPhysicalAddress($mac)) { $mac = null; } if ($mac == null) { $mac = GetMacFromIP($clientip); } if ($GLOBALS["VERBOSE"]) { echo "{$mac}:: {$VIDEOID} -> \n"; } if (!youtube_infos($VIDEOID)) { youtube_events("youtube_infos:: {$VIDEOID} -> FAILED", __LINE__); } $timeint = strtotime($time); $timeKey = date('YmdH', $timeint); $account = 0; if ($mac != null) { if ($username == null) { $username = $q->UID_FROM_MAC($mac); } } if ($clientip != null) { if ($username == null) { $username = $q->UID_FROM_IP($clientip); } } youtube_events("{$timeKey} => ('{$time}','{$clientip}','{$hostname}','{$username}','{$mac}','{$account}','{$VIDEOID}')", __LINE__); return array($timeKey, "('{$time}','{$clientip}','{$hostname}','{$username}','{$mac}','{$account}','{$VIDEOID}')"); }
function ParseDB_FILE($path, $uuid = null, $asmeta = false) { $unix = new unix(); if (!is_file($path)) { return; } echo "Open {$path}\n"; $db_con = dba_open($path, "r", "db4"); if (!$db_con) { if ($asmeta) { meta_admin_mysql(1, "DB open failed {$path}", null, __FILE__, __LINE__); } echo "DB open failed\n"; die; } $mainkey = dba_firstkey($db_con); while ($mainkey != false) { $val = 0; $data = unserialize(dba_fetch($mainkey, $db_con)); $mainkey = dba_nextkey($db_con); if (!is_array($data)) { continue; } $q = new mysql_squid_builder(); $qCommon = new mysql_squid_builder(); if ($uuid != null) { $q = new mysql_stats($uuid); } if ($asmeta) { $q = new mysql_meta(); } if (!isset($data["HOURLY"])) { continue; } if (!isset($data["WWW"])) { continue; } $category = null; $ipaddr = mysql_escape_string2($data["IPADDR"]); if (isset($data["MAC"])) { $mac = mysql_escape_string2($data["MAC"]); } $uid = mysql_escape_string2($data["UID"]); $familysite = mysql_escape_string2($data["WWW"]); if (isset($data["category"])) { $category = mysql_escape_string2($data["category"]); } if ($uid == null) { $uid = $qCommon->UID_FROM_MAC($data["MAC"]); } if ($uid == null) { $uid = $qCommon->UID_FROM_IP($data["IPADDR"]); } $uid = mysql_escape_string2($uid); $length = strlen($ipaddr) + strlen($mac) + strlen($uid) + strlen($familysite); if ($length == 0) { continue; } while (list($day, $array) = each($data["HOURLY"])) { while (list($hour, $size) = each($array)) { $md5 = md5("'{$ipaddr}','{$mac}','{$uid}','{$familysite}','{$day}','{$hour}','{$size}','{$category}'"); $wwwUH[] = "('{$md5}','{$ipaddr}','{$mac}','{$uid}','{$familysite}','{$day}','{$hour}','{$size}','{$category}')"; if ($GLOBALS["VERBOSE"]) { echo "('{$md5}','{$ipaddr}','{$mac}','{$uid}','{$familysite}','{$day}','{$hour}','{$size}','{$category}')\n"; } } } } dba_close($db_con); $TABLE_WEEK_RTTH = "WEEK_RTTH"; $ENGINE = "MEMORY"; if ($asmeta) { $TABLE_WEEK_RTTH = "{$uuid}_WEEK_RTTH"; $ENGINE = "MYISAM"; } if ($asmeta) { xmeta_events("DROP TABLE `{$TABLE_WEEK_RTTH}`", __FUNCTION__, __FILE__, __LINE__); } $q->QUERY_SQL("DROP TABLE `{$TABLE_WEEK_RTTH}`"); if ($asmeta) { xmeta_events("CREATE TABLE `{$TABLE_WEEK_RTTH}`", __FUNCTION__, __FILE__, __LINE__); } $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `{$TABLE_WEEK_RTTH}` (\n\t\t\t`zmd5` varchar(90) NOT NULL,\n\t\t\t`familysite` varchar(128) NOT NULL,\n\t\t\t`ipaddr` varchar(50) NOT NULL DEFAULT '',\n\t\t\t`day` smallint(2) NOT NULL,\n\t\t\t`hour` smallint(2) NOT NULL,\n\t\t\t`uid` varchar(128) NOT NULL,\n\t\t\t`MAC` varchar(20) NOT NULL,\n\t\t\t`size` BIGINT UNSIGNED NOT NULL,\n\t\t\t`category` varchar(90) NOT NULL,\n\t\t\tPRIMARY KEY `zmd5` (`zmd5`),\n\t\t\tKEY `familysite` (`familysite`),\n\t\t\tKEY `ipaddr` (`ipaddr`),\n\t\t\tKEY `uid` (`uid`),\n\t\t\tKEY `category` (`category`),\n\t\t\tKEY `hour` (`hour`),\n\t\t\tKEY `day` (`day`),\n\t\t\tKEY `MAC` (`MAC`)\n\t) ENGINE={$ENGINE};"); if (!$q->ok) { if ($asmeta) { meta_admin_mysql(1, "MySQL error", $q->mysql_error, __FILE__, __LINE__); } echo $q->mysql_error; return; } $q->QUERY_SQL("INSERT IGNORE INTO `{$TABLE_WEEK_RTTH}` ( `zmd5`,`ipaddr`,`MAC`,`uid`,familysite,`day`,`hour`,`size`,`category`) VALUES " . @implode(",", $wwwUH)); if (!$q->ok) { if ($asmeta) { meta_admin_mysql(1, "MySQL error", $q->mysql_error, __FILE__, __LINE__); } echo $q->mysql_error; return; } if ($asmeta) { xmeta_events("Success parsing {$path} adding " . count($wwwUH) . " elements", __FUNCTION__, __FILE__, __LINE__); return; } $sock = new sockets(); $EnableArticaMetaClient = intval($sock->GET_INFO("EnableArticaMetaClient")); $EnableSquidRemoteMySQL = intval($sock->GET_INFO("EnableSquidRemoteMySQL")); if ($EnableSquidRemoteMySQL == 1) { return; } if ($EnableArticaMetaClient == 0) { return; } $DIR_TEMP = $unix->TEMP_DIR(); if (!$unix->compress($path, "{$DIR_TEMP}/SQUID_QUOTASIZE.gz")) { meta_admin_mysql(1, "Unable to compress {$path}", null, __FILE__, __LINE__); @unlink("{$DIR_TEMP}/SQUID_QUOTASIZE.gz"); return; } $artica_meta = new artica_meta(); if (!$artica_meta->SendFile("{$DIR_TEMP}/SQUID_QUOTASIZE.gz", "SQUID_QUOTASIZE")) { meta_admin_mysql(1, "Unable to updload {$DIR_TEMP}/SQUID_QUOTASIZE.gz", null, __FILE__, __LINE__); } @unlink("{$DIR_TEMP}/SQUID_QUOTASIZE.gz"); }
function items() { $page = 1; $q = new mysql(); $table = "nmap_scannet"; if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } if (!$q->TABLE_EXISTS("nmap_scannet", "artica_backup")) { $sql = "CREATE TABLE IF NOT EXISTS `nmap_scannet` (\n\t\t`MAC` varchar(90) NOT NULL,\n\t\t`ipaddr` varchar(90) NOT NULL,\n\t\t`vendor` varchar(90) NOT NULL DEFAULT '',\n\t\t`zDate` datetime NOT NULL,\n\t\tPRIMARY KEY (`MAC`),\n\t\tKEY `ipaddr` (`ipaddr`),\n\t\tKEY `vendor` (`vendor`)\n\t\t) ENGINE=MYISAM;"; $q->QUERY_SQL($sql, "artica_backup"); } $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, "artica_backup")); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); $total = $ligne["TCOUNT"]; } 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 1 {$searchstring} {$ORDER} {$limitSql}"; if (isset($_GET["verbose"])) { echo "<hr><code>{$sql}</code></hr>"; } $results = $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { json_error_show($q->mysql_error, 1); } if (mysql_num_rows($results) == 0) { json_error_show("{$table} no data", 1); } $fontsize = "26px"; $data = array(); $data['page'] = 1; $data['total'] = mysql_num_rows($results); $data['rows'] = array(); //if(mysql_num_rows($results)==0){$data['rows'][] = array('id' => $ligne[time()],'cell' => array($sql,"", "",""));} $computer = new computers(); $tpl = new templates(); $dhcpfixed = $tpl->_ENGINE_parse_body("{dhcpfixed}"); $q2 = new mysql_squid_builder(); while ($ligne = mysql_fetch_assoc($results)) { $ipaddr = $ligne["ipaddr"]; $infoZ = array(); $mac = strtolower($ligne["MAC"]); $vendor = $ligne["vendor"]; $uid = null; $uid = $computer->ComputerIDFromMAC($mac); $view = " "; $jslink = null; $jsfiche = null; $infos = null; $macenc = urlencode($ligne["MAC"]); if ($uid != null) { $jslink = "<a href=\"javascript:blur();\"\n\t\t\t\tOnClick=\"javascript:" . MEMBER_JS($uid, 1, 1) . "\"\n\t\t\t\tstyle='font-size:{$fontsize};text-decoration:underline'>"; $computer = new computers($uid); if ($computer->dhcpfixed == 1) { $infoZ[] = "<a href=\"javascript:blur();\"\n\t\t\t\t\t\t\tOnClick=\"javascript:Loadjs('dhcpd.fixed.hosts.php?modify-dhcpd-settings-js=yes&mac={$macenc}');\"\n\t\t\t\t\t\t\tstyle='text-decoration:underline'>{$dhcpfixed}</a> - "; } if (trim($computer->DisplayName) != null) { $infoZ[] = $computer->DisplayName; } if (trim($computer->ComputerMachineType) != null) { $infoZ[] = $computer->ComputerMachineType; } if (trim($computer->ComputerOS) != null) { $infoZ[] = $computer->ComputerOS; } $infos = @implode(" - ", $infoZ); } else { $ocs = new ocs($mac); if (trim($ocs->HARDWARE_ID > 0)) { if ($ocs->dhcpfixed == 1) { $infos = "<a href=\"javascript:blur();\"\n\t\t\t\t\t\tOnClick=\"javascript:Loadjs('dhcpd.fixed.hosts.php?modify-dhcpd-settings-js=yes&mac={$macenc}');\n\t\t\t\t\t\tstyle='text-decoration:underline'>{$dhcpfixed}</a> - "; } $infos = $infos . $ocs->ComputerName . " - " . $computer->ComputerOS; } } $macenc = urlencode($mac); $proxy_alias = $q2->UID_FROM_MAC($mac); if ($proxy_alias != null) { $proxy_alias = "\n\t\t\t\t<a href=\"javascript:blur();\"\n\t\t\t\tstyle=\"text-decoration:underline\"\n\t\t\t\tOnClick=\"javascript:Loadjs('squid.nodes.php?node-infos-js=yes&MAC={$macenc}');\"\n\t\t\t\t>{$proxy_alias}</a>"; } if ($proxy_alias == null) { $proxy_alias = $q2->UID_FROM_IP($ipaddr); } if ($proxy_alias == null) { $proxy_alias = "<center>\n\t\t\t\t\t<a href=\"javascript:blur();\" \n\t\t\t\t\tOnClick=\"javascript:Loadjs('squid.nodes.php?link-user-js=yes&MAC={$macenc}&ipaddr={$ipaddr}',true)\"\n\t\t\t\t\t><img src='img/32-plus.png'></a></center>"; } $data['rows'][] = array('id' => md5(serialize($ligne)), 'cell' => array("<span style='font-size:26px'>{$ipaddr}</span>", "<span style='font-size:26px'>{$jslink}{$mac}</a></span>", "<span style='font-size:26px'>{$vendor}</span>", "<span style='font-size:18px'>{$infos}</span>", "<span style='font-size:26px'>{$proxy_alias}</span>")); } echo json_encode($data); }
function SearchComputers() { $tpl = new templates(); $MyPage = CurrentPageName(); $sock = new sockets(); $EnableIntelCeleron = intval($sock->GET_INFO("EnableIntelCeleron")); $q = new mysql(); $sock = new sockets(); $fontsize = "14px"; $cs = 0; $page = 1; if (!$q->DATABASE_EXISTS("ocsweb")) { $sock->getFrameWork("services.php?mysql-ocs=yes"); } if (!$q->TABLE_EXISTS("hardware", "ocsweb")) { $sock->getFrameWork("services.php?mysql-ocs=yes"); } if (!$q->TABLE_EXISTS("networks", "ocsweb", true)) { $sock->getFrameWork("services.php?mysql-ocs=yes"); } if (!$q->FIELD_EXISTS("networks", "isActive", "ocsweb")) { $q->QUERY_SQL("ALTER TABLE `networks` ADD `isActive` SMALLINT( 1 ) NOT NULL DEFAULT '0',ADD INDEX ( `isActive` ) ", "ocsweb"); } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $table = "(SELECT networks.HARDWARE_ID,networks.MACADDR,networks.STATUS,networks.IPADDRESS,networks.isActive,\n\t\t\thardware.* FROM networks,hardware WHERE networks.HARDWARE_ID=hardware.ID) 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, "ocsweb")); if (!$q->ok) { json_error_show($q->mysql_error . "<br>{$sql}"); } $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "ocsweb")); if (!$q->ok) { json_error_show($q->mysql_error . "<br>{$sql}"); } $total = $ligne["TCOUNT"]; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql, "ocsweb"); if (!$q->ok) { json_error_show($q->mysql_error . "<hr>{$sql}"); } if (mysql_num_rows($results) == 0) { json_error_show("no data"); } $users = new usersMenus(); $DHC_MAIN = false; if ($users->dhcp_installed) { $EnableDHCPServer = intval($sock->GET_INFO('EnableDHCPServer')); if ($EnableDHCPServer == 1) { $DHC_MAIN = true; } } $SQUID_MAIN = false; if ($users->SQUID_INSTALLED) { $SQUID_MAIN = true; } $fontsize = "22px"; $computer = new computers(); $q2 = new mysql_squid_builder(); while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { if ($ligne["MACADDR"] == "unknown") { continue; } $ligne["MACADDR"] = strtolower($ligne["MACADDR"]); $HARDWARE_ID = $ligne["HARDWARE_ID"]; $uid = null; $OSNAME = null; if ($ligne["OSNAME"] == "Unknown") { $ligne["OSNAME"] = null; } $color = "#7D7D7D"; $md = md5($ligne["MACADDR"]); $uri = strtolower($ligne["NAME"]); if ($EnableIntelCeleron == 0) { $uid = $computer->ComputerIDFromMAC($ligne["MACADDR"]); } $view = " "; $jslink = null; $jsfiche = null; $ISDB = "ok32-grey.png"; $DHCP = "ok32-none.png"; $SQUID = "ok32-none.png"; if ($DHC_MAIN) { $DHCP = "ok32-grey.png"; if ($computer->dhcpfixedFromMac($ligne["MACADDR"])) { $DHCP = "ok32.png"; } } if ($SQUID_MAIN) { $ligne2 = mysql_fetch_array($q2->QUERY_SQL("SELECT enabled FROM computers_time WHERE `MAC`='{$ligne["MACADDR"]}'", "artica_backup")); if (intval($ligne2["enabled"]) != 0) { $SQUID = "warning24.png"; } } if ($uid != null) { $ISDB = "ok32.png"; $jsfiche = MEMBER_JS($uid, 1, 1); $view = "<a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:{$jsfiche}\" \n\t\t\tstyle='font-size:{$fontsize};text-decoration:underline'>" . str_replace("\$", "", strtolower($uid)) . "</a>"; $jslink = "<a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:{$jsfiche}\" \n\t\t\tstyle='font-size:{$fontsize};text-decoration:underline'>"; } else { $uid = $ligne["NAME"]; if (preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+#", $uid)) { $q = new mysql_squid_builder(); $NAME2 = $q->UID_FROM_MAC($ligne["MACADDR"]); if ($NAME2 != null) { $uid = $NAME2; } } if ($uid == null) { $uid = "Unknown"; } $jsfiche = "Loadjs('domains.computer.autoadd.php?mac=" . urlencode($ligne["MACADDR"]) . "&ipaddr=" . urlencode($ligne["IPADDRESS"]) . "&computername=" . urlencode($uid) . "&t={$_GET["t"]}')"; if ($EnableIntelCeleron == 1) { $jsfiche = "Loadjs('domains.computer.mysql.php?HARDWARE_ID={$HARDWARE_ID}&t={$_GET["t"]}')"; } $jslink = "<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:{$jsfiche}\"\n\t\t\tstyle='font-size:{$fontsize};text-decoration:underline'>"; $view = "<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:{$jsfiche}\"\n\t\t\tstyle='font-size:{$fontsize};text-decoration:underline'>{$uid}</a>"; } $js[] = "LoadAjaxTiny('cmp-{$md}','{$page}?compt-status={$ligne["IPADDRESS"]}');"; $icon = "<img src='img/{$ISDB}'>"; if ($ligne["OSNAME"] != null) { $OSNAME = "<div style='font-size:9px'><i>{$ligne["OSNAME"]}</i></div>"; } if ($_GET["callback"] != null) { $color = "black"; if ($_GET["fullvalues"] == 1) { $viewjs = "{$_GET["callback"]}('{$uid}','{$ligne["IPADDRESS"]}','{$ligne["MACADDR"]}')"; } else { $viewjs = "{$_GET["callback"]}('{$uid}')"; } $view = "<a href=\"javascript:blur();\" \n\t\t\t\t\t\tOnClick=\"javascript:{$viewjs}\" \n\t\t\t\t\t\tstyle='font-size:{$fontsize};text-decoration:underline'>" . str_replace("\$", "", strtolower($uid)) . "</a>"; $icon = imgtootltip("arrow-blue-left-32.png", null, $viewjs); } if (!IsPhysicalAddress($ligne["MACADDR"])) { if ($_GET["CorrectMac"] == 1) { continue; } } $AlreadyMAC[$ligne["MACADDR"]] = true; $zdate = null; if (isset($ligne["zDate"])) { $zdate = "<div style='font-size:11px;color:#7D7D7D'>{$ligne["zDate"]}</div>"; } $macenc = urlencode($ligne["MACADDR"]); $ipenc = urlencode($ligne["IPADDRESS"]); $jsDelete = "Loadjs('{$MyPage}?delete-computer-js=yes&MAC={$macenc}&t={$_GET["t"]}');"; $alias = $q2->UID_FROM_MAC($ligne["MACADDR"]); if ($alias != null) { $alias_uri = "Loadjs('squid.nodes.php?node-infos-js=yes&MAC={$macenc}');"; } if ($alias == null) { $alias = $q2->UID_FROM_IP($ligne["IPADDRESS"]); if ($alias != null) { $alias_uri = "Loadjs('squid.nodes.php?node-infos-js=yes&ipaddr={$ipenc}');"; } } if ($alias == null) { $alias = "<center><img src='img/32-plus.png'></center>"; $alias_uri = "Loadjs('squid.nodes.php?link-user-js=yes&MAC={$macenc}&ipaddr={$ipenc}',true)"; } if ($EnableIntelCeleron == 1) { $jsfiche = "Loadjs('domains.computer.mysql.php?HARDWARE_ID={$HARDWARE_ID}&t={$_GET["t"]}')"; } $cs++; $data['rows'][] = array('id' => md5(serialize($ligne)), 'cell' => array($view . $zdate, "<span style='font-size:{$fontsize}'>{$jslink}{$ligne["IPADDRESS"]}</a></span>", "<span style='font-size:{$fontsize}'>{$jslink}{$ligne["MACADDR"]}</a></span>", "<span style='font-size:{$fontsize}'><a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:{$alias_uri}\" style='text-decoration:underline'>{$alias}</a></span>", "<center><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsfiche}\">{$icon}</a></center>", "<center><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsfiche}\"><img src='img/{$DHCP}'></center></a>", "<center><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsfiche}\"><img src='img/{$SQUID}'></center></a>", "<center><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsDelete}\"><img src='img/delete-32.png'></center></a>")); } if ($cs > $_POST["rp"]) { $data['total'] = $cs; echo json_encode($data); return; } if ($cs == 0) { json_error_show("no item"); } $data['total'] = $cs; echo json_encode($data); }
function search() { $Mypage = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); $t = time(); $fontsize = 13; $type = $_GET["type"]; $field_query = "size"; $field_query2 = "SUM(size)"; $table_field = "{size}"; $category = $tpl->_ENGINE_parse_body("{category}"); $table = "WEEK_RTTH"; $member = $tpl->_ENGINE_parse_body("{member}"); $sitename = $tpl->_ENGINE_parse_body("{website}"); $search = '%'; $page = 1; $ORDER = "ORDER BY ID DESC"; $ip = new IP(); $Select = "MAC"; $FORCE_FILTER = " AND `MAC`='{$_GET["MAC"]}'"; if ($ip->isIPAddress($_GET["ipaddr"])) { $Select = "ipaddr"; $FORCE_FILTER = "ipaddr='{$_GET["ipaddr"]}'"; } if ($ip->IsvalidMAC($_GET["MAC"])) { $Select = "MAC"; $FORCE_FILTER = "MAC='{$_GET["MAC"]}'"; } $table = "(SELECT `day`,SUM(size) as size,{$Select} FROM WEEK_RTTH GROUP BY `day`,{$Select} HAVING {$FORCE_FILTER}) 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']; } $search = string_to_flexquery(); if ($search != null) { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table}"; $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 {$search} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql); $data = array(); $data['page'] = 0; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { json_error_show($q->mysql_error); } if (mysql_num_rows($results) == 0) { json_error_show("no data"); } $data['total'] = mysql_num_rows($results); $style = "style='font-size:22px'"; while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $ligne["size"] = FormatBytes($ligne["size"] / 1024); $categorize = "Loadjs('squid.categorize.php?www={$ligne["sitename"]}')"; if (trim($ligne["category"]) == null) { $ligne["category"] = "<span style='color:#D70707'>{categorize_this_website}</span>"; } $id = md5(@implode("", $ligne)); if (trim($ligne["uid"]) == "-") { $ligne["uid"] = null; } if (trim($ligne["uid"]) == null) { $ligne["uid"] = $q->UID_FROM_MAC($ligne["MAC"]); } if (trim($ligne["uid"]) == null) { $ligne["uid"] = $q->UID_FROM_IP($ligne["CLIENT"]); } $categorize = "<a href=\"javascript:blur()\" \n\t\tOnClick=\"javascript:{$categorize}\" \n\t\tstyle='font-size:{$fontsize}px;text-decoration:underline'>"; $familysite = $q->GetFamilySites($ligne["sitename"]); $TrafficHour = "<a href=\"javascript:blur()\" \n\t\tOnClick=\"javascript:Loadjs('squid.traffic.statistics.hours.php?familysite={$ligne["sitename"]}&day={$_GET["day"]}')\" \n\t\tstyle='font-size:{$fontsize}px;text-decoration:underline'>"; $dd = date("Y-m"); $D = $q->time_to_date(strtotime("{$dd}-{$ligne["day"]} 00:00:00")); $data['rows'][] = array('id' => $id, 'cell' => array("<span {$style}>{$D}</span>", "<span {$style}>{$ligne["size"]}</a></span>")); } echo json_encode($data); }
function items() { $t = $_GET["t"]; $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $uid = $_GET["uid"]; $users = new usersMenus(); $sock = new sockets(); if (!$users->AsMailBoxAdministrator) { $uid = $_SESSION["uid"]; } $search = '%'; $table = "UserAuthDaysGrouped"; $database = "artica_backup"; $page = 1; $FORCE_FILTER = null; if (isset($_GET["ByUid"])) { $FORCE_FILTER = " AND LENGTH(uid)>1"; } if (isset($_GET["ByMAC"])) { $FORCE_FILTER = " AND LENGTH(MAC)>1"; } if (!$q->TABLE_EXISTS($table, $database)) { json_error_show("{$table} doesn't exists..."); } if ($q->COUNT_ROWS($table, $database) == 0) { json_error_show("No rules"); } 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, $database)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database)); $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}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql, $database); $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { json_error_show($q->mysql_error); } while ($ligne = mysql_fetch_assoc($results)) { $zmd5 = md5(serialize($ligne)); $delete = imgsimple("delete-24.png", "", "Delete{$t}('{$zmd5}')"); $enabled = Field_checkbox("enable_{$zmd5}", 1, $ligne["enabled"], "Enable{$t}('{$zmd5}')"); $color = "black"; $urljs = "<a href=\"javascript:blur();\" \n\tOnClick=\"javascript:GItem{$t}('{$zmd5}','{$ligne["imapserv"]}/{$ligne["account"]}')\"\n\tstyle='font-size:14px;text-decoration:underline;color:{$color}'>"; $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " "); $ligne["QuerySize"] = FormatBytes($ligne["QuerySize"] / 1024); if ($ligne["MAC"] != null) { if (strlen($ligne["uid"]) < 2) { $ligne["uid"] = $q->UID_FROM_MAC($ligne["MAC"]); } } if ($ligne["ipaddr"] != null) { if ($ligne["uid"] == null) { $ligne["uid"] = $q->UID_FROM_IP($ligne["ipaddr"]); } } $data['rows'][] = array('id' => "{$zmd5}", 'cell' => array("<span style='font-size:14px;color:{$color}'>{$urljs}{$ligne["ipaddr"]}</a></span>", "<span style='font-size:14px;color:{$color}'>{$urljs}{$ligne["MAC"]}</a></span>", "<span style='font-size:14px;color:{$color}'>{$urljs}{$ligne["hostname"]}</a></span>", "<span style='font-size:14px;color:{$color}'>{$urljs}{$ligne["uid"]}</span>", "<span style='font-size:14px;color:{$color}'>{$urljs}{$ligne["QuerySize"]}</span>", "<span style='font-size:14px;color:{$color}'>{$ligne["hits"]}</span>")); } echo json_encode($data); }