2009-04-21 Evi Vanoost <vanooste@rcbi.rochester.edu>

* 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
This commit is contained in:
guruevi 2009-04-21 19:03:16 +00:00
parent 97cc0fc556
commit b4f446fbad
5 changed files with 78 additions and 49 deletions

View File

@ -1,3 +1,17 @@
2009-04-21 Evi Vanoost <vanooste@rcbi.rochester.edu>
* 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 <slerena@gmail.com>
* operation/servers/view_server.php: New stats for server (threads,

View File

@ -48,6 +48,6 @@ session_write_close ();
if (file_exists ($page)) {
require_once ($page);
} else {
echo '<br /><b class="error">Sorry! I can\'t find the page $page!</b>';
echo '<br /><b class="error">Sorry! I can\'t find the page '.$page.'!</b>';
}
?>

View File

@ -82,11 +82,11 @@ echo "</a>";
// Autorefresh
echo '</td><td width="20%">';
if ($config["refr"]) {
echo '<a id="autorefresh" class="white_grey_bold" href="'.((substr ($_SERVER['REQUEST_URI'],-1) != "/") ? safe_input ($_SERVER['REQUEST_URI']) : 'index.php?' ).'&amp;refr=0"><img src="images/page_lightning.png" class="bot" alt="lightning" />&nbsp;'. __('Autorefresh');
echo '<a id="autorefresh" class="white_grey_bold" href="'.get_url_refresh ().'&amp;refr=0"><img src="images/page_lightning.png" class="bot" alt="lightning" />&nbsp;'. __('Autorefresh');
echo ' (<span id="refrcounter">'.date ("i:s", $config["refr"]).'</span>)';
echo '</a>';
} else {
echo '<a id="autorefresh" class="white_bold" href="'.((substr ($_SERVER['REQUEST_URI'],-1) != "/") ? safe_input ($_SERVER['REQUEST_URI']) : "index.php?" ).(count($_GET) ? "&amp;" : "?").'refr="><img src="images/page_lightning.png" class="bot" alt="lightning" />&nbsp;'.__('Autorefresh').'</a>';
echo '<a id="autorefresh" class="white_bold" href="'.get_url_refresh ().'&amp;refr="><img src="images/page_lightning.png" class="bot" alt="lightning" />&nbsp;'.__('Autorefresh').'</a>';
$values = array ('5' => '5 '.__('seconds'),
'10' => '10 '.__('seconds'),
'15' => '15 '.__('seconds'),

View File

@ -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 .= '&amp;'.$key.'='.$value;
}
foreach ($_POST as $key => $value) {
$query .= '&amp;'.$key.'='.$value;
}
$query = get_url_refresh (false);
$output .= '<meta http-equiv="refresh" content="'.$config["refr"].'; URL='.$query.'" />';
}
$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 .= '&amp;'.$key.'='.$value;
}
foreach ($_POST as $key => $value) {
$url .= '&amp;'.$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;
}
?>

View File

@ -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 "<h2>".__('Pandora Agents')." &raquo; ".__('Summary')."</h2>";
// Show group selector (POST)
if (isset($_POST["ag_group"])){
$ag_group = get_parameter_post ("ag_group");
echo '<form method="post" action="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=60&amp;ag_group_refresh='.$ag_group.'">';
if ($group_id > 1) {
echo '<form method="post" action="'.get_url_refresh ().'&amp;group_id='.$group_id.'">';
} else {
echo '<form method="post" action="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=60">';
echo '<form method="post" action="'.get_url_refresh ().'">';
}
echo '<table cellpadding="4" cellspacing="4" class="databox" width="95%">';
echo '<tr><td style="white-space:nowrap;">'.__('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 '</td><td style="white-space:nowrap;">';
@ -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;