CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
stopping a script

 



swaylock
Deleted

Apr 17, 2001, 2:14 PM

Post #1 of 3 (411 views)
stopping a script Can't Post

Hi,

I have what seems to be a relatively simple task, but I'm having difficulty figuring it out.

I have a script that is recieving form data. But I want it to only be able to receive requests from one IP address. I can't figure out how to get the script to check the ENV{'REMOTE_ADDR'} and exit if it does'nt meet the proper criteria and contiue if it does. Here's the code:

#!/usr/bin/perl
#
# default_workgroup must have already been created
#
# This also assumes SPST is already running.

use APP;
require "APPcommon.pl";

$header = "Content-type: text/html\n\n";
print "$header";

$REMOTE_ADD = $ENV{'REMOTE_ADDR'};

if ($REMOTE_ADD != 10.36.72.82) EXIT();

# i want the previous line of code to stop the script if the request come from
# any ip other than the specified ip. If the request comes from the right IP
# the script continues.
# The following section of code parses form data and
# stores the name-value pairs in the hash variable %FORM.

if ($ENV{REQUEST_METHOD}eq "GET")
{
$buffervar = $ENV{QUERY_STRING};
}
elsif ($ENV{REQUEST_METHOD}eq "POST")
{
read (STDIN, $buffervar, $ENV{CONTENT_LENGTH});
}

Thanks for any help here!

Mike




MattWilliams
Deleted

Apr 18, 2001, 2:06 AM

Post #2 of 3 (404 views)
Re: stopping a script [In reply to] Can't Post

Try This

if ($ENV{'HTTP_REFERER'} =~ /[10.36.72.82|other address]/i) {
#do this
} else {
exit;
}



Danni
Deleted

Apr 24, 2001, 3:08 PM

Post #3 of 3 (389 views)
Re: stopping a script [In reply to] Can't Post

or this

change


Code
if ($REMOTE_ADD != 10.36.72.82) EXIT();

to


Code
unless ($REMOTE_ADD eq "10.36.72.82") {exit}



 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives