diff options
Diffstat (limited to 'modules-available/debugconfig/page.inc.php')
-rw-r--r-- | modules-available/debugconfig/page.inc.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/modules-available/debugconfig/page.inc.php b/modules-available/debugconfig/page.inc.php new file mode 100644 index 00000000..09ae0d7d --- /dev/null +++ b/modules-available/debugconfig/page.inc.php @@ -0,0 +1,50 @@ +<?php + +class Page_debugConfig extends Page +{ + + const DEFAULT_CONFIG = array("enabled" => false, "debugServer" => "127.0.0.1", "port" => 5500); + + protected function doPreprocess() + { + User::load(); + if (!User::hasPermission('superadmin')) { + Message::addError('main.no-permission'); + Util::redirect('?do=Main'); + } + if (Request::post('action') === 'debugconf') { + /*if (!filter_var(Request::get('debugServer'), FILTER_VALIDATE_IP)) { + return; + }*/ + $this->setConfig(); + } + } + + protected function doRender() + { + $debug_config = $this->getConfig(); + Render::addTemplate('debugconfig', array("debugEnabled" => $debug_config["enabled"], "debugServer" => $debug_config["debugServer"], "port" => $debug_config["port"])); + + $task = Property::getDebugTaskStruct(); + $taskid = $task['id']; + $taskstatus = Taskmanager::status($task); + error_log(print_r($taskstatus, true)); + + Render::addTemplate('relaystatus', array("taskid" => $taskid, "taskstatus" => $taskstatus)); + } + + private function getConfig() + { + if (Property::getRemoteDebugConfig() == Null) { + Property::setRemoteDebugConfig(self::DEFAULT_CONFIG); + } + return Property::getRemoteDebugConfig(); + } + + private function setConfig() + { + $enabled = isset($_POST['toggleDebug']) ? true : false; + Property::setRemoteDebugConfig(array('enabled' => $enabled, 'debugServer' => Request::post('debugServer'), 'port' => Request::post('port'))); + } +} + |