New upstream version 0.6.27
This commit is contained in:
@@ -1,148 +1,199 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Ajax controller.
|
||||
*
|
||||
* @package PNP4Nagios
|
||||
* @author Joerg Linge
|
||||
* @package PNP4Nagios
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class Ajax_Controller extends System_Controller {
|
||||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
|
||||
public function __construct(){
|
||||
|
||||
class Ajax_Controller extends System_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// Disable auto-rendering
|
||||
$this->auto_render = FALSE;
|
||||
$this->auto_render = false;
|
||||
}
|
||||
|
||||
public function index(){
|
||||
url::redirect("start", 302);
|
||||
public function index()
|
||||
{
|
||||
url::redirect("start", 302);
|
||||
}
|
||||
|
||||
public function search() {
|
||||
public function search()
|
||||
{
|
||||
$query = pnp::clean($this->input->get('term'));
|
||||
$result = array();
|
||||
if(strlen($query)>=1) {
|
||||
if (strlen($query) >= 1) {
|
||||
$hosts = $this->data->getHosts();
|
||||
foreach($hosts as $host){
|
||||
if(preg_match("/$query/i",$host['name'])){
|
||||
array_push($result,$host['name']);
|
||||
foreach ($hosts as $host) {
|
||||
if (preg_match("/$query/i", $host['name'])) {
|
||||
array_push($result, $host['name']);
|
||||
}
|
||||
}
|
||||
echo json_encode($result);
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($what){
|
||||
if($what == 'timerange'){
|
||||
public function remove($what)
|
||||
{
|
||||
if ($what == 'timerange') {
|
||||
$this->session->delete('start');
|
||||
$this->session->delete('end');
|
||||
$this->session->set('timerange-reset', 1);
|
||||
}
|
||||
}
|
||||
|
||||
public function filter($what){
|
||||
if($what == 'set-sfilter'){
|
||||
$this->session->set('sfilter', $_POST['sfilter']);
|
||||
}elseif($what == 'set-spfilter'){
|
||||
$this->session->set('spfilter', $_POST['spfilter']);
|
||||
}elseif($what == 'set-pfilter'){
|
||||
$this->session->set('pfilter', $_POST['pfilter']);
|
||||
|
||||
public function filter($what)
|
||||
{
|
||||
$received_token = $_POST['csrf_token'];
|
||||
$token = Security::token();
|
||||
|
||||
if (!Security::check($received_token, $token)) {
|
||||
echo "CSRF Token invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($what == 'set-sfilter') {
|
||||
$this->session->set('sfilter', htmlspecialchars($_POST['sfilter']));
|
||||
} elseif ($what == 'set-spfilter') {
|
||||
$this->session->set('spfilter', htmlspecialchars($_POST['spfilter']));
|
||||
} elseif ($what == 'set-pfilter') {
|
||||
$this->session->set('pfilter', htmlspecialchars($_POST['pfilter']));
|
||||
}
|
||||
}
|
||||
|
||||
public function basket($action=FALSE){
|
||||
public function basket($action = false)
|
||||
{
|
||||
// Disable auto-rendering
|
||||
$this->auto_render = FALSE;
|
||||
$this->auto_render = false;
|
||||
$host = false;
|
||||
$service = false;
|
||||
$basket = array();
|
||||
|
||||
if($action == "list"){
|
||||
if ($action == "list") {
|
||||
$basket = $this->session->get("basket");
|
||||
if(is_array($basket) && sizeof($basket) > 0){
|
||||
foreach($basket as $item){
|
||||
printf("<li class=\"ui-state-default %s\" id=\"%s\"><a title=\"%s\" id=\"%s\"><img width=12px height=12px src=\"%smedia/images/remove.png\"></a>%s</li>\n",
|
||||
if (is_array($basket) && (!empty($basket))) {
|
||||
foreach ($basket as $item) {
|
||||
printf(
|
||||
"<li class=\"ui-state-default %s\" id=\"%s\"><a title=\"%s\" id=\"%s\"><img width=12px height=12px src=\"%smedia/images/remove.png\"></a>%s</li>\n",
|
||||
"basket_action_remove",
|
||||
$item,
|
||||
$item,
|
||||
Kohana::lang('common.basket-remove', $item),
|
||||
url::base(),
|
||||
pnp::shorten($item)
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
}elseif($action == "add"){
|
||||
$item = $_POST['item'];
|
||||
} elseif ($action == "add") {
|
||||
$received_token = $_POST['csrf_token'];
|
||||
$token = Security::token();
|
||||
|
||||
if (!Security::check($received_token, $token)) {
|
||||
echo "CSRF Token invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
$item = htmlspecialchars($_POST['item']);
|
||||
$basket = $this->session->get("basket");
|
||||
if(!is_array($basket)){
|
||||
if (!is_array($basket)) {
|
||||
$basket = [];
|
||||
$basket[] = "$item";
|
||||
}else{
|
||||
if(!in_array($item,$basket)){
|
||||
} else {
|
||||
if (!in_array($item, $basket)) {
|
||||
$basket[] = $item;
|
||||
}
|
||||
}
|
||||
$this->session->set("basket", $basket);
|
||||
foreach($basket as $item){
|
||||
printf("<li class=\"ui-state-default %s\" id=\"%s\"><a title=\"%s\" id=\"%s\"><img width=12px height=12px src=\"%smedia/images/remove.png\"></a>%s</li>\n",
|
||||
"basket_action_remove",
|
||||
$item,
|
||||
$item,
|
||||
Kohana::lang('common.basket-remove', $item),
|
||||
url::base(),
|
||||
pnp::shorten($item)
|
||||
);
|
||||
foreach ($basket as $item) {
|
||||
printf(
|
||||
"<li class=\"ui-state-default %s\" id=\"%s\"><a title=\"%s\" id=\"%s\"><img width=12px height=12px src=\"%smedia/images/remove.png\"></a>%s</li>\n",
|
||||
"basket_action_remove",
|
||||
$item,
|
||||
$item,
|
||||
Kohana::lang('common.basket-remove', $item),
|
||||
url::base(),
|
||||
pnp::shorten($item)
|
||||
);
|
||||
}
|
||||
}elseif($action == "sort"){
|
||||
$items = $_POST['items'];
|
||||
} elseif ($action == "sort") {
|
||||
$received_token = $_POST['csrf_token'];
|
||||
$token = Security::token();
|
||||
|
||||
if (!Security::check($received_token, $token)) {
|
||||
echo "CSRF Token invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
$item = htmlspecialchars($_POST['item']);
|
||||
$basket = explode(',', $items);
|
||||
array_pop($basket);
|
||||
$this->session->set("basket", $basket);
|
||||
foreach($basket as $item){
|
||||
printf("<li class=\"ui-state-default %s\" id=\"%s\"><a title=\"%s\" id=\"%s\"><img width=12px height=12px src=\"%smedia/images/remove.png\"></a>%s</li>\n",
|
||||
"basket_action_remove",
|
||||
$item,
|
||||
$item,
|
||||
Kohana::lang('common.basket-remove', $item),
|
||||
url::base(),
|
||||
pnp::shorten($item)
|
||||
);
|
||||
foreach ($basket as $item) {
|
||||
printf(
|
||||
"<li class=\"ui-state-default %s\" id=\"%s\"><a title=\"%s\" id=\"%s\"><img width=12px height=12px src=\"%smedia/images/remove.png\"></a>%s</li>\n",
|
||||
"basket_action_remove",
|
||||
$item,
|
||||
$item,
|
||||
Kohana::lang('common.basket-remove', $item),
|
||||
url::base(),
|
||||
pnp::shorten($item)
|
||||
);
|
||||
}
|
||||
}elseif($action == "remove"){
|
||||
} elseif ($action == "remove") {
|
||||
$received_token = $_POST['csrf_token'];
|
||||
$token = Security::token();
|
||||
|
||||
if (!Security::check($received_token, $token)) {
|
||||
echo "CSRF Token invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
$basket = $this->session->get("basket");
|
||||
$item_to_remove = $_POST['item'];
|
||||
$item_to_remove = htmlspecialchars($_POST['item']);
|
||||
$new_basket = array();
|
||||
foreach($basket as $item){
|
||||
if($item == $item_to_remove){
|
||||
foreach ($basket as $item) {
|
||||
if ($item == $item_to_remove) {
|
||||
continue;
|
||||
}
|
||||
$new_basket[] = $item;
|
||||
}
|
||||
$basket = $new_basket;
|
||||
$this->session->set("basket", $basket);
|
||||
foreach($basket as $item){
|
||||
printf("<li class=\"ui-state-default %s\" id=\"%s\"><a title=\"%s\" id=\"%s\"><img width=12px height=12px src=\"%smedia/images/remove.png\"></a>%s</li>\n",
|
||||
"basket_action_remove",
|
||||
$item,
|
||||
$item,
|
||||
Kohana::lang('common.basket-remove', $item),
|
||||
url::base(),
|
||||
pnp::shorten($item)
|
||||
);
|
||||
foreach ($basket as $item) {
|
||||
printf(
|
||||
"<li class=\"ui-state-default %s\" id=\"%s\"><a title=\"%s\" id=\"%s\"><img width=12px height=12px src=\"%smedia/images/remove.png\"></a>%s</li>\n",
|
||||
"basket_action_remove",
|
||||
$item,
|
||||
$item,
|
||||
Kohana::lang('common.basket-remove', $item),
|
||||
url::base(),
|
||||
pnp::shorten($item)
|
||||
);
|
||||
}
|
||||
}elseif($action == "clear"){
|
||||
} elseif ($action == "clear") {
|
||||
$this->session->delete("basket");
|
||||
}else{
|
||||
} else {
|
||||
echo "Action $action not known";
|
||||
}
|
||||
$basket = $this->session->get("basket");
|
||||
if(is_array($basket) && sizeof($basket) == 0){
|
||||
if (is_array($basket) && empty($basket)) {
|
||||
echo Kohana::lang('common.basket-empty');
|
||||
}else{
|
||||
} else {
|
||||
echo "<div align=\"center\" class=\"p2\">\n";
|
||||
echo "<button id=\"show\">".Kohana::lang('common.basket-show')."</button>\n";
|
||||
echo "<button id=\"clear\">".Kohana::lang('common.basket-clear')."</button>\n";
|
||||
echo "<button id=\"show\">" . Kohana::lang('common.basket-show') . "</button>\n";
|
||||
echo "<button id=\"clear\">" . Kohana::lang('common.basket-clear') . "</button>\n";
|
||||
echo "</div>\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,26 +1,36 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
|
||||
/**
|
||||
* Debug controller.
|
||||
*
|
||||
* @package PNP4Nagios
|
||||
* @author Joerg Linge
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class Color_Controller extends System_Controller {
|
||||
|
||||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
|
||||
class Color_Controller extends System_Controller
|
||||
{
|
||||
public $scheme = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->template = $this->add_view('template');
|
||||
$this->template->color = $this->add_view('color');
|
||||
$this->template->color->color_box = $this->add_view('color_box');
|
||||
$this->template->color->color_box = $this->add_view('color_box');
|
||||
$this->template->color->logo_box = $this->add_view('logo_box');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->scheme = $this->config->scheme;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
//phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
/**
|
||||
* Debug controller.
|
||||
*
|
||||
* @package PNP4Nagios
|
||||
* @author Joerg Linge
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class Debug_Controller extends System_Controller {
|
||||
|
||||
|
||||
class Debug_Controller extends System_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -19,48 +25,49 @@ class Debug_Controller extends System_Controller {
|
||||
public function index()
|
||||
{
|
||||
|
||||
$this->data->getTimeRange($this->start,$this->end,$this->view);
|
||||
$this->data->getTimeRange($this->start, $this->end, $this->view);
|
||||
|
||||
if(isset($this->host) && isset($this->service)){
|
||||
$this->url = "?host=".$this->host."&srv=".$this->service;
|
||||
if($this->start){
|
||||
$this->url .= "&start=".$this->start;
|
||||
if (isset($this->host) && isset($this->service)) {
|
||||
$this->url = "?host=" . $this->host . "&srv=" . $this->service;
|
||||
if ($this->start) {
|
||||
$this->url .= "&start=" . $this->start;
|
||||
$this->session->set("start", $this->start);
|
||||
}
|
||||
if($this->end){
|
||||
$this->url .= "&end=".$this->end;
|
||||
if ($this->end) {
|
||||
$this->url .= "&end=" . $this->end;
|
||||
$this->session->set("end", $this->end);
|
||||
}
|
||||
$services = $this->data->getServices($this->host);
|
||||
$this->data->buildDataStruct($this->host,$this->service,$this->view);
|
||||
$this->is_authorized = $this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']);
|
||||
$this->title = "Service Details ". $this->host ." -> " . $this->data->MACRO['DISP_SERVICEDESC'];
|
||||
}elseif(isset($this->host)){
|
||||
$this->data->buildDataStruct($this->host, $this->service, $this->view);
|
||||
$this->is_authorized = $this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']);
|
||||
$this->title = "Service Details " . $this->host . " -> " . $this->data->MACRO['DISP_SERVICEDESC'];
|
||||
} elseif (isset($this->host)) {
|
||||
$this->is_authorized = $this->auth->is_authorized($this->host);
|
||||
if($this->view == ""){
|
||||
if ($this->view == "") {
|
||||
$this->view = $this->config->conf['overview-range'];
|
||||
}
|
||||
if($this->start){
|
||||
$this->url .= "&start=".$this->start;
|
||||
if ($this->start) {
|
||||
$this->url .= "&start=" . $this->start;
|
||||
$this->session->set("start", $this->start);
|
||||
}
|
||||
if($this->end){
|
||||
$this->url .= "&end=".$this->end;
|
||||
if ($this->end) {
|
||||
$this->url .= "&end=" . $this->end;
|
||||
$this->session->set("end", $this->end);
|
||||
}
|
||||
$this->title = "Start $this->host";
|
||||
$services = $this->data->getServices($this->host);
|
||||
$this->title = "Service Overview for $this->host";
|
||||
foreach($services as $service){
|
||||
if($service['state'] == 'active')
|
||||
$this->data->buildDataStruct($this->host,$service['name'],$this->view);
|
||||
foreach ($services as $service) {
|
||||
if ($service['state'] == 'active') {
|
||||
$this->data->buildDataStruct($this->host, $service['name'], $this->view);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(isset($this->host)){
|
||||
} else {
|
||||
if (isset($this->host)) {
|
||||
url::redirect("/graph");
|
||||
}else{
|
||||
} else {
|
||||
throw new Kohana_Exception('error.get-first-host');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,65 +1,91 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
|
||||
/**
|
||||
* Docs controller.
|
||||
*
|
||||
* @package PNP4Nagios
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
* @package PNP4Nagios
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class Docs_Controller extends System_Controller {
|
||||
class Docs_Controller extends System_Controller
|
||||
{
|
||||
public $doc_language = '';
|
||||
|
||||
public $lang = '';
|
||||
|
||||
public $page = '';
|
||||
|
||||
public $content = '';
|
||||
|
||||
public $toc = '';
|
||||
|
||||
public $graph_width = '';
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->template = $this->add_view('template');
|
||||
$this->template->docs = $this->add_view('docs');
|
||||
$this->template->docs->search_box = $this->add_view('search_box');
|
||||
$this->template->docs->docs_box = $this->add_view('docs_box');
|
||||
$this->template->docs->logo_box = $this->add_view('logo_box');
|
||||
$this->doc_language = $this->config->conf['doc_language'];
|
||||
$this->template = $this->add_view('template');
|
||||
$this->template->docs = $this->add_view('docs');
|
||||
$this->template->docs->search_box = $this->add_view('search_box');
|
||||
$this->template->docs->docs_box = $this->add_view('docs_box');
|
||||
$this->template->docs->logo_box = $this->add_view('logo_box');
|
||||
$this->doc_language = $this->config->conf['doc_language'];
|
||||
}
|
||||
//end __construct()
|
||||
|
||||
public function index(){
|
||||
url::redirect("docs/view/");
|
||||
|
||||
public function index()
|
||||
{
|
||||
url::redirect('docs/view/');
|
||||
}
|
||||
//end index()
|
||||
|
||||
public function view($lang=FALSE, $page=FALSE){
|
||||
if($lang == FALSE){
|
||||
if(!in_array($this->config->conf['lang'],$this->doc_language) ){
|
||||
|
||||
public function view($lang = false, $page = false)
|
||||
{
|
||||
if ($lang == false) {
|
||||
if (!in_array($this->config->conf['lang'], $this->doc_language)) {
|
||||
$this->lang = $this->doc_language[0];
|
||||
}else{
|
||||
$this->lang = $this->config->conf['lang'] ;
|
||||
} else {
|
||||
$this->lang = $this->config->conf['lang'];
|
||||
}
|
||||
}else{
|
||||
if(in_array($lang,$this->doc_language) ){
|
||||
} else {
|
||||
if (in_array($lang, $this->doc_language)) {
|
||||
$this->lang = $lang;
|
||||
}else{
|
||||
} else {
|
||||
$this->lang = $this->doc_language[0];
|
||||
url::redirect("docs/view/");
|
||||
url::redirect('docs/view/');
|
||||
}
|
||||
}
|
||||
|
||||
if($page == FALSE){
|
||||
url::redirect("docs/view/".$this->lang."/start");
|
||||
|
||||
if ($page == false) {
|
||||
url::redirect('docs/view/' . $this->lang . '/start');
|
||||
}
|
||||
|
||||
$this->page = $page;
|
||||
$file = sprintf("documents/%s/%s.html", $this->lang, $this->page);
|
||||
$file_toc = sprintf("documents/%s/start.html", $this->lang);
|
||||
if(!file_exists($file)){
|
||||
url::redirect("docs/view/start");
|
||||
$file = sprintf('documents/%s/%s.html', $this->lang, $this->page);
|
||||
$file_toc = sprintf('documents/%s/start.html', $this->lang);
|
||||
if (!file_exists($file)) {
|
||||
url::redirect('docs/view/start');
|
||||
}
|
||||
$this->content = file_get_contents($file);
|
||||
$toc = file( $file_toc );
|
||||
$this->toc = "";
|
||||
$in = FALSE;
|
||||
foreach($toc as $t){
|
||||
if(preg_match("/SECTION/", $t) ){
|
||||
$toc = file($file_toc);
|
||||
$this->toc = '';
|
||||
$in = false;
|
||||
foreach ($toc as $t) {
|
||||
if (preg_match('/SECTION/', $t)) {
|
||||
$in = ! $in;
|
||||
continue;
|
||||
}
|
||||
if($in == TRUE){
|
||||
$this->toc .= $t;
|
||||
if ($in == true) {
|
||||
$this->toc .= $t;
|
||||
}
|
||||
}
|
||||
#
|
||||
@@ -67,14 +93,16 @@ class Docs_Controller extends System_Controller {
|
||||
#
|
||||
$this->toc = str_replace("/de/pnp-0.6/", "", $this->toc);
|
||||
$this->toc = str_replace("/pnp-0.6/", "", $this->toc);
|
||||
$this->toc = preg_replace("/<h2>.*<\/h2>/", "" , $this->toc);
|
||||
$this->content = str_replace("/templates/", "http://docs.pnp4nagios.org/templates/", $this->content);
|
||||
$this->toc = preg_replace("/<h2>.*<\/h2>/", "", $this->toc);
|
||||
$this->content = str_replace("/templates/", url::base() . "documents/templates/", $this->content);
|
||||
$this->content = str_replace("/de/pnp-0.6/", "", $this->content);
|
||||
$this->content = str_replace("/pnp-0.6/", "", $this->content);
|
||||
$this->content = str_replace("/_media", url::base()."documents/_media", $this->content);
|
||||
$this->content = str_replace("/_media", url::base() . "documents/_media", $this->content);
|
||||
$this->content = str_replace("gallery", "", $this->content);
|
||||
$this->content = str_replace("/_detail", url::base()."documents/_media", $this->content);
|
||||
$this->content = str_replace("/lib/images", url::base()."documents/images", $this->content);
|
||||
$this->content = str_replace("/_detail", url::base() . "documents/_media", $this->content);
|
||||
$this->content = str_replace("/lib/images", url::base() . "documents/images", $this->content);
|
||||
$this->graph_width = ($this->config->conf['graph_width'] + 140);
|
||||
}
|
||||
//end view()
|
||||
}
|
||||
//end class
|
||||
|
||||
@@ -1,129 +1,148 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
|
||||
/**
|
||||
* Graph controller.
|
||||
*
|
||||
* @package PNP4Nagios
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
* @package PNP4Nagios
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class Graph_Controller extends System_Controller {
|
||||
class Graph_Controller extends System_Controller
|
||||
{
|
||||
public $is_authorized = '';
|
||||
|
||||
public $title = '';
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->template = $this->add_view('template');
|
||||
if (isset($this->version) && $this->version == "tiny" )
|
||||
$this->template->graph = $this->add_view('graph_tiny');
|
||||
else
|
||||
$this->template->graph = $this->add_view('graph');
|
||||
$this->template->zoom_header = $this->add_view('zoom_header');
|
||||
$this->template = $this->add_view('template');
|
||||
if (isset($this->version) && $this->version == 'tiny') {
|
||||
$this->template->graph = $this->add_view('graph_tiny');
|
||||
} else {
|
||||
$this->template->graph = $this->add_view('graph');
|
||||
}
|
||||
$this->template->zoom_header = $this->add_view('zoom_header');
|
||||
$this->template->zoom_header->graph_width = ($this->config->conf['zgraph_width'] + 140);
|
||||
$this->template->zoom_header->graph_height = ($this->config->conf['zgraph_height'] + 230);
|
||||
$this->template->graph->icon_box = $this->add_view('icon_box');
|
||||
$this->template->graph->icon_box->position = "graph";
|
||||
$this->template->graph->icon_box->xml_icon = TRUE;
|
||||
$this->template->graph->icon_box->pdf_icon = TRUE;
|
||||
$this->template->graph->icon_box->position = 'graph';
|
||||
$this->template->graph->icon_box->xml_icon = true;
|
||||
$this->template->graph->icon_box->pdf_icon = true;
|
||||
}
|
||||
//end __construct()
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->template->graph->graph_content = $this->add_view('graph_content');
|
||||
$this->template->graph->graph_content->graph_width = ($this->config->conf['graph_width'] + 85);
|
||||
$this->template->graph->graph_content = $this->add_view('graph_content');
|
||||
$this->template->graph->graph_content->graph_width = ($this->config->conf['graph_width'] + 85);
|
||||
$this->template->graph->graph_content->timerange_select = $this->add_view('timerange_select');
|
||||
$this->template->graph->header = $this->add_view('header');
|
||||
$this->template->graph->search_box = $this->add_view('search_box');
|
||||
$this->template->graph->service_box = $this->add_view('service_box');
|
||||
$this->template->graph->basket_box = $this->add_view('basket_box');
|
||||
$this->template->graph->widget_menu = $this->add_view('widget_menu');
|
||||
$this->template->graph->graph_content->widget_graph = $this->add_view('widget_graph');
|
||||
$this->template->graph->header = $this->add_view('header');
|
||||
$this->template->graph->search_box = $this->add_view('search_box');
|
||||
$this->template->graph->service_box = $this->add_view('service_box');
|
||||
$this->template->graph->basket_box = $this->add_view('basket_box');
|
||||
$this->template->graph->widget_menu = $this->add_view('widget_menu');
|
||||
$this->template->graph->graph_content->widget_graph = $this->add_view('widget_graph');
|
||||
// Change the status box while multisite theme is in use
|
||||
if($this->theme == "multisite"){
|
||||
$this->template->graph->status_box = $this->add_view('multisite_box');
|
||||
if ($this->theme == 'multisite') {
|
||||
$this->template->graph->status_box = $this->add_view('multisite_box');
|
||||
$this->template->graph->status_box->base_url = $this->config->conf['multisite_base_url'];
|
||||
$this->template->graph->status_box->site = $this->config->conf['multisite_site'];
|
||||
}else{
|
||||
} else {
|
||||
$this->template->graph->status_box = $this->add_view('status_box');
|
||||
}
|
||||
// Service Details
|
||||
if($this->host != "" && $this->service != ""){
|
||||
if ($this->host != '' && $this->service != '') {
|
||||
$this->service = pnp::clean($this->service);
|
||||
$this->host = pnp::clean($this->host);
|
||||
$this->url = "?host=".urlencode($this->host)."&srv=".urlencode($this->service);
|
||||
$this->url = '?host=' . urlencode($this->host) . '&srv=' . urlencode($this->service);
|
||||
$services = $this->data->getServices($this->host);
|
||||
#Landingpage for mobile devices
|
||||
if($this->isMobileDevice()){
|
||||
url::redirect( "mobile/host/".urlencode($this->host)."/".urlencode($this->service) );
|
||||
// Landingpage for mobile devices
|
||||
if ($this->isMobileDevice()) {
|
||||
url::redirect('mobile/host/' . urlencode($this->host) . '/' . urlencode($this->service));
|
||||
}
|
||||
#print Kohana::debug($services);
|
||||
$this->data->buildDataStruct($this->host,$this->service,$this->view);
|
||||
$this->is_authorized = $this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']);
|
||||
// print Kohana::debug($services);
|
||||
$this->data->buildDataStruct($this->host, $this->service, $this->view);
|
||||
$this->is_authorized = $this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']);
|
||||
|
||||
$this->title = Kohana::lang('common.service-details') . " ". $this->host ." -> " . $this->data->MACRO['DISP_SERVICEDESC'];
|
||||
$this->title = Kohana::lang('common.service-details') . ' ' . $this->host . ' -> ' . $this->data->MACRO['DISP_SERVICEDESC'];
|
||||
$this->template->graph->graph_content->graph_width = ($this->data->STRUCT[0]['GRAPH_WIDTH'] + 85);
|
||||
// Status Box Vars
|
||||
$this->template->graph->status_box->host = $this->data->MACRO['DISP_HOSTNAME'];
|
||||
$this->template->graph->status_box->lhost = $this->data->MACRO['HOSTNAME'];
|
||||
$this->template->graph->status_box->service = $this->data->MACRO['DISP_SERVICEDESC'];
|
||||
$this->template->graph->status_box->lservice = $this->data->MACRO['SERVICEDESC'];
|
||||
$this->template->graph->status_box->timet = date($this->config->conf['date_fmt'],intval($this->data->MACRO['TIMET']));
|
||||
$this->template->graph->status_box->timet = date($this->config->conf['date_fmt'], intval($this->data->MACRO['TIMET']));
|
||||
// Service Box Vars
|
||||
$this->template->graph->service_box->services = $services;
|
||||
$this->template->graph->service_box->host = $this->host;
|
||||
$this->template->graph->service_box->host = $this->host;
|
||||
// Timerange Box Vars
|
||||
$this->template->graph->timerange_box = $this->add_view('timerange_box');
|
||||
$this->template->graph->timerange_box = $this->add_view('timerange_box');
|
||||
$this->template->graph->timerange_box->timeranges = $this->data->TIMERANGE;
|
||||
//
|
||||
// Host Overview
|
||||
}elseif($this->host != ""){
|
||||
$this->is_authorized = $this->auth->is_authorized($this->host);
|
||||
$this->host = pnp::clean($this->host);
|
||||
#Landingpage for mobile devices
|
||||
if($this->isMobileDevice()){
|
||||
url::redirect( "mobile/host/".urlencode($this->host) );
|
||||
} elseif ($this->host != '') {
|
||||
$this->is_authorized = $this->auth->is_authorized($this->host);
|
||||
$this->host = pnp::clean($this->host);
|
||||
// Landingpage for mobile devices
|
||||
if ($this->isMobileDevice()) {
|
||||
url::redirect('mobile/host/' . urlencode($this->host));
|
||||
}
|
||||
if($this->view == ""){
|
||||
if ($this->view == '') {
|
||||
$this->view = $this->config->conf['overview-range'];
|
||||
}
|
||||
$this->url = "?host=".$this->host;
|
||||
$this->title = Kohana::lang('common.start'). " ". $this->host;
|
||||
$services = $this->data->getServices($this->host);
|
||||
$this->url = '?host=' . $this->host;
|
||||
$this->title = Kohana::lang('common.start') . ' ' . $this->host;
|
||||
$services = $this->data->getServices($this->host);
|
||||
// Status Box Vars
|
||||
$this->template->graph->status_box->host = $this->data->MACRO['DISP_HOSTNAME'];
|
||||
$this->template->graph->status_box->lhost = $this->data->MACRO['HOSTNAME'];
|
||||
$this->template->graph->status_box->shost = pnp::shorten($this->data->MACRO['DISP_HOSTNAME']);
|
||||
$this->template->graph->status_box->timet = date($this->config->conf['date_fmt'],intval($this->data->MACRO['TIMET']));
|
||||
$this->template->graph->status_box->host = $this->data->MACRO['DISP_HOSTNAME'];
|
||||
$this->template->graph->status_box->lhost = $this->data->MACRO['HOSTNAME'];
|
||||
$this->template->graph->status_box->shost = pnp::shorten($this->data->MACRO['DISP_HOSTNAME']);
|
||||
$this->template->graph->status_box->timet = date($this->config->conf['date_fmt'], intval($this->data->MACRO['TIMET']));
|
||||
// Service Box Vars
|
||||
$this->template->graph->service_box->services = $services;
|
||||
$this->template->graph->service_box->host = $this->host;
|
||||
$this->template->graph->service_box->host = $this->host;
|
||||
// Timerange Box Vars
|
||||
$this->template->graph->timerange_box = $this->add_view('timerange_box');
|
||||
$this->template->graph->timerange_box = $this->add_view('timerange_box');
|
||||
$this->template->graph->timerange_box->timeranges = $this->data->TIMERANGE;
|
||||
|
||||
$this->template->graph->icon_box->xml_icon = FALSE;
|
||||
$this->template->graph->icon_box->xml_icon = false;
|
||||
|
||||
$this->title = Kohana::lang('common.service-overview', $this->host);
|
||||
foreach($services as $service){
|
||||
if($service['state'] == 'active')
|
||||
$this->data->buildDataStruct($this->host,$service['name'],$this->view);
|
||||
foreach ($services as $service) {
|
||||
if ($service['state'] == 'active') {
|
||||
$this->data->buildDataStruct($this->host, $service['name'], $this->view);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
#Landingpage for mobile devices
|
||||
if($this->isMobileDevice()){
|
||||
url::redirect("mobile");
|
||||
return;
|
||||
} else {
|
||||
// Landingpage for mobile devices
|
||||
if ($this->isMobileDevice()) {
|
||||
url::redirect('mobile');
|
||||
return;
|
||||
}
|
||||
if($this->isAuthorizedFor('host_overview' ) ){
|
||||
if ($this->isAuthorizedFor('host_overview')) {
|
||||
$this->host = $this->data->getFirstHost();
|
||||
if(isset($this->host)){
|
||||
url::redirect("graph?host=".$this->host);
|
||||
}else{
|
||||
if (isset($this->host)) {
|
||||
url::redirect('graph?host=' . $this->host);
|
||||
} else {
|
||||
throw new Kohana_Exception('error.get-first-host');
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
throw new Kohana_Exception('error.not_authorized_for_host_overview');
|
||||
}
|
||||
}
|
||||
}
|
||||
//end if
|
||||
$this->template->graph->logo_box = $this->add_view('logo_box');
|
||||
$this->template->graph->header->title = $this->title;
|
||||
}
|
||||
//end index()
|
||||
}
|
||||
//end class
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
|
||||
/**
|
||||
* Image controller.
|
||||
*
|
||||
@@ -6,8 +13,8 @@
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class Image_Controller extends System_Controller {
|
||||
|
||||
class Image_Controller extends System_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -16,47 +23,52 @@ class Image_Controller extends System_Controller {
|
||||
public function index()
|
||||
{
|
||||
// Disable auto-rendering
|
||||
$this->auto_render = FALSE;
|
||||
|
||||
if($this->input->get('w') != "" )
|
||||
$this->auto_render = false;
|
||||
|
||||
if ($this->input->get('w') != "") {
|
||||
$this->rrdtool->config->conf['graph_width'] = intval($this->input->get('w'));
|
||||
if($this->input->get('graph_width') != "" )
|
||||
}
|
||||
if ($this->input->get('graph_width') != "") {
|
||||
$this->rrdtool->config->conf['graph_width'] = intval($this->input->get('graph_width'));
|
||||
}
|
||||
|
||||
if($this->input->get('h') != "" )
|
||||
if ($this->input->get('h') != "") {
|
||||
$this->rrdtool->config->conf['graph_height'] = intval($this->input->get('h'));
|
||||
if($this->input->get('graph_height') != "" )
|
||||
}
|
||||
if ($this->input->get('graph_height') != "") {
|
||||
$this->rrdtool->config->conf['graph_height'] = intval($this->input->get('graph_height'));
|
||||
}
|
||||
|
||||
if($this->input->get('graph_only') !== null)
|
||||
if ($this->input->get('graph_only') !== null) {
|
||||
$this->rrdtool->config->conf['graph_only'] = 1;
|
||||
}
|
||||
|
||||
if($this->input->get('no_legend') !== null)
|
||||
if ($this->input->get('no_legend') !== null) {
|
||||
$this->rrdtool->config->conf['no_legend'] = 1;
|
||||
}
|
||||
|
||||
$this->data->getTimeRange($this->start,$this->end,$this->view);
|
||||
$this->data->getTimeRange($this->start, $this->end, $this->view);
|
||||
|
||||
if($this->tpl != ""){
|
||||
$this->data->buildDataStruct('__special',$this->tpl,$this->view,$this->source);
|
||||
if ($this->tpl != "") {
|
||||
$this->data->buildDataStruct('__special', $this->tpl, $this->view, $this->source);
|
||||
#print Kohana::debug($this->data->STRUCT);
|
||||
$image = $this->rrdtool->doImage($this->data->STRUCT[0]['RRD_CALL']);
|
||||
$this->rrdtool->streamImage($image);
|
||||
}elseif(isset($this->host) && isset($this->service)){
|
||||
$this->data->buildDataStruct($this->host,$this->service,$this->view,$this->source);
|
||||
if($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === FALSE)
|
||||
$this->rrdtool->streamImage("ERROR: NOT_AUTHORIZED");
|
||||
} elseif (isset($this->host) && isset($this->service)) {
|
||||
$this->data->buildDataStruct($this->host, $this->service, $this->view, $this->source);
|
||||
if ($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === false) {
|
||||
$this->rrdtool->streamImage("ERROR: NOT_AUTHORIZED");
|
||||
}
|
||||
|
||||
#print Kohana::debug($this->data->STRUCT);
|
||||
if(sizeof($this->data->STRUCT) > 0){
|
||||
if (!empty($this->data->STRUCT)) {
|
||||
$image = $this->rrdtool->doImage($this->data->STRUCT[0]['RRD_CALL']);
|
||||
}else{
|
||||
$image = FALSE;
|
||||
} else {
|
||||
$image = false;
|
||||
}
|
||||
$this->rrdtool->streamImage($image);
|
||||
}else{
|
||||
$this->rrdtool->streamImage($image);
|
||||
} else {
|
||||
url::redirect("start", 302);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
|
||||
/**
|
||||
* Json controller.
|
||||
*
|
||||
@@ -6,28 +13,32 @@
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class Json_Controller extends System_Controller {
|
||||
|
||||
class Json_Controller extends System_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index(){
|
||||
public function index()
|
||||
{
|
||||
// Disable auto-rendering
|
||||
$this->auto_render = FALSE;
|
||||
$this->auto_render = false;
|
||||
// Service Details
|
||||
if($this->host != "" && $this->service != ""){
|
||||
if ($this->host != "" && $this->service != "") {
|
||||
$services = $this->data->getServices($this->host);
|
||||
$this->data->buildDataStruct($this->host,$this->service,$this->view);
|
||||
if($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === FALSE){
|
||||
$this->data->buildDataStruct($this->host, $this->service, $this->view);
|
||||
if ($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === false) {
|
||||
print json_encode("not authorized");
|
||||
exit;
|
||||
}
|
||||
$i = 0;
|
||||
$json = array();
|
||||
foreach($this->data->STRUCT as $struct){
|
||||
$json[$i]['image_url'] = "host=".$struct['MACRO']['HOSTNAME']."&srv=".$struct['MACRO']['SERVICEDESC']."&source=".$struct['SOURCE']."&view=".$struct['VIEW'];
|
||||
foreach ($this->data->STRUCT as $struct) {
|
||||
$json[$i]['image_url'] = "host=" . $struct['MACRO']['HOSTNAME'] .
|
||||
"&srv=" . $struct['MACRO']['SERVICEDESC'] .
|
||||
"&source=" . $struct['SOURCE'] . "&view=" .
|
||||
$struct['VIEW'];
|
||||
$json[$i]['ds_name'] = $struct['ds_name'];
|
||||
$json[$i]['start'] = $struct['TIMERANGE']['start'];
|
||||
$json[$i]['end'] = $struct['TIMERANGE']['end'];
|
||||
@@ -36,21 +47,24 @@ class Json_Controller extends System_Controller {
|
||||
}
|
||||
print json_encode($json);
|
||||
// Host Overview
|
||||
}elseif($this->host != ""){
|
||||
if($this->auth->is_authorized($this->host) === FALSE){
|
||||
} elseif ($this->host != "") {
|
||||
if ($this->auth->is_authorized($this->host) === false) {
|
||||
print json_encode("not authorized");
|
||||
exit;
|
||||
}
|
||||
$services = $this->data->getServices($this->host);
|
||||
foreach($services as $service){
|
||||
if($service['state'] == 'active'){
|
||||
$this->data->buildDataStruct($this->host,$service['name'],$this->view);
|
||||
}
|
||||
foreach ($services as $service) {
|
||||
if ($service['state'] == 'active') {
|
||||
$this->data->buildDataStruct($this->host, $service['name'], $this->view);
|
||||
}
|
||||
}
|
||||
$i = 0;
|
||||
$json = array();
|
||||
foreach($this->data->STRUCT as $struct){
|
||||
$json[$i]['image_url'] = "host=".$struct['MACRO']['HOSTNAME']."&srv=".$struct['MACRO']['SERVICEDESC']."&source=".$struct['SOURCE']."&view=".$struct['VIEW'];
|
||||
foreach ($this->data->STRUCT as $struct) {
|
||||
$json[$i]['image_url'] = "host=" . $struct['MACRO']['HOSTNAME'] .
|
||||
"&srv=" . $struct['MACRO']['SERVICEDESC'] .
|
||||
"&source=" . $struct['SOURCE'] . "&view=" .
|
||||
$struct['VIEW'];
|
||||
$json[$i]['servicedesc'] = $struct['MACRO']['SERVICEDESC'];
|
||||
$json[$i]['ds_name'] = $struct['ds_name'];
|
||||
$json[$i]['start'] = $struct['TIMERANGE']['start'];
|
||||
@@ -59,12 +73,12 @@ class Json_Controller extends System_Controller {
|
||||
$i++;
|
||||
}
|
||||
print json_encode($json);
|
||||
}else{
|
||||
} else {
|
||||
$this->hosts = $this->data->getHosts();
|
||||
$i = 0;
|
||||
$json = array();
|
||||
foreach($this->hosts as $host){
|
||||
if($host['state'] == "active"){
|
||||
foreach ($this->hosts as $host) {
|
||||
if ($host['state'] == "active") {
|
||||
$json[$i]['hostname'] = $host['name'];
|
||||
$i++;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
|
||||
/**
|
||||
* Mobile controller.
|
||||
*
|
||||
@@ -6,12 +13,12 @@
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class Mobile_Controller extends System_Controller {
|
||||
|
||||
class Mobile_Controller extends System_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->session->set('classic-ui',0);
|
||||
$this->session->set('classic-ui', 0);
|
||||
$this->template = $this->add_view('mobile');
|
||||
}
|
||||
|
||||
@@ -28,17 +35,17 @@ class Mobile_Controller extends System_Controller {
|
||||
$this->template->overview = $this->add_view('mobile_overview');
|
||||
$this->template->overview->hosts = $this->data->getHosts();
|
||||
}
|
||||
public function host($host=NULL)
|
||||
public function host($host = null)
|
||||
{
|
||||
$this->template->host = $this->add_view('mobile_host');
|
||||
$this->is_authorized = $this->auth->is_authorized($host);
|
||||
$this->template->host->hostname = $host;
|
||||
$this->template->host->services = $this->data->getServices($host);
|
||||
}
|
||||
public function graph($host=NULL, $service=NULL)
|
||||
public function graph($host = null, $service = null)
|
||||
{
|
||||
$this->template->graph = $this->add_view('mobile_graph');
|
||||
$this->data->buildDataStruct($host,$service,$this->view);
|
||||
$this->data->buildDataStruct($host, $service, $this->view);
|
||||
$this->is_authorized = $this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']);
|
||||
}
|
||||
public function search()
|
||||
@@ -46,48 +53,48 @@ class Mobile_Controller extends System_Controller {
|
||||
$this->template->query = $this->add_view('mobile_search');
|
||||
$query = pnp::clean($this->input->post('term'));
|
||||
$result = array();
|
||||
if(strlen($query)>=1) {
|
||||
if (strlen($query) >= 1) {
|
||||
$hosts = $this->data->getHosts();
|
||||
foreach($hosts as $host){
|
||||
if(preg_match("/$query/i",$host['name'])){
|
||||
array_push($result,$host['name']);
|
||||
foreach ($hosts as $host) {
|
||||
if (preg_match("/$query/i", $host['name'])) {
|
||||
array_push($result, $host['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->result = $result;
|
||||
}
|
||||
public function pages($page=NULL)
|
||||
public function pages($page = null)
|
||||
{
|
||||
$this->is_authorized=TRUE;
|
||||
if($this->view == ""){
|
||||
$this->is_authorized = true;
|
||||
if ($this->view == "") {
|
||||
$this->view = $this->config->conf['overview-range'];
|
||||
}
|
||||
|
||||
$this->page = $page;
|
||||
if(is_null($this->page) ){
|
||||
if (is_null($this->page)) {
|
||||
$this->template->pages = $this->add_view('mobile_pages');
|
||||
$this->template->pages->pages = $this->data->getPages();
|
||||
return;
|
||||
}
|
||||
$this->data->buildPageStruct($this->page,$this->view);
|
||||
$this->data->buildPageStruct($this->page, $this->view);
|
||||
$this->template->pages = $this->add_view('mobile_graph');
|
||||
}
|
||||
public function special($tpl=NULL)
|
||||
public function special($tpl = null)
|
||||
{
|
||||
$this->tpl = $tpl;
|
||||
if(is_null($this->tpl) ){
|
||||
if (is_null($this->tpl)) {
|
||||
$this->template->special = $this->add_view('mobile_special');
|
||||
$this->template->special->templates = $this->data->getSpecialTemplates();
|
||||
return;
|
||||
}
|
||||
$this->data->buildDataStruct('__special',$this->tpl,$this->view);
|
||||
$this->data->buildDataStruct('__special', $this->tpl, $this->view);
|
||||
$this->template->special = $this->add_view('mobile_graph_special');
|
||||
}
|
||||
public function go($goto=FALSE)
|
||||
public function go($goto = false)
|
||||
{
|
||||
if($goto == 'classic'){
|
||||
$this->session->set('classic-ui',1);
|
||||
url::redirect("graph");
|
||||
if ($goto == 'classic') {
|
||||
$this->session->set('classic-ui', 1);
|
||||
url::redirect("graph");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,80 +1,103 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
|
||||
|
||||
/**
|
||||
* Graph controller.
|
||||
*
|
||||
* @package PNP4Nagios
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
* @package PNP4Nagios
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class Page_Controller extends System_Controller {
|
||||
class Page_Controller extends System_Controller
|
||||
{
|
||||
public $is_authorized = '';
|
||||
|
||||
public function __construct(){
|
||||
public $page = '';
|
||||
|
||||
public $pages = '';
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->template = $this->add_view('template');
|
||||
$this->template->page = $this->add_view('page');
|
||||
$this->template->zoom_header = $this->add_view('zoom_header');
|
||||
$this->template->zoom_header->graph_width = ($this->config->conf['graph_width'] + 140);
|
||||
$this->template->zoom_header->graph_height = ($this->config->conf['graph_height'] + 230);
|
||||
$this->template->page->graph_content = $this->add_view('graph_content');
|
||||
$this->template->page->graph_content->graph_width = ($this->config->conf['graph_width'] + 85);
|
||||
$this->template = $this->add_view('template');
|
||||
$this->template->page = $this->add_view('page');
|
||||
$this->template->zoom_header = $this->add_view('zoom_header');
|
||||
$this->template->zoom_header->graph_width = ($this->config->conf['zgraph_width'] + 140);
|
||||
$this->template->zoom_header->graph_height = ($this->config->conf['zgraph_height'] + 230);
|
||||
$this->template->page->graph_content = $this->add_view('graph_content');
|
||||
$this->template->page->graph_content->graph_width = ($this->config->conf['graph_width'] + 85);
|
||||
$this->template->page->graph_content->timerange_select = $this->add_view('timerange_select');
|
||||
$this->template->page->header = $this->add_view('header');
|
||||
$this->template->page->search_box = $this->add_view('search_box');
|
||||
$this->template->page->logo_box = $this->add_view('logo_box');
|
||||
$this->is_authorized=TRUE;
|
||||
$this->template->page->header = $this->add_view('header');
|
||||
$this->template->page->search_box = $this->add_view('search_box');
|
||||
$this->template->page->logo_box = $this->add_view('logo_box');
|
||||
$this->is_authorized = true;
|
||||
}
|
||||
//end __construct()
|
||||
|
||||
public function index(){
|
||||
if( !$this->isAuthorizedFor('pages') ){
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (!$this->isAuthorizedFor('pages')) {
|
||||
throw new Kohana_Exception('error.auth-pages');
|
||||
}
|
||||
$this->page = pnp::clean($this->input->get('page'));
|
||||
if($this->page == ""){
|
||||
if ($this->page == '') {
|
||||
$this->page = $this->data->getFirstPage();
|
||||
}
|
||||
if($this->page == ""){
|
||||
if ($this->page == '') {
|
||||
throw new Kohana_Exception('error.page-config-dir', $this->config->conf['page_dir']);
|
||||
}
|
||||
if($this->view == ""){
|
||||
if ($this->view == '') {
|
||||
$this->view = $this->config->conf['overview-range'];
|
||||
}
|
||||
$this->data->buildPageStruct($this->page,$this->view);
|
||||
$this->template->page->header->title = Kohana::lang('common.page',$this->data->PAGE_DEF['page_name']);
|
||||
$this->data->buildPageStruct($this->page, $this->view);
|
||||
$this->template->page->header->title = Kohana::lang('common.page', $this->data->PAGE_DEF['page_name']);
|
||||
$this->url = "?page&page=$this->page";
|
||||
// Timerange Box Vars
|
||||
$this->template->page->timerange_box = $this->add_view('timerange_box');
|
||||
$this->template->page->timerange_box = $this->add_view('timerange_box');
|
||||
$this->template->page->timerange_box->timeranges = $this->data->TIMERANGE;
|
||||
// Pages Box
|
||||
$this->pages = $this->data->getPages();
|
||||
$this->template->page->pages_box = $this->add_view('pages_box');
|
||||
$this->template->page->pages_box->pages = $this->pages;
|
||||
$this->template->page->pages_box = $this->add_view('pages_box');
|
||||
$this->template->page->pages_box->pages = $this->pages;
|
||||
// Basket Box
|
||||
$this->template->page->basket_box = $this->add_view('basket_box');
|
||||
// Icon Box
|
||||
$this->template->page->basket_box = $this->add_view('basket_box');
|
||||
// Icon Box
|
||||
$this->template->page->icon_box = $this->add_view('icon_box');
|
||||
$this->template->page->icon_box->position = "page";
|
||||
|
||||
$this->template->page->icon_box->position = 'page';
|
||||
}
|
||||
//end index()
|
||||
|
||||
public function basket(){
|
||||
$basket = $this->session->get("basket");
|
||||
if(is_array($basket) && sizeof($basket) > 0){
|
||||
$this->data->buildBasketStruct($basket,$this->view);
|
||||
$this->template->page->basket_box = $this->add_view('basket_box');
|
||||
$this->template->page->header->title = Kohana::lang('common.page-basket');
|
||||
$this->url = "basket?";
|
||||
|
||||
public function basket()
|
||||
{
|
||||
$basket = $this->session->get('basket');
|
||||
if (is_array($basket) && (!empty($basket))) {
|
||||
$this->data->buildBasketStruct($basket, $this->view);
|
||||
$this->template->page->basket_box = $this->add_view('basket_box');
|
||||
$this->template->page->header->title = Kohana::lang('common.page-basket');
|
||||
$this->url = 'basket?';
|
||||
// Timerange Box Vars
|
||||
$this->template->page->timerange_box = $this->add_view('timerange_box');
|
||||
$this->template->page->timerange_box = $this->add_view('timerange_box');
|
||||
$this->template->page->timerange_box->timeranges = $this->data->TIMERANGE;
|
||||
// Pages Box
|
||||
$this->pages = $this->data->getPages();
|
||||
$this->template->page->pages_box = $this->add_view('pages_box');
|
||||
$this->template->page->pages_box->pages = $this->pages;
|
||||
// Icon Box
|
||||
$this->template->page->pages_box = $this->add_view('pages_box');
|
||||
$this->template->page->pages_box->pages = $this->pages;
|
||||
// Icon Box
|
||||
$this->template->page->icon_box = $this->add_view('icon_box');
|
||||
$this->template->page->icon_box->position = "basket";
|
||||
}else{
|
||||
url::redirect("start", 302);
|
||||
$this->template->page->icon_box->position = 'basket';
|
||||
} else {
|
||||
url::redirect('start', 302);
|
||||
}
|
||||
}
|
||||
//end basket()
|
||||
}
|
||||
//end class
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses
|
||||
|
||||
|
||||
/**
|
||||
* PDF controller.
|
||||
*
|
||||
@@ -6,9 +15,18 @@
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class Pdf_Controller extends System_Controller {
|
||||
class Pdf_Controller extends System_Controller
|
||||
{
|
||||
public $use_bg = '';
|
||||
public $bg = '';
|
||||
public $pdf_page_size = '';
|
||||
public $pdf_margin_left = '';
|
||||
public $pdf_margin_right = '';
|
||||
public $pdf_margin_top = '';
|
||||
public $type = '';
|
||||
|
||||
public function __construct(){
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->use_bg = 0;
|
||||
@@ -18,52 +36,53 @@ class Pdf_Controller extends System_Controller {
|
||||
$this->pdf_margin_top = $this->config->conf['pdf_margin_top'];
|
||||
$this->pdf_margin_right = $this->config->conf['pdf_margin_right'];
|
||||
|
||||
// Define PDF background per url option
|
||||
if(isset($this->bg) && $this->bg != ""){
|
||||
if( is_readable( Kohana::config( 'core.pnp_etc_path')."/".$this->bg ) ){
|
||||
$this->bg = Kohana::config('core.pnp_etc_path')."/".$this->bg;
|
||||
}else{
|
||||
// Define PDF background per url option
|
||||
if (isset($this->bg) && $this->bg != "") {
|
||||
if (is_readable(Kohana::config('core.pnp_etc_path') . "/" . $this->bg)) {
|
||||
$this->bg = Kohana::config('core.pnp_etc_path') . "/" . $this->bg;
|
||||
} else {
|
||||
$this->bg = $this->config->conf['background_pdf'];
|
||||
}
|
||||
}
|
||||
// Use PDF background if readable
|
||||
if(is_readable($this->bg)){
|
||||
if (is_readable($this->bg)) {
|
||||
$this->use_bg = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function index(){
|
||||
public function index()
|
||||
{
|
||||
|
||||
$this->tpl = pnp::clean($this->input->get('tpl'));
|
||||
$this->type = "normal";
|
||||
|
||||
$this->data->getTimeRange($this->start,$this->end,$this->view);
|
||||
$this->data->getTimeRange($this->start, $this->end, $this->view);
|
||||
|
||||
// Service Details
|
||||
if($this->host != "" && $this->service != ""){
|
||||
$this->data->buildDataStruct($this->host,$this->service,$this->view);
|
||||
if ($this->host != "" && $this->service != "") {
|
||||
$this->data->buildDataStruct($this->host, $this->service, $this->view);
|
||||
// Host Overview
|
||||
}elseif($this->host != ""){
|
||||
if($this->view == ""){
|
||||
} elseif ($this->host != "") {
|
||||
if ($this->view == "") {
|
||||
$this->view = $this->config->conf['overview-range'];
|
||||
}
|
||||
$services = $this->data->getServices($this->host);
|
||||
foreach($services as $service){
|
||||
if($service['state'] == 'active')
|
||||
$this->data->buildDataStruct($this->host,$service['name'],$this->view);
|
||||
foreach ($services as $service) {
|
||||
if ($service['state'] == 'active') {
|
||||
$this->data->buildDataStruct($this->host, $service['name'], $this->view);
|
||||
}
|
||||
}
|
||||
// Special Templates
|
||||
}elseif($this->tpl != ""){
|
||||
$this->data->buildDataStruct('__special',$this->tpl,$this->view);
|
||||
} elseif ($this->tpl != "") {
|
||||
$this->data->buildDataStruct('__special', $this->tpl, $this->view);
|
||||
$this->type = 'special';
|
||||
}else{
|
||||
} else {
|
||||
$this->host = $this->data->getFirstHost();
|
||||
if(isset($this->host)){
|
||||
if (isset($this->host)) {
|
||||
url::redirect("/graph?host=$this->host");
|
||||
}else{
|
||||
} else {
|
||||
throw new Kohana_User_Exception('Hostname not set ;-)', "RTFM my Friend, RTFM!");
|
||||
}
|
||||
}
|
||||
}
|
||||
#throw new Kohana_Exception(print_r($this->data->STRUCT,TRUE));
|
||||
/*
|
||||
@@ -72,53 +91,55 @@ class Pdf_Controller extends System_Controller {
|
||||
$pdf = new PDF("P", "mm", $this->pdf_page_size);
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->SetAutoPageBreak('off');
|
||||
$pdf->SetMargins($this->pdf_margin_left,$this->pdf_margin_top,$this->pdf_margin_right);
|
||||
$pdf->SetMargins($this->pdf_margin_left, $this->pdf_margin_top, $this->pdf_margin_right);
|
||||
$pdf->AddPage();
|
||||
if($this->use_bg){
|
||||
if ($this->use_bg) {
|
||||
$pdf->setSourceFile($this->bg);
|
||||
$tplIdx = $pdf->importPage(1,'/MediaBox');
|
||||
$tplIdx = $pdf->importPage(1, '/MediaBox');
|
||||
$pdf->useTemplate($tplIdx);
|
||||
}
|
||||
$pdf->SetCreator('Created with PNP');
|
||||
$pdf->SetFont('Arial', '', 10);
|
||||
// Title
|
||||
$header = TRUE;
|
||||
foreach($this->data->STRUCT as $key=>$data){
|
||||
if($key != 0){
|
||||
$header = FALSE;
|
||||
}
|
||||
$header = true;
|
||||
foreach ($this->data->STRUCT as $key => $data) {
|
||||
if ($key != 0) {
|
||||
$header = false;
|
||||
}
|
||||
if ($pdf->GetY() > 200) {
|
||||
$pdf->AddPage();
|
||||
if($this->use_bg){$pdf->useTemplate($tplIdx);}
|
||||
}
|
||||
if($this->type == 'normal'){
|
||||
if($data['LEVEL'] == 0){
|
||||
$pdf->SetFont('Arial', '', 12);
|
||||
$pdf->CELL(120, 10, $data['MACRO']['DISP_HOSTNAME']." -- ".$data['MACRO']['DISP_SERVICEDESC'], 0, 1);
|
||||
$pdf->SetFont('Arial', '', 10);
|
||||
$pdf->CELL(120, 5, $data['TIMERANGE']['title']." (".$data['TIMERANGE']['f_start']." - ".$data['TIMERANGE']['f_end'].")", 0, 1);
|
||||
$pdf->SetFont('Arial', '', 8);
|
||||
$pdf->CELL(120, 5, "Datasource ".$data["ds_name"], 0, 1);
|
||||
}else{
|
||||
$pdf->SetFont('Arial', '', 8);
|
||||
$pdf->CELL(120, 5, "Datasource ".$data["ds_name"], 0, 1);
|
||||
if ($this->use_bg) {
|
||||
$pdf->useTemplate($tplIdx);
|
||||
}
|
||||
}elseif($this->type == 'special'){
|
||||
if($header){
|
||||
}
|
||||
if ($this->type == 'normal') {
|
||||
if ($data['LEVEL'] == 0) {
|
||||
$pdf->SetFont('Arial', '', 12);
|
||||
$pdf->CELL(120, 10, $data['MACRO']['DISP_HOSTNAME'] . " -- " . $data['MACRO']['DISP_SERVICEDESC'], 0, 1);
|
||||
$pdf->SetFont('Arial', '', 10);
|
||||
$pdf->CELL(120, 5, $data['TIMERANGE']['title'] . " (" . $data['TIMERANGE']['f_start'] . " - " . $data['TIMERANGE']['f_end'] . ")", 0, 1);
|
||||
$pdf->SetFont('Arial', '', 8);
|
||||
$pdf->CELL(120, 5, "Datasource " . $data["ds_name"], 0, 1);
|
||||
} else {
|
||||
$pdf->SetFont('Arial', '', 8);
|
||||
$pdf->CELL(120, 5, "Datasource " . $data["ds_name"], 0, 1);
|
||||
}
|
||||
} elseif ($this->type == 'special') {
|
||||
if ($header) {
|
||||
$pdf->SetFont('Arial', '', 12);
|
||||
$pdf->CELL(120, 10, $data['MACRO']['TITLE'], 0, 1);
|
||||
$pdf->SetFont('Arial', '', 10);
|
||||
$pdf->CELL(120, 5, $data['TIMERANGE']['title']." (".$data['TIMERANGE']['f_start']." - ".$data['TIMERANGE']['f_end'].")", 0, 1);
|
||||
$pdf->CELL(120, 5, $data['TIMERANGE']['title'] . " (" . $data['TIMERANGE']['f_start'] . " - " . $data['TIMERANGE']['f_end'] . ")", 0, 1);
|
||||
$pdf->SetFont('Arial', '', 8);
|
||||
$pdf->CELL(120, 5, "Datasource ".$data["ds_name"], 0, 1);
|
||||
}else{
|
||||
$pdf->CELL(120, 5, "Datasource " . $data["ds_name"], 0, 1);
|
||||
} else {
|
||||
$pdf->SetFont('Arial', '', 10);
|
||||
$pdf->CELL(120, 5, $data['TIMERANGE']['title']." (".$data['TIMERANGE']['f_start']." - ".$data['TIMERANGE']['f_end'].")", 0, 1);
|
||||
$pdf->CELL(120, 5, $data['TIMERANGE']['title'] . " (" . $data['TIMERANGE']['f_start'] . " - " . $data['TIMERANGE']['f_end'] . ")", 0, 1);
|
||||
$pdf->SetFont('Arial', '', 8);
|
||||
$pdf->CELL(120, 5, "Datasource ".$data["ds_name"], 0, 1);
|
||||
$pdf->CELL(120, 5, "Datasource " . $data["ds_name"], 0, 1);
|
||||
}
|
||||
}
|
||||
$image = $this->rrdtool->doImage($data['RRD_CALL'],$out='PDF');
|
||||
$image = $this->rrdtool->doImage($data['RRD_CALL'], $out = 'PDF');
|
||||
$img = $this->rrdtool->saveImage($image);
|
||||
$Y = $pdf->GetY();
|
||||
$cell_height = ($img['height'] * 0.23);
|
||||
@@ -127,25 +148,25 @@ class Pdf_Controller extends System_Controller {
|
||||
$pdf->CELL(120, $cell_height, '', 0, 1);
|
||||
unlink($img['file']);
|
||||
}
|
||||
$pdf->Output("pnp4nagios.pdf","I");
|
||||
|
||||
$pdf->Output("pnp4nagios.pdf", "I");
|
||||
}
|
||||
|
||||
public function page($page){
|
||||
public function page($page)
|
||||
{
|
||||
$this->start = $this->input->get('start');
|
||||
$this->end = $this->input->get('end');
|
||||
$this->view = "";
|
||||
|
||||
if(isset($_GET['view']) && $_GET['view'] != "" ){
|
||||
if (isset($_GET['view']) && $_GET['view'] != "") {
|
||||
$this->view = pnp::clean($_GET['view']);
|
||||
}
|
||||
|
||||
$this->data->getTimeRange($this->start,$this->end,$this->view);
|
||||
$this->data->buildPageStruct($page,$this->view);
|
||||
$this->data->getTimeRange($this->start, $this->end, $this->view);
|
||||
$this->data->buildPageStruct($page, $this->view);
|
||||
// Define PDF background per url option
|
||||
if(isset($this->data->PAGE_DEF['background_pdf'])){
|
||||
if( is_readable( Kohana::config( 'core.pnp_etc_path')."/".$this->data->PAGE_DEF['background_pdf'] ) ){
|
||||
$this->bg = Kohana::config('core.pnp_etc_path')."/".$this->data->PAGE_DEF['background_pdf'];
|
||||
if (isset($this->data->PAGE_DEF['background_pdf'])) {
|
||||
if (is_readable(Kohana::config('core.pnp_etc_path') . "/" . $this->data->PAGE_DEF['background_pdf'])) {
|
||||
$this->bg = Kohana::config('core.pnp_etc_path') . "/" . $this->data->PAGE_DEF['background_pdf'];
|
||||
}
|
||||
}
|
||||
/*
|
||||
@@ -154,34 +175,36 @@ class Pdf_Controller extends System_Controller {
|
||||
$pdf = new PDF("P", "mm", $this->pdf_page_size);
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->SetAutoPageBreak('off');
|
||||
$pdf->SetMargins($this->pdf_margin_left,$this->pdf_margin_top,$this->pdf_margin_right);
|
||||
$pdf->SetMargins($this->pdf_margin_left, $this->pdf_margin_top, $this->pdf_margin_right);
|
||||
$pdf->AddPage();
|
||||
if($this->use_bg){
|
||||
if ($this->use_bg) {
|
||||
$pdf->setSourceFile($this->bg);
|
||||
$tplIdx = $pdf->importPage(1,'/MediaBox');
|
||||
$tplIdx = $pdf->importPage(1, '/MediaBox');
|
||||
$pdf->useTemplate($tplIdx);
|
||||
}
|
||||
|
||||
$pdf->SetCreator('Created with PNP');
|
||||
$pdf->SetFont('Arial', '', 10);
|
||||
// Title
|
||||
foreach($this->data->STRUCT as $data){
|
||||
foreach ($this->data->STRUCT as $data) {
|
||||
if ($pdf->GetY() > 200) {
|
||||
$pdf->AddPage();
|
||||
if($this->use_bg){$pdf->useTemplate($tplIdx);}
|
||||
if ($this->use_bg) {
|
||||
$pdf->useTemplate($tplIdx);
|
||||
}
|
||||
}
|
||||
if($data['LEVEL'] == 0){
|
||||
if ($data['LEVEL'] == 0) {
|
||||
$pdf->SetFont('Arial', '', 12);
|
||||
$pdf->CELL(120, 10, $data['MACRO']['DISP_HOSTNAME']." -- ".$data['MACRO']['DISP_SERVICEDESC'], 0, 1);
|
||||
$pdf->CELL(120, 10, $data['MACRO']['DISP_HOSTNAME'] . " -- " . $data['MACRO']['DISP_SERVICEDESC'], 0, 1);
|
||||
$pdf->SetFont('Arial', '', 10);
|
||||
$pdf->CELL(120, 5, $data['TIMERANGE']['title']." (".$data['TIMERANGE']['f_start']." - ".$data['TIMERANGE']['f_end'].")", 0, 1);
|
||||
$pdf->CELL(120, 5, $data['TIMERANGE']['title'] . " (" . $data['TIMERANGE']['f_start'] . " - " . $data['TIMERANGE']['f_end'] . ")", 0, 1);
|
||||
$pdf->SetFont('Arial', '', 8);
|
||||
$pdf->CELL(120, 5, "Datasource ".$data["ds_name"], 0, 1);
|
||||
}else{
|
||||
$pdf->CELL(120, 5, "Datasource " . $data["ds_name"], 0, 1);
|
||||
} else {
|
||||
$pdf->SetFont('Arial', '', 8);
|
||||
$pdf->CELL(120, 5, "Datasource ".$data["ds_name"], 0, 1);
|
||||
$pdf->CELL(120, 5, "Datasource " . $data["ds_name"], 0, 1);
|
||||
}
|
||||
$image = $this->rrdtool->doImage($data['RRD_CALL'],$out='PDF');
|
||||
$image = $this->rrdtool->doImage($data['RRD_CALL'], $out = 'PDF');
|
||||
$img = $this->rrdtool->saveImage($image);
|
||||
$Y = $pdf->GetY();
|
||||
$cell_height = ($img['height'] * 0.23);
|
||||
@@ -190,20 +213,21 @@ class Pdf_Controller extends System_Controller {
|
||||
$pdf->CELL(120, $cell_height, '', 0, 1);
|
||||
unlink($img['file']);
|
||||
}
|
||||
$pdf->Output("pnp4nagios.pdf","I");
|
||||
$pdf->Output("pnp4nagios.pdf", "I");
|
||||
}
|
||||
|
||||
public function basket(){
|
||||
public function basket()
|
||||
{
|
||||
$this->start = $this->input->get('start');
|
||||
$this->end = $this->input->get('end');
|
||||
$this->view = "";
|
||||
if(isset($_GET['view']) && $_GET['view'] != "" ){
|
||||
if (isset($_GET['view']) && $_GET['view'] != "") {
|
||||
$this->view = pnp::clean($_GET['view']);
|
||||
}
|
||||
$this->data->getTimeRange($this->start,$this->end,$this->view);
|
||||
$this->data->getTimeRange($this->start, $this->end, $this->view);
|
||||
$basket = $this->session->get("basket");
|
||||
if(is_array($basket) && sizeof($basket) > 0){
|
||||
$this->data->buildBasketStruct($basket,$this->view);
|
||||
if (is_array($basket) && (!empty($basket))) {
|
||||
$this->data->buildBasketStruct($basket, $this->view);
|
||||
}
|
||||
//echo Kohana::debug($this->data->STRUCT);
|
||||
/*
|
||||
@@ -212,34 +236,36 @@ class Pdf_Controller extends System_Controller {
|
||||
$pdf = new PDF("P", "mm", $this->pdf_page_size);
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->SetAutoPageBreak('off');
|
||||
$pdf->SetMargins($this->pdf_margin_left,$this->pdf_margin_top,$this->pdf_margin_right);
|
||||
$pdf->SetMargins($this->pdf_margin_left, $this->pdf_margin_top, $this->pdf_margin_right);
|
||||
$pdf->AddPage();
|
||||
if($this->use_bg){
|
||||
if ($this->use_bg) {
|
||||
$pdf->setSourceFile($this->config->conf['background_pdf']);
|
||||
$tplIdx = $pdf->importPage(1,'/MediaBox');
|
||||
$tplIdx = $pdf->importPage(1, '/MediaBox');
|
||||
$pdf->useTemplate($tplIdx);
|
||||
}
|
||||
|
||||
$pdf->SetCreator('Created with PNP');
|
||||
$pdf->SetFont('Arial', '', 10);
|
||||
// Title
|
||||
foreach($this->data->STRUCT as $data){
|
||||
foreach ($this->data->STRUCT as $data) {
|
||||
if ($pdf->GetY() > 200) {
|
||||
$pdf->AddPage();
|
||||
if($this->use_bg){$pdf->useTemplate($tplIdx);}
|
||||
if ($this->use_bg) {
|
||||
$pdf->useTemplate($tplIdx);
|
||||
}
|
||||
}
|
||||
if($data['LEVEL'] == 0){
|
||||
if ($data['LEVEL'] == 0) {
|
||||
$pdf->SetFont('Arial', '', 12);
|
||||
$pdf->CELL(120, 10, $data['MACRO']['DISP_HOSTNAME']." -- ".$data['MACRO']['DISP_SERVICEDESC'], 0, 1);
|
||||
$pdf->CELL(120, 10, $data['MACRO']['DISP_HOSTNAME'] . " -- " . $data['MACRO']['DISP_SERVICEDESC'], 0, 1);
|
||||
$pdf->SetFont('Arial', '', 10);
|
||||
$pdf->CELL(120, 5, $data['TIMERANGE']['title']." (".$data['TIMERANGE']['f_start']." - ".$data['TIMERANGE']['f_end'].")", 0, 1);
|
||||
$pdf->CELL(120, 5, $data['TIMERANGE']['title'] . " (" . $data['TIMERANGE']['f_start'] . " - " . $data['TIMERANGE']['f_end'] . ")", 0, 1);
|
||||
$pdf->SetFont('Arial', '', 8);
|
||||
$pdf->CELL(120, 5, "Datasource ".$data["ds_name"], 0, 1);
|
||||
}else{
|
||||
$pdf->CELL(120, 5, "Datasource " . $data["ds_name"], 0, 1);
|
||||
} else {
|
||||
$pdf->SetFont('Arial', '', 8);
|
||||
$pdf->CELL(120, 5, "Datasource ".$data["ds_name"], 0, 1);
|
||||
$pdf->CELL(120, 5, "Datasource " . $data["ds_name"], 0, 1);
|
||||
}
|
||||
$image = $this->rrdtool->doImage($data['RRD_CALL'],$out='PDF');
|
||||
$image = $this->rrdtool->doImage($data['RRD_CALL'], $out = 'PDF');
|
||||
$img = $this->rrdtool->saveImage($image);
|
||||
$Y = $pdf->GetY();
|
||||
$cell_height = ($img['height'] * 0.23);
|
||||
@@ -248,8 +274,7 @@ class Pdf_Controller extends System_Controller {
|
||||
$pdf->CELL(120, $cell_height, '', 0, 1);
|
||||
unlink($img['file']);
|
||||
}
|
||||
$pdf->Output("pnp4nagios.pdf","I");
|
||||
|
||||
$pdf->Output("pnp4nagios.pdf", "I");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,23 +283,29 @@ class Pdf_Controller extends System_Controller {
|
||||
+
|
||||
*
|
||||
*/
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
require Kohana::find_file('vendor/fpdf', 'fpdf');
|
||||
require Kohana::find_file('vendor/fpdf', 'fpdi');
|
||||
class PDF extends FPDI {
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses
|
||||
|
||||
class PDF extends FPDI
|
||||
{
|
||||
//Page header
|
||||
function Header() {
|
||||
//Arial bold 10
|
||||
$this->SetFont('Arial', 'B', 10);
|
||||
}
|
||||
public function Header()
|
||||
{
|
||||
//Arial bold 10
|
||||
$this->SetFont('Arial', 'B', 10);
|
||||
}
|
||||
|
||||
//Page footer
|
||||
function Footer() {
|
||||
//Position at 1.5 cm from bottom
|
||||
$this->SetY(-20);
|
||||
//Arial italic 8
|
||||
$this->SetFont('Arial', 'I', 8);
|
||||
//Page number
|
||||
$this->Cell(0, 10, $this->PageNo() . '/{nb}', 0, 0, 'C');
|
||||
public function Footer()
|
||||
{
|
||||
//Position at 1.5 cm from bottom
|
||||
$this->SetY(-20);
|
||||
//Arial italic 8
|
||||
$this->SetFont('Arial', 'I', 8);
|
||||
//Page number
|
||||
$this->Cell(0, 10, $this->PageNo() . '/{nb}', 0, 0, 'C');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
/**
|
||||
* Popup controller.
|
||||
*
|
||||
* @package PNP4Nagios
|
||||
* @author Joerg Linge
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class Popup_Controller extends System_Controller {
|
||||
|
||||
|
||||
class Popup_Controller extends System_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -17,16 +22,16 @@ class Popup_Controller extends System_Controller {
|
||||
|
||||
public function index()
|
||||
{
|
||||
if ( $this->view == "" ){
|
||||
if ($this->view == "") {
|
||||
$this->view = $this->config->conf['overview-range'];
|
||||
}
|
||||
|
||||
$this->imgwidth = pnp::clean($this->input->get('width',$this->config->conf['popup-width']));
|
||||
$this->imgwidth = pnp::clean($this->input->get('width', $this->config->conf['popup-width']));
|
||||
|
||||
$this->data->getTimeRange($this->start,$this->end,$this->view);
|
||||
$this->data->getTimeRange($this->start, $this->end, $this->view);
|
||||
|
||||
if(isset($this->host) && isset($this->service)){
|
||||
$this->data->buildDataStruct($this->host,$this->service,$this->view,$this->source);
|
||||
if (isset($this->host) && isset($this->service)) {
|
||||
$this->data->buildDataStruct($this->host, $this->service, $this->view, $this->source);
|
||||
$this->template->host = $this->host;
|
||||
$this->template->srv = $this->service;
|
||||
$this->template->view = $this->view;
|
||||
@@ -34,7 +39,7 @@ class Popup_Controller extends System_Controller {
|
||||
$this->template->end = $this->end;
|
||||
$this->template->start = $this->start;
|
||||
$this->template->imgwidth = $this->imgwidth;
|
||||
}else{
|
||||
} else {
|
||||
url::redirect("/graph");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
|
||||
/**
|
||||
* Graph controller.
|
||||
*
|
||||
@@ -6,8 +13,8 @@
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class Special_Controller extends System_Controller {
|
||||
|
||||
class Special_Controller extends System_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -15,18 +22,20 @@ class Special_Controller extends System_Controller {
|
||||
$this->template->graph = $this->add_view('graph');
|
||||
$this->templates = $this->data->getSpecialTemplates();
|
||||
$this->data->GRAPH_TYPE = 'special';
|
||||
if($this->tpl == ''){
|
||||
if($this->templates)
|
||||
if ($this->tpl == '') {
|
||||
if ($this->templates) {
|
||||
$this->tpl = $this->templates[0];
|
||||
url::redirect('special?tpl='.$this->tpl, 302);
|
||||
}
|
||||
url::redirect('special?tpl=' . $this->tpl, 302);
|
||||
}
|
||||
}
|
||||
|
||||
public function index(){
|
||||
$this->url = "?tpl=".$this->tpl;
|
||||
public function index()
|
||||
{
|
||||
$this->url = "?tpl=" . $this->tpl;
|
||||
$this->template->zoom_header = $this->add_view('zoom_header');
|
||||
$this->template->zoom_header->graph_width = ($this->config->conf['graph_width'] + 140);
|
||||
$this->template->zoom_header->graph_height = ($this->config->conf['graph_height'] + 230);
|
||||
$this->template->zoom_header->graph_width = ($this->config->conf['zgraph_width'] + 140);
|
||||
$this->template->zoom_header->graph_height = ($this->config->conf['zgraph_height'] + 230);
|
||||
$this->template->graph->graph_content = $this->add_view('graph_content_special');
|
||||
$this->template->graph->graph_content->graph_width = ($this->config->conf['graph_width'] + 85);
|
||||
$this->template->graph->graph_content->timerange_select = $this->add_view('timerange_select');
|
||||
@@ -38,7 +47,7 @@ class Special_Controller extends System_Controller {
|
||||
$this->template->graph->widget_menu = $this->add_view('widget_menu');
|
||||
$this->template->graph->graph_content->widget_graph = $this->add_view('widget_graph');
|
||||
#print Kohana::debug($services);
|
||||
$this->data->buildDataStruct('__special',$this->tpl,$this->view);
|
||||
$this->data->buildDataStruct('__special', $this->tpl, $this->view);
|
||||
$this->template->graph->icon_box = $this->add_view('icon_box');
|
||||
$this->template->graph->icon_box->position = "special";
|
||||
$this->template->graph->logo_box = $this->add_view('logo_box');
|
||||
@@ -48,5 +57,4 @@ class Special_Controller extends System_Controller {
|
||||
$this->template->graph->header->title = $this->data->MACRO['TITLE'];
|
||||
//print Kohana::debug($this->data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
|
||||
/**
|
||||
* Default controller.
|
||||
*
|
||||
* @package pnp4nagios
|
||||
* @package pnp4nagios
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class Start_Controller extends System_Controller {
|
||||
|
||||
class Start_Controller extends System_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -17,5 +24,4 @@ class Start_Controller extends System_Controller {
|
||||
{
|
||||
url::redirect("graph", 302);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,210 +1,260 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
|
||||
/**
|
||||
* system controller.
|
||||
*
|
||||
* @package pnp4nagios
|
||||
* @package pnp4nagios
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class System_Controller extends Template_Controller {
|
||||
class System_Controller extends Template_Controller
|
||||
{
|
||||
public $data = '';
|
||||
|
||||
public $config = '';
|
||||
|
||||
public $rrdtool = '';
|
||||
|
||||
public $auth = '';
|
||||
|
||||
public $start = '';
|
||||
|
||||
public $end = '';
|
||||
|
||||
public $theme = '';
|
||||
|
||||
public $view = '';
|
||||
|
||||
public $host = '';
|
||||
|
||||
public $service = '';
|
||||
|
||||
public $source = '';
|
||||
|
||||
public $version = '';
|
||||
|
||||
public $tpl = '';
|
||||
|
||||
public $controller = '';
|
||||
|
||||
public $session = '';
|
||||
|
||||
public $url = '';
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->data = new Data_Model();
|
||||
$this->config = new Config_Model();
|
||||
$this->rrdtool = new Rrdtool_Model();
|
||||
$this->auth = new Auth_Model();
|
||||
#$this->system = new System_Model();
|
||||
|
||||
$this->data = new Data_Model();
|
||||
$this->config = new Config_Model();
|
||||
$this->rrdtool = new Rrdtool_Model();
|
||||
$this->auth = new Auth_Model();
|
||||
// $this->system = new System_Model();
|
||||
$this->config->read_config();
|
||||
Kohana::config_set('locale.language',$this->config->conf['lang']);
|
||||
Kohana::config_set('locale.language', $this->config->conf['lang']);
|
||||
// Check for mod_rewrite
|
||||
$this->check_mod_rewrite();
|
||||
|
||||
$this->start = $this->input->get('start',FALSE);
|
||||
$this->end = $this->input->get('end',FALSE);
|
||||
$this->theme = pnp::clean($this->input->get('theme',FALSE));
|
||||
$this->view = pnp::clean($this->input->get('view', ""));
|
||||
$this->host = pnp::clean($this->input->get('host',NULL));
|
||||
$this->service = pnp::clean($this->input->get('srv',NULL));
|
||||
$this->source = pnp::clean($this->input->get('source',NULL));
|
||||
$this->version = pnp::clean($this->input->get('version',NULL));
|
||||
$this->tpl = pnp::clean($this->input->get('tpl'));
|
||||
$this->controller = Router::$controller;
|
||||
$this->start = $this->input->get('start', false);
|
||||
$this->end = $this->input->get('end', false);
|
||||
$this->theme = pnp::clean($this->input->get('theme', false));
|
||||
$this->view = pnp::clean($this->input->get('view', ''));
|
||||
$this->host = pnp::clean($this->input->get('host', null));
|
||||
$this->service = pnp::clean($this->input->get('srv', null));
|
||||
$this->source = pnp::clean($this->input->get('source', null));
|
||||
$this->version = pnp::clean($this->input->get('version', null));
|
||||
$this->tpl = pnp::clean($this->input->get('tpl'));
|
||||
$this->controller = Router::$controller;
|
||||
|
||||
$this->data->getTimeRange($this->start,$this->end,$this->view);
|
||||
if(Router::$controller != "image" && Router::$controller != "image_special"){
|
||||
$this->data->getTimeRange($this->start, $this->end, $this->view);
|
||||
if (! in_array(Router::$controller, ['image', 'image_special', 'xport'])) {
|
||||
$this->session = Session::instance();
|
||||
|
||||
# Session withou theme info
|
||||
if($this->session->get("theme","new") == "new"){
|
||||
if($this->theme){
|
||||
# store $this->theme if available
|
||||
Kohana::config_set('core.theme',$this->theme);
|
||||
$this->session->set('theme', $this->theme );
|
||||
}else{
|
||||
# set $this->theme to default value
|
||||
$this->theme = $this->config->conf['ui-theme'];
|
||||
Kohana::config_set('core.theme',$this->theme);
|
||||
}
|
||||
# Sesion with theme info
|
||||
}else{
|
||||
if($this->theme && $this->theme != 'default'){
|
||||
# store $this->theme if available
|
||||
$this->session->set('theme', $this->theme );
|
||||
Kohana::config_set('core.theme',$this->theme);
|
||||
}elseif($this->theme == 'default'){
|
||||
# reset to default theme
|
||||
$this->theme = $this->config->conf['ui-theme'];
|
||||
$this->session->set('theme', $this->theme );
|
||||
Kohana::config_set('core.theme',$this->theme);
|
||||
}else{
|
||||
# set $this->theme with session infos
|
||||
$this->theme = $this->session->get('theme');
|
||||
Kohana::config_set('core.theme',$this->theme);
|
||||
}
|
||||
}
|
||||
// Initialize CSRF Token
|
||||
$this->session->set('csrf_token', Security::token());
|
||||
|
||||
if($this->start && $this->end ){
|
||||
if($this->session->get('timerange-reset',0) == 0){
|
||||
$this->session->set("start", $this->start);
|
||||
$this->session->set("end", $this->end);
|
||||
}else{
|
||||
// Session withou theme info
|
||||
if ($this->session->get('theme', 'new') == 'new') {
|
||||
if ($this->theme) {
|
||||
// store $this->theme if available
|
||||
Kohana::config_set('core.theme', $this->theme);
|
||||
$this->session->set('theme', $this->theme);
|
||||
} else {
|
||||
// set $this->theme to default value
|
||||
$this->theme = $this->config->conf['ui-theme'];
|
||||
Kohana::config_set('core.theme', $this->theme);
|
||||
}
|
||||
// Sesion with theme info
|
||||
} else {
|
||||
if ($this->theme && $this->theme != 'default') {
|
||||
// store $this->theme if available
|
||||
$this->session->set('theme', $this->theme);
|
||||
Kohana::config_set('core.theme', $this->theme);
|
||||
} elseif ($this->theme == 'default') {
|
||||
// reset to default theme
|
||||
$this->theme = $this->config->conf['ui-theme'];
|
||||
$this->session->set('theme', $this->theme);
|
||||
Kohana::config_set('core.theme', $this->theme);
|
||||
} else {
|
||||
// set $this->theme with session infos
|
||||
$this->theme = $this->session->get('theme');
|
||||
Kohana::config_set('core.theme', $this->theme);
|
||||
}
|
||||
}
|
||||
//end if
|
||||
|
||||
if ($this->start && $this->end) {
|
||||
if ($this->session->get('timerange-reset', 0) == 0) {
|
||||
$this->session->set('start', $this->start);
|
||||
$this->session->set('end', $this->end);
|
||||
} else {
|
||||
$this->session->set('timerange-reset', 0);
|
||||
}
|
||||
}
|
||||
if($this->start && !$this->end){
|
||||
if($this->session->get('timerange-reset',0) == 0){
|
||||
$this->session->set("start", $this->start);
|
||||
$this->session->set("end", "");
|
||||
}else{
|
||||
if ($this->start && !$this->end) {
|
||||
if ($this->session->get('timerange-reset', 0) == 0) {
|
||||
$this->session->set('start', $this->start);
|
||||
$this->session->set('end', '');
|
||||
} else {
|
||||
$this->session->set('timerange-reset', 0);
|
||||
}
|
||||
}
|
||||
if($this->end && !$this->start){
|
||||
if($this->session->get('timerange-reset',0) == 0){
|
||||
$this->session->set("end", $this->end);
|
||||
$this->session->set("start", "");
|
||||
}else{
|
||||
if ($this->end && !$this->start) {
|
||||
if ($this->session->get('timerange-reset', 0) == 0) {
|
||||
$this->session->set('end', $this->end);
|
||||
$this->session->set('start', '');
|
||||
} else {
|
||||
$this->session->set('timerange-reset', 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
//end if
|
||||
}
|
||||
//end __construct()
|
||||
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
// Disable auto-rendering
|
||||
$this->auto_render = FALSE;
|
||||
$this->auto_render = false;
|
||||
|
||||
// By defining a __call method, all pages routed to this controller
|
||||
// that result in 404 errors will be handled by this method, instead of
|
||||
// being displayed as "Page Not Found" errors.
|
||||
echo $this->_("The requested page doesn't exist") . " ($method)";
|
||||
}
|
||||
//end __call()
|
||||
|
||||
|
||||
/**
|
||||
* Handle paths to current theme etc
|
||||
*
|
||||
*/
|
||||
public function add_view($view=false)
|
||||
public function add_view($view = false)
|
||||
{
|
||||
$view = trim($view);
|
||||
if (empty($view)) {
|
||||
return false;
|
||||
}
|
||||
if (!file_exists(APPPATH."/views/".$view.".php")) {
|
||||
if (!file_exists(APPPATH . '/views/' . $view . '.php')) {
|
||||
return false;
|
||||
}
|
||||
#return new View($this->theme_path.$view);
|
||||
// return new View($this->theme_path.$view);
|
||||
return new View($view);
|
||||
}
|
||||
//end add_view()
|
||||
|
||||
public function check_mod_rewrite(){
|
||||
if(!function_exists('apache_get_modules')){
|
||||
// Add index.php to every URL while not running withn apache mod_php
|
||||
Kohana::config_set('core.index_page','index.php');
|
||||
return TRUE;
|
||||
|
||||
public function check_mod_rewrite()
|
||||
{
|
||||
if (!function_exists('apache_get_modules')) {
|
||||
// Add index.php to every URL while not running withn apache mod_php
|
||||
Kohana::config_set('core.index_page', 'index.php');
|
||||
return true;
|
||||
}
|
||||
if(!in_array('mod_rewrite', apache_get_modules())){
|
||||
if (!in_array('mod_rewrite', apache_get_modules())) {
|
||||
// Add index.php to every URL while mod_rewrite is not available
|
||||
Kohana::config_set('core.index_page','index.php');
|
||||
Kohana::config_set('core.index_page', 'index.php');
|
||||
}
|
||||
if ( $this->config->conf['use_url_rewriting'] == 0 ){
|
||||
Kohana::config_set('core.index_page','index.php');
|
||||
if ($this->config->conf['use_url_rewriting'] == 0) {
|
||||
Kohana::config_set('core.index_page', 'index.php');
|
||||
}
|
||||
}
|
||||
//end check_mod_rewrite()
|
||||
|
||||
public function isAuthorizedFor($auth) {
|
||||
|
||||
public function isAuthorizedFor($auth)
|
||||
{
|
||||
$conf = $this->config->conf;
|
||||
if ($auth == "service_links") {
|
||||
if ($auth == 'service_links') {
|
||||
$users = explode(',', $conf['allowed_for_service_links']);
|
||||
if (in_array('EVERYONE', $users)) {
|
||||
return 1;
|
||||
} elseif (in_array('NONE', $users)) {
|
||||
return 0;
|
||||
} elseif (in_array($this->auth->REMOTE_USER, $users)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ($auth == 'host_search') {
|
||||
$users = explode(',', $conf['allowed_for_host_search']);
|
||||
if (in_array('EVERYONE', $users)) {
|
||||
return 1;
|
||||
} elseif (in_array('NONE', $users)) {
|
||||
return 0;
|
||||
} elseif (in_array($this->auth->REMOTE_USER, $users)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ($auth == 'host_overview') {
|
||||
$users = explode(',', $conf['allowed_for_host_overview']);
|
||||
if (in_array('EVERYONE', $users)) {
|
||||
return 1;
|
||||
} elseif (in_array('NONE', $users)) {
|
||||
return 0;
|
||||
} elseif (in_array($this->auth->REMOTE_USER, $users)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ($auth == 'pages') {
|
||||
$users = explode(',', $conf['allowed_for_pages']);
|
||||
if (in_array('EVERYONE', $users)) {
|
||||
return 1;
|
||||
} elseif (in_array('NONE', $users)) {
|
||||
return 0;
|
||||
} elseif (in_array($this->auth->REMOTE_USER, $users)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
//end isAuthorizedFor()
|
||||
|
||||
$users = explode(",", $conf['allowed_for_service_links']);
|
||||
if (in_array('EVERYONE', $users)) {
|
||||
return 1;
|
||||
}
|
||||
elseif (in_array('NONE', $users)) {
|
||||
return 0;
|
||||
}
|
||||
elseif (in_array($this->auth->REMOTE_USER, $users)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function isMobileDevice()
|
||||
{
|
||||
if ($this->session->get('classic-ui', 0) == 1) {
|
||||
return false;
|
||||
}
|
||||
if ($auth == "host_search") {
|
||||
$users = explode(",", $conf['allowed_for_host_search']);
|
||||
if (in_array('EVERYONE', $users)) {
|
||||
return 1;
|
||||
}
|
||||
elseif (in_array('NONE', $users)) {
|
||||
return 0;
|
||||
}
|
||||
elseif (in_array($this->auth->REMOTE_USER, $users)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
if (preg_match('/' . $this->config->conf['mobile_devices'] . '/', $_SERVER['HTTP_USER_AGENT'])) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if ($auth == "host_overview") {
|
||||
$users = explode(",", $conf['allowed_for_host_overview']);
|
||||
if (in_array('EVERYONE', $users)) {
|
||||
return 1;
|
||||
}
|
||||
elseif (in_array('NONE', $users)) {
|
||||
return 0;
|
||||
}
|
||||
elseif (in_array($this->auth->REMOTE_USER, $users)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ($auth == "pages") {
|
||||
$users = explode(",", $conf['allowed_for_pages']);
|
||||
if (in_array('EVERYONE', $users)) {
|
||||
return 1;
|
||||
}
|
||||
elseif (in_array('NONE', $users)) {
|
||||
return 0;
|
||||
}
|
||||
elseif (in_array($this->auth->REMOTE_USER, $users)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public function isMobileDevice (){
|
||||
if( $this->session->get('classic-ui',0) == 1){
|
||||
return FALSE;
|
||||
}
|
||||
if ( preg_match('/'.$this->config->conf['mobile_devices'].'/', $_SERVER['HTTP_USER_AGENT'] ) ){
|
||||
return TRUE;
|
||||
}else{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
//end isMobileDevice()
|
||||
}
|
||||
//end class
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
|
||||
/**
|
||||
* Xml controller.
|
||||
*
|
||||
@@ -6,8 +13,8 @@
|
||||
* @author Jorg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class Xml_Controller extends System_Controller {
|
||||
|
||||
class Xml_Controller extends System_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -16,27 +23,27 @@ class Xml_Controller extends System_Controller {
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->auto_render = FALSE;
|
||||
if($this->service == "" && $this->host == ""){
|
||||
$this->auto_render = false;
|
||||
if ($this->service == "" && $this->host == "") {
|
||||
url::redirect("graph", 302);
|
||||
}
|
||||
$this->data->readXML($this->host, $this->service);
|
||||
if($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === FALSE){
|
||||
if ($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === false) {
|
||||
header('Content-Type: application/xml');
|
||||
print "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
|
||||
print "<NAGIOS>\n";
|
||||
print "<ERROR>not authorized</ERROR>\n";
|
||||
print "</NAGIOS>\n";
|
||||
exit;
|
||||
}else{
|
||||
$xmlfile = $this->config->conf['rrdbase'].$this->host."/".$this->service.".xml";
|
||||
if(is_readable($xmlfile)){
|
||||
} else {
|
||||
$xmlfile = $this->config->conf['rrdbase'] . $this->host . "/" . $this->service . ".xml";
|
||||
if (is_readable($xmlfile)) {
|
||||
$fh = fopen($xmlfile, 'r');
|
||||
header('Content-Type: application/xml');
|
||||
fpassthru($fh);
|
||||
fclose($fh);
|
||||
exit;
|
||||
}else{
|
||||
} else {
|
||||
header('Content-Type: application/xml');
|
||||
print "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
|
||||
print "<NAGIOS>\n";
|
||||
|
||||
@@ -1,26 +1,33 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
|
||||
/**
|
||||
* Xport controller.
|
||||
*
|
||||
*
|
||||
* @package pnp4nagios
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class Xport_Controller extends System_Controller {
|
||||
|
||||
class Xport_Controller extends System_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// Disable auto-rendering
|
||||
$this->auto_render = FALSE;
|
||||
$this->data->getTimeRange($this->start,$this->end,$this->view);
|
||||
|
||||
$this->auto_render = false;
|
||||
$this->data->getTimeRange($this->start, $this->end, $this->view);
|
||||
}
|
||||
|
||||
public function xml(){
|
||||
if(isset($this->host) && isset($this->service)){
|
||||
$this->data->buildXport($this->host,$this->service);
|
||||
if($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === FALSE){
|
||||
public function xml()
|
||||
{
|
||||
if (isset($this->host) && isset($this->service)) {
|
||||
$this->data->buildXport($this->host, $this->service);
|
||||
if ($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === false) {
|
||||
header('Content-Type: application/xml');
|
||||
print "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
|
||||
print "<NAGIOS>\n";
|
||||
@@ -30,45 +37,45 @@ class Xport_Controller extends System_Controller {
|
||||
}
|
||||
$data = $this->rrdtool->doXport($this->data->XPORT);
|
||||
header('Content-Type: application/xml');
|
||||
print $data;
|
||||
}else{
|
||||
print $data;
|
||||
} else {
|
||||
throw new Kohana_Exception('error.xport-host-service');
|
||||
}
|
||||
}
|
||||
|
||||
public function json(){
|
||||
if(isset($this->host) && isset($this->service)){
|
||||
$this->data->buildXport($this->host,$this->service);
|
||||
if($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === FALSE){
|
||||
public function json()
|
||||
{
|
||||
if (isset($this->host) && isset($this->service)) {
|
||||
$this->data->buildXport($this->host, $this->service);
|
||||
if ($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === false) {
|
||||
header('Content-type: application/json');
|
||||
print json_encode("not authorized");
|
||||
print json_encode("not authorized");
|
||||
exit;
|
||||
}
|
||||
$data = $this->rrdtool->doXport($this->data->XPORT);
|
||||
$json = json_encode(simplexml_load_string($data));
|
||||
header('Content-type: application/json');
|
||||
print $json;
|
||||
}else{
|
||||
print $json;
|
||||
} else {
|
||||
throw new Kohana_Exception('error.xport-host-service');
|
||||
}
|
||||
}
|
||||
|
||||
public function csv(){
|
||||
if(isset($this->host) && isset($this->service)){
|
||||
$this->data->buildXport($this->host,$this->service);
|
||||
if($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === FALSE){
|
||||
public function csv()
|
||||
{
|
||||
if (isset($this->host) && isset($this->service)) {
|
||||
$this->data->buildXport($this->host, $this->service);
|
||||
if ($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === false) {
|
||||
header("Content-Type: text/plain; charset=UTF-8");
|
||||
print "not authorized";
|
||||
print "not authorized";
|
||||
exit;
|
||||
}
|
||||
$data = $this->rrdtool->doXport($this->data->XPORT);
|
||||
$csv = $this->data->xml2csv($data);
|
||||
header("Content-Type: text/plain; charset=UTF-8");
|
||||
print $csv;
|
||||
}else{
|
||||
} else {
|
||||
throw new Kohana_Exception('error.xport-host-service');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
<?php
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('SYSPATH') or die('No direct access allowed.');
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
||||
|
||||
|
||||
/**
|
||||
* Zoom controller.
|
||||
*
|
||||
* @package PNP4Nagios
|
||||
* @author Joerg Linge
|
||||
* @author Joerg Linge
|
||||
* @license GPL
|
||||
*/
|
||||
class Zoom_Controller extends System_Controller {
|
||||
|
||||
|
||||
class Zoom_Controller extends System_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -34,20 +41,22 @@ class Zoom_Controller extends System_Controller {
|
||||
#
|
||||
$start_limit = strtotime("2000/01/01");
|
||||
$this->start = abs((int)$this->start);
|
||||
if($this->start < $start_limit)
|
||||
$this->start = $start_limit;
|
||||
if ($this->start < $start_limit) {
|
||||
$this->start = $start_limit;
|
||||
}
|
||||
#
|
||||
# Limit end to now + one hour
|
||||
#
|
||||
# Limit end to now + one hour
|
||||
#
|
||||
$end_limit = time() + 3600;
|
||||
$this->end = abs((int)$this->end);
|
||||
if($this->end > $end_limit)
|
||||
if ($this->end > $end_limit) {
|
||||
$this->end = $end_limit;
|
||||
}
|
||||
|
||||
$this->data->getTimeRange($this->start,$this->end,$this->view);
|
||||
$this->data->getTimeRange($this->start, $this->end, $this->view);
|
||||
|
||||
if(isset($this->tpl) && $this->tpl != 'undefined' ){
|
||||
if($this->start && $this->end ){
|
||||
if (isset($this->tpl) && $this->tpl != 'undefined') {
|
||||
if ($this->start && $this->end) {
|
||||
$this->session->set("start", $this->start);
|
||||
$this->session->set("end", $this->end);
|
||||
}
|
||||
@@ -56,11 +65,11 @@ class Zoom_Controller extends System_Controller {
|
||||
$this->template->source = $this->source;
|
||||
$this->template->end = $this->end;
|
||||
$this->template->start = $this->start;
|
||||
$this->url = "?tpl=".$this->tpl;
|
||||
$this->url = "?tpl=" . $this->tpl;
|
||||
$this->template->graph_height = $this->graph_height;
|
||||
$this->template->graph_width = $this->graph_width;
|
||||
}elseif(isset($this->host) && isset($this->service)){
|
||||
if($this->start && $this->end ){
|
||||
} elseif (isset($this->host) && isset($this->service)) {
|
||||
if ($this->start && $this->end) {
|
||||
$this->session->set("start", $this->start);
|
||||
$this->session->set("end", $this->end);
|
||||
}
|
||||
@@ -70,10 +79,10 @@ class Zoom_Controller extends System_Controller {
|
||||
$this->template->source = $this->source;
|
||||
$this->template->end = $this->end;
|
||||
$this->template->start = $this->start;
|
||||
$this->url = "?host=".urlencode($this->host)."&srv=".urlencode($this->service);
|
||||
$this->url = "?host=" . urlencode($this->host) . "&srv=" . urlencode($this->service);
|
||||
$this->template->graph_height = $this->graph_height;
|
||||
$this->template->graph_width = $this->graph_width;
|
||||
}else{
|
||||
} else {
|
||||
url::redirect("/graph");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user