Home Ask Login Register

Developers Planet

Your answer is one click away!

Roberto February 2016

Website Detect "In-House Access"

TL;DR: How to detect local website users?

I have a self-hosted website running in the student-building I live in. In this website I would like a page for and links to certain local applications, like the webremote of the RPi running Kodi, an FTP, a page of instructions etc.

I don't want those to be visible to random internet users, so is there any way for a website to detect whether the user is accessing the website from inside the local network? Preferably in JavaScript, but PHP would also be fine.


LuvnJesus February 2016

in PHP it can be done in several ways. The simplest way is to do a simple IP check.

if ($_SERVER['REMOTE_ADDR'] = "") {  // Internet IP or IP rangehere
   // Show links for internal users
} else {
   // Show stuff for all other users

or for range of IPs assuming 192.168.1.x addresses

if ($_SERVER['REMOTE_ADDR'] >= "" && $_SERVER['REMOTE_ADDR'] <= "") {
  // Internal Info
} else {
  // External Info

Post Status

Asked in February 2016
Viewed 3,081 times
Voted 8
Answered 1 times


Leave an answer

Quote of the day: live life