Compare commits
6 Commits
feature/co
...
c4f36235ab
Author | SHA1 | Date | |
---|---|---|---|
|
c4f36235ab | ||
daa0e0a2c5 | |||
|
464f229a16 | ||
|
fe72097d75 | ||
|
98efb779b1 | ||
30045b9f65 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,6 +2,7 @@
|
||||
.ftpconfig
|
||||
.ftpconfig2
|
||||
*.log
|
||||
*.bin
|
||||
config.php
|
||||
|
||||
_nemazat/index.html
|
||||
|
@@ -21,13 +21,24 @@ if (isset($_POST) && !empty($_POST)){
|
||||
|
||||
$ga = new PHPGangsta_GoogleAuthenticator();
|
||||
$checkResult = $ga->verifyCode($otaSecret, $otaCode, 2); // 2 = 2*30sec clock tolerance
|
||||
if ($checkResult) {
|
||||
$userManager->setOta($otaCode, $otaSecret);
|
||||
}
|
||||
if ($checkResult) {
|
||||
$userManager->setOta($otaCode, $otaSecret);
|
||||
}
|
||||
header('Location: ' . BASEURL . 'setting');
|
||||
die();
|
||||
} else if (isset ($_POST['userPermission']) && !empty ($_POST['userID'])) {
|
||||
$userManager->setUserDataAdmin("permission", $_POST['userPermission'], $_POST['userID']);
|
||||
header('Location: ' . BASEURL . 'setting');
|
||||
die();
|
||||
} else {
|
||||
foreach ($_POST as $key => $value) {
|
||||
if ($key == 'submit') continue;
|
||||
$settingMng = new SettingsManager();
|
||||
if ($settingMng->getByName($key)) {
|
||||
$settingMng->update($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: ' . BASEURL . 'setting');
|
||||
die();
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ class GoogleHome {
|
||||
}
|
||||
}
|
||||
|
||||
if ($traids < 0){
|
||||
if ($traids < 1){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@@ -14,21 +14,23 @@ class SettingsManager{
|
||||
}
|
||||
|
||||
public static function create ($name, $value, $type = '') {
|
||||
$setting = array (
|
||||
'name' => $name,
|
||||
'value' => $value,
|
||||
'type' => $type,
|
||||
);
|
||||
try {
|
||||
Db::add ('settings', $setting);
|
||||
} catch(PDOException $error) {
|
||||
echo $error->getMessage();
|
||||
die();
|
||||
if (!self::getByName($name)){
|
||||
$setting = array (
|
||||
'name' => $name,
|
||||
'value' => $value,
|
||||
'type' => $type,
|
||||
);
|
||||
try {
|
||||
Db::add ('settings', $setting);
|
||||
} catch(PDOException $error) {
|
||||
echo $error->getMessage();
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function update ($name, $value, $type = '') {
|
||||
if (self::getByName($name)){
|
||||
if (!self::getByName($name)){
|
||||
self::create($name, $value, $type);
|
||||
} else {
|
||||
try {
|
||||
|
@@ -9,6 +9,14 @@ class AirQuality extends VirtualDeviceManager
|
||||
|
||||
function make()
|
||||
{
|
||||
//Register the settings
|
||||
$settingMng = new SettingsManager();
|
||||
if (!($settingField = $settingMng->getByName("airquality"))) {
|
||||
$settingMng->create("token", "", "airquality");
|
||||
} else {
|
||||
$app_id = $settingField['value'];
|
||||
}
|
||||
|
||||
try {
|
||||
if (DeviceManager::registeret($this->virtual_device_name)) {
|
||||
$deviceId = DeviceManager::getDeviceByToken($this->virtual_device_name)['device_id'];
|
||||
@@ -17,9 +25,9 @@ class AirQuality extends VirtualDeviceManager
|
||||
sleep(1);
|
||||
$subDevice = SubDeviceManager::getSubDeviceByMaster($deviceId, strtolower($this->subdevice_type));
|
||||
}
|
||||
|
||||
|
||||
//if (!$this->fetchEnabled($deviceId,$subDevice['subdevice_id'])) die();
|
||||
|
||||
|
||||
$finalUrl = sprintf($this->api_uri, $this->city_sluig, $this->app_id);
|
||||
$json = json_decode(Utilities::CallAPI('GET', $finalUrl, ''), true);
|
||||
RecordManager::create($deviceId, $this->subdevice_type, $json['data']['aqi']);
|
||||
|
@@ -33,4 +33,8 @@ class OpenWeatherMap extends VirtualDeviceManager
|
||||
return 'exception: ' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
function enable(){
|
||||
(new SettingsManager)->create('open_weather_api_token', '', 'open_weather');
|
||||
}
|
||||
}
|
||||
|
@@ -70,6 +70,8 @@ class Setting extends Template
|
||||
$result = $settingsManager->getSettingGroup($plugins[$key]['slug']);
|
||||
if (count ($result) > 0) {
|
||||
$plugins[$key]['settings'] = $result;
|
||||
} else {
|
||||
unset($plugins[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -202,7 +202,23 @@ $partial = new Partial('head');
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<!--Plugins Settings-->
|
||||
<?php foreach ($PLUGINSSETTINGS as $key => $pluginSeting) { ?>
|
||||
<div class="col-12 col-sm-9 mx-auto mt-4">
|
||||
<h4 class="mb-4"><?php echo $pluginSeting['name'] ?></h4>
|
||||
<form method="post">
|
||||
<?php foreach ($pluginSeting['settings'] as $key => $pluginSetingField) { ?>
|
||||
<div class="field">
|
||||
<div class="label"><?php echo $pluginSetingField['name'] ?>:</div>
|
||||
<input type="text" class="input" name="<?php echo $pluginSetingField['name'] ?>" value="<?php echo $pluginSetingField['value'] ?>">
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="field">
|
||||
<input type="submit" name="submitPlugins<?php echo $pluginSeting['name'] ?>Settings" class="button" value="<?php $LANGMNG->echo('b_save') ?>">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user