Scoop -- the swiss army chainsaw of content management
Front Page · Everything · News · Code · Help! · Wishlist · Project · Scoop Sites · Dev Notes · Latest CVS changes · Development Activities
Scoop Box Exchange - Show Box: add_user 1.00

Author: theantix [Info]

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";
Display: Sort:
is_new_account needs to be set! (none / 0) (#1)
by wwinfrey on Sun May 08, 2005 at 11:55:22 PM PST

users created with this box will not be able to reset and mail themselves a password because the check_password method looks for a value of '0' for the is_new_account column. since it is not, when a new account is created, a value of NULL is assigned (the default) and this method will fail.



Menu
· create account
· faq
· search
· report bugs
· Scoop Administrators Guide
· Scoop Box Exchange

Scoop Site Scroller: Get one yourself!
Scoop::Ads
Almost there...

Login
Make a new account
Username:
Password:

Hosted by ScoopHost.com Powered by Scoop
All trademarks and copyrights on this page are owned by their respective companies. Comments are owned by the Poster. The Rest © 1999 The Management

create account | faq | search