From 39805c3f0c24cacb8dd7f8c13d97d0c0a971828c Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 5 Mar 2019 18:29:42 +0100 Subject: [PATCH 01/11] removed old useless code Former-commit-id: d378a359085f9ad8d45f40bff6c280b456a86c33 --- pandora_console/include/functions_reporting_html.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 362120e0a1..5bbf71477e 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -549,10 +549,6 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0) foreach ($item['data'] as $sla) { if (isset($sla)) { - $the_first_men_time = get_agent_first_time( - io_safe_output($sla['agent']) - ); - // First_table. $row = []; $row[] = $sla['agent']; @@ -2964,10 +2960,6 @@ function reporting_html_availability($table, $item, $pdf=0) $table2->style[5] = 'text-align: right'; foreach ($item['data'] as $row) { - $the_first_men_time = get_agent_first_time( - io_safe_output($row['agent']) - ); - $table_row = []; $table_row[] = $row['agent']; $table_row[] = $row['availability_item']; From 174256ab7082646318c7e0b9afc755ec7bed9e3c Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 26 Mar 2019 10:55:50 +0100 Subject: [PATCH 02/11] minor approach csv report Former-commit-id: a875a42dc53c85942dd8f80f0b5a0f788fb39ca5 --- pandora_console/include/functions_reporting_html.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 5bbf71477e..ea4ff5dcb6 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -3268,9 +3268,8 @@ function get_agent_first_time($agent_name) $id = agents_get_agent_id($agent_name, true); $utimestamp = db_get_all_rows_sql( - 'SELECT utimestamp FROM tagente_datos WHERE id_agente_modulo IN - (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = '.$id.') - ORDER BY utimestamp ASC LIMIT 1' + 'SELECT min(utimestamp) FROM tagente_datos WHERE id_agente_modulo IN + (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = '.$id.')' ); $utimestamp = $utimestamp[0]['utimestamp']; From c1536b79784b9465873dd75c174708818063dc88 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 26 Mar 2019 11:46:50 +0100 Subject: [PATCH 03/11] Do not crash if an extension cannot be loaded. Former-commit-id: f303be21ceabe052545e53e1a4b6bcd08a4526c2 --- pandora_console/include/functions_extensions.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandora_console/include/functions_extensions.php b/pandora_console/include/functions_extensions.php index 8efb4c8f36..4e57ea84d1 100755 --- a/pandora_console/include/functions_extensions.php +++ b/pandora_console/include/functions_extensions.php @@ -380,7 +380,15 @@ function extensions_load_extensions($process_login) // ~ } // ~ } // ~ else { + try { include_once $path_extension; + } + // PHP 7 + catch (Throwable $e) { + } + // PHP 5 + catch (Exception $e) { + } // ~ } } } From d740b328109432e8c1fba06f1baecc7f5d52e6a0 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 26 Mar 2019 11:47:20 +0100 Subject: [PATCH 04/11] Add support for DESTDIR. Former-commit-id: 0252a660a3d8250657cd5f7b8fcfd620172c8a65 --- pandora_console/include/functions.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index e1861e70a3..9816e373bb 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1438,7 +1438,13 @@ function enterprise_include($filename) global $config; // Load enterprise extensions - $filepath = realpath($config['homedir'].'/'.ENTERPRISE_DIR.'/'.$filename); + if (defined('DESTDIR')) { + $destdir = DESTDIR; + } else { + $destdir = ''; + } + + $filepath = realpath($destdir.$config['homedir'].'/'.ENTERPRISE_DIR.'/'.$filename); if ($filepath === false) { return ENTERPRISE_NOT_HOOK; From c25143c27e13f7235ccf9ba1a2f117c5976ec0a3 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 26 Mar 2019 11:53:03 +0100 Subject: [PATCH 05/11] Add a notification for 'limited mode'. Former-commit-id: dce72c7a9ea452029e5650a2012ff35cc6eca9b8 --- .../include/class/ConsoleSupervisor.php | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 64643b4c58..bddd417277 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -234,6 +234,7 @@ class ConsoleSupervisor /* * Check license. * NOTIF.LICENSE.EXPIRATION + * NOTIF.LICENSE.LIMITED */ $this->checkLicense(); @@ -537,6 +538,9 @@ class ConsoleSupervisor } switch ($data['type']) { + case 'NOTIF.LICENSE.LIMITED': + $max_age = 0; + break; case 'NOTIF.LICENSE.EXPIRATION': case 'NOTIF.FILES.ATTACHMENT': case 'NOTIF.FILES.DATAIN': @@ -684,11 +688,27 @@ class ConsoleSupervisor $days_to_expiry = ((strtotime($license['expiry_date']) - time()) / (60 * 60 * 24)); + // Limited mode. + if (isset($config['limited_mode'])) { + // Warn user if license is going to expire in 15 days or less. + $this->notify( + [ + 'type' => 'NOTIF.LICENSE.LIMITED', + 'title' => __('Limited mode.'), + 'message' => io_safe_output($config['limited_mode']), + 'url' => 'index.php?sec=gsetup&sec2=godmode/setup/license', + ] + ); + } else { + $this->cleanNotifications('NOTIF.LICENSE.LIMITED'); + } + + // Expiry. if (($days_to_expiry <= 15) && ($days_to_expiry > 0)) { // Warn user if license is going to expire in 15 days or less. $this->notify( [ - 'type' => 'NOTIF.LICENSE_EXPIRATION', + 'type' => 'NOTIF.LICENSE.EXPIRATION', 'title' => __('License is going to expire.'), 'message' => __( 'Your license is going to expire in %d days. Please contact sales.', From aa0ab53cf3d989a37d0e53b5dc289c900582ea06 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 26 Mar 2019 15:31:51 +0100 Subject: [PATCH 06/11] Clear license errors when logging in. Former-commit-id: 1f68f190ebc84202b0e39b92c12d065f8b52543c --- pandora_console/index.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandora_console/index.php b/pandora_console/index.php index 1c05a97fd8..713799570c 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -244,6 +244,11 @@ if (strlen($search) > 0) { // Login process if (! isset($config['id_user'])) { + + // Clear error messages. + unset($_COOKIE['errormsg']); + setcookie('errormsg', null, -1); + if (isset($_GET['login'])) { include_once 'include/functions_db.php'; // Include it to use escape_string_sql function From fa7cdc020b1713e0a7e8e9a005253eaadbc0162e Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 26 Mar 2019 15:32:57 +0100 Subject: [PATCH 07/11] Add a countdown to license error messages. Former-commit-id: bba7ccf777c05801731a790351dc9920b1546262 --- .../include/javascript/jquery.pandora.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/javascript/jquery.pandora.js b/pandora_console/include/javascript/jquery.pandora.js index bd0da308c4..9e0b3447af 100644 --- a/pandora_console/include/javascript/jquery.pandora.js +++ b/pandora_console/include/javascript/jquery.pandora.js @@ -163,12 +163,21 @@ $(document).ready (function () { background: "black" }, open: function() { - setTimeout(function(){ - $("#spinner_ok").hide(); + var remaining = 30; + + // Timeout counter. + var count = function() { + if (remaining > 0) { + $("#license_error_remaining").text(remaining); + remaining -= 1; + } else { + $("#license_error_remaining").hide(); $("#ok_buttom").show(); - }, - 30000 - ); + clearInterval(count); + } + } + + setInterval(count, 1000); } }); From 2cf945a5e33297818906400d8137d034d90b831d Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Tue, 26 Mar 2019 17:59:00 +0100 Subject: [PATCH 08/11] fixed minor error header disabled Former-commit-id: 87ac8d400ac83f316bf8efb1fca6afe2d60e6c8c --- pandora_console/general/header.php | 8 +- pandora_console/install.php | 1105 ---------------------------- 2 files changed, 5 insertions(+), 1108 deletions(-) delete mode 100644 pandora_console/install.php diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index aaf9bb2cda..530adacea4 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -19,10 +19,11 @@ require_once 'include/functions_notifications.php'; config_check(); -if ($_SESSION['menu_type']=='classic') +if ($_SESSION['menu_type'] == 'classic') { echo '
'; -else +} else { echo '
'; +} ?>
'; diff --git a/pandora_console/install.php b/pandora_console/install.php deleted file mode 100644 index 696d0fcf37..0000000000 --- a/pandora_console/install.php +++ /dev/null @@ -1,1105 +0,0 @@ - - - - - Pandora FMS - Installation Wizard - - - - - - - - - - - - - - - -
- -
- - - -'; - echo " $label "; - echo ''; - if (!extension_loaded($ext)) { - echo ""; - return 1; - } else { - echo ""; - return 0; - } - - echo ''; -} - -function check_include($ext, $label) -{ - echo ''; - echo " $label "; - echo ''; - if (!include $ext) { - echo ""; - return 1; - } else { - echo ""; - return 0; - } - - echo ''; -} - - -function check_exists($file, $label) -{ - echo ''; - echo " $label "; - echo ''; - if (!file_exists($file)) { - echo " "; - return 1; - } else { - echo " "; - return 0; - } - - echo ''; -} - - -function check_generic($ok, $label) -{ - echo ""; - if ($ok == 0) { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 1; - } else { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 0; - } -} - - -function check_writable($fullpath, $label) -{ - echo ""; - if (file_exists($fullpath)) { - if (is_writable($fullpath)) { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 0; - } else { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 1; - } - } else { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 1; - } -} - - -function check_variable($var, $value, $label, $mode) -{ - echo ''; - echo " $label "; - echo ''; - if ($mode == 1) { - if ($var >= $value) { - echo " "; - return 0; - } else { - echo " "; - return 1; - } - } else if ($var == $value) { - echo " "; - return 0; - } else { - echo " "; - return 1; - } - - echo ''; -} - - -function parse_mysql_dump($url) -{ - if (file_exists($url)) { - $file_content = file($url); - $query = ''; - foreach ($file_content as $sql_line) { - if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { - $query .= $sql_line; - if (preg_match("/;[\040]*\$/", $sql_line)) { - if (!$result = mysql_query($query)) { - echo mysql_error(); - // Uncomment for debug - echo "
$query
"; - return 0; - } - - $query = ''; - } - } - } - - return 1; - } else { - return 0; - } -} - - -function parse_mysqli_dump($connection, $url) -{ - if (file_exists($url)) { - $file_content = file($url); - $query = ''; - foreach ($file_content as $sql_line) { - if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { - $query .= $sql_line; - if (preg_match("/;[\040]*\$/", $sql_line)) { - if (!$result = mysqli_query($connection, $query)) { - echo mysqli_error(); - // Uncomment for debug - echo "
$query
"; - return 0; - } - - $query = ''; - } - } - } - - return 1; - } else { - return 0; - } -} - - -function random_name($size) -{ - $temp = ''; - for ($a = 0; $a < $size; $a++) { - $temp = $temp.chr(rand(122, 97)); - } - - return $temp; -} - - -function print_logo_status($step, $step_total) -{ - global $banner; - - $header = " -
-
-
- $banner -
-
"; - $header .= " -
- Install step $step of $step_total -
"; - - return $header; -} - - -// -// This function adjusts path settings in pandora db for FreeBSD. -// -// All packages and configuration files except operating system's base files -// are installed under /usr/local in FreeBSD. So, path settings in pandora db -// for some programs should be changed from the Linux default. -// -function adjust_paths_for_freebsd($engine, $connection=false) -{ - $adjust_sql = [ - "update trecon_script set script = REPLACE(script,'/usr/share','/usr/local/share');", - "update tconfig set value = REPLACE(value,'/usr/bin','/usr/local/bin') where token='netflow_daemon' OR token='netflow_nfdump' OR token='netflow_nfexpire';", - "update talert_commands set command = REPLACE(command,'/usr/bin','/usr/local/bin');", - "update talert_commands set command = REPLACE(command,'/usr/share', '/usr/local/share');", - "update tplugin set execute = REPLACE(execute,'/usr/share','/usr/local/share');", - "update tevent_response set target = REPLACE(target,'/usr/share','/usr/local/share');", - "insert into tconfig (token, value) VALUES ('graphviz_bin_dir', '/usr/local/bin');", - ]; - - for ($i = 0; $i < count($adjust_sql); $i++) { - switch ($engine) { - case 'mysql': - $result = mysql_query($adjust_sql[$i]); - break; - - case 'mysqli': - $result = mysqli_query($connection, $adjust_sql[$i]); - break; - - case 'oracle': - // Delete the last semicolon from current query - $query = substr($adjust_sql[$i], 0, (strlen($adjust_sql[$i]) - 1)); - $sql = oci_parse($connection, $query); - $result = oci_execute($sql); - break; - - case 'pgsql': - pg_send_query($connection, $adjust_sql[$i]); - $result = pg_get_result($connection); - break; - } - - if (!$result) { - return 0; - } - } - - return 1; -} - - -function install_step1() -{ - global $banner; - - echo " -
-
- ".print_logo_status(1, 6)." -
-

Welcome to Pandora FMS installation Wizard

-

This wizard helps you to quick install Pandora FMS console and main database in your system.

-

In four steps, this installer will check all dependencies and will create your configuration, ready to use.

-

For more information, please refer to documentation.
- Pandora FMS Development Team

- "; - if (file_exists('include/config.php')) { - echo "
Warning: You already have a config.php file. - Configuration and database would be overwritten if you continued.
"; - } - - echo '
'; - echo ''; - $writable = check_writable('include', 'Checking if ./include is writable'); - if (file_exists('include/config.php')) { - $writable += check_writable('include/config.php', 'Checking if include/config.php is writable'); - } - - echo '
'; - - echo "
Warning: This installer will overwrite and destroy - your existing Pandora FMS configuration and Database. Before continue, - please be sure that you have no valuable Pandora FMS data in your Database.
-
"; - - echo "
Upgrade: - If you want to upgrade from Pandora FMS 4.x to 5.0 version, please use the migration tool inside /extras directory in this setup. -
"; - - echo '
'; - - if ($writable == 0) { - echo "
"; - echo ""; - echo '
'; - } else { - echo "
ERROR:You need to setup permissions to be able to write in ./include directory
"; - } - - echo '
'; - - echo "
"; - echo " -
-
- Pandora FMS is an OpenSource Software project registered at - SourceForge -
-
"; -} - - -function install_step1_licence() -{ - echo " -
-
- ".print_logo_status(2, 6)." -
-

GPL2 Licence terms agreement

-

Pandora FMS is an OpenSource software project licensed under the GPL2 licence. Pandora FMS includes, as well, another software also licensed under LGPL and BSD licenses. Before continue, you must accept the licence terms.. -

For more information, please refer to our website at http://pandorafms.org and contact us if you have any kind of question about the usage of Pandora FMS

-

If you dont accept the licence terms, please, close your browser and delete Pandora FMS files.

- "; - - if (!file_exists('COPYING')) { - echo "
Licence file 'COPYING' is not present in your distribution. This means you have some 'partial' Pandora FMS distribution. We cannot continue without accepting the licence file."; - echo '
'; - } else { - echo "
"; - echo "'; - echo '

'; - echo "

"; - } - - echo '
'; - - echo "
-
-
- Pandora FMS is an OpenSource Software project registered at - SourceForge -
-
"; -} - - -function install_step2() -{ - echo " -
-
- ".print_logo_status(3, 6)." -
"; - echo '

Checking software dependencies

'; - echo ''; - $res = 0; - $res += check_variable(phpversion(), '7.0', 'PHP version >= 7.0', 1); - $res += check_extension('gd', 'PHP GD extension'); - $res += check_extension('ldap', 'PHP LDAP extension'); - $res += check_extension('snmp', 'PHP SNMP extension'); - $res += check_extension('session', 'PHP session extension'); - $res += check_extension('gettext', 'PHP gettext extension'); - $res += check_extension('mbstring', 'PHP Multibyte String'); - $res += check_extension('zip', 'PHP Zip'); - $res += check_extension('zlib', 'PHP Zlib extension'); - $res += check_extension('json', 'PHP json extension'); - $res += check_extension('curl', 'CURL (Client URL Library)'); - $res += check_extension('filter', 'PHP filter extension'); - $res += check_extension('calendar', 'PHP calendar extension'); - if (PHP_OS == 'FreeBSD') { - $res += check_exists('/usr/local/bin/twopi', 'Graphviz Binary'); - } else if (PHP_OS == 'NetBSD') { - $res += check_exists('/usr/pkg/bin/twopi', 'Graphviz Binary'); - } else if (substr(PHP_OS, 0, 3) == 'WIN') { - $res += check_exists("..\\..\\..\\Graphviz\\bin\\twopi.exe", 'Graphviz Binary'); - } else { - $res += check_exists('/usr/bin/twopi', 'Graphviz Binary'); - } - - echo ''; - check_extension('mysqli', 'PHP MySQL(mysqli) extension'); - echo '
'; - echo "DB Engines"; - echo ''; - echo '
'; - - if ($res > 0) { - echo " -
You have some incomplete - dependencies. Please correct them or this installer - will not be able to finish your installation. -
-
- Remember, if you install any PHP module to comply - with these dependences, you need to restart - your HTTP/Apache server after it to use the new - modules. -
-
- Ignore it. -
"; - } else { - echo "
"; - echo " - "; - echo '
'; - } - - echo '
'; - echo "
"; - echo " -
-
-
-
- Pandora FMS is an OpenSource Software project registered at - SourceForge -
-
"; -} - - -function install_step3() -{ - $options = ''; - if (extension_loaded('mysql')) { - $options .= ""; - } - - if (extension_loaded('mysqli')) { - $options .= ""; - } - - $error = false; - if (empty($options)) { - $error = true; - } - - echo " -
-
- ".print_logo_status(4, 6)." -
-

Environment and database setup

-

- This wizard will create your Pandora FMS database, - and populate it with all the data needed to run for the first time. -

-

- You need a privileged user to create database schema, this is usually root user. - Information about root user will not be used or stored anymore. -

-

- You can also deploy the scheme into an existing Database. - In this case you need a privileged Database user and password of that instance. -

-

- Now, please, complete all details to configure your database and environment setup. -

-
- Warning: This installer will overwrite and destroy your existing - Pandora FMS configuration and Database. Before continue, - please be sure that you have no valuable Pandora FMS data in your Database. -

-
"; - - if (extension_loaded('oci8')) { - echo "
For Oracle installation an existing Database with a privileged user is needed.
"; - } - - if (!$error) { - echo ""; - } - - echo ""; - echo '"; - - // the field dbgrant is only shown when the DB host is different from 127.0.0.1 or localhost - echo " - - "; - - echo " "; - - echo ""; - echo '
'; - echo 'DB Engine
'; - - if ($error) { - echo " -
- Warning: You haven't a any DB engine with PHP. Please check the previous step to DB engine dependencies. -
"; - } else { - echo "'; - - echo '
'; - echo ' Installation in
'; - echo "'; - } - - echo "
DB User with privileges
- - -
DB Password for this user
- - -
DB Hostname
- - -
DB Name (pandora by default)
- - -
Drop Database if exists
- -
Full path to HTTP publication directory
- For example /var/www/pandora_console/ -
- - -
'; - echo "URL path to Pandora FMS Console
- For example '/pandora_console' -
- -
- "; - - if (!$error) { - echo "
"; - echo " - "; - echo '
'; - ?> - - '; - - echo ''; - - echo "
"; - echo "
-
- Pandora FMS is an OpenSource Software project registered at - SourceForge -
-
"; -} - - -function install_step4() -{ - $pandora_config = 'include/config.php'; - - if ((! isset($_POST['user'])) || (! isset($_POST['dbname'])) || (! isset($_POST['host'])) - || (! isset($_POST['pass'])) || (!isset($_POST['engine'])) || (! isset($_POST['db_action'])) - ) { - $dbpassword = ''; - $dbuser = ''; - $dbhost = ''; - $dbname = ''; - $engine = ''; - $dbaction = ''; - $dbgrant = ''; - } else { - $engine = $_POST['engine']; - $dbpassword = $_POST['pass']; - $dbuser = $_POST['user']; - $dbhost = $_POST['host']; - $dbaction = $_POST['db_action']; - if (isset($_POST['dbgrant']) && $_POST['dbgrant'] != '') { - $dbgrant = $_POST['dbgrant']; - } else { - $dbgrant = $_SERVER['SERVER_ADDR']; - } - - if (isset($_POST['drop'])) { - $dbdrop = $_POST['drop']; - } else { - $dbdrop = 0; - } - - $dbname = $_POST['dbname']; - if (isset($_POST['url'])) { - $url = $_POST['url']; - } else { - $url = 'http://localhost'; - } - - if (isset($_POST['path'])) { - $path = $_POST['path']; - $path = str_replace('\\', '/', $path); - // Windows compatibility - } else { - $path = '/var/www'; - } - } - - $everything_ok = 0; - $step1 = 0; - $step2 = 0; - $step3 = 0; - $step4 = 0; - $step5 = 0; - $step6 = 0; - $step7 = 0; - - echo " -
-
- ".print_logo_status(5, 6)." -
-

Creating database and default configuration file

- "; - switch ($engine) { - case 'mysql': - if (! mysql_connect($dbhost, $dbuser, $dbpassword)) { - check_generic(0, 'Connection with Database'); - } else { - check_generic(1, 'Connection with Database'); - - // Drop database if needed and don't want to install over an existing DB - if ($dbdrop == 1) { - mysql_query("DROP DATABASE IF EXISTS `$dbname`"); - } - - // Create schema - if ($dbaction == 'db_new' || $dbdrop == 1) { - $step1 = mysql_query("CREATE DATABASE `$dbname`"); - check_generic($step1, "Creating database '$dbname'"); - } else { - $step1 = 1; - } - - if ($step1 == 1) { - $step2 = mysql_select_db($dbname); - check_generic($step2, "Opening database '$dbname'"); - - $step3 = parse_mysql_dump('pandoradb.sql'); - check_generic($step3, 'Creating schema'); - - $step4 = parse_mysql_dump('pandoradb_data.sql'); - check_generic($step4, 'Populating database'); - if (PHP_OS == 'FreeBSD') { - $step_freebsd = adjust_paths_for_freebsd($engine); - check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); - } - - $random_password = random_name(8); - $host = $dbhost; - // set default granted origin to the origin of the queries - if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { - $host = $dbgrant; - // if the granted origin is different from local machine, set the valid origin - } - - $step5 = mysql_query( - "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host - IDENTIFIED BY '".$random_password."'" - ); - mysql_query('FLUSH PRIVILEGES'); - check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
"); - - $step6 = is_writable('include'); - check_generic($step6, "Write permissions to save config file in './include'"); - - $cfgin = fopen('include/config.inc.php', 'r'); - $cfgout = fopen($pandora_config, 'w'); - $config_contents = fread($cfgin, filesize('include/config.inc.php')); - $dbtype = 'mysql'; - $config_new = ''; - $step7 = fputs($cfgout, $config_new); - $step7 = ($step7 + fputs($cfgout, $config_contents)); - if ($step7 > 0) { - $step7 = 1; - } - - fclose($cfgin); - fclose($cfgout); - chmod($pandora_config, 0600); - check_generic($step7, "Created new config file at '".$pandora_config."'"); - } - } - - if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { - $everything_ok = 1; - } - break; - - case 'mysqli': - $connection = mysqli_connect($dbhost, $dbuser, $dbpassword); - if (mysqli_connect_error() > 0) { - check_generic(0, 'Connection with Database'); - } else { - check_generic(1, 'Connection with Database'); - - // Drop database if needed and don't want to install over an existing DB - if ($dbdrop == 1) { - mysqli_query($connection, "DROP DATABASE IF EXISTS `$dbname`"); - } - - // Create schema - if ($dbaction == 'db_new' || $dbdrop == 1) { - $step1 = mysqli_query($connection, "CREATE DATABASE `$dbname`"); - check_generic($step1, "Creating database '$dbname'"); - } else { - $step1 = 1; - } - - if ($step1 == 1) { - $step2 = mysqli_select_db($connection, $dbname); - check_generic($step2, "Opening database '$dbname'"); - - $step3 = parse_mysqli_dump($connection, 'pandoradb.sql'); - check_generic($step3, 'Creating schema'); - - $step4 = parse_mysqli_dump($connection, 'pandoradb_data.sql'); - check_generic($step4, 'Populating database'); - if (PHP_OS == 'FreeBSD') { - $step_freebsd = adjust_paths_for_freebsd($engine, $connection); - check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); - } - - $random_password = random_name(8); - $host = $dbhost; - // set default granted origin to the origin of the queries - if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { - $host = $dbgrant; - // if the granted origin is different from local machine, set the valid origin - } - - $step5 = mysqli_query( - $connection, - "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host - IDENTIFIED BY '".$random_password."'" - ); - mysqli_query($connection, 'FLUSH PRIVILEGES'); - check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
"); - - $step6 = is_writable('include'); - check_generic($step6, "Write permissions to save config file in './include'"); - - $cfgin = fopen('include/config.inc.php', 'r'); - $cfgout = fopen($pandora_config, 'w'); - $config_contents = fread($cfgin, filesize('include/config.inc.php')); - $dbtype = 'mysql'; - $config_new = ''; - $step7 = fputs($cfgout, $config_new); - $step7 = ($step7 + fputs($cfgout, $config_contents)); - if ($step7 > 0) { - $step7 = 1; - } - - fclose($cfgin); - fclose($cfgout); - chmod($pandora_config, 0600); - check_generic($step7, "Created new config file at '".$pandora_config."'"); - } - } - - if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { - $everything_ok = 1; - } - break; - } - - echo '
'; - - if ($everything_ok == 1) { - echo "
"; - echo " - "; - echo '
'; - } else { - $info = "
There were some problems. - Installation was not completed. -

Please correct failures before trying again. - All database "; - if ($engine == 'oracle') { - $info .= 'objects '; - } else { - $info .= 'schemes '; - } - - $info .= 'created in this step have been dropped.

-
'; - echo $info; - - switch ($engine) { - case 'mysql': - if (mysql_error() != '') { - echo "
ERROR: ".mysql_error().'.
'; - } - - if ($step1 == 1) { - mysql_query("DROP DATABASE $dbname"); - } - break; - - case 'mysqli': - if (mysqli_error($connection) != '') { - echo "
ERROR: ".mysqli_error($connection).'.
'; - } - - if ($step1 == 1) { - mysqli_query($connection, "DROP DATABASE $dbname"); - } - break; - } - - echo '
'; - } - - echo '
'; - echo "
"; - echo " -
-
- Pandora FMS is an Open Source Software project registered at - SourceForge -
-
"; -} - - -function install_step5() -{ - echo " -
-
- ".print_logo_status(6, 6)." -
-

Installation complete

-

For security, you now must manually delete this installer - ('install.php') file before trying to access to your Pandora FMS console. -

You should also install Pandora FMS Servers before trying to monitor anything; - please read documentation on how to install it.

-

Default user is 'admin' with password 'pandora', - please change it both as soon as possible.

-

Don't forget to check http://pandorafms.com - for updates. -

Select if you want to rename 'install.php'.

-
- - -
-


. -

-
"; - - echo "
-
- Pandora FMS is an OpenSource Software project registered at - SourceForge -
-
"; -} From 004fec7454b32b33730d3b30e6bd2d61e250e9ed Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Tue, 26 Mar 2019 18:35:56 +0100 Subject: [PATCH 09/11] Revert "fixed minor error header disabled" This reverts commit 2cf945a5e33297818906400d8137d034d90b831d [formerly 87ac8d400ac83f316bf8efb1fca6afe2d60e6c8c]. Former-commit-id: 3129ccb02e68230c537e25bc5bd939c400c2ae66 --- pandora_console/general/header.php | 8 +- pandora_console/install.php | 1105 ++++++++++++++++++++++++++++ 2 files changed, 1108 insertions(+), 5 deletions(-) create mode 100644 pandora_console/install.php diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 530adacea4..aaf9bb2cda 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -19,11 +19,10 @@ require_once 'include/functions_notifications.php'; config_check(); -if ($_SESSION['menu_type'] == 'classic') { +if ($_SESSION['menu_type']=='classic') echo '
'; -} else { +else echo '
'; -} ?>
'; diff --git a/pandora_console/install.php b/pandora_console/install.php new file mode 100644 index 0000000000..696d0fcf37 --- /dev/null +++ b/pandora_console/install.php @@ -0,0 +1,1105 @@ + + + + + Pandora FMS - Installation Wizard + + + + + + + + + + + + + + + +
+ +
+ + + +'; + echo " $label "; + echo ''; + if (!extension_loaded($ext)) { + echo ""; + return 1; + } else { + echo ""; + return 0; + } + + echo ''; +} + +function check_include($ext, $label) +{ + echo ''; + echo " $label "; + echo ''; + if (!include $ext) { + echo ""; + return 1; + } else { + echo ""; + return 0; + } + + echo ''; +} + + +function check_exists($file, $label) +{ + echo ''; + echo " $label "; + echo ''; + if (!file_exists($file)) { + echo " "; + return 1; + } else { + echo " "; + return 0; + } + + echo ''; +} + + +function check_generic($ok, $label) +{ + echo ""; + if ($ok == 0) { + echo " "; + echo ''; + echo " $label "; + echo ''; + echo ''; + return 1; + } else { + echo " "; + echo ''; + echo " $label "; + echo ''; + echo ''; + return 0; + } +} + + +function check_writable($fullpath, $label) +{ + echo ""; + if (file_exists($fullpath)) { + if (is_writable($fullpath)) { + echo " "; + echo ''; + echo " $label "; + echo ''; + echo ''; + return 0; + } else { + echo " "; + echo ''; + echo " $label "; + echo ''; + echo ''; + return 1; + } + } else { + echo " "; + echo ''; + echo " $label "; + echo ''; + echo ''; + return 1; + } +} + + +function check_variable($var, $value, $label, $mode) +{ + echo ''; + echo " $label "; + echo ''; + if ($mode == 1) { + if ($var >= $value) { + echo " "; + return 0; + } else { + echo " "; + return 1; + } + } else if ($var == $value) { + echo " "; + return 0; + } else { + echo " "; + return 1; + } + + echo ''; +} + + +function parse_mysql_dump($url) +{ + if (file_exists($url)) { + $file_content = file($url); + $query = ''; + foreach ($file_content as $sql_line) { + if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { + $query .= $sql_line; + if (preg_match("/;[\040]*\$/", $sql_line)) { + if (!$result = mysql_query($query)) { + echo mysql_error(); + // Uncomment for debug + echo "
$query
"; + return 0; + } + + $query = ''; + } + } + } + + return 1; + } else { + return 0; + } +} + + +function parse_mysqli_dump($connection, $url) +{ + if (file_exists($url)) { + $file_content = file($url); + $query = ''; + foreach ($file_content as $sql_line) { + if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { + $query .= $sql_line; + if (preg_match("/;[\040]*\$/", $sql_line)) { + if (!$result = mysqli_query($connection, $query)) { + echo mysqli_error(); + // Uncomment for debug + echo "
$query
"; + return 0; + } + + $query = ''; + } + } + } + + return 1; + } else { + return 0; + } +} + + +function random_name($size) +{ + $temp = ''; + for ($a = 0; $a < $size; $a++) { + $temp = $temp.chr(rand(122, 97)); + } + + return $temp; +} + + +function print_logo_status($step, $step_total) +{ + global $banner; + + $header = " +
+
+
+ $banner +
+
"; + $header .= " +
+ Install step $step of $step_total +
"; + + return $header; +} + + +// +// This function adjusts path settings in pandora db for FreeBSD. +// +// All packages and configuration files except operating system's base files +// are installed under /usr/local in FreeBSD. So, path settings in pandora db +// for some programs should be changed from the Linux default. +// +function adjust_paths_for_freebsd($engine, $connection=false) +{ + $adjust_sql = [ + "update trecon_script set script = REPLACE(script,'/usr/share','/usr/local/share');", + "update tconfig set value = REPLACE(value,'/usr/bin','/usr/local/bin') where token='netflow_daemon' OR token='netflow_nfdump' OR token='netflow_nfexpire';", + "update talert_commands set command = REPLACE(command,'/usr/bin','/usr/local/bin');", + "update talert_commands set command = REPLACE(command,'/usr/share', '/usr/local/share');", + "update tplugin set execute = REPLACE(execute,'/usr/share','/usr/local/share');", + "update tevent_response set target = REPLACE(target,'/usr/share','/usr/local/share');", + "insert into tconfig (token, value) VALUES ('graphviz_bin_dir', '/usr/local/bin');", + ]; + + for ($i = 0; $i < count($adjust_sql); $i++) { + switch ($engine) { + case 'mysql': + $result = mysql_query($adjust_sql[$i]); + break; + + case 'mysqli': + $result = mysqli_query($connection, $adjust_sql[$i]); + break; + + case 'oracle': + // Delete the last semicolon from current query + $query = substr($adjust_sql[$i], 0, (strlen($adjust_sql[$i]) - 1)); + $sql = oci_parse($connection, $query); + $result = oci_execute($sql); + break; + + case 'pgsql': + pg_send_query($connection, $adjust_sql[$i]); + $result = pg_get_result($connection); + break; + } + + if (!$result) { + return 0; + } + } + + return 1; +} + + +function install_step1() +{ + global $banner; + + echo " +
+
+ ".print_logo_status(1, 6)." +
+

Welcome to Pandora FMS installation Wizard

+

This wizard helps you to quick install Pandora FMS console and main database in your system.

+

In four steps, this installer will check all dependencies and will create your configuration, ready to use.

+

For more information, please refer to documentation.
+ Pandora FMS Development Team

+ "; + if (file_exists('include/config.php')) { + echo "
Warning: You already have a config.php file. + Configuration and database would be overwritten if you continued.
"; + } + + echo '
'; + echo ''; + $writable = check_writable('include', 'Checking if ./include is writable'); + if (file_exists('include/config.php')) { + $writable += check_writable('include/config.php', 'Checking if include/config.php is writable'); + } + + echo '
'; + + echo "
Warning: This installer will overwrite and destroy + your existing Pandora FMS configuration and Database. Before continue, + please be sure that you have no valuable Pandora FMS data in your Database.
+
"; + + echo "
Upgrade: + If you want to upgrade from Pandora FMS 4.x to 5.0 version, please use the migration tool inside /extras directory in this setup. +
"; + + echo '
'; + + if ($writable == 0) { + echo "
"; + echo ""; + echo '
'; + } else { + echo "
ERROR:You need to setup permissions to be able to write in ./include directory
"; + } + + echo '
'; + + echo "
"; + echo " +
+
+ Pandora FMS is an OpenSource Software project registered at + SourceForge +
+
"; +} + + +function install_step1_licence() +{ + echo " +
+
+ ".print_logo_status(2, 6)." +
+

GPL2 Licence terms agreement

+

Pandora FMS is an OpenSource software project licensed under the GPL2 licence. Pandora FMS includes, as well, another software also licensed under LGPL and BSD licenses. Before continue, you must accept the licence terms.. +

For more information, please refer to our website at http://pandorafms.org and contact us if you have any kind of question about the usage of Pandora FMS

+

If you dont accept the licence terms, please, close your browser and delete Pandora FMS files.

+ "; + + if (!file_exists('COPYING')) { + echo "
Licence file 'COPYING' is not present in your distribution. This means you have some 'partial' Pandora FMS distribution. We cannot continue without accepting the licence file."; + echo '
'; + } else { + echo "
"; + echo "'; + echo '

'; + echo "

"; + } + + echo '
'; + + echo "
+
+
+ Pandora FMS is an OpenSource Software project registered at + SourceForge +
+
"; +} + + +function install_step2() +{ + echo " +
+
+ ".print_logo_status(3, 6)." +
"; + echo '

Checking software dependencies

'; + echo ''; + $res = 0; + $res += check_variable(phpversion(), '7.0', 'PHP version >= 7.0', 1); + $res += check_extension('gd', 'PHP GD extension'); + $res += check_extension('ldap', 'PHP LDAP extension'); + $res += check_extension('snmp', 'PHP SNMP extension'); + $res += check_extension('session', 'PHP session extension'); + $res += check_extension('gettext', 'PHP gettext extension'); + $res += check_extension('mbstring', 'PHP Multibyte String'); + $res += check_extension('zip', 'PHP Zip'); + $res += check_extension('zlib', 'PHP Zlib extension'); + $res += check_extension('json', 'PHP json extension'); + $res += check_extension('curl', 'CURL (Client URL Library)'); + $res += check_extension('filter', 'PHP filter extension'); + $res += check_extension('calendar', 'PHP calendar extension'); + if (PHP_OS == 'FreeBSD') { + $res += check_exists('/usr/local/bin/twopi', 'Graphviz Binary'); + } else if (PHP_OS == 'NetBSD') { + $res += check_exists('/usr/pkg/bin/twopi', 'Graphviz Binary'); + } else if (substr(PHP_OS, 0, 3) == 'WIN') { + $res += check_exists("..\\..\\..\\Graphviz\\bin\\twopi.exe", 'Graphviz Binary'); + } else { + $res += check_exists('/usr/bin/twopi', 'Graphviz Binary'); + } + + echo ''; + check_extension('mysqli', 'PHP MySQL(mysqli) extension'); + echo '
'; + echo "DB Engines"; + echo ''; + echo '
'; + + if ($res > 0) { + echo " +
You have some incomplete + dependencies. Please correct them or this installer + will not be able to finish your installation. +
+
+ Remember, if you install any PHP module to comply + with these dependences, you need to restart + your HTTP/Apache server after it to use the new + modules. +
+
+ Ignore it. +
"; + } else { + echo "
"; + echo " + "; + echo '
'; + } + + echo '
'; + echo "
"; + echo " +
+
+
+
+ Pandora FMS is an OpenSource Software project registered at + SourceForge +
+
"; +} + + +function install_step3() +{ + $options = ''; + if (extension_loaded('mysql')) { + $options .= ""; + } + + if (extension_loaded('mysqli')) { + $options .= ""; + } + + $error = false; + if (empty($options)) { + $error = true; + } + + echo " +
+
+ ".print_logo_status(4, 6)." +
+

Environment and database setup

+

+ This wizard will create your Pandora FMS database, + and populate it with all the data needed to run for the first time. +

+

+ You need a privileged user to create database schema, this is usually root user. + Information about root user will not be used or stored anymore. +

+

+ You can also deploy the scheme into an existing Database. + In this case you need a privileged Database user and password of that instance. +

+

+ Now, please, complete all details to configure your database and environment setup. +

+
+ Warning: This installer will overwrite and destroy your existing + Pandora FMS configuration and Database. Before continue, + please be sure that you have no valuable Pandora FMS data in your Database. +

+
"; + + if (extension_loaded('oci8')) { + echo "
For Oracle installation an existing Database with a privileged user is needed.
"; + } + + if (!$error) { + echo ""; + } + + echo ""; + echo '"; + + // the field dbgrant is only shown when the DB host is different from 127.0.0.1 or localhost + echo " + + "; + + echo " "; + + echo ""; + echo '
'; + echo 'DB Engine
'; + + if ($error) { + echo " +
+ Warning: You haven't a any DB engine with PHP. Please check the previous step to DB engine dependencies. +
"; + } else { + echo "'; + + echo '
'; + echo ' Installation in
'; + echo "'; + } + + echo "
DB User with privileges
+ + +
DB Password for this user
+ + +
DB Hostname
+ + +
DB Name (pandora by default)
+ + +
Drop Database if exists
+ +
Full path to HTTP publication directory
+ For example /var/www/pandora_console/ +
+ + +
'; + echo "URL path to Pandora FMS Console
+ For example '/pandora_console' +
+ +
+ "; + + if (!$error) { + echo "
"; + echo " + "; + echo '
'; + ?> + + '; + + echo ''; + + echo "
"; + echo "
+
+ Pandora FMS is an OpenSource Software project registered at + SourceForge +
+
"; +} + + +function install_step4() +{ + $pandora_config = 'include/config.php'; + + if ((! isset($_POST['user'])) || (! isset($_POST['dbname'])) || (! isset($_POST['host'])) + || (! isset($_POST['pass'])) || (!isset($_POST['engine'])) || (! isset($_POST['db_action'])) + ) { + $dbpassword = ''; + $dbuser = ''; + $dbhost = ''; + $dbname = ''; + $engine = ''; + $dbaction = ''; + $dbgrant = ''; + } else { + $engine = $_POST['engine']; + $dbpassword = $_POST['pass']; + $dbuser = $_POST['user']; + $dbhost = $_POST['host']; + $dbaction = $_POST['db_action']; + if (isset($_POST['dbgrant']) && $_POST['dbgrant'] != '') { + $dbgrant = $_POST['dbgrant']; + } else { + $dbgrant = $_SERVER['SERVER_ADDR']; + } + + if (isset($_POST['drop'])) { + $dbdrop = $_POST['drop']; + } else { + $dbdrop = 0; + } + + $dbname = $_POST['dbname']; + if (isset($_POST['url'])) { + $url = $_POST['url']; + } else { + $url = 'http://localhost'; + } + + if (isset($_POST['path'])) { + $path = $_POST['path']; + $path = str_replace('\\', '/', $path); + // Windows compatibility + } else { + $path = '/var/www'; + } + } + + $everything_ok = 0; + $step1 = 0; + $step2 = 0; + $step3 = 0; + $step4 = 0; + $step5 = 0; + $step6 = 0; + $step7 = 0; + + echo " +
+
+ ".print_logo_status(5, 6)." +
+

Creating database and default configuration file

+ "; + switch ($engine) { + case 'mysql': + if (! mysql_connect($dbhost, $dbuser, $dbpassword)) { + check_generic(0, 'Connection with Database'); + } else { + check_generic(1, 'Connection with Database'); + + // Drop database if needed and don't want to install over an existing DB + if ($dbdrop == 1) { + mysql_query("DROP DATABASE IF EXISTS `$dbname`"); + } + + // Create schema + if ($dbaction == 'db_new' || $dbdrop == 1) { + $step1 = mysql_query("CREATE DATABASE `$dbname`"); + check_generic($step1, "Creating database '$dbname'"); + } else { + $step1 = 1; + } + + if ($step1 == 1) { + $step2 = mysql_select_db($dbname); + check_generic($step2, "Opening database '$dbname'"); + + $step3 = parse_mysql_dump('pandoradb.sql'); + check_generic($step3, 'Creating schema'); + + $step4 = parse_mysql_dump('pandoradb_data.sql'); + check_generic($step4, 'Populating database'); + if (PHP_OS == 'FreeBSD') { + $step_freebsd = adjust_paths_for_freebsd($engine); + check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); + } + + $random_password = random_name(8); + $host = $dbhost; + // set default granted origin to the origin of the queries + if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { + $host = $dbgrant; + // if the granted origin is different from local machine, set the valid origin + } + + $step5 = mysql_query( + "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host + IDENTIFIED BY '".$random_password."'" + ); + mysql_query('FLUSH PRIVILEGES'); + check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
"); + + $step6 = is_writable('include'); + check_generic($step6, "Write permissions to save config file in './include'"); + + $cfgin = fopen('include/config.inc.php', 'r'); + $cfgout = fopen($pandora_config, 'w'); + $config_contents = fread($cfgin, filesize('include/config.inc.php')); + $dbtype = 'mysql'; + $config_new = ''; + $step7 = fputs($cfgout, $config_new); + $step7 = ($step7 + fputs($cfgout, $config_contents)); + if ($step7 > 0) { + $step7 = 1; + } + + fclose($cfgin); + fclose($cfgout); + chmod($pandora_config, 0600); + check_generic($step7, "Created new config file at '".$pandora_config."'"); + } + } + + if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { + $everything_ok = 1; + } + break; + + case 'mysqli': + $connection = mysqli_connect($dbhost, $dbuser, $dbpassword); + if (mysqli_connect_error() > 0) { + check_generic(0, 'Connection with Database'); + } else { + check_generic(1, 'Connection with Database'); + + // Drop database if needed and don't want to install over an existing DB + if ($dbdrop == 1) { + mysqli_query($connection, "DROP DATABASE IF EXISTS `$dbname`"); + } + + // Create schema + if ($dbaction == 'db_new' || $dbdrop == 1) { + $step1 = mysqli_query($connection, "CREATE DATABASE `$dbname`"); + check_generic($step1, "Creating database '$dbname'"); + } else { + $step1 = 1; + } + + if ($step1 == 1) { + $step2 = mysqli_select_db($connection, $dbname); + check_generic($step2, "Opening database '$dbname'"); + + $step3 = parse_mysqli_dump($connection, 'pandoradb.sql'); + check_generic($step3, 'Creating schema'); + + $step4 = parse_mysqli_dump($connection, 'pandoradb_data.sql'); + check_generic($step4, 'Populating database'); + if (PHP_OS == 'FreeBSD') { + $step_freebsd = adjust_paths_for_freebsd($engine, $connection); + check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); + } + + $random_password = random_name(8); + $host = $dbhost; + // set default granted origin to the origin of the queries + if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { + $host = $dbgrant; + // if the granted origin is different from local machine, set the valid origin + } + + $step5 = mysqli_query( + $connection, + "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host + IDENTIFIED BY '".$random_password."'" + ); + mysqli_query($connection, 'FLUSH PRIVILEGES'); + check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
"); + + $step6 = is_writable('include'); + check_generic($step6, "Write permissions to save config file in './include'"); + + $cfgin = fopen('include/config.inc.php', 'r'); + $cfgout = fopen($pandora_config, 'w'); + $config_contents = fread($cfgin, filesize('include/config.inc.php')); + $dbtype = 'mysql'; + $config_new = ''; + $step7 = fputs($cfgout, $config_new); + $step7 = ($step7 + fputs($cfgout, $config_contents)); + if ($step7 > 0) { + $step7 = 1; + } + + fclose($cfgin); + fclose($cfgout); + chmod($pandora_config, 0600); + check_generic($step7, "Created new config file at '".$pandora_config."'"); + } + } + + if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { + $everything_ok = 1; + } + break; + } + + echo '
'; + + if ($everything_ok == 1) { + echo "
"; + echo " + "; + echo '
'; + } else { + $info = "
There were some problems. + Installation was not completed. +

Please correct failures before trying again. + All database "; + if ($engine == 'oracle') { + $info .= 'objects '; + } else { + $info .= 'schemes '; + } + + $info .= 'created in this step have been dropped.

+
'; + echo $info; + + switch ($engine) { + case 'mysql': + if (mysql_error() != '') { + echo "
ERROR: ".mysql_error().'.
'; + } + + if ($step1 == 1) { + mysql_query("DROP DATABASE $dbname"); + } + break; + + case 'mysqli': + if (mysqli_error($connection) != '') { + echo "
ERROR: ".mysqli_error($connection).'.
'; + } + + if ($step1 == 1) { + mysqli_query($connection, "DROP DATABASE $dbname"); + } + break; + } + + echo '
'; + } + + echo '
'; + echo "
"; + echo " +
+
+ Pandora FMS is an Open Source Software project registered at + SourceForge +
+
"; +} + + +function install_step5() +{ + echo " +
+
+ ".print_logo_status(6, 6)." +
+

Installation complete

+

For security, you now must manually delete this installer + ('install.php') file before trying to access to your Pandora FMS console. +

You should also install Pandora FMS Servers before trying to monitor anything; + please read documentation on how to install it.

+

Default user is 'admin' with password 'pandora', + please change it both as soon as possible.

+

Don't forget to check http://pandorafms.com + for updates. +

Select if you want to rename 'install.php'.

+
+ + +
+


. +

+
"; + + echo "
+
+ Pandora FMS is an OpenSource Software project registered at + SourceForge +
+
"; +} From 4cd06539a27b40077422138ac09c9aea1fad1b0b Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Tue, 26 Mar 2019 18:37:49 +0100 Subject: [PATCH 10/11] fixed minor error refresh header Former-commit-id: 5fd75dd4fe634760c37fb06a16cc127c9cbfc71d --- pandora_console/general/header.php | 8 +++++--- pandora_console/index.php | 9 +++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index aaf9bb2cda..530adacea4 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -19,10 +19,11 @@ require_once 'include/functions_notifications.php'; config_check(); -if ($_SESSION['menu_type']=='classic') +if ($_SESSION['menu_type'] == 'classic') { echo '
'; -else +} else { echo '
'; +} ?>
'; diff --git a/pandora_console/index.php b/pandora_console/index.php index 9fb4149da0..0e1a11149a 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -173,8 +173,8 @@ if (!empty($config['https']) && empty($_SERVER['HTTPS'])) { // Pure mode (without menu, header and footer). $config['pure'] = (bool) get_parameter('pure'); -// Auto Refresh page (can now be disabled anywhere in the script) -if (get_parameter('refr')) { +// Auto Refresh page (can now be disabled anywhere in the script). +if (get_parameter('refr') != null) { $config['refr'] = (int) get_parameter('refr'); } @@ -1026,10 +1026,11 @@ if ($config['pure'] == 0) { echo '
'; From 8160983e367ef49e7b440f21a5e5c9e1ce559c63 Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 27 Mar 2019 00:01:24 +0100 Subject: [PATCH 11/11] Auto-updated build strings. Former-commit-id: 00a94a2b9b56bbb245f3389855c734f7af14d874 --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index c3a2f46b3b..c5593f4d39 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.732-190326 +Version: 7.0NG.732-190327 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index b9a4cb5aee..5325602855 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.732-190326" +pandora_version="7.0NG.732-190327" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 2dbc15fd4d..db68a4c637 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.732'; -use constant AGENT_BUILD => '190326'; +use constant AGENT_BUILD => '190327'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index a3a516effe..92a3d10086 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.732 -%define release 190326 +%define release 190327 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 9fd72d55cc..4ec527ceb8 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.732 -%define release 190326 +%define release 190327 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 4ba4e38416..5145594c3d 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.732" -PI_BUILD="190326" +PI_BUILD="190327" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 41ea57370b..ed3a26bf93 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190326} +{190327} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 1b83b2b09c..39bc92b3c3 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.732(Build 190326)") +#define PANDORA_VERSION ("7.0NG.732(Build 190327)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index c9e10dc797..ace464831d 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.732(Build 190326))" + VALUE "ProductVersion", "(7.0NG.732(Build 190327))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 98663b438d..89a8716f46 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.732-190326 +Version: 7.0NG.732-190327 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index b6b571c565..176e8bacfb 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.732-190326" +pandora_version="7.0NG.732-190327" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 37e1635bee..d33560a067 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC190326'; +$build_version = 'PC190327'; $pandora_version = 'v7.0NG.732'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 696d0fcf37..58597ed800 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index d658368835..ac50fb7e4e 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.732 -%define release 190326 +%define release 190327 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index a286cfb7ae..ebe2f3afb5 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.732 -%define release 190326 +%define release 190327 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index ba672c18d1..e38650eeb3 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.732" -PI_BUILD="190326" +PI_BUILD="190327" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 4f3148f4a7..9a1058b755 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.732 PS190326"; +my $version = "7.0NG.732 PS190327"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 56c1939227..59ea5d85b0 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.732 PS190326"; +my $version = "7.0NG.732 PS190327"; # save program name for logging my $progname = basename($0);