-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
114 lines (96 loc) · 3.98 KB
/
Copy pathindex.php
File metadata and controls
114 lines (96 loc) · 3.98 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<html>
<head>
<title>Wecker Main Page</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="icon" href="/res/favicon.png">
<meta name="viewport" content="width=device-width, height=device-heigt, initial-scale=0.73, user-scalable=no" >
</head>
<body>
<div class="header">
<div class="clockbox">
<form action="index.php" method="post">
<p>TV Control:</p>
<div class="status">
<?php
$status = exec('echo pow 0 | cec-client -d 1 -s');
if($status == "power status: standby"){
echo '<div class="offline"></div>'.'Status: <span class="offtext">Offline</span>';
}else{
echo '<div class="online"></div>'.'Status: <span class="ontext">Online</span>';
}
?>
</div>
<input formaction="action.php?action=1" type="submit" value="TV an">
<input formaction="action.php?action=2" type="submit" value="TV aus">
<p>Musik Control:</p>
<input formaction="action.php?action=3" type="submit" value="Musik an">
<input formaction="action.php?action=4" type="submit" value="Musik aus">
<p>Weckzeit:</p>
<input type="text" name="ts" placeholder="DD-MM-YYYY HH:MM:SS">
<input type="submit" name="save" value="Speichern">
<input type="submit" name="delete" value="Löschen">
<input class="deleteall" type="submit" name="deleteall" value="Alle löschen">
</form>
</div>
<div class="timetable">
<p>Weckzeiten:</p>
<?php
$con = new mysqli("localhost", "++", "++++", "alarm");
if (isset($_POST['save'])) {
$ts = $_POST['ts'];
if (!$con) {
die("Database Connect failed");
}
$date1 = strtotime(str_replace(".", "-", $ts));
$date2 = date("Y-m-d H:i:s", $date1);
$now = time();
if ($date1 > $now) {
$sql = "insert into alarm (ts) values('" . $date2 . "')";
if ($con->query($sql) === false) {
echo $con->error;
}
} else {
echo "<p>Zeit ist in der Vergangenheit</p>";
}
}
if (isset($_POST['delete'])) {
$ts = $_POST['ts'];
$date = strtotime(str_replace(".", "-", $ts));
$date = date("Y.m.d H:i:s", $date);
if (!$con) {
die("Database Connect failed");
}
$sql = "DELETE FROM alarm WHERE ts = '$date'";
if ($con->query($sql) === false) {
echo $con->error;
}
}
if (isset($_POST['deleteall'])) {
if (!$con) {
die("Database Connect failed");
}
$sql = "DELETE FROM alarm";
if ($con->query($sql) === false) {
echo $con->error;
}
}
$sql = "select * from alarm order by ts asc";
$result = $con->query($sql);
echo "<table border=1>";
$i = 0;
while ($row = $result->fetch_assoc() AND $i < 10) {
$i = $i + 1;
$date = new DateTime($row["ts"]);
$datum = $date->format('d.m.Y H:i:s');
echo "<tr><td>". $datum ."</td></tr>";
}
if ($i == 0) {
echo "<tr><td>empty</td></tr>";
}
echo "</table>";
$con->close();
?>
</div>
</div>
</body>
</html>