- moved setting of cookies from index.php into common.lib.php

- revised the parameter passing code
- make use of new functionality of PMA_generate_common_url()
This commit is contained in:
Sebastian Mendel
2005-11-29 08:46:23 +00:00
parent 277ba326df
commit 74f29a1f0e

View File

@@ -7,6 +7,7 @@
* @uses libraries/common.lib.php global fnctions
* @uses libraries/select_theme.lib.php theme manager
* @uses libraries/relation.lib.php table relations
* @uses $_SESSION['window_name_hash'] to set it
* @uses $GLOBALS['strNoFrames']
* @uses $GLOBALS['cfg']['QueryHistoryDB']
* @uses $GLOBALS['cfg']['Server']['user']
@@ -16,8 +17,6 @@
* @uses $GLOBALS['collation_connection'] from $_REQUEST (grab_globals.lib.php)
* or common.lib.php
* @uses $GLOBALS['available_languages'] from common.lib.php (select_lang.lib.php)
* @uses $GLOBALS['cookie_path'] from common.lib.php
* @uses $GLOBALS['is_https'] from common.lib.php
* @uses $GLOBALS['db']
* @uses $GLOBALS['charset']
* @uses $GLOBALS['lang']
@@ -27,7 +26,6 @@
* @uses PMA_purgeHistory()
* @uses PMA_generate_common_url()
* @uses PMA_VERSION
* @uses setcookie()
* @uses session_write_close()
* @uses time()
* @uses getenv()
@@ -39,11 +37,6 @@
*/
require_once('./libraries/common.lib.php');
setcookie('pma_lang', $lang, time() + 60*60*24*30, $cookie_path, '', $is_https);
if (isset($convcharset)) {
setcookie('pma_charset', $convcharset, time() + 60*60*24*30, $cookie_path, '', $is_https);
}
/**
* Includes the ThemeManager if it hasn't been included yet
*/
@@ -56,17 +49,6 @@ $_SESSION['window_name_hash'] = time();
// free the session file, for the other frames to be loaded
session_write_close();
/**
* Saves collation_connection (coming from main.php) in a cookie
*/
// (from grab_globals)
// TODO: move into common.lib.php line #360
if ( isset( $collation_connection ) ) {
setcookie( 'pma_collation_connection', $collation_connection,
time() + 60*60*24*30, $cookie_path, '', $is_https );
}
// Gets the host name
// loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
if (empty($HTTP_HOST)) {
@@ -87,42 +69,42 @@ $cfgRelation = PMA_getRelationsParam();
if ( $GLOBALS['cfg']['QueryHistoryDB'] && $cfgRelation['historywork'] ) {
PMA_purgeHistory( $GLOBALS['cfg']['Server']['user'] );
}
unset( $cfgRelation );
/**
* pass variables to child pages
*/
$drops = array( 'lang', 'server', 'convcharset', 'collation_connection',
'db', 'table' );
$url_querys = array();
// pass variables to child pages
foreach( $_GET as $key => $val ) {
if ( ! in_array( $key, $drops ) ) {
$url_querys[] = urlencode( $key ) . '=' . urlencode( $val );
foreach( $drops as $each_drop ) {
if ( ! array_key_exists( $each_drop, $_GET ) ) {
unset( $_GET[$each_drop] );
}
}
unset( $drops );
if ( count( $url_querys ) ) {
$url_query = implode( '&', $url_querys ) . '&';
} else {
$url_query = '';
}
unset( $url_querys );
unset( $drops, $each_drop );
if ( empty( $GLOBALS['db'] ) ) {
$url_query .= PMA_generate_common_url();
$main_target = $GLOBALS['cfg']['DefaultTabServer'];
} elseif ( empty( $GLOBALS['table'] ) ) {
$url_query .= PMA_generate_common_url( $GLOBALS['db'] );
$_GET['db'] = $GLOBALS['db'];
$main_target = $GLOBALS['cfg']['DefaultTabDatabase'];
} else {
$url_query .= PMA_generate_common_url( $GLOBALS['db'], $GLOBALS['table'] );
$_GET['db'] = $GLOBALS['db'];
$_GET['table'] = $GLOBALS['table'];
$main_target = $GLOBALS['cfg']['DefaultTabTable'];
}
if (!empty($GLOBALS['target']) && preg_match('@[a-z_]+\.php@', $GLOBALS['target']) && $GLOBALS['target'] != 'index.php') {
$url_query = PMA_generate_common_url( $_GET );
if ( ! empty( $GLOBALS['target'] )
&& preg_match( '@[a-z_]+\.php@', $GLOBALS['target'] )
&& $GLOBALS['target'] != 'index.php' ) {
$main_target = $GLOBALS['target'];
}
$main_target .= '?' . $url_query;
$main_target .= $url_query;
$lang_iso_code = $GLOBALS['available_languages'][$GLOBALS['lang']][2];
@@ -139,7 +121,8 @@ header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
<head>
<link rel="icon" href="./favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
<title>phpMyAdmin <?php echo PMA_VERSION; ?> - <?php echo htmlspecialchars($HTTP_HOST); ?></title>
<title>phpMyAdmin <?php echo PMA_VERSION; ?> -
<?php echo htmlspecialchars($HTTP_HOST); ?></title>
<meta http-equiv="Content-Type"
content="text/html; charset=<?php echo $GLOBALS['charset']; ?>" />
<script type="text/javascript" language="javascript">
@@ -158,12 +141,12 @@ header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
var pma_absolute_uri = '<?php echo $GLOBALS['cfg']['PmaAbsoluteUri']; ?>';
// ]]>
</script>
<script src="./js/querywindow.js" type="text/javascript"
language="javascript"></script>
<script src="./js/querywindow.js" type="text/javascript" language="javascript">
</script>
</head>
<frameset cols="<?php echo $GLOBALS['cfg']['LeftWidth']; ?>,*" rows="*" id="mainFrameset">
<frame frameborder="0" id="leftFrame"
src="left.php?<?php echo $url_query; ?>"
src="left.php<?php echo $url_query; ?>"
name="nav<?php echo $_SESSION['window_name_hash']; ?>" />
<frame frameborder="0" id="rightFrame"
src="<?php echo $main_target; ?>"