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_id = agents_get_agent_id_by_module_id($this->moduleId); $agent_name = agents_get_name($agent_id); $module_name = modules_get_agentmodule_name($this->moduleId); $ui->contentAddHtml('

'.$module_name.'

'); $ui->contentAddHtml('

'.$agent_name.'

'); $ui->contentAddHtml($table->getHTML()); $ui->contentAddHtml('
'); } else { $table = new Table(); $table->id = 'list_module_data'; $table->importFromHash($listData['data']); $html = $table->getHTML(); return $html; } // if ($system->getPageSize() < $listData['total']) { // $ui->contentAddHtml( // '
'.html_print_image('images/spinner.gif', true, false, false, false, false, true).' '.__('Loading...').'
' // ); // $this->addJavascriptAddBottom(); // } } $ui->contentAddLinkListener('list_servers'); } private function addJavascriptAddBottom() { $ui = Ui::getInstance(); $ui->contentAddHtml( "" ); } private function filterServersGetString() { if ($this->default) { return __('(Default)'); } else { $filters_to_serialize = []; if (!$this->default_filters['group']) { $filters_to_serialize[] = sprintf( __('Group: %s'), groups_get_name($this->group, true) ); } if (!$this->default_filters['module_group']) { $module_group = db_get_value( 'name', 'tmodule_group', 'id_mg', $this->module_group ); $module_group = io_safe_output($module_group); $filters_to_serialize[] = sprintf( __('Module group: %s'), $module_group ); } if (!$this->default_filters['status']) { $filters_to_serialize[] = sprintf( __('Status: %s'), $this->list_status[$this->status] ); } if (!$this->default_filters['free_search']) { $filters_to_serialize[] = sprintf( __('Free Search: %s'), $this->free_search ); } if (!$this->default_filters['tag']) { $tag_name = tags_get_name($this->tag); $filters_to_serialize[] = sprintf( __('Tag: %s'), $tag_name ); } $string = '('.implode(' - ', $filters_to_serialize).')'; return $string; } } }