From 4336870cf090dd3cfbca57fb978131506601adb7 Mon Sep 17 00:00:00 2001 From: slerena Date: Mon, 27 Jun 2011 15:27:19 +0000 Subject: [PATCH] 2011-06-27 Sancho Lerena * include/functions_config.php: Added a new function to do global system wide checks with a notification icon in the header. * general/header.php: Implemented changes on global checks. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4488 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 ++ pandora_console/general/header.php | 26 ++----- pandora_console/include/functions_config.php | 81 ++++++++++++++++++++ 3 files changed, 94 insertions(+), 20 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 7e1f88a92f..5fa724216b 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2011-06-27 Sancho Lerena + + * include/functions_config.php: Added a new function to do global + system wide checks with a notification icon in the header. + + * general/header.php: Implemented changes on global checks. + 2011-06-27 Junichi Satoh * include/functions_ui.php: Added a new function to show max/min diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index dbdafc826d..6b660ce185 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -20,27 +20,13 @@ require_once ('include/functions_servers.php'); $msg_cnt = 0; $alert_cnt = 0; +$config["alert_cnt"] = 0; $_SESSION["alert_msg"] = ""; // Check permissions -// Global error checking. - -if (!is_writable ("attachment")){ - $alert_cnt++; - - // At this first version I'm passing errors using session variables, because the error management - // is done by an AJAX request. Better solutions could be implemented in the future :-) - - $_SESSION["alert_msg"] .= '

'.__('Attachment directory is not writable by HTTP Server').'

'.'

'.__('Please check that the web server has write rights on the {HOMEDIR}/attachment directory').'

'; -} - -// Check default password for "admin" -$hashpass = db_get_sql ("SELECT password FROM tusuario WHERE id_user = 'admin'"); -if ($hashpass == "1da7ee7d45b96d0e1f45ee4ee23da560"){ - $alert_cnt++; - $_SESSION["alert_msg"] .= '

'.__('Default password for "Admin" user has not been changed.').'

'.'

'.__('Please change the default password because is a common vulnerability reported.').'

'; -} +// Global errors/warnings checking. +config_check(); ?> @@ -84,7 +70,7 @@ if ($hashpass == "1da7ee7d45b96d0e1f45ee4ee23da560"){ } } - if ($alert_cnt > 0){ + if ($config["alert_cnt"] > 0){ echo ''; ui_require_css_file ('dialog'); ui_require_jquery_file ('ui.core'); @@ -92,7 +78,7 @@ if ($hashpass == "1da7ee7d45b96d0e1f45ee4ee23da560"){ echo ''; html_print_image ("images/error.png", false, - array ("title" => __('You have %d warning(s)', $alert_cnt), "id" => "yougotalert", "class" => "bot")); + array ("title" => __('You have %d warning(s)', $config["alert_cnt"]), "id" => "yougotalert", "class" => "bot")); echo ''; echo " "; echo " "; @@ -214,7 +200,7 @@ $(document).ready (function () { 0): ?> $("#yougotmail").pulsate (); - 0): ?> + 0): ?> $("#yougotalert").pulsate (); diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index f38348e9e8..006af9769c 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -653,4 +653,85 @@ function config_process_config () { /* Finally, check if any value was overwritten in a form */ config_update_config(); } + +function config_check (){ + global $config; + + // At this first version I'm passing errors using session variables, because the error management + // is done by an AJAX request. Better solutions could be implemented in the future :-) + + // Check default password for "admin" + $hashpass = db_get_sql ("SELECT password FROM tusuario WHERE id_user = 'admin'"); + if ($hashpass == "1da7ee7d45b96d0e1f45ee4ee23da560"){ + $config["alert_cnt"]++; + $_SESSION["alert_msg"] .= '

'.__('Default password for "Admin" user has not been changed.').'

'.'

'.__('Please change the default password because is a common vulnerability reported.').'

'; + } + + if (!is_writable ("attachment")){ + $config["alert_cnt"]++; + $_SESSION["alert_msg"] .= '

'.__('Attachment directory is not writable by HTTP Server').'

'.'

'.__('Please check that the web server has write rights on the {HOMEDIR}/attachment directory').'

'; + } + + // Get remote file dir. + $remote_config = db_get_sql ("SELECT `value` FROM tconfig WHERE `token` = 'remote_config'"); + if (defined ('PANDORA_ENTERPRISE')){ + + if (!is_writable ($remote_config)){ + $config["alert_cnt"]++; + $_SESSION["alert_msg"] .= '

'.__('Remote configuration directory is not writtable for the console').' - $remote_config

'; + } + + $remote_config = $remote_config . "/conf"; + if (!is_writable ($remote_config)){ + $config["alert_cnt"]++; + $_SESSION["alert_msg"] .= '

'.__('Remote configuration directory is not writtable for the console').' - $remote_config

'; + } + + $remote_config = $remote_config . "/collections"; + if (!is_writable ($remote_config)){ + $config["alert_cnt"]++; + $_SESSION["alert_msg"] .= '

'.__('Remote configuration directory is not writtable for the console').' - $remote_config

'; + } + } + + // Check attachment directory (too much files?) + + $filecount = count(glob($config["homedir"]."/attachment/*")); + // 100 temporal files of trash should be enough for most people. + if ($filecount > 100){ + $config["alert_cnt"]++; + $_SESSION["alert_msg"] .= '

'.__('Too much files in your tempora/attachment directory').'

'; + $_SESSION["alert_msg"] .= __("There are too much files in attachment directory. This is not fatal, but you should consider cleaning up your attachment directory manually"). " ( $filecount ". __("files") . " )"; + } + + // Check database maintance + + $db_maintance = db_get_sql ("SELECT `value` FROM tconfig WHERE `token` = 'db_maintance'"); + $now = date("U"); + + $resta = $now - $db_maintance; + // ~ about 50 hr + if (($db_maintance == "") OR ($resta > 190000)){ + $config["alert_cnt"]++; + $_SESSION["alert_msg"] .= '

'.__("Database maintance problem").'

'; + $_SESSION["alert_msg"] .= __('Your database is not well maintained. Seems that it have more than 48hr without a proper maintance. Please review Pandora FMS documentation about how to execute this maintance process (pandora_db.pl) and enable it as soon as possible').''; + } + + $fontpath = db_get_sql ("SELECT `value` FROM tconfig WHERE `token` = 'fontpath'"); + if (($fontpath == "") OR (!file_exists ($fontpath))) { + $config["alert_cnt"]++; + $_SESSION["alert_msg"] .= '

'.__("Default font doesnt exist").'

'; + $_SESSION["alert_msg"] .= __('Your defined fonr doesnt exist or is not defined. Please check font parameters in your config').''; + } + + global $develop_bypass; + + if ($develop_bypass == 1){ + $config["alert_cnt"]++; + $_SESSION["alert_msg"] .= '

'.__("Developer mode is enabled").'

'; + $_SESSION["alert_msg"] .= __('Your Pandora FMS has the "develop_bypass" mode enabled. This is a developer mode and should be disabled in a production system. This value is written in the main index.php file').''; + } + +} + ?>