On campus detection script

To further increase the functionality of Moodle I added a small PHP script which detects if a user is on campus or working remotely. With this script I am able to show different information and restrict information based upon location.

First we need to get the network information of the user

$IP = $_SERVER[”REMOTE_ADDR”];

$hostname = @gethostbyaddr ($IP);

Then we can create a variable which stores the hostname

$hostnamecheck = strstr($hostname,”college”);

A simple if else switch is used to check the hostname and display a message or the rest of the page.

if (strstr($hostname,”college”)) { echo ” ” }

This opens up a huge range of possibilities as Moodle now not only detects if you are a staff member or student but also where you are. This means that different campus logins can have tailored content within courses and information pages.

This script is now used in conjunction with the ban messaging feature and ban forum feature. So certain users can access messaging via mobile phone or at home but these rights are unavailable to them whilst on a college computer.

Comments are closed.