diff options
author | Erich Eckner <git@eckner.net> | 2019-07-26 11:56:53 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-07-26 11:56:53 +0200 |
commit | 7f1fca14e680b85b50e2914d1e9240b3bf7a74e0 (patch) | |
tree | 7f8454f2423631d891432093c20ff0eff44f500b | |
parent | 13d60346f1e0230e1637d85deb11ccbe5b01d644 (diff) | |
download | raspi-lights-out-7f1fca14e680b85b50e2914d1e9240b3bf7a74e0.tar.xz |
httpdocs/index.php: fertig
-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"; |