switch ($action) { case "today": $accts = $BILL->GetTodayUsersAccts($sort, 0, $gid); $wday = date("w"); if ($wday == 0) { $wday = 6; } $head = "Статистика по пользователям за " . $wdaysto[$wday - 1] . ", " . date("d") . " " . $monthsof[date("n") - 1] . "" . date(" Y года"); break; case "month": $accts = $BILL->GetMonthUsersAccts($sort, 0, $gid); $head = "Статистика по пользователям за " . $months[date("n") - 1] . " " . date("Y") . " года:<br>\n <small>(по состоянию на " . date("d") . " " . $monthsof[date("n") - 1] . ")</small>"; break; case "week": $accts = $BILL->GetWeekUsersAccts($sort, 0, $gid); get_current_week(&$b, &$a, 0); $head = "Статистика по пользователям за текущую неделю:<br><small>(" . date_dmy(strtotime($b)) . " - " . date_dmy(strtotime($a)) . ")</small>"; break; case "sessions": if ($mod == "show") { if (!isset($groupby)) { $groupby = ""; } if ($daysel[0] == "null") { $daysel1 = 1; } else { $daysel1 = $daysel[0]; } if ($monsel[0] == "null") { $monsel1 = 1; } else {
function GetWeekUsersAccts($order = ">traffic", $draw = false, $gid = "all") { global $GV; if ($gid != "all") { $gidwhere = " where `gid`='" . $gid . "' "; } else { $gidwhere = ""; } if ($gid != "all") { $gidandwhere = " and `gid`='" . $gid . "' "; } else { $gidandwhere = ""; } if ($order == ">user") { $uorder = " order by LOWER(`user`) desc"; } elseif ($order == "<user") { $uorder = " order by LOWER(`user`) asc"; } elseif ($order == ">fio") { $uorder = " order by LOWER(`fio`) desc"; } elseif ($order == "<fio") { $uorder = " order by LOWER(`fio`) asc"; } else { $uorder = ""; } $query = "select user,fio,uid,nick from `" . $GV["users_tbl"] . "`{$gidwhere}" . $uorder . ";"; $result = mysql_query($query, $this->link) or die($query . " : " . mysql_error()); if (mysql_num_rows($result) == 0) { return NULL; } $users = NULL; $k = 0; while ($row = mysql_fetch_array($result)) { $users[$k]["fio"] = $row["fio"]; $users[$k]["user"] = $row["user"]; $users[$k]["nick"] = $row["nick"]; $users[$k++]["uid"] = $row["uid"]; } get_current_week($bdate, $adate, 1); $res = NULL; $k = 0; if ($draw) { $sum_traf = 0; $sum_time = 0; for ($i = 0; $i < count($users); ++$i) { $query = "select sum(out_bytes),sum(in_bytes),sum(time_on) from `" . $GV["actions_tbl"] . "` where start_time>'" . $bdate . "' and stop_time<'" . $adate . "' and `user`='" . $users[$i]["user"] . "';"; $result = mysql_query($query); $row = mysql_fetch_array($result); $sum_traf += (int) $row["sum(out_bytes)"]; $sum_time += (int) $row["sum(time_on)"]; } $res_others["traffic"] = 0; $res_others["time"] = 0; $res_others["user"] = "******"; } for ($i = 0; $i < count($users); ++$i) { $query = "select sum(out_bytes),sum(in_bytes),sum(time_on) from `" . $GV["actions_tbl"] . "` where user='******' and start_time>='" . $bdate . "' and stop_time<='" . $adate . "';"; $result = mysql_query($query); $row = mysql_fetch_array($result); $traf = (int) $row["sum(out_bytes)"]; $time = (int) $row["sum(time_on)"]; $ok = true; if ($draw) { if ($traf < 0.06 * $sum_traf) { $ok = false; $res_others["traffic"] += $traf; $res_others["time"] += $time; } else { $ok = true; } } if ($ok && ($traf || $time)) { $res[$k]["traffic"] = $traf; $res[$k]["time"] = $time; $res[$k]["user"] = $users[$i]["user"]; $res[$k]["uid"] = $users[$i]["uid"]; $res[$k]["nick"] = $users[$i]["nick"]; $res[$k++]["fio"] = $users[$i]["fio"]; } } if (count($res)) { if ($order == ">traffic") { usort($res, "accts_compare_traffic_desc"); } elseif ($order == ">time") { usort($res, "accts_compare_time_desc"); } elseif ($order == "<traffic") { usort($res, "accts_compare_traffic_asc"); } elseif ($order == "<time") { usort($res, "accts_compare_time_asc"); } $res = array_values($res); } if ($draw && $res_others["traffic"]) { $res[$k]["traffic"] = $res_others["traffic"]; $res[$k]["time"] = $res_others["time"]; $res[$k]["nick"] = $res_others["user"]; $res[$k]["fio"] = $res_others["user"]; $res[$k]["user"] = $res_others["user"]; } return $res; }