diff --git a/ChangeLog b/ChangeLog index 09cc8bdd4..6ddb0de61 100755 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,10 @@ $Source$ libraries/display_export.lib.php, libraries/export/htmlword.php: Word export now can contain table structure and better handles more tables/databases export. + * db_operations.php, export.php, main.php, tbl_move_copy.php, + libraries/common.lib.php, libraries/select_theme.lib.php, + libraries/auth/cookie.auth.lib.php: Unified cookie path handling, added + / to end of path (bug #1155373). 2005-03-06 Marc Delisle * libraries/relation.lib.php, /display_export.lib.php, diff --git a/db_operations.php b/db_operations.php index e1da3085b..8761d997b 100644 --- a/db_operations.php +++ b/db_operations.php @@ -47,10 +47,10 @@ if (isset($db) && } else { $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']); if (isset($switch_to_new) && $switch_to_new == 'true') { - setcookie('pma_switch_to_new', 'true', 0, substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')), '', ($pma_uri_parts['scheme'] == 'https')); + setcookie('pma_switch_to_new', 'true', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); $db = $newname; } else { - setcookie('pma_switch_to_new', '', 0, substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')), '', ($pma_uri_parts['scheme'] == 'https')); + setcookie('pma_switch_to_new', '', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); } } } diff --git a/export.php b/export.php index f9bc882aa..7997fd671 100644 --- a/export.php +++ b/export.php @@ -187,23 +187,17 @@ if ($asfile) { $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']); if ($export_type == 'server') { if (isset($remember_template)) { - setcookie('pma_server_filename_template', $filename_template , 0, - substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')), - '', ($pma_uri_parts['scheme'] == 'https')); + setcookie('pma_server_filename_template', $filename_template , 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); } $filename = str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template)); } elseif ($export_type == 'database') { if (isset($remember_template)) { - setcookie('pma_db_filename_template', $filename_template , 0, - substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')), - '', ($pma_uri_parts['scheme'] == 'https')); + setcookie('pma_db_filename_template', $filename_template , 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); } $filename = str_replace('__DB__', $db, str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template))); } else { if (isset($remember_template)) { - setcookie('pma_table_filename_template', $filename_template , 0, - substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')), - '', ($pma_uri_parts['scheme'] == 'https')); + setcookie('pma_table_filename_template', $filename_template , 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); } $filename = str_replace('__TABLE__', $table, str_replace('__DB__', $db, str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template)))); } diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index e3d3ed098..9e81da0e9 100644 --- a/libraries/auth/cookie.auth.lib.php +++ b/libraries/auth/cookie.auth.lib.php @@ -15,10 +15,8 @@ if (!isset($coming_from_common)) { // Gets the default font sizes PMA_setFontSizes(); -// Defines the cookie path and whether the server is using https or not -$pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']); -$cookie_path = substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')); -$is_https = (isset($pma_uri_parts['scheme']) && $pma_uri_parts['scheme'] == 'https') ? 1 : 0; + +// timestamp for login timeout $current_time = time(); // Uses faster mcrypt library if available @@ -618,7 +616,7 @@ global $conn_error, $server; if (isset($GLOBALS['allowDeny_forbidden']) && $GLOBALS['allowDeny_forbidden']) { $conn_error = $GLOBALS['strAccessDenied']; } else if (isset($GLOBALS['no_activity']) && $GLOBALS['no_activity']) { - $conn_error = sprintf($GLOBALS['strNoActivity'],$GLOBALS['cfg']['LoginCookieValidity']); + $conn_error = sprintf($GLOBALS['strNoActivity'],$GLOBALS['cfg']['LoginCookieValidity']); } else if (PMA_DBI_getError()) { $conn_error = PMA_DBI_getError(); } else if (isset($php_errormsg)) { diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 5ecfecacb..ec89ef4c9 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -1126,6 +1126,11 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} } } + // some variables used mostly for cookies: + $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']); + $cookie_path = substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')) . '/'; + $is_https = (isset($pma_uri_parts['scheme']) && $pma_uri_parts['scheme'] == 'https') ? 1 : 0; + $dblist = array(); /** @@ -1536,7 +1541,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} * @param string the current database name * @param string the current table name * @param boolean whether to retain or to displays the result - * @param boolean whether to force an exact count + * @param boolean whether to force an exact count * * @return mixed the number of records if retain is required, true else * @@ -2518,7 +2523,7 @@ if (typeof(document.getElementById) != 'undefined' . $full_field_type; if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($collation) && $collation != 'NULL' && preg_match('@^(TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR|CHAR)$@i', $full_field_type)) { $query .= PMA_generateCharsetQueryPart($collation); - } + } if (!empty($default)) { if (strtoupper($default) == 'NULL') { $query .= ' DEFAULT NULL'; diff --git a/libraries/select_theme.lib.php b/libraries/select_theme.lib.php index de626d132..3e29a3b09 100644 --- a/libraries/select_theme.lib.php +++ b/libraries/select_theme.lib.php @@ -77,31 +77,25 @@ if ($PMA_ThemeAvailable == TRUE) { // themeManager is available closedir($handleThemes); } // end themeManger -if (!isset($pma_uri_parts)) { // cookie-setup if needed - $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']); - $cookie_path = substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')); - $is_https = (isset($pma_uri_parts['scheme']) && $pma_uri_parts['scheme'] == 'https') ? 1 : 0; -} // end cookie setup - if (isset($set_theme)) { // if user submit a theme - setcookie('pma_theme', $set_theme, time() + 60*60*24*30, $cookie_path, '', $is_https); + setcookie('pma_theme', $set_theme, time() + 60*60*24*30, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']); } else { // else check if user have a theme cookie if (!isset($_COOKIE['pma_theme']) || empty($_COOKIE['pma_theme'])) { if ($PMA_ThemeDefault == TRUE) { if (basename($PHP_SELF) == 'index.php') { - setcookie('pma_theme', $cfg['ThemeDefault'], time() + 60*60*24*30, $cookie_path, '', $is_https); + setcookie('pma_theme', $cfg['ThemeDefault'], time() + 60*60*24*30, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']); } $pmaTheme=$cfg['ThemeDefault']; }else{ if (basename($PHP_SELF) == 'index.php') { - setcookie('pma_theme', 'original', time() + 60*60*24*30, $cookie_path, '', $is_https); + setcookie('pma_theme', 'original', time() + 60*60*24*30, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']); } $pmaTheme='original'; } } else { $pmaTheme=$_COOKIE['pma_theme']; if (basename($PHP_SELF) == 'index.php') { - setcookie('pma_theme', $pmaTheme, time() + 60*60*24*30, $cookie_path, '', $is_https); + setcookie('pma_theme', $pmaTheme, time() + 60*60*24*30, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']); } } } // end if diff --git a/main.php b/main.php index bab2bd770..4ff7652a9 100644 --- a/main.php +++ b/main.php @@ -12,12 +12,6 @@ define('PMA_DISPLAY_HEADING', 0); */ require_once('./libraries/grab_globals.lib.php'); require_once('./libraries/common.lib.php'); -// Puts the language to use in a cookie that will expire in 30 days -if (!isset($pma_uri_parts)) { - $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']); - $cookie_path = substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')); - $is_https = (isset($pma_uri_parts['scheme']) && $pma_uri_parts['scheme'] == 'https') ? 1 : 0; -} 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); diff --git a/tbl_move_copy.php b/tbl_move_copy.php index 594ce3081..cc60ff107 100644 --- a/tbl_move_copy.php +++ b/tbl_move_copy.php @@ -44,11 +44,11 @@ if (isset($new_name) && trim($new_name) != '') { } else { $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']); if (isset($switch_to_new) && $switch_to_new == 'true') { - setcookie('pma_switch_to_new', 'true', 0, substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')), '', ($pma_uri_parts['scheme'] == 'https')); + setcookie('pma_switch_to_new', 'true', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); $db = $target_db; $table = $new_name; } else { - setcookie('pma_switch_to_new', '', 0, substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')), '', ($pma_uri_parts['scheme'] == 'https')); + setcookie('pma_switch_to_new', '', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); } } }