2013-03-15 Miguel de Dios <miguel.dedios@artica.es>

* mobile/*: added first version of new mobile console.
	



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7861 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-03-15 14:50:47 +00:00
parent 3c9153937f
commit 8c5e0dd4cf
12 changed files with 1908 additions and 556 deletions

View File

@ -1,3 +1,7 @@
2013-03-15 Miguel de Dios <miguel.dedios@artica.es>
* mobile/*: added first version of new mobile console.
2013-03-15 Miguel de Dios <miguel.dedios@artica.es>
* include/javascript/jquery.form.js: updated to last version.
@ -5,7 +9,6 @@
* include/functions_reporting.php, include/functions_groups.php:
added changes for to get the data as hash instead a html.
2013-03-15 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_events.php, include/functions_html.php,

View File

@ -12,13 +12,14 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
require_once("system.class.php");
//Singleton
class DB {
private static $instance;
private $system;
private $engine;
public function __construct($system, $engine = 'mysql') {
public function __construct($engine = 'mysql') {
$this->system = &$system;
$this->engine = $engine;
@ -27,6 +28,14 @@ class DB {
//NONE
break;
}
}
}
public static function getInstance($engine = 'mysql') {
if (!(self::$instance instanceof self)) {
self::$instance = new self($engine);
}
return self::$instance;
}
}
?>

View File

@ -1,271 +1,93 @@
* {
margin: 0;
padding: 0;
border: 0;
font-size: 12px;
font-family: Arial;
}
a:hover {
text-decoration: none;
text-decoration: none !important;
}
body {
}
input {
border: 1px solid;
}
.tactical_link {
text-decoration: none;
}
.tactical_link:hover {
text-decoration: underline;
}
.orange {
color: #ffa300;
}
.green {
color: #5a8629;
}
.yellow {
color: #F3C500;
}
.greenb {
color: #00aa00;
}
.grey {
color: #808080;
font-weight: bold;
}
select {
border: #CCCCCC 1px solid;
}
.button_filter {
background: url("../../images/zoom.png") no-repeat scroll center center;
margin-left: 5px;
width: 20px;
height: 20px;
}
input {
border: #CCCCCC 1px solid;
}
.title_h3, .title_h3 * {
border-top: 1px solid #CCCCCC;
margin: 5px;
color: #3F4E2F;
}
.title_h3_server {
border-top: 1px solid #CCCCCC;
border-bottom: 1px solid #CCCCCC;
margin: 5px;
color: #3F4E2F;
}
tr.rowPair {
background-color: #fff;
}
tr.rowOdd {
background-color: #EEEEEE;
}
tr.rowPair:hover {
background-color: #E0E0E0;
}
tr.rowOdd:hover {
background-color: #E0E0E0
}
#footer {
background: #000;
height: 30px;
color: #fff;
text-align: center;
margin-top: 20px;
font-size: 10px;
}
/*----------------INI-LOGIN---------------------------------------------------*/
#center_div {
background-color: white;
border-style: none;
direction: ltr;
display: block;
position: absolute;
top: 30px;
left: 50%;
font-family: Arial,Helvetica,sans-serif;
font-size: 11px;
margin: 0;
text-align: left;
vertical-align: top;
}
#negative_position_div {
display: block;
position: absolute;
left: -335px;
.group_view tr {
border-bottom: 3px solid white !important;
}
#style_div #shadow {
display: block;
border: 0px;
position: absolute;
top: 15px;
left: 235px;
background: #036A3A;
width: 200px;
height: 120px;
color: #fff;
tr.group_view_crit, .group_view_crit {
background-color: #FA3030;
color: #000000 !important;
}
#style_div #shadow p {
position: absolute;
bottom: 0px;
right: 2px;
.group_view_crit * {
color: #000000 !important;
}
#style_div #shadow * {
font-size: 9px;
tr.group_view_norm, .group_view_norm {
background-color: #FFFFFF;
color: #000000 !important;
}
.group_view_norm * {
color: #000000 !important;
}
#style_div #version {
color: #036A3A;
tr.group_view_ok, .group_view_ok {
background-color: #00C000;
color: #000000 !important;
}
.group_view_ok * {
color: #000000 !important;
}
#style_div #login_box {
background: url("../../../images/pandora_logo.png") bottom left no-repeat #fff;
display: block;
border: 2px solid #6DC62D;
position: absolute;
top: 0px;
left: 220px;
width: 200px;
height: 120px;
tr.group_view_warn, .group_view_warn, tr.group_view_warn.a, a.group_view_warn, tr.a.group_view_warn {
background-color: #F5E535;
}
a.group_view_warn {
color: #000000 !important;
}
#style_div #text-user {
width: 60px;
height: 15px;
position: absolute;
left: 20px;
top: 20px;
tr.group_view_alrm, .group_view_alrm {
background-color: #ED8701;
}
.group_view_alrm * {
color: #000000 !important;
}
#style_div #password-password {
width: 60px;
height: 15px;
position: absolute;
left: 20px;
top: 45px;
tr.group_view_unk, .group_view_unk {
background-color: #C4C4C4;
}
.group_view_unk * {
color: #000000 !important;
}
#style_div .login_button {
width: 70px;
height: 70px;
background: url('../../images/key.gif') #fff center no-repeat;
border: outset 5px #A3A3A3;
position: absolute;
left: 120px;
top: 10px;
tr.group_view_data, .group_view_data {
color: #000000 !important;
}
.group_view_data_unk {
color: #303030 !important;
}
.group_view_data_ok {
color: #00C000 !important;
}
.group_view_data_crit {
color: #5C0000 !important;
}
.group_view_data_alrm {
color: #5C1D00 !important;
}
.group_view_data_warn {
color: #5C5900 !important;
}
#style_div .login_button:hover {
border: outset 5px #E9E9E9;
/*Fix the square border in search input*/
.ui-input-search {
border-radius: 0.6em 0.6em 0.6em 0.6em !important;
}
/*STYLE FOR IEXPLOTER MOBILE, MAY BE ANY DAY ERASE THIS LINES*/
#form_table td {
background: url('../../images/transparent_pixel.gif');
}
#table_version #text-user {
width: 60px;
height: 15px;
}
#table_version #password-password {
width: 60px;
height: 15px;
}
#table_version .login_button {
width: 70px;
height: 70px;
background: url('../../images/key.gif') #fff center no-repeat;
border: outset 5px #A3A3A3;
}
#table_version_negative_position_div {
/*margin-left: -120px;*/
}
/*----------------END-LOGIN---------------------------------------------------*/
/*----------------INI-MENU----------------------------------------------------*/
#top_menu {
background: #3F4E2F;
overflow: hidden;
position: absolute;
z-index: 2;
}
#margin_bottom_menu {
/*margin-bottom: 17px;*/
}
#menu {
display: none;
}
#down_button {
height: 20px;
background: #fff;
}
#down_button img {
background: #3F4E2F;
padding-left: 10px;
padding-right: 10px;
}
.icon_menu {
width: 30px;
height: 30px;
}
/*----------------END-MENU----------------------------------------------------*/
/*----------------INI-EVENTS ROW BACKGROUND-----------------------------------*/
.datos_green, .datos_greenf9 {
background-color: #BBFFA4;
}
.datos_red, .datos_redf9 {
background-color: #FFC0B5;
}
.datos_yellow, .datos_yellowf9 {
background-color: #F4FFBF;
}
.datos_blue, .datos_bluef9 {
background-color: #CDE2EA;
}
.datos_grey, .datos_greyf9 {
background-color: #E4E4E4;
}
/*----------------END-EVENTS ROW BACKGROUND-----------------------------------*/
/*----------------INI-TABLE---------------------------------------------------*/
th {
background-color:#9EAC8B;
color:#FFFFFF;
text-align:center;
}
.databox {
border: 1px solid #f2f2f2;
background-color: #fafafa;
}
/*----------------END-TABLE---------------------------------------------------*/
.ui-select {
width: 100% !important;
}

View File

@ -0,0 +1,271 @@
* {
margin: 0;
padding: 0;
border: 0;
font-size: 12px;
font-family: Arial;
}
a:hover {
text-decoration: none;
}
body {
}
input {
border: 1px solid;
}
.tactical_link {
text-decoration: none;
}
.tactical_link:hover {
text-decoration: underline;
}
.orange {
color: #ffa300;
}
.green {
color: #5a8629;
}
.yellow {
color: #F3C500;
}
.greenb {
color: #00aa00;
}
.grey {
color: #808080;
font-weight: bold;
}
select {
border: #CCCCCC 1px solid;
}
.button_filter {
background: url("../../images/zoom.png") no-repeat scroll center center;
margin-left: 5px;
width: 20px;
height: 20px;
}
input {
border: #CCCCCC 1px solid;
}
.title_h3, .title_h3 * {
border-top: 1px solid #CCCCCC;
margin: 5px;
color: #3F4E2F;
}
.title_h3_server {
border-top: 1px solid #CCCCCC;
border-bottom: 1px solid #CCCCCC;
margin: 5px;
color: #3F4E2F;
}
tr.rowPair {
background-color: #fff;
}
tr.rowOdd {
background-color: #EEEEEE;
}
tr.rowPair:hover {
background-color: #E0E0E0;
}
tr.rowOdd:hover {
background-color: #E0E0E0
}
#footer {
background: #000;
height: 30px;
color: #fff;
text-align: center;
margin-top: 20px;
font-size: 10px;
}
/*----------------INI-LOGIN---------------------------------------------------*/
#center_div {
display: block;
position: absolute;
top: 30px;
left: 50%;
}
#negative_position_div {
display: block;
position: absolute;
left: -335px;
}
#style_div #shadow {
display: block;
border: 0px;
position: absolute;
top: 15px;
left: 235px;
background: #036A3A;
width: 200px;
height: 120px;
color: #fff;
}
#style_div #shadow p {
position: absolute;
bottom: 0px;
right: 2px;
}
#style_div #shadow * {
font-size: 9px;
}
#style_div #version {
color: #036A3A;
}
#style_div #login_box {
background: url("../../../images/pandora_logo.png") bottom left no-repeat #fff;
display: block;
border: 2px solid #6DC62D;
position: absolute;
top: 0px;
left: 220px;
width: 200px;
height: 120px;
}
#style_div #text-user {
width: 60px;
height: 15px;
position: absolute;
left: 20px;
top: 20px;
}
#style_div #password-password {
width: 60px;
height: 15px;
position: absolute;
left: 20px;
top: 45px;
}
#style_div .login_button {
width: 70px;
height: 70px;
background: url('../../images/key.gif') #fff center no-repeat;
border: outset 5px #A3A3A3;
position: absolute;
left: 120px;
top: 10px;
}
#style_div .login_button:hover {
border: outset 5px #E9E9E9;
}
/*STYLE FOR IEXPLOTER MOBILE, MAY BE ANY DAY ERASE THIS LINES*/
#form_table td {
background: url('../../images/transparent_pixel.gif');
}
#table_version #text-user {
width: 60px;
height: 15px;
}
#table_version #password-password {
width: 60px;
height: 15px;
}
#table_version .login_button {
width: 70px;
height: 70px;
background: url('../../images/key.gif') #fff center no-repeat;
border: outset 5px #A3A3A3;
}
#table_version_negative_position_div {
/*margin-left: -120px;*/
}
/*----------------END-LOGIN---------------------------------------------------*/
/*----------------INI-MENU----------------------------------------------------*/
#top_menu {
background: #3F4E2F;
overflow: hidden;
position: absolute;
z-index: 2;
}
#margin_bottom_menu {
/*margin-bottom: 17px;*/
}
#menu {
display: none;
}
#down_button {
height: 20px;
background: #fff;
}
#down_button img {
background: #3F4E2F;
padding-left: 10px;
padding-right: 10px;
}
.icon_menu {
width: 30px;
height: 30px;
}
/*----------------END-MENU----------------------------------------------------*/
/*----------------INI-EVENTS ROW BACKGROUND-----------------------------------*/
.datos_green, .datos_greenf9 {
background-color: #BBFFA4;
}
.datos_red, .datos_redf9 {
background-color: #FFC0B5;
}
.datos_yellow, .datos_yellowf9 {
background-color: #F4FFBF;
}
.datos_blue, .datos_bluef9 {
background-color: #CDE2EA;
}
.datos_grey, .datos_greyf9 {
background-color: #E4E4E4;
}
/*----------------END-EVENTS ROW BACKGROUND-----------------------------------*/
/*----------------INI-TABLE---------------------------------------------------*/
th {
background-color:#9EAC8B;
color:#FFFFFF;
text-align:center;
}
.databox {
border: 1px solid #f2f2f2;
background-color: #fafafa;
}
/*----------------END-TABLE---------------------------------------------------*/

View File

@ -15,22 +15,32 @@
if (!isset($config)) {
require_once('../include/config.php');
}
require_once('db.class.php');
//Singleton
class System {
private static $instance;
private $session;
private $config;
private $db;
function __construct() {
$this->loadConfig();
$this->db = new DB($this, $this->getConfig('db_engine', 'mysql'));
DB::getInstance($this->getConfig('db_engine', 'mysql'));
session_start();
$this->session = $_SESSION;
session_write_close();
}
public static function getInstance() {
if (!(self::$instance instanceof self)) {
self::$instance = new self;
}
return self::$instance;
}
private function loadConfig() {
global $config;
@ -84,12 +94,6 @@ class System {
}
}
public function debug($var) {
echo "<pre>";
var_dump($var);
echo "</pre>";
}
public function sessionDestroy() {
session_start();
session_destroy();
@ -98,5 +102,17 @@ class System {
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;
}
}
}
?>

View File

@ -0,0 +1,683 @@
<?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.
//Singleton
class Ui {
private static $instance;
private $title;
private $endHeader = false;
private $header = array();
private $endContent = false;
private $content = array();
private $endFooter = false;
private $footer = array();
private $form = array();
private $grid = array();
private $collapsible = true;
private $endForm = true;
private $endGrid = true;
private $endCollapsible = true;
private $dialog = '';
public function __construct() {
}
public static function getInstance() {
if (!(self::$instance instanceof self)) {
self::$instance = new self;
}
return self::$instance;
}
public function debug($var, $file = false) {
$more_info = '';
if (is_string($var)) {
$more_info = 'size: ' . strlen($var);
}
elseif (is_bool($var)) {
$more_info = 'val: ' .
($var ? 'true' : 'false');
}
elseif (is_null($var)) {
$more_info = 'is null';
}
elseif (is_array($var)) {
$more_info = count($var);
}
if ($file === true)
$file = '/tmp/logDebug';
if (strlen($file) > 0) {
$f = fopen($file, "a");
ob_start();
echo date("Y/m/d H:i:s") . " (" . gettype($var) . ") " . $more_info . "\n";
print_r($var);
echo "\n\n";
$output = ob_get_clean();
fprintf($f,"%s",$output);
fclose($f);
}
else {
echo "<pre>" .
date("Y/m/d H:i:s") . " (" . gettype($var) . ") " . $more_info .
"</pre>";
echo "<pre>";print_r($var);echo "</pre>";
}
}
public function createPage($title = null) {
if (!isset($title)) {
$this->title = __('Pandora FMS mobile');
}
$this->html = '';
$this->endHeader = false;
$this->header = array();
$this->endContent = false;
$this->content = array();
$this->noFooter = false;
$this->endFooter = false;
$this->footer = array();
$this->form = array();
$this->grid = array();
$this->collapsible = array();
$this->endForm = true;
$this->endGrid = true;
$this->endCollapsible = true;
$this->dialog = '';
}
public function showFooter($show = true) {
$this->noFooter = !$show;
}
public function beginHeader() {
$this->header = array();
$this->header['button_left'] = '';
$this->header['button_right'] = '';
$this->header['title'] = __('Pandora FMS mobile');
$this->endHeader = false;
}
public function endHeader() {
$this->endHeader = true;
}
public function createHeader($title = null, $buttonLeft = null, $buttonRight = null) {
$this->beginHeader();
$this->headerTitle($title);
$this->headerAddButtonLeft($buttonLeft);
$this->headerAddButtonRight($buttonRight);
$this->endHeader();
}
public function headerTitle($title = null) {
if (isset($title)) {
$this->header['title'] = $title;
}
}
public function headerAddButtonLeft($button = null) {
if (isset($button)) {
$this->header['button_left'] = $button;
}
}
public function headerAddButtonRight($button = null) {
if (isset($button)) {
$this->header['button_right'] = $button;
}
}
public function createHeaderButton($options) {
return $this->createButton($options);
}
public function createDefaultHeader($title = false) {
if ($title === false) {
$title = __('Pandora FMS mobile');
}
$this->createHeader(
$title,
$this->createHeaderButton(
array('icon' => 'back',
'pos' => 'left',
'text' => __('Logout'),
'href' => 'index.php?action=logout')),
$this->createHeaderButton(
array('icon' => 'home',
'pos' => 'right',
'text' => __('Home'),
'href' => 'index.php?page=home')));
}
public function createButton($options) {
$return = '<a data-role="button" ';
if (isset($options['icon'])) {
$return .= 'data-icon="' . $options['icon'] . '" ';
}
if (isset($options['icon_pos'])) {
$return .= 'data-iconpos="' . $options['pos'] . '" ';
}
if (isset($options['href'])) {
$return .= 'href="' . $options['href'] . '" ';
}
else {
$return .= 'href="#" ';
}
$return .= '>';
if (isset($options['text'])) {
$return .= $options['text'];
}
$return .= '</a>';
return $return;
}
public function beginFooter() {
$this->footer = array();
$this->endFooter = false;
}
public function endFooter() {
$this->endFooter = true;
}
public function createFooter($text = "") {
$this->footerText($text);
}
public function footerText($text = null) {
if (!isset($text)) {
$this->footer['text'] = '';
}
else {
$this->footer['text'] = $text;
}
$this->endFooter();
}
public function defaultFooter() {
global $pandora_version, $build_version;
if (isset($_SERVER['REQUEST_TIME'])) {
$time = $_SERVER['REQUEST_TIME'];
}
else {
$time = get_system_time ();
}
return "<div id='footer' style='text-align: center;'>\n"
. sprintf(__('Pandora FMS %s - Build %s', $pandora_version, $build_version)) . "<br />\n"
. __('Generated at') . ' '. ui_print_timestamp ($time, true, array ("prominent" => "timestamp")) . "\n"
. "</div>";
}
public function beginContent() {
$this->content = array();
$this->endContent = false;
}
public function endContent() {
$this->endContent = true;
}
public function contentAddHtml($html) {
$this->content[] = $html;
}
public function contentBeginGrid($mode = 'responsive') {
$this->endGrid = false;
$this->grid = array();
$this->grid['mode'] = $mode;
$this->grid['cells'] = array();
}
public function contentGridAddCell($html) {
$this->grid['cells'][] = $html;
}
public function contentEndGrid() {
$this->endGrid = true;
//TODO Make others modes, only responsible mode
$convert_columns_jquery_grid = array(
2 => 'a', 3 => 'b', 4 => 'c', 5 => 'd');
$convert_cells_jquery_grid = array('a', 'b', 'c', 'd', 'e');
$html = "<div class='ui-grid-" .
$convert_columns_jquery_grid[count($this->grid['cells'])] . " ui-responsive'>\n";
reset($convert_cells_jquery_grid);
foreach ($this->grid['cells'] as $cell) {
switch ($this->grid['mode']) {
default:
case 'responsive':
$html .= "<div class='ui-block-" .
current($convert_cells_jquery_grid) . "'>\n";
break;
}
next($convert_cells_jquery_grid);
$html .= "<div class='ui-body ui-body-d'>\n";
$html .= $cell;
$html .= "</div>\n";
$html .= "</div>\n";
}
$html .= "</div>\n";
$this->contentAddHtml($html);
$this->grid = array();
}
public function contentBeginCollapsible($title = "&nbsp;") {
$this->endCollapsible = false;
$this->collapsible = array();
$this->collapsible['items'] = array();
$this->collapsible['title'] = $title;
}
public function contentCollapsibleAddItem($html) {
$this->collapsible['items'][] = $html;
}
public function contentEndCollapsible() {
$this->endCollapsible = true;
$html = "<div data-role='collapsible' " .
" data-collapsed-icon='arrow-d' " .
" data-expanded-icon='arrow-u' data-mini='true' ".
" data-theme='a' data-content-theme='c'>\n";
$html .= "<h4>" . $this->collapsible['title'] . "</h4>\n";
$html .= "<ul data-role='listview' data-theme='c'>\n";
foreach ($this->collapsible['items'] as $item) {
$html .= "<li>" . $item . "</li>";
}
$html .= "</ul>\n";
$html .= "</div>\n";
$this->contentAddHtml($html);
$this->collapsible = array();
}
public function beginForm($action = "index.php", $method = "post") {
$this->form = array();
$this->endForm = false;
$this->form['action'] = $action;
$this->form['method'] = $method;
}
public function endForm() {
$this->contentAddHtml($this->getEndForm());
}
public function getEndForm() {
$this->endForm = true;
$html = "<form action='" . $this->form['action'] . "' " .
"method='" . $this->form['method'] . "'>\n";
foreach ($this->form['fields'] as $field) {
$html .= $field . "\n";
}
$html .= "</form>\n";
$this->form = array();
return $html;
}
public function formAddHtml($html) {
$this->form['fields'][] = $html;
}
public function formAddInput($options) {
//$label = '', $name = '', $id = '', $value = '') {
if (empty($options['name'])) {
$options['name'] = uniqid('input');
}
if (empty($options['id'])) {
$options['id'] = 'text-' . $options['name'];
}
$html = "<div>\n";
$html .= "<fieldset data-role='controlgroup'>\n";
if (!empty($options['label'])) {
$html .= "<label for='" . $options['id'] . "'>" . $options['label'] . "</label>\n";
}
//Erase other options and only for the input
unset($options['label']);
$html .= "<input ";
foreach ($options as $option => $value) {
$html .= " " . $option . "='" . $value . "' ";
}
$html .= ">\n";
$html .= "</fieldset>\n";
$html .= "</div>\n";
$this->formAddHtml($html);
}
public function formAddInputPassword($options) {
$options['type'] = 'password';
$this->formAddInput($options);
}
public function formAddInputText($options) {
$options['type'] = 'text';
$this->formAddInput($options);
}
public function formAddInputSearch($options) {
$options['type'] = 'search';
$this->formAddInput($options);
}
public function formAddSubmitButton($options) {
$options['type'] = 'submit';
if (isset($options['icon'])) {
$options['data-icon'] = $options['icon'];
unset($options['icon']);
}
if (isset($options['icon_pos'])) {
$options['data-iconpos'] = $options['icon_pos'];
unset($options['icon_pos']);
}
if (isset($options['text'])) {
$options['value'] = $options['text'];
unset($options['text']);
}
$this->formAddInput($options);
}
public function formAddSelectBox($options) {
$html = '';
if (empty($options['name'])) {
$options['name'] = uniqid('input');
}
if (empty($options['id'])) {
$options['id'] = 'select-' . $options['name'];
}
$html = "<div data-role='fieldcontain'>\n";
$html .= "<fieldset>\n";
if (!empty($options['label'])) {
$html .= "<label for='" . $options['id'] . "'>" . $options['label'] . "</label>\n";
}
$html .= "<select name='" . $options['name'] . "' " .
"id='" . $options['id'] . "' data-native-menu='false'>\n";
//Hack of jquery mobile
$html .= "<option>" . $options['title'] . "</option>\n";
if (empty($options['items']))
$options['items'] = array();
foreach ($options['items'] as $id => $item) {
if (!empty($options['item_id'])) {
$item_id = $item[$options['item_id']];
}
else {
$item_id = $id;
}
if (!empty($options['item_value'])) {
$item_value = $item[$options['item_value']];
}
else {
$item_value = $item;
}
$html .= "<option value='" . $item_id . "'>" . $item_value . "</option>\n";
}
$html .= "</select>\n";
$html .= "</fieldset>\n";
$html .= "</div>\n";
$this->formAddHtml($html);
}
public function formAddSlider($options) {
$options['type'] = 'range';
$this->formAddInput($options);
//<input type="range" name="slider-fill" id="slider-fill" value="60" min="0" max="1000" step="50" data-highlight="true">
}
public function addDialog($title = '', $content = '', $button_text = '') {
$this->dialog = "<div data-role='dialog' data-close-btn='none'>\n";
$this->dialog .= "<div data-role='header'>\n";
$this->dialog .= "<h1>" . $title . "</h1>\n";
$this->dialog .= "</div>\n";
$this->dialog .= "<div data-role='content'>\n";
$this->dialog .= $content;
$this->dialog .= "<a data-role='button' href='#main_page'>";
if (empty($button_text)) {
$this->dialog .= __('Close');
}
else {
$this->dialog .= $button_text;
}
$this->dialog .= "</a></p>\n";
$this->dialog .= "</div>\n";
$this->dialog .= "</div>\n";
}
public function showError($msg) {
echo $msg;
}
public function showPage() {
if (!$this->endHeader) {
$this->showError(__('Not found header.'));
}
else if (!$this->endContent) {
$this->showError(__('Not found content.'));
}
else if ((!$this->endFooter) && (!$this->noFooter)) {
$this->showError(__('Not found footer.'));
}
else if (!$this->endForm) {
$this->showError(__('Incorrect form.'));
}
else if (!$this->endGrid) {
$this->showError(__('Incorrect grid.'));
}
else if (!$this->endCollapsible) {
$this->showError(__('Incorrect collapsible.'));
}
ob_start ();
echo "<!DOCTYPE html>\n";
echo "<html>\n";
echo " <head>\n";
echo " <title>" . $this->title . "</title>\n";
echo " <meta name='viewport' content='width=device-width, initial-scale=1'>\n";
echo " <link rel='stylesheet' href='include/style/main.css' />\n";
echo " <link rel='stylesheet' href='http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.css' />\n";
echo " <script src='http://code.jquery.com/jquery-1.9.1.js'></script>\n";
echo " <script src='http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.js'></script>\n";
echo " </head>\n";
echo " <body>\n";
if (!empty($this->dialog)) {
echo " " . $this->dialog . "\n";
}
echo " <div data-role='page' id='main_page'>\n";
echo " <div data-role='header' data-position='fixed' >\n";
echo " <h1>" . $this->header['title'] . "</h1>\n";
echo " " . $this->header['button_left'] . "\n";
echo " " . $this->header['button_right'] . "\n";
echo " </div>\n";
echo " <div data-role='content'>\n";
foreach ($this->content as $content) {
echo " " . $content . "\n";
}
echo " </div>\n";
if (!$this->noFooter) {
echo " <div data-role='footer' role='contentinfo'>\n";
if (!empty($this->footer['text'])) {
echo " " . $this->footer['text'] . "\n";
}
else {
echo " " . $this->defaultFooter() . "\n";
}
}
echo " </div>\n";
echo " </div>\n";
echo " </body>\n";
echo "</html>";
ob_end_flush();
}
//
//
}
class Table {
private $head = array();
private $rows = array();
private $id = array();
private $rowClass = array();
private $class_table = '';
public function __construct() {
$this->init();
}
public function init() {
$this->id = uniqid();
$this->head = array();
$this->rows = array();
$this->rowClass = array();
$this->class_table = '';
}
public function addHeader($head) {
$this->head = $head;
}
public function importFromHash($data) {
foreach ($data as $id => $row) {
$table_row = array();
foreach ($row as $key => $value) {
if (!in_array($key, $this->head)) {
$this->head[] = $key;
}
$cell_key = array_search($key, $this->head);
$table_row[$cell_key] = $value;
}
$this->rows[] = $table_row;
}
}
public function setClass($class = '') {
$this->class_table = $class;
}
public function setRowClass($class = '', $pos = false) {
if (is_array($class)) {
$this->rowClass = $class;
}
else {
if ($pos !== false) {
$this->rowClass[$pos] = $class;
}
else {
$this->rowClass = array_fill(0, count($this->rows), $class);
}
}
}
public function getHTML() {
$html = '';
$html = "<table data-role='table' id='" . $this->id . "' " .
"data-mode='reflow' class='" . $this->class_table . " ui-responsive table-stroke'>\n";
$html .= "<thead>\n";
$html .= "<tr>\n";
//Empty head for white space between rows in the responsive vertical layout
$html .= "<th></th>\n";
foreach ($this->head as $head) {
$html .= "<th>" . $head . "</th>\n";
}
$html .= "</tr>\n";
$html .= "</thead>\n";
$html .= "<tbody>\n";
foreach ($this->rows as $key => $row) {
$class = '';
if (isset($this->rowClass[$key])) {
$class = $this->rowClass[$key];
}
$html .= "<tr class='" . $class . "'>\n";
//Empty head for white space between rows in the responsive vertical layout
$html .= "<th></th>\n";
foreach ($row as $cell) {
$html .= "<td>" . $cell . "</td>\n";
}
$html .= "</tr>\n";
}
$html .= "</table>\n";
$html .= "</tbody>\n";
return $html;
}
}
?>

View File

@ -12,45 +12,61 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
require_once("system.class.php");
//Singleton
class User {
private static $instance;
private $user;
private $logged;
private $system;
private $logged = false;
private $errorLogin = false;
private $logout_action = false;
public function __construct($user = null, $password = null) {
global $system;
$this->user = $user;
$this->system = &$system;
//$this->system->debug($this->system);
$this->errorLogin = false;
if (process_user_login($this->user, $password)) {
$this->logged = true;
$this->hackInjectConfig();
}
else {
$this->logged = false;
}
}
public function hackinjectConfig() {
public static function getInstance() {
if (!(self::$instance instanceof self)) {
self::$instance = new self;
}
return self::$instance;
}
public function hackInjectConfig() {
//hack to compatibility with pandora
if ($this->logged) {
//hack to compatibility with pandora
global $config;
$system = System::getInstance();
$config['id_user'] = $this->user;
$this->system->setSessionBase('id_usuario', $this->user);
$system->setSessionBase('id_usuario', $this->user);
$system->setSession('user', $this);
}
}
public function isLogged() {
$autologin = $this->system->getRequest('autologin', false);
$system = System::getInstance();
$autologin = $system->getRequest('autologin', false);
if ($autologin) {
$user = $this->system->getRequest('user', null);
$password = $this->system->getRequest('password', null);
$user = $system->getRequest('user', null);
$password = $system->getRequest('password', null);
if ($this->checkLogin($user, $password)) {
$this->hackinjectConfig();
$this->hackInjectConfig();
}
}
@ -58,114 +74,103 @@ class User {
}
public function checkLogin($user = null, $password = null) {
$system = System::getInstance();
if (($user == null) && ($password == null)) {
$user = $this->system->getRequest('user', null);
$password = $this->system->getRequest('password', null);
$user = $system->getRequest('user', null);
$password = $system->getRequest('password', null);
}
if (process_user_login($user, $password) !== false) {
$this->logged = true;
$this->user = $user;
}
else {
$this->logged = false;
if (!empty($user) && !empty($password)) {
if (process_user_login($user, $password) !== false) {
$this->logged = true;
$this->user = $user;
$this->errorLogin = false;
}
else {
$this->logged = false;
$this->errorLogin = true;
}
}
return true;
if ($this->logged) {
$this->hackInjectConfig();
if (! check_acl($system->getConfig('id_user'), 0, "AR")) {
db_pandora_audit("ACL Violation",
"Trying to access Agent Data view");
require ("../general/noaccess.php");
return;
}
$user_language = get_user_language ($system->getConfig('id_user'));
if (file_exists ('../include/languages/'.$user_language.'.mo')) {
$l10n = new gettext_reader (new CachedFileReader ('../include/languages/'.$user_language.'.mo'));
$l10n->load_tables();
}
}
return $this->logged;
}
public function logout() {
$this->user = null;
$this->logged = false;
$this->errorLogin = false;
$this->logout_action = true;
$system = System::getInstance();
$system->setSession('user', null);
}
public function showLogin($text = '') {
public function showLogin() {
global $pandora_version;
echo "<form action='index.php' method='post'>";
html_print_input_hidden('action', 'login');
?>
<div id="center_div">
<div id="table_version_negative_position_div">
<table cellspacing="0" style="margin: 10px;" id="table_version">
<tr>
<td style="height: 120px; width: 200px; background: #fff; width: 200px; height: 120px;" colspan="2" rowspan="2">
<table id="form_table" cellspacing="0" style="border: 2px solid #6DC62D; width: 100%; height: 100%; background: url('../images/pandora_logo.png') bottom left no-repeat #fff;">
<tr>
<td style="color: #036A3A; height: 20px;" colspan="2" valign="top" align="left"><?php echo $pandora_version;?> <?php echo $text;?></td>
<td style="width: 80px; height: 80px;" valign="bottom" align="left" rowspan="4">
<?php
html_print_submit_button('', 'login', false, 'class="login_button" alt="' . __('Login') . '" title="' . __('Login') . '"');
?>
</td>
</tr>
<tr>
<td style="width: 20px; height: 25px;">&nbsp;</td>
<td valign="top" align="left"><?php html_print_input_text('user', $this->user, __('User'), 10, 20);?></td>
</tr>
<tr>
<td style="width: 20px; height: 15px;">&nbsp;</td>
<td valign="top" align="left"><?php html_print_input_password('password', '', __('Password'), 10, 20);?></td>
</tr>
<tr>
<td style="height: 20px;">&nbsp;</td>
<td style="height: 20px;">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</td>
<td style="height: 15px; width: 15px; background: #fff;">&nbsp;</td>
</tr>
<tr>
<td style="width: 15px; height: 90px; background: #036A3A;">&nbsp;</td>
</tr>
<tr>
<td style="height: 15px; width: 15px; background: #fff;">&nbsp;</td>
<td style="width: 200px; height: 15px; background: #036A3A; color: #fff; font-size: 9px; text-align: right;" colspan="2">
<?php echo '<b style="font-size: 9px;">' . __('Your IP').':</b>' . $this->system->getConfig("remote_addr") . '&nbsp;';?>
</td>
</tr>
<tr>
<td style="background: white; height: 0px;">&nbsp;</td>
<td style="background: white; height: 0px;">&nbsp;</td>
<td style="background: white; height: 0px;">&nbsp;</td>
</tr>
</table>
</div>
</div>
<?php
echo "</form>";
$ui = Ui::getInstance();
/*
?>
<div id="center_div">
<div id="negative_position_div">
<div id="style_div">
<div id="shadow">
<p>
<?php
echo '<b>' . __('Your IP').':</b>' . $this->system->getConfig("remote_addr");
?>
</p>
</div>
<?php
echo "<form id='login_box' method='post' style=''>";
echo "<div id='version'>" . $pandora_version . "</div>";
html_print_input_hidden('action', 'login');
html_print_input_text('user', $this->user, __('User'), 10, 20);
html_print_input_password('password', '', __('Password'), 10, 20);
html_print_submit_button(__(''), 'login', false, 'onclick="javascript: click();" class="login_button" alt="' . __('Login') . '" title="' . __('Login') . '"');
echo "</form>";
?>
</div>
</div>
</div>
<?php
*/
$ui->createPage();
if ($this->errorLogin) {
$ui->addDialog(__('Login Failed'),
__('User not found in database or incorrect password.'));
}
if ($this->logout_action) {
$ui->addDialog(__('Logged out'),
__('Your session is over. Please close your browser window to close this Pandora session.'));
}
$ui->createHeader();
$ui->showFooter(false);
$ui->beginContent();
$ui->contentAddHtml('<div style="text-align: center;">' .
html_print_image ("images/pandora_login.png",
true, array ("alt" => "logo", "border" => 0)) .
'</div>');
$ui->beginForm();
$ui->formAddHtml(html_print_input_hidden('action', 'login', true));
$options = array(
'name' => 'user',
'value' => $this->user,
'placeholder' => __('user'),
'label' => __('User')
);
$ui->formAddInputText($options);
$options = array(
'name' => 'password',
'value' => '',
'placeholder' => __('password'),
'label' => __('Password')
);
$ui->formAddInputPassword($options);
$options = array(
'value' => __('Login'),
'icon' => 'star',
'icon_pos' => 'right'
);
$ui->formAddSubmitButton($options);
$ui->endForm();
$ui->endContent();
$ui->showPage();
$this->errorLogin = false;
$this->logout_action = false;
}
public function getIdUser() {

View File

@ -12,211 +12,80 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//Set character encoding to UTF-8 - fixes a lot of multibyte character headaches
//Set character encoding to UTF-8 - fixes a lot of multibyte character
//headaches
if (function_exists ('mb_internal_encoding')) {
mb_internal_encoding ("UTF-8");
}
ob_start ();
$develop_bypass = 1;
require_once("include/ui.class.php");
require_once("include/system.class.php");
require_once("include/db.class.php");
require_once("include/user.class.php");
require_once("include/functions_web.php");
require_once('operation/agents/view_agents.php');
require_once('operation/servers/view_servers.php');
require_once('operation/agents/tactical.php');
require_once('operation/agents/group_view.php');
require_once('operation/agents/view_alerts.php');
require_once('operation/events/events.php');
require_once('operation/agents/monitor_status.php');
require_once('operation/home.php');
require_once('operation/tactical.php');
require_once('operation/groups.php');
require_once('operation/events.php');
$enterpriseHook = enterprise_include('mobile/include/enterprise.class.php');
$system = new System();
$system = System::getInstance();
$user = $system->getSession('user', null);
if ($user == null) {
$user = new User();
$user = User::getInstance();
}
$user->hackinjectConfig();
if ($user->isLogged()) {
$user_language = get_user_language ($system->getConfig('id_user'));
if (file_exists ('../include/languages/'.$user_language.'.mo')) {
$l10n = new gettext_reader (new CachedFileReader ('../include/languages/'.$user_language.'.mo'));
$l10n->load_tables();
}
else {
$user->hackInjectConfig();
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name = "viewport" content = "width = device-width" />
<title>Pandora FMS - <?php echo __('the Flexible Monitoring System (mobile version)'); ?></title>
<link rel="stylesheet" href="include/style/main.css" type="text/css" />
<link rel="stylesheet" href="../include/styles/tip.css" type="text/css" />
</head>
<body>
<div>
<!--<div style="width: 240px; height: 320px; border: 2px solid red; overflow: hidden;">-->
<!--<div style="width: 240px; height: 640px; border: 2px solid red; overflow: hidden;">-->
<?php
$action = $system->getRequest('action');
switch ($action) {
case 'login':
if (!$user->checkLogin()) {
$user->showLogin();
}
else {
if ($user->isLogged()) {
$user->hackinjectConfig();
menu();
if (! check_acl($system->getConfig('id_user'), 0, "AR")) {
db_pandora_audit("ACL Violation",
"Trying to access Agent Data view");
require ("../general/noaccess.php");
return;
}
$user_language = get_user_language ($system->getConfig('id_user'));
if (file_exists ('../include/languages/'.$user_language.'.mo')) {
$l10n = new gettext_reader (new CachedFileReader ('../include/languages/'.$user_language.'.mo'));
$l10n->load_tables();
}
$tactical = new Tactical();
$tactical->show();
}
else {
$user->showLogin();
}
}
break;
case 'logout':
$user->logout();
$user->showLogin('<span style="color: red; font-weight: bolder; float: right;">' . __('LOGOUT') . '</span>');
break;
$action = $system->getRequest('action');
if (!$user->isLogged()) {
$action = 'login';
}
switch ($action) {
case 'login':
if (!$user->checkLogin()) {
$user->showLogin();
}
else {
if ($user->isLogged()) {
$home = new Home();
$home->show();
}
else {
$user->showLoginFail();
}
}
break;
case 'logout':
$user->logout();
$user->showLogin();
break;
default:
$page = $system->getRequest('page', 'home');
switch ($page) {
case 'home':
default:
if (!$user->isLogged()) {
$user->showLogin();
}
else {
menu();
$page = $system->getRequest('page', 'tactical');
switch ($page) {
case 'reports':
if ($enterpriseHook !== ENTERPRISE_NOT_HOOK) {
$enterprise = new Enterprise($page);
$enterprise->show();
}
break;
default:
case 'tactical':
if (! check_acl($system->getConfig('id_user'), 0, "AR")) {
db_pandora_audit("ACL Violation",
"Trying to access Agent Data view");
require ("../general/noaccess.php");
return;
}
$tactical = new Tactical();
$tactical->show();
break;
case 'agents':
if (! check_acl($system->getConfig('id_user'), 0, "AR")) {
db_pandora_audit("ACL Violation",
"Trying to access Agent Data view");
require ("../general/noaccess.php");
return;
}
$viewAgents = new ViewAgents();
$viewAgents->show();
break;
case 'agent':
$action = $system->getRequest('action', 'view_agent');
switch ($action) {
case 'view_module_graph':
$idAgentModule = $system->getRequest('id', 0);
$viewGraph = new viewGraph($idAgentModule);
$viewGraph->show();
break;
default:
case 'view_agent':
$viewAgent = new ViewAgent();
$viewAgent->show();
break;
}
break;
case 'servers':
if (! check_acl($system->getConfig('id_user'), 0, "PM")) {
db_pandora_audit("ACL Violation",
"Trying to access Agent Data view");
require ("../general/noaccess.php");
return;
}
$viewServers = new ViewServers();
$viewServers->show();
break;
case 'alerts':
if (! check_acl($system->getConfig('id_user'), 0, "PM")) {
db_pandora_audit("ACL Violation",
"Trying to access Agent Data view");
require ("../general/noaccess.php");
return;
}
$viewAlerts = new ViewAlerts();
$viewAlerts->show();
break;
case 'groups':
if (! check_acl($system->getConfig('id_user'), 0, "PM")) {
db_pandora_audit("ACL Violation",
"Trying to access Agent Data view");
require ("../general/noaccess.php");
return;
}
$groupView = new GroupView();
$groupView->show();
break;
case 'events':
if (! check_acl($system->getConfig('id_user'), 0, "IR")) {
db_pandora_audit("ACL Violation",
"Trying to access event viewer");
require ("general/noaccess.php");
return;
}
$eventsView = new EventsView();
$eventsView->show();
break;
case 'monitor':
if (! check_acl($system->getConfig('id_user'), 0, "AR")) {
db_pandora_audit("ACL Violation",
"Trying to access Agent Data view");
require ("../general/noaccess.php");
return;
}
$monitorStatus = new MonitorStatus($user);
$monitorStatus->show();
break;
}
}
$home = new Home();
$home->show();
break;
case 'tactical':
$tactical = new Tactical();
$tactical->show();
break;
case 'groups':
$groups = new Groups();
$groups->show();
break;
case 'events':
$events = new Events();
$events->show();
break;
}
?>
</div>
<?php
if ($user->isLogged()) {
footer();
}
?>
</body>
</html>
<?php
$system->setSession('user', $user);
//$system->sessionDestroy();
ob_end_flush();
break;
}
?>

View File

@ -0,0 +1,239 @@
<?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.
class Events {
private $correct_acl = false;
private $default = true;
private $free_search = '';
private $hours_old = 8;
private $status = 2
private $type = "";
private $severity = -1;
private $filter = 0;
function __construct() {
$system = System::getInstance();
if ($system->checkACL("ER")) {
$this->correct_acl = true;
}
else {
$this->correct_acl = false;
}
}
private function eventsGetFilters() {
$system = System::getInstance();
$this->hours_old = $system->getRequest('hours_old', 8);
if ($this->hours_old != 8) {
$this->default = false;
}
$this->free_search = $system->getRequest('free_search', '');
if ($this->free_search != '') {
$this->default = false;
}
$this->status = $system->getRequest('status', __("Status"));
if ($this->status === __("Status")) {
$this->status = 2;
}
else {
$this->default = false;
}
$this->type = $system->getRequest('type', __("Type"));
if ($this->type === __("Type")) {
$this->type = "";
}
else {
$this->default = false;
}
$this->severity = $system->getRequest('severity', __("Severity"));
if ($this->severity === __("Severity")) {
$this->severity = -1;
}
else {
$this->default = false;
}
$this->filter = $system->getRequest('filter', __('Preset Filters'));
if ($this->filter === __("Preset Filters")) {
$this->filter = 0;
}
else {
$this->default = false;
}
///The user set a preset filter
$this->loadPresetFilter()
}
private loadPresetFilter() {
}
public function show() {
if (!$this->correct_acl) {
$this->show_fail_acl();
}
else {
$this->eventsGetFilters();
$this->show_events();
}
}
private function show_fail_acl() {
$ui = Ui::getInstance();
$ui->createPage();
$ui->addDialog(__('You don\'t have access to this page'),
__('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database'));
$ui->showPage();
}
private function show_events() {
$ui = Ui::getInstance();
$ui->createPage();
$ui->createDefaultHeader(__("PandoraFMS: Events"));
$ui->showFooter(false);
$ui->beginContent();
$filter_title = sprintf(__('Filter Events by %s'), $this->filterEventsGetString());
$ui->contentBeginCollapsible($filter_title);
$ui->beginForm();
$options = array(
'name' => 'page',
'type' => 'hidden',
'value' => 'events'
);
$ui->formAddInput($options);
$items = array('caca' => 'caca', 'pis' => 'pis',
'pedo' => 'pedo');
$options = array(
'name' => 'filter',
'title' => __('Preset Filters'),
'label' => __('Preset Filters'),
'items' => $items
);
$ui->formAddSelectBox($options);
$items = array('caca' => 'caca', 'pis' => 'pis',
'pedo' => 'pedo');
$options = array(
'name' => 'group',
'title' => __('Group'),
'label' => __('Group'),
'items' => $items
);
$items = array('caca' => 'caca', 'pis' => 'pis',
'pedo' => 'pedo');
$options = array(
'name' => 'status',
'title' => __('Status'),
'label' => __('Status'),
'items' => $items
);
$ui->formAddSelectBox($options);
$items = array('caca' => 'caca', 'pis' => 'pis',
'pedo' => 'pedo');
$options = array(
'name' => 'type',
'title' => __('Type'),
'label' => __('Type'),
'items' => $items
);
$ui->formAddSelectBox($options);
$items = array('caca' => 'caca', 'pis' => 'pis',
'pedo' => 'pedo');
$options = array(
'name' => 'severity',
'title' => __('Severity'),
'label' => __('Severity'),
'items' => $items
);
$ui->formAddSelectBox($options);
$options = array(
'name' => 'free_search',
'value' => $this->free_search,
'placeholder' => __('Free search')
);
$ui->formAddInputSearch($options);
$options = array(
'label' => __('Max. hours old'),
'name' => 'hours_old',
'value' => $this->hours_old,
'min' => 0,
'max' => 24 * 7,
'step' => 8
);
$ui->formAddSlider($options);
$options = array(
'icon' => 'refresh',
'icon_pos' => 'right',
'text' => __('Apply Filter')
);
$ui->formAddSubmitButton($options);
$html = $ui->getEndForm();
$ui->contentCollapsibleAddItem($html);
$ui->contentEndCollapsible();
$this->listEvents();
$ui->endContent();
$ui->showPage();
}
function listEvents() {
$ui = Ui::getInstance();
$system = System::getInstance();
$sql_post = '';
$result = events_get_events_grouped($sql_post,
0, $system->getPageSize(), false, false);
$events = array(
array(
__('Status') => 'icon',
__('Event Name') => 'nombre del evento',
__('Timestamp') => '2 days',
__('Agent') => 'pepito'),
array(
__('Status') => 'icon',
__('Event Name') => 'nombre del evento',
__('Timestamp') => '2 days',
__('Agent') => 'pepito'));
$ui = Ui::getInstance();
$table = new Table();
$table->importFromHash($events);
$ui->contentAddHtml($table->getHTML());
}
private function filterEventsGetString() {
if ($this->default)
return __("(Default)");
else {
if ($this->filter) {
//TODO put the name of filter
}
else {
/*
$string = sprintf(__("(Status: %s Hours: %s Type: %s Severity: %s Free Search: %s)"),
$this->hours_old,
return $string;
*/
}
}
}
}
?>

View File

@ -0,0 +1,110 @@
<?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.
include_once("../include/functions_users.php");
class Groups {
private $correct_acl = false;
private $groups = array();
private $status = array();
function __construct() {
$system = System::getInstance();
if ($system->checkACL()) {
$this->correct_acl = true;
$this->groups = $this->getListGroups();
foreach ($this->groups as $key => $group) {
$this->status[$key] = $group['status'];
unset($this->groups[$key]['status']);
}
}
else {
$this->correct_acl = false;
}
}
public function show() {
if (!$this->correct_acl) {
$this->show_fail_acl();
}
else {
$this->show_group();
}
}
private function show_fail_acl() {
$ui = Ui::getInstance();
$ui->createPage();
$ui->addDialog(__('You don\'t have access to this page'),
__('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database'));
$ui->showPage();
}
private function show_group() {
$ui = Ui::getInstance();
$ui->createPage();
$ui->createDefaultHeader(__("PandoraFMS: Groups"));
$ui->showFooter(false);
$ui->beginContent();
$table = new Table();
$table->setClass('group_view');
$table->importFromHash($this->groups);
$table->setRowClass($this->status);
$ui->contentAddHtml($table->getHTML());
$ui->endContent();
$ui->showPage();
}
private function getListGroups() {
$return = array();
$user = User::getInstance();
// Get group list that user has access
$groups_full = users_get_groups($user->getIdUser(), "AR", true, true);
$groups = array();
foreach ($groups_full as $group) {
$groups[$group['id_grupo']]['name'] = $group['nombre'];
if ($group['id_grupo'] != 0) {
$groups[$group['parent']]['childs'][] = $group['id_grupo'];
$groups[$group['id_grupo']]['prefix'] = $groups[$group['parent']]['prefix'].'&nbsp;&nbsp;&nbsp;';
}
else {
$groups[$group['id_grupo']]['prefix'] = '';
}
if (!isset($groups[$group['id_grupo']]['childs'])) {
$groups[$group['id_grupo']]['childs'] = array();
}
}
// For each valid group for this user, take data from agent and modules
foreach ($groups as $id_group => $group) {
$rows = groups_get_group_row($id_group, $groups, $group, $printed_groups, false);
if (!empty($rows))
$return = array_merge($return, $rows);
}
return $return;
}
}

View File

@ -0,0 +1,159 @@
<?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.
class Home {
private $global_search = '';
function __construct() {
$this->global_search = '';
}
public function show() {
global $config;
require_once ($config["homedir"] . '/include/functions_graph.php');
$ui = Ui::getInstance();
$ui->createPage();
$ui->createDefaultHeader(__("PandoraFMS: Home"));
$ui->showFooter(false);
$ui->beginContent();
$ui->beginForm();
$options = array(
'name' => 'global_search',
'value' => $this->global_search,
'placeholder' => __('Global search')
);
$ui->formAddInputSearch($options);
$ui->endForm();
//List of buttons
$options = array('icon' => 'gear',
'pos' => 'right',
'text' => __('Tactical'),
'href' => 'index.php?page=tactical');
$ui->contentAddHtml($ui->createButton($options));
$options = array('icon' => 'info',
'pos' => 'right',
'text' => __('Events'),
'href' => 'index.php?page=events');
$ui->contentAddHtml($ui->createButton($options));
$options = array('icon' => 'arrow-u',
'pos' => 'right',
'text' => __('Groups'),
'href' => 'index.php?page=groups');
$ui->contentAddHtml($ui->createButton($options));
$options = array('icon' => 'alert',
'pos' => 'right',
'text' => __('Alerts'),
'href' => 'index.php?page=alerts');
$ui->contentAddHtml($ui->createButton($options));
//~
//~ $ui->contentAddHtml('
//~ <style>
//~ /* Basic styles */
//~ .container div {
//~ text-align: left;
//~ border-color: #ddd;
//~ }
//~ .container p {
//~ color: #777;
//~ line-height: 140%
//~ }
//~ /* Stack all blocks to start */
//~ .container .ui-block-a,
//~ .container .ui-block-b,
//~ .container .ui-block-c {
//~ width: 100%;
//~ float: none;
//~ }
//~ /* 1st breakpoint - Float B and C, leave A full width on top */
//~ @media all and (min-width: 42em){
//~ .container div {
//~ min-height:14em;
//~ }
//~ .container .ui-block-b,
//~ .container .ui-block-c {
//~ float:left;
//~ width: 49.95%;
//~ }
//~ .container .ui-block-b p,
//~ .container .ui-block-c p {
//~ font-size:.8em;
//~ }
//~ }
//~ /* 2nd breakpoint - Float all, 50/25/25 */
//~ @media all and (min-width: 55em){
//~ .container div {
//~ min-height:17em;
//~ }
//~ .container .ui-block-a,
//~ .container .ui-block-c {
//~ float:left;
//~ width: 49.95%;
//~ }
//~ .container .ui-block-b,
//~ .container .ui-block-c {
//~ float:left;
//~ width: 24.925%;
//~ }
//~ }
//~ /* 3rd breakpoint - Bump up font size at very wide screens */
//~ @media all and (min-width: 75em){
//~ .container {
//~ font-size:125%;
//~ }
//~ .container .ui-block-a,
//~ .container .ui-block-c {
//~ float:left;
//~ width: 49.95%;
//~ }
//~ .container .ui-block-b,
//~ .container .ui-block-c {
//~ float:left;
//~ width: 24.925%;
//~ }
//~ }
//~ </style>
//~ <div class="container">
//~ <!-- Lead story block -->
//~ <div class="ui-block-a">
//~ <div class="ui-body ui-body-d">
//~ <h2>Apple schedules iPad Mini event for October 23</h2>
//~ <p>One of the worst-kept secrets in tech has been confirmed: Apple will hold an event October 23 in San Jose, California, at which the company is widely expected to unveil a smaller, cheaper version of its popular iPad called "Mini".</p>
//~ </div>
//~ </div>
//~ <!-- secondary story block #1 -->
//~ <div class="ui-block-b">
//~ <div class="ui-body ui-body-d">
//~ <h4>Microsoft Surface tablet goes on sale for $499</h4>
//~ <p>The Microsoft Surface tablet picture has come into focus. The Redmond giant filled in the blanks on the new tablets availability and specs.</p>
//~ </div>
//~ </div>
//~ <!-- secondary story block #2 -->
//~ <div class="ui-block-c">
//~ <div class="ui-body ui-body-d">
//~ <h4>AOL unveils Alto, an email service that syncs 5 accounts</h4>
//~ <p>AOL, struggling to shed its outdated image, is reimagining one of the most visibly aging parts of its platform: Its email service. </p>
//~ </div>
//~ </div>
//~ </div>');
$ui->endContent();
$ui->showPage();
return;
}
}
?>

View File

@ -0,0 +1,166 @@
<?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.
include("../include/functions_reporting.php");
include("../include/functions_servers.php");
class Tactical {
private $correct_acl = false;
function __construct() {
$system = System::getInstance();
if ($system->checkACL()) {
$this->correct_acl = true;
}
else {
$this->correct_acl = false;
}
}
public function show() {
if (!$this->correct_acl) {
$this->show_fail_acl();
}
else {
$this->show_tactical();
}
}
private function show_fail_acl() {
$ui = Ui::getInstance();
$ui->createPage();
$ui->addDialog(__('You don\'t have access to this page'),
__('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database'));
$ui->showPage();
}
private function show_tactical() {
$ui = Ui::getInstance();
$ui->createPage();
$ui->createDefaultHeader(__("PandoraFMS: Tactical"));
$ui->showFooter(false);
$ui->beginContent();
$ui->contentBeginGrid('responsive');
$data = reporting_get_group_stats();
$formatted_data = reporting_get_stats_indicators($data, 280, 20, false);
$overview = '<fieldset class="databox" style="width:97%;">
<legend style="text-align:left; color: #666;">' .
$formatted_data['server_health']['title'] .
'</legend>' .
$formatted_data['server_health']['graph'] .
'</fieldset>' .
'<fieldset class="databox" style="width:97%;">
<legend style="text-align:left; color: #666;">' .
$formatted_data['monitor_health']['title'] .
'</legend>' .
$formatted_data['monitor_health']['graph'] .
'</fieldset>' .
'</fieldset>' .
'<fieldset class="databox" style="width:97%;">
<legend style="text-align:left; color: #666;">' .
$formatted_data['module_sanity']['title'] .
'</legend>' .
$formatted_data['module_sanity']['graph'] .
'</fieldset>' .
'</fieldset>' .
'<fieldset class="databox" style="width:97%;">
<legend style="text-align:left; color: #666;">' .
$formatted_data['alert_level']['title'] .
'</legend>' .
$formatted_data['alert_level']['graph'] .
'</fieldset>';
$ui->contentGridAddCell($overview);
$formatted_data = reporting_get_stats_alerts($data);
ob_start();
$formatted_data .= reporting_get_stats_modules_status($data) . "<br />\n" .
reporting_get_stats_agents_monitors($data);
$graph_js = ob_get_clean();
$formatted_data = $graph_js . $formatted_data;
$ui->contentGridAddCell($formatted_data);
$ui->contentEndGrid();
$this->getLastActivity();
$ui->contentBeginCollapsible(__('Last activity'));
$table = new Table();
$table->importFromHash($this->getLastActivity());
$ui->contentCollapsibleAddItem($table->getHTML());
$ui->contentEndCollapsible();
$ui->endContent();
$ui->showPage();
}
private function getLastActivity() {
global $config;
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf ("SELECT id_usuario,accion,fecha,ip_origen,descripcion,utimestamp
FROM tsesion
WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - " . SECONDS_1WEEK . ")
AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 10", $config["id_user"]);
break;
case "postgresql":
$sql = sprintf ("SELECT \"id_usuario\", accion, fecha, \"ip_origen\", descripcion, utimestamp
FROM tsesion
WHERE (\"utimestamp\" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - " . SECONDS_1WEEK . ")
AND \"id_usuario\" = '%s' ORDER BY \"utimestamp\" DESC LIMIT 10", $config["id_user"]);
break;
case "oracle":
$sql = sprintf ("SELECT id_usuario, accion, fecha, ip_origen, descripcion, utimestamp
FROM tsesion
WHERE ((utimestamp > ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - " . SECONDS_1WEEK . ")
AND id_usuario = '%s') AND rownum <= 10 ORDER BY utimestamp DESC", $config["id_user"]);
break;
}
$sessions = db_get_all_rows_sql ($sql);
if ($sessions === false)
$sessions = array ();
$return = array();
foreach ($sessions as $session) {
$data = array();
switch ($config["dbtype"]) {
case "mysql":
case "oracle":
$session_id_usuario = $session['id_usuario'];
$session_ip_origen = $session['ip_origen'];
break;
case "postgresql":
$session_id_usuario = $session['id_usuario'];
$session_ip_origen = $session['ip_origen'];
break;
}
$data[__("User")] = '<strong>' . $session_id_usuario . '</strong>';
$data[__("Action")] = ui_print_session_action_icon ($session['accion'], true);
$data[__("Action")] .= $session['accion'];
$data[__("Date")] = human_time_comparation($session['utimestamp']);
$data[__("Source IP")] = $session_ip_origen;
$data[__("Description")] = io_safe_output ($session['descripcion']);
$return[] = $data;
}
return $return;
}
}
?>