|
-
Oct 17th, 2001, 08:04 PM
#1
Thread Starter
Hyperactive Member
Simple Password Access in CGI
Can anyone tell me how it's done? I'm completely new to CGI so a long spiel would be most helpful
-
Oct 17th, 2001, 08:16 PM
#2
PowerPoster
what are you talking about?
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Oct 17th, 2001, 08:21 PM
#3
Thread Starter
Hyperactive Member
Someone goes to a site, the first thing they see is a password access screen. They type in a password and if it's correct they are redirected to another page.
Sorry about that, I tend to be too vague in my descriptions...
Last edited by Zaphod64831; Oct 17th, 2001 at 08:34 PM.
-
Oct 17th, 2001, 08:37 PM
#4
Code:
#!/usr/bin/perl
print "Content-type: text/html\n\n\n";
require("inc.cgi");
open(FILE, ">>$tfname");
sub GetFormInput {
(*fval) = @_ if @_ ;
local ($buf);
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN,$buf,$ENV{'CONTENT_LENGTH'});
}
else {
$buf=$ENV{'QUERY_STRING'};
}
if ($buf eq "") {
return 0 ;
}
else {
@fval=split(/&/,$buf);
$i = 0;
foreach $i (0 .. $#fval){
($name,$val)=split (/=/,$fval[$i],2);
$val=~tr/+/ /;
$val=~ s/%(..)/pack("c",hex($1))/ge;
$name=~tr/+/ /;
$name=~ s/%(..)/pack("c",hex($1))/ge;
if (!defined($field{$name})) {
$field{$name}=$val;
}
else {
$field{$name} .= ",$val";
#if you want multi-selects to goto into an array change to:
#$field{$name} .= "\0$val";
}
if($i eq 0) {
print FILE "\"$val\"";
} else {
print FILE ",\"$val\"";
}
}
print FILE "\n";
}
close(FILE);
return 1;
}
&GetFormInput;
if($field{"pass"} eq "mypass" && $field{"user"} eq "username"){
print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=urltoredirectto\">";
} else {
print "Wrong username or password";
}
I haven't tried this yet, but it should work.
-Dennis
-
Oct 17th, 2001, 08:50 PM
#5
Thread Starter
Hyperactive Member
Thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you
-
Oct 19th, 2001, 05:05 PM
#6
Thread Starter
Hyperactive Member
-
Oct 20th, 2001, 11:28 PM
#7
Code:
#!/usr/bin/perl
print "Content-type: text/html\n\n\n";
sub GetFormInput {
(*fval) = @_ if @_ ;
local ($buf);
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN,$buf,$ENV{'CONTENT_LENGTH'});
}
else {
$buf=$ENV{'QUERY_STRING'};
}
if ($buf eq "") {
return 0 ;
}
else {
@fval=split(/&/,$buf);
foreach $i (0 .. $#fval){
($name,$val)=split (/=/,$fval[$i],2);
$val=~tr/+/ /;
$val=~ s/%(..)/pack("c",hex($1))/ge;
$name=~tr/+/ /;
$name=~ s/%(..)/pack("c",hex($1))/ge;
if (!defined($field{$name})) {
$field{$name}=$val;
}
else {
$field{$name} .= ",$val";
#if you want multi-selects to goto into an array change to:
#$field{$name} .= "\0$val";
}
}
}
return 1;
}
&GetFormInput;
if($field{"pass"} eq "mypass" && $field{"user"} eq "username"){
print "<META HTTP-EQUIV=\"refresh\" CONTENT=0; URL=http://www.olemac.net\">";
} else {
print "Wrong username or password";
}
try that.
-
Oct 22nd, 2001, 08:35 PM
#8
Thread Starter
Hyperactive Member
-
Oct 22nd, 2001, 08:37 PM
#9
Thread Starter
Hyperactive Member
BTW I finally saw blazing saddles yesterday on comedy central, that scene was hilarious
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|