scorpion975
IS-IT--Management
How can i modify this script so that each time a user logs in it will display a diff, page it is set up now, to view main.txt after logging in, all members are stored in members.txt folder.
Any thoughts:
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
require "cookie.lib";
&GetCookies('Custom-CGI_pass','Custom-CGI_id');
# check to see if cookies are present
if ($Cookies{'Custom-CGI_pass'} eq "" || $Cookies{'Custom-CGI_id'} eq "") {
print "Location: login.cgi\n\n";
exit;
}
&get_input;
# this is the menu
if ($in{'action'} eq "") {
&mainpage;
exit;
}
if ($in{'action'} eq "logout") {
&loggout;
}
else {
&mainpage;
exit;
}
##############
# End Menu selection!
##############
# if everything is a ok, then print logged in page
sub mainpage {
open (FILE,"main.txt");
$mainpage = '';
while (<FILE>)
{
$mainpage .= $_;
}
close (FILE);
print "Content-type: text/html\n\n";
print "<!-- Thank you for signing up for Course. -->\n";
print "<!-- We hope you come back and take more courses online. -->\n";
print $mainpage;
}
####### this is the log out section
sub loggout {
# this is a simple operation, to delete cookies (ie. loggout member)
# all you hav to do is set the cookies to a bull ("") value.
&SetCookies('Custom-CGI_id',"");
&SetCookies('Custom-CGI_pass',"");
&get_template;
print "Content-type: text/html\n\n";
print $header;
print "<body bgcolor=\"#E2DEB8\">\n";
print "<h1>Logged Out</h1>\n";
print "You have been successfully logged out, you can log back in by clicking \n";
print "<a href=\"login.cgi\">here</a>.\n";
print $footer;
exit;
}
Any thoughts:
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
require "cookie.lib";
&GetCookies('Custom-CGI_pass','Custom-CGI_id');
# check to see if cookies are present
if ($Cookies{'Custom-CGI_pass'} eq "" || $Cookies{'Custom-CGI_id'} eq "") {
print "Location: login.cgi\n\n";
exit;
}
&get_input;
# this is the menu
if ($in{'action'} eq "") {
&mainpage;
exit;
}
if ($in{'action'} eq "logout") {
&loggout;
}
else {
&mainpage;
exit;
}
##############
# End Menu selection!
##############
# if everything is a ok, then print logged in page
sub mainpage {
open (FILE,"main.txt");
$mainpage = '';
while (<FILE>)
{
$mainpage .= $_;
}
close (FILE);
print "Content-type: text/html\n\n";
print "<!-- Thank you for signing up for Course. -->\n";
print "<!-- We hope you come back and take more courses online. -->\n";
print $mainpage;
}
####### this is the log out section
sub loggout {
# this is a simple operation, to delete cookies (ie. loggout member)
# all you hav to do is set the cookies to a bull ("") value.
&SetCookies('Custom-CGI_id',"");
&SetCookies('Custom-CGI_pass',"");
&get_template;
print "Content-type: text/html\n\n";
print $header;
print "<body bgcolor=\"#E2DEB8\">\n";
print "<h1>Logged Out</h1>\n";
print "You have been successfully logged out, you can log back in by clicking \n";
print "<a href=\"login.cgi\">here</a>.\n";
print $footer;
exit;
}