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$
$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>
* libraries/display_tbl.lib.php3: bug 579785, Edit links URLs too long
for some browsers

View File

@@ -67,12 +67,21 @@ if (!defined('PMA_COMMON_LIB_INCLUDED')){
$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
* versions of phpMyAdmin/php/mysql...
*/
$old_error_reporting = error_reporting(0);
if (!include('./config.inc.php3')) {
if (!include($cfgfile_to_load)) {
// Creates fake settings
$cfg = array('DefaultLang' => 'en');
// Loads the laguage file
@@ -111,14 +120,21 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
}
error_reporting($old_error_reporting);
unset($old_error_reporting);
unset($cfgfile_to_load);
/**
* Reads in the developer edition config file. This is used exclusively during
* the development cycle of PMA, to prevent the accident of the developers ever
* submitting their config.inc.php3 file.
* Includes compatibility code for older config.inc.php3 revisions
* if necessary
*/
if (file_exists('./config.inc.developer.php3')) {
include('./config.inc.developer.php3');
if (!isset($cfg['FileRevision']) || (int) substr($cfg['FileRevision'], 13, 3) < 120) {
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');
// 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
// output buffering should be run
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
* 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.
* 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
@@ -42,7 +45,7 @@ $lang_path = 'lang/';
* When there are more than one charset for a language, we put the -utf-8
* first.
*/
$available_languages = array(
$available_languages = array(
'ar-utf-8' => array('ar([-_][[:alpha:]]{2})?|arabic', 'arabic-utf-8', 'ar'),
'ar-win1256' => array('ar([-_][[:alpha:]]{2})?|arabic', 'arabic-windows-1256', 'ar'),
'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-utf-8' => array('zh|chinese simplified', 'chinese_gb-utf-8', '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);
/**
@@ -159,28 +162,28 @@ if (!defined('PMA_IS_LANG_DETECT_FUNCTION')) {
}
} // end of the 'PMA_langDetect()' function
} // end if
} // end if
/**
/**
* 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+
*/
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
if (!empty($_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'];
}
}
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
if (!empty($_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'];
}
}
if (!isset($lang)) {
if (!isset($lang)) {
if (isset($_GET) && !empty($_GET['lang'])) {
$lang = $_GET['lang'];
}
@@ -199,25 +202,25 @@ if (!isset($lang)) {
else if (isset($HTTP_COOKIE_VARS) && !empty($HTTP_COOKIE_VARS['lang'])) {
$lang = $HTTP_COOKIE_VARS['lang'];
}
}
}
/**
/**
* Do the work!
*/
// compatibility with config.inc.php3 <= v1.80
if (!isset($cfg['Lang']) && isset($cfgLang)) {
// compatibility with config.inc.php3 <= v1.80
if (!isset($cfg['Lang']) && isset($cfgLang)) {
$cfg['Lang'] = $cfgLang;
unset($cfgLang);
}
if (!isset($cfg['DefaultLang']) && isset($cfgDefaultLang)) {
}
if (!isset($cfg['DefaultLang']) && isset($cfgDefaultLang)) {
$cfg['DefaultLang'] = $cfgDefaultLang;
unset($cfgLang);
}
}
// Disable UTF-8 if $cfg['AllowAnywhereRecoding'] has been set to FALSE.
if (!isset($cfg['AllowAnywhereRecoding']) || !$cfg['AllowAnywhereRecoding']) {
// Disable UTF-8 if $cfg['AllowAnywhereRecoding'] has been set to FALSE.
if (!isset($cfg['AllowAnywhereRecoding']) || !$cfg['AllowAnywhereRecoding']) {
$available_language_files = $available_languages;
$available_languages = array();
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_data);
unset($available_language_files);
} // end if
} // end if
// Lang forced
if (!empty($cfg['Lang'])) {
// Lang forced
if (!empty($cfg['Lang'])) {
$lang = $cfg['Lang'];
}
}
// If '$lang' is defined, ensure this is a valid translation
if (!empty($lang) && empty($available_languages[$lang])) {
// If '$lang' is defined, ensure this is a valid translation
if (!empty($lang) && empty($available_languages[$lang])) {
$lang = '';
}
}
// Language is not defined yet :
// 1. try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE
// variable
if (empty($lang) && !empty($HTTP_ACCEPT_LANGUAGE)) {
// Language is not defined yet :
// 1. try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE
// variable
if (empty($lang) && !empty($HTTP_ACCEPT_LANGUAGE)) {
$accepted = explode(',', $HTTP_ACCEPT_LANGUAGE);
$acceptedCnt = count($accepted);
reset($accepted);
for ($i = 0; $i < $acceptedCnt && empty($lang); $i++) {
PMA_langDetect($accepted[$i], 1);
}
}
// 2. try to findout user's language by checking its HTTP_USER_AGENT variable
if (empty($lang) && !empty($HTTP_USER_AGENT)) {
}
// 2. try to findout user's language by checking its HTTP_USER_AGENT variable
if (empty($lang) && !empty($HTTP_USER_AGENT)) {
PMA_langDetect($HTTP_USER_AGENT, 2);
}
}
// 3. Didn't catch any valid lang : we use the default settings
if (empty($lang)) {
// 3. Didn't catch any valid lang : we use the default settings
if (empty($lang)) {
$lang = $cfg['DefaultLang'];
}
}
// 4. Checks whether charset recoding should be allowed or not
$allow_recoding = FALSE; // Default fallback value
if (!isset($convcharset) || empty($convcharset)) {
// 4. Checks whether charset recoding should be allowed or not
$allow_recoding = FALSE; // Default fallback value
if (!isset($convcharset) || empty($convcharset)) {
$convcharset = $cfg['DefaultCharset'];
}
}
// 5. Defines the associated filename and load the translation
$lang_file = $lang_path . $available_languages[$lang][1] . '.inc.php3';
require('./' . $lang_file);
// 5. Defines the associated filename and load the translation
$lang_file = $lang_path . $available_languages[$lang][1] . '.inc.php3';
require('./' . $lang_file);
// $__PMA_SELECT_LANG_LIB__
} // $__PMA_SELECT_LANG_LIB__
?>