From c802351bb9cac99cd8cff55848db20e2767df353 Mon Sep 17 00:00:00 2001 From: josch Date: Mon, 29 Oct 2007 08:48:51 +0000 Subject: [PATCH] fixed registration process git-svn-id: http://yolanda.mister-muffin.de/svn@152 7eef14d0-6ed0-489d-bf55-20463b2d70db --- trunk/init_sql.pl | 15 +++++++++++++ trunk/locale/en-us.xml | 7 ++++-- trunk/register.pl | 51 ++++++++++++++++++++++++++++++++---------- 3 files changed, 59 insertions(+), 14 deletions(-) diff --git a/trunk/init_sql.pl b/trunk/init_sql.pl index 76e3047..03671d2 100644 --- a/trunk/init_sql.pl +++ b/trunk/init_sql.pl @@ -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; diff --git a/trunk/locale/en-us.xml b/trunk/locale/en-us.xml index a806752..5e08dad 100755 --- a/trunk/locale/en-us.xml +++ b/trunk/locale/en-us.xml @@ -48,8 +48,10 @@ You seem to be already registered. Please log out to create a new account. You seem to be already logged in. Please log out to log in again. Username and password do not match. - - + Passwords do not match. + Please insert a username. + Please insert a password. + Please repeat your password. @@ -83,6 +85,7 @@ username password + repeat password register login diff --git a/trunk/register.pl b/trunk/register.pl index 9ff2369..3ae7ba7 100644 --- a/trunk/register.pl +++ b/trunk/register.pl @@ -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,21 +25,48 @@ 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')) { - #connect to db - my $dbh = DBI->connect("DBI:mysql:$database:$host", $dbuser, $dbpass) or die $dbh->errstr; + 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; + #do query + $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; + #disconnect db + $dbh->disconnect() or die $dbh->errstr; - #print a little confirmation - $page->{'message'}->{'type'} = "information"; - $page->{'message'}->{'text'} = "information_registered"; + #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 {