-
Notifications
You must be signed in to change notification settings - Fork 4
/
clockjrwww.php
55 lines (48 loc) · 1.33 KB
/
clockjrwww.php
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
// requires apache and php running
// mkdir commands and chmod777
// ln -s ~/clockjr/clockjrwww.php /var/www/html/index.php
if(!empty($_REQUEST['cmd'])){
$command = $_REQUEST['cmd'];
$dir = "/home/pi/clockjr/commands/";
$cmdfile = fopen($dir . ".clockjrcommand", "w");
$cmdfile;
fwrite($cmdfile, $command);
fclose($cmdfile);
header('Location: /');
}
if(!empty($_REQUEST['ssid']) && !empty($_REQUEST['password'])){
$command = 'network={' . "\n\t" . 'ssid="' . $_REQUEST['ssid'] . '"' . "\n\t" . 'psk="' . $_REQUEST['password'] . '"' . "\n}\n";
$dir = "/home/pi/clockjr/commands/";
$cmdfile = fopen($dir . ".wifi", "w");
$cmdfile;
fwrite($cmdfile, $command);
fclose($cmdfile);
header('Location: /');
}
$log = shell_exec("tail -n 10 /home/pi/clockjr/clocklog.log | tac");
?>
<html>
<head>
<title>ClockJr</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
</head>
<body>
<a href="?cmd=P" style="font-size: 10vw">Party</a><br>
<a href="?cmd=O" style="font-size: 10vw">On/Off</a><br>
<hr>
<form action="/index.php" style="font-size: 2vw">
Add WiFi access:<br>
Network Name:<br>
<input type="text" name="ssid" value="">
<br>
Password:<br>
<input type="text" name="password" value="">
<br><br>
<input type="submit" value="Submit">
</form>
<pre>
<?php echo $log ?>
</pre>
</body>
</html>