From 7128b47f7eb6f2f9dabdc50cf02cece8d4a64469 Mon Sep 17 00:00:00 2001 From: guruevi Date: Tue, 21 Apr 2009 19:03:16 +0000 Subject: [PATCH] 2009-04-21 Evi Vanoost * include/functions_ui.php: Added get_url_refresh which gets the correct url to refresh a page against instead of manually reconstructing for each form. Modified process_page_head to use this new function * general/header.php: Use of new function get_url_refresh. Fixes some minor annoyances I had with this refresh when groups were selected with a post * ajax.php: Error message didn't display the right page name * operation/agentes/estado_agente.php: Fixed bug #2770377 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1640 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 14 +++ pandora_console/ajax.php | 2 +- pandora_console/general/header.php | 4 +- pandora_console/include/functions_ui.php | 86 +++++++++++-------- .../operation/agentes/estado_agente.php | 21 ++--- 5 files changed, 78 insertions(+), 49 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 53770116b0..ed78b8655d 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,17 @@ +2009-04-21 Evi Vanoost + + * include/functions_ui.php: Added get_url_refresh which gets the correct + url to refresh a page against instead of manually reconstructing for each + form. Modified process_page_head to use this new function + + * general/header.php: Use of new function get_url_refresh. Fixes some + minor annoyances I had with this refresh when groups were selected with + a post + + * ajax.php: Error message didn't display the right page name + + * operation/agentes/estado_agente.php: Fixed bug #2770377 + 2009-04-21 Sancho Lerena * operation/servers/view_server.php: New stats for server (threads, diff --git a/pandora_console/ajax.php b/pandora_console/ajax.php index c9112ba5eb..b3b01bb918 100644 --- a/pandora_console/ajax.php +++ b/pandora_console/ajax.php @@ -48,6 +48,6 @@ session_write_close (); if (file_exists ($page)) { require_once ($page); } else { - echo '
Sorry! I can\'t find the page $page!'; + echo '
Sorry! I can\'t find the page '.$page.'!'; } ?> diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 92f5cb929a..49299f58d3 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -82,11 +82,11 @@ echo ""; // Autorefresh echo ''; if ($config["refr"]) { - echo 'lightning '. __('Autorefresh'); + echo 'lightning '. __('Autorefresh'); echo ' ('.date ("i:s", $config["refr"]).')'; echo ''; } else { - echo ' '.__('Autorefresh').''; + echo 'lightning '.__('Autorefresh').''; $values = array ('5' => '5 '.__('seconds'), '10' => '10 '.__('seconds'), '15' => '15 '.__('seconds'), diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 74004b32aa..72e8e4503e 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -577,40 +577,7 @@ function process_page_head ($string, $bitfield) { $output = ''; if ($config["refr"] > 0) { - // Agent selection filters and refresh - $protocol = 'http'; - $ssl = false; - if ($config['https']) { - /* Check with "on" because some web servers like Cherokee always - set this value even if SSL is not enabled */ - if (isset ($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === true || $_SERVER['HTTPS'] == 'on')) { - $protocol = 'https'; - $ssl = true; - } - } - - $query = $protocol.'://' . $_SERVER['SERVER_NAME']; - - if ((!$ssl && $_SERVER['SERVER_PORT'] != 80) || ($ssl && $_SERVER['SERVER_PORT'] != 443)) { - $query .= ":".$_SERVER['SERVER_PORT']; - } - $query .= $_SERVER['SCRIPT_NAME']; - - if (sizeof ($_REQUEST)) - //Some (old) browsers don't like the ?&key=var - $query .= '?1=1'; - - //We don't clean these variables up as they're only being passed along - foreach ($_GET as $key => $value) { - /* Avoid the 1=1 */ - if ($key == 1) - continue; - $query .= '&'.$key.'='.$value; - } - foreach ($_POST as $key => $value) { - $query .= '&'.$key.'='.$value; - } - + $query = get_url_refresh (false); $output .= ''; } $output .= "\n\t"; @@ -1163,4 +1130,55 @@ function get_include_contents ($filename, $params = false) { return $contents; } + +/** + * Construct and return the URL to be used in order to refresh the current page correctly. + * + * @param bool $relative Whether to return the relative URL or the absolute URL. Returns relative by default + */ +function get_url_refresh ($relative = true) { + // Agent selection filters and refresh + global $config; + $url = ''; + + if (sizeof ($_REQUEST)) + //Some (old) browsers don't like the ?&key=var + $url .= '?1=1'; + + //We don't clean these variables up as they're only being passed along + foreach ($_GET as $key => $value) { + /* Avoid the 1=1 */ + if ($key == 1) + continue; + $url .= '&'.$key.'='.$value; + } + foreach ($_POST as $key => $value) { + $url .= '&'.$key.'='.$value; + } + + if ($relative === false) { + if ($config['https']) { + //When $config["https"] is set, always force https + $protocol = 'https'; + $ssl = true; + } elseif (isset ($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === true || $_SERVER['HTTPS'] == 'on')) { + $protocol = 'https'; + $ssl = true; + } else { + $protocol = 'http'; + $ssl = false; + } + + $fullurl = $protocol.'://' . $_SERVER['SERVER_NAME']; + + if ((!$ssl && $_SERVER['SERVER_PORT'] != 80) || ($ssl && $_SERVER['SERVER_PORT'] != 443)) { + $fullurl .= ":".$_SERVER['SERVER_PORT']; + } + $fullurl .= $_SERVER['SCRIPT_NAME']; + + return $fullurl.$url; + } + + return $url; +} ?> diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index df78755092..1ab80796c3 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -49,25 +49,21 @@ if (is_ajax ()) { // Take some parameters (GET) $offset = get_parameter ("offset", 0); $group_id = get_parameter ("group_id", 0); -$ag_group = get_parameter ("ag_group", $group_id); -$ag_group = get_parameter_get ("ag_group_refresh", $ag_group); //if it isn't set, defaults to prev. value $search = get_parameter ("search", ""); echo "

".__('Pandora Agents')." » ".__('Summary')."

"; -// Show group selector (POST) -if (isset($_POST["ag_group"])){ - $ag_group = get_parameter_post ("ag_group"); - echo '
'; +if ($group_id > 1) { + echo ''; } else { - echo ''; + echo ''; } echo ''; echo '
'.__('Group').': '; $groups = get_user_groups (); -print_select ($groups, 'ag_group', $ag_group, 'this.form.submit()', '', ''); +print_select ($groups, 'group_id', $group_id, 'this.form.submit()', '', ''); echo ''; @@ -88,8 +84,8 @@ if ($search != ""){ } // Show only selected groups -if ($ag_group > 1) { - $agent_names = get_group_agents ($ag_group, $search_sql, "upper"); +if ($group_id > 1) { + $agent_names = get_group_agents ($group_id, $search_sql, "upper"); // Not selected any specific group } else { $user_group = get_user_groups ($config["id_user"], "AR"); @@ -97,7 +93,8 @@ if ($ag_group > 1) { } if (!empty ($agent_names)) { - $agents = get_db_all_rows_sql (sprintf ("SELECT * FROM tagente WHERE id_agente IN (%s)", implode (",", array_keys ($agent_names)))); + $num_agents = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente WHERE id_agente IN (%s)", implode (",", array_keys ($agent_names)))); + $agents = get_db_all_rows_sql (sprintf ("SELECT * FROM tagente WHERE id_agente IN (%s) ORDER BY nombre ASC LIMIT %d,%d", implode (",", array_keys ($agent_names)), $offset, $config["block_size"])); } if (empty ($agents)) { @@ -105,7 +102,7 @@ if (empty ($agents)) { } // Prepare pagination -pagination (count ($agents), "index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=$ag_group&refr=60&search=$search", $offset); +pagination ($num_agents, get_url_refresh ()."&group_id=".$group_id."&search=".$search, $offset); // Show data. $table->cellpadding = 4;