-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathindex.php
80 lines (65 loc) · 2.11 KB
/
index.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
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
<?php
$password="openwrtindonesia"; // password untuk login ke server saklarku
$scriptlocation="script/gpio.sh"; // lokasi server, relatif ke file index.php ini
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');
if (!isset($_POST['key'])) {
die('{ "success": false, "message": "unauthorized!" }');
} elseif ($_POST['key'] != $password) {
die('{ "success": false, "message": "password salah!" }');
}
if (isset($_GET['auth'])) {
if ($_POST[key] != $password) {
echo '{ "success": false, "message": "password salah!" }';
} else {
echo '{ "success": true, "message": "sukses login!" }';
}
}
elseif (isset($_GET['toggle'])) {
$target = $_POST['target'];
$output = exec("bash $scriptlocation toggle $target");
echo "$output";
}
elseif (isset($_GET['single'])) {
$target = $_POST['target'];
$status = $_POST['status'];
$output = exec("bash $scriptlocation single '$target' '$status'");
echo "$output";
}
elseif (isset($_GET['group'])) {
$target = $_POST['target'];
$status = $_POST['status'];
$output = exec("bash $scriptlocation group '$target' '$status'");
echo "$output";
}
elseif (isset($_GET['allon'])) {
$output = exec("bash $scriptlocation allon");
echo "$output";
}
elseif (isset($_GET['alloff'])) {
$output = exec("bash $scriptlocation alloff");
echo "$output";
}
elseif (isset($_GET['list'])) {
$output = exec("bash $scriptlocation list");
echo "$output";
}
elseif (isset($_GET['status'])) {
$output = exec("bash $scriptlocation status");
echo "$output";
}
elseif (isset($_GET['listjadwal'])) {
$output = exec("bash $scriptlocation list-jadwal");
echo "$output";
}
elseif (isset($_GET['updatenama'])) {
$nama = $_POST['nama'];
$output = exec("bash $scriptlocation update-nama '$nama'");
echo "$output";
}
else {
echo '{ "success": false, "message": "request tidak lengkap atau salah" }';
}
?>