diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e648053013..2b4603c29f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,20 @@ +2009-03-05 Evi Vanoost + + * include/auth/ldap.php: Fixed a small issue to check on a variable + + * include/functions_extensions.php: Fixed an issue since errors + produced with @function will filter into custom error handlers + + * include/functions_ui.php: Added RSS link in the header to display + RSS feed availability in RSS-enabled browsers + + * operation/events/events_marquee.php, + operation/events/events_statistics.php: require_once so it won't load + the same function files twice + + * operation/events/events_rss.php: Better error handling. Require_once + required because it was giving a problem with certain function files. + 2009-03-05 Esteban Sanchez * include/functions_config.php: Fixed auth files inclusion that may diff --git a/pandora_console/include/auth/ldap.php b/pandora_console/include/auth/ldap.php index 0065e8b3c6..f5d81489e0 100644 --- a/pandora_console/include/auth/ldap.php +++ b/pandora_console/include/auth/ldap.php @@ -466,9 +466,9 @@ function ldap_connect_bind () { $ret = false; - if (!empty ($config["auth"]["ldap_port"]) && !is_resource ($ldap_cache["ds"])) { + if (!empty ($config["auth"]["ldap_port"]) && (empty ($ldap_cache["ds"]) || !is_resource ($ldap_cache["ds"]))) { $ldap_cache["ds"] = @ldap_connect ($config["auth"]["ldap_server"], $config["auth"]["ldap_port"]); - } elseif (!is_resource ($ldap_cache["ds"])) { + } elseif (empty ($ldap_cache["ds"]) || !is_resource ($ldap_cache["ds"])) { $ldap_cache["ds"] = @ldap_connect ($config["auth"]["ldap_server"]); } else { return true; diff --git a/pandora_console/include/functions_extensions.php b/pandora_console/include/functions_extensions.php index 1240803741..31fe1623ad 100644 --- a/pandora_console/include/functions_extensions.php +++ b/pandora_console/include/functions_extensions.php @@ -83,12 +83,16 @@ function is_extension ($page) { */ function get_extensions ($enterprise = false) { $dir = EXTENSIONS_DIR; + $handle = false; if ($enterprise) $dir = ENTERPRISE_DIR.'/'.EXTENSIONS_DIR; - $handle = @opendir ($dir); - if (! $handle) { + + if (file_exists ($dir)) + $handle = @opendir ($dir); + + if (empty ($handle)) return; - } + $file = readdir ($handle); $extensions = array (); $ignores = array ('.', '..'); diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index db8d825211..8a579db6d6 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -569,7 +569,8 @@ function process_page_head ($string, $bitfield) { '; + + '; if ($config["language"] != "en") { //Load translated strings - load them last so they overload all the objects diff --git a/pandora_console/operation/events/event_statistics.php b/pandora_console/operation/events/event_statistics.php index 79d0a205e3..3362961633 100644 --- a/pandora_console/operation/events/event_statistics.php +++ b/pandora_console/operation/events/event_statistics.php @@ -18,7 +18,7 @@ // Load global vars -require("include/config.php"); +require_once ("include/config.php"); check_login (); diff --git a/pandora_console/operation/events/events_marquee.php b/pandora_console/operation/events/events_marquee.php index c40b90daf3..b92040cb57 100644 --- a/pandora_console/operation/events/events_marquee.php +++ b/pandora_console/operation/events/events_marquee.php @@ -28,7 +28,7 @@ $MARQUEE_FONT_SIZE="32px"; $MARQUEE_SPEED=12; $output = ""; -require "../../include/config.php"; +require_once "../../include/config.php"; require_once "../../include/functions.php"; require_once "../../include/functions_db.php"; diff --git a/pandora_console/operation/events/events_rss.php b/pandora_console/operation/events/events_rss.php index b4acd9dd89..11f530a09f 100644 --- a/pandora_console/operation/events/events_rss.php +++ b/pandora_console/operation/events/events_rss.php @@ -3,7 +3,7 @@ // ======================================== // Copyright (c) 2004-2007 Sancho Lerena, slerena@openideas.info // Copyright (c) 2005-2007 Artica Soluciones Tecnologicas -// Copyright (c) 2008 Evi Vanoost, vanooste@rcbi.rochester.edu +// Copyright (c) 2008-2009 Evi Vanoost, vanooste@rcbi.rochester.edu // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -16,10 +16,35 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require "../../include/config.php"; -require "../../include/functions.php"; +ini_set ('display_errors', 0); //Don't display other errors, messes up XML +header("Content-Type: application/xml; charset=UTF-8"); //Send header before starting to output + +require_once "../../include/config.php"; +require_once "../../include/functions.php"; require_once "../../include/functions_db.php"; +function rss_error_handler ($errno, $errstr, $errfile, $errline) { + global $config; + + $base = 'http'.(isset ($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == TRUE ? 's': '').'://'.$_SERVER['HTTP_HOST']; + $url = $base.$config["homeurl"]; + $selfurl = $base.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; + + $rss_feed = ''; //' Fixes certain highlighters freaking out on the PHP closing tag + $rss_feed .= ''; + $rss_feed .= 'Pandora RSS FeedLatest events on Pandora'; + $rss_feed .= ''.date (DATE_RFC822, 0).''; + $rss_feed .= ''.$url.''; //Link back to the main Pandora page + $rss_feed .= ''; //Alternative for Atom feeds. It's the same. + + $rss_feed .= ''.$url.'/index.php?sec=eventos&sec2=operation/events/eventsError creating feed'; + $rss_feed .= 'There was an error creating the feed: '.$errno.' - '.$errstr.' in '.$errfile.' on line '.$errline.''; + $rss_feed .= ''.$url.'/index.php?sec=eventos&sec2=operation/events/events'; + + exit ($rss_feed); //Exit by displaying the feed +} + +set_error_handler ('rss_error_handler', E_ALL); //Errors output as RSS $ev_group = get_parameter ("ev_group", 0); // group $search = get_parameter ("search", ""); // free search $event_type = get_parameter ("event_type", ''); // 0 all @@ -36,11 +61,11 @@ if ($status == 1) if ($status == 0) $sql_post .= " AND `tevento`.`estado` = 0"; if ($search != "") - $sql_post .= " AND `tevento`.`evento` LIKE '%$search%'"; + $sql_post .= " AND `tevento`.`evento` LIKE '%$search%'"; if ($event_type != "") - $sql_post .= " AND `tevento`.`event_type` = '$event_type'"; + $sql_post .= " AND `tevento`.`event_type` = '$event_type'"; if ($severity != -1) - $sql_post .= " AND `tevento`.`criticity` >= ".$severity; + $sql_post .= " AND `tevento`.`criticity` >= ".$severity; if ($id_agent != -1) $sql_post .= " AND `tevento`.`id_agente` = ".$id_agent; if ($id_event != -1) @@ -58,17 +83,24 @@ $sql="SELECT `tevento`.`id_evento` AS event_id, $result= get_db_all_rows_sql ($sql); -//$url = "https://".$_SERVER['HTTP_HOST']."/pandora_console"; +$base = 'http'.(isset ($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == TRUE ? 's': '').'://'.$_SERVER['HTTP_HOST']; +$url = $base.$config["homeurl"]; +$selfurl = $base.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; -$url = 'http://'.$_SERVER['HTTP_HOST'].$config["homeurl"]; -$selfurl = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; -$rss_feed = ''; +if (empty ($result)) { + $lastbuild = 0; //Last build in 1970 +} else { + $lastbuild = (int) $result[0]['unix_timestamp']; +} + +$rss_feed = ''; //' Fixes certain highlighters freaking out on the PHP closing tag +$rss_feed .= ''; $rss_feed .= 'Pandora RSS FeedLatest events on Pandora'; -$rss_feed .= ''.date(DATE_RFC822, $result[0]['unix_timestamp']).''; -$rss_feed .= ''.$url.''; -$rss_feed .= ''; +$rss_feed .= ''.date (DATE_RFC822, $lastbuild).''; //Last build date is the last event - that way readers won't mark it as having new posts +$rss_feed .= ''.$url.''; //Link back to the main Pandora page +$rss_feed .= ''; //Alternative for Atom feeds. It's the same. -if ($result === false) { +if (empty ($result)) { $result = array(); $rss_feed .= ''.$url.'/index.php?sec=eventos&sec2=operation/events/eventsNo results'; $rss_feed .= 'There are no results. Click on the link to see all Pending events'; @@ -99,6 +131,5 @@ foreach ($result as $row) { $rss_feed .= ""; -header("Content-Type: application/xml; charset=UTF-8"); echo $rss_feed; -?> +?> \ No newline at end of file