fixed registration process
git-svn-id: http://yolanda.mister-muffin.de/svn@152 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
parent
17b97802d8
commit
c802351bb9
3 changed files with 59 additions and 14 deletions
|
@ -7,6 +7,8 @@ my $session = new CGI::Session;
|
|||
|
||||
my $dbh = DBI->connect("DBI:mysql:$database:$host", $dbuser, $dbpass) or die $dbh->errstr;
|
||||
|
||||
$dbh->do(qq{drop table config});
|
||||
|
||||
$dbh->do(qq{drop table users});
|
||||
|
||||
$dbh->do(qq{drop table videos});
|
||||
|
@ -34,6 +36,15 @@ $dbh->do(qq{insert into
|
|||
)
|
||||
}) or die $dbh->errstr;
|
||||
|
||||
$dbh->do(qq{create table
|
||||
config
|
||||
(
|
||||
key varchar(255) not null,
|
||||
value varchar(255) not null,
|
||||
primary key (key)
|
||||
)
|
||||
}) or die $dbh->errstr;
|
||||
|
||||
$dbh->do(qq{create table
|
||||
users
|
||||
(
|
||||
|
@ -41,6 +52,10 @@ $dbh->do(qq{create table
|
|||
username varchar(255) not null,
|
||||
password char(41) not null,
|
||||
sid char(32) not null,
|
||||
timestamp bigint not null,
|
||||
locale varchar(10) not null,
|
||||
pagesize unsigned tinyint default 5,
|
||||
cortado tinyint default 1,
|
||||
primary key (id)
|
||||
)
|
||||
}) or die $dbh->errstr;
|
||||
|
|
|
@ -48,8 +48,10 @@
|
|||
<str id="error_already_registered">You seem to be already registered. Please log out to create a new account.</str>
|
||||
<str id="error_already_logged_in">You seem to be already logged in. Please log out to log in again.</str>
|
||||
<str id="error_username_password_do_not_match">Username and password do not match.</str>
|
||||
<str id=""></str>
|
||||
<str id=""></str>
|
||||
<str id="error_passwords_do_not_match">Passwords do not match.</str>
|
||||
<str id="error_insert_username">Please insert a username.</str>
|
||||
<str id="error_insert_password">Please insert a password.</str>
|
||||
<str id="error_repeat_password">Please repeat your password.</str>
|
||||
<str id=""></str>
|
||||
|
||||
<!-- information -->
|
||||
|
@ -83,6 +85,7 @@
|
|||
<!-- login / register page -->
|
||||
<str id="username">username</str>
|
||||
<str id="password">password</str>
|
||||
<str id="password_repeat">repeat password</str>
|
||||
<str id="button_register">register</str>
|
||||
<str id="button_login">login</str>
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ $username = get_username_from_sid($session->id);
|
|||
%page = ();
|
||||
|
||||
$page->{'username'} = $username;
|
||||
$page->{'locale'} = $locale;
|
||||
($page->{'locale'}) = $query->http('HTTP_ACCEPT_LANGUAGE') =~ /^([^,]+),.*$/;
|
||||
$page->{'stylesheet'} = $stylesheet;
|
||||
$page->{'xmlns:dc'} = $xmlns_dc;
|
||||
$page->{'xmlns:cc'} = $xmlns_cc;
|
||||
|
@ -25,14 +25,16 @@ if($username)
|
|||
$page->{'message'}->{'text'} = "error_already_registered";
|
||||
}
|
||||
#if username and password are passed put them into the database
|
||||
elsif($query->param('user') and $query->param('pass'))
|
||||
elsif($query->param('user') and $query->param('pass') and $query->param('pass_repeat'))
|
||||
{
|
||||
if($query->param('pass') eq $query->param('pass_repeat'))
|
||||
{
|
||||
#connect to db
|
||||
my $dbh = DBI->connect("DBI:mysql:$database:$host", $dbuser, $dbpass) or die $dbh->errstr;
|
||||
|
||||
#do query
|
||||
$dbh->de(qq{insert into users (username, password) values ( ?, password( ? ))}, undef,
|
||||
$query->param("user"), $query->param("pass")) or die $dbh->errstr;
|
||||
$dbh->de(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;
|
||||
|
||||
#disconnect db
|
||||
$dbh->disconnect() or die $dbh->errstr;
|
||||
|
@ -40,6 +42,31 @@ elsif($query->param('user') and $query->param('pass'))
|
|||
#print a little confirmation
|
||||
$page->{'message'}->{'type'} = "information";
|
||||
$page->{'message'}->{'text'} = "information_registered";
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->{'registerform'} = [''];
|
||||
$page->{'message'}->{'type'} = "error";
|
||||
$page->{'message'}->{'text'} = "error_passwords_do_not_match";
|
||||
}
|
||||
}
|
||||
elsif(not $query->param('user'))
|
||||
{
|
||||
$page->{'registerform'} = [''];
|
||||
$page->{'message'}->{'type'} = "error";
|
||||
$page->{'message'}->{'text'} = "error_insert_username";
|
||||
}
|
||||
elsif(not $query->param('pass'))
|
||||
{
|
||||
$page->{'registerform'} = [''];
|
||||
$page->{'message'}->{'type'} = "error";
|
||||
$page->{'message'}->{'text'} = "error_insert_password";
|
||||
}
|
||||
elsif(not $query->param('pass_repeat'))
|
||||
{
|
||||
$page->{'registerform'} = [''];
|
||||
$page->{'message'}->{'type'} = "error";
|
||||
$page->{'message'}->{'text'} = "error_repeat_password";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue