1<?php defined('SYSPATH') OR die('No direct access allowed.'); 2/** 3 * Mobile controller. 4 * 5 * @package PNP4Nagios 6 * @author Joerg Linge 7 * @license GPL 8 */ 9class Mobile_Controller extends System_Controller { 10 11 public function __construct() 12 { 13 parent::__construct(); 14 $this->session->set('classic-ui',0); 15 $this->template = $this->add_view('mobile'); 16 } 17 18 public function index() 19 { 20 $this->template->home = $this->add_view('mobile_home'); 21 } 22 public function about() 23 { 24 $this->template->about = $this->add_view('mobile_about'); 25 } 26 public function overview() 27 { 28 $this->template->overview = $this->add_view('mobile_overview'); 29 $this->template->overview->hosts = $this->data->getHosts(); 30 } 31 public function host($host=NULL) 32 { 33 $this->template->host = $this->add_view('mobile_host'); 34 $this->is_authorized = $this->auth->is_authorized($host); 35 $this->template->host->hostname = $host; 36 $this->template->host->services = $this->data->getServices($host); 37 } 38 public function graph($host=NULL, $service=NULL) 39 { 40 $this->template->graph = $this->add_view('mobile_graph'); 41 $this->data->buildDataStruct($host,$service,$this->view); 42 $this->is_authorized = $this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']); 43 } 44 public function search() 45 { 46 $this->template->query = $this->add_view('mobile_search'); 47 $query = pnp::clean($this->input->post('term')); 48 $result = array(); 49 if(strlen($query)>=1) { 50 $hosts = $this->data->getHosts(); 51 foreach($hosts as $host){ 52 if(preg_match("/$query/i",$host['name'])){ 53 array_push($result,$host['name']); 54 } 55 } 56 } 57 $this->result = $result; 58 } 59 public function pages($page=NULL) 60 { 61 $this->is_authorized=TRUE; 62 if($this->view == ""){ 63 $this->view = $this->config->conf['overview-range']; 64 } 65 66 $this->page = $page; 67 if(is_null($this->page) ){ 68 $this->template->pages = $this->add_view('mobile_pages'); 69 $this->template->pages->pages = $this->data->getPages(); 70 return; 71 } 72 $this->data->buildPageStruct($this->page,$this->view); 73 $this->template->pages = $this->add_view('mobile_graph'); 74 } 75 public function special($tpl=NULL) 76 { 77 $this->tpl = $tpl; 78 if(is_null($this->tpl) ){ 79 $this->template->special = $this->add_view('mobile_special'); 80 $this->template->special->templates = $this->data->getSpecialTemplates(); 81 return; 82 } 83 $this->data->buildDataStruct('__special',$this->tpl,$this->view); 84 $this->template->special = $this->add_view('mobile_graph_special'); 85 } 86 public function go($goto=FALSE) 87 { 88 if($goto == 'classic'){ 89 $this->session->set('classic-ui',1); 90 url::redirect("graph"); 91 } 92 } 93} 94