Raspbian Shutdown from web

sudo apt-get update && sudo apt-get install lighttpd php-cgi
sudo lighty-enable-mod fastcgi fastcgi-php
sudo service lighttpd force-reload
sudo visudo
# Add the following line below “pi ALL etc.” and exit the visudo editor:
www-data ALL = NOPASSWD: /sbin/shutdown
sudo nano /var/www/index.html

<html><a href="shutdown.php">Shutdown NOW</a></html>

sudo nano /var/www/shutdown.php

<?php system('sudo /sbin/shutdown -h now'); ?>

Source: https://www.raspberrypi.org/forums/viewtopic.php?t=58802