Skip to content
Snippets Groups Projects
Commit ce6b3c4e authored by Robert Anderson's avatar Robert Anderson
Browse files

Initial support for querying database

parent aa38d2a3
No related branches found
No related tags found
No related merge requests found
<?php
# Requires / Includes
include_once("functions/AdminUsers.php");
include_once("functions/AdminGroups.php");
include_once("functions/AdminRealms.php");
include_once("functions/AdminLocations.php");
define('RES_OK',0);
define('RES_ERR',-1);
......@@ -167,8 +172,7 @@
);
echo json_encode($res);
*/
# echo json_encode($msg);
print_r($_POST);
echo json_encode($msg);
exit;
}
......@@ -287,46 +291,185 @@ print_r($_POST);
}
}
switch ($function) {
case "getWiSPResellers":
if ($function == "getWiSPUsers") {
$rawData = array (
$rawData = array (
array(
'ID' => 10,
'Name' => 'TestReseller1'
)
);
array(
'ID' => 10,
'AgentID' => 5,
'AgentName' => 'joe agent',
'Username' => 'johnsmith',
'UsageCap' => 1000,
'ClassID' => 7,
'ClassDesc' => 'ClassTest',
'RealmDesc' => 'My Realm',
'Service' => 'My Service',
'AgentDisabled' => FALSE,
'Disabled' => FALSE,
'AgentRef' => 'Reseller ref'
)
);
$numResults = 1;
$res = new json_response;
$res->setID('ID');
$res->addField('ID','int');
$res->addField('AgentID','int');
$res->addField('AgentName','string');
$res->addField('Username','string');
$res->addField('UsageCap','int');
$res->addField('ClassID','int');
$res->addField('ClassDesc','string');
$res->addField('RealmDesc','string');
$res->addField('Service','string');
$res->addField('AgentDisabled','boolean');
$res->addField('Disabled','boolean');
$res->addField('AgentRef','string');
$res->parseArray($rawData);
$res->setDatasetSize($numResults);
echo json_encode($res->export());
$numResults = 1;
$res = new json_response;
$res->setID('ID');
$res->addField('ID','int');
$res->addField('Name','string');
$res->parseArray($rawData);
$res->setDatasetSize($numResults);
echo json_encode($res->export());
break;
case "getLocations":
$rawData = getAdminLocations($soapParams);
$res = new json_response;
$res->setID('ID');
$res->addField('ID','int');
$res->addField('Name','string');
$res->parseArray($rawData[1]);
$res->setDatasetSize($rawData[0]);
echo json_encode($res->export());
break;
case "getAdminRealms":
$rawData = getAdminRealms($soapParams);
$res = new json_response;
$res->setID('ID');
$res->addField('ID','int');
$res->addField('Name','string');
$res->addField('Disabled','boolean');
$res->parseArray($rawData[1]);
$res->setDatasetSize($rawData[0]);
echo json_encode($res->export());
break;
case "getAdminGroups":
$rawData = getAdminGroups($soapParams);
$res = new json_response;
$res->setID('ID');
$res->addField('ID','int');
$res->addField('Name','string');
$res->addField('Priority','int');
$res->addField('Disabled','boolean');
$res->addField('Comment','string');
$res->parseArray($rawData[1]);
$res->setDatasetSize($rawData[0]);
echo json_encode($res->export());
break;
case "getAdminUsers":
$rawData = getAdminUsers($soapParams);
$res = new json_response;
$res->setID('ID');
$res->addField('ID','int');
$res->addField('Username','string');
$res->addField('Disabled','boolean');
$res->parseArray($rawData[1]);
$res->setDatasetSize($rawData[0]);
echo json_encode($res->export());
break;
case "getWiSPUsers":
$rawData = array (
array(
'ID' => 10,
'AgentID' => 5,
'AgentName' => 'joe agent',
'Username' => 'johnsmith',
'UsageCap' => 1000,
'ClassID' => 7,
'ClassDesc' => 'ClassTest',
'RealmDesc' => 'My Realm',
'Service' => 'My Service',
'AgentDisabled' => FALSE,
'Disabled' => FALSE,
'AgentRef' => 'Reseller ref'
)
);
$numResults = 1;
$res = new json_response;
$res->setID('ID');
$res->addField('ID','int');
$res->addField('AgentID','int');
$res->addField('AgentName','string');
$res->addField('Username','string');
$res->addField('UsageCap','int');
$res->addField('ClassID','int');
$res->addField('ClassDesc','string');
$res->addField('RealmDesc','string');
$res->addField('Service','string');
$res->addField('AgentDisabled','boolean');
$res->addField('Disabled','boolean');
$res->addField('AgentRef','string');
$res->parseArray($rawData);
$res->setDatasetSize($numResults);
echo json_encode($res->export());
break;
case "getWiSPUserLogs":
$rawData = array (
array(
'ID' => 10,
'Username' => 'johnsmith',
'Status' => 1,
'Timestamp' => '10/03/2009',
'AcctSessionID' => '24234',
'AcctSessionTime' => '10:30',
'NASIPAddress' => '192.168.1.254',
'NASPortType' => '2',
'NASPort' => '3128',
'CalledStationID' => '282282',
'CallingStationID' => '2782872',
'NASTransmitRate' => '2000',
'NASReceiveRate' => '4000',
'FramedIPAddress' => '192.168.1.30',
'AcctInputMbyte' => '1241',
'AcctOutputMbyte' => '229',
'LastAcctUpdate' => '1282893',
'ConnectTermReason' => 'Failboat'
)
);
$numResults = 1;
$res = new json_response;
$res->setID('ID');
$res->addField('ID','int');
$res->addField('Username','int');
$res->addField('Status','string');
$res->addField('Timestamp','string');
$res->addField('AcctSessionID','int');
$res->addField('AcctSessionTime','int');
$res->addField('NASIPAddress','string');
$res->addField('NASPortType','string');
$res->addField('NASPort','string');
$res->addField('CalledStationID','boolean');
$res->addField('CallingStationID','boolean');
$res->addField('NASTransmitRate','string');
$res->addField('NASReceiveRate','string');
$res->addField('FramedIPAddress','string');
$res->addField('AcctInputMbyte','string');
$res->addField('AcctOutputMbyte','string');
$res->addField('LastAcctUpdate','string');
$res->addField('ConnectTermReason','string');
$res->parseArray($rawData);
$res->setDatasetSize($numResults);
echo json_encode($res->export());
break;
}
exit;
......
<?php
include_once("include/db.php");
# Return list of users
function getAdminGroups($params) {
$db = connect_db();
$sql = "SELECT ID, Name, Priority, Disabled, Comment FROM groups";
$res = $db->query($sql);
$resultArray = array();
# loop through rows
while ($row = $res->fetchObject()) {
$item = array();
$item['ID'] = $row->id;
$item['Name'] = $row->name;
$item['Priority'] = $row->priority;
$item['Disabled'] = $row->disabled;
$item['Comment'] = $row->comment;
# push this row onto array
array_push($resultArray,$item);
}
# get number of rows
$sql = "SELECT count(*) FROM groups";
$res = $db->query($sql);
$numResults = $res->fetchColumn();
return array($numResults,$resultArray);
}
?>
<?php
include_once("include/db.php");
# Return list of users
function getAdminLocations($params) {
$db = connect_db();
$sql = "SELECT ID, Name FROM wisp_locations";
$res = $db->query($sql);
$resultArray = array();
# loop through rows
while ($row = $res->fetchObject()) {
$item = array();
$item['ID'] = $row->id;
$item['Name'] = $row->name;
# push this row onto array
array_push($resultArray,$item);
}
# get number of rows
$sql = "SELECT count(*) FROM wisp_locations";
$res = $db->query($sql);
$numResults = $res->fetchColumn();
return array($numResults,$resultArray);
}
?>
<?php
include_once("include/db.php");
# Return list of users
function getAdminRealms($params) {
$db = connect_db();
$sql = "SELECT ID, Name, Disabled FROM realms";
$res = $db->query($sql);
$resultArray = array();
# loop through rows
while ($row = $res->fetchObject()) {
$item = array();
$item['ID'] = $row->id;
$item['Name'] = $row->name;
$item['Disabled'] = $row->disabled;
# push this row onto array
array_push($resultArray,$item);
}
# get number of rows
$sql = "SELECT count(*) FROM realms";
$res = $db->query($sql);
$numResults = $res->fetchColumn();
return array($numResults,$resultArray);
}
?>
<?php
include_once("include/db.php");
# Return list of users
function getAdminUsers($params) {
$db = connect_db();
$sql = "SELECT ID, Username, Disabled FROM users";
$res = $db->query($sql);
$resultArray = array();
# loop through rows
while ($row = $res->fetchObject()) {
$item = array();
$item['ID'] = $row->id;
$item['Username'] = $row->username;
$item['Disabled'] = $row->disabled;
# push this row onto array
array_push($resultArray,$item);
}
# get number of rows
$sql = "SELECT count(*) FROM users";
$res = $db->query($sql);
$numResults = $res->fetchColumn();
return array($numResults,$resultArray);
}
?>
<?php
# Web Admin UI Config
# Copyright (C) 2007-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.
# 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_PASS="";
$DB_TABLE_PREFIX="";
#
# THE BELOW SECTION IS UNSUPPORTED AND MEANT FOR THE ORIGINAL SPONSOR OF V2
#
#$DB_POSTFIX_DSN="mysql:host=localhost;dbname=postfix";
#$DB_POSTFIX_USER="root";
#$DB_POSTFIX_PASS="";
?>
<?php
# Database Interface
# Copyright (C) 2007-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.
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 SMRadius DB: " . $e->getMessage());
}
return $dbh;
}
# Connect to postfix DB
function connect_postfix_db()
{
global $DB_POSTFIX_DSN;
global $DB_POSTFIX_USER;
global $DB_POSTFIX_PASS;
try {
$dbh = new PDO($DB_POSTFIX_DSN, $DB_POSTFIX_USER, $DB_POSTFIX_PASS, array(
PDO::ATTR_PERSISTENT => false
));
$dbh->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
} catch (PDOException $e) {
die("Error connecting to Postfix DB: " . $e->getMessage());
}
return $dbh;
}
# vim: ts=4
?>
<?php
# Radius term code mappings
# Copyright (C) 2007-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.
# Return string for radius term code
function strRadiusTermCode($errCode) {
if (is_numeric($errCode)) {
switch ($errCode) {
case 0:
return "Still logged in";
case 45: # Unknown
case 46: # Unknown
case 63: # Unknown
case 1:
return "User request";
case 2:
case 816: # TCP connection reset? unknown
return "Carrier loss";
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";
default:
return "Unkown";
}
} else {
return "Unknown";
}
}
?>
......@@ -73,6 +73,10 @@
<script type="text/javascript" src="js/app/windows/WiSPUsers.js"></script>
<script type="text/javascript" src="js/app/windows/WiSPUserLogs.js"></script>
<script type="text/javascript" src="js/app/windows/WiSPUserTopups.js"></script>
<script type="text/javascript" src="js/app/windows/WiSPLocations.js"></script>
<script type="text/javascript" src="js/app/windows/AdminUsers.js"></script>
<script type="text/javascript" src="js/app/windows/AdminGroups.js"></script>
<script type="text/javascript" src="js/app/windows/AdminRealms.js"></script>
<script type="text/javascript">document.getElementById('loading-msg').innerHTML = 'Layout...';</script>
<script type="text/javascript" src="js/app/main-layout.js"></script>
......
......@@ -4,18 +4,21 @@ var radiusMenu = new Ext.menu.Menu({
{
text: 'Users',
handler: function() {
showAdminUserWindow();
}
},
{
text: 'Groups',
handler: function() {
showAdminGroupWindow();
}
},
{
text: 'Realms',
handler: function() {
showAdminRealmWindow();
}
}
......@@ -43,6 +46,7 @@ var wispMenu = new Ext.menu.Menu({
{
text: 'Locations',
handler: function() {
showWiSPLocationWindow();
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment