-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhvp-settings.class.php
35 lines (29 loc) · 1.01 KB
/
hvp-settings.class.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
<?php
namespace Hvp;
require_once "hvp-data-connector.class.php";
class Settings {
private $conn = NULL;
function __construct () {
/* create data-connector object */
$this->conn = new DataConnector ();
}
public function get_value ($name) {
$name_escaped = $this->conn->escapeString ($name);
$result = $this->conn->query ("SELECT value FROM settings WHERE name = '$name_escaped';");
if (($row = $result->fetchArray ()) == FALSE)
return NULL;
return $row[0];
}
public function set_value ($name, $value) {
$name_escaped = $this->conn->escapeString ($name);
$value_escaped = $this->conn->escapeString ($value);
$this->conn->query ("INSERT OR REPLACE INTO settings (name, value) VALUES ('$name_escaped', '$value_escaped');");
}
public function __get ($name) {
$name_escaped = $this->conn->escapeString ($name);
$result = $this->conn->query ("SELECT value FROM settings WHERE name LIKE '/general/$name_escaped';");
if (($row = $result->fetchArray ()) == FALSE)
return NULL;
return $row[0];
}
}