##
if($usecgi){
use CGI;
$query = new CGI;
@names = $query->param;
foreach $i (@names){
$in{$i} = $query->param("$i");
}
}
else{
# Read in text
if ($ENV{'REQUEST_METHOD'} eq "GET") {
$in = $ENV{'QUERY_STRING'};
} elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
for ($i = 0; $i < $ENV{'CONTENT_LENGTH'}; $i++) {
$in .= getc;
}
}
#.... followed by more code for parsing, splitting and assigning the new variables
####
($in{'command'} eq 'login')&&(&Login);
($in{'command'} eq '')&&(&Login);
#all require password below
&GetLogin;
...
# passing thru Get login allows access to more program functions and additional pages. the login page actually calls the next page... via hidden form field
####
sub GetCookies{
$cookies = $ENV{'HTTP_COOKIE'};
@allcookies = split(/;\s*/,$cookies);
foreach $i (@allcookies){
($name,$value) = split(/\s*=\s*/,$i);
$cookie{$name}=$value;
}
}
####
sub GetLogin{
&GetCookies;
$in{'UserName'} = $cookie{'UserName'};
$in{'PassWord'} = $cookie{'PassWord'};
if(!$in{'UserName'}){
&PageOut('t_login.htm');
exit;
#back where you started, though the Javascript sees that it never comes here
}
else{
(($in{'UserName'} ne $username)||(($in{'PassWord'} ne $password)))&&(&PError("Error. Invalid username or password"));
#here we need to check the final results after parsing the cookie info and retrieving matches in the db of variables... we have no choice but to return a server error message.
}
}