Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
include_once("include/db.php");
# Return list of wisp users
function getWiSPUsers($params) {
global $db;
# Filters and sorts are the same here
$filtersorts = array(
'Username' => 'users.Username',
'Disabled' => 'users.Disabled',
'ID' => 'wisp_userdata.UserID',
'Firstname' => 'wisp_userdata.Firstname',
'Lastname' => 'wisp_userdata.Lastname',
'Email' => 'wisp_userdata.Email',
'Phone' => 'wisp_userdata.Phone'
);
$res = DBSelectSearch("
SELECT
users.Username,
users.Disabled,
wisp_userdata.UserID,
wisp_userdata.FirstName,
wisp_userdata.LastName,
wisp_userdata.Email,
wisp_userdata.Phone
FROM
users, wisp_userdata
WHERE
wisp_userdata.UserID = users.ID
",$params[1],$filtersorts,$filtersorts
);
$sth = $res[0]; $numResults = $res[1];
# If STH is blank, return the error back to whoever requested the data
if (!isset($sth)) {
return $res;
}
$resultArray = array();
# loop through rows
while ($row = $sth->fetchObject()) {
$item = array();
$item['ID'] = $row->userid;
$item['Username'] = $row->username;
$item['Disabled'] = $row->disabled;
$item['Firstname'] = $row->firstname;
$item['Lastname'] = $row->lastname;
$item['Email'] = $row->email;
$item['Phone'] = $row->phone;
# push this row onto array
array_push($resultArray,$item);
}
return array($resultArray,$numResults);
}
# Return specific wisp user row
function getWiSPUser($params) {
global $db;
$res = DBSelect("
SELECT
wisp_userdata.UserID,
wisp_userdata.FirstName,
wisp_userdata.LastName,
wisp_userdata.Phone,
wisp_userdata.Email,
users.Username
FROM
wisp_userdata, users
WHERE
wisp_userdata.UserID = ?
AND
users.ID = wisp_userdata.UserID
",array($params[0])
);
if (!is_object($res)) {
return $res;
}
$resultArray = array();
$row = $res->fetchObject();
$resultArray['Username'] = $row->username;
$resultArray['Firstname'] = $row->firstname;
$resultArray['Lastname'] = $row->lastname;
$resultArray['Phone'] = $row->phone;
$resultArray['Email'] = $row->email;
$res = DBSelect("
SELECT
user_attributes.Name,
user_attributes.Value
FROM
user_attributes
WHERE
user_attributes.UserID = ?
",array($params[0])
);
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
if (!is_object($res)) {
return $res;
}
while ($row = $res->fetchObject()) {
switch ($row->name) {
case "User-Password":
$resultArray['Password'] = $row->value;
break;
case "MACAddress":
$resultArray['MACAddress'] = $row->value;
break;
case "SMRadius-Capping-Traffic-Limit":
$resultArray['Datalimit'] = $row->value;
break;
case "SMRadius-Capping-Uptime-Limit":
$resultArray['Uptimelimit'] = $row->value;
break;
case "Framed-IP-Address":
$resultArray['IPAddress'] = $row->value;
break;
}
}
foreach ( array('Password','MACAddress','Datalimit','Uptimelimit','IPAddress') as $key) {
if (!isset($resultArray[$key])) {
$resultArray[$key] = '';
}
}
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
return $resultArray;
}
# Remove wisp user
function removeWiSPUser($params) {
global $db;
DBBegin();
$res = DBDo("DELETE FROM wisp_userdata WHERE UserID = ?",array($params[0]));
if ($res !== FALSE) {
$res = DBDo("DELETE FROM users WHERE ID = ?",array($params[0]));
} else {
DBRollback();
return $res;
}
if ($res !== FALSE) {
DBCommit();
return $res;
} else {
DBRollback();
}
return NULL;
}
# Add wisp user
function createWiSPUser($params) {
global $db;
DBBegin();
$res = DBDo("INSERT INTO users (Username) VALUES (?)",array($params[0]['Username']));
if ($res !== FALSE) {
$userID = DBLastInsertID();
$res = DBDo("INSERT INTO wisp_userdata (UserID) VALUES (?)",array($userID));
}
if ($res !== FALSE) {
DBCommit();
return $res;
} else {
DBRollback();
}
# if (!is_numeric($res)) {
# return $res;
# }
return NULL;
}
# Edit admin group
function updateWiSPUser($params) {
global $db;
$res = DBDo("UPDATE users SET Username = ? WHERE ID = ?",array($params[0]['Username'],$params[0]['ID']));
if (!is_numeric($res)) {
return $res;
}
return NULL;
}
?>