-
Notifications
You must be signed in to change notification settings - Fork 0
/
savesettings.php
106 lines (104 loc) · 3.23 KB
/
savesettings.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
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
<?php
if(isset($_POST["fanfield"]))
{
// Handle CSRF
check_csrf(isset($_POST["token"]) ? $_POST["token"] : "");
switch ($_POST["fanfield"]) {
case "fanspeed":
$commandlist = 'argonone-cli ';
if(isset($_POST["temp0"]) && is_numeric($_POST["temp0"]))
{
$commandlist .= ' --temp0='.$_POST["temp0"];
}
else
{
$temp0 = '';
}
if(isset($_POST["fan0"]) && is_numeric($_POST["fan0"]))
{
$commandlist .= ' --fan0='.$_POST["fan0"];
}
else
{
$fan0 = '';
}
if(isset($_POST["temp1"]) && is_numeric($_POST["temp1"]))
{
$commandlist .= ' --temp1='.$_POST["temp1"];
}
else
{
$temp1 = '';
}
if(isset($_POST["fan1"]) && is_numeric($_POST["fan1"]))
{
$commandlist .= ' --fan1='.$_POST["fan1"];
}
else
{
$fan1 = '';
}
if(isset($_POST["temp2"]) && is_numeric($_POST["temp2"]))
{
$commandlist .= ' --temp2='.$_POST["temp2"];
}
else
{
$temp2 = '';
}
if(isset($_POST["fan2"]) && is_numeric($_POST["fan2"]))
{
$commandlist .= ' --fan2='.$_POST["fan2"];
}
else
{
$fan2 = '';
}
if(isset($_POST["hysteresis"]) && is_numeric($_POST["hysteresis"]))
{
$commandlist .= ' --hysteresis='.$_POST["hysteresis"];
}
else
{
$hysteresis = '';
}
if(isset($_POST["cooldowntemp"]) && is_numeric($_POST["cooldowntemp"]) && isset($_POST["cooldownfan"]) && is_numeric($_POST["cooldownfan"]))
{
exec('argonone-cli -cooldown=' .$_POST["cooldowntemp"] .' --fan=' .$_POST["cooldownfan"] .' -r');
}
else
{
}
if(isset($_POST["cooldowntemp"]) && is_numeric($_POST["cooldowntemp"]))
{
exec('argonone-cli --cooldown=' .$_POST["cooldowntemp"] .' -r');
}
else
{
}
if(isset($_POST["manual"]) && is_numeric($_POST["manual"]))
{
exec('argonone-cli --manual=' .$_POST["manual"] .' -r');
}
else
{
}
exec("$commandlist -r");
$success .= "The Argononed settings have been updated";
break;
case "fanauto":
exec('argonone-cli -a');
$success = "Argononed is now in Auto Mode";
break;
case "fanoff":
exec('argonone-cli -off');
$success = "Argononed fan is now off";
break;
case "clearfandb":
$rootdir = $_SERVER['DOCUMENT_ROOT'];
shell_exec('cp /var/www/html/admin/scripts/pi-hole/fanspeed/fanspeed.db /etc/pihole/fanspeed.db');
$success = "Fanspeed database is cleared";
break;
}
}
?>