Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
smradius
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
smradius
smradius
Compare revisions
d7135ca21b5dfdbfaeafeab45ff3e08d83e97dc9 to master
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
smradius/smradius
Select target project
No results found
master
Select Git revision
Swap
Target
centiva-shail/smradius
Select target project
smradius/smradius
centiva-shail/smradius
nkukard/smradius
3 results
d7135ca21b5dfdbfaeafeab45ff3e08d83e97dc9
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
webui/user/index.php
+384
-469
384 additions, 469 deletions
webui/user/index.php
webui/user/logs.php
+71
-51
71 additions, 51 deletions
webui/user/logs.php
webui/user/styles.css
+1
-1
1 addition, 1 deletion
webui/user/styles.css
with
456 additions
and
521 deletions
webui/user/index.php
View file @
b659b33b
<?php
<?php
# Main User Control Panel Page
# Main User Control Panel Page
# Copyright (c) 2007-20
09
, AllWorldIT
# Copyright (c) 2007-20
15
, AllWorldIT
#
#
# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
...
@@ -25,6 +25,12 @@ include("include/header.php");
...
@@ -25,6 +25,12 @@ include("include/header.php");
# NB: We will only end up here if we authenticated!
# NB: We will only end up here if we authenticated!
# Displays error
function
webuiError
(
$msg
)
{
echo
isset
(
$msg
)
?
$msg
:
"Unknown error"
;
}
# Display details
# Display details
function
displayDetails
()
{
function
displayDetails
()
{
global
$db
;
global
$db
;
...
@@ -33,82 +39,90 @@ function displayDetails() {
...
@@ -33,82 +39,90 @@ function displayDetails() {
# Get user's ID
# Get user's ID
$sql
=
"
$sql
=
"
SELECT
SELECT
ID
ID
, Username
FROM
FROM
${DB_TABLE_PREFIX}users
${DB_TABLE_PREFIX}users
WHERE
WHERE
Username = "
.
$db
->
quote
(
$_SESSION
[
'username'
])
.
"
Username = "
.
$db
->
quote
(
$_SESSION
[
'username'
])
.
"
"
;
"
;
$res
=
$db
->
query
(
$sql
);
$res
=
$db
->
query
(
$sql
);
if
(
!
(
is_object
(
$res
)))
{
webuiError
(
"Error fetching user information"
);
}
$row
=
$res
->
fetchObject
();
$row
=
$res
->
fetchObject
();
# Set user ID
# Set user ID
$userID
=
$row
->
id
;
$userID
=
$row
->
id
;
$username
=
$row
->
username
;
# Get accounting data
# Get accounting data
$currentMonth
=
date
(
"Y-m"
);
$currentMonth
=
date
(
"Y-m"
);
$sql
=
"
$sql
=
"
SELECT
SELECT
AcctSessionTime,
SUM(AcctSessionTime) / 60 AS
AcctSessionTime,
AcctInputOctets
,
SUM(
AcctInputOctets
) / 1024 / 1024 +
AcctInputGigawords
,
SUM(
AcctInputGigawords
) * 4096 +
AcctOutputOctets
,
SUM(
AcctOutputOctets
) / 1024 / 1024 +
AcctOutputGigawords
SUM(
AcctOutputGigawords
) * 4096 AS TotalTraffic
FROM
FROM
${DB_TABLE_PREFIX}accounting
${DB_TABLE_PREFIX}accounting
WHERE
WHERE
Username = "
.
$db
->
quote
(
$
_SESSION
[
'
username
'
]
)
.
"
Username = "
.
$db
->
quote
(
$username
)
.
"
AND
AND
EventTimestamp >= "
.
$db
->
quote
(
$currentMonth
)
.
"
PeriodKey = "
.
$db
->
quote
(
$currentMonth
)
.
"
ORDER BY
EventTimestamp
DESC
"
;
"
;
$res
=
$db
->
query
(
$sql
);
$res
=
$db
->
query
(
$sql
);
if
(
!
(
is_object
(
$res
)))
{
webuiError
(
"Error fetching user accounting"
);
}
# Set total traffic and uptime used
# Set total traffic and uptime used
$totalTraffic
=
0
;
$totalTraffic
=
0
;
$totalUptime
=
0
;
$totalUptime
=
0
;
while
(
$row
=
$res
->
fetchObject
())
{
# Traffic in
# Pull in row
$inputDataItem
=
0
;
$row
=
$res
->
fetchObject
();
if
(
isset
(
$row
->
acctinputoctets
)
&&
$row
->
acctinputoctets
>
0
)
{
$inputDataItem
+=
(
$row
->
acctinputoctets
/
1024
)
/
1024
;
}
if
(
isset
(
$row
->
acctinputgigawords
)
&&
$row
->
acctinputgigawords
>
0
)
{
$inputDataItem
+=
(
$row
->
acctinputgigawords
*
4096
);
}
$totalTraffic
+=
$inputDataItem
;
# Traffic
if
(
isset
(
$row
->
totaltraffic
)
&&
$row
->
totaltraffic
>
0
)
{
$totalTraffic
+=
$row
->
totaltraffic
;
}
# Uptime
if
(
isset
(
$row
->
acctsessiontime
)
&&
$row
->
acctsessiontime
>
0
)
{
$totalUptime
+=
$row
->
acctsessiontime
;
}
# Traffic out
# Fetch user uptime and traffic cap (group attributes)
$outputDataItem
=
0
;
$sql
=
"
SELECT
${DB_TABLE_PREFIX}group_attributes.Name, ${DB_TABLE_PREFIX}group_attributes.Value
FROM
${DB_TABLE_PREFIX}group_attributes, ${DB_TABLE_PREFIX}users_to_groups
WHERE
${DB_TABLE_PREFIX}users_to_groups.GroupID = ${DB_TABLE_PREFIX}group_attributes.GroupID
AND ${DB_TABLE_PREFIX}users_to_groups.UserID = "
.
$db
->
quote
(
$userID
)
.
"
AND ${DB_TABLE_PREFIX}group_attributes.Disabled = 0
"
;
$res
=
$db
->
query
(
$sql
);
if
(
!
(
is_object
(
$res
)))
{
webuiError
(
"Error fetching user attributes"
);
}
if
(
isset
(
$row
->
acctoutputoctets
)
&&
$row
->
acctoutputoctets
>
0
)
{
# Initial values
$outputDataItem
+=
(
$row
->
acctoutputoctets
/
1024
)
/
1024
;
$trafficCap
=
"Prepaid"
;
}
$uptimeCap
=
"Prepaid"
;
if
(
isset
(
$row
->
acctoutputgigawords
)
&&
$row
->
acctoutputgigawords
>
0
)
{
while
(
$row
=
$res
->
fetchObject
())
{
$outputDataItem
+=
(
$row
->
acctoutputgigawords
*
4096
);
if
(
$row
->
name
===
"SMRadius-Capping-Traffic-Limit"
)
{
$trafficCap
=
(
int
)
$row
->
value
;
}
}
if
(
$row
->
name
===
"SMRadius-Capping-Uptime-Limit"
)
{
$totalTraffic
+=
$outputDataItem
;
$uptimeCap
=
(
int
)
$row
->
value
;
# Uptime
$sessionTimeItem
=
0
;
if
(
isset
(
$row
->
acctsessiontime
)
&&
$row
->
acctsessiontime
>
0
)
{
$sessionTimeItem
+=
$row
->
acctsessiontime
;
}
}
$totalUptime
+=
$sessionTimeItem
;
# Round up
$totalUptime
=
ceil
(
$totalUptime
/
60
);
}
}
# Fetch user uptime and traffic cap
# Fetch user uptime and traffic cap
(user attributes)
$sql
=
"
$sql
=
"
SELECT
SELECT
Name, Value
Name, Value
...
@@ -116,17 +130,19 @@ function displayDetails() {
...
@@ -116,17 +130,19 @@ function displayDetails() {
${DB_TABLE_PREFIX}user_attributes
${DB_TABLE_PREFIX}user_attributes
WHERE
WHERE
UserID = "
.
$db
->
quote
(
$userID
)
.
"
UserID = "
.
$db
->
quote
(
$userID
)
.
"
AND Disabled = 0
"
;
"
;
$res
=
$db
->
query
(
$sql
);
$res
=
$db
->
query
(
$sql
);
if
(
!
(
is_object
(
$res
)))
{
webuiError
(
"Error fetching user attributes"
);
}
# Set uptime and traffic cap
# Override group_attributes with user attributes
$trafficCap
=
"Prepaid"
;
$uptimeCap
=
"Prepaid"
;
while
(
$row
=
$res
->
fetchObject
())
{
while
(
$row
=
$res
->
fetchObject
())
{
if
(
$row
->
name
==
"SMRadius-Capping-Traffic-Limit"
)
{
if
(
$row
->
name
==
=
"SMRadius-Capping-Traffic-Limit"
)
{
$trafficCap
=
(
int
)
$row
->
value
;
$trafficCap
=
(
int
)
$row
->
value
;
}
}
if
(
$row
->
name
==
"SMRadius-Capping-Uptime-Limit"
)
{
if
(
$row
->
name
==
=
"SMRadius-Capping-Uptime-Limit"
)
{
$uptimeCap
=
(
int
)
$row
->
value
;
$uptimeCap
=
(
int
)
$row
->
value
;
}
}
}
}
...
@@ -136,7 +152,9 @@ function displayDetails() {
...
@@ -136,7 +152,9 @@ function displayDetails() {
SELECT
SELECT
${DB_TABLE_PREFIX}topups_summary.Balance,
${DB_TABLE_PREFIX}topups_summary.Balance,
${DB_TABLE_PREFIX}topups.Type,
${DB_TABLE_PREFIX}topups.Type,
${DB_TABLE_PREFIX}topups.Value
${DB_TABLE_PREFIX}topups.Value,
${DB_TABLE_PREFIX}topups.ValidFrom,
${DB_TABLE_PREFIX}topups.ValidTo
FROM
FROM
${DB_TABLE_PREFIX}topups_summary,
${DB_TABLE_PREFIX}topups_summary,
${DB_TABLE_PREFIX}topups
${DB_TABLE_PREFIX}topups
...
@@ -146,511 +164,408 @@ function displayDetails() {
...
@@ -146,511 +164,408 @@ function displayDetails() {
AND ${DB_TABLE_PREFIX}topups_summary.PeriodKey = "
.
$db
->
quote
(
$currentMonth
)
.
"
AND ${DB_TABLE_PREFIX}topups_summary.PeriodKey = "
.
$db
->
quote
(
$currentMonth
)
.
"
AND ${DB_TABLE_PREFIX}topups_summary.Depleted = 0
AND ${DB_TABLE_PREFIX}topups_summary.Depleted = 0
ORDER BY
ORDER BY
${DB_TABLE_PREFIX}topups.Timestamp
${DB_TABLE_PREFIX}topups.Timestamp
ASC
"
;
"
;
$res
=
$db
->
query
(
$sql
);
$res
=
$db
->
query
(
$sql
);
if
(
!
(
is_object
(
$res
)))
{
webuiError
(
"Error fetching topup summaries"
);
}
# Store summary topups
# Store summary topups
$topups
=
array
();
$topups
=
array
();
$i
=
0
;
$i
=
0
;
while
(
$row
=
$res
->
fetchObject
())
{
while
(
$row
=
$res
->
fetchObject
())
{
$topups
[
$i
]
=
array
();
$topups
[
$i
]
=
array
();
$topups
[
$i
][
'Type'
]
=
$row
->
type
;
$topups
[
$i
][
'Type'
]
=
$row
->
type
;
$topups
[
$i
][
'Limit'
]
=
$row
->
balance
;
$topups
[
$i
][
'CurrentLimit'
]
=
$row
->
balance
;
$topups
[
$i
][
'OriginalLimit'
]
=
$row
->
value
;
$topups
[
$i
][
'Limit'
]
=
$row
->
value
;
$topups
[
$i
][
'ValidFrom'
]
=
$row
->
validfrom
;
$topups
[
$i
][
'Expires'
]
=
$row
->
validto
;
$i
++
;
$i
++
;
}
}
# Fetch user uptime and traffic topups
# Fetch user uptime and traffic topups
$thisMonth
UnixTime
=
strtotime
(
$currentMonth
)
;
$thisMonth
Timestamp
=
date
(
"Y-m"
)
.
'-01'
;
$now
=
time
(
);
$now
=
date
(
"Y-m-d"
);
$sql
=
"
$sql
=
"
SELECT
SELECT
Value, Type
Value, Type
, ValidFrom, ValidTo
FROM
FROM
${DB_TABLE_PREFIX}
topups
topups
WHERE
WHERE
${DB_TABLE_PREFIX}topups.
UserID = "
.
$db
->
quote
(
$userID
)
.
"
UserID = "
.
$db
->
quote
(
$userID
)
.
"
AND
${DB_TABLE_PREFIX}topups.
ValidFrom
>
= "
.
$db
->
quote
(
$thisMonth
Unix
Time
)
.
"
AND ValidFrom = "
.
$db
->
quote
(
$thisMonthTime
stamp
)
.
"
AND
${DB_TABLE_PREFIX}topups.
ValidTo > "
.
$db
->
quote
(
$now
)
.
"
AND ValidTo >
=
"
.
$db
->
quote
(
$now
)
.
"
AND
${DB_TABLE_PREFIX}topups.
Depleted = 0
AND Depleted = 0
ORDER BY
ORDER BY
${DB_TABLE_PREFIX}topups.
Timestamp
Timestamp
ASC
"
;
"
;
$res
=
$db
->
query
(
$sql
);
$res
=
$db
->
query
(
$sql
);
if
(
!
(
is_object
(
$res
)))
{
webuiError
(
"Error fetching topup"
);
}
# Store normal topups
# Store normal topups
while
(
$row
=
$res
->
fetchObject
())
{
while
(
$row
=
$res
->
fetchObject
())
{
$topups
[
$i
]
=
array
();
$topups
[
$i
]
=
array
();
$topups
[
$i
][
'Type'
]
=
$row
->
type
;
$topups
[
$i
][
'Type'
]
=
$row
->
type
;
$topups
[
$i
][
'Limit'
]
=
$row
->
value
;
$topups
[
$i
][
'Limit'
]
=
$row
->
value
;
$topups
[
$i
][
'ValidFrom'
]
=
$row
->
validfrom
;
$topups
[
$i
][
'Expires'
]
=
$row
->
validto
;
$i
++
;
$i
++
;
}
}
# Set excess traffic usage
# Calculate topup usage for prepaid and normal users
$excessTraffic
=
0
;
$totalTrafficTopupsAvail
=
0
;
if
(
is_numeric
(
$trafficCap
)
&&
$trafficCap
>
0
)
{
if
(
!
(
is_numeric
(
$trafficCap
)
&&
$trafficCap
==
0
))
{
$excessTraffic
+=
$totalTraffic
-
$trafficCap
;
}
elseif
(
is_string
(
$trafficCap
))
{
$excessTraffic
+=
$totalTraffic
;
}
#
Set excess uptime
usage
#
Excess
usage
$excess
Uptime
=
0
;
$excess
=
0
;
if
(
is_numeric
(
$uptimeCap
)
&&
$uptimeCap
>
0
)
{
if
(
$trafficCap
===
"Prepaid"
)
{
$excess
Uptime
+=
$totalUptime
-
$uptimeCap
;
$excess
=
$totalTraffic
;
}
else
if
(
is_string
(
$uptimeCap
))
{
}
else
{
$excess
Uptime
+=
$totalUptime
;
$excess
=
$totalTraffic
>
$trafficCap
?
(
$totalTraffic
-
$trafficCap
)
:
0
;
}
}
# Loop through traffic topups and check for current topup, total topups not being used
# Loop through all valid topups
if
(
is_string
(
$trafficCap
)
||
$trafficCap
!=
0
)
{
$trafficRows
=
array
();
$currentTrafficTopup
=
array
();
$topupTrafficRemaining
=
0
;
$i
=
0
;
$i
=
0
;
# User is using traffic from topups
foreach
(
$topups
as
$topup
)
{
if
(
$excessTraffic
>
0
)
{
foreach
(
$topups
as
$topupItem
)
{
# Traffic topups
if
(
$topupItem
[
'Type'
]
==
1
)
{
if
(
$topup
[
'Type'
]
==
1
)
{
if
(
$excessTraffic
<=
0
)
{
$topupTrafficRemaining
+=
$topupItem
[
'Limit'
];
# Topup not currently in use
next
(
$topupItem
);
if
(
$excess
<=
0
)
{
}
elseif
(
$excessTraffic
>=
$topupItem
[
'Limit'
])
{
$trafficRows
[
$i
]
=
array
();
$excessTraffic
-=
$topupItem
[
'Limit'
];
}
else
{
$trafficRows
[
$i
][
'Cap'
]
=
$topup
[
'Limit'
];
if
(
isset
(
$topupItem
[
'OriginalLimit'
]))
{
$trafficRows
[
$i
][
'Used'
]
=
isset
(
$topup
[
'CurrentLimit'
])
?
(
$topup
[
'Limit'
]
-
$topup
[
'CurrentLimit'
])
:
0
;
$currentTrafficTopup
[
'Cap'
]
=
$topupItem
[
'OriginalLimit'
];
$trafficRows
[
$i
][
'ValidFrom'
]
=
$topup
[
'ValidFrom'
];
}
else
{
$trafficRows
[
$i
][
'Expires'
]
=
$topup
[
'Expires'
];
$currentTrafficTopup
[
'Cap'
]
=
$topupItem
[
'Limit'
];
}
# Set total available topups
$currentTrafficTopup
[
'Used'
]
=
$excessTraffic
;
$totalTrafficTopupsAvail
+=
isset
(
$topup
[
'CurrentLimit'
])
?
$topup
[
'CurrentLimit'
]
:
$topup
[
'Limit'
];
$excessTraffic
-=
$topupItem
[
'Limit'
];
}
$i
++
;
}
}
# Topup currently in use
# User has not used traffic topups yet
}
elseif
(
!
isset
(
$topup
[
'CurrentLimit'
])
&&
$excess
<
$topup
[
'Limit'
])
{
}
else
{
$trafficRows
[
$i
]
=
array
();
foreach
(
$topups
as
$topupItem
)
{
if
(
$topupItem
[
'Type'
]
==
1
)
{
$trafficRows
[
$i
][
'Cap'
]
=
$topup
[
'Limit'
];
if
(
$i
==
0
)
{
$trafficRows
[
$i
][
'Used'
]
=
$excess
;
if
(
isset
(
$topupItem
[
'OriginalLimit'
]))
{
$trafficRows
[
$i
][
'ValidFrom'
]
=
$topup
[
'ValidFrom'
];
$currentTrafficTopup
[
'Cap'
]
=
$topupItem
[
'OriginalLimit'
];
$trafficRows
[
$i
][
'Expires'
]
=
$topup
[
'Expires'
];
}
else
{
$currentTrafficTopup
[
'Cap'
]
=
$topupItem
[
'Limit'
];
# Set total available topups
}
$totalTrafficTopupsAvail
+=
$topup
[
'Limit'
];
$i
=
1
;
$currentTrafficTopup
[
'Used'
]
=
0
;
# Set current topup
}
else
{
$currentTrafficTopup
=
array
();
$topupTrafficRemaining
+=
$topupItem
[
'Limit'
];
$currentTrafficTopup
[
'Used'
]
=
$excess
;
}
$currentTrafficTopup
[
'Cap'
]
=
$topup
[
'Limit'
];
# If we hit this topup then all the rest of them are available
$excess
=
0
;
$i
++
;
}
elseif
(
isset
(
$topup
[
'CurrentLimit'
])
&&
$excess
<
$topup
[
'CurrentLimit'
])
{
$trafficRows
[
$i
]
=
array
();
$trafficRows
[
$i
][
'Cap'
]
=
$topup
[
'Limit'
];
$trafficRows
[
$i
][
'Expires'
]
=
$topup
[
'Expires'
];
$trafficRows
[
$i
][
'ValidFrom'
]
=
$topup
[
'ValidFrom'
];
$trafficRows
[
$i
][
'Used'
]
=
(
$topup
[
'Limit'
]
-
$topup
[
'CurrentLimit'
])
+
$excess
;
# Set total available topups
$totalTrafficTopupsAvail
+=
$topup
[
'CurrentLimit'
];
# Set current topup
$currentTrafficTopup
=
array
();
$currentTrafficTopup
[
'Used'
]
=
(
$topup
[
'Limit'
]
-
$topup
[
'CurrentLimit'
])
+
$excess
;
$currentTrafficTopup
[
'Cap'
]
=
$topup
[
'Limit'
];
# If we hit this topup then all the rest of them are available
$excess
=
0
;
$i
++
;
# Topup has been used up
}
else
{
$trafficRows
[
$i
]
=
array
();
$trafficRows
[
$i
][
'Cap'
]
=
$topup
[
'Limit'
];
$trafficRows
[
$i
][
'Used'
]
=
$topup
[
'Limit'
];
$trafficRows
[
$i
][
'ValidFrom'
]
=
$topup
[
'ValidFrom'
];
$trafficRows
[
$i
][
'Expires'
]
=
$topup
[
'Expires'
];
# Subtract this topup from excess usage
$excess
-=
isset
(
$topup
[
'CurrentLimit'
])
?
$topup
[
'CurrentLimit'
]
:
$topup
[
'Limit'
];
$i
++
;
}
}
}
}
}
}
}
}
# Loop through uptime topups and check for current topup, total topups not being used
# Calculate topup usage for prepaid and normal users
if
(
is_string
(
$uptimeCap
)
||
$uptimeCap
!=
0
)
{
$totalUptimeTopupsAvail
=
0
;
$currentUptimeTopup
=
array
();
if
(
!
(
is_numeric
(
$uptimeCap
)
&&
$uptimeCap
==
0
))
{
$topupUptimeRemaining
=
0
;
$i
=
0
;
# Excess usage
# User is using uptime from topups
$excess
=
0
;
if
(
$excessUptime
>
0
)
{
if
(
$uptimeCap
===
"Prepaid"
)
{
foreach
(
$topups
as
$topupItem
)
{
$excess
=
$totalUptime
;
if
(
$topupItem
[
'Type'
]
==
2
)
{
if
(
$excessUptime
<=
0
)
{
$topupUptimeRemaining
+=
$topupItem
[
'Limit'
];
next
(
$topupItem
);
}
elseif
(
$excessUptime
>=
$topupItem
[
'Limit'
])
{
$excessUptime
-=
$topupItem
[
'Limit'
];
}
else
{
if
(
isset
(
$topupItem
[
'OriginalLimit'
]))
{
$currentUptimeTopup
[
'Cap'
]
=
$topupItem
[
'OriginalLimit'
];
}
else
{
$currentUptimeTopup
[
'Cap'
]
=
$topupItem
[
'Limit'
];
}
$currentUptimeTopup
[
'Used'
]
=
$excessUptime
;
$excessUptime
-=
$topupItem
[
'Limit'
];
}
}
}
# User has not used uptime topups yet
}
else
{
}
else
{
foreach
(
$topups
as
$topupItem
)
{
$excess
=
$totalUptime
>
$uptimeCap
?
(
$totalUptime
-
$uptimeCap
)
:
0
;
if
(
$topupItem
[
'Type'
]
==
2
)
{
if
(
$i
==
0
)
{
if
(
isset
(
$topupItem
[
'OriginalLimit'
]))
{
$currentUptimeTopup
[
'Cap'
]
=
$topupItem
[
'OriginalLimit'
];
}
else
{
$currentUptimeTopup
[
'Cap'
]
=
$topupItem
[
'Limit'
];
}
$i
=
1
;
$currentUptimeTopup
[
'Used'
]
=
0
;
}
else
{
$topupUptimeRemaining
+=
$topupItem
[
'Limit'
];
}
}
}
}
}
}
/*
# Loop through all valid topups
# Fetch user phone and email info
$uptimeRows
=
array
();
$sql = "
$i
=
0
;
SELECT
foreach
(
$topups
as
$topup
)
{
Phone, Email
FROM
${DB_TABLE_PREFIX}wisp_userdata
WHERE
UserID = '$userID'
";
$res = $db->query($sql);
# Uptime topups
if
(
$topup
[
'Type'
]
==
2
)
{
$userPhone = "Not set";
# Topup not currently in use
$userEmail = "Not set";
if
(
$excess
<=
0
)
{
if ($res->rowCount() > 0) {
$uptimeRows
[
$i
]
=
array
();
$row = $res->fetchObject();
$userPhone = $row->phone;
$uptimeRows
[
$i
][
'Cap'
]
=
$topup
[
'Limit'
];
$userEmail = $row->email;
$uptimeRows
[
$i
][
'Used'
]
=
isset
(
$topup
[
'CurrentLimit'
])
?
(
$topup
[
'Limit'
]
-
$topup
[
'CurrentLimit'
])
:
0
;
}
$uptimeRows
[
$i
][
'ValidFrom'
]
=
$topup
[
'ValidFrom'
];
*/
$uptimeRows
[
$i
][
'Expires'
]
=
$topup
[
'Expires'
];
# Set total available topups
$totalUptimeTopupsAvail
+=
isset
(
$topup
[
'CurrentLimit'
])
?
$topup
[
'CurrentLimit'
]
:
$topup
[
'Limit'
];
# These two items need fixing
$i
++
;
$isDialup
=
0
;
$userService
=
"Not set"
;
# Topup currently in use
}
elseif
(
!
isset
(
$topup
[
'CurrentLimit'
])
&&
$excess
<
$topup
[
'Limit'
])
{
$uptimeRows
[
$i
]
=
array
();
$uptimeRows
[
$i
][
'Cap'
]
=
$topup
[
'Limit'
];
$uptimeRows
[
$i
][
'Used'
]
=
$excess
;
$uptimeRows
[
$i
][
'ValidFrom'
]
=
$topup
[
'ValidFrom'
];
$uptimeRows
[
$i
][
'Expires'
]
=
$topup
[
'Expires'
];
# Set total available topups
$totalUptimeTopupsAvail
+=
$topup
[
'Limit'
];
# Set current topup
$currentUptimeTopup
=
array
();
$currentUptimeTopup
[
'Used'
]
=
$excess
;
$currentUptimeTopup
[
'Cap'
]
=
$topup
[
'Limit'
];
# If we hit this topup then all the rest of them are available
$excess
=
0
;
$i
++
;
}
elseif
(
isset
(
$topup
[
'CurrentLimit'
])
&&
$excess
<
$topup
[
'CurrentLimit'
])
{
$uptimeRows
[
$i
]
=
array
();
$uptimeRows
[
$i
][
'Cap'
]
=
$topup
[
'Limit'
];
$uptimeRows
[
$i
][
'Expires'
]
=
$topup
[
'Expires'
];
$uptimeRows
[
$i
][
'ValidFrom'
]
=
$topup
[
'ValidFrom'
];
$uptimeRows
[
$i
][
'Used'
]
=
(
$topup
[
'Limit'
]
-
$topup
[
'CurrentLimit'
])
+
$excess
;
# Set total available topups
$totalUptimeTopupsAvail
+=
$topup
[
'CurrentLimit'
];
# Set current topup
$currentUptimeTopup
=
array
();
$currentUptimeTopup
[
'Used'
]
=
(
$topup
[
'Limit'
]
-
$topup
[
'CurrentLimit'
])
+
$excess
;
$currentUptimeTopup
[
'Cap'
]
=
$topup
[
'Limit'
];
# If we hit this topup then all the rest of them are available
$excess
=
0
;
$i
++
;
# Topup has been used up
}
else
{
$uptimeRows
[
$i
]
=
array
();
$uptimeRows
[
$i
][
'Cap'
]
=
$topup
[
'Limit'
];
$uptimeRows
[
$i
][
'Used'
]
=
$topup
[
'Limit'
];
$uptimeRows
[
$i
][
'ValidFrom'
]
=
$topup
[
'ValidFrom'
];
$uptimeRows
[
$i
][
'Expires'
]
=
$topup
[
'Expires'
];
# Subtract this topup from excess usage
$excess
-=
isset
(
$topup
[
'CurrentLimit'
])
?
$topup
[
'CurrentLimit'
]
:
$topup
[
'Limit'
];
$i
++
;
}
}
}
}
# HTML
?>
?>
<table
class=
"blockcenter"
>
<table
class=
"blockcenter"
>
<tr>
<tr>
<td
colspan=
"4"
class=
"section"
>
Account Information
</td>
<td
width=
"500"
colspan=
"4"
class=
"section"
>
Account Information
</td>
</tr>
<tr>
<td
align=
"center"
class=
"title"
>
Username
</td>
<td
align=
"center"
class=
"title"
>
Traffic Cap
</td>
<td
align=
"center"
class=
"title"
>
Uptime Cap
</td>
</tr>
<tr>
<td
align=
"center"
class=
"value"
>
<?php
echo
$username
;
?>
</td>
<td
align=
"center"
class=
"value"
>
<?php
if
(
is_numeric
(
$trafficCap
)
&&
$trafficCap
==
0
)
{
echo
"Unlimited"
;
}
elseif
(
is_string
(
$trafficCap
)
&&
$trafficCap
===
"Prepaid"
)
{
echo
$trafficCap
;
}
else
{
echo
$trafficCap
.
" MB"
;
}
?>
</td>
<td
align=
"center"
class=
"value"
>
<?php
if
(
is_numeric
(
$uptimeCap
)
&&
$uptimeCap
==
0
)
{
echo
"Unlimited"
;
}
elseif
(
is_string
(
$uptimeCap
)
&&
$uptimeCap
===
"Prepaid"
)
{
echo
$uptimeCap
;
}
else
{
echo
$uptimeCap
.
" MB"
;
}
?>
</td>
</tr>
</tr>
<tr>
<tr>
<td
colspan=
"2"
class=
"title"
>
Username
</td>
<td>
</td>
<td
colspan=
"2"
class=
"title"
>
Service
</td>
</tr>
</tr>
<tr>
<tr>
<td
colspan=
"2"
class=
"value"
>
<?php
echo
$_SESSION
[
'username'
];
?>
</td>
<td
colspan=
"4"
class=
"section"
>
Traffic Usage
</td>
<td
colspan=
"2"
class=
"value"
>
<?php
echo
$userService
;
?>
</td>
</tr>
</tr>
<tr>
<td
align=
"center"
class=
"title"
>
Active Topup
</td>
<td
align=
"center"
class=
"title"
>
Total Topup
</td>
<td
align=
"center"
class=
"title"
>
Total Usage
</td>
</tr>
<td
align=
"center"
class=
"value"
>
<?php
if
(
isset
(
$currentTrafficTopup
)
&&
(
!
(
is_numeric
(
$trafficCap
)
&&
$trafficCap
==
0
)))
{
echo
sprintf
(
"%.2f"
,
$currentTrafficTopup
[
'Used'
])
.
"/"
.
sprintf
(
$currentTrafficTopup
[
'Cap'
])
.
" MB"
;
}
else
{
echo
"None"
;
}
?>
</td>
<td
align=
"center"
class=
"value"
>
<?php
echo
$totalTrafficTopupsAvail
.
" MB"
;
?>
</td>
<td
align=
"center"
class=
"value"
>
<?php
echo
sprintf
(
"%.2f"
,
$totalTraffic
)
.
" MB"
;
?>
</td>
<tr>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td
colspan=
"4"
class=
"section"
>
Uptime Usage
</td>
</tr>
<tr>
<td
align=
"center"
class=
"title"
>
Active Topup
</td>
<td
align=
"center"
class=
"title"
>
Total Topup
</td>
<td
align=
"center"
class=
"title"
>
Total Usage
</td>
</tr>
<tr>
<td
align=
"center"
class=
"value"
>
<?php
if
(
isset
(
$currentUptimeTopup
)
&&
(
!
(
is_numeric
(
$uptimeCap
)
&&
$uptimeCap
==
0
)))
{
echo
sprintf
(
"%.2f"
,
$currentUptimeTopup
[
'Used'
])
.
"/"
.
sprintf
(
$currentUptimeTopup
[
'Cap'
])
.
" MB"
;
}
else
{
echo
"None"
;
}
?>
</td>
<td
align=
"center"
class=
"value"
>
<?php
echo
$totalUptimeTopupsAvail
.
" MB"
;
?>
</td>
<td
align=
"center"
class=
"value"
>
<?php
echo
sprintf
(
"%.2f"
,
$totalUptime
)
.
" Min"
;
?>
</td>
</tr>
</table>
<p>
</p>
<?php
<?php
#
Only
display
cap for DSL users
#
Dont
display
if we unlimited
if
(
!
$isDialup
)
{
if
(
!
(
is_numeric
(
$trafficCap
)
&&
$trafficCap
==
0
)
)
{
?>
?>
<table
class=
"blockcenter"
>
<tr>
<tr>
<td
colspan=
"
4
"
class=
"section"
>
Traffic
Usage
</td>
<td
width=
"500"
colspan=
"
3
"
class=
"section"
>
T
opup Overview: T
raffic
</td>
</tr>
</tr>
<tr>
<tr>
<td
class=
"title"
>
Traffic Cap
</td>
<td
align=
"center"
class=
"title"
>
Used
</td>
<td
class=
"title"
>
Unused Topup
</td>
<td
align=
"center"
class=
"title"
>
Valid From
</td>
<td
class=
"title"
>
Current Topup
</td>
<td
align=
"center"
class=
"title"
>
Valid To
</td>
<td
class=
"title"
>
Used This Month
</td>
</tr>
</tr>
<tr>
<?php
if
(
is_numeric
(
$trafficCap
)
&&
$trafficCap
>
0
)
{
?>
<td
class=
"value"
>
<?php
echo
$trafficCap
;
?>
MB
</td>
<?php
}
elseif
(
is_numeric
(
$trafficCap
)
&&
$trafficCap
==
0
)
{
?>
<td
class=
"value"
>
Uncapped
</td>
<?php
}
else
{
?>
<td
class=
"value"
>
<?php
echo
$trafficCap
;
?>
</td>
<?php
}
if
(
is_numeric
(
$trafficCap
)
&&
$trafficCap
==
0
)
{
?>
<td
class=
"value"
>
N/A
</td>
<?php
}
else
{
?>
<td
class=
"value"
>
<?php
echo
$topupTrafficRemaining
;
?>
MB
</td>
<?php
}
if
(
isset
(
$currentTrafficTopup
[
'Used'
])
&&
isset
(
$currentTrafficTopup
[
'Cap'
]))
{
?>
<td
class=
"value"
>
<?php
printf
(
'%.2f'
,
$currentTrafficTopup
[
'Used'
]);
print
(
"/"
.
$currentTrafficTopup
[
'Cap'
]);
?>
MB
</td>
<?php
<?php
}
else
{
foreach
(
$trafficRows
as
$trafficRow
)
{
?>
?>
<td
class=
"value"
>
N/A
</td>
<tr>
<?php
<td
align=
"center"
class=
"value"
>
}
?>
<td
class=
"value"
>
<?php
printf
(
'%.2f'
,
$totalTraffic
);
?>
MB
</td>
</tr>
<?php
<?php
if
(
isset
(
$currentTrafficTopup
[
'Used'
])
&&
isset
(
$currentTrafficTopup
[
'Cap'
]))
{
echo
sprintf
(
"%.2f"
,
$trafficRow
[
'Used'
])
.
"/"
.
sprintf
(
$trafficRow
[
'Cap'
])
.
" MB"
;
$topupPercent
=
ceil
((
$currentTrafficTopup
[
'Used'
]
/
$currentTrafficTopup
[
'Cap'
])
*
100
);
?>
?>
<tr>
<td
colspan=
"4"
>
<div
class=
"graph"
>
<strong
class=
"bar"
style=
"width:
<?php
echo
$topupPercent
.
'%'
;
?>
"
>
<?php
echo
$topupPercent
.
'%'
?>
</strong>
</div>
</td>
</td>
<td
align=
"center"
class=
"value"
>
<?php
$validFrom
=
strtotime
(
$trafficRow
[
'ValidFrom'
]);
echo
date
(
"Y-m-d"
,
$validFrom
);
?>
</td>
<td
align=
"center"
class=
"value"
>
<?php
$validTo
=
strtotime
(
$trafficRow
[
'Expires'
]);
echo
date
(
"Y-m-d"
,
$validTo
);
?>
</td>
</tr>
</tr>
<?php
<?php
}
}
?>
?>
</table>
<?php
}
# Dont display if we unlimited
if
(
!
(
is_numeric
(
$uptimeCap
)
&&
$uptimeCap
==
0
))
{
?>
<p>
</p>
<table
class=
"blockcenter"
>
<tr>
<tr>
<td
colspan=
"
4
"
class=
"section"
>
Uptime Usag
e
</td>
<td
width=
"500"
colspan=
"
3
"
class=
"section"
>
Topup Overview: Uptim
e
</td>
</tr>
</tr>
<tr>
<tr>
<td
class=
"title"
>
Uptime Cap
</td>
<td
align=
"center"
class=
"title"
>
Used
</td>
<td
class=
"title"
>
Unused Topup
</td>
<td
align=
"center"
class=
"title"
>
Valid From
</td>
<td
class=
"title"
>
Current Topup
</td>
<td
align=
"center"
class=
"title"
>
Valid To
</td>
<td
class=
"title"
>
Used This Month
</td>
</tr>
</tr>
<tr>
<?php
if
(
is_numeric
(
$uptimeCap
)
&&
$uptimeCap
>
0
)
{
?>
<td
class=
"value"
>
<?php
echo
$uptimeCap
;
?>
Min
</td>
<?php
<?php
}
elseif
(
is_numeric
(
$uptime
Cap
)
&&
$uptime
Cap
==
0
)
{
foreach
(
$uptime
Rows
as
$uptime
Row
)
{
?>
?>
<td
class=
"value"
>
Uncapped
</td>
<tr>
<?php
<td
align=
"center"
class=
"value"
>
}
else
{
?>
<td
class=
"value"
>
<?php
echo
$uptimeCap
;
?>
</td>
<?php
}
if
(
is_numeric
(
$uptimeCap
)
&&
$uptimeCap
==
0
)
{
?>
<td
class=
"value"
>
N/A
</td>
<?php
}
else
{
?>
<td
class=
"value"
>
<?php
echo
$topupUptimeRemaining
;
?>
Min
</td>
<?php
}
if
(
isset
(
$currentUptimeTopup
[
'Used'
])
&&
isset
(
$currentUptimeTopup
[
'Cap'
]))
{
?>
<td
class=
"value"
>
<?php
printf
(
'%.2f'
,
$currentUptimeTopup
[
'Used'
]);
print
(
"/"
.
$currentUptimeTopup
[
'Cap'
]);
?>
Min
</td>
<?php
}
else
{
?>
<td
class=
"value"
>
N/A
</td>
<?php
}
?>
<td
class=
"value"
>
<?php
printf
(
'%.2f'
,
$totalUptime
);
?>
Min
</td>
</tr>
<?php
<?php
if
(
isset
(
$currentUptimeTopup
[
'Used'
])
&&
isset
(
$currentUptimeTopup
[
'Cap'
]))
{
echo
sprintf
(
"%.2f"
,
$uptimeRow
[
'Used'
])
.
"/"
.
sprintf
(
$uptimeRow
[
'Cap'
])
.
" MB"
;
$topupPercent
=
ceil
((
$currentUptimeTopup
[
'Used'
]
/
$currentUptimeTopup
[
'Cap'
])
*
100
);
?>
?>
<tr>
<td
colspan=
"4"
>
<div
class=
"graph"
>
<strong
class=
"bar"
style=
"width:
<?php
echo
$topupPercent
.
'%'
;
?>
"
>
<?php
echo
$topupPercent
.
'%'
?>
</strong>
</div>
</td>
</td>
<td
align=
"center"
class=
"value"
>
<?php
$validFrom
=
strtotime
(
$uptimeRow
[
'ValidFrom'
]);
echo
date
(
"Y-m-d"
,
$validFrom
);
?>
</td>
<td
align=
"center"
class=
"value"
>
<?php
$validTo
=
strtotime
(
$uptimeRow
[
'Expires'
]);
echo
date
(
"Y-m-d"
,
$validTo
);
?>
</td>
</tr>
</tr>
<?php
<?php
}
}
?>
?>
<!--
</table>
<tr>
<td colspan="2" class="section">Notifications</td>
</tr>
<form method="post">
<tr>
<td class="title">Email Address</td>
<td class="value">
<input type="text" name="notifyMethodEmail" value="php echo $userEmail; "></input>
</td>
</tr>
<tr>
<td class="title">Cell Number</td>
<td class="value">
<input type="text" name="notifyMethodCell" value="php echo $userPhone; "></input>
</td>
</tr>
</form>
--!>
<?php
<?php
}
}
?>
?>
<tr>
<p>
</p>
<td></td>
<p
align=
"center"
><a
href=
"logs.php"
>
Usage Logs
</a></p>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td colspan="4" align="center">
<a href="logs.php">Usage Logs</a>
</td>
</tr>
</table>
<br><br>
<font size="-1">
Note:
<li>Please contact your ISP if you have any problem using this interface.</li>
</font>
<?php
<?php
}
}
/*
# If this is a post and we're updating
if (isset($_POST['notifyUpdate']) && $_POST['notifyUpdate'] == "update") {
$username = $_SESSION['username'];
# Get user's ID
$sql = "
SELECT
ID
FROM
${DB_TABLE_PREFIX}users
WHERE
Username = '$username'
";
$res = $db->query($sql);
$row = $res->fetchObject();
$userID = $row->id;
$sql = "
SELECT
Name, Value
FROM
${DB_TABLE_PREFIX}user_attributes
WHERE
UserID = '$userID'
";
$res = $db->query($sql);
$userPhone = "Unavailable";
$userEmail = "Unavailable";
while ($row = $res->fetchObject()) {
if ($row->name == "SMRadius-Notify-Phone") {
$userPhone = $row->value;
}
if ($row->name == "SMRadius-Notify-Email") {
$userEmail = $row->value;
}
}
# If we want to update email address
if (isset($_POST['notifyMethodEmail']) && !empty($_POST['notifyMethodEmail'])) {
$db->beginTransaction();
# Unavailble if no email address is set yet
if ($userEmail == "Unavailable") {
# Prepare to insert email address for the first time
$emailStatement = $db->prepare("INSERT INTO
${DB_TABLE_PREFIX}user_attributes (UserID,Name,Operator,Value)
VALUES
('$userID','SMRadius-Notify-Email','=*',?)
");
$emailResult = $emailStatement->execute(array($_POST['notifyMethodEmail'],));
# If successful, commit
if ($emailResult) {
$db->commit();
echo "<center>Email address updated</center>";
# Else, rollback changes and give error
} else {
$db->rollback();
echo "<center>Error updating email address, please contact your ISP.</center>";
}
} else {
# Prepare to update existing email address
$emailStatement = $db->prepare("UPDATE
${DB_TABLE_PREFIX}user_attributes
SET
Value = ?
WHERE
Name = 'SMRadius-Notify-Email'
AND
UserID = '$userID'
");
$emailResult = $emailStatement->execute(array($_POST['notifyMethodEmail'],));
# If successful, commit
if ($emailResult) {
$db->commit();
echo "<center>Email address updated</center>";
# Else, rollback changes and give error
} else {
$db->rollback();
echo "<center>Error updating email address, please contact your ISP.</center>";
}
}
}
# If we want to update phone number
if (isset($_POST['notifyMethodCell']) && !empty($_POST['notifyMethodCell'])) {
$db->beginTransaction();
# Unavailable if there is none found for this user
if ($userPhone == "Unavailable") {
# Prepare to insert first number
$phoneStatement = $db->prepare("INSERT INTO
${DB_TABLE_PREFIX}user_attributes (UserID,Name,Operator,Value)
VALUES
('$userID','SMRadius-Notify-Phone','=*',?)
");
$phoneResult = $phoneStatement->execute(array($_POST['notifyMethodCell'],));
# If successful, commit
if ($phoneResult) {
$db->commit();
echo "<center>Mobile phone number updated</center>";
# Else, rollback changes and give error
} else {
$db->rollback();
echo "<center>Error updating mobile phone number, please contact your ISP.</center>";
}
} else {
# Prepare to update existing number
$phoneStatement = $db->prepare("UPDATE
${DB_TABLE_PREFIX}user_attributes
SET
Value = ?
WHERE
Name = 'SMRadius-Notify-Phone'
AND
UserID = '$userID'
");
$phoneResult = $phoneStatement->execute(array($_POST['notifyMethodPhone'],));
# If successful, commit
if ($emailResult) {
$db->commit();
echo "<center>Mobile phone number updated</center>";
# Else, rollback changes and give error
} else {
$db->rollback();
echo "<center>Error updating mobile phone number, please contact your ISP.</center>";
}
}
}
}
*/
displayDetails
();
displayDetails
();
# Footer
# Footer
...
...
This diff is collapsed.
Click to expand it.
webui/user/logs.php
View file @
b659b33b
<?php
<?php
# Radius user logs
# Radius user logs
# Copyright (C) 2007-20
09
, AllWorldIT
# Copyright (C) 2007-20
15
, AllWorldIT
#
#
# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
...
@@ -43,6 +43,16 @@ function displayLogs() {
...
@@ -43,6 +43,16 @@ function displayLogs() {
<p
class=
"middle center"
>
<p
class=
"middle center"
>
Display logs between
Display logs between
<?php
<?php
# Validate dates before sending
if
(
isset
(
$_POST
[
'searchFrom'
]))
{
if
(
!
(
preg_match
(
"/^\d
{
4
}
\-(0[1-9]|1[0-2])\-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/"
,
$_POST
[
'searchFrom'
])))
{
unset
(
$_POST
[
'searchFrom'
]);
}
}
if
(
isset
(
$_POST
[
'searchFrom'
]))
{
$searchFrom
=
date
(
"Y-m-d"
,
strtotime
(
$_POST
[
'searchFrom'
]));
$_POST
[
'searchFrom'
]
=
$searchFrom
;
}
if
(
isset
(
$_POST
[
'searchFrom'
]))
{
if
(
isset
(
$_POST
[
'searchFrom'
]))
{
?>
?>
<input
type=
"text"
name=
"searchFrom"
size=
"11"
value=
"
<?php
echo
$_POST
[
'searchFrom'
]
?>
"
/>
<input
type=
"text"
name=
"searchFrom"
size=
"11"
value=
"
<?php
echo
$_POST
[
'searchFrom'
]
?>
"
/>
...
@@ -55,6 +65,16 @@ function displayLogs() {
...
@@ -55,6 +65,16 @@ function displayLogs() {
?>
?>
and
and
<?php
<?php
# Validate dates before sending
if
(
isset
(
$_POST
[
'searchTo'
]))
{
if
(
!
(
preg_match
(
"/^\d
{
4
}
\-(0[1-9]|1[0-2])\-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/"
,
$_POST
[
'searchTo'
])))
{
unset
(
$_POST
[
'searchTo'
]);
}
}
if
(
isset
(
$_POST
[
'searchTo'
]))
{
$searchFrom
=
date
(
"Y-m-d"
,
strtotime
(
$_POST
[
'searchTo'
]));
$_POST
[
'searchTo'
]
=
$searchFrom
;
}
if
(
isset
(
$_POST
[
'searchTo'
]))
{
if
(
isset
(
$_POST
[
'searchTo'
]))
{
?>
?>
<input
type=
"text"
name=
"searchTo"
size=
"11"
value=
"
<?php
echo
$_POST
[
'searchTo'
]
?>
"
/>
<input
type=
"text"
name=
"searchTo"
size=
"11"
value=
"
<?php
echo
$_POST
[
'searchTo'
]
?>
"
/>
...
@@ -95,79 +115,78 @@ function displayLogs() {
...
@@ -95,79 +115,78 @@ function displayLogs() {
$extraSQL
.
=
" AND EventTimestamp <= ?"
;
$extraSQL
.
=
" AND EventTimestamp <= ?"
;
array_push
(
$extraSQLVals
,
$_POST
[
'searchTo'
]);
array_push
(
$extraSQLVals
,
$_POST
[
'searchTo'
]);
#
Query to get all defaul
t
d
at
a
#
Accounting query FIXME nas receive and transmi
t
r
at
es
$sql
=
"
$sql
=
"
SELECT
SELECT
EventTimestamp,
EventTimestamp,
CallingStationID,
CallingStationID,
AcctSessionTime
,
AcctSessionTime
/ 60 AS AcctSessionTime,
AcctInputOctets
,
AcctInputOctets
/ 1024 / 1024 +
AcctInputGigawords
,
AcctInputGigawords
* 4096 AS AcctInputMbyte,
AcctOutputOctets
,
AcctOutputOctets
/ 1024 / 1024 +
AcctOutputGigawords
,
AcctOutputGigawords
* 4096 AS AcctOutputMbyte,
AcctTerminateCause
AcctTerminateCause
FROM
FROM
${DB_TABLE_PREFIX}accounting
${DB_TABLE_PREFIX}accounting
WHERE
WHERE
Username = "
.
$db
->
quote
(
$_SESSION
[
'username'
])
.
"
Username = "
.
$db
->
quote
(
$_SESSION
[
'username'
])
.
"
$extraSQL
$extraSQL
ORDER BY
ORDER BY
EventTimestamp
EventTimestamp
DESC
DESC
"
;
"
;
$res
=
$db
->
prepare
(
$sql
);
$res
=
$db
->
prepare
(
$sql
);
$res
->
execute
(
$extraSQLVals
);
$res
->
execute
(
$extraSQLVals
);
# Define totals:
# Display logs
$totalData
=
0
;
$totalInput
=
0
;
$totalInputData
=
0
;
$totalOutput
=
0
;
$totalOutputData
=
0
;
$totalTime
=
0
;
$totalSessionTime
=
0
;
while
(
$row
=
$res
->
fetchObject
())
{
while
(
$row
=
$res
->
fetchObject
())
{
# Input data calculation
# Input data calculation
$inputDataItem
=
0
;
$inputData
=
0
;
if
(
isset
(
$row
->
acctinputmbyte
)
&&
$row
->
acctinputmbyte
>
0
)
{
if
(
isset
(
$row
->
acctinputoctets
)
&&
$row
->
acctinputoctets
>
0
)
{
$inputData
+=
$row
->
acctinputmbyte
;
$inputDataItem
+=
(
$row
->
acctinputoctets
/
1024
)
/
1024
;
}
}
if
(
isset
(
$row
->
acctinputgigawords
)
&&
$row
->
acctinputgigawords
>
0
)
{
$totalInput
+=
$inputData
;
$inputDataItem
+=
(
$row
->
acctinputgigawords
*
4096
);
}
$totalInputData
+=
$inputDataItem
;
# Output data calculation
# Output data calculation
$outputDataItem
=
0
;
$outputData
=
0
;
if
(
isset
(
$row
->
acctoutputmbyte
)
&&
$row
->
acctoutputmbyte
>
0
)
{
if
(
isset
(
$row
->
acctoutputoctets
)
&&
$row
->
acctoutputoctets
>
0
)
{
$outputData
+=
$row
->
acctoutputmbyte
;
$outputDataItem
+=
(
$row
->
acctoutputoctets
/
1024
)
/
1024
;
}
}
if
(
isset
(
$row
->
acctoutputgigawords
)
&&
$row
->
acctoutputgigawords
>
0
)
{
$totalOutput
+=
$outputData
;
$outputDataItem
+=
(
$row
->
acctoutputgigawords
*
4096
);
}
$totalOutputData
+=
$outputDataItem
;
$totalData
+=
$totalOutputData
+
$totalInputData
;
#
T
ime calculation
#
Upt
ime calculation
$sessionTime
Item
=
0
;
$sessionTime
=
0
;
if
(
isset
(
$row
->
acctsessiontime
)
&&
$row
->
acctsessiontime
>
0
)
{
if
(
isset
(
$row
->
acctsessiontime
)
&&
$row
->
acctsessiontime
>
0
)
{
$sessionTime
Item
+=
(
$row
->
acctsessiontime
-
(
$row
->
acctsessiontime
%
60
))
/
60
;
$sessionTime
+=
$row
->
acctsessiontime
;
}
}
$totalTime
+=
$sessionTime
;
$totalSessionTime
+=
$sessionTimeItem
;
?>
?>
<tr>
<tr>
<td
class=
"desc"
>
<?php
echo
$row
->
eventtimestamp
;
?>
</td>
<td
class=
"desc"
>
<?php
echo
$row
->
eventtimestamp
;
?>
</td>
<td
class=
"desc"
>
<?php
echo
$row
->
acct
session
t
ime
;
?>
</td>
<td
class=
"desc"
>
<?php
printf
(
"%.2f"
,
$
session
T
ime
)
;
?>
</td>
<td
class=
"desc"
>
<?php
echo
$row
->
callingstationid
;
?>
</td>
<td
class=
"desc"
>
<?php
echo
$row
->
callingstationid
;
?>
</td>
<td
class=
"center desc"
>
<?php
echo
strRadiusTermCode
(
$row
->
acctterminatecause
);
?>
</td>
<td
class=
"center desc"
>
<?php
echo
strRadiusTermCode
(
$row
->
acctterminatecause
);
?>
</td>
<td
class=
"center desc"
>
<?php
echo
"NASTransmitRate"
;
?>
</td>
<td
class=
"center desc"
>
<td
class=
"center desc"
>
<?php
echo
"NASReceiveRate"
;
?>
</td>
<?php
<td
class=
"right desc"
>
<?php
printf
(
'%.2f'
,
$inputDataItem
);
?>
</td>
if
(
isset
(
$row
->
nastransmitrate
))
{
<td
class=
"right desc"
>
<?php
printf
(
'%.2f'
,
$outputDataItem
);
?>
</td>
echo
$row
->
nastransmitrate
;
}
?>
</td>
<td
class=
"center desc"
>
<?php
if
(
isset
(
$row
->
nasreceiverate
))
{
echo
$row
->
nasreceiverate
;
}
?>
</td>
<td
class=
"right desc"
>
<?php
printf
(
"%.2f"
,
$inputData
);
?>
</td>
<td
class=
"right desc"
>
<?php
printf
(
"%.2f"
,
$outputData
);
?>
</td>
</tr>
</tr>
<?php
<?php
}
}
...
@@ -178,15 +197,16 @@ function displayLogs() {
...
@@ -178,15 +197,16 @@ function displayLogs() {
</tr>
</tr>
<?php
<?php
}
else
{
}
else
{
$totalTraffic
=
$totalInput
+
$totalOutput
;
?>
?>
<tr>
<tr>
<td
colspan=
"6"
class=
"right"
>
Sub Total:
</td>
<td
colspan=
"6"
class=
"right"
>
Sub Total:
</td>
<td
class=
"right desc"
>
<?php
printf
(
'
%.2f
'
,
$totalInput
Data
);
?>
</td>
<td
class=
"right desc"
>
<?php
printf
(
"
%.2f
"
,
$totalInput
);
?>
</td>
<td
class=
"right desc"
>
<?php
printf
(
'
%.2f
'
,
$totalOutput
Data
);
?>
</td>
<td
class=
"right desc"
>
<?php
printf
(
"
%.2f
"
,
$totalOutput
);
?>
</td>
</tr>
</tr>
<tr>
<tr>
<td
colspan=
"6"
class=
"right"
>
Total:
</td>
<td
colspan=
"6"
class=
"right"
>
Total:
</td>
<td
colspan=
"2"
class=
"center desc"
>
<?php
printf
(
'
%.2f
'
,
$total
Data
);
?>
</td>
<td
colspan=
"2"
class=
"center desc"
>
<?php
printf
(
"
%.2f
"
,
$total
Traffic
);
?>
</td>
</tr>
</tr>
<?php
<?php
}
}
...
...
This diff is collapsed.
Click to expand it.
webui/user/styles.css
View file @
b659b33b
/*
/*
*
*
* User Control Panel Stylesheet
* User Control Panel Stylesheet
* Copyright (C) 2007-20
09
, AllWorldIT
* Copyright (C) 2007-20
15
, AllWorldIT
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by
...
...
This diff is collapsed.
Click to expand it.
Prev
1
…
6
7
8
9
10
Next