checkACL($this->acl)) { $this->correct_acl = true; } else { $this->correct_acl = false; } $this->moduleId = $system->getRequest('module_id'); } public function ajax($parameter2=false) { $system = System::getInstance(); if (!$this->correct_acl) { return; } else { switch ($parameter2) { case 'get_module_data': $this->getFilters(); $page = $system->getRequest('page', 0); $module_id = $system->getRequest('module_id'); $servers = []; $end = 1; $listData = $this->getListData($page, true); if (!empty($listData['data'])) { $end = 0; $servers = $listData['data']; } echo json_encode(['end' => $end, 'servers' => $servers]); break; } } } public function show() { if (!$this->correct_acl) { $this->show_fail_acl(); } else { $this->show_module_data(); } } private function show_fail_acl() { $error['type'] = 'onStart'; $error['title_text'] = __('You don\'t have access to this page'); $error['content_text'] = System::getDefaultACLFailText(); if (class_exists('HomeEnterprise')) { $home = new HomeEnterprise(); } else { $home = new Home(); } $home->show($error); } private function show_module_data() { $ui = Ui::getInstance(); $ui->createPage(); $ui->createDefaultHeader( __('Module data'), $ui->createHeaderButton( [ 'icon' => 'ui-icon-back', 'pos' => 'left', 'text' => __('Back'), 'href' => 'index.php?page=modules', 'class' => 'header-button-left', ] ) ); $ui->showFooter(false); $ui->beginContent(); $this->listDataHtml(); $ui->endContent(); $ui->showPage(); } private function getListData($page=0, $ajax=false) { global $config; $system = System::getInstance(); $total = 0; $data = []; $module_data = modules_get_agentmodule_data( $this->moduleId, 604800, 0, false, false, 'DESC' ); $total = (int) count($module_data); foreach ($module_data as $module) { $row[__('Data')] = ''.$module['data'].''; $row[__('Timestamp')] = ''.human_time_comparation($module['utimestamp'], 'tiny').''; array_push($data, $row); } return [ 'data' => $data, 'total' => $total, ]; } public function listDataHtml($page=0, $return=false) { $system = System::getInstance(); $ui = Ui::getInstance(); $listData = $this->getListData($page); if ($listData['total'] == 0) { $html = '
'.__('No data').'
'; if (!$return) { $ui->contentAddHtml($html); } else { return $html; } } else { if (!$return) { $table = new Table(); $table->id = 'list_module_data'; $table->importFromHash($listData['data']); $ui->contentAddHtml(''.$agent_name.'
'); $ui->contentAddHtml($table->getHTML()); $ui->contentAddHtml('