Perl script modification needed for multiple users to the site

Afternoon all,


I am in need of modification to the following script and page so that I can have multiple users with username and passwords all being directed to different home page on my site.

The script I am using has this code :



#!c:/Perl/bin/perl.exe
require ("cgi-lib.pl");
&ReadParse(*form);
$user = $form{'user'};
$pass = $form{'pass'};

####################################################################
#Start here to edit the 5 variables that may need to be changed    #
####################################################################

# Edit Variable #1 of 5
#Set #!/usr/bin/perl at the top line 1 to point to your Perl interpretor
#Usually #!/usr/bin/perl or #!/usr/local/bin/perl

# Edit Variable #2 of 5
#Replace "california" on next line with your own username  
$myusername = "s";

# Edit Variable #3 of 5
#Replace "raisins" on next line with your own password  
$mypassword = "m";

# Edit Variable #4 of 5
#Replace "granted.txt" on next line with your own file to be displayed when user/pass is correct
$protectedfile = "granted.txt";

# Edit Variable #5 of 5
#Replace "denied.txt" on next line with your own file to be displayed when user/pass is incorrect      
$accessdeniedfile = "denied.txt";

#That's it for this file Install Step #2. Now go to Install Step #3 on the readme.txt file.




















####################################################################
#End of variable selection DO NOT edit below this line             #
####################################################################
print "Content-type: text/html\n\n";
if ($mypassword eq $pass && $myusername eq $user)
{
open (granted, "$protectedfile");
@granted=<granted>;
print "@granted";
close (granted);
}
else
{
open (denied, "$accessdeniedfile");
@denied=<denied>;
print "@denied";
close (denied);
}
####################################################################
#This script created by Steve Baker (www.supernovacomputers.com) July 07, 2000#
####################################################################



Which is directed to this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>
Access Granted
</title>
<meta http-equiv="refresh" CONTENT="5;URL=http://123.456.678.90/S/new/index.htm">
</head>
<body>
Connecting....
<br>
</body>
</html>


Which is then directed to the private home page of my site.



What I want to do though, is to have another site linked from that password protected main page going to other 'home' pages.

Please ask for clarification if you don't understand.

Summary:


Login >>>> Connecting page >>>> Home Page


I want to add different login users so they go to different static Home Page files. Please advise how to change either the Login script page or the Connecting page HTML.



Many thanks.




Leon
Leon5178Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TintinCommented:
So you want each user to go to their own individual home page?
Do you have to do it via a redirect?  Could you not just use web server user authentication for each user?

BTW, the script above is very poorly written.  
0
Leon5178Author Commented:
Tintin,


To be honest with you, I am not a Perl developer so I do not know how good that script is. It just seems to do the job and I am looking to create parallel sites for various members of my family.

I could use web server authentication but I am using the Apache Web server that comes with Oracle Application Server so I have little scope for flexibility.

I don't have to do a redirect but this was a free script that seemed to do the job so I kept it. I am open to suggestions as long as it doesn't take too much effort to implement.

Let me know what your thoughts are on this.



Leon



0
ozoCommented:
A trivial generalization of the above script could be:


use strict;
use warnings;
use CGI;

my $q=new CGI;
my %form = $q->Vars;
my $user = $form{'user'};
my $pass = $form{'pass'};

my %users=(
's'     => ['m','granted.txt'],
'user2' => ['password2','granted2.txt'],
'user3' => ['password3','granted3.txt'],
);
my $accessdeniedfile = 'denied.txt';

####################################################################
print "Content-type: text/html\n\n";
if( $users{$user} && $users{$user}->[0] eq $pass ){
    open GRANTED, "<$users{$user}->[1]" or die "can't open GRANTED $!";
    print <GRANTED>;
    close GRANTED;
}else{
    open DENIED, "<$accessdeniedfile" or die "can't open DENIED $!";
    print <DENIED>;
    close DENIED;
}



Although it still does nothing to prevent an intruder from directly accessing http://123.456.678.90/S/new/index.htm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.