findBoxCore = new FindBoxCoreSystem(...array_values($f3->get('CORE.fb'))); // Set Admin F3 UI folder $f3->set('UI', 'ui/admin/'); } public function Admin($f3) { echo Template::instance()->render('masterpage.tpl'); } public function ESLStatus($f3) { $eslStatus = $this->findBoxCore->GetAllESLStatus(); $f3->set('STATUS_BADGE_COLOR', [ 'OFFLINE' => 'warning', 'BLOCKED,FC' => 'danger', 'NO_STATUS' => 'light', 'OK' => 'success' ]); $f3->set('BATLEV_ICONS', [ 'GOOD' => 'full', // 100% - 60% 'LOW' => 'half', // 60% - 30% 'BAD' => 'empty', // 30% - 0% ]); $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; case 'geteslstatus': $labelID = $configOBJ->label_id; $esl = new SmartESL($this->findBoxCore, [$labelID]); $status = $esl->GetStatus(true); $svgPath = $this->findBoxCore->GetTemplateImage($status[$configOBJ->label_id]['data']['template_id']); echo json_encode([ "err" => "Status reloaded successfully", "value" => $status[$configOBJ->label_id], "svgPath" => $svgPath ]); break; case 'blinklabels': $esl = new SmartESL($this->findBoxCore, [$configOBJ->labelid]); $ret = $esl->BlinkSpecial(2, 1, 1000, 5, 0); if ($ret['err'] == 0 && $ret['value']['code'] == 0) { if ($ret['value']['value'][$configOBJ->labelid]) echo json_encode([ "err" => 0, "value" => "{$configOBJ->labelid} blink successfull" ]); else echo json_encode([ "err" => 1, "value" => "{$configOBJ->labelid} blink error" ]); } break; case 'unbind': $ret = $this->findBoxCore->UnBind($configOBJ->labelid); if ($ret['err'] != 0) { echo json_encode($ret); return; } echo json_encode([ "err" => 0, "value" => "{$configOBJ->labelid} unbind successfull" ]); break; case 'resetfailcounter': $URI = "/1.0.0/index.php/smartesl.resetfailcounter/1.0.0/[[\"{$configOBJ->labelid}\"]]"; $this->findBoxCore->CallAPI($URI, ""); echo json_encode([ "err" => 0, "value" => "{$configOBJ->labelid} Reset Fail Counter successfull" ]); break; case 'TemplateSelector': $this->TemplateSelector($f3, $configOBJ); break; case 'SetDisplay': foreach($configOBJ->labels as $labelID) { $esl = new SmartESL($this->findBoxCore, [$labelID]); $esl->Display($configOBJ->id, $labelID); } echo json_encode([ "err" => "Display command successfull" ]); break; } return; } private function TemplateSelector($f3, $Command) { global $f3, $frameworkUtils; $fb_template = $this->findBoxCore->CallAPI('/1.0.0/index.php/smartesl.gettemplates/1.0.0/', '[]'); $templates = $this->findBoxCore->getLabelsFromResponse($fb_template); if ($Command->clearCache == 1) $frameworkUtils->rrmdir("fbtpl"); $tplFileNames = []; if ($templates != null) { foreach($templates as $item) { if (!in_array($item['resolution'], $Command->resolution)) continue; if (!file_exists("fbtpl/{$item['template_id']}.svg")) $this->findBoxCore->GetTemplateImage($item['template_id']); $tplFileNames[] = [ "id" => $item['template_id'], "name" => $item['name'], "resolution" => $item['resolution'], "title" => $item['name'], "svg" => file_get_contents("fbtpl/{$item['template_id']}.svg") ]; } } $f3->set('TPLOBJ', $tplFileNames); $tpl = Template::instance()->render('templates.tpl'); echo json_encode([ "err" => 0, "value" => $tpl ]); } }