#!/usr/bin/perl use strict; no strict 'vars'; use CGI qw(:standard); use CGI::Session::DB_File; use Crypt::PasswdMD5; use DBI; $| = 1; require "/var/www/cgi-bin/lunchforum/includes/errors.pl"; require "/var/www/cgi-bin/lunchforum/includes/login.pl"; require "/var/www/cgi-bin/lunchforum/includes/main_forum.pl"; require "/var/www/cgi-bin/lunchforum/includes/newaccount.pl"; $title = "Digex Lunch Forum"; $dbpath = "/var/www/cgi-bin/nobody/lunchforum"; $database = "dlforum"; $server = "localhost"; $dbuser = "dlfuser"; $dbpasswd = "m1ck3yd335"; $cgi = CGI->new; $sid = $cgi=>cookie('hungry') || undef; $session = new CGI::Session::DB_File($sid, {Filename=>"$dbpath/lunchforum.db", LockDirectory=>"$dbpath/"}); $sid ||=$session->id; $cookie = $cgi->cookie(-name=>'hungry', -value=>$sid, -expires=>'+30m'); $dbh = DBI->connect("DBI:mysql:$database:$server","$dbuser","$dbpasswd"); if (param('newaccount')) { &newaccount_form } elsif (param('newlogin')) { $username = &login('newuser'); &newaccount($username); } elsif (param('oldlogin')) { $username = &login; &main_handler($username) } elsif (!(param('logged'))) { &login_form } else { $username = ($session->param('username') || "duh"); &main_handler($username) } $dbh->disconnect; sub main_handler { $username = shift; &page_navbar($username); &page_header($username); &page_body($username); } sub print_header { print $cgi->header( -type=>'text/html', -cookie=>$cookie, -start_html=>$title) } #### sub login_form { &print_header; print "
", $cgi->start_form, $cgi->h1($title), $sid,br, "Welcome to the Digex Lunch Forum.",br, "Please login below or check \"New Account\"",br, "to sign up for our group and receive your premier benefits.",br,br, "
Username ", $cgi->textfield('username'),"
Password ", $cgi->password_field('secret'),"
",br, $cgi->checkbox_group(-name=>'newaccount', -value=>'New Account'),br,br, $cgi->submit(-name=>'oldlogin', -value=>'Next'), " ", $cgi->defaults('Clear'),"
", $cgi->end_form, $cgi->end_html; }