Jump to content

Running script depending on client Public IP


angelcause

Recommended Posts

I am writing a script which will be dependent on the client's public ip address. e.g.

 

if the client is using ip address 203.122.55.124 script A should run and if else then script B should run. Now I know that the If and else will be used but cant guess how will the public ip be captured.

 

Please help

 

 

Consider getting country from the public ip to make decisions. Try this, IP2Location db1 lite
Its free to use and provide you the country of the user based on the IP address. A variety of APIs is also provided.

 

 

That's if the OP want's to do geolocation

Hope it's not a dynamic IP (which changes). Otherwise you'll have to be updating your code constantly. I think a log in system would be much better with permissions/user levels. If 'administrator' logs in, run script A, if 'maintainer' logs in, run script B, etc.

Actually I have a script which runs in two modes - Local Host and WAN. The IP I am using is like 203.135.37.204

 

Here is what I want 

 

I have 2 scripts 

 

Script A

and 

Script B

 

Now I want the script to see if the public address of client is  the above (203.135.37.204) then it should run script A else it should run script B

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.