OccupancySensor is a project mainly written in PHP, it's free.
Code for a web page that grabs Pachube Data about a room's electricity consumption and tells you if the lights are on or not
This is some basic php code that checks a pachube data feed for data about a room's power consumption, looks to see if it's above a threshhold, and responds with a a simple html page telling you if anyone's in the room (and using an above-baseline amount of power)
We're getting our power data via a current sensor that Julian Lee clipped around the power mains in the building, and he put in an arduino with a ethernet shield to send the data periodically to pachube.
Here's the tech specs:
And here's our pachube feed: https://pachube.com/feeds/34432