New URL and hidden input generating stuff.

This commit is contained in:
Michal Čihař
2003-01-08 13:50:30 +00:00
parent cbb9ea86d6
commit 1e8447e111
50 changed files with 229 additions and 559 deletions

View File

@@ -417,10 +417,10 @@ if (uname.value == '') {
}
} // end if
if (!empty($GLOBALS['SERVER_SOFTWARE']) && $GLOBALS['SERVER_SOFTWARE'] == 'Microsoft-IIS/5.0') {
header('Refresh: 0; url=' . $cfg['PmaAbsoluteUri'] . 'index.php3?lang=' . $GLOBALS['lang'] . '&server=' . $server);
header('Refresh: 0; url=' . $cfg['PmaAbsoluteUri'] . 'index.php3?' . PMA_generate_common_url());
}
else {
header('Location: ' . $cfg['PmaAbsoluteUri'] . 'index.php3?lang=' . $GLOBALS['lang'] . '&server=' . $server);
header('Location: ' . $cfg['PmaAbsoluteUri'] . 'index.php3?' . PMA_generate_common_url());
}
exit();
} // end if

View File

@@ -190,6 +190,11 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
$cfg['OBGzip'] = FALSE;
}
/**
* Include URL/hidden inputs generating.
*/
include('./libraries/url_generating.lib.php3');
/**
* Loads the mysql extensions if it is not loaded yet
@@ -333,7 +338,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
echo ' ' . $GLOBALS['strSQLQuery'] . ' : ' . "\n";
if ($is_modify_link && isset($db)) {
echo ' ['
. '<a href="db_details.php3?lang=' . $GLOBALS['lang'] . '&amp;convcharset=' . $GLOBALS['convcharset'] . '&amp;server=' . urlencode($GLOBALS['server']) . '&amp;db=' . urlencode($GLOBALS['db']) . '&amp;sql_query=' . urlencode($the_query) . '&amp;show_query=1">' . $GLOBALS['strEdit'] . '</a>'
. '<a href="db_details.php3?' . PMA_generate_common_url($GLOBALS['db']) . '&amp;sql_query=' . urlencode($the_query) . '&amp;show_query=1">' . $GLOBALS['strEdit'] . '</a>'
. ']' . "\n";
} // end if
echo '</p>' . "\n"
@@ -1061,11 +1066,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
// Reloads the navigation frame via JavaScript if required
if (isset($GLOBALS['reload']) && $GLOBALS['reload']) {
echo "\n";
$reload_url = './left.php3'
. '?lang=' . $GLOBALS['lang']
. '&convcharset=' . $GLOBALS['convcharset']
. '&server=' . $GLOBALS['server']
. ((!empty($GLOBALS['db'])) ? '&db=' . urlencode($GLOBALS['db']) : '');
$reload_url = './left.php3?' . PMA_generate_common_url($GLOBALS['db']);
?>
<script type="text/javascript" language="javascript1.2">
<!--
@@ -1135,12 +1136,7 @@ if (typeof(document.getElementById) != 'undefined'
<?php
if ($cfg['ShowSQL'] == TRUE && !empty($GLOBALS['sql_query'])) {
// Basic url query part
$url_qpart = '?convcharset=' . $GLOBALS['convcharset']
. '&amp;lang=' . $GLOBALS['lang']
. '&amp;server=' . $GLOBALS['server']
. ((!empty($GLOBALS['db'])) ? '&amp;db=' . urlencode($GLOBALS['db']) : '')
. ((!empty($GLOBALS['table'])) ? '&amp;table=' . urlencode($GLOBALS['table']) : '');
$url_qpart = '?' . PMA_generate_common_url($GLOBALS['db'], $GLOBALS['table']);
echo "\n";
?>
<tr>

View File

@@ -13,7 +13,7 @@ if (!isset($is_db) || !$is_db) {
$is_db = @PMA_mysql_select_db($db);
}
if (empty($db) || !$is_db) {
header('Location: ' . $cfg['PmaAbsoluteUri'] . 'main.php3?lang=' . $lang . '&convcharset=' . $convcharset . '&server=' . $server . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
header('Location: ' . $cfg['PmaAbsoluteUri'] . 'main.php3?' . PMA_generate_common_url() . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
exit();
}
} // end if (ensures db exists)
@@ -24,7 +24,7 @@ if (!isset($is_table) || !$is_table) {
}
if (empty($table)
|| !($is_table && @mysql_numrows($is_table))) {
header('Location: ' . $cfg['PmaAbsoluteUri'] . 'db_details.php3?lang=' . $lang . '&convcharset=' . $convcharset . '&server=' . $server . '&db=' . urlencode($db) . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
header('Location: ' . $cfg['PmaAbsoluteUri'] . 'db_details.php3?' . PMA_generate_common_url($db) . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
exit();
} else if (isset($is_table)) {
mysql_free_result($is_table);

View File

@@ -238,11 +238,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
?>
<td>
<form action="sql.php3" method="post">
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<input type="hidden" name="db" value="<?php echo $db; ?>" />
<input type="hidden" name="table" value="<?php echo $table; ?>" />
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
<input type="hidden" name="pos" value="0" />
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
@@ -255,11 +251,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
</td>
<td>
<form action="sql.php3" method="post">
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<input type="hidden" name="db" value="<?php echo $db; ?>" />
<input type="hidden" name="table" value="<?php echo $table; ?>" />
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
<input type="hidden" name="pos" value="<?php echo $pos_prev; ?>" />
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
@@ -280,11 +272,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
<td align="center">
<form action="sql.php3" method="post"
onsubmit="return (checkFormElementInRange(this, 'session_max_rows', 1) && checkFormElementInRange(this, 'pos', 0, <?php echo $unlim_num_rows - 1; ?>))">
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<input type="hidden" name="db" value="<?php echo $db; ?>" />
<input type="hidden" name="table" value="<?php echo $table; ?>" />
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
@@ -329,11 +317,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
?>
<td>
<form action="sql.php3" method="post">
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<input type="hidden" name="db" value="<?php echo $db; ?>" />
<input type="hidden" name="table" value="<?php echo $table; ?>" />
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
<input type="hidden" name="pos" value="<?php echo $pos_next; ?>" />
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
@@ -347,11 +331,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
<td>
<form action="sql.php3" method="post"
onsubmit="return <?php echo (($pos + $session_max_rows < $unlim_num_rows && $num_rows >= $session_max_rows) ? 'true' : 'false'); ?>">
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<input type="hidden" name="db" value="<?php echo $db; ?>" />
<input type="hidden" name="table" value="<?php echo $table; ?>" />
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
<input type="hidden" name="pos" value="<?php echo $unlim_num_rows - $session_max_rows; ?>" />
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
@@ -374,11 +354,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
</td>
<td>
<form action="sql.php3" method="post">
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<input type="hidden" name="db" value="<?php echo $db; ?>" />
<input type="hidden" name="table" value="<?php echo $table; ?>" />
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
<input type="hidden" name="pos" value="0" />
<input type="hidden" name="session_max_rows" value="all" />
@@ -460,12 +436,8 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
? ' rowspan="2"'
: '';
}
$text_url = 'sql.php3'
. '?lang=' . $lang
. '&amp;convcharset=' . $convcharset
. '&amp;server=' . $server
. '&amp;db=' . urlencode($db)
. '&amp;table=' . urlencode($table)
$text_url = 'sql.php3?'
. PMA_generate_common_url($db, $table)
. '&amp;sql_query=' . urlencode($sql_query)
. '&amp;pos=' . $pos
. '&amp;session_max_rows=' . $session_max_rows
@@ -634,11 +606,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
} else {
$sorted_sql_query = $unsorted_sql_query . $sort_order;
}
$url_query = 'lang=' . $lang
. '&amp;convcharset=' . $convcharset
. '&amp;server=' . $server
. '&amp;db=' . urlencode($db)
. '&amp;table=' . urlencode($table)
$url_query = PMA_generate_common_url($db, $table)
. '&amp;pos=' . $pos
. '&amp;session_max_rows=' . $session_max_rows
. '&amp;disp_direction=' . $disp_direction
@@ -914,11 +882,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
} // end if (1.1)
// 1.2 Defines the urls for the modify/delete link(s)
$url_query = 'lang=' . $lang
. '&amp;convcharset=' . $convcharset
. '&amp;server=' . $server
. '&amp;db=' . urlencode($db)
. '&amp;table=' . urlencode($table)
$url_query = PMA_generate_common_url($db, $table)
. '&amp;pos=' . $pos
. '&amp;session_max_rows=' . $session_max_rows
. '&amp;disp_direction=' . $disp_direction
@@ -963,11 +927,8 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
. '?' . str_replace('&amp;', '&', $url_query)
. '&sql_query=' . urlencode($sql_query)
. '&goto=main.php3';
$del_url = 'sql.php3'
. '?lang=' . $lang
. '&amp;convcharset=' . $convcharset
. '&amp;server=' . $server
. '&amp;db=mysql'
$del_url = 'sql.php3?'
. PMA_generate_common_url('mysql')
. '&amp;sql_query=' . urlencode('KILL ' . $row['Id'])
. '&amp;goto=' . urlencode($lnk_goto);
$js_conf = 'KILL ' . $row['Id'];
@@ -1051,9 +1012,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
$title = (!empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';
$vertical_display['data'][$row_no][$i] .= '<a href="sql.php3?'
. 'lang=' . $lang . '&amp;server=' . $server
. '&amp;convcharset=' . $convcharset
. '&amp;db=' . urlencode($db) . '&amp;table=' . urlencode($map[$meta->name][0])
. PMA_generate_common_url($db, $map[$meta->name][0])
. '&amp;pos=0&amp;session_max_rows=' . $session_max_rows . '&amp;dontlimitchars=' . $dontlimitchars
. '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$pointer]) . '"' . $title . '>'
. $row[$pointer] . '</a>';
@@ -1162,9 +1121,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
$title = (!empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';
$vertical_display['data'][$row_no][$i] .= '<a href="sql.php3?'
. 'lang=' . $lang . '&amp;convcharset=' . $convcharset
. '&amp;server=' . $server
. '&amp;db=' . urlencode($db) . '&amp;table=' . urlencode($map[$meta->name][0])
. PMA_generate_common_url($db, $map[$meta->name][0])
. '&amp;pos=0&amp;session_max_rows=' . $session_max_rows . '&amp;dontlimitchars=' . $dontlimitchars
. '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = \'' . PMA_sqlAddslashes($relation_id) . '\'') . '"' . $title . '>'
. $row[$pointer] . '</a>';

View File

@@ -0,0 +1,46 @@
<?php
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* URL/hidden inputs generating.
*/
if (!defined('PMA_URL_GENERATION_LIB_INCLUDED')){
define('PMA_URL_GENERATION_LIB_INCLUDED', 1);
function PMA_generate_common_hidden_inputs ($db = '', $table = '')
{
global $lang, $convcharset, $server;
global $cfg, $allow_recoding;
$result = '<input type="hidden" name="lang" value="' . $lang . '" />' . "\n" .
'<input type="hidden" name="server" value="' . $server . '" />' . "\n";
if (isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)
$result .= '<input type="hidden" name="convcharset" value="' . $convcharset . '" />' . "\n";
if (!empty($db))
$result .= '<input type="hidden" name="db" value="'.htmlspecialchars($db).'" />';
if (!empty($table))
$result .= '<input type="hidden" name="table" value="'.htmlspecialchars($table).'" />';
return $result;
}
function PMA_generate_common_url ($db = '', $table = '')
{
global $lang, $convcharset, $server;
global $cfg, $allow_recoding;
$result = 'lang=' . $lang
. '&amp;server=' . $server;
if (isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)
$result .= '&amp;convcharset=' . $convcharset;
if (!empty($db))
$result .= '&amp;db='.urlencode($db);
if (!empty($table))
$result .= '&amp;table='.urlencode($table);
return $result;
}
}
?>