本文整理汇总了PHP中IP::IsvalidMAC方法的典型用法代码示例。如果您正苦于以下问题:PHP IP::IsvalidMAC方法的具体用法?PHP IP::IsvalidMAC怎么用?PHP IP::IsvalidMAC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IP
的用法示例。
在下文中一共展示了IP::IsvalidMAC方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
function save()
{
$_POST["mac"] = str_replace("-", ":", $_POST["mac"]);
$_POST["mac"] = strtolower($_POST["mac"]);
$ipClass = new IP();
if (!$ipClass->IsvalidMAC($_POST["mac"])) {
echo "MAC: {$_POST["mac"]} Invalid!\n";
return;
}
if (!$ipClass->isValid($_POST["ipaddr"])) {
echo "MAC: {$_POST["ipaddr"]} Invalid!\n";
return;
}
$cmp = new computers();
$uid = $cmp->ComputerIDFromMAC($_POST["mac"]);
if ($uid != null) {
$cmp = new computers($uid);
}
if ($uid == null) {
$uid = "{$_POST["hostname"]}\$";
}
$cmp->uid = $uid;
$cmp->ComputerIP = $_POST["ipaddr"];
$cmp->ComputerMacAddress = $_POST["mac"];
$cmp->ComputerRealName = $_POST["hostname"];
if ($cmp->Add()) {
echo $cmp->ldap_error;
}
}
示例2: delete_computer_js
function delete_computer_js()
{
$page = CurrentPageName();
$t = time();
if (!is_numeric($_GET["t"])) {
$_GET["t"] = 0;
}
header("content-type: application/x-javascript");
$MAC = $_GET["MAC"];
$tpl = new templates();
$IpClass = new IP();
if (!$IpClass->IsvalidMAC($MAC)) {
$error = $tpl->javascript_parse_text("{invalid_mac_address}");
echo "alert('{$error} \"{$MAC}\"');";
return;
}
$delete = $tpl->javascript_parse_text("{delete}");
$html = "\nvar xSave{$t}= function (obj) {\n\tvar t={$_GET["t"]};\n\tvar results=obj.responseText;\n\tif(results.length>3){alert(results);return;}\n\tif(t>0){\n\t\t\$('#flexRT{$_GET["t"]}').flexReload();\n\t}\n}\n\t\nfunction Save{$t}(){\n\tif(!confirm('{$delete} {$MAC} ?')){return;}\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('delete-computer','{$MAC}');\n\tXHR.sendAndLoad('{$page}', 'POST',xSave{$t});\n}\nSave{$t}();\n";
echo $html;
}
示例3: list1
function list1()
{
$page = 1;
$tpl = new templates();
$influx = new influx();
$q = new postgres_sql();
$USER_FIELD = $_GET["user"];
$search = $_GET["search"];
if ($search == null) {
$search = "*";
}
$table = "access_log";
if (!isset($_POST["rp"])) {
$_POST["rp"] = 100;
}
$from = date("Y-m-d H:i:s", strtotime("-2 hour"));
if (isset($_POST["sortname"])) {
if ($_POST["sortname"] != null) {
$ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
}
}
if ($GLOBALS["VERBOSE"]) {
echo "string_to_flexPostGresquery\n";
}
$searchstring = string_to_flexPostGresquery();
$searchstringORG = $searchstring;
if ($searchstring != null) {
$sql = "SELECT COUNT(*) as tcount FROM {$table} WHERE {$searchstring}";
if ($GLOBALS["VERBOSE"]) {
echo "{$sql}\n";
}
$ligne = @pg_fetch_assoc($q->QUERY_SQL($sql));
if (!$q->ok) {
json_error_show($q->mysql_error);
}
$total = $ligne["tcount"];
} else {
$sql = "SELECT COUNT(*) as tcount FROM {$table}";
if ($GLOBALS["VERBOSE"]) {
echo "{$sql}\n";
}
$ligne = @pg_fetch_assoc($q->QUERY_SQL($sql));
$total = $ligne["tcount"];
if (!$q->ok) {
json_error_show($q->mysql_error);
}
if ($GLOBALS["VERBOSE"]) {
echo "COUNT: {$total}\n";
}
}
if (isset($_POST['rp'])) {
$rp = $_POST['rp'];
}
$pageStart = ($page - 1) * $rp;
if (is_numeric($rp)) {
$limitSql = "LIMIT {$rp} OFFSET {$pageStart} ";
}
if ($searchstring != null) {
$searchstring = " AND {$searchstring}";
}
$sql = "SELECT * FROM access_log WHERE zdate > '{$from}' {$searchstring} {$ORDER} {$limitSql}";
if ($GLOBALS["VERBOSE"]) {
echo "{$sql}\n";
}
$data = array();
$data['page'] = $page;
$data['total'] = $total;
$data['rows'] = array();
$results = $q->QUERY_SQL($sql);
if (!$q->ok) {
json_error_show($q->mysql_error);
}
$SumoF = @pg_num_rows($results);
if ($SumoF == 0) {
json_error_show("no data {$sql}");
}
$c = 0;
$fontsize = "18px";
$color = null;
$curday = date("Y-m-d");
$ipClass = new IP();
while ($ligne = pg_fetch_assoc($results)) {
$USER = trim($ligne["userid"]);
$size = intval($ligne["size"]);
if ($size == 0) {
continue;
}
$time = $ligne["zdate"];
$CATEGORY = $ligne["category"];
$SITE = $ligne["familysite"];
$RQS = $ligne["rqs"];
$MAC_link = null;
$MAC = $ligne["mac"];
$IPADDR = $ligne["ipaddr"];
$size = FormatBytes($size / 1024);
$RQS = FormatNumber($RQS);
if ($ipClass->IsvalidMAC($MAC)) {
$MAC_link = "<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:Loadjs('squid.nodes.php?node-infos-js=yes&MAC=" . urlencode($MAC) . "');\"\n\t\t\t\t\tstyle='font-size:{$fontsize};text-decoration:underline'>\n\t\t\t\t\t";
}
$time = str_replace($curday, "", $time);
//.........这里部分代码省略.........
示例4: remove_MAC_sessions
function remove_MAC_sessions($mac)
{
$ipClass = new IP();
if (!$ipClass->IsvalidMAC($mac)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} invalid mac address: {$mac}\n";
}
return;
}
$unix = new unix();
$tmp = $unix->TEMP_DIR();
$iptables_save = $unix->find_program("iptables-save");
$iptables_restore = $unix->find_program("iptables-restore");
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} {$GLOBALS["CACHE_FILE"]}\n";
}
shell_exec("{$iptables_save} > {$GLOBALS["CACHE_FILE"]}");
$data = file_get_contents($GLOBALS["CACHE_FILE"]);
$datas = explode("\n", $data);
$pattern = "#{$mac}#i";
$c = 0;
$MAIN = array();
while (list($num, $ligne) = each($datas)) {
if ($ligne == null) {
continue;
}
if (preg_match($pattern, $ligne)) {
$c++;
continue;
}
$MAIN[] = $ligne;
}
$t = time();
file_put_contents("{$tmp}/{$t}.conf", @implode("\n", $MAIN));
system("{$iptables_restore} < {$tmp}/{$t}.conf");
@unlink("{$tmp}/{$t}.conf");
shell_exec("{$iptables_save} > {$GLOBALS["CACHE_FILE"]}");
}
示例5: dirname
function MAC_TO_NAME($MAC = null)
{
if ($MAC == "00:00:00:00:00:00") {
return null;
}
if ($MAC == null) {
return null;
}
include_once dirname(__FILE__) . "/class.tcpip.inc";
$ip = new IP();
$tt = array();
if (!$ip->IsvalidMAC($MAC)) {
return null;
}
$ligne = mysql_fetch_array($this->QUERY_SQL("SELECT uid FROM `webfilters_nodes` WHERE `MAC`='{$MAC}'"));
if ($ligne["uid"] != null) {
return $ligne["uid"];
}
$results = $this->QUERY_SQL("SELECT hostname FROM `UserAutDB` WHERE `MAC`='{$MAC}' AND LENGTH(hostname)>0");
while ($ligne = mysql_fetch_assoc($results)) {
$tt[$ligne["hostname"]] = $ligne["hostname"];
}
if (count($tt) > 0) {
return @implode(",", $tt);
}
}
示例6: wifidog_login
function wifidog_login($error = null)
{
header('Content-Type: text/html; charset=iso-8859-1');
$REMOTE_ADDR = $_SERVER["REMOTE_ADDR"];
session_start();
$ipClass = new IP();
$USE_TERMS_ACCEPTED = false;
$gateway_addr = $_REQUEST["gw_address"];
$gw_port = $_REQUEST["gw_port"];
$gw_id = $_REQUEST["gw_id"];
$ARP = $_REQUEST["mac"];
$url = $_REQUEST["url"];
$cachefile = "{$GLOBALS["CACHEDIR"]}/{$ARP}." . md5($error . serialize($_REQUEST)) . "." . __FUNCTION__ . ".html";
if (isset($_POST["wifidog-terms"])) {
$_SESSION["USE_TERMS_ACCEPTED"] = true;
$USE_TERMS_ACCEPTED = true;
}
if (isset($_SESSION["USE_TERMS_ACCEPTED"])) {
$USE_TERMS_ACCEPTED = true;
}
if (isset($_GET["clear"])) {
unset($_SESSION["WIFIDOG_RULES"]);
}
if (!$ipClass->IsvalidMAC($ARP)) {
$CacheError1 = "{$GLOBALS["CACHEDIR"]}/hostspot_network_incompatible.html";
if (!is_file($CacheError1)) {
$tpl = new templates();
$text_form = $tpl->_ENGINE_parse_body(FATAL_ERROR_SHOW_128("{hostspot_network_incompatible}"));
@file_put_contents($CacheError1, $text_form);
} else {
$text_form = @file_get_contents($CacheError1);
}
}
if (!isset($_REQUEST["token"])) {
$_REQUEST["token"] = generateToken($ARP);
}
$wifidog_build_uri = wifidog_build_uri();
$uriext = $wifidog_build_uri[0];
$HiddenFields = $wifidog_build_uri[1];
$wifidog_templates = new wifidog_rules();
$_SESSION["WIFIDOG_RULES"] = $wifidog_templates->ruleid;
if ($GLOBALS["HOTSPOT_DEBUG"]) {
wifidog_logs("Rule number {$_SESSION["WIFIDOG_RULES"]}", __FUNCTION__, __LINE__);
}
$wifidog_rule = new wifidog_settings($_SESSION["WIFIDOG_RULES"]);
$ArticaHotSpotNowPassword = intval($wifidog_rule->GET_INFO("ArticaHotSpotNowPassword"));
$ENABLED_REDIRECT_LOGIN = intval($wifidog_rule->GET_INFO("ENABLED_REDIRECT_LOGIN"));
$ENABLED_SMTP = intval($wifidog_rule->GET_INFO("ENABLED_SMTP"));
$ENABLED_AUTO_LOGIN = intval($wifidog_rule->GET_INFO("ENABLED_AUTO_LOGIN"));
$USE_TERMS = intval($wifidog_rule->GET_INFO("USE_TERMS"));
$ALLOW_RECOVER_PASS = intval($wifidog_rule->GET_INFO("ALLOW_RECOVER_PASS"));
$DO_NOT_AUTENTICATE = intval($wifidog_rule->GET_INFO("DO_NOT_AUTENTICATE"));
$SMS_REGISTER = intval($wifidog_rule->GET_INFO("SMS_REGISTER"));
$BOUNCE_AUTH = intval($wifidog_rule->GET_INFO("BOUNCE_AUTH"));
if ($BOUNCE_AUTH == 1) {
if ($ARP != null) {
$CacheARP = "{$GLOBALS["CACHEDIR"]}/{$ARP}";
$ligne["uid"] = null;
if (is_file($CacheARP)) {
if (file_time_min_Web($CacheARP) > 15) {
@unlink($CacheARP);
}
}
if (!is_file($CacheARP)) {
$q = new mysql_hotspot();
$sql = "SELECT * FROM hotspot_members WHERE MAC='{$ARP}'";
$ligne = mysql_fetch_array($q->QUERY_SQL($sql));
$uid = $ligne["uid"];
} else {
$ligne["uid"] = @file_get_contents($CacheARP);
}
if ($ligne["uid"] != null) {
$array["LOGIN"] = $ligne["uid"];
$array["IPADDR"] = null;
$array["MAC"] = $ARP;
$array["ARP"] = $ARP;
$array["token"] = $_REQUEST["token"];
$array["ruleid"] = $_SESSION["WIFIDOG_RULES"];
if (UnLock($array)) {
wifidog_redirect_after_login();
return;
}
}
}
}
if ($USE_TERMS == 1) {
if (!$USE_TERMS_ACCEPTED) {
if ($GLOBALS["HOTSPOT_DEBUG"]) {
wifidog_logs("->wifidog_terms()", __FUNCTION__, __LINE__);
}
return wifidog_terms($ARP);
}
}
$wifidog_templates = new wifidog_templates($_SESSION["WIFIDOG_RULES"]);
if ($SMS_REGISTER == 1) {
if ($GLOBALS["HOTSPOT_DEBUG"]) {
wifidog_logs("->wifidog_register_sms()", __FUNCTION__, __LINE__);
}
wifidog_register_sms();
return;
//.........这里部分代码省略.........
示例7: list1
//.........这里部分代码省略.........
$search_query = "AND {$_POST["qtype"]} =~ /{$search}/";
}
}
$to = strtotime("{$_GET["date2"]} {$_GET["time2"]}");
$md5_table = md5("{$from}{$to}{$USER_FIELD}");
$_SESSION["SQUID_STATS_MEMBER_SEARCH"] = $search;
$Maxlines = $_GET["Maxlines"];
$_SESSION["SQUID_STATS_MAX_LINES"] = $Maxlines;
if ($search != "*") {
//$search_query="AND (SITE =~ /$search/ or $USER_FIELD =~ /$search/)";
}
$totext = "and time < {$to}s";
if (!isset($_POST["rp"])) {
$_POST["rp"] = 100;
}
if ($from == $to) {
$totext = null;
}
$totext = null;
$sql = "SELECT * from access_log WHERE time > {$from}s {$totext} {$search_query} ORDER BY ASC LIMIT {$_POST["rp"]}";
$main = $influx->QUERY_SQL($sql);
$data = array();
$data['page'] = 1;
$data['total'] = 0;
$data['rows'] = array();
$c = 0;
$fontsize = "18px";
$color = null;
$ipClass = new IP();
foreach ($main as $row) {
$USER = trim($row->USERID);
if ($row->SIZE == 0) {
continue;
}
$time = date("H:i:00", InfluxToTime($row->time));
$CURTIME = strtotime($time);
$CATEGORY = $row->CATEGORY;
$SITE = $row->SITE;
$RQS = $row->RQS;
$MAC_link = null;
$MAC = $row->MAC;
$IPADDR = $row->IPADDR;
$USER = trim($row->USERID);
$SIZE = $row->SIZE;
$MD5 = md5("{$time}{$MAC}{$IPADDR}{$USER}{$SITE}");
if (!isset($MAIN[$CURTIME][$MD5])) {
$MAIN[$CURTIME][$MD5]["TIME"] = $time;
$MAIN[$CURTIME][$MD5]["RQS"] = $RQS;
$MAIN[$CURTIME][$MD5]["MAC"] = $MAC;
$MAIN[$CURTIME][$MD5]["IPADDR"] = $IPADDR;
$MAIN[$CURTIME][$MD5]["USER"] = $USER;
$MAIN[$CURTIME][$MD5]["SIZE"] = $SIZE;
$MAIN[$CURTIME][$MD5]["SITE"] = $SITE;
$MAIN[$CURTIME][$MD5]["CATEGORY"] = $CATEGORY;
} else {
$MAIN[$CURTIME][$MD5]["RQS"] = $MAIN[$MD5]["RQS"] + $RQS;
$MAIN[$CURTIME][$MD5]["SIZE"] = $MAIN[$MD5]["SIZE"] + $SIZE;
$MAIN[$CURTIME][$MD5]["CATEGORY"] = $CATEGORY;
}
}
krsort($MAIN);
while (list($curtime, $array0) = each($MAIN)) {
while (list($MDKey, $array) = each($array0)) {
$USER = trim($array["USER"]);
if ($color == null) {
$color = "#F2F0F1";
} else {
$color = null;
}
$time = $array["TIME"];
$RQS = $array["RQS"];
$MAC_link = null;
$SIZE = $array["SIZE"];
if ($SIZE > 1024) {
$size = FormatBytes($SIZE / 1024);
} else {
$size = "{$SIZE} Bytes";
}
$MAC = $array["MAC"];
$IPADDR = $array["IPADDR"];
$CATEGORY = $array["CATEGORY"];
$SITE = $array["SITE"];
$RQS = FormatNumber($RQS);
$c++;
if ($ipClass->IsvalidMAC($MAC)) {
$MAC_link = "<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:Loadjs('squid.nodes.php?node-infos-js=yes&MAC=" . urlencode($MAC) . "');\"\n\t\t\tstyle='font-size:{$fontsize};text-decoration:underline'>\t\t\n\t\t\t";
}
if ($ipClass->isValid($SITE)) {
$SITE = "<a href=\"https://db-ip.com/{$SITE}\" style='text-decoration:underline;color:black' target=_new>{$SITE}</a>";
}
if ($c > $_POST["rp"]) {
break;
}
$data['rows'][] = array('id' => $c, 'cell' => array("<span style='font-size:{$fontsize}'>{$time}</a></span>", "<span style='font-size:{$fontsize}'>{$SITE}</a></span>", "<span style='font-size:{$fontsize}'>{$CATEGORY}</a></span>", "<span style='font-size:{$fontsize}'>{$MAC_link}{$MAC}</a></span>", "<span style='font-size:{$fontsize}'>{$IPADDR}</a></span>", "<span style='font-size:{$fontsize}'>{$USER}</a></span>", "<span style='font-size:{$fontsize}'>{$RQS}</a></span>", "<span style='font-size:{$fontsize}'>{$size}</a></span>"));
}
}
$data['total'] = $c;
echo json_encode($data);
return;
}
示例8: items
function items(){
$tpl=new templates();
$MyPage=CurrentPageName();
$q=new mysql_squid_builder();
$t=$_GET["t"];
$search='%';
$table="UserAuthDaysGrouped";
$page=1;
$FORCE_FILTER=null;
$total=0;
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));
$total = $ligne["TCOUNT"];
}else{
$total = $q->COUNT_ROWS("UserAuthDaysGrouped");
}
if (isset($_POST['rp'])) {$rp = $_POST['rp'];}
$pageStart = ($page-1)*$rp;
if(is_numeric($rp)){$limitSql = "LIMIT $pageStart, $rp";}
$sql="SELECT * FROM $table WHERE 1 $searchstring $FORCE_FILTER $ORDER $limitSql";
$results = $q->QUERY_SQL($sql);
$data = array();
$data['page'] = $page;
$data['total'] = $total;
$data['rows'] = array();
if(!$q->ok){json_error_show($q->mysql_error."<br>$sql");}
if(mysql_num_rows($results)==0){json_error_show("no data");}
$fontsize="16";
//ipaddr | hostname | uid | MAC | account | QuerySize | hits
$IpClass=new IP();
while ($ligne = mysql_fetch_assoc($results)) {
$color="black";
$md=md5(serialize($ligne));
$ligne["QuerySize"]=FormatBytes($ligne["QuerySize"]/1024);
$ligne["hits"]=FormatNumber($ligne["hits"]);
$uiduri="<a href=\"javascript:Loadjs('squid.members.zoom.php?field=uid&value=".urlencode($ligne["uid"])."')\"
style='font-size:{$fontsize}px;color:$color;text-decoration:underline'>";
$macencode=urlencode($ligne["MAC"]);
$MACUri="<a href=\"javascript:Loadjs('squid.nodes.php?node-infos-js=yes&MAC=$macencode',true);\"
style='font-size:{$fontsize}px;color:$color;text-decoration:underline'>";
if(!$IpClass->IsvalidMAC($ligne["MAC"])){$MACUri=null;}
$data['rows'][] = array(
'id' => $ligne['ID'],
'cell' => array(
"<span style='font-size:{$fontsize}px;color:$color'>{$ligne["ipaddr"]}</span>",
"<span style='font-size:{$fontsize}px;color:$color'>{$ligne["hostname"]}</span>",
"<span style='font-size:{$fontsize}px;color:$color'>$uiduri{$ligne["uid"]}</a></span>",
"<span style='font-size:{$fontsize}px;color:$color'>$MACUri{$ligne["MAC"]}</a></span>",
"<span style='font-size:{$fontsize}px;color:$color'>{$ligne["QuerySize"]}</span>",
"<span style='font-size:{$fontsize}px;color:$color'>{$ligne["hits"]}</span>",
)
);
}
echo json_encode($data);
}
示例9: xqueries
function xqueries()
{
$page = CurrentPageName();
$tpl = new templates();
$influx = new influx();
$sql = "SELECT MAX(ZDATE) AS MAX FROM access_log";
$main = $influx->QUERY_SQL($sql);
$MAX = $main[0]->MAX;
$LastEntry = $tpl->time_to_date($MAX, true);
if ($GLOBALS["VERBOSE"]) {
echo "<p style='color:blue'>{$MAX} -> {$LastEntry}</p>";
}
$from_gmt = $tpl->time_to_date($MAX - 300, true);
$from = QueryToUTC($MAX - 300);
$fromTime = date("Y-m-d H:i:s", $from);
$ToTime = date("Y-m-d H:i:s", QueryToUTC($MAX));
$sql = "SELECT * from access_log WHERE time > '{$fromTime}' AND time < '{$ToTime}'";
//echo "<hr>$sql</HR>";
$main = null;
$influx2 = new influx();
$QUERY2 = $influx2->QUERY_SQL($sql);
$color = null;
$ipClass = new IP();
$q = new mysql_squid_builder();
$c = 0;
$D = 0;
foreach ($QUERY2 as $row) {
$USER = trim($row->USERID);
$IPADDR = trim($row->IPADDR);
$MAC = trim($row->MAC);
if ($row->SIZE == 0) {
continue;
}
if (is_numeric($USER)) {
continue;
}
$RQS = $row->RQS;
$time = InfluxToTime($row->time);
$DATEKEY = date("H:00", $time);
$KEYMD5 = md5("{$USER}{$IPADDR}{$MAC}");
$c = $c + $RQS;
$D = $D + $row->SIZE;
if (!isset($MAIN[$DATEKEY][$KEYMD5])) {
$MAIN[$DATEKEY][$KEYMD5]["USER"] = $USER;
$MAIN[$DATEKEY][$KEYMD5]["IPADDR"] = $IPADDR;
$MAIN[$DATEKEY][$KEYMD5]["MAC"] = $MAC;
$MAIN[$DATEKEY][$KEYMD5]["SIZE"] = $row->SIZE;
$MAIN[$DATEKEY][$KEYMD5]["RQS"] = $RQS;
} else {
$MAIN[$DATEKEY][$KEYMD5]["SIZE"] = $MAIN[$DATEKEY][$KEYMD5]["SIZE"] + $row->SIZE;
$MAIN[$DATEKEY][$KEYMD5]["RQS"] = $MAIN[$DATEKEY][$KEYMD5]["RQS"] + $RQS;
}
}
$D = FormatBytes($D / 1024);
$requests = $tpl->javascript_parse_text("{requests}");
$last_entry_on = $tpl->javascript_parse_text("{last_entry_on}");
$since = $tpl->_ENGINE_parse_body("{since}");
$html[] = "\n\t\n\t<div style='width:98%' class=form>\n\t<div style='margin-top:5px;font-size:16px;text-align:right;margin-bottom:15px;font-weight:bold'>\n\t\t{$since} 5mn ({$c} {$requests} / {$D}) UTC:" . $tpl->time_to_date($from, true) . " - GMT {$from_gmt} / {$last_entry_on}: {$LastEntry}</div>";
$html[] = "\n\t\t\n\t<table style='width:100%'>";
$html[] = $tpl->_ENGINE_parse_body("<tr>\n\t\t\t<th style='font-size:18px'>{time}</th>\n\t\t\t<th style='font-size:18px'>{MAC}</th>\n\t\t\t<th style='font-size:18px'>{ipaddr}</th>\n\t\t\t<th style='font-size:18px'>{uid}</th>\n\t\t\t<th style='font-size:18px'>{requests}</th>\n\t\t\t<th style='font-size:18px'>{size}</th>\n\t\t\t</tr>\n\t\t\t");
while (list($time, $SUBARRAY) = each($MAIN)) {
while (list($KEYMD5, $BIGARRAY) = each($SUBARRAY)) {
if ($color == null) {
$color = "#F2F0F1";
} else {
$color = null;
}
$MAC = $BIGARRAY["MAC"];
$RQS = $BIGARRAY["RQS"];
$SIZE = $BIGARRAY["SIZE"];
$USER = $BIGARRAY["USER"];
$IPADDR = $BIGARRAY["IPADDR"];
$MAC_link = null;
if ($SIZE > 1024) {
$size = FormatBytes($SIZE / 1024);
} else {
$size = "{$SIZE}Bytes";
}
$RQS = FormatNumber($RQS);
if ($ipClass->IsvalidMAC($MAC)) {
$MAC_link = "<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:Loadjs('squid.nodes.php?node-infos-js=yes&MAC=" . urlencode($MAC) . "');\"\n\t\t\tstyle='font-size:16px;text-decoration:underline;font-weight:bold'>\t\t\n\t\t\t";
if (trim($USER) == null) {
$USER = $q->MacToUid($MAC);
}
}
$html[] = "<tr style='background-color:{$color}'>";
$html[] = "<td style='font-size:16px;width:50px;padding:10px;font-weight:bold'>{$time}</td>";
$html[] = "<td style='font-size:16px;width:50px;padding:10px;font-weight:bold'>{$MAC_link}{$MAC}</a></td>";
$html[] = "<td style='font-size:16px;width:50px;padding:10px;font-weight:bold'>{$IPADDR}</td>";
$html[] = "<td style='font-size:16px;width:50px;padding:10px;font-weight:bold'>{$USER}</td>";
$html[] = "<td style='font-size:16px;width:50px;text-align:right;padding:10px' nowrap>{$RQS}</td>";
$html[] = "<td style='font-size:16px;width:50px;text-align:right;padding:10px' nowrap>{$size}</td>";
$html[] = "</tr>";
}
}
$html[] = "</table>";
$html[] = "</div>";
$html[] = "\n\t<script>\n\t\tfunction FollowerRefresh(){\n\t\t\tif(!document.getElementById('ZRTRQUESTS_COMPTER')){ return;}\n\t\t\tvar compter=parseInt(document.getElementById('ZRTRQUESTS_COMPTER').value);\n\t\t\tif(compter<10){\n\t\t\t\tcompter=compter+1;\n\t\t\t\tdocument.getElementById('ZRTRQUESTS_COMPTER').value=compter;\n\t\t\t\tsetTimeout(\"FollowerRefresh()\",1000);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tdocument.getElementById('ZRTRQUESTS_COMPTER').value=0;\n\t\t\tif(!document.getElementById('proxy-follower-table')){ return;}\n\t\t\tLoadAjaxSilent('proxy-follower-table','{$page}?follow=yes&t={$_GET["t"]}');\n\t\t}\n\t\t\t\n\t\t\t\n\tsetTimeout(\"FollowerRefresh()\",1000);\n\t</script>";
echo @implode("\n", $html);
}
示例10: group_popup
function group_popup()
{
$page = CurrentPageName();
$q = new mysql_squid_builder();
$tpl = new templates();
$table = $_GET["table"];
$IP = trim($_GET["IP"]);
$MAC = trim($_GET["MAC"]);
$t = time();
$GROUPS[null] = "{select}";
$IPclass = new IP();
if ($MAC != null) {
if ($IPclass->IsvalidMAC($MAC)) {
$ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM webfilters_nodes WHERE MAC='{$MAC}'"));
$member = $ligne["uid"];
$group = $ligne["group"];
$sql = "SELECT `group` FROM webfilters_nodes GROUP BY `group` ORDER BY `group`";
$results = $q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
echo $q->mysql_error_html();
}
while ($ligne2 = mysql_fetch_assoc($results)) {
if (trim($ligne2["group"]) == null) {
continue;
}
$GROUPS[$ligne2["group"]] = $ligne2["group"];
}
$field = "\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:26px'>{MAC}:</td>\n\t\t\t\t<td>" . Field_text("{$t}-ITEM", $MAC, "font-size:26px;width:260px", $MAC, null, null, false, "LinkUserStatsDBcHeck{$t}(event)") . "</td>\n\t\t\t</tr>\n\t\t\t";
}
}
if ($IP != null) {
if ($member == null) {
if ($IPclass->isValid($_GET["ipaddr"])) {
$ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM webfilters_ipaddr WHERE ipaddr='{$IP}'"));
$member = $ligne["uid"];
$group = $ligne["group"];
$sql = "SELECT `group` FROM webfilters_ipaddr GROUP BY `group` ORDER BY `group`";
$results = $q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
echo $q->mysql_error_html();
}
while ($ligne2 = mysql_fetch_assoc($results)) {
if (trim($ligne2["group"]) == null) {
continue;
}
$GROUPS[$ligne2["group"]] = $ligne2["group"];
}
}
}
$field = "<tr>\n\t\t\t\t<td class=legend style='font-size:26px'>{ipaddr}:</td>\n\t\t\t\t<td>" . field_ipv4("{$t}-ITEM", $IP, "font-size:26px;width:250px", null, null, null, false, "LinkUserStatsDBcHeck{$t}(event)") . "</td>\n\t\t\t</tr>";
}
$html = "<div id='div-{$t}' style='width:98%' class=form>\n<div style='font-size:30px;margin-bottom:20px'>{proxy_alias}: {$_GET["MAC"]} / {$_GET["ipaddr"]}</div>\n\t<table style='width:100%'>\n\t\t{$field}\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:26px'>{alias}:</td>\n\t\t\t<td>" . Field_text("{$t}-uid", $member, "font-size:26px;width:550px", null, null, null, false, "LinkUserStatsDBcHeck{$t}(event)") . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:26px'>{group}:</td>\n\t\t\t<td>" . Field_array_Hash($GROUPS, "{$t}-group", $group, "style:font-size:26px;", null, null, null, false, "LinkUserStatsDBcHeck{$t}(event)") . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:26px'>{group} ({new}):</td>\n\t\t\t<td>" . Field_text("{$t}-group2", null, "font-size:26px;width:550px", null, null, null, false, "LinkUserStatsDBcHeck{$t}(event)") . "</td>\n\t\t</tr>\t\t\t\t\t\t\t\t\t\t\n\t\t<tr>\n\t\t\t<td colspan=2 align='right'><hr>" . button("{apply}", "LinkUserStatsDB{$t}()", 32) . "</td>\n\t\t</tr>\n\t</table>\n</div>\n<script>\nvar x_LinkUserStatsDB{$t}=function(obj){\n\tvar tempvalue=obj.responseText;\n\tif(tempvalue.length>3){alert(tempvalue);return;}\n\tYahooWinHide();\n\tif(document.getElementById('main_node_infos_tab')){RefreshTab('main_node_infos_tab');}\n\t\t\n\tif(document.getElementById('OCS_SEARCH_TABLE')){\n\t\tvar id=document.getElementById('OCS_SEARCH_TABLE').value;\n\t\t\$('#'+id).flexReload();\n\t}\n\tif(document.getElementById('PROXY_ALIASES_TABLE')){\n\t\t\$('#PROXY_ALIASES_TABLE').flexReload();\n\t}\n\t\t\n\tif(IsFunctionExists('RefreshNodesSquidTbl')){ RefreshNodesSquidTbl();}\n\tLoadjs('squid.macToUid.progress.php');\n}\n\t\t\nfunction LinkUserStatsDBcHeck{$t}(e){\n\tif(checkEnter(e)){LinkUserStatsDB{$t}();}\n}\n\t\t\nfunction LinkUserStatsDB{$t}(){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('uid',document.getElementById('{$t}-uid').value);\n\tXHR.appendData('group',document.getElementById('{$t}-group').value);\n\tXHR.appendData('group2',document.getElementById('{$t}-group2').value);\n\tXHR.appendData('item',document.getElementById('{$t}-ITEM').value);\n\tXHR.appendData('table','{$table}');\n\tXHR.sendAndLoad('{$page}', 'POST',x_LinkUserStatsDB{$t});\n}\n</script>\n\t\t\n\t\t";
echo $tpl->_ENGINE_parse_body($html);
}
示例11: node_infos_realtime_list
function node_infos_realtime_list()
{
$page = CurrentPageName();
$tpl = new templates();
$sock = new sockets();
$influx = new influx();
$from = strtotime('-1 hour');
if (isset($_POST['page'])) {
$page = $_POST['page'];
}
if (isset($_POST['rp'])) {
$rp = $_POST['rp'];
}
$ip = new IP();
if ($ip->isIPAddress($_GET["ipaddr"])) {
$Select = "IPADDR";
$FORCE_FILTER = " IPADDR='{$_GET["ipaddr"]}'";
}
if ($ip->IsvalidMAC($_GET["MAC"])) {
$Select = "MAC";
$FORCE_FILTER = " MAC='{$_GET["MAC"]}'";
}
$sql = "SELECT * FROM access_log where time >{$from}s and {$FORCE_FILTER} ORDER BY time DESC LIMIT {$rp}";
$data = array();
$data['page'] = $page;
$data['total'] = 0;
$data['rows'] = array();
$today = date("Y-m-d");
$tcp = new IP();
$main = $influx->QUERY_SQL($sql);
$c = 0;
foreach ($main as $row) {
$color = "black";
$return_code_text = null;
$ff = array();
$color = "black";
$uri = $row->SITE;
$xtimelog = null;
$date = date("H:i:s", InfluxToTime($row->time));
$mac = $row->MAC;
$ip = $row->IPADDR;
$user = $row->uid;
$size = $row->SIZE;
$rqs = $row->RQS;
$ident = array();
$md = md5(serialize($row));
$c++;
$spanON = "<span style='color:{$color};font-size:16px'>";
$spanOFF = "</span>";
$cached_text = null;
$size = FormatBytes($size / 1024);
$data['rows'][] = array('id' => $md, 'cell' => array("{$spanON}{$date}{$spanOFF}", "{$spanON}{$uri}{$spanOFF}", "{$spanON}{$rqs}{$spanOFF}", "{$spanON}{$size}{$spanOFF}"));
}
$data['total'] = $c;
echo json_encode($data);
}
示例12: BANDWIDTH_MONITOR
function BANDWIDTH_MONITOR()
{
$sock = new sockets();
$SquidPerformance = intval($sock->GET_INFO("SquidPerformance"));
if ($SquidPerformance > 1) {
return;
}
$watchdog = new squid_watchdog();
$MonitConfig = $watchdog->MonitConfig;
if ($MonitConfig["CHECK_BANDWITDH"] == 0) {
return;
}
$CHECK_BANDWITDH_INTERVAL = $MonitConfig["CHECK_BANDWITDH_INTERVAL"];
$influx = new influx();
if (!is_numeric($CHECK_BANDWITDH_INTERVAL)) {
$CHECK_BANDWITDH_INTERVAL = 5;
}
$olddate = strtotime("-{$CHECK_BANDWITDH_INTERVAL} minutes", time());
$CHECK_BANDWITDH_SIZE = intval($MonitConfig["CHECK_BANDWITDH_INTERVAL"]);
$query_date = date("Y-m-d H:i:s", $olddate);
$postgres = new postgres_sql();
$sql = "select sum(SIZE) as size from access_log where zdate > '{$olddate}'";
$ligne = @pg_fetch_assoc($postgres->QUERY_SQL($sql));
$size = $ligne["size"] / 1024;
$size = round($size / 1024, 2);
if ($GLOBALS["VERBOSE"]) {
echo "Since " . date("Y-m-d H:i:s", $olddate) . "- Size: {$size}MB\n";
}
if ($GLOBALS["VERBOSE"]) {
echo "{$size}MB must be higher than {$CHECK_BANDWITDH_SIZE}MB\n";
}
if ($size < $CHECK_BANDWITDH_SIZE) {
return;
}
$EXCEED_SIZE = $size;
$REPORT[] = "Report bandwidth usage since: " . date("{l} {F} d H:i:s", $olddate);
$ipclass = new IP();
$sql = "select sum(size) as size,ipaddr,mac,userid from access_log where zdate > '{$olddate}' group by IPADDR,MAC,USERID order by size desc";
$results = $postgres->QUERY_SQL($sql);
while ($ligne = @pg_fetch_assoc($results)) {
$users2 = array();
$size = $ligne["size"] / 1024;
$size = round($size / 1024, 2);
if ($size == 0) {
continue;
}
if ($size < 1) {
continue;
}
if ($CHECK_BANDWITDH_SIZE > 1) {
if ($size < 2) {
continue;
}
}
$IPADDR = $ligne["ipaddr"];
$users2[] = $IPADDR;
$MAC = trim($ligne["mac"]);
$USERID = $ligne["userid"];
if ($USERID != null) {
$users2[] = $USERID;
}
if ($ipclass->IsvalidMAC($MAC)) {
$users2[] = $MAC;
}
$REPORT[] = "User: " . @implode(", ", $users2) . " {$size}MB used";
if ($GLOBALS["VERBOSE"]) {
echo "Since " . date("Y-m-d H:i:s", $olddate) . "- {$IPADDR},{$MAC},{$USERID} Size: {$size}MB\n";
}
}
$catz = new mysql_catz();
$sql = "select sum(SIZE) as size,familysite from access_log group by familysite where zdate > '{$olddate}' ORDER by size desc";
$results = $postgres->QUERY_SQL($sql);
while ($ligne = @pg_fetch_assoc($results)) {
$size = $ligne["size"] / 1024;
$size = round($size / 1024, 2);
if ($size == 0) {
continue;
}
if ($size < 1) {
continue;
}
$FAMILYSITE = $ligne["familysite"];
$category = $catz->GET_CATEGORIES($FAMILYSITE);
if ($category != null) {
$category_text = " (category:{$category})";
}
$REPORT[] = "Web site: {$FAMILYSITE} {$size}MB used{$category_text}";
}
squid_admin_mysql(0, "Bandwidth usage {$EXCEED_SIZE}MB exceed {$CHECK_BANDWITDH_SIZE}MB", @implode("\n", $REPORT), __FILE__, __LINE__);
}
示例13: node_infos_realtime_list
function node_infos_realtime_list(){
$page=CurrentPageName();
$tpl=new templates();
$sock=new sockets();
$q=new mysql_squid_builder();
$GLOBALS["Q"]=$q;
$table="squidhour_".date("YmdH");
if(isset($_POST['page'])) {$page = $_POST['page'];}
if(isset($_POST['rp'])) {$rp = $_POST['rp'];}
$ip=new IP();
if($ip->isIPAddress($_GET["ipaddr"])){
$Select="ipaddr";
$FORCE_FILTER=" ipaddr='{$_GET["ipaddr"]}'";
}
if($ip->IsvalidMAC($_GET["MAC"])){
$Select="MAC";
$FORCE_FILTER=" MAC='{$_GET["MAC"]}'";
}
$searchstring=string_to_flexquery();
if($searchstring<>null){
$sql="SELECT COUNT(*) as TCOUNT FROM `$table` WHERE $FORCE_FILTER $searchstring";
$ligne=mysql_fetch_array($q->QUERY_SQL($sql));
$total = $ligne["TCOUNT"];
}else{
$sql="SELECT COUNT(*) as TCOUNT FROM `$table` WHERE $FORCE_FILTER";
$ligne=mysql_fetch_array($q->QUERY_SQL($sql));
$total = $ligne["TCOUNT"];
}
if(!is_numeric($rp)){$rp=50;}
$pageStart = ($page-1)*$rp;
$limitSql = "LIMIT $pageStart, $rp";
if(isset($_POST["sortname"])){if($_POST["sortname"]<>null){$ORDER="ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";}}
$sql="SELECT * FROM `$table` WHERE $FORCE_FILTER $searchstring $ORDER $limitSql";
$results = $q->QUERY_SQL($sql);
if(!$q->ok){json_error_show($q->mysql_error."\n$sql");}
$data = array();
$data['page'] = $page;
$data['total'] = $total;
$data['rows'] = array();
$today=date("Y-m-d");
$tcp=new IP();
$cachedT=$tpl->_ENGINE_parse_body("{cached}");
$c=0;
while ($ligne = mysql_fetch_assoc($results)) {
$color="black";
$return_code_text=null;
$ff=array();
$color="black";
$uri=$ligne["uri"];
$date=$ligne["zDate"];
$mac=$ligne["MAC"];
$ip=$ligne["CLIENT"];
$user=$ligne["uid"];
$dom=$ligne["sitename"];
$cached=$ligne["cached"];
$return_code=$ligne["TYPE"];
$size=$ligne["QuerySize"];
$ident=array();
$md=md5(serialize($ligne));
$today=date("Y-m-d");
$date=str_replace($today, "", $date);
$spanON="<span style='color:$color'>";
$spanOFF="</span>";
$cached_text=null;
if($cached==1){$cached_text=" - $cachedT";}
$size=FormatBytes($size/1024);
if($return_code=="Service Unavailable"){$color="#BA0000";}
if($return_code=="Bad Gateway"){$color="#BA0000";}
$return_code_text="<div style='color:$color;font-size:11px'><i>«$return_code»$cached_text - $size</i></div>";
$data['rows'][] = array(
'id' => $md,
'cell' => array(
"$spanON$date$spanOFF",
"$spanON$uri.$return_code_text$spanOFF",
)
);
}
echo json_encode($data);
}
示例14: BANDWIDTH_MONITOR
function BANDWIDTH_MONITOR()
{
$sock = new sockets();
$SquidPerformance = intval($sock->GET_INFO("SquidPerformance"));
if ($SquidPerformance > 1) {
return;
}
$watchdog = new squid_watchdog();
$MonitConfig = $watchdog->MonitConfig;
if ($MonitConfig["CHECK_BANDWITDH"] == 0) {
return;
}
$CHECK_BANDWITDH_INTERVAL = $MonitConfig["CHECK_BANDWITDH_INTERVAL"];
$influx = new influx();
if (!is_numeric($CHECK_BANDWITDH_INTERVAL)) {
$CHECK_BANDWITDH_INTERVAL = 5;
}
$olddate = strtotime("-{$CHECK_BANDWITDH_INTERVAL} minutes", time());
$CHECK_BANDWITDH_SIZE = intval($MonitConfig["CHECK_BANDWITDH_INTERVAL"]);
$sql = "select sum(SIZE) as size from access_log where time > {$olddate}s";
$main = $influx->QUERY_SQL($sql);
foreach ($main as $row) {
$size = $row->size / 1024;
$size = round($size / 1024, 2);
if ($GLOBALS["VERBOSE"]) {
echo "Since " . date("Y-m-d H:i:s", $olddate) . "- Size: {$size}MB\n";
}
}
if ($GLOBALS["VERBOSE"]) {
echo "{$size}MB must be higher than {$CHECK_BANDWITDH_SIZE}MB\n";
}
if ($size < $CHECK_BANDWITDH_SIZE) {
return;
}
$EXCEED_SIZE = $size;
$REPORT[] = "Report bandwidth usage since: " . date("{l} {F} d H:i:s", $olddate);
$ipclass = new IP();
$sql = "select sum(SIZE) as size,IPADDR,MAC,USERID from access_log group by IPADDR,MAC,USERID where time > {$olddate}s";
$main = $influx->QUERY_SQL($sql);
foreach ($main as $row) {
$users2 = array();
$size = $row->size / 1024;
$size = round($size / 1024, 2);
if ($size == 0) {
continue;
}
if ($size < 1) {
continue;
}
if ($CHECK_BANDWITDH_SIZE > 1) {
if ($size < 2) {
continue;
}
}
$IPADDR = $row->IPADDR;
$users2[] = $IPADDR;
$MAC = trim($row->MAC);
$USERID = trim($row->USERID);
if ($USERID != null) {
$users2[] = $USERID;
}
if ($ipclass->IsvalidMAC($MAC)) {
$users2[] = $MAC;
}
$REPORT[] = "User: " . @implode(", ", $users2) . " {$size}MB used";
if ($GLOBALS["VERBOSE"]) {
echo "Since " . date("Y-m-d H:i:s", $olddate) . "- {$IPADDR},{$MAC},{$USERID} Size: {$size}MB\n";
}
}
$catz = new mysql_catz();
$sql = "select sum(SIZE) as size,FAMILYSITE from access_log group by FAMILYSITE where time > {$olddate}s";
$main = $influx->QUERY_SQL($sql);
foreach ($main as $row) {
$size = $row->size / 1024;
$size = round($size / 1024, 2);
if ($size == 0) {
continue;
}
if ($size < 1) {
continue;
}
$FAMILYSITE = $row->FAMILYSITE;
$category = $catz->GET_CATEGORIES($FAMILYSITE);
if ($category != null) {
$category_text = " (category:{$category})";
}
$REPORT[] = "Web site: {$FAMILYSITE} {$size}MB used{$category_text}";
}
squid_admin_mysql(0, "Bandwidth usage {$EXCEED_SIZE}MB exceed {$CHECK_BANDWITDH_SIZE}MB", @implode("\n", $REPORT), __FILE__, __LINE__);
}
示例15: mQuotaWebFilter
function mQuotaWebFilter()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/exec.squid.stats.hours.php.mQuotaWebFilter.pid";
$timefile = "/etc/artica-postfix/pids/exec.squid.stats.hours.php.mQuotaWebFilter.time";
$sock = new sockets();
$SquidPerformance = intval($sock->GET_INFO("SquidPerformance"));
if ($SquidPerformance > 1) {
die;
}
$pid = $unix->get_pid_from_file($pidfile);
if (!$GLOBALS["FORCE"]) {
if ($pid < 100) {
$pid = null;
}
$unix = new unix();
if ($unix->process_exists($pid, basename(__FILE__))) {
$rpcessTime = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["VERBOSE"]) {
echo "Already executed pid {$pid} since {$rpcessTime}Mn\n";
}
if ($rpcessTime < 10) {
return;
}
$unix->KILL_PROCESS($pid, 9);
}
$timeexec = $unix->file_time_min($timefile);
if ($timeexec < 30) {
return;
}
$mypid = getmypid();
@file_put_contents($pidfile, $mypid);
}
build_last_hour();
$ipClass = new IP();
if ($GLOBALS["VERBOSE"]) {
echo "Time File: {$timefile}\n";
}
$ARRAY["TIME_BUILD"] = time();
$q = new mysql_squid_builder();
$influx = new influx();
$date_from = InfluxQueryFromUTC(strtotime("-1 hour"));
$sql = "SELECT SUM(SIZE) as size,USERID,IPADDR,MAC,CATEGORY FROM access_log GROUP BY time(1h) ,USERID,IPADDR,MAC,CATEGORY WHERE time > {$date_from}s";
if ($GLOBALS["VERBOSE"]) {
echo "{$sql}\n";
}
$main = $influx->QUERY_SQL($sql);
foreach ($main as $row) {
$CATEGORY = $row->CATEGORY;
$USERID = strtolower($row->USERID);
$IPADDR = $row->IPADDR;
$MAC = $row->MAC;
$size = intval($row->size);
if ($size == 0) {
continue;
}
if ($CATEGORY != null) {
if (!isset($ARRAY["categories"][$CATEGORY]["HOUR"][$USERID])) {
$ARRAY["categories"][$CATEGORY]["HOUR"][$USERID] = $size;
} else {
$size_old = intval($ARRAY["categories"][$CATEGORY]["HOUR"][$USERID]);
$size_old = $size_old + $size;
$ARRAY["categories"][$CATEGORY]["HOUR"][$USERID] = $size_old;
}
if (!isset($ARRAY["categories"][$CATEGORY]["HOUR"][$IPADDR])) {
$ARRAY["categories"][$CATEGORY]["HOUR"][$IPADDR] = $size;
} else {
$size_old = $ARRAY["categories"][$CATEGORY]["HOUR"][$IPADDR];
$size_old = $size_old + $size;
if ($size_old == 0) {
echo "Warning {$CATEGORY}/{$IPADDR} {$ARRAY["categories"][$CATEGORY]["HOUR"][$IPADDR]} + {$size} = 0\n";
}
$ARRAY["categories"][$CATEGORY]["HOUR"][$IPADDR] = $size_old;
}
if (!isset($ARRAY["categories"][$CATEGORY]["HOUR"][$MAC])) {
$ARRAY["categories"][$CATEGORY]["HOUR"][$MAC] = $size;
} else {
$size_old = $ARRAY["categories"][$CATEGORY]["HOUR"][$MAC];
$size_old = $size_old + $size;
$ARRAY["categories"][$CATEGORY]["HOUR"][$MAC] = $size_old;
}
}
if (!isset($ARRAY["UID"][$USERID]["HOUR"])) {
$ARRAY["UID"][$USERID]["HOUR"] = $size;
} else {
$size_old = $ARRAY["UID"][$USERID]["HOUR"];
$size_old = $size_old + $size;
$ARRAY["UID"][$USERID]["HOUR"] = $size_old;
}
if (!isset($ARRAY["IPADDR"][$IPADDR]["HOUR"])) {
$ARRAY["IPADDR"][$IPADDR]["HOUR"] = $size;
} else {
$size_old = $ARRAY["IPADDR"][$IPADDR]["HOUR"];
$size_old = $size_old + $size;
$ARRAY["IPADDR"][$IPADDR]["HOUR"] = $size_old;
}
if ($ipClass->IsvalidMAC($MAC)) {
if (!isset($ARRAY["MAC"][$MAC]["HOUR"])) {
$ARRAY["MAC"][$MAC]["HOUR"] = $size;
} else {
//.........这里部分代码省略.........