Compare commits
2 Commits
bad58f82e2
...
feature/co
Author | SHA1 | Date | |
---|---|---|---|
a7380841cf | |||
28dd69e3a5 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,7 +2,6 @@
|
|||||||
.ftpconfig
|
.ftpconfig
|
||||||
.ftpconfig2
|
.ftpconfig2
|
||||||
*.log
|
*.log
|
||||||
*.bin
|
|
||||||
config.php
|
config.php
|
||||||
|
|
||||||
_nemazat/index.html
|
_nemazat/index.html
|
||||||
|
@@ -53,7 +53,6 @@ $router->any('/api/HA', 'GoogleHomeApi@response');
|
|||||||
$router->post('/api/endpoint/', 'EndpointsApi@default');
|
$router->post('/api/endpoint/', 'EndpointsApi@default');
|
||||||
$router->any('/api/update/', 'UpdatesApi@default');
|
$router->any('/api/update/', 'UpdatesApi@default');
|
||||||
$router->any('/api/users/status', 'UsersApi@status');
|
$router->any('/api/users/status', 'UsersApi@status');
|
||||||
$router->any('/api/users/subscribe', 'UsersApi@subscribe');
|
|
||||||
|
|
||||||
// examples
|
// examples
|
||||||
$router->any('/api/example', 'ExampleApi@example');
|
$router->any('/api/example', 'ExampleApi@example');
|
||||||
|
@@ -12,11 +12,6 @@ class CronApi extends ApiController
|
|||||||
$backupWorker = new DatabaseBackup();
|
$backupWorker = new DatabaseBackup();
|
||||||
$backupWorker->purge(5);
|
$backupWorker->purge(5);
|
||||||
|
|
||||||
//Old Records Cleanup
|
|
||||||
foreach (SubDeviceManager::getAllSubDevices() as $key => $value) {
|
|
||||||
RecordManager::setHistory($value['subdevice_id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->response(['Value' => 'OK']);
|
$this->response(['Value' => 'OK']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,13 +34,4 @@ class UsersApi extends ApiController{
|
|||||||
}
|
}
|
||||||
$this->response(['value'=>'OK']);
|
$this->response(['value'=>'OK']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function subscribe(){
|
|
||||||
//$this->requireAuth();
|
|
||||||
|
|
||||||
$subscriptionToken = $this->input['token'];
|
|
||||||
$subscriptionUserId = $this->input['user_id'];
|
|
||||||
NotificationManager::addSubscriber($subscriptionUserId, $subscriptionToken);
|
|
||||||
$this->response(['value'=>'OK']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -28,17 +28,6 @@ if (isset($_POST) && !empty($_POST)){
|
|||||||
die();
|
die();
|
||||||
} else if (isset ($_POST['userPermission']) && !empty ($_POST['userID'])) {
|
} else if (isset ($_POST['userPermission']) && !empty ($_POST['userID'])) {
|
||||||
$userManager->setUserDataAdmin("permission", $_POST['userPermission'], $_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');
|
header('Location: ' . BASEURL . 'setting');
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,7 @@ class GoogleHome {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($traids < 1){
|
if ($traids < 0){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -102,7 +102,7 @@ class RecordManager{
|
|||||||
|
|
||||||
public static function clean ($day) {
|
public static function clean ($day) {
|
||||||
if (isset($day)) {
|
if (isset($day)) {
|
||||||
Db::command ('DELETE FROM records WHERE `time` < ADDDATE(NOW(), INTERVAL ? DAY);', array($day));
|
Db::command ('DELETE FROM records WHERE `time` < ADDDATE(NOW(), INTERVAL -? DAY);', array($day));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,10 +110,5 @@ class RecordManager{
|
|||||||
public static function cleanSubdeviceRecords ($subDeviceId) {
|
public static function cleanSubdeviceRecords ($subDeviceId) {
|
||||||
Db::command ('DELETE FROM records WHERE subdevice_id = ?);', array($subDeviceId));
|
Db::command ('DELETE FROM records WHERE subdevice_id = ?);', array($subDeviceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function setHistory($subDeviceId){
|
|
||||||
$history = SubDeviceManager::getSubDevice($subDeviceId)['history'];
|
|
||||||
if ($history > 0) self::clean(-abs($history));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@@ -14,7 +14,6 @@ class SettingsManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function create ($name, $value, $type = '') {
|
public static function create ($name, $value, $type = '') {
|
||||||
if (!self::getByName($name)){
|
|
||||||
$setting = array (
|
$setting = array (
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'value' => $value,
|
'value' => $value,
|
||||||
@@ -27,10 +26,9 @@ class SettingsManager{
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static function update ($name, $value, $type = '') {
|
public static function update ($name, $value, $type = '') {
|
||||||
if (!self::getByName($name)){
|
if (self::getByName($name)){
|
||||||
self::create($name, $value, $type);
|
self::create($name, $value, $type);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
@@ -9,14 +9,6 @@ class AirQuality extends VirtualDeviceManager
|
|||||||
|
|
||||||
function make()
|
function make()
|
||||||
{
|
{
|
||||||
//Register the settings
|
|
||||||
$settingMng = new SettingsManager();
|
|
||||||
if (!($settingField = $settingMng->getByName("airquality"))) {
|
|
||||||
$settingMng->create("token", "", "airquality");
|
|
||||||
} else {
|
|
||||||
$app_id = $settingField['value'];
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (DeviceManager::registeret($this->virtual_device_name)) {
|
if (DeviceManager::registeret($this->virtual_device_name)) {
|
||||||
$deviceId = DeviceManager::getDeviceByToken($this->virtual_device_name)['device_id'];
|
$deviceId = DeviceManager::getDeviceByToken($this->virtual_device_name)['device_id'];
|
||||||
|
@@ -9,24 +9,24 @@ class DatabaseBackup
|
|||||||
$filenames[] = $backupWorker->scheme(); //Backup Database scheme
|
$filenames[] = $backupWorker->scheme(); //Backup Database scheme
|
||||||
$filenames[] = $backupWorker->data(); //Backup Database Data
|
$filenames[] = $backupWorker->data(); //Backup Database Data
|
||||||
//$filenames[] = $_SERVER['DOCUMENT_ROOT'] . '/config/config.php'; //Backup Configuration File
|
//$filenames[] = $_SERVER['DOCUMENT_ROOT'] . '/config/config.php'; //Backup Configuration File
|
||||||
$backupWorker->compress($_SERVER['DOCUMENT_ROOT'] . BASEDIR . '/backup/' . date("Y-m-d", time()) . '.zip', $filenames);
|
$backupWorker->compress($_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'backup/' . date("Y-m-d", time()) . '.zip', $filenames);
|
||||||
return 'sucessful';
|
return 'sucessful';
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return 'exception: ' . $e->getMessage();
|
return 'exception: ' . $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function data()
|
private function scheme()
|
||||||
{
|
{
|
||||||
$backupfile = $_SERVER['DOCUMENT_ROOT'] . BASEDIR . "/backup/" . DBNAME . '_data_' . date("Y-m-d", time()) . '.sql';
|
$backupfile = $_SERVER['DOCUMENT_ROOT'] . BASEDIR . "backup/" . DBNAME . '_scheme_' . date("Y-m-d", time()) . '.sql';
|
||||||
$command = "mysqldump --skip-comments --no-create-info -h localhost -u " . DBUSER . " -p" . DBPASS . " " . DBNAME . " -r $backupfile 2>&1";
|
$command = "mysqldump --skip-comments --no-create-info -h localhost -u " . DBUSER . " -p" . DBPASS . " " . DBNAME . " -r $backupfile 2>&1";
|
||||||
$this->executeCommand($command);
|
$this->executeCommand($command);
|
||||||
return $backupfile;
|
return $backupfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function scheme()
|
private function data()
|
||||||
{
|
{
|
||||||
$backupfile = $_SERVER['DOCUMENT_ROOT'] . BASEDIR . "/backup/" . DBNAME . '_scheme_' . date("Y-m-d", time()) . '.sql';
|
$backupfile = $_SERVER['DOCUMENT_ROOT'] . BASEDIR . "backup/" . DBNAME . '_data_' . date("Y-m-d", time()) . '.sql';
|
||||||
$command = "mysqldump --skip-comments --no-data -h localhost -u " . DBUSER . " -p" . DBPASS . " " . DBNAME . " -r $backupfile 2>&1";
|
$command = "mysqldump --skip-comments --no-data -h localhost -u " . DBUSER . " -p" . DBPASS . " " . DBNAME . " -r $backupfile 2>&1";
|
||||||
$this->executeCommand($command);
|
$this->executeCommand($command);
|
||||||
return $backupfile;
|
return $backupfile;
|
||||||
@@ -43,7 +43,9 @@ class DatabaseBackup
|
|||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
if ($zip->open($filename, ZipArchive::CREATE | ZipArchive::OVERWRITE)) {
|
if ($zip->open($filename, ZipArchive::CREATE | ZipArchive::OVERWRITE)) {
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$zip->addFile($file);
|
$filename = explode('/', $file);
|
||||||
|
$filename = end($filename);
|
||||||
|
$zip->addFile($file, $filename);
|
||||||
}
|
}
|
||||||
$zip->close();
|
$zip->close();
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
|
@@ -33,8 +33,4 @@ class OpenWeatherMap extends VirtualDeviceManager
|
|||||||
return 'exception: ' . $e->getMessage();
|
return 'exception: ' . $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function enable(){
|
|
||||||
(new SettingsManager)->create('open_weather_api_token', '', 'open_weather');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -70,8 +70,6 @@ class Setting extends Template
|
|||||||
$result = $settingsManager->getSettingGroup($plugins[$key]['slug']);
|
$result = $settingsManager->getSettingGroup($plugins[$key]['slug']);
|
||||||
if (count ($result) > 0) {
|
if (count ($result) > 0) {
|
||||||
$plugins[$key]['settings'] = $result;
|
$plugins[$key]['settings'] = $result;
|
||||||
} else {
|
|
||||||
unset($plugins[$key]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -202,23 +202,7 @@ $partial = new Partial('head');
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
24
core/Configuration/ConfigurationLoader.php
Normal file
24
core/Configuration/ConfigurationLoader.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Core\Configuration;
|
||||||
|
|
||||||
|
class ConfigurationLoader
|
||||||
|
{
|
||||||
|
private const CONFIGURATIONS_DIRECTORY = __DIR__ . DIRECTORY_SEPARATOR
|
||||||
|
. '..' . DIRECTORY_SEPARATOR
|
||||||
|
. '..' . DIRECTORY_SEPARATOR . 'config'
|
||||||
|
. DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
|
public function load(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Concerns
|
||||||
|
* -> Loading configuration files
|
||||||
|
* - Scan directory for files.
|
||||||
|
* - Filtering none config / php files.
|
||||||
|
* - Creating assoc array.
|
||||||
|
*/
|
||||||
|
}
|
@@ -8,4 +8,18 @@ namespace Core\Configuration;
|
|||||||
* @author Romano Schoonheim https://github.com/romano1996
|
* @author Romano Schoonheim https://github.com/romano1996
|
||||||
*/
|
*/
|
||||||
class Configurations
|
class Configurations
|
||||||
{}
|
{
|
||||||
|
/** @var array */
|
||||||
|
private $configurations;
|
||||||
|
|
||||||
|
public function __construct(ConfigurationLoader $configurationLoader)
|
||||||
|
{
|
||||||
|
// Concern: Storing assoc array to this object.
|
||||||
|
$this->configurations = $configurationLoader->load();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get(string $path)
|
||||||
|
{
|
||||||
|
// Concern: Accessing configurations based on "paths" application.something For example.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user