From: kkalev Date: Tue, 23 Sep 2003 12:09:43 +0000 (+0000) Subject: Calculate weekly used time correctly (from Sunday 00:00:00) X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=594f9a65af31781c8e117c91f492172e443f3d64;p=freeradius-dialup-admin.git Calculate weekly used time correctly (from Sunday 00:00:00) --- diff --git a/Changelog b/Changelog index f5f4407..98dcb70 100644 --- a/Changelog +++ b/Changelog @@ -41,6 +41,7 @@ Ver 1.63: * Add a few more attribute help pages from Ulrich Walcher * Also check for $server != '' in stats.php3. Bug noted by Ulrich Walcher * Consider the account locked either if Dialup-Access == FALSE or if it is not set at all +* Calculate weekly used time correctly (from Sunday 00:00:00) Ver 1.62: * Remove one sql query from user_admin which was not needed. * Instead of a query like "LIKE 'YYYY-MM-DD%'" use "AcctStopTime >= 'YYYY-MM-DD 00:00:00 AND AcctStopTime diff --git a/htdocs/user_admin.php3 b/htdocs/user_admin.php3 index e9a44c1..1be9a42 100644 --- a/htdocs/user_admin.php3 +++ b/htdocs/user_admin.php3 @@ -93,7 +93,6 @@ if ($link){ AND AcctStartTime >= '$week_str' AND AcctStartTime <= '$now_str';"); if ($search){ $row = @da_sql_fetch_array($search,$config); - $weekly_used = $row['sum(AcctSessionTime)']; $tot_time = time2str($row['sum(AcctSessionTime)']); $tot_input = bytes2str($row['sum(AcctInputOctets)']); $tot_output = bytes2str($row['sum(AcctOutputOctets)']); @@ -105,6 +104,15 @@ if ($link){ else echo "Database query failed: " . da_sql_error($link,$config) . "
\n"; $search = @da_sql_query($link,$config, + "SELECT sum(AcctSessionTime) FROM $config[sql_accounting_table] WHERE UserName = '$login' + AND AcctStartTime >= '$week_start' AND AcctStartTime <= '$now_str';"); + if ($search){ + $row = @da_sql_fetch_array($search,$config); + $weekly_used = $row['sum(AcctSessionTime)']; + } + else + echo "Database query failed: " . da_sql_error($link,$config) . "
\n"; + $search = @da_sql_query($link,$config, "SELECT COUNT(*) FROM $config[sql_accounting_table] WHERE UserName = '$login' AND AcctStopTime >= '$week_str' AND AcctStopTime <= '$now_str' AND (AcctTerminateCause LIKE 'Login-Incorrect%' OR