Search code examples
phpdrupallan

Check if user is on LAN


I'm making a drupal website that will be used in a museum. They want to send a mail with a printable page to the user. If the user is currently in the museum, they want to send the mail to the reception too, so the page can be printed in the museum.

I'm assuming the best way to check whether the person is in the museum or not is by determining if the user is on the LAN or not. Is there any way to do this in php and/or drupal?


Solution

  • I had a similar project.

    What I did was checked if the user's IP address is the same to that of the LAN's external IP. If it is, it does the thing.

    You fetch IP address using

    $_SERVER['REMOTE_ADDR'];
    

    then, put this value under if-else.

    Simple?