A Simple Script
To use this script, you need to fill in the dirrerent html's in the array named @html.
Than to use it you would link to
yoursite.com/cgi-bin/scriptname.cgi?html=NAMEHERE . I tested it , and it worked for me.
Code Sample:
#!/usr/local/bin/perl
#
##########
#making array with all the .html's
@html=("yahoo.html","other.html","somthing.html");
$errorhtml="error.html";
$printed=0;
##########
#getting form input
&GetFormInput;
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";
}
}
}
return 1;
}
$input=$field{'html'};
$input="$input.html";
##########
#Checking to see if any of the html's in the array equal the inputed html
foreach $page(@html)
{
if($input eq $page)
{
print "Location: $page";
$printed=1;
}
} #end of foreach $page(@html)
##########
#printing the error html if nothing was found
if($printed==0)
{
print "Location: $errorhtml";
}
------------------
A 'jiffy' is an actual unit of time for 1/100th of a second.
[This message has been edited by robp (edited 15 December 1999).]
http://www.thehungersite.com - http://www.therainforestsite.com
http://www.ratemymullet.com - Beauty is only mullet deep.
japhy posted this at 05:58 — 15th December 1999.
They have: 161 posts
Joined: Dec 1999
Adhering more closely to the specs given, I offer this potential solution:
------------------
--
MIDN 4/C PINYAN, NROTCURPI, USNR
[This message has been edited by japhy (edited 15 December 1999).]
jackchen posted this at 07:31 — 15th December 1999.
They have: 472 posts
Joined: Oct 1999
Can someone here write a simple Perl script for me?
Let's say someone enter
"awards.cgi?yahoo", then the script will look for a file called "yahoo.html" in the same directory.
The query is the filename, the default extension will be html.
And if someone types "awards.cgi?yahoo", but the script can't find yahoo.html, then I would like the script to load an error.html.
All .html will be in the same directory as the CGI.
Thanks.
------------------
Goodbookmarks.com - Daily updates of good and honest website, plus a daily joke!
Submit Your Site Now!
fairhousing posted this at 12:40 — 15th December 1999.
They have: 1,587 posts
Joined: Mar 1999
i could write something like that and i'm brain dead when it comes to cgi compared to some of these guys.
------------------
Get paid to surf, email, and everything else online! 75 hrs a month at 55+ cents an hour! Beats AllAdvantage Easily. CLICK 4 DETAILS
Traffic-Website.com free traffic, affiliate programs, hosting, & domain names.
My Site got hacked, but i'm coming back?
fairhousing posted this at 20:19 — 15th December 1999.
They have: 1,587 posts
Joined: Mar 1999
there's 2 possible solutions, don't if they've beent tested though.
------------------
Get paid to surf, email, and everything else online! 75 hrs a month at 55+ cents an hour! Beats AllAdvantage Easily. CLICK 4 DETAILS
Traffic-Website.com free traffic, affiliate programs, hosting, & domain names.
My Site got hacked, but i'm coming back?
jackchen posted this at 00:40 — 16th December 1999.
They have: 472 posts
Joined: Oct 1999
I'm sorry robp, but your code didn't work.
For your information, I'm entering the URL directly into the browser.
------------------
Goodbookmarks.com - Daily updates of good and honest website, plus a daily joke!
Submit Your Site Now!
Gil posted this at 01:17 — 16th December 1999.
They have: 103 posts
Joined: Apr 1999
Here's a small script, half the size of the others, that actually works simply.
------------------
Gil Hildebrand, Jr.
The Web Development Genius of the 21st Century
Boardzilla Programmer
Gil Hildebrand, Jr.
Internet Consultant
New Orleans, LA
Rob Pengelly posted this at 01:36 — 16th December 1999.
They have: 850 posts
Joined: Jul 1999
Not sure why mine didn't work, I just tried it again using
server.com/Cgi-Bin/test.cgi?html=yahoo
and it seemed to work fine. Might as well use Gil's though, nice and short.
------------------
A 'jiffy' is an actual unit of time for 1/100th of a second.
[This message has been edited by robp (edited 15 December 1999).]
http://www.thehungersite.com - http://www.therainforestsite.com
http://www.ratemymullet.com - Beauty is only mullet deep.
japhy posted this at 01:53 — 16th December 1999.
They have: 161 posts
Joined: Dec 1999
Gil's is fine as long as you're only looking for HTML files.
In retrospect, the program doesn't need taint checking, since you're not using the filename in a system command.
------------------
--
MIDN 4/C PINYAN, NROTCURPI, USNR
Gil posted this at 03:35 — 16th December 1999.
They have: 103 posts
Joined: Apr 1999
I was just trying to keep it simple for him japhy..that's the way I would've done it though if I needed it for myself..
------------------
Gil Hildebrand, Jr.
The Web Development Genius of the 21st Century
Boardzilla Programmer
Gil Hildebrand, Jr.
Internet Consultant
New Orleans, LA
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.