PHP Classes

redirect ip range in PHP script

Recommend this page to a friend!

      PHP Forms Class with HTML Generator and JavaScript Validation  >  PHP Forms Class with HTML Generator and JavaScript Validation package blog  >  Locating addresses on...  >  All threads  >  redirect ip range in PHP script  >  (Un) Subscribe thread alerts  
Subject:redirect ip range in PHP script
Summary:How to direct ip range
Messages:7
Author:John Bunt
Date:2007-01-30 15:36:43
Update:2007-03-20 18:01:26
 

  1. redirect ip range in PHP script   Reply   Report abuse  
Picture of John Bunt John Bunt - 2007-01-30 15:36:43
I know how to redirect specific Ip addresses but not a range. I found a script that won't work. Please help. I need ASAP.
Thank you for your help.


  2. Re: redirect ip range in PHP script   Reply   Report abuse  
Picture of me me me me - 2007-01-30 15:48:59 - In reply to message 1 from John Bunt
What do you want to redirect exactly?
If your script it in: www.mywebsite.com/run.php, do you want it to be:
www.mywebsite.com/run.php?ip=12.0.0.1 (for instance).

Please put another minute or your time into explaining yourself, so I don't put in 20 minutes of my time trying to understand you.

Thanks,
Shaffer.

  3. Re: redirect ip range in PHP script   Reply   Report abuse  
Picture of John Bunt John Bunt - 2007-01-30 16:38:20 - In reply to message 2 from me me
My index.php exists just to direct bad IP's (competitors filling out bogus forms, etc.) to form2.php. Everyone else goes to form.php.

Now I have someone entering in bogus info into the form but he is coming from a couple ranges of IP's. I have no problem directing a specific ip but I cant figure out a range.

This is my original index.php
<?

$visitor = $_SERVER['REMOTE_ADDR'];

switch ($visitor){
case "xxx.xxx.xxx.xxx":
require('form2.php');
break;
case "xxx.xxx.xxx.xxx":
require('form2.php');
break;
case "xxx.xxx.xxx.xxx":
require('form2.php');
break;
case "xxx.xxx.xxx.xxx":
require('form2.php');
break;
default:
require('form.php');
break;
}

?>


Thank you for your time and help.

  4. Re: redirect ip range in PHP script   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-01-30 17:57:30 - In reply to message 1 from John Bunt
Is this related with the forms generation and validation class? If not, please use another general purpose forum.

  5. Re: redirect ip range in PHP script   Reply   Report abuse  
Picture of DarkRaverNL DarkRaverNL - 2007-03-19 12:40:36 - In reply to message 4 from Manuel Lemos
Why not use a if(in_array($ip_range)) ?

If you store the 'banned' ip addresses in a database and fetch them first then u got a array with IPs :)

  6. Re: redirect ip range in PHP script   Reply   Report abuse  
Picture of John Bunt John Bunt - 2007-03-20 14:55:49 - In reply to message 5 from DarkRaverNL
Thank you for your response. I did get it figured out though.
I have a real problem now though you might be able to help with.
I have searched everywhere and I can't find any information about this.
I have a form that someone fills out on SITE A and then an email goes out with a reference number attached. My problem is I have another site B that has a form that does the same thing...but it needs to access the same simple text file with the ref.# on site A. It is no problem to read it but after that it needs to add 1 to the number and write the new ref# to site A. So really I just need to know how to write to a text file from one domain to the other.
This post might be a little off topic but I am just asking since I was responding to the person who just replied to me...and IM VERY DESPERATE!

Thank you VERY much.

  7. Re: redirect ip range in PHP script   Reply   Report abuse  
Picture of John Bunt John Bunt - 2007-03-20 18:01:26 - In reply to message 4 from Manuel Lemos
I have a form problem but I don't know if it is on topic for this thread.
If not could you please direct me if it's not to much trouble.
Anyway here is my problem:

I have searched everywhere and I can't find any information about this.
I have a form that someone fills out on SITE A and then an email goes out with a reference number attached. My problem is I have another site B that has a form that does the same thing...but it needs to access the same simple text file with the ref.# on site A. It is no problem to read it but after that it needs to add 1 to the number and write the new ref# to site A. So really I just need to know how to write to a text file from one domain to the other.
This post might be a little off topic but I am just asking since I was responding to the person who just replied to me...and IM VERY DESPERATE!

Thank you VERY much.