Don't include the "real" config file if a developer edition exists.

This commit is contained in:
Alexander M. Turek
2002-07-18 22:12:49 +00:00
parent 4ec070cb31
commit e2b2560a98
3 changed files with 288 additions and 271 deletions

View File

@@ -5,6 +5,10 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2002-07-18 Alexander M. Turek <rabus@users.sourceforge.net>
* libraries/common.lib.php3, libraries/select_lang.lib.php3: Don't include
the "real" config file if a developer edition exists.
2002-07-18 Marc Delisle <lem9@users.sourceforge.net> 2002-07-18 Marc Delisle <lem9@users.sourceforge.net>
* libraries/display_tbl.lib.php3: bug 579785, Edit links URLs too long * libraries/display_tbl.lib.php3: bug 579785, Edit links URLs too long
for some browsers for some browsers

View File

@@ -67,12 +67,21 @@ if (!defined('PMA_COMMON_LIB_INCLUDED')){
$pos = 0; $pos = 0;
} }
/**
* Detects the config file we want to load
*/
if (file_exists('./config.inc.developer.php3')) {
$cfgfile_to_load = './config.inc.developer.php3';
} else {
$cfgfile_to_load = './config.inc.php3';
}
/** /**
* Parses the configuration file and gets some constants used to define * Parses the configuration file and gets some constants used to define
* versions of phpMyAdmin/php/mysql... * versions of phpMyAdmin/php/mysql...
*/ */
$old_error_reporting = error_reporting(0); $old_error_reporting = error_reporting(0);
if (!include('./config.inc.php3')) { if (!include($cfgfile_to_load)) {
// Creates fake settings // Creates fake settings
$cfg = array('DefaultLang' => 'en'); $cfg = array('DefaultLang' => 'en');
// Loads the laguage file // Loads the laguage file
@@ -111,14 +120,21 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
} }
error_reporting($old_error_reporting); error_reporting($old_error_reporting);
unset($old_error_reporting); unset($old_error_reporting);
unset($cfgfile_to_load);
/** /**
* Reads in the developer edition config file. This is used exclusively during * Includes compatibility code for older config.inc.php3 revisions
* the development cycle of PMA, to prevent the accident of the developers ever * if necessary
* submitting their config.inc.php3 file.
*/ */
if (file_exists('./config.inc.developer.php3')) { if (!isset($cfg['FileRevision']) || (int) substr($cfg['FileRevision'], 13, 3) < 120) {
include('./config.inc.developer.php3'); require('./libraries/config_import.lib.php3');
}
/**
* Includes the language file if it hasn't been included yet
*/
if (!defined('PMA_SELECT_LANG_LIB_INCLUDED')){
require('./libraries/select_lang.lib.php3');
} }
/** /**
@@ -148,11 +164,6 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
include('./libraries/defines.lib.php3'); include('./libraries/defines.lib.php3');
// For compatibility with old config.inc.php3
if (!isset($cfg['FileRevision']) || (int) substr($cfg['FileRevision'], 13, 3) < 120) {
include('./libraries/config_import.lib.php3');
}
// If zlib output compression is set in the php configuration file, no // If zlib output compression is set in the php configuration file, no
// output buffering should be run // output buffering should be run
if (PMA_PHP_INT_VERSION < 40000 if (PMA_PHP_INT_VERSION < 40000

View File

@@ -8,14 +8,17 @@
/** if (!defined('PMA_SELECT_LANG_LIB_INCLUDED')){
define('PMA_SELECT_LANG_LIB_INCLUDED', 1);
/**
* Define the path to the translations directory and get some variables * Define the path to the translations directory and get some variables
* from system arrays if 'register_globals' is set to 'off' * from system arrays if 'register_globals' is set to 'off'
*/ */
$lang_path = 'lang/'; $lang_path = 'lang/';
/** /**
* All the supported languages have to be listed in the array below. * All the supported languages have to be listed in the array below.
* 1. The key must be the "official" ISO 639 language code and, if required, * 1. The key must be the "official" ISO 639 language code and, if required,
* the dialect code. It can also contains some informations about the * the dialect code. It can also contains some informations about the
@@ -42,7 +45,7 @@ $lang_path = 'lang/';
* When there are more than one charset for a language, we put the -utf-8 * When there are more than one charset for a language, we put the -utf-8
* first. * first.
*/ */
$available_languages = array( $available_languages = array(
'ar-utf-8' => array('ar([-_][[:alpha:]]{2})?|arabic', 'arabic-utf-8', 'ar'), 'ar-utf-8' => array('ar([-_][[:alpha:]]{2})?|arabic', 'arabic-utf-8', 'ar'),
'ar-win1256' => array('ar([-_][[:alpha:]]{2})?|arabic', 'arabic-windows-1256', 'ar'), 'ar-win1256' => array('ar([-_][[:alpha:]]{2})?|arabic', 'arabic-windows-1256', 'ar'),
'bg-utf-8' => array('bg|bulgarian', 'bulgarian-utf-8', 'bg'), 'bg-utf-8' => array('bg|bulgarian', 'bulgarian-utf-8', 'bg'),
@@ -124,10 +127,10 @@ $available_languages = array(
'zh-tw' => array('zh[-_]tw|chinese traditional', 'chinese_big5', 'zh-TW'), 'zh-tw' => array('zh[-_]tw|chinese traditional', 'chinese_big5', 'zh-TW'),
'zh-utf-8' => array('zh|chinese simplified', 'chinese_gb-utf-8', 'zh'), 'zh-utf-8' => array('zh|chinese simplified', 'chinese_gb-utf-8', 'zh'),
'zh' => array('zh|chinese simplified', 'chinese_gb', 'zh') 'zh' => array('zh|chinese simplified', 'chinese_gb', 'zh')
); );
if (!defined('PMA_IS_LANG_DETECT_FUNCTION')) { if (!defined('PMA_IS_LANG_DETECT_FUNCTION')) {
define('PMA_IS_LANG_DETECT_FUNCTION', 1); define('PMA_IS_LANG_DETECT_FUNCTION', 1);
/** /**
@@ -159,28 +162,28 @@ if (!defined('PMA_IS_LANG_DETECT_FUNCTION')) {
} }
} // end of the 'PMA_langDetect()' function } // end of the 'PMA_langDetect()' function
} // end if } // end if
/** /**
* Get some global variables if 'register_globals' is set to 'off' * Get some global variables if 'register_globals' is set to 'off'
* loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+ * loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
*/ */
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$HTTP_ACCEPT_LANGUAGE = $_SERVER['HTTP_ACCEPT_LANGUAGE']; $HTTP_ACCEPT_LANGUAGE = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
} }
else if (!empty($HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'])) { else if (!empty($HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'])) {
$HTTP_ACCEPT_LANGUAGE = $HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE']; $HTTP_ACCEPT_LANGUAGE = $HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'];
} }
if (!empty($_SERVER['HTTP_USER_AGENT'])) { if (!empty($_SERVER['HTTP_USER_AGENT'])) {
$HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
} }
else if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) { else if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) {
$HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT']; $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
} }
if (!isset($lang)) { if (!isset($lang)) {
if (isset($_GET) && !empty($_GET['lang'])) { if (isset($_GET) && !empty($_GET['lang'])) {
$lang = $_GET['lang']; $lang = $_GET['lang'];
} }
@@ -199,25 +202,25 @@ if (!isset($lang)) {
else if (isset($HTTP_COOKIE_VARS) && !empty($HTTP_COOKIE_VARS['lang'])) { else if (isset($HTTP_COOKIE_VARS) && !empty($HTTP_COOKIE_VARS['lang'])) {
$lang = $HTTP_COOKIE_VARS['lang']; $lang = $HTTP_COOKIE_VARS['lang'];
} }
} }
/** /**
* Do the work! * Do the work!
*/ */
// compatibility with config.inc.php3 <= v1.80 // compatibility with config.inc.php3 <= v1.80
if (!isset($cfg['Lang']) && isset($cfgLang)) { if (!isset($cfg['Lang']) && isset($cfgLang)) {
$cfg['Lang'] = $cfgLang; $cfg['Lang'] = $cfgLang;
unset($cfgLang); unset($cfgLang);
} }
if (!isset($cfg['DefaultLang']) && isset($cfgDefaultLang)) { if (!isset($cfg['DefaultLang']) && isset($cfgDefaultLang)) {
$cfg['DefaultLang'] = $cfgDefaultLang; $cfg['DefaultLang'] = $cfgDefaultLang;
unset($cfgLang); unset($cfgLang);
} }
// Disable UTF-8 if $cfg['AllowAnywhereRecoding'] has been set to FALSE. // Disable UTF-8 if $cfg['AllowAnywhereRecoding'] has been set to FALSE.
if (!isset($cfg['AllowAnywhereRecoding']) || !$cfg['AllowAnywhereRecoding']) { if (!isset($cfg['AllowAnywhereRecoding']) || !$cfg['AllowAnywhereRecoding']) {
$available_language_files = $available_languages; $available_language_files = $available_languages;
$available_languages = array(); $available_languages = array();
while (list($tmp_lang, $tmp_lang_data) = each($available_language_files)) { while (list($tmp_lang, $tmp_lang_data) = each($available_language_files)) {
@@ -228,49 +231,48 @@ if (!isset($cfg['AllowAnywhereRecoding']) || !$cfg['AllowAnywhereRecoding']) {
unset($tmp_lang); unset($tmp_lang);
unset($tmp_lang_data); unset($tmp_lang_data);
unset($available_language_files); unset($available_language_files);
} // end if } // end if
// Lang forced // Lang forced
if (!empty($cfg['Lang'])) { if (!empty($cfg['Lang'])) {
$lang = $cfg['Lang']; $lang = $cfg['Lang'];
} }
// If '$lang' is defined, ensure this is a valid translation // If '$lang' is defined, ensure this is a valid translation
if (!empty($lang) && empty($available_languages[$lang])) { if (!empty($lang) && empty($available_languages[$lang])) {
$lang = ''; $lang = '';
} }
// Language is not defined yet : // Language is not defined yet :
// 1. try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE // 1. try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE
// variable // variable
if (empty($lang) && !empty($HTTP_ACCEPT_LANGUAGE)) { if (empty($lang) && !empty($HTTP_ACCEPT_LANGUAGE)) {
$accepted = explode(',', $HTTP_ACCEPT_LANGUAGE); $accepted = explode(',', $HTTP_ACCEPT_LANGUAGE);
$acceptedCnt = count($accepted); $acceptedCnt = count($accepted);
reset($accepted); reset($accepted);
for ($i = 0; $i < $acceptedCnt && empty($lang); $i++) { for ($i = 0; $i < $acceptedCnt && empty($lang); $i++) {
PMA_langDetect($accepted[$i], 1); PMA_langDetect($accepted[$i], 1);
} }
} }
// 2. try to findout user's language by checking its HTTP_USER_AGENT variable // 2. try to findout user's language by checking its HTTP_USER_AGENT variable
if (empty($lang) && !empty($HTTP_USER_AGENT)) { if (empty($lang) && !empty($HTTP_USER_AGENT)) {
PMA_langDetect($HTTP_USER_AGENT, 2); PMA_langDetect($HTTP_USER_AGENT, 2);
} }
// 3. Didn't catch any valid lang : we use the default settings // 3. Didn't catch any valid lang : we use the default settings
if (empty($lang)) { if (empty($lang)) {
$lang = $cfg['DefaultLang']; $lang = $cfg['DefaultLang'];
} }
// 4. Checks whether charset recoding should be allowed or not // 4. Checks whether charset recoding should be allowed or not
$allow_recoding = FALSE; // Default fallback value $allow_recoding = FALSE; // Default fallback value
if (!isset($convcharset) || empty($convcharset)) { if (!isset($convcharset) || empty($convcharset)) {
$convcharset = $cfg['DefaultCharset']; $convcharset = $cfg['DefaultCharset'];
} }
// 5. Defines the associated filename and load the translation // 5. Defines the associated filename and load the translation
$lang_file = $lang_path . $available_languages[$lang][1] . '.inc.php3'; $lang_file = $lang_path . $available_languages[$lang][1] . '.inc.php3';
require('./' . $lang_file); require('./' . $lang_file);
} // $__PMA_SELECT_LANG_LIB__
// $__PMA_SELECT_LANG_LIB__
?> ?>