2007-10-11 23:47:13 +00:00
|
|
|
require "functions.pl";
|
2007-10-10 21:48:12 +00:00
|
|
|
|
|
|
|
#initialize session data
|
|
|
|
CGI::Session->name($session_name);
|
|
|
|
$query = new CGI;
|
|
|
|
$session = new CGI::Session;
|
|
|
|
|
2007-10-29 15:00:40 +00:00
|
|
|
@userinfo = get_userinfo_from_sid($session->id);
|
2007-10-27 09:17:30 +00:00
|
|
|
|
2007-10-29 15:00:40 +00:00
|
|
|
@page = get_page_array(@userinfo);
|
2007-10-27 09:17:30 +00:00
|
|
|
|
|
|
|
#check if user is logged in
|
|
|
|
if($username)
|
|
|
|
{
|
2008-02-14 22:15:38 +00:00
|
|
|
$page->{'message'}->{'type'} = "error";
|
|
|
|
$page->{'message'}->{'text'} = "error_already_registered";
|
|
|
|
|
|
|
|
print output_page();
|
2007-10-27 09:17:30 +00:00
|
|
|
}
|
2007-10-10 21:48:12 +00:00
|
|
|
#if username and password are passed put them into the database
|
2007-10-29 08:48:51 +00:00
|
|
|
elsif($query->param('user') and $query->param('pass') and $query->param('pass_repeat'))
|
2007-10-11 17:26:39 +00:00
|
|
|
{
|
2008-02-14 22:15:38 +00:00
|
|
|
if($query->param('pass') eq $query->param('pass_repeat'))
|
|
|
|
{
|
|
|
|
my $sth = $dbh->prepare(qq{select id from users where username = ? limit 1 });
|
|
|
|
|
|
|
|
#execute query
|
|
|
|
$sth->execute($query->param('user'));
|
|
|
|
|
|
|
|
#if something was returned the selected username already exists
|
|
|
|
if($sth->fetchrow_array())
|
|
|
|
{
|
|
|
|
$page->{'registerform'} = [''];
|
|
|
|
$page->{'message'}->{'type'} = "error";
|
|
|
|
$page->{'message'}->{'text'} = "error_username_already_registered";
|
|
|
|
|
|
|
|
print output_page();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#insert new user
|
|
|
|
$dbh->do(qq{insert into users (username, password, timestamp, locale) values ( ?, password( ? ), unix_timestamp(), ?)}, undef,
|
|
|
|
$query->param("user"), $query->param("pass"), $page->{'locale'}) or die $dbh->errstr;
|
|
|
|
|
|
|
|
print $query->redirect("index.pl?information=information_registered");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$page->{'registerform'} = [''];
|
|
|
|
$page->{'message'}->{'type'} = "error";
|
|
|
|
$page->{'message'}->{'text'} = "error_passwords_do_not_match";
|
|
|
|
|
|
|
|
print output_page();
|
|
|
|
}
|
2007-10-29 08:48:51 +00:00
|
|
|
}
|
2007-10-29 15:00:40 +00:00
|
|
|
elsif(not $query->param('user') and ($query->param('pass') or $query->param('pass_repeat')))
|
2007-10-29 08:48:51 +00:00
|
|
|
{
|
2008-02-14 22:15:38 +00:00
|
|
|
$page->{'registerform'} = [''];
|
|
|
|
$page->{'message'}->{'type'} = "error";
|
|
|
|
$page->{'message'}->{'text'} = "error_insert_username";
|
|
|
|
|
|
|
|
print output_page();
|
2007-10-29 08:48:51 +00:00
|
|
|
}
|
2007-10-29 15:00:40 +00:00
|
|
|
elsif(not $query->param('pass') and ($query->param('user') or $query->param('pass_repeat')))
|
2007-10-29 08:48:51 +00:00
|
|
|
{
|
2008-02-14 22:15:38 +00:00
|
|
|
$page->{'registerform'} = [''];
|
|
|
|
$page->{'message'}->{'type'} = "error";
|
|
|
|
$page->{'message'}->{'text'} = "error_insert_password";
|
|
|
|
|
|
|
|
print output_page();
|
2007-10-29 08:48:51 +00:00
|
|
|
}
|
2007-10-29 15:00:40 +00:00
|
|
|
elsif(not $query->param('pass_repeat') and ($query->param('user') or $query->param('pass')))
|
2007-10-29 08:48:51 +00:00
|
|
|
{
|
2008-02-14 22:15:38 +00:00
|
|
|
$page->{'registerform'} = [''];
|
|
|
|
$page->{'message'}->{'type'} = "error";
|
|
|
|
$page->{'message'}->{'text'} = "error_repeat_password";
|
|
|
|
|
|
|
|
print output_page();
|
2007-10-11 17:26:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-02-14 22:15:38 +00:00
|
|
|
$page->{'registerform'} = [''];
|
|
|
|
|
|
|
|
print output_page();
|
2007-11-02 12:12:44 +00:00
|
|
|
}
|