Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
smradius
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
shail
smradius
Commits
fb95d85d
Commit
fb95d85d
authored
15 years ago
by
Robert Anderson
Browse files
Options
Downloads
Patches
Plain Diff
Better error handling
Adding users still needs work
parent
bd1ecd07
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
webui/wisp-multiuser-add.php
+69
-38
69 additions, 38 deletions
webui/wisp-multiuser-add.php
with
69 additions
and
38 deletions
webui/wisp-multiuser-add.php
+
69
−
38
View file @
fb95d85d
...
...
@@ -82,20 +82,19 @@ if (isset($_POST['frmaction']) && $_POST['frmaction'] == "insert") {
if
(
!
empty
(
$_POST
[
'num_users'
])
&&
!
empty
(
$_POST
[
'session_timeout'
])
&&
!
empty
(
$_POST
[
'data_limit'
])
&&
!
empty
(
$_POST
[
'time_limit'
]))
{
$db
->
beginTransaction
();
$numberOfUsers
=
(
int
)
$_POST
[
'num_users'
];
$sessionTimeout
=
(
int
)
$_POST
[
'session_timeout'
];
$dataLimit
=
(
int
)
$_POST
[
'data_limit'
];
$timeLimit
=
(
int
)
$_POST
[
'time_limit'
];
$loginNamePrefix
=
$_POST
[
'login_prefix'
];
$userList
=
array
();
# FIXME
for
(
$counter
=
0
;
$counter
<=
$numberOfUsers
;
$counter
++
)
{
# Loop and try add user, maybe its duplicate?
do
{
$isDuplicate
=
0
;
# Generate random username
$randomString
=
""
;
for
(
$i
=
0
;
$i
<
8
;
$i
++
)
{
$randomString
.
=
chr
(
rand
(
97
,
122
));
}
...
...
@@ -114,12 +113,19 @@ if (isset($_POST['frmaction']) && $_POST['frmaction'] == "insert") {
FROM
${DB_TABLE_PREFIX}users
WHERE
Username
LIKE '%
$userName
%'
Username
= "
.
$db
->
quote
(
$userName
)
.
"
"
);
$row
=
$stmt
->
fetchObject
();
}
while
(
$row
->
duplicate
>
0
);
}
while
(
$row
->
duplicate
!=
0
);
array_push
(
$userList
,
$userName
);
}
$db
->
beginTransaction
();
foreach
(
$userList
as
$userName
)
{
#Insert user into users table
$stmt
=
$db
->
prepare
(
"
...
...
@@ -146,11 +152,16 @@ if (isset($_POST['frmaction']) && $_POST['frmaction'] == "insert") {
"
);
$res
=
$stmt
->
execute
(
array
(
$userID
));
}
else
{
$res
=
0
;
if
(
$res
!==
FALSE
)
{
?>
<div
class=
"
warning"
>
Failed to retreive user ID
</div>
<div
class=
"
notice"
>
Userdata added
</div>
<?php
}
else
{
$res
=
0
;
?>
<div
class=
"warning"
>
Failed to create user
</div>
<?php
}
}
...
...
@@ -158,77 +169,97 @@ if (isset($_POST['frmaction']) && $_POST['frmaction'] == "insert") {
# Generate password
$userPassword
=
""
;
for
(
$passCount
=
0
;
$passCount
<
8
;
$passCount
++
)
{
$userPassword
.
=
chr
(
rand
(
97
,
122
));
$userPassword
.
=
chr
(
rand
(
97
,
122
));
}
# Insert password into user_attributes table
$stmt
=
$db
->
prepare
(
"
INSERT INTO
${DB_TABLE_PREFIX}user_attributes (UserID,Name,Operator,Value)
VALUES
(
$userID
,'User-Password','==',?)
INSERT INTO
${DB_TABLE_PREFIX}user_attributes (UserID,Name,Operator,Value)
VALUES
(
$userID
,'User-Password','==',?)
"
);
$res
=
$stmt
->
execute
(
array
(
$userPassword
));
}
else
{
if
(
$res
!==
FALSE
)
{
?>
<div
class=
"notice"
>
User password added
</div>
<?php
}
else
{
?>
<div
class=
"warning"
>
Failed to add user password
</div>
<div
class=
"warning"
>
<?php
print_r
(
$stmt
->
errorInfo
());
?>
</div>
<div
class=
"warning"
>
Failed to add user password
</div>
<div
class=
"warning"
>
<?php
print_r
(
$stmt
->
errorInfo
());
?>
</div>
<?php
}
}
if
(
$res
!==
FALSE
)
{
# Insert data limit into user_attributes table
$stmt
=
$db
->
prepare
(
"
INSERT INTO
${DB_TABLE_PREFIX}user_attributes (UserID,Name,Operator,Value)
VALUES
(
$userID
,'SMRadius-Capping-Traffic-Limit',':=',?)
INSERT INTO
${DB_TABLE_PREFIX}user_attributes (UserID,Name,Operator,Value)
VALUES
(
$userID
,'SMRadius-Capping-Traffic-Limit',':=',?)
"
);
$res
=
$stmt
->
execute
(
array
(
$dataLimit
));
}
else
{
if
(
$res
!==
FALSE
)
{
?>
<div
class=
"notice"
>
Data cap added
</div>
<?php
}
else
{
?>
<div
class=
"warning"
>
Failed to add data cap
</div>
<div
class=
"warning"
>
<?php
print_r
(
$stmt
->
errorInfo
());
?>
</div>
<div
class=
"warning"
>
Failed to add data cap
</div>
<div
class=
"warning"
>
<?php
print_r
(
$stmt
->
errorInfo
());
?>
</div>
<?php
}
}
if
(
$res
!==
FALSE
)
{
# Insert time limit into user_attributes table
$stmt
=
$db
->
prepare
(
"
INSERT INTO
${DB_TABLE_PREFIX}user_attributes (UserID,Name,Operator,Value)
VALUES
(
$userID
,'SMRadius-Capping-UpTime-Limit',':=',?)
INSERT INTO
${DB_TABLE_PREFIX}user_attributes (UserID,Name,Operator,Value)
VALUES
(
$userID
,'SMRadius-Capping-UpTime-Limit',':=',?)
"
);
$res
=
$stmt
->
execute
(
array
(
$timeLimit
));
}
else
{
if
(
$res
!==
FALSE
)
{
?>
<div
class=
"warning"
>
Failed to add uptime cap
</div>
<div
class=
"warning"
>
<?php
print_r
(
$stmt
->
errorInfo
());
?>
</div>
<div
class=
"notice"
>
Uptime limit added
</div>
<?php
}
else
{
?>
<div
class=
"warning"
>
Failed to add uptime limit
</div>
<div
class=
"warning"
>
<?php
print_r
(
$stmt
->
errorInfo
());
?>
</div>
<?php
}
}
if
(
$res
!==
FALSE
)
{
# Insert timeout into user_attributes table
$stmt
=
$db
->
prepare
(
"
INSERT INTO
${DB_TABLE_PREFIX}user_attributes (UserID,Name,Operator,Value)
VALUES
(
$userID
,'Session-Timeout','+=',?)
INSERT INTO
${DB_TABLE_PREFIX}user_attributes (UserID,Name,Operator,Value)
VALUES
(
$userID
,'Session-Timeout','+=',?)
"
);
$res
=
$stmt
->
execute
(
array
(
$sessionTimeout
));
}
else
{
if
(
$res
!==
FALSE
)
{
?>
<div
class=
"notice"
>
User timeout added
</div>
<?php
}
else
{
?>
<div
class=
"warning"
>
Failed to add u
ptime cap
</div>
<div
class=
"warning"
>
<?php
print_r
(
$stmt
->
errorInfo
());
?>
</div>
<div
class=
"warning"
>
Failed to add u
ser timeout
</div>
<div
class=
"warning"
>
<?php
print_r
(
$stmt
->
errorInfo
());
?>
</div>
<?php
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment