| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- /**
- * @author Open Mind
- * @date 04/12/2018
- * @time 15:22
- */
- namespace OpenMind\Admin;
- use OpenMind\FindBox\FindBoxCoreSystem;
- use OpenMind\Web\Controller;
- use Template;
- class Pages extends Controller
- {
- private $findBoxCore = null;
- public function __construct($f3)
- {
- parent::__construct($f3);
- $this->findBoxCore = new FindBoxCoreSystem(...array_values($f3->get('CORE.fb')));
- // Set Admin F3 UI folder
- $f3->set('UI', 'src/OpenMind/Admin/ui/');
- }
- public function Admin($f3)
- {
- echo Template::instance()->render('masterpage.tpl');
- }
- public function ESLStatus($f3)
- {
- $eslStatus = $this->findBoxCore->GetAllESLStatus();
- $f3->set('STATUS_BADGE_COLOR', [
- 'BLOCKED,FC' => 'info',
- 'OFFLINE' => 'warning',
- 'BLOCKED,FC' => 'danger',
- 'NO_STATUS' => 'light',
- 'OK' => 'success'
- ]);
- $f3->set('ESL_STATUS', $eslStatus);
- $f3->set('PAGENAME', 'Dashboard');
- $f3->set('CONTENT', 'labelstatus.tpl');
- echo Template::instance()->render('masterpage.tpl');
- }
- public function OML_Settings($f3)
- {
- global $frameworkUtils;
- $path = 'cfg/config.bin';
- if (!file_exists($path))
- throw new \Exception('Config file not found');
- $data = file_get_contents($path);
- $config = $frameworkUtils->Decrypt($data);
- $f3->set('PAGENAME', 'OM-Link Settings');
- $f3->set('CONTENT', 'omlsettings.tpl');
- $f3->set('CONFIG_TEXT', $config);
- echo Template::instance()->render('masterpage.tpl');
- }
- public function Config($f3)
- {
- global $frameworkUtils;
- $config = $f3->get('BODY');
- if (strlen($config) == 0) {
- echo json_encode([
- "err" => "Empty body command"
- ]);
- return;
- }
- $configOBJ = json_decode($config);
- switch ($configOBJ->method) {
- case 'saveconfig':
- $newConfig = $frameworkUtils->Encrypt($configOBJ->value);
- @rename('cfg/config.bin', 'cfg/config.bin.old');
- @file_put_contents('cfg/config.bin', $newConfig);
- echo json_encode([
- "err" => "Configuration saved"
- ]);
- break;
- case 'loadconfig':
- $config = $frameworkUtils->Decrypt(file_get_contents('cfg/config.bin'));
- echo json_encode([
- "err" => "Configuration reloaded successfully",
- "value" => $config
- ]);
- break;
- }
- return;
- }
- }
|