Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • smradius/smradius
  • centiva-shail/smradius
  • nkukard/smradius
3 results
Show changes
Showing
with 1028 additions and 2677 deletions
<?php
# Footer of page
#
# Copyright (c) 2005-2008, AllWorldIT
# Copyright (C) 2007-2015, AllWorldIT
#
# 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
......@@ -19,11 +18,13 @@
?>
<div class="copyright">Copyright (c) 2005-2008, <a href="http://www.allworldit.com" ?>AllWorldIT</a></div>
<div class="copyright">SMRadius - Copyright &copy; 2007-2011, <a href="http://www.allworldit.com" ?>AllWorldIT</a></div>
<br />
</body>
</html>
<?php
ob_flush();
# vim: ts=4
?>
<?php
# Top part of radius control panel
#
# Copyright (c) 2005-2008, AllWorldIT
# Copyright (C) 2007-2015, AllWorldIT
#
# 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
......@@ -42,3 +41,7 @@ require_once("include/version.php");
}
?>
<br>
<?php
# vim: ts=4
?>
<?php
# Misc functions we can use
#
# Copyright (c) 2005-2008, AllWorldIT
# Copyright (C) 2007-2015, AllWorldIT
#
# 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
......@@ -38,4 +37,5 @@ function displaySuccess($msg)
# vim: ts=4
?>
<?php
# This file takes care of authentication for us and gets the soap object
#
# Copyright (c) 2005-2008, AllWorldIT
# Web User UI PRE
# Copyright (C) 2007-2015, AllWorldIT
#
# 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
......@@ -18,48 +17,41 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
ob_start();
require_once("../shared-php/auth.php");
require_once("../shared-php/miscfuncs.php");
require_once("auth.php");
require_once("miscfuncs.php");
# Main authentication object
$auth = new Auth('Agent');
# Check if we logged in and set SOAP object
$soap = NULL;
$auth = new Auth('Radius');
# First of all check if we in maintenance mode
if (file_exists("../maintmode")) {
include("header.php");
displayError("System unavailable due to maintenance, sorry for the inconvenience. Please try again in 5 minutes");
include("footer.php");
?>
<center>System unavailable due to maintenance, sorry for the inconvenience. Please try again in 5 minutes.</center>
<?php
include("include/footer.php");
exit;
}
# If not ... carry on
$auth->setLoginBoxUsername('Username');
# Check if we logged in
if (!$auth->loggedIn) {
$username = isset($_POST['username']) ? $_POST['username'] : NULL;
$password = isset($_POST['password']) ? $_POST['password'] : NULL;
$username = isset($_POST['username']) ? $_POST['username'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
# If not, check credentials
if ($auth->checkLogin($username,$password) != 0) {
include("header.php");
$auth->displayLogin();
include("footer.php");
include("include/footer.php");
exit;
}
} else {
# Log client out
if (!empty($_REQUEST['logout']) && $_REQUEST['logout'] != "") {
if (isset($_REQUEST['logout']) && $_REQUEST['logout'] == 1) {
$auth->logout("You have been logged out.");
require_once('HTTP.php');
HTTP::Redirect('.');
......@@ -67,4 +59,5 @@ if (!$auth->loggedIn) {
}
}
# vim: ts=4
?>
<?php
# Radius term code mappings
#
# Copyright (c) 2005-2008, AllWorldIT
# Copyright (C) 2007-2015, AllWorldIT
#
# 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
......@@ -24,41 +23,58 @@
function strRadiusTermCode($errCode) {
if (is_numeric($errCode)) {
# Terminate codes RFC 2866
switch ($errCode) {
case 0:
return "Still logged in";
case 45: # Unknown
case 46: # Unknown
case 63: # Unknown
case 1:
return "User request";
return "User Request";
case 2:
case 816: # TCP connection reset? unknown
return "Carrier loss";
return "Lost Carrier";
case 3:
return "Lost Service";
case 4:
return "Idle Timeout";
case 5:
return "Session timeout";
case 6: # Admin reset
case 10: # NAS request
case 11: # NAS reboot
case 831: # NAS request? unknown
case 841: # NAS request? unknown
return "Router reset/reboot";
case 8: # Port error
return "Port error";
case 180: # Unknown
return "Local hangup";
case 827: # Unknown
return "Service unavailable";
return "Session Timeout";
case 6:
return "Admin Reset";
case 7:
return "Admin Reboot";
case 8:
return "Port Error";
case 9:
return "NAS Error";
case 10:
return "NAS Request";
case 11:
return "NAS Reboot";
case 12:
return "Port Unneeded";
case 13:
return "Port Preempted";
case 14:
return "Port Suspended";
case 15:
return "Service Unavailable";
case 16:
return "Callback";
case 17:
return "User Error";
case 18:
return "Host Request";
default:
return "Unkown";
}
} else {
return "Unknown";
switch ($errCode) {
case NULL:
return "Still logged in";
default:
return "Unkown";
}
}
}
# vim: ts=4
?>
<?php
# Versioning for this interface
#
# Copyright (c) 2005-2008, AllWorldIT
# Copyright (C) 2007-2015, AllWorldIT
#
# 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
......@@ -20,6 +19,7 @@
$VERSION = "0.4.0b1";
$VERSION = "0.0.3a";
# vim: ts=4
?>
<?php
# Main User Control Panel Page
# Copyright (c) 2007-2015, AllWorldIT
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# pre takes care of authentication and creates soap object we need
include("include/pre.php");
# Page header
include("include/header.php");
# NB: We will only end up here if we authenticated!
# Displays error
function webuiError($msg) {
echo isset($msg) ? $msg : "Unknown error";
}
# Display details
function displayDetails() {
global $db;
global $DB_TABLE_PREFIX;
# Get user's ID
$sql = "
SELECT
ID, Username
FROM
${DB_TABLE_PREFIX}users
WHERE
Username = ".$db->quote($_SESSION['username'])."
";
$res = $db->query($sql);
if (!(is_object($res))) {
webuiError("Error fetching user information");
}
$row = $res->fetchObject();
# Set user ID
$userID = $row->id;
$username = $row->username;
# Get accounting data
$currentMonth = date("Y-m");
$sql = "
SELECT
SUM(AcctSessionTime) / 60 AS AcctSessionTime,
SUM(AcctInputOctets) / 1024 / 1024 +
SUM(AcctInputGigawords) * 4096 +
SUM(AcctOutputOctets) / 1024 / 1024 +
SUM(AcctOutputGigawords) * 4096 AS TotalTraffic
FROM
${DB_TABLE_PREFIX}accounting
WHERE
Username = ".$db->quote($username)."
AND
PeriodKey = ".$db->quote($currentMonth)."
";
$res = $db->query($sql);
if (!(is_object($res))) {
webuiError("Error fetching user accounting");
}
# Set total traffic and uptime used
$totalTraffic = 0;
$totalUptime = 0;
# Pull in row
$row = $res->fetchObject();
# Traffic
if (isset($row->totaltraffic) && $row->totaltraffic > 0) {
$totalTraffic += $row->totaltraffic;
}
# Uptime
if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) {
$totalUptime += $row->acctsessiontime;
}
# Fetch user uptime and traffic cap (group attributes)
$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");
}
# Initial values
$trafficCap = "Prepaid";
$uptimeCap = "Prepaid";
while ($row = $res->fetchObject()) {
if ($row->name === "SMRadius-Capping-Traffic-Limit") {
$trafficCap = (int)$row->value;
}
if ($row->name === "SMRadius-Capping-Uptime-Limit") {
$uptimeCap = (int)$row->value;
}
}
# Fetch user uptime and traffic cap (user attributes)
$sql = "
SELECT
Name, Value
FROM
${DB_TABLE_PREFIX}user_attributes
WHERE
UserID = ".$db->quote($userID)."
AND Disabled = 0
";
$res = $db->query($sql);
if (!(is_object($res))) {
webuiError("Error fetching user attributes");
}
# Override group_attributes with user attributes
while ($row = $res->fetchObject()) {
if ($row->name === "SMRadius-Capping-Traffic-Limit") {
$trafficCap = (int)$row->value;
}
if ($row->name === "SMRadius-Capping-Uptime-Limit") {
$uptimeCap = (int)$row->value;
}
}
# Fetch user uptime and traffic summary
$sql = "
SELECT
${DB_TABLE_PREFIX}topups_summary.Balance,
${DB_TABLE_PREFIX}topups.Type,
${DB_TABLE_PREFIX}topups.Value,
${DB_TABLE_PREFIX}topups.ValidFrom,
${DB_TABLE_PREFIX}topups.ValidTo
FROM
${DB_TABLE_PREFIX}topups_summary,
${DB_TABLE_PREFIX}topups
WHERE
${DB_TABLE_PREFIX}topups_summary.TopupID = ${DB_TABLE_PREFIX}topups.ID
AND ${DB_TABLE_PREFIX}topups.UserID = ".$db->quote($userID)."
AND ${DB_TABLE_PREFIX}topups_summary.PeriodKey = ".$db->quote($currentMonth)."
AND ${DB_TABLE_PREFIX}topups_summary.Depleted = 0
ORDER BY
${DB_TABLE_PREFIX}topups.Timestamp ASC
";
$res = $db->query($sql);
if (!(is_object($res))) {
webuiError("Error fetching topup summaries");
}
# Store summary topups
$topups = array();
$i = 0;
while ($row = $res->fetchObject()) {
$topups[$i] = array();
$topups[$i]['Type'] = $row->type;
$topups[$i]['CurrentLimit'] = $row->balance;
$topups[$i]['Limit'] = $row->value;
$topups[$i]['ValidFrom'] = $row->validfrom;
$topups[$i]['Expires'] = $row->validto;
$i++;
}
# Fetch user uptime and traffic topups
$thisMonthTimestamp = date("Y-m").'-01';
$now = date("Y-m-d");
$sql = "
SELECT
Value, Type, ValidFrom, ValidTo
FROM
topups
WHERE
UserID = ".$db->quote($userID)."
AND ValidFrom = ".$db->quote($thisMonthTimestamp)."
AND ValidTo >= ".$db->quote($now)."
AND Depleted = 0
ORDER BY
Timestamp ASC
";
$res = $db->query($sql);
if (!(is_object($res))) {
webuiError("Error fetching topup");
}
# Store normal topups
while ($row = $res->fetchObject()) {
$topups[$i] = array();
$topups[$i]['Type'] = $row->type;
$topups[$i]['Limit'] = $row->value;
$topups[$i]['ValidFrom'] = $row->validfrom;
$topups[$i]['Expires'] = $row->validto;
$i++;
}
# Calculate topup usage for prepaid and normal users
$totalTrafficTopupsAvail = 0;
if (!(is_numeric($trafficCap) && $trafficCap == 0)) {
# Excess usage
$excess = 0;
if ($trafficCap === "Prepaid") {
$excess = $totalTraffic;
} else {
$excess = $totalTraffic > $trafficCap ? ($totalTraffic - $trafficCap) : 0;
}
# Loop through all valid topups
$trafficRows = array();
$i = 0;
foreach ($topups as $topup) {
# Traffic topups
if ($topup['Type'] == 1) {
# Topup not currently in use
if ($excess <= 0) {
$trafficRows[$i] = array();
$trafficRows[$i]['Cap'] = $topup['Limit'];
$trafficRows[$i]['Used'] = isset($topup['CurrentLimit']) ? ($topup['Limit'] - $topup['CurrentLimit']) : 0;
$trafficRows[$i]['ValidFrom'] = $topup['ValidFrom'];
$trafficRows[$i]['Expires'] = $topup['Expires'];
# Set total available topups
$totalTrafficTopupsAvail += isset($topup['CurrentLimit']) ? $topup['CurrentLimit'] : $topup['Limit'];
$i++;
# Topup currently in use
} elseif (!isset($topup['CurrentLimit']) && $excess < $topup['Limit']) {
$trafficRows[$i] = array();
$trafficRows[$i]['Cap'] = $topup['Limit'];
$trafficRows[$i]['Used'] = $excess;
$trafficRows[$i]['ValidFrom'] = $topup['ValidFrom'];
$trafficRows[$i]['Expires'] = $topup['Expires'];
# Set total available topups
$totalTrafficTopupsAvail += $topup['Limit'];
# Set current topup
$currentTrafficTopup = array();
$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++;
}
}
}
}
# Calculate topup usage for prepaid and normal users
$totalUptimeTopupsAvail = 0;
if (!(is_numeric($uptimeCap) && $uptimeCap == 0)) {
# Excess usage
$excess = 0;
if ($uptimeCap === "Prepaid") {
$excess = $totalUptime;
} else {
$excess = $totalUptime > $uptimeCap ? ($totalUptime - $uptimeCap) : 0;
}
# Loop through all valid topups
$uptimeRows = array();
$i = 0;
foreach ($topups as $topup) {
# Uptime topups
if ($topup['Type'] == 2) {
# Topup not currently in use
if ($excess <= 0) {
$uptimeRows[$i] = array();
$uptimeRows[$i]['Cap'] = $topup['Limit'];
$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'];
$i++;
# 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">
<tr>
<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>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="4" class="section">Traffic 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>
<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>&nbsp;</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>&nbsp;</p>
<?php
# Dont display if we unlimited
if (!(is_numeric($trafficCap) && $trafficCap == 0)) {
?>
<table class="blockcenter">
<tr>
<td width="500" colspan="3" class="section">Topup Overview: Traffic</td>
</tr>
<tr>
<td align="center" class="title">Used</td>
<td align="center" class="title">Valid From</td>
<td align="center" class="title">Valid To</td>
</tr>
<?php
foreach ($trafficRows as $trafficRow) {
?>
<tr>
<td align="center" class="value">
<?php
echo sprintf("%.2f",$trafficRow['Used'])."/".sprintf($trafficRow['Cap'])." MB";
?>
</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>
<?php
}
?>
</table>
<?php
}
# Dont display if we unlimited
if (!(is_numeric($uptimeCap) && $uptimeCap == 0)) {
?>
<p>&nbsp;</p>
<table class="blockcenter">
<tr>
<td width="500" colspan="3" class="section">Topup Overview: Uptime</td>
</tr>
<tr>
<td align="center" class="title">Used</td>
<td align="center" class="title">Valid From</td>
<td align="center" class="title">Valid To</td>
</tr>
<?php
foreach ($uptimeRows as $uptimeRow) {
?>
<tr>
<td align="center" class="value">
<?php
echo sprintf("%.2f",$uptimeRow['Used'])."/".sprintf($uptimeRow['Cap'])." MB";
?>
</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>
<?php
}
?>
</table>
<?php
}
?>
<p>&nbsp;</p>
<p align="center"><a href="logs.php">Usage Logs</a></p>
<?php
}
displayDetails();
# Footer
include("include/footer.php");
# vim: ts=4
?>
<?php
# Radius user logs
#
# Copyright (c) 2005-2008, AllWorldIT
# Copyright (C) 2007-2015, AllWorldIT
#
# 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
......@@ -21,13 +20,10 @@
include("include/pre.php");
# Page header
include("include/header.php");
# Soap functions
require_once("soapfuncs.php");
# Database
include_once("include/db.php");
# Radius functions
require_once("radiuscodes.php");
require_once("include/radiuscodes.php");
# NB: We will only end up here if we authenticated!
......@@ -35,46 +31,60 @@ require_once("radiuscodes.php");
# Display settings
function displayLogs() {
global $soap;
global $db;
global $DB_TABLE_PREFIX;
# Check if we should search
if (isset($_POST['searchFrom']) || isset($_POST['searchFrom'])) {
if (isset($_POST['searchFrom'])) {
$search['searchFrom'] = isset($_POST['searchFrom']) ? $_POST['searchFrom'] : '';
$_SESSION['radiusLogs_searchFrom'] = $search['searchFrom'];
}
if (isset($_POST['searchTo'])) {
$search['searchTo'] = isset($_POST['searchTo']) ? $_POST['searchTo'] : '';
$_SESSION['radiusLogs_searchTo'] = $search['searchTo'];
}
$results = $soap->getRadiusUserLogs($search);
}
$userDetails = $soap->getRadiusUserDetails();
$isDialup = preg_match('/dialup/i',$userDetails->Service);
?>
<table class="blockcenter" width="750">
<tr>
<td colspan="4" class="title">
<form method="POST">
<p class="middle center">
Display logs between
<input type="text" name="searchFrom" value="<?php
if (isset($_SESSION['radiusLogs_searchFrom'])) {
echo $_SESSION['radiusLogs_searchFrom'];
}
?>" size="11">
<?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'])) {
?>
<input type="text" name="searchFrom" size="11" value="<?php echo $_POST['searchFrom'] ?>"/>
<?php
} else {
?>
<input type="text" name="searchFrom" size="11"/>
<?php
}
?>
and
<input type="text" name="searchTo" value="<?php
if (isset($_SESSION['radiusLogs_searchTo'])) {
echo $_SESSION['radiusLogs_searchTo'];
}
?>" size="11">
<?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'])) {
?>
<input type="text" name="searchTo" size="11" value="<?php echo $_POST['searchTo'] ?>"/>
<?php
} else {
?>
<input type="text" name="searchTo" size="11"/>
<?php
}
?>
<input type="submit" value="search">
</p>
</form>
......@@ -84,18 +94,8 @@ function displayLogs() {
</tr>
<tr>
<td class="section">Timestamp</td>
<td class="section">Duration</td>
<?php
if (!$isDialup) {
?>
<td class="section">Port</td>
<?php
} else {
?>
<td class="section">Caller ID</td>
<?php
}
?>
<td class="section">Duration<br> (Min)</td>
<td class="section">Caller ID</td>
<td class="section">Term Reason</td>
<td class="section">Receive</td>
<td class="section">Transmit</td>
......@@ -103,77 +103,128 @@ function displayLogs() {
<td class="section">Download</td>
</tr>
<?php
if (isset($results) && is_array($results)) {
$total = 0;
$totalUpload = 0;
$totalDownload = 0;
# Loop with log entries
foreach ($results as $item) {
$inputMBytes = $item->AcctInputOctets > 0 ? $item->AcctInputOctets / 1024 / 1024 : 0;
$outputMBytes = $item->AcctOutputOctets > 0 ? $item->AcctOutputOctets / 1024 / 1024 : 0;
$inputMBytes += $item->AcctInputGigawords * 4096;
$outputMBytes += $item->AcctOutputGigawords * 4096;
# Extra SQL
$extraSQL = "";
$extraSQLVals = array();
$limitSQL = "";
if (isset($_POST['searchFrom']) && isset($_POST['searchTo'])) {
$extraSQL .= " AND EventTimestamp >= ?";
array_push($extraSQLVals,$_POST['searchFrom']);
$extraSQL .= " AND EventTimestamp <= ?";
array_push($extraSQLVals,$_POST['searchTo']);
# Accounting query FIXME nas receive and transmit rates
$sql = "
SELECT
EventTimestamp,
CallingStationID,
AcctSessionTime / 60 AS AcctSessionTime,
AcctInputOctets / 1024 / 1024 +
AcctInputGigawords * 4096 AS AcctInputMbyte,
AcctOutputOctets / 1024 / 1024 +
AcctOutputGigawords * 4096 AS AcctOutputMbyte,
AcctTerminateCause
FROM
${DB_TABLE_PREFIX}accounting
WHERE
Username = ".$db->quote($_SESSION['username'])."
$extraSQL
ORDER BY
EventTimestamp
DESC
";
$res = $db->prepare($sql);
$res->execute($extraSQLVals);
# Display logs
$totalInput = 0;
$totalOutput = 0;
$totalTime = 0;
while ($row = $res->fetchObject()) {
# Input data calculation
$inputData = 0;
if (isset($row->acctinputmbyte) && $row->acctinputmbyte > 0) {
$inputData += $row->acctinputmbyte;
}
$totalInput += $inputData;
# Output data calculation
$outputData = 0;
if (isset($row->acctoutputmbyte) && $row->acctoutputmbyte > 0) {
$outputData += $row->acctoutputmbyte;
}
$totalOutput += $outputData;
# Uptime calculation
$sessionTime = 0;
if (isset($row->acctsessiontime) && $row->acctsessiontime > 0) {
$sessionTime += $row->acctsessiontime;
}
$totalTime += $sessionTime;
?>
<tr>
<td class="desc"><?php echo $item->Timestamp; ?>
<td class="desc"><?php echo $item->AcctSessionTime; ?></td>
<?php
if (!$isDialup) {
?>
<td class="desc"><?php echo $item->NASPort; ?></td>
<td class="desc"><?php echo $row->eventtimestamp; ?></td>
<td class="desc"><?php printf("%.2f",$sessionTime); ?></td>
<td class="desc"><?php echo $row->callingstationid; ?></td>
<td class="center desc"><?php echo strRadiusTermCode($row->acctterminatecause); ?></td>
<td class="center desc">
<?php
if (isset($row->nastransmitrate)) {
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>
<?php
} else {
}
if ($res->rowCount() == 0) {
?>
<td class="desc"><?php echo $item->CallingStationID; ?></td>
<tr>
<td colspan="8" class="info">There are no logs for the selected dates</td>
</tr>
<?php
}
} else {
$totalTraffic = $totalInput + $totalOutput;
?>
<td class="center desc"><?php echo strRadiusTermCode($item->ConnectTermReason); ?></td>
<td class="center desc"><?php echo $item->NASTransmitRate; ?></td>
<td class="center desc"><?php echo $item->NASReceiveRate; ?></td>
<td class="right desc"><?php echo sprintf('%.2f',$inputMBytes); ?></td>
<td class="right desc"><?php echo sprintf('%.2f',$outputMBytes); ?></td>
<tr>
<td colspan="6" class="right">Sub Total:</td>
<td class="right desc"><?php printf("%.2f",$totalInput); ?></td>
<td class="right desc"><?php printf("%.2f",$totalOutput); ?></td>
</tr>
<tr>
<td colspan="6" class="right">Total:</td>
<td colspan="2" class="center desc"><?php printf("%.2f",$totalTraffic); ?></td>
</tr>
<?php
$totalUpload += $inputMBytes;
$totalDownload += $outputMBytes;
}
$total = $totalUpload + $totalDownload;
?>
<tr>
<td colspan="6" class="right">Sub Total:</td>
<td class="right desc"><?php echo sprintf('%.2f',$totalUpload); ?></td>
<td class="right desc"><?php echo sprintf('%.2f',$totalDownload); ?></td>
</tr>
<tr>
<td colspan="6" class="right">Total:</td>
<td colspan="2" class="center desc"><?php echo sprintf('%.2f',$total); ?></td>
</tr>
<?php
} else {
?>
<tr>
<td colspan="8" class="info">Please specify dates above in YYYY-MM-DD format and click "search".</td>
</tr>
<tr>
<td colspan="8" class="info">Please specify dates above in YYYY-MM-DD format and click "search".</td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
<a href=".">Back</a><br>
<?php
displayLogs();
?>
<a href=".">Back</a><br><br>
<?php
......@@ -181,4 +232,6 @@ displayLogs();
# Footer
include("include/footer.php");
# vim: ts=4
?>
td.section {
border-style: solid;
border-width: 2px;
color: #ffffff;
background-color: #000066;
text-align: center;
}
td.top {
vertical-align: top;
}
td.middle {
vertical-align: middle;
}
td.right {
text-align: right;
}
td.title,div.title {
border-style: solid;
border-width: 1px;
background-color: #ffffdd;
}
div.pagetitle {
border-style: solid;
border-width: 1px;
border-color: #000000;
font-size: larger;
text-align: center;
}
div.smallinfo {
font-size: 10px;
text-align: center;
}
div.copyright {
border-style: solid;
border-width: 1px;
font-size: 10px;
text-align: center;
}
td.pinfo {
border-style: dotted;
border-width: 1px;
font-size: smaller;
}
td.info {
border-style: dotted;
border-width: 1px;
font-size: smaller;
text-align: center;
}
td.value,div.value {
}
td.desc,div.desc {
background-color: #eeeeee;
}
.blockcenter {
margin-left: auto;
margin-right: auto;
}
.center {
text-align: center;
}
.important {
font-style: italic;
}
/*
*
* User Control Panel Stylesheet
* Copyright (C) 2007-2015, AllWorldIT
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
td.section {
border-style: solid;
border-width: 2px;
color: #ffffff;
background-color: #000066;
text-align: center;
}
td.top {
vertical-align: top;
}
td.middle {
vertical-align: middle;
}
td.right {
text-align: right;
}
td.title,div.title {
border-style: solid;
border-width: 1px;
background-color: #ffffdd;
}
div.pagetitle {
border-style: solid;
border-width: 1px;
border-color: #000000;
font-size: larger;
text-align: center;
}
div.smallinfo {
font-size: 10px;
text-align: center;
}
div.copyright {
border-style: solid;
border-width: 1px;
font-size: 10px;
text-align: center;
}
td.pinfo {
border-style: dotted;
border-width: 1px;
font-size: smaller;
}
td.info {
border-style: dotted;
border-width: 1px;
font-size: smaller;
text-align: center;
}
td.value,div.value {
}
td.desc,div.desc {
background-color: #eeeeee;
}
.blockcenter {
margin-left: auto;
margin-right: auto;
}
.center {
text-align: center;
}
.important {
font-style: italic;
}
body { font-family: verdana; text-align: center; }
a, a:visited {
......@@ -176,4 +197,21 @@ mtsearchtableorder {
mtsearchtablesubmit {
font-weight: bold;
}
\ No newline at end of file
}
.graph {
position: relative; /* IE is dumb */
margin: auto;
width: 200px;
border: 1px solid #000066;
padding: 2px;
}
.graph .bar {
display: block;
position: relative;
background: #E6E6FA;
text-align: center;
color: #333;
height: 2em;
line-height: 2em;
}
.graph .bar span { position: absolute; left: 1em; }
<?php
# Policy add
# Copyright (C) 2008, LinuxRulz
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
include_once("includes/header.php");
include_once("includes/footer.php");
include_once("includes/db.php");
$db = connect_db();
printHeader(array(
));
if (!isset($_POST['frmaction'])) {
?>
<p class="pageheader">Add user</p>
<!-- Add user input fields -->
<form method="post" action="wisp-user-add.php">
<div>
<input type="hidden" name="frmaction" value="insert" />
</div>
<table class="entry">
<tr>
<td class="textcenter" colspan="2">Account Information</td>
</tr>
<tr>
<td><div></div><td>
</tr>
<tr>
<td class="entrytitle">User Name</td>
<td><input type="text" name="user_name" /></td>
</tr>
<tr>
<td class="entrytitle">Password</td>
<td><input type="password" name="user_password" /></td>
</tr>
<tr>
<td><div></div><td>
</tr>
<tr>
<td class="textcenter" colspan="2">Private Information</td>
</tr>
<tr>
<td><div></div><td>
</tr>
<tr>
<td class="entrytitle">First Name</td>
<td><input type="text" name="user_first_name" /></td>
</tr>
<tr>
<td class="entrytitle">Last Name</td>
<td><input type="text" name="user_last_name" /></td>
</tr>
<tr>
<td class="entrytitle">Phone</td>
<td><input type="text" name="user_phone" /></td>
</tr>
<tr>
<td class="entrytitle">Location</td>
<td><input type="text" name="user_location" /></td>
</tr>
<tr>
<td class="entrytitle">Email Address</td>
<td><input type="text" name="user_email" /></td>
</tr>
<tr>
<td class="entrytitle">IP Address</td>
<td><input type="text" name="user_ip_address" /></td>
</tr>
<tr>
<td class="entrytitle">Pool Name</td>
<td><input type="text" name="pool_name" /></td>
</tr>
<tr>
<td class="entrytitle">Group Name</td>
<td><input type="text" name="group_name" /></td>
</tr>
<tr>
<td class="entrytitle">Address List</td>
<td><input type="text" name="address_list" /></td>
</tr>
<tr>
<td class="textcenter" colspan="2"><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>
<?php
}
if ($_POST['frmaction'] == "insert") {
?>
<p class="pageheader">Add user</p>
<?php
# Check for empty values
$emptyItem = 0;
foreach ($_POST as $key => $value) {
if (empty($value)) {
$emptyItem = 1;
}
}
if ($emptyItem == 1) {
?>
<div class="warning">One or more fields have been left empty</div>
<?php
} else {
$stmt = $db->prepare("
INSERT INTO ${DB_TABLE_PREFIX}wispusers
(
Username,
Password,
FirstName,
LastName,
Location,
Email,
Phone,
IPAddress,
PoolName,
GroupName,
AddressList,
)
VALUES
(?,?,?,?,?,?,?,?,?,?,?)
");
$res = $stmt->execute(array(
$_POST['user_name'],
$_POST['user_password'],
$_POST['user_first_name'],
$_POST['user_last_name'],
$_POST['user_location'],
$_POST['user_email'],
$_POST['user_phone'],
$_POST['user_ip_address'],
$_POST['pool_name'],
$_POST['group_name'],
$_POST['address_list'],
));
# Was it successful?
if ($res) {
?>
<div class="notice">User added</div>
<?php
} else {
?>
<div class="warning">Failed to add user</div>
<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
<?php
}
}
}
printFooter();
# vim: ts=4
?>
<?php
# Module: Policy delete
# Copyright (C) 2008, LinuxRulz
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
include_once("includes/header.php");
include_once("includes/footer.php");
include_once("includes/db.php");
$db = connect_db();
printHeader(array(
"Tabs" => array(
"Back to user list" => "wisp-user-list.php",
),
));
# Display delete confirm screen
if ($_POST['frmaction'] == "delete") {
# Check a user was selected
if (isset($_POST['user_id'])) {
?>
<p class="pageheader">Remove User</p>
<form action="wisp-user-delete.php" method="post">
<div>
<input type="hidden" name="frmaction" value="delete2" />
<input type="hidden" name="user_id" value="<?php echo $_POST['user_id']; ?>" />
</div>
<div class="textcenter">
Are you very sure? <br />
<input type="submit" name="confirm" value="yes" />
<input type="submit" name="confirm" value="no" />
</div>
</form>
<?php
} else {
?>
<div class="warning">No user selected</div>
<?php
}
# SQL Updates
} elseif ($_POST['frmaction'] == "delete2") {
?>
<p class="pageheader">User Remove Results</p>
<?php
if (isset($_POST['user_id'])) {
if ($_POST['confirm'] == "yes") {
$res = $db->exec("DELETE FROM wispusers WHERE ID = ".$_POST['user_id']);
if ($res !== FALSE) {
?>
<div class="notice">User with ID: <?php print_r($_POST['user_id']);?> deleted</div>
<?php
} else {
?>
<div class="warning">Error deleting user</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<?php
}
} else {
?>
<div class="warning">Delete user aborted</div>
<?php
}
} else {
?>
<div class="warning">Attribute list is not empty!</div>
<?php
}
} else {
?>
<div class="warning">Invocation error, no user ID selected</div>
<?php
}
printFooter();
# vim: ts=4
?>
<?php
# Policy member change
# Copyright (C) 2008, LinuxRulz
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
include_once("includes/header.php");
include_once("includes/footer.php");
include_once("includes/db.php");
$db = connect_db();
printHeader(array(
));
# Display edit screen
if ($_POST['frmaction'] == "edit") {
# Check a user was selected
if (isset($_POST['user_id'])) {
# Prepare statement
$userID = $_POST['user_id'];
$sql = "SELECT Password, FirstName, LastName, Location, Email, Phone, IPAddress, PoolName, GroupName, AddressList FROM wispusers WHERE ID = $userID";
$res = $db->query($sql);
$row = $res->fetchObject();
?>
<p class="pageheader">Edit User Information</p>
<form action="wisp-user-edit.php" method="post">
<input type="hidden" name="frmaction" value="edit2" />
<input type="hidden" name="user_id" value="<?php echo $_POST['user_id']; ?>" />
<table class="entry">
<tr>
<td class="entrytitle textcenter" colspan="3">Account Information</td>
</tr>
<tr>
<td><div></div></td>
<td>Old Value</td>
<td>New Value</td>
</tr>
<tr>
<td class="entrytitle texttop">Password</td>
<td class="oldval texttop"><?php echo $row->password ?></td>
<td><input type="password" name="new_password" /></td>
</tr>
<tr>
<td class="entrytitle textcenter" colspan="3">Private Information</td>
</tr>
<tr>
<td><div></div></td>
<td>Old Value</td>
<td>New Value</td>
</tr>
<tr>
<td class="entrytitle texttop">First Name</td>
<td class="oldval texttop"><?php echo $row->firstname ?></td>
<td><input type="text" name="new_firstname" /></td>
</tr>
<tr>
<td class="entrytitle texttop">Last Name</td>
<td class="oldval texttop"><?php echo $row->lastname ?></td>
<td><input type="text" name="new_lastname" /></td>
</tr>
<tr>
<td class="entrytitle texttop">Location</td>
<td class="oldval texttop"><?php echo $row->location ?></td>
<td><input type="text" name="new_location" /></td>
</tr>
<tr>
<td class="entrytitle texttop">Email</td>
<td class="oldval texttop"><?php echo $row->email ?></td>
<td><input type="text" name="new_email" /></td>
</tr>
<tr>
<td class="entrytitle texttop">Phone</td>
<td class="oldval texttop"><?php echo $row->phone ?></td>
<td><input type="text" name="new_phone" /></td>
</tr>
<tr>
<td class="entrytitle texttop">IPAddress</td>
<td class="oldval texttop"><?php echo $row->ipaddress ?></td>
<td><input type="text" name="new_ipaddress" /></td>
</tr>
<tr>
<td class="entrytitle texttop">Pool Name</td>
<td class="oldval texttop"><?php echo $row->poolname ?></td>
<td><input type="text" name="new_poolname" /></td>
</tr>
<tr>
<td class="entrytitle texttop">Group Name</td>
<td class="oldval texttop"><?php echo $row->groupname ?></td>
<td><input type="text" name="new_groupname" /></td>
</tr>
<tr>
<td class="entrytitle texttop">Address List</td>
<td class="oldval texttop"><?php echo $row->addresslist ?></td>
<td><input type="text" name="new_addresslist" /></td>
</tr>
</table>
<p />
<div class="textcenter">
<input type="submit" />
</div>
</form>
<?php
$res->closeCursor();
} else {
?>
<div class="warning">No user selected</div>
<?php
}
# SQL Updates
} elseif ($_POST['frmaction'] == "edit2") {
?>
<p class="pageheader">User Edit Results</p>
<?php
# Check a user was selected
if (isset($_POST['user_id'])) {
$updates = array();
if (!empty($_POST['new_password'])) {
array_push($updates,"Password = ".$db->quote($_POST['new_password']));
}
if (!empty($_POST['new_firstname'])) {
array_push($updates,"FirstName = ".$db->quote($_POST['new_firstname']));
}
if (!empty($_POST['new_lastname'])) {
array_push($updates,"LastName = ".$db->quote($_POST['new_lastname']));
}
if (!empty($_POST['new_location'])) {
array_push($updates,"Location = ".$db->quote($_POST['new_location']));
}
if (!empty($_POST['new_email'])) {
array_push($updates,"Email = ".$db->quote($_POST['new_email']));
}
if (!empty($_POST['new_phone'])) {
array_push($updates,"Phone = ".$db->quote($_POST['new_phone']));
}
if (!empty($_POST['new_ipaddress'])) {
array_push($updates,"IPAddress = ".$db->quote($_POST['new_ipaddress']));
}
if (!empty($_POST['new_poolname'])) {
array_push($updates,"PoolName = ".$db->quote($_POST['new_poolname']));
}
if (!empty($_POST['new_groupname'])) {
array_push($updates,"GroupName = ".$db->quote($_POST['new_groupname']));
}
if (!empty($_POST['new_addresslist'])) {
array_push($updates,"AddressList = ".$db->quote($_POST['new_addresslist']));
}
# Check if we have updates
if (sizeof($updates) > 0) {
$updateStr = implode(', ',$updates);
$res = $db->exec("UPDATE wispusers SET $updateStr WHERE ID = ".$db->quote($_POST['user_id']));
if ($res) {
?>
<div class="notice">User updated</div>
<?php
} else {
?>
<div class="warning">Error updating user</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<?php
}
# Warn
} else {
?>
<div class="warning">No user updates</div>
<?php
}
# Warn
} else {
?>
<div class="error">No user data available</div>
<?php
}
} else {
?>
<div class="warning">Invalid invocation</div>
<?php
}
printFooter();
# vim: ts=4
?>
<?php
# Radius User List
# Copyright (C) 2008-2009, AllWorldIT
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
include_once("includes/header.php");
include_once("includes/footer.php");
include_once("includes/db.php");
$db = connect_db();
printHeader(array(
));
# If we have nothing to do - display search
if (!isset($_POST['frmaction'])) {
?>
<p class="pageheader">User List</p>
<form id="main_form" action="wisp-user-list.php" method="post">
<input type="hidden" name="frmaction" value="dofilter" />
<table class="entry" style="width: 80%;">
<tr>
<td>Sort by:</td>
<td colspan="4">
<input type="radio" name="sortby" value="id">ID</input>
<input type="radio" name="sortby" value="fname">First Name</input>
<input type="radio" name="sortby" value="lname">Last Name</input>
<input type="radio" name="sortby" value="uname">Username</input>
</td>
</tr>
<tr>
<td>Username:</td>
<td><input type="text" name="username" /></td>
<td>First Name:</td>
<td><input type="text" name="firstname" /></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="lastname" /></td>
<td>Phone:</td>
<td><input type="text" name="phone" /></td>
</tr>
<tr>
<td>Location:</td>
<td><input type="text" name="location" /></td>
<td>Email:</td>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td>Pool Name:</td>
<td><input type="text" name="poolname" /></td>
<td>Group:</td>
<td><input type="text" name="group" /></td>
</tr>
<tr>
<td class="textcenter" colspan="5"><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>
<?php
}
if ($_POST['frmaction'] == "dofilter") {
?>
<form id="main_form" action="wisp-user-list.php" method="post">
<div class="textcenter">
Action
<select id="main_form_action" name="frmaction"
onchange="
var myform = document.getElementById('main_form');
var myobj = document.getElementById('main_form_action');
if (myobj.selectedIndex == 2) {
myform.action = 'wisp-user-edit.php';
} else if (myobj.selectedIndex == 3) {
myform.action = 'wisp-user-delete.php';
}
myform.submit();
">
<option selected="selected">select action</option>
<option disabled="disabled"> - - - - - - - - - - - </option>
<option value="edit">Edit User</option>
<option value="delete">Remove User</option>
</select>
</div>
<p />
<table class="results" style="width: 75%;">
<tr class="resultstitle">
<td class="textcenter">ID</td>
<td class="textcenter">Username</td>
<td class="textcenter">FirstName</td>
<td class="textcenter">LastName</td>
<td class="textcenter">Data</td>
<td class="textcenter">Time</td>
<td class="textcenter">Email</td>
<td class="textcenter">Phone</td>
</tr>
<?php
# Additions to the SQL statement
$extraSQLVals = array();
$extraSQL = "";
$orderSQL = "";
# What searches are we going to do?
if ($_POST['username']) {
$extraSQL = " AND Username LIKE ?";
array_push($extraSQLVals,"%".$_POST['username']."%");
}
if ($_POST['firstname']) {
$extraSQL = " AND FirstName LIKE ?";
array_push($extraSQLVals,"%".$_POST['firstname']."%");
}
if ($_POST['lastname']) {
$extraSQL = " AND LastName LIKE ?";
array_push($extraSQLVals,"%".$_POST['lastname']."%");
}
if ($_POST['phone']) {
$extraSQL = " AND Phone LIKE ?";
array_push($extraSQLVals,"%".$_POST['phone']."%");
}
if ($_POST['location']) {
$extraSQL = " AND Location LIKE ?";
array_push($extraSQLVals,"%".$_POST['location']."%");
}
if ($_POST['email']) {
$extraSQL = " AND Email LIKE ?";
array_push($extraSQLVals,"%".$_POST['email']."%");
}
if ($_POST['poolname']) {
$extraSQL = " AND PoolName LIKE ?";
array_push($extraSQLVals,"%".$_POST['poolname']."%");
}
if ($_POST['group']) {
$extraSQL = " AND GroupName LIKE ?";
array_push($extraSQLVals,"%".$_POST['group']."%");
}
# How are we sorting the results?
switch ($_POST['sortby']) {
case "id":
$sortSQL = " ORDER BY ID";
break;
case "fname":
$sortSQL = " ORDER BY FirstName";
break;
case "lname":
$sortSQL = " ORDER BY LastName";
break;
case "uname":
$sortSQL = " ORDER BY Username";
break;
}
# Query based on user input
$sql = "
SELECT
ID,
Username,
FirstName,
LastName,
Data,
Time,
Email,
Phone
FROM
wispusers
WHERE
1 = 1
$extraSQL
$sortSQL
";
$res = $db->prepare($sql);
$res->execute($extraSQLVals);
#$totalInputData = 0;
#$totalOutputData = 0;
#$totalSessionTime = 0;
# List users
$rownums = 0;
while ($row = $res->fetchObject()) {
# If there was nothing returned we want to know about it
if ($row->id != NULL) {
$rownums = $rownums + 1;
} else {
$rownums = $rownums - 1;
}
# Data usage
# ==========
# Input
#$inputDataItem = 0;
#
#if (!empty($row->acctinputoctets) && $row->acctinputoctets > 0) {
# $inputDataItem = ($row->accinputoctets / 1024 / 1024);
#}
#if (!empty($row->acctinputgigawords) && $row->inputgigawords > 0) {
# $inputDataItem = ($row->acctinputgigawords * 4096);
#}
#if ($inputDataItem != 0) {
# $inputDataItemDisplay = ceil($inputDataItem * 100)/100;
#} else {
# $inputDataItemDisplay = 0;
#}
#
#$totalInputData = $totalInputData + $inputDataItem;
#
# Output
#$outputDataItem = 0;
#
#if (!empty($row->acctoutputoctets) && $row->acctoutputoctets > 0) {
# $outputDataItem = ($row->acctoutputoctets / 1024 / 1024);
#}
#if (!empty($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
# $outputDataItem = ($row->acctoutputgigawords * 4096);
#}
#if ($outputDataItem != 0) {
# $outputDataItem = ceil($outputDataItem * 100)/100;
#} else {
# $outputDataItem = 0;
#}
#
#$totalOutputData = $totalOutputData + $outputDataItem;
#
# Add up time
#if (!empty($row->acctsessiontime) && $row->acctsessiontime > 0) {
# $sessionTimeItem = $row->acctsessiontime / 60;
# $sessionTimeItem = ceil($sessionTimeItem * 100)/100;
#}
#
#$totalSessionTime = $totalSessionTime + $sessionTimeItem;
#$totalSessionTime = ceil($totalSessionTime * 100)/100;
?>
<tr class="resultsitem">
<td><input type="radio" name="user_id" value="<?php echo $row->id ?>"/><?php echo $row->id ?></td>
<td><?php echo $row->username ?></td>
<td><?php echo $row->firstname ?></td>
<td><?php echo $row->lastname ?></td>
<td><?php echo $row->data ?></td>
<td><?php echo $row->time ?></td>
<td><?php echo $row->email ?></td>
<td><?php echo $row->phone ?></td>
</tr>
<?php
}
$res->closeCursor();
# If there were no rows, complain
if ($rownums <= 0) {
?>
<p />
<tr>
<td colspan="3" class="textcenter">No users found</td>
</tr>
<?php
}
?>
</table>
</form>
<?php
}
printFooter();
# vim: ts=4
?>
<?php
# mysql:host=xx;dbname=yyy
#
# pgsql:host=xx;dbname=yyy
#
# sqlite:////full/unix/path/to/file.db?mode=0666
#
#$DB_DSN="sqlite:////tmp/cluebringer.sqlite";
$DB_DSN="mysql:host=localhost;dbname=smradius";
$DB_USER="root";
$DB_PASS="root";
$DB_TABLE_PREFIX="";
?>
<?php
require_once('include/config.php');
# Connect to DB
function connect_db()
{
global $DB_DSN;
global $DB_USER;
global $DB_PASS;
try {
$dbh = new PDO($DB_DSN, $DB_USER, $DB_PASS, array(
PDO::ATTR_PERSISTENT => false
));
$dbh->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
} catch (PDOException $e) {
die("Error connecting to Policyd v2 DB: " . $e->getMessage());
}
return $dbh;
}
# vim: ts=4
?>
<?php
# Footer of page
#
# Copyright (c) 2005-2008, AllWorldIT
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
?>
<div class="copyright">Copyright (c) 2005-2008, <a href="http://www.allworldit.com">AllWorldIT</a></div>
<p />
<div class="text-center">
<img src="../static/valid-xhtml10.png" alt="Valid XHTML 1.0 Logo" />
<img src="../static/valid-css2.png" alt="Valid CSS 2 Logo" />
</div>
</body>
</html>
<?php
ob_flush();
?>
<?php
# Header of page
#
# Copyright (c) 2005-2008, AllWorldIT
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Grab version
require_once("include/version.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>SOAP Backend Interface</title>
<link rel="stylesheet" href="../static/styles.css" type="text/css" />
<link rel="stylesheet" href="../static/menu.css" type="text/css" />
</head>
<body>
<div class="pagetitle">Agent Control Panel</div>
<?php
if ($auth->loggedIn) {
?>
<div class="smallinfo">Logged in as <?php echo $auth->username ?> (<a href="./?logout=1">Logout</a>).</div>
<?php
} else {
?>
<div class="smallinfo">v<?php echo $VERSION ?></div>
<?php
}
?>
<?php
# Mail transport stuff
#
# Copyright (c) 2005-2008, AllWorldIT
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# pre takes care of authentication and creates soap object we need
include("include/pre.php");
# Page header
include("include/header.php");
# Soap functions
require_once("php/soapfuncs.php");
?>
<a href=".">Home</a><br><br>
<?php
# Actual form action to update mailbox
function actionUpdate() {
global $soap;
global $transportID;
# Create update hash
$update = NULL;
if ($_POST["policyID"] != "nochange") {
$update["PolicyID"] = $_POST["policyID"];
}
if ($_POST["agentDisabled"] != "") {
$update["AgentDisabled"] = $_POST["agentDisabled"];
}
if ($_POST["agentRef"] != "") {
$update["AgentRef"] = $_POST["agentRef"];
}
# If there are still updates to be done, do them
if ($update != NULL) {
$update["ID"] = $transportID;
$res = $soap->updateMailTransport($update);
if ($res == 0) {
echo "Updated transport<br>\n";
} else {
echo "Error updating transport($res): ".strSoapError($res);
}
# Or report no updates to be made
} else {
echo "No updates to be made!\n";
}
}
# Display edit screen
function screenEdit() {
global $soap;
global $transportID;
$transportInfo = $soap->getMailTransportInfo($transportID);
if (!is_object($transportInfo)) {
echo "getMailTransportInfo: ".strSoapError($transportInfo);
return;
}
$mailPolicies = $soap->getMailPolicies();
if (!is_array($mailPolicies)) {
echo "getMailPolicies: ".strSoapError($mailPolicies);
return;
}
?>
<form action="mailTransports.php?transportID=<?php echo $transportID; ?>" method="POST">
<table border="1">
<tr>
<td colspan="3" align="center">
Transport: <?php printf("%s => %s",$transportInfo->DomainName,
$transportInfo->Transport."/".$transportInfo->Detail); ?>
</td>
</tr>
<tr>
<td>Attribute</td>
<td>Value</td>
<td>New Value</td>
</tr>
<?php
$policyName = "";
foreach ($mailPolicies as $policy) {
if ($transportInfo->PolicyID == $policy->ID) {
$policyName = $policy->PolicyName;
}
}
?>
<tr>
<td>Policy</td>
<td><?php echo $policyName ? $policyName : "default"; ?></td>
<td>
<select name="policyID">
<option value="nochange"></option>
<option value="">Default</option>
<?php
foreach ($mailPolicies as $policy) {
printf("<option value=\"%s\">%s</option>",$policy->ID,$policy->PolicyName);
}
?>
</select>
</td>
</tr>
<tr>
<td>AgentRef</td>
<td><?php echo $transportInfo->AgentRef; ?></td>
<td><input type="text" name="agentRef"></td>
</tr>
<tr>
<td>Disabled</td>
<td><?php echo $transportInfo->AgentDisabled ? "yes" : "no"; ?></td>
<td>
<select name="agentDisabled">
<option value="0" <?php if (!$transportInfo->AgentDisabled) { echo "selected"; } ?>>no</option>
<option value="1" <?php if ($transportInfo->AgentDisabled) { echo "selected"; } ?>>yes</option>
</select>
</td>
<td></td>
</tr>
</table>
<input type="hidden" name="action" value="update">
<input type="submit" value="Update">
</form>
<?php
}
# List mailboxes
function transportList($searchOptions) {
global $soap;
$mailTransports = $soap->getMailTransports($searchOptions);
if (is_array($mailTransports)) {
?>
<a href="mailTransports.php">Back to mail transport search</a><br><br>
<table class="mtlisttable">
<tr class="mtlisttabletitle">
<td colspan="6">Search Results for Mail Transports</td>
</tr>
<tr class="mtlisttablehead">
<td rowspan="2">Domain</td>
<td rowspan="2">Transport</td>
<td rowspan="2">AgentRef</td>
<td colspan="2">Disabled</td>
</tr>
<tr class="mtlisttablehead">
<td>Agent</td>
<td>Delivery</td>
</tr>
<?php
$i = 0;
foreach ($mailTransports as $transport) {
# Check if number is odd or even
if ($i % 2 == 0) {
$j = "1";
} else {
$j = "2";
}
?>
<tr class="mtlisttabledata<?php echo $j ?>">
<td><?php
echo "<a href=\"mailTransports.php?transportID=".$transport->ID."&screen=edit\"?>";
echo $transport->DomainName;
echo "</a>";
?></td>
<td><?php echo $transport->Transport . "/" . $transport->Detail; ?></td>
<td><?php echo $transport->AgentRef; ?></td>
<td><?php echo $transport->AgentDisabled ? "yes" : "no"; ?></td>
<td><?php echo $transport->DisableDelivery ? "yes" : "no"; ?></td>
<td>
<?php
if ($transport->Transport == "virtual") {
?>
<a href="mailboxes.php?transportID=<?php echo $transport->ID ?>">Mailboxes</a> |
<a href="mailboxAliases.php?transportID=<?php echo $transport->ID ?>">Aliases</a>
<?php
}
?>
</td>
</tr>
<?php
$i++;
}
?>
</table>
<br>
<a href="mailTransports.php">Back to mail transport search</a><br><br>
<?php
} else {
echo "getMailTransports: ".strSoapError($mailTransports);
}
}
# Function to display search box
function searchBox() {
?>
<form action="mailTransports.php" method="GET">
<input type="hidden" name="search" value="1">
<table class="mtsearchtable">
<tr class="mtsearchtabletitle">
<td colspan="3">Search Mail Transports</td>
</tr>
<tr>
<td colspan="2" class="mtsearchtableblank"></td>
<td>Order by</td>
</tr>
<tr>
<td class="mtsearchtablehead">Domain Name</td>
<td class="mtsearchtabledata">
<input type="text" name="searchDomainName" value="<?php
echo $_SESSION['transport_searchDomainName']
?>">
</td>
<td class="mtsearchtableorder">
<input type="radio" name="searchOrderBy" value="DomainName" <?php
if ($_SESSION['transport_searchOrderBy'] == ""
|| $_SESSION['transport_searchOrderBy'] == "DomainName") {
echo "checked";
}
?>>
</td>
</tr>
<tr>
<td class="mtsearchtablehead">Agent Ref</td>
<td class="mtsearchtabledata">
<input type="text" name="searchAgentRef" value="<?php
echo $_SESSION['transport_searchAgentRef']
?>">
</td>
<td class="mtsearchtableorder">
<input type="radio" name="searchOrderBy" value="AgentRef" <?php
if ($_SESSION['transport_searchOrderBy'] == "AgentRef") {
echo "checked";
}
?>>
</td>
</tr>
<tr class="mtsearchtablesubmit">
<td colspan="3"><input type="submit"></td>
</tr>
</table>
</form>
Note On Searching:
<li>Wildcards can be specified with *'s. For example: *.com
<li>Blank search criteria matches everything
<?php
}
# Check if we have a transport
if ($_REQUEST['transportID'] > 0) {
$transportID = $_REQUEST['transportID'];
$transportInfo = $soap->getMailTransportInfo($transportID);
echo("<a href=\"mailTransports.php?search=1\">Back to mail transports</a><br><br>");
# Check if we have a special action to perform
if ($_POST["action"] == "update") {
actionUpdate();
# Edit screen
} elseif ($_REQUEST["screen"] == "edit") {
screenEdit();
}
# We came from our search box
} elseif ($_REQUEST['search'] == 1) {
# Process search options
if (isset($_REQUEST['searchDomainName'])) {
$_SESSION['transport_searchDomainName'] = $_REQUEST['searchDomainName'];
}
if (isset($_REQUEST['searchAgentRef'])) {
$_SESSION['transport_searchAgentRef'] = $_REQUEST['searchAgentRef'];
}
if (isset($_REQUEST['searchOrderBy'])) {
$_SESSION['transport_searchOrderBy'] = $_REQUEST['searchOrderBy'];
}
# Setup search
$searchOptions->searchDomainName = $_SESSION['transport_searchDomainName'];
$searchOptions->searchAgentRef = $_SESSION['transport_searchAgentRef'];
$searchOptions->searchOrderBy = $_SESSION['transport_searchOrderBy'];
transportList($searchOptions);
# Anything else
} else {
searchBox();
}
# Footer
include("include/footer.php");
?>
<?php
# Mailbox stuff
#
# Copyright (c) 2005-2008, AllWorldIT
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# pre takes care of authentication and creates soap object we need
include("include/pre.php");
# Page header
include("include/header.php");
# Soap functions
require_once("php/soapfuncs.php");
?>
<a href=".">Home</a><br><br>
<a href="mailTransports.php">Back to mail transport search</a><br><br>
<a href="mailTransports.php?search=1">Back to mail transports</a><br><br>
<?php
# Actual form action to add mailbox
function actionAdd() {
global $soap;
global $transportID;
$mailboxAliasInfo = NULL;
$mailboxAliasInfo["Address"] = $_POST["address"];
if ($_POST["goto"] != "") {
$mailboxAliasInfo["Goto"] = $_POST["goto"];
} else {
echo "Forward to must be specified!<br>";
return;
}
# Check optional data
if ($_POST["agentDisabled"] != "") {
$mailboxAliasInfo["AgentDisabled"] = $_POST["agentDisabled"];
}
if ($_POST["agentRef"] != "") {
$mailboxAliasInfo["AgentRef"] = $_POST["agentRef"];
}
# Create mailbox and check for error
$res = $soap->createMailboxAlias($transportID,$mailboxAliasInfo);
if ($res > 0) {
echo "Added mailbox alias\n";
} else {
echo "Error creating mailbox alias: ".strSoapError($res);
}
}
# Actual form action to update mailbox
function actionUpdate() {
global $soap;
global $mailboxAliasID;
# Create update hash
$update = NULL;
if ($_POST["goto"] != "") {
$update["Goto"] = $_POST["goto"];
}
if ($_POST["agentDisabled"] != "") {
$update["AgentDisabled"] = $_POST["agentDisabled"];
}
if ($_POST["agentRef"] != "") {
$update["AgentRef"] = $_POST["agentRef"];
}
# If there are still updates to be done, do them
if ($update != NULL) {
$update["ID"] = $mailboxAliasID;
$res = $soap->updateMailboxAlias($update);
if ($res == 0) {
echo "Updated mailbox alias\n";
} else {
echo "Error updating mailbox alias: ".strSoapError($res);
}
# Or report no updates to be made
} else {
echo "No updates to be made!\n";
}
}
# Actual form action to remove a mailbox
function actionRemove() {
global $soap;
global $mailboxAliasID;
$res = $soap->removeMailboxAlias($mailboxAliasID);
if ($res == 0) {
echo "Removed mailbox alias\n";
} else {
echo "Error removing mailbox alias: ".strSoapError($res);
}
}
# Display edit screen
function screenEdit() {
global $soap;
global $transportID;
global $mailboxAliasID;
$transportInfo = $soap->getMailTransportInfo($transportID);
if (!is_object($transportInfo)) {
echo "getMailTransportInfo: ".strSoapError($transportInfo);
return;
}
$aliasInfo = $soap->getMailboxAliasInfo($mailboxAliasID);
if (!is_object($aliasInfo)) {
echo "getMailboxAliasInfo: ".strSoapError($aliasInfo);
return;
}
?>
<form action="mailboxAliases.php?transportID=<?php echo $transportID; ?>&mailboxAliasID=<?php echo $mailboxAliasID; ?>" method="POST">
<table border="1">
<tr>
<td colspan="3" align="center">
Alias: <?php printf("%s@%s",$aliasInfo->Address,$transportInfo->DomainName); ?>
</td>
</tr>
<tr>
<td>Attribute</td>
<td>Value</td>
<td>New Value</td>
</tr>
<tr>
<td>Foward to</td>
<td><?php echo $aliasInfo->Goto; ?></td>
<td><input type="text" name="goto"></td>
</tr>
<tr>
<td>AgentRef</td>
<td><?php echo $aliasInfo->AgentRef; ?></td>
<td><input type="text" name="agentRef"></td>
</tr>
<tr>
<td>Disabled</td>
<td><?php echo $aliasInfo->AgentDisabled ? "yes" : "no"; ?></td>
<td>
<select name="agentDisabled">
<option value="0" <?php if (!$aliasInfo->AgentDisabled) { echo "selected"; } ?>>no</option>
<option value="1" <?php if ($aliasInfo->AgentDisabled) { echo "selected"; } ?>>yes</option>
</select>
</td>
</tr>
</table>
<input type="hidden" name="action" value="update">
<input type="submit" value="Update">
</form>
<?php
}
# Remove screen
function screenRemove() {
global $soap;
global $transportID;
global $mailboxAliasID;
$transportInfo = $soap->getMailTransportInfo($transportID);
if (!is_object($transportInfo)) {
echo "getMailTransportInfo: ".strSoapError($transportInfo);
return;
}
$mailboxAliasInfo = $soap->getMailboxAliasInfo($mailboxAliasID);
if (!is_object($mailboxAliasInfo)) {
echo "getMailboxAliasInfo: ".strSoapError($mailboxAliasInfo);
return;
}
?>
<form action="mailboxAliases.php?transportID=<?php echo $transportID ?>&mailboxAliasID=<?php echo $mailboxAliasID ?>" method="POST">
<input type="hidden" name="action" value="remove">
Are you very sure you wish to remove alias <?php printf("%s@%s",$mailboxAliasInfo->Address,$transportInfo->DomainName) ?>?<br>
<input type="submit" value="Yes">
<br>
<?php
}
# Add screen
function screenAdd() {
global $soap;
global $transportID;
global $mailboxAliasesID;
$transportInfo = $soap->getMailTransportInfo($transportID);
if (!is_object($transportInfo)) {
echo "getMailTransportInfo: ".strSoapError($transportInfo);
return;
}
?>
<form action="mailboxAliases.php?transportID=<?php echo $transportID ?>&action=add" method="POST">
<input type="hidden" name="action" value="add">
<table border="1">
<tr>
<td>Attribute</td>
<td>Value</td>
</tr>
<tr>
<td>Address (@<?php echo $transportInfo->DomainName ?>)</td>
<td><input type="text" name="address"></td>
</tr>
<tr>
<td>Forward to</td>
<td><input type="text" name="goto"></td>
</tr>
<tr>
<td>AgentRef</td>
<td><input type="text" name="agentRef"></td>
</tr>
<tr>
<td>Disabled</td>
<td>
<select name="agentDisabled">
<option value="0" selected>no</option>
<option value="1">yes</option>
</select>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Add">
</td>
</tr>
</table>
</form>
<br>
<?php
}
# List mailbox aliases
function mailboxAliasList($searchOptions) {
global $soap;
global $transportID;
$transportInfo = $soap->getMailTransportInfo($transportID);
if (!is_object($transportInfo)) {
echo "getMailTransportInfo: ".strSoapError($transportInfo);
return;
}
?>
<table border="1">
<tr>
<td colspan="6" align="center">Aliases for <?php echo $transportInfo->DomainName; ?></td>
</tr>
<tr>
<td align="center" rowspan="2">Alias</td>
<td align="center" rowspan="2">Foward to</td>
<td align="center" rowspan="2">AgentRef</td>
<td align="center" colspan="2">Disable</td>
<td></td>
</tr>
<tr>
<td align="center">Agent</td>
<td align="center">Delivery</td>
<td></td>
</tr>
<?php
$mailboxAliases = $soap->getMailboxAliases($transportID,$searchOptions);
if (is_array($mailboxAliases)) {
if (count($mailboxAliases)) {
?>
<tr>
<td colspan="6" align="center">
<a href="mailboxAliases.php?transportID=<?php echo $transportID ?>&screen=add">Add Mailbox Alias</a>
</td>
</tr>
<?php
}
foreach ($mailboxAliases as $item) {
?>
<tr>
<td><?php echo $item->Address != "" ? $item->Address : "[catchall]"; ?></td>
<td><?php echo $item->Goto; ?></td>
<td><?php echo $item->AgentRef; ?></td>
<td align="center"><?php echo $item->AgentDisabled ? "yes" : "no"; ?></td>
<td align="center"><?php echo $item->DisableDelivery ? "yes" : "no"; ?></td>
<td>
<a href="mailboxAliases.php?transportID=<?php echo $transportID; ?>&mailboxAliasID=<?php echo $item->ID; ?>&screen=edit">Edit</a>
| <a href="mailboxAliases.php?transportID=<?php echo $transportID; ?>&mailboxAliasID=<?php echo $item->ID; ?>&screen=remove">Remove</a>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="6" align="center">
<a href="mailboxAliases.php?transportID=<?php echo $transportID ?>&screen=add">Add Mailbox Alias</a>
</td>
</tr>
<?php
} else {
?>
<tr>
<td colspan="6">
<?php
echo "getMailboxAliases: ".strSoapError($mailboxAliases);
?>
</td>
</tr>
<?php
}
?>
</table>
<?php
}
# Display search box
function searchBox()
{
global $transportID;
?>
<form action="mailboxAliases.php" method="GET">
<input type="hidden" name="transportID" value="<?php echo $transportID ?>">
<input type="hidden" name="search" value="1">
<table border="1">
<tr>
<td colspan="3" align="center">Search Mailbox Aliases</td>
</tr>
<tr>
<td colspan="2"></td>
<td align="center">Order by</td>
</tr>
<tr>
<td>Address</td>
<td>
<input type="text" name="searchAddress" value="<?php
echo $_SESSION['mailboxAlias_searchAddress']
?>">
</td>
<td align="center">
<input type="radio" name="searchOrderBy" value="Address" <?php
if ($_SESSION['mailboxAlias_searchOrderBy'] == ""
|| $_SESSION['mailboxAlias_searchOrderBy'] == "Address") {
echo "checked";
}
?>>
</td>
</tr>
<tr>
<td>Agent Ref</td>
<td>
<input type="text" name="searchAgentRef" value="<?php
echo $_SESSION['mailboxAlias_searchAgentRef']
?>">
</td>
<td align="center"><input type="radio" name="searchOrderBy" value="AgentRef" <?php
if ($_SESSION['mailboxAlias_searchOrderBy'] == "AgentRef") {
echo "checked";
}
?>>
</td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit"></td>
</tr>
</table>
</form>
Note On Searching:
<li>Wildcards can be specified with *'s. For example: *.com
<li>Blank search criteria matches everything
<?php
}
# Check if we have a transport
if ($_REQUEST['transportID'] > 0) {
$transportID = $_REQUEST['transportID'];
# Check if we have a mailbox ID, pull in the relevant stuff
if ($_REQUEST['mailboxAliasID'] > 0) {
$mailboxAliasID = $_REQUEST['mailboxAliasID'];
printf("<a href=\"mailboxAliases.php?transportID=%s\">Back to mailbox alias search</a><br><br>",$transportID);
printf("<a href=\"mailboxAliases.php?transportID=%s&search=1\">Back to mailbox aliases</a><br><br>",$transportID);
# Check if we have a special action to perform
if ($_POST["action"] == "update") {
actionUpdate();
# Actual remove action
} elseif ($_POST["action"] == "remove") {
actionRemove();
# Edit screen
} elseif ($_REQUEST["screen"] == "edit") {
screenEdit();
# Remove screen
} elseif ($_REQUEST["screen"] == "remove") {
screenRemove();
}
} else {
# Check if we have a special action to perform
if ($_REQUEST["screen"] == "add") {
printf("<a href=\"mailboxAliases.php?transportID=%s\">Back to mailbox alias search</a><br><br>",$transportID);
printf("<a href=\"mailboxAliases.php?transportID=%s&search=1\">Back to mailbox aliases</a><br><br>",$transportID);
screenAdd();
} elseif ($_POST["action"] == "add") {
printf("<a href=\"mailboxAliases.php?transportID=%s\">Back to mailbox alias search</a><br><br>",$transportID);
printf("<a href=\"mailboxAliases.php?transportID=%s&search=1\">Back to mailbox aliases</a><br><br>",$transportID);
actionAdd();
# We came from search screen
} elseif ($_REQUEST['search'] == 1) {
printf("<a href=\"mailboxAliases.php?transportID=%s\">Back to mailbox alias search</a><br><br>",$transportID);
# Process search options
if (isset($_REQUEST['searchAddress'])) {
$_SESSION['mailboxAlias_searchAddress'] = $_REQUEST['searchAddress'];
}
if (isset($_REQUEST['searchAgentRef'])) {
$_SESSION['mailboxAlias_searchAgentRef'] = $_REQUEST['searchAgentRef'];
}
if (isset($_REQUEST['searchOrderBy'])) {
$_SESSION['mailboxAlias_searchOrderBy'] = $_REQUEST['searchOrderBy'];
}
# Setup search
$searchOptions->searchAddress = $_SESSION['mailboxAlias_searchAddress'];
$searchOptions->searchAgentRef = $_SESSION['mailboxAlias_searchAgentRef'];
$searchOptions->searchOrderBy = $_SESSION['mailboxAlias_searchOrderBy'];
mailboxAliasList($searchOptions);
# We need to search
} else {
searchBox();
}
}
} else {
echo "You cannot call this module directly.";
}
# Footer
include("include/footer.php");
?>
<?php
# Mailbox stuff
#
# Copyright (c) 2005-2008, AllWorldIT
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# pre takes care of authentication and creates soap object we need
include("include/pre.php");
# Page header
include("include/header.php");
# Soap functions
require_once("php/soapfuncs.php");
# Javascript stuff
include("js.getRandomPass");
?>
<a href=".">Home</a><br><br>
<a href="mailTransports.php">Back to mail transport search</a><br><br>
<a href="mailTransports.php?search=1">Back to mail transports</a><br><br>
<?php
# Actual form action to add mailbox
function actionAdd() {
global $soap;
global $transportID;
$mailboxInfo = NULL;
# Verify data
if ($_POST["address"] != "") {
$mailboxInfo["Address"] = $_POST["address"];
} else {
echo "Address must be specified!<br>";
return;
}
if ($_POST["password"] != "") {
$mailboxInfo["Password"] = $_POST["password"];
} else {
echo "Password must be specified!<br>";
return;
}
# Check optional data
if ($_POST["quota"] != "") {
$mailboxInfo["Quota"] = $_POST["quota"];
} else {
echo "Quota must be defined!, you probably want to choose 5 for a 5Mb mailbox.<br>";
return;
}
if ($_POST["policyID"] != "") {
$mailboxInfo["PolicyID"] = $_POST["policyID"];
}
if ($_POST["name"] != "") {
$mailboxInfo["Name"] = $_POST["name"];
}
if ($_POST["agentRef"] != "") {
$mailboxInfo["AgentRef"] = $_POST["agentRef"];
}
if ($_POST["premiumSMTP"] != "") {
$mailboxInfo["PremiumSMTP"] = $_POST["premiumSMTP"];
}
if ($_POST["premiumPolicy"] != "") {
$mailboxInfo["PremiumPolicy"] = $_POST["premiumPolicy"];
}
if ($_POST["agentDisabled"] != "") {
$mailboxInfo["AgentDisabled"] = $_POST["agentDisabled"];
}
# Create mailbox and check for error
$res = $soap->createMailbox($transportID,$mailboxInfo);
if ($res > 0) {
echo "Added mailbox<br>\n";
} else {
echo "Error creating mailbox: ".strSoapError($res);
}
}
# Actual form action to update mailbox
function actionUpdate() {
global $soap;
global $mailboxID;
# Create update hash
$update = NULL;
if ($_POST["password"] != "") {
$update["Password"] = $_POST["password"];
}
if ($_POST["quota"] != "") {
$update["Quota"] = $_POST["quota"];
}
if ($_POST["policyID"] != "nochange") {
$update["PolicyID"] = $_POST["policyID"];
}
if ($_POST["name"] != "") {
$update["Name"] = $_POST["name"];
}
if ($_POST["agentRef"] != "") {
$update["AgentRef"] = $_POST["agentRef"];
}
if ($_POST["premiumSMTP"] != "") {
$update["PremiumSMTP"] = $_POST["premiumSMTP"];
}
if ($_POST["premiumPolicy"] != "") {
$update["PremiumPolicy"] = $_POST["premiumPolicy"];
}
if ($_POST["agentDisabled"] != "") {
$update["AgentDisabled"] = $_POST["agentDisabled"];
}
# If there are still updates to be done, do them
if ($update != NULL) {
$update["ID"] = $mailboxID;
$res = $soap->updateMailbox($update);
if ($res == 0) {
echo "Updated mailbox<br>\n";
} else {
echo "Error updating mailbox: ".strSoapError($res);
}
# Or report no updates to be made
} else {
echo "No updates to be made!\n";
}
}
# Actual form action to remove a mailbox
function actionRemove() {
global $soap;
global $mailboxID;
$res = $soap->removeMailbox($mailboxID);
if ($res == 0) {
echo "Removed mailbox\n";
} else {
echo "Error removing mailbox: ".strSoapError($res);
}
}
# Display edit screen
function screenEdit() {
global $soap;
global $transportID;
global $mailboxID;
$transportInfo = $soap->getMailTransportInfo($transportID);
if (!is_object($transportInfo)) {
echo "getMailTransportInfo: ".strSoapError($transportInfo);
return;
}
$mailboxInfo = $soap->getMailboxInfo($mailboxID);
if (!is_object($mailboxInfo)) {
echo "getMailboxInfo: ".strSoapError($mailboxInfo);
return;
}
$mailPolicies = $soap->getMailPolicies();
if (!is_array($mailPolicies)) {
echo "getMailPolicies: ".strSoapError($mailPolicies);
return;
}
?>
<form action="mailboxes.php?transportID=<?php echo $transportID; ?>&mailboxID=<?php echo $mailboxID; ?>" method="POST">
<input type="hidden" name="action" value="update">
<table border="1">
<tr>
<td colspan="3" align="center">
Mailbox: <?php printf("%s@%s",$mailboxInfo->Address,$transportInfo->DomainName); ?>
</td>
</tr>
<tr>
<td>Attribute</td>
<td>Value</td>
<td>New Value</td>
</tr>
<tr>
<td>Quota (in Mbyte)</td>
<td><?php echo $mailboxInfo->Quota; ?></td>
<td><input type="text" name="quota"></td>
</tr>
<tr>
<td>Password</td>
<td>*encrypted*</td>
<td>
<input type="text" name="password">
<input type="button" value="generate" onClick="this.form.password.value=getRandomPass(8)">
</td>
</tr>
<?php
$policyName = "";
foreach ($mailPolicies as $policy) {
if ($mailboxInfo->PolicyID == $policy->ID) {
$policyName = $policy->PolicyName;
}
}
?>
<tr>
<td>Policy</td>
<td><?php echo $policyName ? $policyName : "default"; ?></td>
<td>
<select name="policyID">
<option value="nochange"></option>
<option value="">Default</option>
<?php
foreach ($mailPolicies as $policy) {
printf("<option value=\"%s\">%s</option>",$policy->ID,$policy->PolicyName);
}
?>
</select>
</td>
</tr>
<tr>
<td>Name</td>
<td><?php echo $mailboxInfo->Name; ?></td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>AgentRef</td>
<td><?php echo $mailboxInfo->AgentRef; ?></td>
<td><input type="text" name="agentRef"></td>
</tr>
<tr>
<td>Premium SMTP</td>
<td><?php echo $mailboxInfo->PremiumSMTP ? "yes" : "no"; ?></td>
<td>
<select name="premiumSMTP">
<option value="0" <?php if (!$mailboxInfo->PremiumSMTP) { echo "selected"; } ?>>no</option>
<option value="1" <?php if ($mailboxInfo->PremiumSMTP) { echo "selected"; } ?>>yes</option>
</select>
</td>
</tr>
<tr>
<td>Premium Policy</td>
<td><?php echo $mailboxInfo->PremiumPolicy ? "yes" : "no"; ?></td>
<td>
<select name="premiumPolicy">
<option value="0" <?php if (!$mailboxInfo->PremiumPolicy) { echo "selected"; } ?>>no</option>
<option value="1" <?php if ($mailboxInfo->PremiumPolicy) { echo "selected"; } ?>>yes</option>
</select>
</td>
</tr>
<tr>
<td>Disabled</td>
<td><?php echo $mailboxInfo->AgentDisabled ? "yes" : "no"; ?></td>
<td>
<select name="agentDisabled">
<option value="0" <?php if (!$mailboxInfo->AgentDisabled) { echo "selected"; } ?>>no</option>
<option value="1" <?php if ($mailboxInfo->AgentDisabled) { echo "selected"; } ?>>yes</option>
</select>
</td>
</tr>
<tr>
<td align="center" colspan="3">
<input type="submit" value="Update">
</td>
</tr>
</table>
</form>
<br>
<font size="-1">
Note:
<li>To enable clients to log in an change their anti-virus/spam settings, set [Policy] to "Client - Premium Service" and [Premium Policy] to "yes"
</font>
<?php
}
# Remove screen
function screenRemove() {
global $soap;
global $transportID;
global $mailboxID;
$transportInfo = $soap->getMailTransportInfo($transportID);
if (!is_object($transportInfo)) {
echo "getMailTransportInfo: ".strSoapError($transportInfo);
return;
}
$mailboxInfo = $soap->getMailboxInfo($mailboxID);
if (!is_object($mailboxInfo)) {
echo "getMailboxInfo: ".strSoapError($mailboxInfo);
return;
}
?>
<form action="mailboxes.php?transportID=<?php echo $transportID ?>&mailboxID=<?php echo $mailboxID ?>" method="POST">
<input type="hidden" name="action" value="remove">
Are you very sure you wish to remove mailbox <?php printf("%s@%s",$mailboxInfo->Address,$transportInfo->DomainName) ?>?
<br>
<input type="submit" value="Yes">
</form>
<br
<?php
}
# Add screen
function screenAdd() {
global $soap;
global $transportID;
global $mailboxID;
$transportInfo = $soap->getMailTransportInfo($transportID);
if (!is_object($transportInfo)) {
echo "getMailTransportInfo: ".strSoapError($transportInfo);
return;
}
?>
<form action="mailboxes.php?transportID=<?php echo $transportID ?>&action=add" method="POST">
<input type="hidden" name="action" value="add">
<table border="1">
<tr>
<td>Attribute</td>
<td>Value</td>
</tr>
<tr>
<td>Address (@<?php echo $transportInfo->DomainName ?>)</td>
<td><input type="text" name="address"></td>
</tr>
<tr>
<td>Password</td>
<td>
<input type="text" name="password">
<input type="button" value="generate" onClick="this.form.password.value=getRandomPass(8)">
</td>
</tr>
<tr>
<td>Quota (in Mbyte)</td>
<td><input type="text" name="quota"></td>
</tr>
<tr>
<td>Name</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>AgentRef</td>
<td><input type="text" name="agentRef"></td>
</tr>
<tr>
<td>Premium SMTP</td>
<td>
<select name="premiumSMTP">
<option value="0" selected>no</option>
<option value="1">yes</option>
</select>
</td>
</tr>
<tr>
<td>Premium Policy</td>
<td>
<select name="premiumPolicy">
<option value="0" selected>no</option>
<option value="1">yes</option>
</select>
</td>
</tr>
<tr>
<td>Disabled</td>
<td>
<select name="agentDisabled">
<option value="0" selected>no</option>
<option value="1">yes</option>
</select>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Add">
</td>
</tr>
</table>
</form>
<br>
<?php
}
# List mailboxes
function mailboxList($searchOptions) {
global $soap;
global $transportID;
$transportInfo = $soap->getMailTransportInfo($transportID);
if (!is_object($transportInfo)) {
echo "getMailTransportInfo: ".strSoapError($transportInfo);
return;
}
?>
<table border="1">
<tr>
<td colspan="7" align="center">Search Results for Mailboxes on <?php echo $transportInfo->DomainName; ?></td>
</tr>
<tr>
<td rowspan="2" align="center">Mailbox</td>
<td rowspan="2" align="center">Quota</td>
<td rowspan="2" align="center">AgentRef</td>
<td colspan="3" align="center">Disable</td>
<td rowspan="2"></td>
</tr>
<tr>
<td>Agent</td>
<td>Login</td>
<td>Delivery</td>
</tr>
<?php
$mailboxes = $soap->getMailboxes($transportID,$searchOptions);
if (is_array($mailboxes)) {
if (count($mailboxes)) {
?>
<tr>
<td colspan="7" align="center">
<a href="mailboxes.php?transportID=<?php echo $transportID ?>&screen=add">Add Mailbox</a>
</td>
</tr>
<?php
}
foreach ($mailboxes as $item) {
?>
<tr>
<td><?php echo $item->Address; ?></td>
<td><?php echo $item->Quota; ?>Mb</td>
<td><?php echo $item->AgentRef; ?></td>
<td align="center"><?php echo $item->AgentDisabled ? "yes" : "no"; ?></td>
<td align="center"><?php echo $item->DisableLogin ? "yes" : "no"; ?></td>
<td align="center"><?php echo $item->DisableDelivery ? "yes" : "no"; ?></td>
<td>
<a href="mailboxes.php?transportID=<?php echo $transportID; ?>&mailboxID=<?php echo $item->ID; ?>&screen=edit">Edit</a>
| <a href="mailboxes.php?transportID=<?php echo $transportID; ?>&mailboxID=<?php echo $item->ID; ?>&screen=remove">Remove</a>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="7" align="center">
<a href="mailboxes.php?transportID=<?php echo $transportID ?>&screen=add">Add Mailbox</a>
</td>
</tr>
<?php
} else {
?>
<tr>
<td colspan="5">
<?php
echo "getMailboxes: ".strSoapError($mailboxes);
?>
</td>
</tr>
<?php
}
?>
</table>
<?php
}
# Display search box
function searchBox()
{
global $transportID;
?>
<form action="mailboxes.php" method="GET">
<input type="hidden" name="transportID" value="<?php echo $transportID ?>">
<input type="hidden" name="search" value="1">
<table border="1">
<tr>
<td colspan="3" align="center">Search Mailboxes</td>
</tr>
<tr>
<td colspan="2"></td>
<td align="center">Order by</td>
</tr>
<tr>
<td>Address</td>
<td>
<input type="text" name="searchAddress" value="<?php
echo $_SESSION['mailbox_searchAddress']
?>">
</td>
<td align="center">
<input type="radio" name="searchOrderBy" value="Address" <?php
if ($_SESSION['mailbox_searchOrderBy'] == ""
|| $_SESSION['mailbox_searchOrderBy'] == "Address") {
echo "checked";
}
?>>
</td>
</tr>
<tr>
<td>Agent Ref</td>
<td>
<input type="text" name="searchAgentRef" value="<?php
echo $_SESSION['mailbox_searchAgentRef']
?>">
</td>
<td align="center"><input type="radio" name="searchOrderBy" value="AgentRef" <?php
if ($_SESSION['mailbox_searchOrderBy'] == "AgentRef") {
echo "checked";
}
?>>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit"></td>
</tr>
</table>
</form>
Note On Searching:
<li>Wildcards can be specified with *'s. For example: *.com
<li>Blank search criteria matches everything
<?php
}
# Check if we have a transport
if ($_REQUEST['transportID'] > 0) {
$transportID = $_REQUEST['transportID'];
$transportInfo = $soap->getMailTransportInfo($transportID);
# Check if we have a mailbox ID, pull in the relevant stuff
if ($_REQUEST['mailboxID'] > 0) {
$mailboxID = $_REQUEST['mailboxID'];
printf("<a href=\"mailboxes.php?transportID=%s\">Back to mailbox search</a><br><br>",$transportID);
printf("<a href=\"mailboxes.php?transportID=%s&search=1\">Back to mailboxes</a><br><br>",$transportID);
# Check if we have a special action to perform
if ($_POST["action"] == "update") {
actionUpdate();
# Actual remove action
} elseif ($_POST["action"] == "remove") {
actionRemove();
# Edit screen
} elseif ($_REQUEST["screen"] == "edit") {
screenEdit();
# Remove screen
} elseif ($_REQUEST["screen"] == "remove") {
screenRemove();
}
} else {
# Check if we have a special action to perform
if ($_REQUEST["screen"] == "add") {
printf("<a href=\"mailboxes.php?transportID=%s\">Back to mailbox search</a><br><br>",$transportID);
printf("<a href=\"mailboxes.php?transportID=%s&search=1\">Back to mailboxes</a><br><br>",$transportID);
screenAdd();
} elseif ($_POST["action"] == "add") {
printf("<a href=\"mailboxes.php?transportID=%s\">Back to mailbox search</a><br><br>",$transportID);
printf("<a href=\"mailboxes.php?transportID=%s&search=1\">Back to mailboxes</a><br><br>",$transportID);
actionAdd();
# We came from search screen
} elseif ($_REQUEST['search'] == 1) {
printf("<a href=\"mailboxes.php?transportID=%s\">Back to mailbox search</a><br><br>",$transportID);
# Process search options
if (isset($_REQUEST['searchAddress'])) {
$_SESSION['mailbox_searchAddress'] = $_REQUEST['searchAddress'];
}
if (isset($_REQUEST['searchAgentRef'])) {
$_SESSION['mailbox_searchAgentRef'] = $_REQUEST['searchAgentRef'];
}
if (isset($_REQUEST['searchOrderBy'])) {
$_SESSION['mailbox_searchOrderBy'] = $_REQUEST['searchOrderBy'];
}
# Setup search
$searchOptions->searchAddress = $_SESSION['mailbox_searchAddress'];
$searchOptions->searchAgentRef = $_SESSION['mailbox_searchAgentRef'];
$searchOptions->searchOrderBy = $_SESSION['mailbox_searchOrderBy'];
mailboxList($searchOptions);
# We need to search
} else {
searchBox();
}
}
} else {
echo "You cannot call this module directly.";
}
# Footer
include("include/footer.php");
?>