2020-11-05 08:54:04 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
class SSDB
|
|
|
|
{
|
2021-03-18 13:26:03 -04:00
|
|
|
function execute($conn, $sql)
|
|
|
|
{
|
2020-11-05 08:54:04 -05:00
|
|
|
if ($conn->query($sql) === TRUE) {
|
2021-03-18 13:26:03 -04:00
|
|
|
return true;
|
2020-11-05 08:54:04 -05:00
|
|
|
} else {
|
2021-03-18 13:26:03 -04:00
|
|
|
return $conn->error;
|
2020-11-05 08:54:04 -05:00
|
|
|
}
|
|
|
|
}
|
2021-03-18 13:26:03 -04:00
|
|
|
function getSetting($conn, $setting)
|
|
|
|
{
|
|
|
|
$sql = "SELECT value FROM settings WHERE setting='" . $setting . "'";
|
2020-11-05 08:54:04 -05:00
|
|
|
$result = $conn->query($sql);
|
|
|
|
|
|
|
|
if ($result->num_rows == 1) {
|
2021-03-18 13:26:03 -04:00
|
|
|
while ($row = $result->fetch_assoc()) {
|
2020-11-05 08:54:04 -05:00
|
|
|
return $row["value"];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return "null";
|
|
|
|
}
|
|
|
|
}
|
2021-03-18 13:26:03 -04:00
|
|
|
function setSetting($conn, $settingname, $settingvalue)
|
|
|
|
{
|
|
|
|
$sql = "INSERT INTO settings (setting,value) VALUES ('" . $settingname . "','" . $settingvalue . "');";
|
|
|
|
if ($conn->query($sql) === TRUE) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return $conn->error;
|
|
|
|
}
|
2020-11-05 08:54:04 -05:00
|
|
|
}
|
2021-03-18 13:26:03 -04:00
|
|
|
function deleteSetting($conn, $settingname)
|
|
|
|
{
|
|
|
|
$sql = "DELETE FROM settings WHERE setting=\"" . $settingname . "\";";
|
2020-11-05 08:54:04 -05:00
|
|
|
if ($conn->query($sql) === TRUE) {
|
2021-03-18 13:26:03 -04:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return $conn->error;
|
|
|
|
}
|
2020-11-05 08:54:04 -05:00
|
|
|
}
|
2021-03-18 13:26:03 -04:00
|
|
|
function updateSetting($conn, $settingname, $settingvalue)
|
|
|
|
{
|
2020-11-05 08:54:04 -05:00
|
|
|
$this->deleteSetting($conn, $settingname);
|
|
|
|
$this->setSetting($conn, $settingname, $settingvalue);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-18 13:26:03 -04:00
|
|
|
function getBooleanSetting($conn, $setting)
|
|
|
|
{
|
|
|
|
if (trim($this->getSetting($conn, $setting)) == "yes") {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2020-11-05 08:54:04 -05:00
|
|
|
}
|
|
|
|
}
|