pandorafms/pandora_console/mobile/include/system.class.php

129 lines
3.0 KiB
PHP
Raw Normal View History

2010-09-15 17:54:59 +02:00
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
if (!isset($config)) {
require_once('../include/config.php');
}
2010-09-15 17:54:59 +02:00
//Singleton
2010-09-15 17:54:59 +02:00
class System {
private static $instance;
2010-09-15 17:54:59 +02:00
private $session;
private $config;
function __construct() {
$this->loadConfig();
$session_id = session_id();
DB::getInstance($this->getConfig('db_engine', 'mysql'));
if (empty($session_id)) {
session_start();
}
2010-09-15 17:54:59 +02:00
$this->session = $_SESSION;
session_write_close();
2018-05-21 15:19:25 +02:00
require_once($this->getConfig('homedir') . '/include/functions.php');
require_once($this->getConfig('homedir') . '/include/functions_io.php');
2010-09-15 17:54:59 +02:00
}
public static function getInstance() {
if (!(self::$instance instanceof self)) {
self::$instance = new self;
}
return self::$instance;
}
2010-09-15 17:54:59 +02:00
private function loadConfig() {
global $config;
$config['mobile'] = true;
2010-09-15 17:54:59 +02:00
$this->config = &$config;
}
public function getRequest($name, $default = null) {
2018-05-21 15:19:25 +02:00
return get_parameter($name, $default);
}
public function safeOutput($value) {
return io_safe_output($value);
}
public function safeInput($value) {
return io_safe_input($value);
2010-09-15 17:54:59 +02:00
}
2010-09-17 Miguel de Dios <miguel.dedios@artica.es> * include/fgraph.php: added function "grafico_modulo_sparse_mobile" for to paint a mobile graph. * include/functions_db.php: erased deprecate function "dame_grupo_icono". * include/functions_module.php: moved the functions "format_delete", "format_time", "format_data", "format_verbatim", "format_timestamp", "format_delete", "format_delete_string", "format_delete_log4x" from the file "operation/agentes/datos_agente.php" for to use in other source code places. * operation/agentes/datos_agente.php: extracted the functions "format_delete", "format_time", "format_data", "format_verbatim", "format_timestamp", "format_delete", "format_delete_string", "format_delete_log4x" to "include/functions_module.php" for to use in other source code. * operation/agentes/tactical.php: cleaned source code style. * operation/agentes/group_view.php: cleaned source code style. * mobile/operation/agents/view_agents.php: added class "viewGraph" to show graph and data of any module. * mobile/operation/agents/tactical.php: added first version of page to show tactical mobile page. * mobile/operation/agents/view_alerts.php: added first version of page to show alerts mobile page. * mobile/operation/agents/group_view.php: added first version of page to show group view mobile page. * mobile/operation/servers/view_servers.php: added first version of page to show servers mobile page. * mobile/include/style/main.css: added many new styles. * mobile/include/functions_web.php: added links into menu for new pages. * mobile/include/system.class.php: fixed scope of method "getConfig". * mobile/index.php: added hooks for new pages. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3250 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-09-17 12:56:17 +02:00
public function getConfig($name, $default = null) {
2010-09-15 17:54:59 +02:00
if (!isset($this->config[$name])) {
return $default;
}
else {
return $this->config[$name];
}
}
public function setSessionBase($name, $value) {
session_start();
$_SESSION[$name] = $value;
session_write_close();
}
2010-09-15 17:54:59 +02:00
public function setSession($name, $value) {
$this->session[$name] = $value;
session_start();
$_SESSION = $this->session;
session_write_close();
}
public function getSession($name, $default = null) {
if (!isset($this->session[$name])) {
return $default;
}
else {
return $this->session[$name];
}
}
public function sessionDestroy() {
session_start();
session_destroy();
}
public function getPageSize() {
return 10;
}
public function checkACL($access = "AR", $group_id = 0) {
if (check_acl($this->getConfig('id_user'), $group_id, $access)) {
return true;
}
else {
db_pandora_audit("ACL Violation",
"Trying to access to Mobile Page");
return false;
}
}
2018-05-11 14:24:26 +02:00
public function getDefaultACLFailText() {
return
__("Access to this page is restricted to authorized users only, please contact your system administrator if you should need help.") .
"<br><br>" .
__("Please remember that any attempts to access this page will be recorded on the %s System Database.", get_product_name())
;
}
2010-09-15 17:54:59 +02:00
}
?>