PHP_SMART_HOME_V3/app/views/Setting.php

56 lines
1.5 KiB
PHP
Raw Normal View History

2019-08-23 11:39:42 +00:00
<?php
class Setting extends Template
{
function __construct()
{
2019-10-30 14:18:29 +00:00
2019-08-23 11:39:42 +00:00
global $userManager;
2019-10-11 12:12:05 +00:00
global $langMng;
2019-08-23 11:39:42 +00:00
if (!$userManager->isLogin()){
2019-10-11 14:32:05 +00:00
header('Location: ' . BASEDIR . 'login');
2019-08-23 11:39:42 +00:00
}
$automations = [];
$automationsData = AutomationManager::getAll();
foreach ($automationsData as $automationKey => $automationData) {
$automations[$automationData['automation_id']] = [
'name' => '',
'onDays' => $automationData['on_days'],
'ifSomething' => $automationData['if_something'],
'doSomething' => $automationData['do_something'],
];
}
$template = new Template('setting');
2019-10-11 14:38:20 +00:00
$template->prepare('baseDir', BASEDIR);
2020-01-17 09:27:51 +00:00
$template->prepare('debugMod', DEBUGMOD);
2019-08-23 11:39:42 +00:00
$template->prepare('title', 'Automation');
2019-10-11 12:12:05 +00:00
$template->prepare('langMng', $langMng);
2019-08-23 11:39:42 +00:00
$template->prepare('automations', $automations);
2019-10-30 14:18:29 +00:00
$users = $userManager->getUsers();
$template->prepare('users', $users);
if ($userManager->getUserData('ota') == ''){
$ga = new PHPGangsta_GoogleAuthenticator();
$otaSecret = $ga->createSecret();
$qrCodeUrl = $ga->getQRCodeGoogleUrl('Smart Home', $otaSecret);
$oneCode = $ga->getCode($otaSecret);
$template->prepare('qrUrl', $qrCodeUrl);
$template->prepare('otaSecret', $otaSecret);
$template->prepare('otaCode', $oneCode);
// echo "Secret is: ".$secret."\n\n";
// echo "Google Charts URL for the QR-Code: ".$qrCodeUrl."\n\n";
// echo "Checking Code '$oneCode' and Secret '$otaSecret':\n";
}
2019-11-22 14:09:22 +00:00
$rooms = RoomManager::getAllRooms();
$template->prepare('rooms', $rooms);
2019-10-30 14:18:29 +00:00
2019-08-23 11:39:42 +00:00
$template->render();
}
}