2007-10-11 16:25:56 +00:00
|
|
|
#!/usr/bin/perl
|
2007-10-11 17:06:08 +00:00
|
|
|
require "include.pl";
|
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;
|
|
|
|
|
|
|
|
#if username and password are passed put them into the database
|
2007-10-11 17:26:39 +00:00
|
|
|
if($query->param('user') and $query->param('pass'))
|
|
|
|
{
|
2007-10-10 21:48:12 +00:00
|
|
|
#connect to db
|
2007-10-11 10:00:38 +00:00
|
|
|
my $dbh = DBI->connect("DBI:mysql:$database:$host", $dbuser, $dbpass) or die $dbh->errstr;
|
2007-10-10 21:48:12 +00:00
|
|
|
|
2007-10-11 10:00:38 +00:00
|
|
|
#do query
|
2007-10-24 11:25:18 +00:00
|
|
|
$dbh->de(qq{insert into users (username, password) values ( ?, password( ? ))}, undef,
|
|
|
|
$query->param("user"), $query->param("pass")) or die $dbh->errstr;
|
2007-10-11 10:00:38 +00:00
|
|
|
|
2007-10-10 21:48:12 +00:00
|
|
|
#disconnect db
|
2007-10-11 10:00:38 +00:00
|
|
|
$dbh->disconnect() or die $dbh->errstr;
|
2007-10-10 21:48:12 +00:00
|
|
|
|
|
|
|
#print a little confirmation
|
|
|
|
print $session->header();
|
2007-10-11 23:21:16 +00:00
|
|
|
print 'done';
|
2007-10-11 17:26:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-10 21:48:12 +00:00
|
|
|
#if not, print register form
|
2007-10-11 23:47:13 +00:00
|
|
|
|
2007-10-12 11:04:34 +00:00
|
|
|
%page = ();
|
2007-10-11 23:47:13 +00:00
|
|
|
|
|
|
|
#if a username is associated with session id, username is nonempty
|
|
|
|
$page->{username} = get_username_from_sid($session->id);
|
2007-10-12 11:04:34 +00:00
|
|
|
$page->{locale} = $locale;
|
|
|
|
$page->{stylesheet} = $stylesheet;
|
|
|
|
$page->{registerform} = [''];
|
2007-10-11 23:47:13 +00:00
|
|
|
|
|
|
|
#print xml http header along with session cookie
|
|
|
|
print $session->header(-type=>'text/xml');
|
|
|
|
|
|
|
|
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page');
|
2007-10-10 21:48:12 +00:00
|
|
|
}
|