From 70aac98112858d3bf422b8121e53211743d32c5b Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Fri, 15 Mar 2013 14:50:47 +0000 Subject: [PATCH] 2013-03-15 Miguel de Dios * 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 --- pandora_console/ChangeLog | 5 +- pandora_console/mobile/include/db.class.php | 17 +- pandora_console/mobile/include/style/main.css | 310 ++------ .../mobile/include/style/main.css.old | 271 +++++++ .../mobile/include/system.class.php | 34 +- pandora_console/mobile/include/ui.class.php | 683 ++++++++++++++++++ pandora_console/mobile/include/user.class.php | 223 +++--- pandora_console/mobile/index.php | 247 ++----- pandora_console/mobile/operation/events.php | 239 ++++++ pandora_console/mobile/operation/groups.php | 110 +++ pandora_console/mobile/operation/home.php | 159 ++++ pandora_console/mobile/operation/tactical.php | 166 +++++ 12 files changed, 1908 insertions(+), 556 deletions(-) create mode 100755 pandora_console/mobile/include/style/main.css.old create mode 100755 pandora_console/mobile/include/ui.class.php create mode 100644 pandora_console/mobile/operation/events.php create mode 100644 pandora_console/mobile/operation/groups.php create mode 100644 pandora_console/mobile/operation/home.php create mode 100755 pandora_console/mobile/operation/tactical.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index f8983bcfb1..680c023667 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,7 @@ +2013-03-15 Miguel de Dios + + * mobile/*: added first version of new mobile console. + 2013-03-15 Miguel de Dios * 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 * include/functions_events.php, include/functions_html.php, diff --git a/pandora_console/mobile/include/db.class.php b/pandora_console/mobile/include/db.class.php index 9e5aacf596..7db3b2b944 100644 --- a/pandora_console/mobile/include/db.class.php +++ b/pandora_console/mobile/include/db.class.php @@ -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; + } } ?> \ No newline at end of file diff --git a/pandora_console/mobile/include/style/main.css b/pandora_console/mobile/include/style/main.css index 5cafa1ffba..030fe86e48 100644 --- a/pandora_console/mobile/include/style/main.css +++ b/pandora_console/mobile/include/style/main.css @@ -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; +} \ No newline at end of file diff --git a/pandora_console/mobile/include/style/main.css.old b/pandora_console/mobile/include/style/main.css.old new file mode 100755 index 0000000000..5cafa1ffba --- /dev/null +++ b/pandora_console/mobile/include/style/main.css.old @@ -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---------------------------------------------------*/ diff --git a/pandora_console/mobile/include/system.class.php b/pandora_console/mobile/include/system.class.php index 76263a0588..94a4c23a89 100644 --- a/pandora_console/mobile/include/system.class.php +++ b/pandora_console/mobile/include/system.class.php @@ -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 "
";
-		var_dump($var);
-		echo "
"; - } - 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; + } + } } ?> \ No newline at end of file diff --git a/pandora_console/mobile/include/ui.class.php b/pandora_console/mobile/include/ui.class.php new file mode 100755 index 0000000000..6023ddcb74 --- /dev/null +++ b/pandora_console/mobile/include/ui.class.php @@ -0,0 +1,683 @@ + 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 "
" .
+				date("Y/m/d H:i:s") . " (" . gettype($var) . ") " . $more_info .
+				"
"; + echo "
";print_r($var);echo "
"; + } + } + + 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 = '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 ""; + } + + 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 = "
\n"; + + reset($convert_cells_jquery_grid); + foreach ($this->grid['cells'] as $cell) { + switch ($this->grid['mode']) { + default: + case 'responsive': + $html .= "
\n"; + break; + } + next($convert_cells_jquery_grid); + $html .= "
\n"; + $html .= $cell; + $html .= "
\n"; + + $html .= "
\n"; + } + + $html .= "
\n"; + + $this->contentAddHtml($html); + $this->grid = array(); + } + + public function contentBeginCollapsible($title = " ") { + $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 = "
\n"; + $html .= "

" . $this->collapsible['title'] . "

\n"; + + $html .= "
    \n"; + foreach ($this->collapsible['items'] as $item) { + $html .= "
  • " . $item . "
  • "; + } + $html .= "
\n"; + + $html .= "
\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 = "
\n"; + foreach ($this->form['fields'] as $field) { + $html .= $field . "\n"; + } + $html .= "
\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 = "
\n"; + $html .= "
\n"; + if (!empty($options['label'])) { + $html .= "\n"; + } + + //Erase other options and only for the input + unset($options['label']); + + $html .= " $value) { + $html .= " " . $option . "='" . $value . "' "; + } + $html .= ">\n"; + + $html .= "
\n"; + $html .= "
\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 = "
\n"; + $html .= "
\n"; + if (!empty($options['label'])) { + $html .= "\n"; + } + + $html .= "\n"; + + $html .= "
\n"; + $html .= "
\n"; + + $this->formAddHtml($html); + } + + public function formAddSlider($options) { + $options['type'] = 'range'; + + $this->formAddInput($options); + // + } + + public function addDialog($title = '', $content = '', $button_text = '') { + $this->dialog = "
\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 "\n"; + echo "\n"; + echo " \n"; + echo " " . $this->title . "\n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + if (!empty($this->dialog)) { + echo " " . $this->dialog . "\n"; + } + echo "
\n"; + echo "
\n"; + echo "

" . $this->header['title'] . "

\n"; + echo " " . $this->header['button_left'] . "\n"; + echo " " . $this->header['button_right'] . "\n"; + echo "
\n"; + echo "
\n"; + foreach ($this->content as $content) { + echo " " . $content . "\n"; + } + echo "
\n"; + if (!$this->noFooter) { + echo "
\n"; + if (!empty($this->footer['text'])) { + echo " " . $this->footer['text'] . "\n"; + } + else { + echo " " . $this->defaultFooter() . "\n"; + } + } + echo "
\n"; + echo "
\n"; + echo " \n"; + echo ""; + 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 = "\n"; + + + $html .= "\n"; + $html .= "\n"; + //Empty head for white space between rows in the responsive vertical layout + $html .= "\n"; + foreach ($this->head as $head) { + $html .= "\n"; + } + $html .= "\n"; + $html .= "\n"; + + + $html .= "\n"; + foreach ($this->rows as $key => $row) { + $class = ''; + if (isset($this->rowClass[$key])) { + $class = $this->rowClass[$key]; + } + + $html .= "\n"; + //Empty head for white space between rows in the responsive vertical layout + $html .= "\n"; + foreach ($row as $cell) { + $html .= "\n"; + } + $html .= "\n"; + } + + $html .= "
" . $head . "
" . $cell . "
\n"; + $html .= "\n"; + + return $html; + } +} + +?> diff --git a/pandora_console/mobile/include/user.class.php b/pandora_console/mobile/include/user.class.php index 9fda9b1d75..16ceda8c24 100644 --- a/pandora_console/mobile/include/user.class.php +++ b/pandora_console/mobile/include/user.class.php @@ -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 "
"; - html_print_input_hidden('action', 'login'); - ?> -
-
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- -
 user, __('User'), 10, 20);?>
 
  
   
-
 
 
  - ' . __('Your IP').':' . $this->system->getConfig("remote_addr") . ' ';?> -
   
-
-
- "; + $ui = Ui::getInstance(); - /* - ?> -
-
-
-
-

- ' . __('Your IP').':' . $this->system->getConfig("remote_addr"); - ?> -

-
- "; - echo "
" . $pandora_version . "
"; - 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 ""; - ?> -
-
-
- 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('
' . + html_print_image ("images/pandora_login.png", + true, array ("alt" => "logo", "border" => 0)) . + '
'); + $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() { diff --git a/pandora_console/mobile/index.php b/pandora_console/mobile/index.php index 2eb9e8e4fe..5ad10be148 100644 --- a/pandora_console/mobile/index.php +++ b/pandora_console/mobile/index.php @@ -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(); } -?> - - - - - Pandora FMS - <?php echo __('the Flexible Monitoring System (mobile version)'); ?> - - - - -
- - - 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('' . __('LOGOUT') . ''); - 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; } - ?> -
- isLogged()) { - footer(); - } - ?> - - -setSession('user', $user); -//$system->sessionDestroy(); -ob_end_flush(); + break; +} ?> diff --git a/pandora_console/mobile/operation/events.php b/pandora_console/mobile/operation/events.php new file mode 100644 index 0000000000..a9d3b00e84 --- /dev/null +++ b/pandora_console/mobile/operation/events.php @@ -0,0 +1,239 @@ +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.

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; + */ + } + } + } +} + +?> \ No newline at end of file diff --git a/pandora_console/mobile/operation/groups.php b/pandora_console/mobile/operation/groups.php new file mode 100644 index 0000000000..02c0c1e4af --- /dev/null +++ b/pandora_console/mobile/operation/groups.php @@ -0,0 +1,110 @@ +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.

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'].'   '; + } + 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; + } +} \ No newline at end of file diff --git a/pandora_console/mobile/operation/home.php b/pandora_console/mobile/operation/home.php new file mode 100644 index 0000000000..e80ea75229 --- /dev/null +++ b/pandora_console/mobile/operation/home.php @@ -0,0 +1,159 @@ +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(' + //~ + //~
+ //~ + //~
+ //~
+ //~

Apple schedules iPad Mini event for October 23

+ //~

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".

+ //~
+ //~
+ //~ + //~
+ //~
+ //~

Microsoft Surface tablet goes on sale for $499

+ //~

The Microsoft Surface tablet picture has come into focus. The Redmond giant filled in the blanks on the new tablets availability and specs.

+ //~
+ //~
+ //~ + //~
+ //~
+ //~

AOL unveils Alto, an email service that syncs 5 accounts

+ //~

AOL, struggling to shed its outdated image, is reimagining one of the most visibly aging parts of its platform: Its email service.

+ //~
+ //~
+//~
'); + + $ui->endContent(); + $ui->showPage(); + return; + } +} +?> \ No newline at end of file diff --git a/pandora_console/mobile/operation/tactical.php b/pandora_console/mobile/operation/tactical.php new file mode 100755 index 0000000000..0ac238afec --- /dev/null +++ b/pandora_console/mobile/operation/tactical.php @@ -0,0 +1,166 @@ +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.

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 = '
+ ' . + $formatted_data['server_health']['title'] . + '' . + $formatted_data['server_health']['graph'] . + '
' . + '
+ ' . + $formatted_data['monitor_health']['title'] . + '' . + $formatted_data['monitor_health']['graph'] . + '
' . + '' . + '
+ ' . + $formatted_data['module_sanity']['title'] . + '' . + $formatted_data['module_sanity']['graph'] . + '
' . + '' . + '
+ ' . + $formatted_data['alert_level']['title'] . + '' . + $formatted_data['alert_level']['graph'] . + '
'; + $ui->contentGridAddCell($overview); + + $formatted_data = reporting_get_stats_alerts($data); + ob_start(); + $formatted_data .= reporting_get_stats_modules_status($data) . "
\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")] = '' . $session_id_usuario . ''; + $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; + } +} +?>