summaryrefslogtreecommitdiff
path: root/httpdocs/index.php
blob: 0513515e5c727c9ee91a888760fa30e0d548bb37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php

$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";