function tabs() { $page = CurrentPageName(); $tpl = new templates(); $users = new usersMenus(); $q = new mysql_uuid_meta($_GET["uuid"]); $CurrentTable = "squid_hourly_" . date("YmdH"); $CurrentDay = "squid_daily_" . date("Ymd"); $CurrentMonth = "squid_monthly_" . date("Ym"); if ($q->TABLE_EXISTS($CurrentTable)) { $array["RTT"] = "{requests}: {this_hour}"; } if ($q->TABLE_EXISTS($CurrentDay)) { $array["RTD"] = "{requests}: {this_day}"; } if ($q->TABLE_EXISTS($CurrentMonth)) { $array["RTM"] = "{requests}: {this_month}"; } $textsize = "22px"; if (count($array) == 0) { echo FATAL_ERROR_SHOW_128("No statistics can be extracted<br>{$CurrentTable}<br>{$CurrentDay}"); return; } $t = time(); while (list($num, $ligne) = each($array)) { if ($num == "RTT") { $link = "artica-meta.hosts.squid.stats.hour.php?uuid={$_GET["uuid"]}"; $html[] = $tpl->_ENGINE_parse_body("<li style='font-size:{$textsize}'><a href=\"{$link}\"><span>{$ligne}</span></a></li>\n"); continue; } if ($num == "RTD") { $link = "artica-meta.hosts.squid.stats.day.php?uuid={$_GET["uuid"]}"; $html[] = $tpl->_ENGINE_parse_body("<li style='font-size:{$textsize}'><a href=\"{$link}\"><span>{$ligne}</span></a></li>\n"); continue; } if ($num == "RTM") { $link = "artica-meta.hosts.squid.stats.day.php?uuid={$_GET["uuid"]}&month=yes"; $html[] = $tpl->_ENGINE_parse_body("<li style='font-size:{$textsize}'><a href=\"{$link}\"><span>{$ligne}</span></a></li>\n"); continue; } if ($num == "node-infos-RULES") { //$html[]= $tpl->_ENGINE_parse_body("<li style='font-size:$textsize'><a href=\"squid.nodes.accessrules.php?MAC={$_GET["MAC"]}&ipaddr={$_GET["ipaddr"]}\"><span>$ligne</span></a></li>\n"); continue; } $html[] = $tpl->_ENGINE_parse_body("<li style='font-size:{$textsize}'><a href=\"{$page}?{$num}=yes&MAC={$_GET["MAC"]}&ipaddr={$_GET["ipaddr"]}\"><span>{$ligne}</span></a></li>\n"); } echo build_artica_tabs($html, "squid{$_GET["uuid"]}"); }
function showlist() { $page = 1; $q = new mysql_uuid_meta($_GET["uuid"]); $table = "squid_daily_" . date("Ymd"); if ($_GET["month"] == "yes") { $table = "squid_monthly_" . date("Ym"); } 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 {$searchstring}"; $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']; } 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); if (!$q->ok) { json_error_show($q->mysql_error . "<br>{$sql}", 1); } if (mysql_num_rows($results) == 0) { if (!$q->TABLE_EXISTS($table)) { $add = " no table!"; } json_error_show("no data {$add}<br><i>{$sql}</i>", 2); } $data = array(); $data['page'] = 1; $data['total'] = $total; $data['rows'] = array(); //if(mysql_num_rows($results)==0){$data['rows'][] = array('id' => $ligne[time()],'cell' => array($sql,"", "",""));} while ($ligne = mysql_fetch_assoc($results)) { $uid = $ligne["uid"]; $familysite = $ligne["sitename"]; $sizeText = "{$ligne["size"]} Bytes"; $time = $ligne["zDate"]; $mac = $ligne["mac"]; $ipaddr = $ligne["ipaddr"]; $time = strtotime($time); $xtime = date("H:i:00", $time); if ($ligne["size"] > 1024) { $sizeText = FormatBytes($ligne["size"] / 1024); } $hits = FormatNumber($ligne["hits"]); $data['rows'][] = array('id' => md5(serialize($ligne)), 'cell' => array("<span style='font-size:14px'>{$uid}</span>", "<span style='font-size:14px'>{$mac}</span>", "<span style='font-size:14px'>{$ipaddr}</span>", "<span style='font-size:14px'>{$familysite}</a></span>", "<span style='font-size:14px'>{$hits}</span>", "<span style='font-size:14px'>{$sizeText}</span>")); } echo json_encode($data); }
function _hourly_to_daily($tablename, $uuid) { $q = new mysql_uuid_meta($uuid); $f = array(); $sql = "SELECT DATE_FORMAT(`zDate`,'%Y-%m-%d') as `zDate`,DATE_FORMAT(`zDate`,'%Y%m%d') as `NextDate`,`sitename`,\n\t`mac`,`uid`,`ipaddr`,SUM(`hits`) as `hits`,SUM(`size`) as `size` FROM {$tablename} \n\tGROUP BY `sitename`,`mac`,`uid`,`ipaddr`,DATE_FORMAT(`zDate`,'%Y-%m-%d'),DATE_FORMAT(`zDate`,'%Y%m%d')"; $results = $q->QUERY_SQL($sql); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $md5 = md5(serialize($ligne)); $date = $ligne["zDate"]; $hits = $ligne["hits"]; $size = $ligne["size"]; $mac = $ligne["mac"]; $uid = $ligne["uid"]; $ipaddr = $ligne["ipaddr"]; $sitename = $ligne["sitename"]; $Nexttablename = "squid_daily_" . $ligne["NextDate"]; $f[$Nexttablename][] = "('{$md5}','{$date}','{$sitename}','{$mac}','{$uid}','{$ipaddr}','{$hits}','{$size}')"; if (count($f[$Nexttablename]) > 2000) { $prefix = "INSERT IGNORE INTO `{$Nexttablename}` (`zdm5`,`zDate`,`sitename`,`mac`,`uid`,`ipaddr`,`hits`,`size`) VALUES "; if (!$q->create_squid_hourly($Nexttablename)) { return false; } if (!$q->TABLE_EXISTS($Nexttablename)) { return false; } $q->QUERY_SQL($prefix . @implode(",", $f[$Nexttablename])); if (!$q->ok) { return false; } $f[$Nexttablename] = array(); } } if (count($f) > 0) { while (list($tablename, $rows) = each($f)) { $prefix = "INSERT IGNORE INTO `{$tablename}` (`zmd5`,`zDate`,`sitename`,`mac`,`uid`,`ipaddr`,`hits`,`size`) VALUES "; if (!$q->create_squid_hourly($tablename)) { return false; } if (!$q->TABLE_EXISTS($tablename)) { return false; } $q->QUERY_SQL($prefix . @implode(",", $rows)); if (!$q->ok) { return false; } } } return true; }