Description:
This is a completely insecure way to setup new user accounts within a box for testing purposes
Box Code:
There are three portions of code for this to work.
A box "add_user", a box "fn_add_user", and an op "adduser".
If you don't want to implement this as a box you can just copy
this <FORM> of the "add_user" box to a special page.
***Box add_user:***
return '' unless ($S->have_perm('edit_user'));
my $content = qq{
<FORM NAME="uedit" METHOD="GET" ACTION="%%rootdir%%/">
<SMALL>Nick:
<INPUT TYPE="hidden" NAME="op" VALUE="adduser">
<INPUT TYPE="text" NAME="nick" VALUE="" SIZE=10><BR>
Pass: <INPUT TYPE="password" NAME="passwd" VALUE="" SIZE=10>
Confirm: <INPUT TYPE="password" NAME="cpasswd" VALUE="" SIZE=10>
<INPUT TYPE="SUBMIT" NAME="tool" VALUE="Add User">
</SMALL></FORM>};
return $content;
***Op Setup:***
op: adduser
template: -----
function: fn_add_user
Function is a box: yes
Permission: edit_user
Enabled: yes
***Box fn_add_user:***
return "Passwords do not match" if ( $S->{CGI}->param('passwd') ne $S->{CGI}->param('cpasswd'));
my $default_group = $S->_get_default_group('');
my $c_pass = $S->crypt_pass($S->{CGI}->param('passwd'));
my $f_nick = $S->dbh->quote($S->{CGI}->param('nick'));
my ($rv, $sth) = $S->db_lock_tables({
users => 'WRITE'});
$sth->finish;
($rv, $sth) = $S->db_select({
WHAT => 'uid',
FROM => 'users',
ORDER_BY => 'uid desc',
LIMIT => '1'});
my $ret = $sth->fetchrow();
$sth->finish;
my $uid = ($ret + 1);
if ($rv == 1) {
my ($rv, $sth) = $S->db_insert({
INTO => 'users',
COLS => 'uid, nickname, passwd, perm_group, creation_time',
VALUES => "$uid, $f_nick, '$c_pass', '$default_group', NOW()"});
$sth->finish;
}
$S->db_unlock_tables();
return "User $f_nick created with uid $uid";
|