-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup_model.php
39 lines (32 loc) · 1005 Bytes
/
setup_model.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
<?php
// no direct access
defined('EMONCMS_EXEC') or die('Restricted access');
class Setup
{
private $mysqli;
public function __construct($mysqli)
{
$this->mysqli = $mysqli;
}
public function status() {
$wifi = "unconfigured";
$result = $this->mysqli->query("SELECT wifi FROM setup");
if ($result && $row = $result->fetch_object()) {
$wifi = $row->wifi;
}
return $wifi;
}
public function set_status($val) {
if ($val=="ethernet" || $val=="standalone" || $val=="client") {
$result = $this->mysqli->query("SELECT wifi FROM setup");
if ($result->num_rows==0) {
$this->mysqli->query("INSERT INTO setup (wifi) VALUES ('$val')");
} else {
$this->mysqli->query("UPDATE setup SET `wifi`='$val'");
}
return "saved:$val";
} else {
return "Invalid value";
}
}
}