diff options
author | Michal Čihař <michal@cihar.com> | 2004-09-14 18:21:31 +0400 |
---|---|---|
committer | Michal Čihař <michal@cihar.com> | 2004-09-14 18:21:31 +0400 |
commit | 4e37b2911337c00e3fc0aa922f0df215e1918051 (patch) | |
tree | 0175d1e1bf8f2f7087e051ea16f7a8608ba9d7a1 | |
parent | 3b9fad6607da428bcc06922457123510ab2ad8b0 (diff) |
Better theme version check (bug #1023029).
-rwxr-xr-x | ChangeLog | 7 | ||||
-rw-r--r-- | libraries/common.lib.php | 23 | ||||
-rw-r--r-- | libraries/defines.lib.php | 11 | ||||
-rw-r--r-- | libraries/select_theme.lib.php | 19 | ||||
-rw-r--r-- | themes.php | 23 | ||||
-rw-r--r-- | themes/darkblue_orange/info.inc.php | 1 | ||||
-rw-r--r-- | themes/original/info.inc.php | 1 |
7 files changed, 53 insertions, 32 deletions
@@ -5,6 +5,11 @@ phpMyAdmin - Changelog $Id$ $Source$ +2004-09-14 Michal Čihař <michal@cihar.com> + * themes.php, libraries/common.lib.php, libraries/defines.lib.php, + libraries/select_theme.lib.php, themes/darkblue_orange/info.inc.php, + themes/original/info.inc.php: Better theme version check (bug #1023029). + 2004-09-13 Garvin Hicking <me@supergarv.de> * browse_foreigners.php: bug #1027204 - paging did not work in foreigner browsing window. @@ -28,7 +33,7 @@ $Source$ on Insert tab from the Insert textfile sub-page 2004-09-07 Marc Delisle <lem9@users.sourceforge.net> - * main.php: bug #992211, wrong parameters to + * main.php: bug #992211, wrong parameters to PMA_generate_common_hidden_inputs(), thanks to Ryan Schmidt 2004-09-07 Michal Čihař <michal@cihar.com> diff --git a/libraries/common.lib.php b/libraries/common.lib.php index a85a558a2a..5a4adaab85 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -264,7 +264,7 @@ if ($is_minimum_common == FALSE) { * @param string The path to check * * @return string The secured path - * + * * @access public * @author Marc Delisle (lem9@users.sourceforge.net) */ @@ -273,7 +273,7 @@ function PMA_securePath($path) { // change .. to . $path = preg_replace('@\.\.*@','.',$path); - return $path; + return $path; } // end function // If zlib output compression is set in the php configuration file, no @@ -311,13 +311,13 @@ if (!isset($_COOKIE['pma_theme']) || empty($_COOKIE['pma_theme'])){ } } } - if ($ThemeDefaultOk == TRUE){ + if ($ThemeDefaultOk == TRUE){ $GLOBALS['theme'] = $cfg['ThemeDefault']; } else { $GLOBALS['theme'] = 'original'; } } else { - // if we just changed theme, we must take the new one so that + // if we just changed theme, we must take the new one so that // index.php takes the correct one for height computing if (isset($_POST['set_theme'])) { $GLOBALS['theme'] = PMA_securePath($_POST['set_theme']); @@ -327,13 +327,16 @@ if (!isset($_COOKIE['pma_theme']) || empty($_COOKIE['pma_theme'])){ } // check for theme requires/name -unset($theme_name, $theme_version); +unset($theme_name, $theme_generation, $theme_version); @include($cfg['ThemePath'] . '/' . $GLOBALS['theme'] . '/info.inc.php'); // did it set correctly? -if (!isset($theme_name, $theme_version)) +if (!isset($theme_name, $theme_generation, $theme_version)) $GLOBALS['theme'] = 'original'; // invalid theme - + +if ($theme_generation != PMA_THEME_GENERATION) + $GLOBALS['theme'] = 'original'; // different generation + if ($theme_version < PMA_THEME_VERSION) $GLOBALS['theme'] = 'original'; // too old version @@ -612,7 +615,7 @@ if ($is_minimum_common == FALSE) { $doedit_goto = '<a href="db_details.php?' . PMA_generate_common_url($db) . '&sql_query=' . urlencode($the_query) . '&show_query=1">'; } if ($GLOBALS['cfg']['PropertiesIconic']) { - echo $doedit_goto + echo $doedit_goto . '<img src=" '. $GLOBALS['pmaThemeImage'] . 'b_edit.png" width="16" height="16" border="0" hspace="2" align="middle" alt="' . $GLOBALS['strEdit'] .'" />' . '</a>'; } else { @@ -691,7 +694,7 @@ if ($is_minimum_common == FALSE) { /** - * Returns a string formatted with CONVERT ... USING + * Returns a string formatted with CONVERT ... USING * if MySQL supports it * * @param string the string itself @@ -1908,7 +1911,7 @@ if (typeof(document.getElementById) != 'undefined' ) && ($text != $GLOBALS['strEmpty'] && $text != $GLOBALS['strDrop'])) { $addclass = 'Active'; } - if ($text == $GLOBALS['strEmpty'] && $text == $GLOBALS['strDrop']) $addclass = 'Drop'; + if ($text == $GLOBALS['strEmpty'] && $text == $GLOBALS['strDrop']) $addclass = 'Drop'; if (empty($class)){ if (empty($addclass)) { $addclass = 'Normal'; } } else { $addclass = $class; } diff --git a/libraries/defines.lib.php b/libraries/defines.lib.php index 2b3748cafb..bf4d86f57f 100644 --- a/libraries/defines.lib.php +++ b/libraries/defines.lib.php @@ -7,10 +7,11 @@ * Overview: * PMA_VERSION (string) - phpMyAdmin version string * PMA_THEME_VERSION (int) - phpMyAdmin theme version integer + * PMA_THEME_GENERATION (int) - phpMyAdmin theme generation integer * PMA_PHP_INT_VERSION (int) - eg: 30017 instead of 3.0.17 or * 40006 instead of 4.0.6RC3 * PMA_IS_WINDOWS (bool) - mark if phpMyAdmin running on windows - * PMA_IS_IIS (bool) - true is phpMyAdmin is running + * PMA_IS_IIS (bool) - true is phpMyAdmin is running * on Microsoft IIS server * PMA_IS_GD2 (bool) - true if GD2 is present * PMA_USR_OS (string) - the plateform (os) of the user @@ -26,6 +27,10 @@ if (!defined('PMA_THEME_VERSION')) { define('PMA_THEME_VERSION', 1); } +if (!defined('PMA_THEME_GENERATION')) { + define('PMA_THEME_GENERATION', 1); +} + // php version if (!defined('PMA_PHP_INT_VERSION')) { if (!preg_match('@([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})@', phpversion(), $match)) { @@ -55,9 +60,9 @@ if (!defined('PMA_IS_WINDOWS')) { } } -// Whether the Web server php is running on is IIS +// Whether the Web server php is running on is IIS if (!defined('PMA_IS_IIS')) { - if (isset($_SERVER['SERVER_SOFTWARE']) + if (isset($_SERVER['SERVER_SOFTWARE']) && stristr($_SERVER['SERVER_SOFTWARE'], 'Microsoft/IIS')) { define('PMA_IS_IIS', 1); } else { diff --git a/libraries/select_theme.lib.php b/libraries/select_theme.lib.php index 25a809ee56..de626d132f 100644 --- a/libraries/select_theme.lib.php +++ b/libraries/select_theme.lib.php @@ -27,7 +27,7 @@ * PMA and they must have the same size in pixels. * You can only use own images, if you've edit own css files. */ - + /** * We need some elements of the superglobal $_SERVER array. */ @@ -55,23 +55,26 @@ if ($PMA_ThemeAvailable == TRUE) { // themeManager is available if ($PMA_Theme != "." && $PMA_Theme != ".." && $PMA_Theme != 'CVS') { // file check if (@is_dir($cfg['ThemePath'].'/'.$PMA_Theme)) { // check the theme // check for theme requires/name - unset($theme_name, $theme_version); + unset($theme_name, $theme_generation, $theme_version); @include($cfg['ThemePath'] . '/' . $PMA_Theme . '/info.inc.php'); - + // did it set correctly? - if (!isset($theme_name, $theme_version)) + if (!isset($theme_name, $theme_version, $theme_generation)) continue; // invalid theme - + + if ($theme_generation != PMA_THEME_GENERATION) + continue; // different generation + if ($theme_version < PMA_THEME_VERSION) continue; // too old version $available_themes_choices[]=$PMA_Theme; - $available_themes_choices_names[$PMA_Theme] = $theme_name; + $available_themes_choices_names[$PMA_Theme] = $theme_name; } // end check the theme } // end file check } // end get themes } // end check for themes directory - closedir($handleThemes); + closedir($handleThemes); } // end themeManger if (!isset($pma_uri_parts)) { // cookie-setup if needed @@ -84,7 +87,7 @@ if (isset($set_theme)) { // if user submit a theme setcookie('pma_theme', $set_theme, time() + 60*60*24*30, $cookie_path, '', $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 ($PMA_ThemeDefault == TRUE) { if (basename($PHP_SELF) == 'index.php') { setcookie('pma_theme', $cfg['ThemeDefault'], time() + 60*60*24*30, $cookie_path, '', $is_https); } diff --git a/themes.php b/themes.php index a210a67439..937708dbf8 100644 --- a/themes.php +++ b/themes.php @@ -88,19 +88,22 @@ if ($handleThemes = opendir($path_to_themes)) { // open themes while (false !== ($PMA_Theme = readdir($handleThemes))) { // get screens if ($PMA_Theme != "." && $PMA_Theme != "..") { $screen_directory = $path_to_themes . $PMA_Theme; - + // check for theme requires/name - unset($theme_name, $theme_version); + unset($theme_name, $theme_generation, $theme_version); @include($path_to_themes . $PMA_Theme . '/info.inc.php'); - + // did it set correctly? - if (!isset($theme_name, $theme_version)) + if (!isset($theme_name, $theme_generation, $theme_version)) continue; // invalid theme - + + if ($theme_generation != PMA_THEME_GENERATION) + continue; // different generation + if ($theme_version < PMA_THEME_VERSION) continue; // too old version - - + + if (is_dir($screen_directory) && @file_exists($screen_directory.'/screen.png')) { // if screen exists then output ?> <tr> @@ -116,7 +119,7 @@ if ($handleThemes = opendir($path_to_themes)) { // open themes <!-- document.write('<a href="#top" onclick="takeThis(\'<?php echo $PMA_Theme; ?>\'); return false;">'); document.write('<img src="<?php echo $screen_directory; ?>/screen.png" border="1" '); - if (document.getElementById) { + if (document.getElementById) { document.write('style="border: 1px solid #000000;" '); } document.write('alt="<?php echo htmlspecialchars(addslashes($theme_name)); ?> - Theme" '); @@ -137,11 +140,11 @@ if ($handleThemes = opendir($path_to_themes)) { // open themes <tr> <td><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width="1" height="1" border="0" alt="" /></td> </tr> -<?php +<?php } // end 'screen output' } // end 'check theme' } // end 'get screens' - closedir($handleThemes); + closedir($handleThemes); } // end 'open themes' ?> </table> diff --git a/themes/darkblue_orange/info.inc.php b/themes/darkblue_orange/info.inc.php index cccc81c75b..4772b5fa3d 100644 --- a/themes/darkblue_orange/info.inc.php +++ b/themes/darkblue_orange/info.inc.php @@ -3,4 +3,5 @@ /* Theme information */ $theme_name = 'Darkblue/orange'; $theme_version = 1; +$theme_generation = 1; ?> diff --git a/themes/original/info.inc.php b/themes/original/info.inc.php index 666b44854a..968f2deff2 100644 --- a/themes/original/info.inc.php +++ b/themes/original/info.inc.php @@ -3,4 +3,5 @@ /* Theme information */ $theme_name = 'Original'; $theme_version = 1; +$theme_generation = 1; ?> |