#!/usr/bin/perl ######################################### # login # no input: print form # input: set cookie, send along to index ######################################### if (-e "/var/www/vhosts/carbonpictures.com/bucky/lock") { print "Content-type: text/html\nPragma: no-cache\n\n"; print "

" . $BUCKY_CONFIG->{BUCKY_NAME} . " is down for maintenance!

please check back in a bit.

"; exit(0); } #if (! exists $ENV{'HTTPS'} || $ENV{'HTTPS'} ne "on") # { # print "Location: https://www.carbonpictures.com/cgi-bin/bucky/index\n\n"; # exit; # } use localbucky; $dbh = DBI->connect ($dsn); # Check to see if user has supplied a username for login if (exists($input->{username})) { if ($DEBUG) { header("login"); } # Look up user, based on username and password my ($USER) = auth( $input->{username}, crypt($input->{password}, lc($input->{username}) ) ); # No such user, or password failed, so redirect to logout if ($USER == -1) { print "password failed
\n" if $DEBUG; logout(); } # User successfully logged in! Update the last login time update_lastsession( $USER->{username} ); $USER->{lastsession} = $USER->{lastseen}; if ($DEBUG) { print "
\n"; print "uid: $USER->{id}\n

username: $USER->{username}\n

\n"; print "

\n"; footer(); } nice_redirect(); } # Else, if there's an i=1 query string, redirect to adduser program elsif (exists($input->{i}) && $input->{i} == 1) { redirect("$BUCKY/adduser?i=1"); } # Else, no username, so just display the login page else { header("login"); print qq{



}; # Display any login errors if ($input->{error} == 1) { print "bad username/password!
"; } elsif ($input->{error} == 2) { print "illegal traversal!
"; } print "$BUCKY_LOGIN_WELCOME"; print qq{
\n
\n\n}; login_form(); print qq(

\n\n); # print qq(tour the hacklab); # print qq(

want an account?
request one
); print qq(

\n\n); footer(); } $dbh->disconnect (); print "Login: " . &report_time() . "\n" if $timer; #########################################