diff options
-rw-r--r-- | httpdocs/index.php | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/httpdocs/index.php b/httpdocs/index.php index 3bb3330..0513515 100644 --- a/httpdocs/index.php +++ b/httpdocs/index.php @@ -1,3 +1,39 @@ <?php -echo 'YO'; +$f = popen('/usr/bin/gpio read 27','r'); +if ($f === false) { + print 'Cannot access gpio'; + die(); +} +$l = trim(fgets($f)); +pclose($f); + +print "<html>\n"; +print "<head>\n"; +print '<title>fileserver lights-out</title>' . "\n"; +if (array_key_exists('push', $_GET)) + print '<meta http-equiv="refresh" content="1;/">' . "\n"; +print "</head>\n"; +print "<body>\n"; +print 'Fileserver is currently '; +if ($l == '1') + print '<font color="ff0000">off</font>'; +else + print '<font color="00ff00">on</font>'; +print "<br>\n"; +if (array_key_exists('push', $_GET) +&& ($_GET['push'] > 0) +&& ($_GET['push'] < 300)) { + print 'pushing for ' . ($_GET['push'] * 0.1) . ' seconds ... <br>' . "\n"; + shell_exec('/usr/bin/gpio write 28 1'); + flush(); + usleep(100000 * $_GET['push']); + shell_exec('/usr/bin/gpio write 28 0'); + print '... done<br>' . "\n"; +} +print '<a href="?push=1">short power button push</a>'; +print "<br>\n"; +print '<a href="?push=150">long power button push</a>'; +print "<br>\n"; +print "</body>\n"; +print "</html>\n"; |