diff --git a/web/ajax.php b/web/ajax.php
index 5b8a6a21..992cdb94 100644
--- a/web/ajax.php
+++ b/web/ajax.php
@@ -243,37 +243,14 @@ if ($ui->smallletters('w', 9, 'get') == 'datatable') {
die;
-} else if (isset($admin_id) and $pa['voiceserverStats'] and $ui->smallletters('d', 15, 'get') == 'adminvoicestats' and $ui->st('w', 'get')) {
+} else if (isset($user_id) and $pa['usertickets'] and $ui->w('d', 20, 'get') == 'userTicketCategories' and $ui->id('topicName', 10, 'get')) {
- $data = array();
+ require_once(EASYWIDIR . '/stuff/ajax/userpanel_ticket_category.php');
+ die;
- if ($ui->st('w', 'get') == 'us') {
- $query = $sql->prepare("SELECT u.`id`,u.`cname`,u.`vname`,u.`name` FROM `userdata` u INNER JOIN `voice_server` v ON u.`id`=v.`userid` AND v.`active`='Y' WHERE u.`resellerid`=? GROUP BY u.`id`");
- $query->execute(array($resellerLockupID));
- while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
- $data[] = '';
- }
-
- } else if ($ui->st('w', 'get') == 'se') {
-
- $query = $sql->prepare("SELECT v.`id`,v.`ip`,v.`port`,v.`dns`,m.`usedns` FROM `voice_server` v INNER JOIN `voice_masterserver` m ON v.`masterserver`=m.`id` WHERE v.`resellerid`=? ORDER BY v.`ip`,v.`port`");
- $query->execute(array($resellerLockupID));
- while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
- $data[] = '';
- }
-
- } else if ($ui->st('w', 'get') == 'ma') {
-
- $query = $sql->prepare("SELECT `id`,`ssh2ip` FROM `voice_masterserver` WHERE `resellerid`=? AND `active`='Y' ORDER BY `ssh2ip`");
- $query->execute(array($resellerLockupID));
- while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
- $data[] = '';
- }
-
- }
-
- require_once IncludeTemplate($template_to_use, 'ajax_admin_voice_stats.tpl', 'ajax');
+} else if (isset($admin_id) and $pa['voiceserverStats'] and $ui->w('d', 15, 'get') == 'adminVoiceStats' and $ui->st('w', 'get')) {
+ require_once(EASYWIDIR . '/stuff/ajax/admin_voice_stats.php');
die;
} else if (isset($user_id) and $pa['voiceserverStats'] and $ui->smallletters('d', 14, 'get') == 'uservoicestats' and $ui->st('w', 'get')) {
@@ -281,12 +258,7 @@ if ($ui->smallletters('w', 9, 'get') == 'datatable') {
require_once(EASYWIDIR . '/stuff/ajax/userpanel_voice_stats.php');
die;
-} else if (isset($user_id) and $pa['usertickets'] and $ui->w('d', 20, 'get') == 'userTicketCategories' and $ui->id('topicName', 10, 'get')) {
-
- require_once(EASYWIDIR . '/stuff/ajax/userpanel_ticket_category.php');
- die;
-
-} else if (isset($user_id) and $pa['voiceserverStats'] and $ui->w('d', 14, 'get') == 'voiceUserStats') {
+} else if ($pa['voiceserverStats'] and ((isset($user_id) and $ui->w('d', 14, 'get') == 'voiceUserStats') or (isset($admin_id) and $ui->w('d', 15, 'get') == 'voiceAdminStats'))) {
require_once(EASYWIDIR . '/stuff/ajax/stats_voicestats.php');
die;
diff --git a/web/stuff/admin/voice_usage.php b/web/stuff/admin/voice_usage.php
index 9645f992..0ea68ce7 100644
--- a/web/stuff/admin/voice_usage.php
+++ b/web/stuff/admin/voice_usage.php
@@ -41,7 +41,8 @@ if (!isset($admin_id) or $main != 1 or (isset($admin_id) and !$pa['voiceserver']
die;
}
-$sprache = getlanguagefile('traffic',$user_language,$reseller_id);
+$sprache = getlanguagefile('traffic', $user_language, $reseller_id);
+$voSprache = getlanguagefile('voice', $user_language, $reseller_id);
if ($ui->w('action', 4, 'post') and !token(true)) {
@@ -50,199 +51,159 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
} else if ($pa['voiceserverStats']) {
$data = array();
+ $freeSlots = 0;
+ $usedSlots = 0;
+ $freeTraffic = 0;
+ $fileTraffic = 0;
+ $kind = 'al';
+ $selectedID = 0;
- $display = $sprache->total;
- if (!$ui->st('kind', 'post') or $ui->st('kind', 'post') == 'al') {
+ $display = $sprache->total;
- $kind = 'al';
- $whichdata = '';
+ $dateRange = ($ui->escaped('dateRange', 'post')) ? $ui->escaped('dateRange', 'post') : date('m/d/Y', strtotime("-6 days")) . ' - ' . date('m/d/Y');
+ $accuracy = (in_array($ui->st('accuracy', 'post'), array('da', 'mo'))) ? $ui->st('accuracy', 'post') : 'da';
- } else if ($ui->id('what', 30, 'post') and $ui->st('kind', 'post') == 'us') {
+ @list($startDate, $endDate) = explode('-', str_replace(' ', '', $dateRange));
+ @list($startMonth, $startDay, $startYear) = explode('/', $startDate);
+ @list($endMonth, $endDay, $endYear) = explode('/', $endDate);
+ $menuStart = round((strtotime("{$endYear}-{$endMonth}-{$endDay}") - strtotime("{$startYear}-{$startMonth}-{$startDay}")) / 86400);
- $kind = 'us';
- $extra = $sprache->user;
+ if ($ui->id('masterID', 10, 'post')) {
- $whichdata = '&distro=' . $ui->id('what', 30, 'post');
+ $selectedID = $ui->id('masterID', 10, 'post');
- $query = $sql->prepare("SELECT u.`id`,u.`cname`,u.`vname`,u.`name` FROM `userdata` u INNER JOIN `voice_server` v ON u.`id`=v.`userid` AND v.`active`='Y' WHERE u.`resellerid`=? GROUP BY u.`id`");
- $query->execute(array($reseller_id));
- while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
- if ($ui->id('what', 30, 'post') == $row['id']) {
- $data[] = '';
- } else {
- $data[] = '';
- }
- }
+ $query = $sql->prepare("SELECT SUM(`slots`) AS `s`,SUM(`usedslots`) AS `u`,SUM(`maxtraffic`) AS `m`,SUM(`filetraffic`) AS `f` FROM `voice_server` WHERE `masterserver`=? AND `resellerid`=?");
+ $query->execute(array($ui->id('masterID', 10, 'post'), $resellerLockupID));
- $query = $sql->prepare("SELECT `cname` FROM `userdata` WHERE `accounttype`='r' AND `id`=? AND `resellerid`=? LIMIT 1");
- $query->execute(array($ui->id('what', 30, 'post'),$reseller_id));
- while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
- $display = $extra . ' ' . $row['cname'];
- }
+ } else if ($ui->id('userID', 10, 'post')) {
- } else if ($ui->id('what', 30, 'post') and $ui->st('kind', 'post') == 'se') {
+ $selectedID = $ui->id('userID', 10, 'post');
- $kind = 'se';
- $whichdata = '&shorten=' . $ui->id('what', 30, 'post');
+ $query = $sql->prepare("SELECT SUM(`slots`) AS `s`,SUM(`usedslots`) AS `u`,SUM(`maxtraffic`) AS `m`,SUM(`filetraffic`) AS `f` FROM `voice_server` WHERE `userid`=? AND `resellerid`=? LIMIT 1");
+ $query->execute(array($ui->id('userID', 10, 'post'), $resellerLockupID));
- $query = $sql->prepare("SELECT v.`id`,v.`ip`,v.`port`,v.`dns`,m.`usedns` FROM `voice_server` v INNER JOIN `voice_masterserver` m ON v.`masterserver`=m.`id` WHERE v.`id`=? AND v.`resellerid`=? AND v.`active`='Y' AND m.`active`='Y' LIMIT 1");
- $query->execute(array($ui->id('what', 30, 'post'),$reseller_id));
- while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
- $display = $sprache->server . ' ' . $row['ip'] . ':' . $row['port'];
- }
+ } else if ($ui->id('serverID', 10, 'post')) {
- $query = $sql->prepare("SELECT v.`id`,v.`ip`,v.`port`,v.`dns`,m.`usedns` FROM `voice_server` v INNER JOIN `voice_masterserver` m ON v.`masterserver`=m.`id` WHERE v.`resellerid`=? AND v.`active`='Y' AND m.`active`='Y' ORDER BY v.`ip`,v.`port`");
- $query->execute(array($reseller_id));
- while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
- $server = $row['ip'] . ':' . $row['port'];
- if ($ui->id('what', 30, 'post') == $row['id']) {
- $data[] = '';
- } else {
- $data[] = '';
- }
- }
+ $selectedID = $ui->id('serverID', 10, 'post');
- } else if ($ui->id('what', 30, 'post') and $ui->st('kind', 'post') == 'ma') {
+ $query = $sql->prepare("SELECT `slots` AS `s`,`usedslots` AS `u`,`maxtraffic` AS `m`,`filetraffic` AS `f` FROM `voice_server` WHERE `id`=? AND `resellerid`=? LIMIT 1");
+ $query->execute(array($ui->id('serverID', 10, 'post'), $resellerLockupID));
- $kind = 'ma';
- $whichdata = '&short=' . $ui->id('what', 30, 'post');
+ } else {
+ $query = $sql->prepare("SELECT SUM(`slots`) AS `s`, SUM(`usedslots`) AS `u`, SUM(`maxtraffic`) AS `m`, SUM(`filetraffic`) AS `f` FROM `voice_server` WHERE `resellerid`=?");
+ $query->execute(array($resellerLockupID));
+ }
- $query = $sql->prepare("SELECT `ssh2ip` FROM `voice_masterserver` WHERE `id`=? AND `resellerid`=? AND `active`='Y' LIMIT 1");
- $query->execute(array($ui->id('what', 30, 'post'), $reseller_id));
- while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
- $display = $sprache->server . ' ' . $row['ssh2ip'];
- }
+ while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
+ $freeSlots = (int) ($row['s'] - $row['u']);
+ $usedSlots = (int) $row['u'];
+ $freeTraffic = ceil($row['m'] - ($row['f'] / 1024));
+ $fileTraffic = ceil($row['f'] / 1024);
+ }
- $query = $sql->prepare("SELECT `id`,`ssh2ip` FROM `voice_masterserver` WHERE `resellerid`=? AND `active`='Y' ORDER BY `ssh2ip`");
- $query->execute(array($reseller_id));
- while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
- if ($ui->id('what', 30, 'post') == $row['id']) {
- $data[] = '';
- } else {
- $data[] = '';
- }
- }
- }
+ if ($ui->id('masterID', 10, 'post') and $ui->st('kind', 'post') == 'ma') {
- if (!isset($ui->post['dmy'])) {
+ $kind = 'ma';
- $dmy = 'da';
- $year = date('Y',strtotime('-6 days'));
- $month = date('m',strtotime('-6 days'));
- $day = date('d',strtotime('-6 days'));
- $yearstop = date('Y');
- $monthstop = date('m');
- $daystop = date('d');
- $amount = 7;
+ } else if ($ui->id('serverID', 10, 'post') and $ui->st('kind', 'post') == 'us') {
- } else if ($ui->post['dmy'] == 'da') {
+ $kind = 'us';
- $dmy = 'da';
+ } else if ($ui->id('serverID', 10, 'post') and $ui->st('kind', 'post') == 'se') {
- $year = ($ui->isinteger('yearstart', 'post') and $ui->isinteger('yearstart', 'post') <= date('Y')) ? $ui->isinteger('yearstart', 'post') : date('Y', strtotime('-6 days'));
- $yearstop = ($ui->isinteger('yearstop', 'post') and $ui->isinteger('yearstop', 'post') <= date('Y')) ? $ui->isinteger('yearstop', 'post') : date('Y');
+ $kind = 'se';
- $month = ($ui->isinteger('monthstart', 'post') and $ui->isinteger('monthstart', 'post') <= 12) ? $ui->isinteger('monthstart', 'post') : date('m', strtotime('-6 days'));
- $monthstop = ($ui->isinteger('monthstop', 'post') and $ui->isinteger('monthstop', 'post') <= 12) ? $ui->isinteger('monthstop', 'post') : date('m');
+ $query = $sql->prepare("SELECT v.`ip`,v.`port` FROM `voice_server` v INNER JOIN `voice_masterserver` m ON v.`masterserver`=m.`id` WHERE v.`id`=? AND v.`resellerid`=? LIMIT 1");
+ $query->execute(array($ui->id('serverID', 10, 'post'), $resellerLockupID));
+ $display = $query->fetchColumn();
+ }
- $day = ($ui->isinteger('daystart', 'post') and $ui->isinteger('daystart', 'post') <= 31) ? $ui->isinteger('daystart', 'post') : date('d', strtotime('-6 days'));
- $daystop = ($ui->isinteger('daystop', 'post') and $ui->isinteger('daystop', 'post') <= 31) ? $ui->isinteger('daystop', 'post') : date('d');
+ $htmlExtraInformation['css'][] = '';
+ $htmlExtraInformation['js'][] = '';
+ $htmlExtraInformation['js'][] = '';
- $now = date('Y-m-d');
- $date1 = strtotime("$year-$month-$day");
- $date2 = strtotime("$yearstop-$monthstop-$daystop");
- $amount = intval(($date2 - $date1) / 86400) + 1;
+ $htmlExtraInformation['js'][] = "";
- if ($amount < 0 and "$yearstop-$monthstop-$daystop" > $now){
- $yearstop = date('Y');
- $monthstop = date('m');
- $daystop = date('d');
- $day = date('d',strtotime('-6 days'));
- $month = date('m',strtotime('-6 days'));
- $year = date('Y',strtotime('-6 days'));
- $amount = 7;
- }
+ $htmlExtraInformation['css'][] = '';
+ $htmlExtraInformation['js'][] = '';
+ $htmlExtraInformation['js'][] = '';
+ $htmlExtraInformation['js'][] = "";
- $amount = $i;
-
- if ($amount < 0 or "$yearstop-$monthstop" > $now){
- $yearstop = date('Y');
- $monthstop = date('m');
- $daystop = date('t', strtotime("$yearstop-$monthstop"));
- $day = 1;
- $month = date('m', strtotime('-6 months'));
- $year = date('Y', strtotime('-6 months'));
- $amount = 7;
- }
-
- } else if ($ui->post['dmy'] == 'ye') {
-
- $dmy = 'ye';
- $day = 1;
-
- $year = ($ui->isinteger('yearstart', 'post') and $ui->isinteger('yearstart', 'post') <= date('Y')) ? $ui->isinteger('yearstart', 'post') : date('Y', strtotime('-6 days'));
- $yearstop = ($ui->isinteger('yearstop', 'post') and $ui->isinteger('yearstop', 'post') <= date('Y')) ? $ui->isinteger('yearstop', 'post') : date('Y');
-
- $month = 1;
- $monthstop = 12;
- $daystop = 31;
-
- $now = date('Y');
- $date1 = strtotime($year . '-' . $month . '-' . $day);
- $date2 = strtotime($yearstop . '-' . $monthstop . '-' . $daystop);
- $add = $date1;
- $i = 0;
-
- while ($add <= $date2) {
- $add = strtotime('+1 year', $add);
- $i++;
- }
-
- $amount = $i;
-
- if ($amount < 0 or "$yearstop" > $now){
- $yearstop = date('Y');
- $monthstop = 12;
- $daystop = 31;
- $day = 1;
- $month = 1;
- $year = date('Y', strtotime('-1 year'));
- $amount = 2;
- }
- }
-
- if ($user_language == 'de') {
- $startdate = $day . '.' . $month . '.' . $year;
- $stopdate = $daystop . '.' . $monthstop . '.' . $yearstop;
- } else {
- $startdate = $year . '-' . $month . '-' . $day;
- $stopdate = $yearstop . '-' . $monthstop . '-' . $daystop;
- }
-
- $getlink = "images.php?img=vo&from=admin&d={$dmy}&p={$year}&id={$day}&po={$month}&m={$amount}{$whichdata}";
$template_file = 'admin_voice_stats.tpl';
}
\ No newline at end of file
diff --git a/web/stuff/ajax/admin_voice_stats.php b/web/stuff/ajax/admin_voice_stats.php
new file mode 100644
index 00000000..129d27a3
--- /dev/null
+++ b/web/stuff/ajax/admin_voice_stats.php
@@ -0,0 +1,74 @@
+
+ *
+ * This file is part of Easy-WI.
+ *
+ * Easy-WI is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Easy-WI is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Easy-WI. If not, see