Jump to content

Recommended Posts

Hey i have tried many codes.....

this is one example of it.....

 

The scenario is as folows...

I have an IP hosted on a server...

I want to kno who accesses the files of that IP...

the codes that i tried yet, give out the IP of my own server or nothin at all...

 

 

<?php
 
$ip = $_SERVER['REMOTE_ADDR'];
        if (!empty($_SERVER['HTTP_CLIENT_IP'])) {

            $ip = $_SERVER['HTTP_CLIENT_IP'];
        } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {

            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        }


Echo "Client IP is  " . $ip;
?>        
 
 
Link to comment
https://forums.phpfreaks.com/topic/284574-how-to-get-client-ip/
Share on other sites

the server is at my office.... i have tried acessing from diff locations ie from my house, frnds house.

But the above code is giving the location of itself as may be the code itself generates its own location. All done from a computer.

 

If i have understood your first question this is the answer for it.

There isnt any load on the server and it does not involve proxies.

 

Its an app were the staff would login-logout for attendance. I dont want them to access from anyother loaction other than my office.

So code should be as such that only accessing the pages from the office would mark them present. In order for me to do that i need to kno the location of the staff using my attendance app.

If the app is something which should only be accessible from within the office, then you could just setup your server to only listen to LAN addresses and not any public addresses. Then the app would only load for someone who is on the local LAN at the office.

 

If you are not getting the IP you expect from the code above, then you are accessing the server indirectly in someway, either via a proxy, ssh tunnel, vpn, etc. Depending on what is inbetween, you may or may not be able to get the original IP address.

  • 4 weeks later...

k what i have found out is the IP which is been extracted is my Gateway IP and not client IP.

Now i cant remov my gateway as i will loose my connection.

 

i have tried sme settings but it has no effect....either nothings hapnenin or i m losing my connection.

 

Pls if u can provide me with some solution to sort out this gateway issue or how to get the client IP if d above code doesnt work.......

 

 

Thanks in advance.... 

Edited by udaystrad
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.