Jump to content

Running script depending on client Public IP


Go to solution Solved by QuickOldCar,

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

Edited by QuickOldCar

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.