Huge set of optimizations, please test!

This commit is contained in:
Alexander M. Turek
2003-11-26 22:52:25 +00:00
parent 0500480bcf
commit 37d50c1822
115 changed files with 12275 additions and 12579 deletions

View File

@@ -5,6 +5,23 @@ phpMyAdmin - Changelog
$Id$
$Source$
2003-11-26 Alexander M. Turek <lifeforrent@derrabus.de>
* Almost every file:
- Replaced all include / require commands by require_once where possible;
- Further php 4.1+ optimizations;
- footer.inc.php now automatically stops the script execution;
- Coding standards.
* config.inc.php: Don't include select_lang.lib.php here.
* libraries/common.lib.php, libraries/defines.lib.php,
libraries/defines_php.lib.php, libraries/defines_mysql.lib.php,
scripts/create-release.sh:
defines.lib.php was included twice. For optimization reasons I moved all
the code that is independent from the MySQL connection out of defines.lib
into defines_php.lib.
To point out the (new) meanings of the files I renamed defines.lib.php to
defines_mysql.lib.php while defines_php.lib.php is now known as
defines.lib.php.
2003-11-26 Michal Cihar <cleanerfasterbetter@cihar.com>
* lang/check_lang.sh: Cleanup.
* lang/sort_lang.sh: Cleanup.

View File

@@ -5,25 +5,23 @@
/**
* Get the variables sent or posted to this script and displays the header
*/
require('./libraries/grab_globals.lib.php');
require_once('./libraries/grab_globals.lib.php');
/**
* Gets a core script and starts output buffering work
*/
if (!defined('PMA_COMMON_LIB_INCLUDED')) {
include('./libraries/common.lib.php');
}
require_once('./libraries/common.lib.php');
PMA_checkParameters(array('db', 'table', 'field'));
require('./libraries/ob.lib.php');
require_once('./libraries/ob.lib.php');
if ($cfg['OBGzip']) {
$ob_mode = PMA_outBufferModeGet();
if ($ob_mode) {
PMA_outBufferPre($ob_mode);
}
}
include('./libraries/header_http.inc.php');
require_once('./libraries/header_http.inc.php');
$field = urldecode($field);
/**
@@ -58,8 +56,8 @@ PMA_setFontSizes();
<body bgcolor="<?php echo $cfg['LeftBgColor']; ?>" style="margin-left: 5px; margin-top: 5px; margin-right: 5px; margin-bottom: 0px">
<?php
$per_page = 200;
require('./libraries/relation.lib.php'); // foreign keys
require('./libraries/transformations.lib.php'); // Transformations
require_once('./libraries/relation.lib.php'); // foreign keys
require_once('./libraries/transformations.lib.php'); // Transformations
$cfgRelation = PMA_getRelationsParam();
$foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE);
@@ -74,7 +72,7 @@ if (isset($foreign_navig) && $foreign_navig == $strShowAll) {
unset($foreign_limit);
}
include('./libraries/get_foreign.lib.php');
require('./libraries/get_foreign.lib.php');
?>
<form action="browse_foreigners.php" method="post">

View File

@@ -6,10 +6,10 @@
/**
* Gets some core libraries
*/
require('./libraries/grab_globals.lib.php');
require('./libraries/common.lib.php');
require('./db_details_common.php');
require('./libraries/relation.lib.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
require_once('./db_details_common.php');
require_once('./libraries/relation.lib.php');
/**
@@ -21,6 +21,5 @@ $cfgRelation = PMA_getRelationsParam(TRUE);
/**
* Displays the footer
*/
echo "\n";
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -434,10 +434,6 @@ $cfg['AvailableCharsets'] = array(
'SHIFT_JIS'
);
// Loads language file
require('./libraries/select_lang.lib.php');
/**
* Customization & design
*/

View File

@@ -4,8 +4,8 @@
chdir('..');
$is_minimum_common = TRUE;
require('./libraries/grab_globals.lib.php');
require('./libraries/common.lib.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
// Gets the default font sizes
// garvin: TODO: Should be optimized to not include the whole common.lib.php bunch
@@ -13,7 +13,7 @@ require('./libraries/common.lib.php');
PMA_setFontSizes();
$ctype = 'css';
require('./libraries/header_http.inc.php');
require_once('./libraries/header_http.inc.php');
if (!isset($js_frame)) {
$js_frame = 'left';

View File

@@ -6,13 +6,11 @@
/**
* Gets some core libraries
*/
require('./libraries/grab_globals.lib.php');
require_once('./libraries/grab_globals.lib.php');
$js_to_run = 'functions.js';
require('./header.inc.php');
require_once('./header.inc.php');
require_once('./libraries/common.lib.php');
if (!defined('PMA_COMMON_LIB_INCLUDED')) {
include('./libraries/common.lib.php');
}
PMA_checkParameters(array('db'));
@@ -32,6 +30,6 @@ $result = PMA_mysql_query('CREATE DATABASE ' . PMA_backquote($db)) or PMA_m
* Displays the result and calls default page
*/
$message = $strDatabase . ' ' . htmlspecialchars($db) . ' ' . $strHasBeenCreated;
require('./' . $cfg['DefaultTabDatabase']);
require_once('./' . $cfg['DefaultTabDatabase']);
?>

View File

@@ -6,16 +6,16 @@
* Gets the variables sent or posted to this script, then displays headers
*/
if (!isset($selected_tbl)) {
include('./libraries/grab_globals.lib.php');
include('./header.inc.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./header.inc.php');
}
/**
* Gets the relations settings
*/
require('./libraries/relation.lib.php');
require('./libraries/transformations.lib.php');
require_once('./libraries/relation.lib.php');
require_once('./libraries/transformations.lib.php');
$cfgRelation = PMA_getRelationsParam();
@@ -317,5 +317,5 @@ function printPage()
<?php
echo '<br /><br />&nbsp;<input type="button" style="visibility: ; width: 100px; height: 25px" name="print" value="' . $strPrint . '" onclick="printPage()">' . "\n";
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -35,7 +35,7 @@ $sub_part = '';
require('./db_details_db_info.php');
if ($num_tables == 0 && empty($db_query_force)) {
$is_info = TRUE;
include('./db_details_structure.php');
require('./db_details_structure.php');
exit();
}
@@ -200,5 +200,5 @@ if (function_exists('PMA_set_enc_form')) {
* Displays the footer
*/
echo "\n";
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -5,15 +5,9 @@
/**
* Gets some core libraries
*/
if (!defined('PMA_GRAB_GLOBALS_INCLUDED')) {
include('./libraries/grab_globals.lib.php');
}
if (!defined('PMA_COMMON_LIB_INCLUDED')) {
include('./libraries/common.lib.php');
}
if (!defined('PMA_BOOKMARK_LIB_INCLUDED')) {
include('./libraries/bookmark.lib.php');
}
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
require_once('./libraries/bookmark.lib.php');
PMA_checkParameters(array('db'));
@@ -35,13 +29,13 @@ if (!isset($is_db) || !$is_db) {
}
if (empty($db) || !$is_db) {
header('Location: ' . $cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
exit();
exit;
}
} // end if (ensures db exists)
// Displays headers
if (!isset($message)) {
$js_to_run = 'functions.js';
include('./header.inc.php');
require_once('./header.inc.php');
// Reloads the navigation frame via JavaScript if required
if (isset($reload) && $reload) {
echo "\n";

View File

@@ -5,9 +5,7 @@
// Check parameters
if (!defined('PMA_COMMON_LIB_INCLUDED')) {
include('./libraries/common.lib.php');
}
require_once('./libraries/common.lib.php');
PMA_checkParameters(array('db'));

View File

@@ -52,15 +52,14 @@ if ($num_tables > 1) {
<br /><br />';
} elseif ($num_tables == 0) {
echo $strDatabaseNoTable;
include('./footer.inc.php');
exit;
require_once('./footer.inc.php');
} // end if
$export_type = 'database';
require('./libraries/display_export.lib.php');
require_once('./libraries/display_export.lib.php');
/**
* Displays the footer
*/
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -12,13 +12,13 @@
* Get the values of the variables posted or sent to this script and display
* the headers
*/
require('./libraries/read_dump.lib.php');
require('./libraries/grab_globals.lib.php');
require('./header.inc.php');
require_once('./libraries/read_dump.lib.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./header.inc.php');
//require common added for string importing - Robbat2, 15 January 2003 9.34PM
//all hardcoded strings converted by Robbat2, 15 January 2003 9.34PM
require('./libraries/common.lib.php');
require_once('./libraries/common.lib.php');
// Check parameters
PMA_checkParameters(array('db'));
@@ -148,7 +148,7 @@ if (isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])) {
}
// Get relation settings
include('./libraries/relation.lib.php');
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
// Gets the query from a file if required
@@ -299,6 +299,6 @@ if (isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])) {
* Displays the footer
*/
echo "\n";
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -7,9 +7,9 @@
* Get the values of the variables posted or sent to this script and display
* the headers
*/
require('./libraries/grab_globals.lib.php');
require('./libraries/common.lib.php');
require('./libraries/relation.lib.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
require_once('./libraries/relation.lib.php');
/**
@@ -25,13 +25,13 @@ if (isset($submit_sql) && preg_match('@^SELECT@i', $encoded_sql_query)) {
$goto = 'db_details.php';
$zero_rows = htmlspecialchars($strSuccess);
$sql_query = urldecode($encoded_sql_query);
include('./sql.php');
require('./sql.php');
exit();
} else {
$sub_part = '_qbe';
include('./db_details_common.php');
require('./db_details_common.php');
$url_query .= '&amp;goto=db_details_qbe.php';
include('./db_details_db_info.php');
require('./db_details_db_info.php');
}
if (isset($submit_sql) && !preg_match('@^SELECT@i', $encoded_sql_query)) {
@@ -1076,5 +1076,5 @@ if (!empty($qry_orderby)) {
/**
* Displays the footer
*/
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -8,26 +8,22 @@
* because there is no table in the database ($is_info is TRUE)
*/
if (empty($is_info)) {
if (!defined('PMA_GRAB_GLOBALS_INCLUDED')) {
include('./libraries/grab_globals.lib.php');
}
if (!defined('PMA_COMMON_LIB_INCLUDED')) {
include('./libraries/common.lib.php');
}
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
// Drops/deletes/etc. multiple tables if required
if ((!empty($submit_mult) && isset($selected_tbl))
|| isset($mult_btn)) {
$action = 'db_details_structure.php';
$err_url = 'db_details_structure.php?'. PMA_generate_common_url($db);
include('./mult_submits.inc.php');
require('./mult_submits.inc.php');
}
include('./db_details_common.php');
require('./db_details_common.php');
$url_query .= '&amp;goto=db_details_structure.php';
// Gets the database structure
$sub_part = '_structure';
include('./db_details_db_info.php');
require('./db_details_db_info.php');
echo "\n";
/**
@@ -82,7 +78,7 @@ function pma_TableHeader($alternate = FALSE) {
/**
* Settings for relations stuff
*/
require('./libraries/relation.lib.php');
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
/**
@@ -251,7 +247,7 @@ else {
</td>
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
<?php
include('./libraries/bookmark.lib.php');
require_once('./libraries/bookmark.lib.php');
$book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
if (!empty($sts_data['Rows'])) {
@@ -692,5 +688,5 @@ echo "\n" . '</ul>';
* Displays the footer
*/
echo "\n";
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -6,14 +6,11 @@
/**
* Gets the variables sent or posted to this script, then displays headers
*/
require('./libraries/grab_globals.lib.php');
require('./header.inc.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./header.inc.php');
// Check parameters
if (!defined('PMA_COMMON_LIB_INCLUDED')) {
include('./libraries/common.lib.php');
}
require_once('./libraries/common.lib.php');
PMA_checkParameters(array('db'));
@@ -25,7 +22,7 @@ $err_url = 'db_details.php?' . PMA_generate_common_url($db);
/**
* Settings for relations stuff
*/
require('./libraries/relation.lib.php');
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
/**
@@ -308,5 +305,5 @@ function printPage()
<?php
echo '<br /><br />&nbsp;<input type="button" style="visibility: ; width: 100px; height: 25px" name="print" value="' . $strPrint . '" onclick="printPage()">' . "\n";
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -379,5 +379,5 @@ echo"\n";
* Displays the footer
*/
echo "\n";
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -5,9 +5,9 @@
/**
* Get the variables sent or posted to this script and a core script
*/
require('./libraries/grab_globals.lib.php');
require('./libraries/common.lib.php');
require('./libraries/zip.lib.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
require_once('./libraries/zip.lib.php');
PMA_checkParameters(array('what'));
@@ -263,16 +263,16 @@ if ($save_on_server) {
}
if (isset($message)) {
$js_to_run = 'functions.js';
include('./header.inc.php');
require_once('./header.inc.php');
if ($export_type == 'server') {
$active_page = 'server_export.php';
include('./server_export.php');
require('./server_export.php');
} elseif ($export_type == 'database') {
$active_page = 'db_details_export.php';
include('./db_details_export.php');
require('./db_details_export.php');
} else {
$active_page = 'tbl_properties_export.php';
include('./tbl_properties_export.php');
require('./tbl_properties_export.php');
}
exit();
}
@@ -299,7 +299,7 @@ if (!$save_on_server) {
} else {
// HTML
$backup_cfgServer = $cfg['Server'];
include('./header.inc.php');
require_once('./header.inc.php');
$cfg['Server'] = $backup_cfgServer;
unset($backup_cfgServer);
echo '<div align="' . $cell_align_left . '">' . "\n";
@@ -314,16 +314,16 @@ if ($export_type == 'database') {
if ($num_tables == 0) {
$message = $strNoTablesFound;
$js_to_run = 'functions.js';
include('./header.inc.php');
require_once('./header.inc.php');
if ($export_type == 'server') {
$active_page = 'server_export.php';
include('./server_export.php');
require('./server_export.php');
} elseif ($export_type == 'database') {
$active_page = 'db_details_export.php';
include('./db_details_export.php');
require('./db_details_export.php');
} else {
$active_page = 'tbl_properties_export.php';
include('./tbl_properties_export.php');
require('./tbl_properties_export.php');
}
exit();
}
@@ -337,11 +337,11 @@ $do_relation = isset($GLOBALS[$what . '_relation']);
$do_comments = isset($GLOBALS[$what . '_comments']);
$do_mime = isset($GLOBALS[$what . '_mime']);
if ($do_relation || $do_comments || $do_mime) {
require('./libraries/relation.lib.php');
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
}
if ($do_mime) {
require('./libraries/transformations.lib.php');
require_once('./libraries/transformations.lib.php');
}
// Include dates in export?
@@ -455,10 +455,9 @@ if (!empty($asfile)) {
if (@function_exists('bzcompress')) {
$dump_buffer = bzcompress($dump_buffer);
if ($dump_buffer === -8) {
include('./header.inc.php');
require_once('./header.inc.php');
echo sprintf($strBzError, '<a href="http://bugs.php.net/bug.php?id=17300" target="_blank">17300</a>');
include('./footer.inc.php');
exit;
require_once('./footer.inc.php');
}
}
}
@@ -481,16 +480,16 @@ if (!empty($asfile)) {
}
$js_to_run = 'functions.js';
include('./header.inc.php');
require_once('./header.inc.php');
if ($export_type == 'server') {
$active_page = 'server_export.php';
include('./server_export.php');
require_once('./server_export.php');
} elseif ($export_type == 'database') {
$active_page = 'db_details_export.php';
include('./db_details_export.php');
require_once('./db_details_export.php');
} else {
$active_page = 'tbl_properties_export.php';
include('./tbl_properties_export.php');
require_once('./tbl_properties_export.php');
}
exit();
} else {
@@ -507,6 +506,6 @@ else {
echo ' </pre>' . "\n";
echo '</div>' . "\n";
echo "\n";
include('./footer.inc.php');
require_once('./footer.inc.php');
} // end if
?>

View File

@@ -2,10 +2,15 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
// In this file you may add PHP or HTML statements that will be used to define
// the footer for phpMyAdmin pages.
/**
* In this file you may add PHP or HTML statements that will be used to define
* the footer for phpMyAdmin pages.
*
* WARNING: This script has to be included at the very end of your code because
* it will stop the script execution!
*/
require('./libraries/relation.lib.php'); // for PMA_setHistory()
require_once('./libraries/relation.lib.php'); // for PMA_setHistory()
/**
* Query window
@@ -14,6 +19,7 @@ require('./libraries/relation.lib.php'); // for PMA_setHistory()
// If query window is wanted and open, update with latest selected db/table.
if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
?>
<script type="text/javascript">
<!--
<?php
@@ -137,10 +143,10 @@ if (isset($GLOBALS['cfg']['DBG']['enable'])
&& isset($GLOBALS['cfg']['DBG']['profile']['enable'])
&& $GLOBALS['cfg']['DBG']['profile']['enable']) {
//run the basic setup code first
include('./libraries/dbg/setup.php');
require_once('./libraries/dbg/setup.php');
//if the setup ran fine, then do the profiling
if (isset($GLOBALS['DBG']) && $GLOBALS['DBG']) {
include('./libraries/dbg/profiling.php');
require_once('./libraries/dbg/profiling.php');
dbg_dump_profiling_results();
}
}
@@ -153,4 +159,9 @@ if (isset($GLOBALS['cfg']['OBGzip']) && $GLOBALS['cfg']['OBGzip']
PMA_outBufferPost($GLOBALS['ob_mode']);
}
/**
* Stops the script execution
*/
exit;
?>

View File

@@ -2,161 +2,154 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
if (!defined('PMA_HEADER_INC_INCLUDED')) {
define('PMA_HEADER_INC_INCLUDED', 1);
/**
* Gets a core script and starts output buffering work
*/
require_once('./libraries/common.lib.php');
require_once('./libraries/ob.lib.php');
if ($GLOBALS['cfg']['OBGzip']) {
$GLOBALS['ob_mode'] = PMA_outBufferModeGet();
if ($GLOBALS['ob_mode']) {
PMA_outBufferPre($GLOBALS['ob_mode']);
}
}
/**
* Gets a core script and starts output buffering work
*/
if (!defined('PMA_COMMON_LIB_INCLUDED')) {
include('./libraries/common.lib.php');
}
if (!defined('PMA_OB_LIB_INCLUDED')) {
include('./libraries/ob.lib.php');
}
if ($GLOBALS['cfg']['OBGzip']) {
$GLOBALS['ob_mode'] = PMA_outBufferModeGet();
if ($GLOBALS['ob_mode']) {
PMA_outBufferPre($GLOBALS['ob_mode']);
}
}
// garvin: For re-usability, moved http-headers and stylesheets
// to a seperate file. It can now be included by header.inc.php,
// queryframe.php, querywindow.php.
// garvin: For re-usability, moved http-headers and stylesheets
// to a seperate file. It can now be included by header.inc.php,
// queryframe.php, querywindow.php.
require_once('./libraries/header_http.inc.php');
require_once('./libraries/header_meta_style.inc.php');
$title = '';
if (isset($GLOBALS['db'])) {
$title .= str_replace('\'', '\\\'', $GLOBALS['db']);
}
if (isset($GLOBALS['table'])) {
$title .= (empty($title) ? '' : '.') . str_replace('\'', '\\\'', $GLOBALS['table']);
}
if (!empty($GLOBALS['cfg']['Server']) && isset($GLOBALS['cfg']['Server']['host'])) {
$title .= (empty($title) ? 'phpMyAdmin ' : ' ')
. sprintf($GLOBALS['strRunning'], (empty($GLOBALS['cfg']['Server']['verbose']) ? str_replace('\'', '\\\'', $GLOBALS['cfg']['Server']['host']) : str_replace('\'', '\\\'', $GLOBALS['cfg']['Server']['verbose'])));
}
$title .= (empty($title) ? '' : ' - ') . 'phpMyAdmin ' . PMA_VERSION;
?>
<script type="text/javascript" language="javascript">
<!--
// Updates the title of the frameset if possible (ns4 does not allow this)
if (typeof(parent.document) != 'undefined' && typeof(parent.document) != 'unknown'
&& typeof(parent.document.title) == 'string') {
parent.document.title = '<?php echo $title; ?>';
}
<?php
// Add some javascript instructions if required
if (isset($js_to_run) && $js_to_run == 'functions.js') {
echo "\n";
?>
// js form validation stuff
var errorMsg0 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strFormEmpty']); ?>';
var errorMsg1 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotNumber']); ?>';
var errorMsg2 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotValidNumber']); ?>';
var noDropDbMsg = '<?php echo((!$GLOBALS['cfg']['AllowUserDropDatabase']) ? str_replace('\'', '\\\'', $GLOBALS['strNoDropDatabases']) : ''); ?>';
var confirmMsg = '<?php echo(($GLOBALS['cfg']['Confirm']) ? str_replace('\'', '\\\'', $GLOBALS['strDoYouReally']) : ''); ?>';
//-->
</script>
<script src="libraries/functions.js" type="text/javascript" language="javascript"></script>
<?php
} else if (isset($js_to_run) && $js_to_run == 'user_password.js') {
echo "\n";
?>
// js form validation stuff
var jsHostEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strHostEmpty']); ?>';
var jsUserEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strUserEmpty']); ?>';
var jsPasswordEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordEmpty']); ?>';
var jsPasswordNotSame = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordNotSame']); ?>';
//-->
</script>
<script src="libraries/user_password.js" type="text/javascript" language="javascript"></script>
<?php
} else if (isset($js_to_run) && $js_to_run == 'server_privileges.js') {
echo "\n";
?>
// js form validation stuff
var jsHostEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strHostEmpty']); ?>';
var jsUserEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strUserEmpty']); ?>';
var jsPasswordEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordEmpty']); ?>';
var jsPasswordNotSame = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordNotSame']); ?>';
//-->
</script>
<script src="libraries/server_privileges.js" type="text/javascript" language="javascript"></script>
<?php
} else if (isset($js_to_run) && $js_to_run == 'indexes.js') {
echo "\n";
?>
// js index validation stuff
var errorMsg0 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strFormEmpty']); ?>';
var errorMsg1 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotNumber']); ?>';
var errorMsg2 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotValidNumber']); ?>';
//-->
</script>
<script src="libraries/indexes.js" type="text/javascript" language="javascript"></script>
<?php
} else if (isset($js_to_run) && $js_to_run == 'tbl_change.js') {
echo "\n";
?>
//-->
</script>
<script src="libraries/tbl_change.js" type="text/javascript" language="javascript"></script>
<?php
} else {
echo "\n";
?>
//-->
</script>
<?php
}
echo "\n";
?>
<meta name="OBGZip" content="<?php echo ($cfg['OBGzip'] ? 'true' : 'false'); ?>" />
</head>
<?php
if ($GLOBALS['cfg']['RightBgImage'] != '') {
$bkg_img = ' background="' . $GLOBALS['cfg']['RightBgImage'] . '"';
} else {
$bkg_img = '';
}
?>
<body bgcolor="<?php echo $GLOBALS['cfg']['RightBgColor'] . '"' . $bkg_img; ?>>
<?php
if (!defined('PMA_DISPLAY_HEADING')) {
define('PMA_DISPLAY_HEADING', 1);
}
if (PMA_DISPLAY_HEADING) {
$header_url_qry = '?' . PMA_generate_common_url();
echo '<h1>' . "\n";
$server_info = (!empty($cfg['Server']['verbose'])
? $cfg['Server']['verbose']
: $server_info = $cfg['Server']['host'] . (empty($cfg['Server']['port'])
? ''
: ':' . $cfg['Server']['port']
)
);
if (isset($GLOBALS['db'])) {
echo ' ' . $GLOBALS['strDatabase'] . ' <i><a class="h1" href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . $header_url_qry . '&amp;db=' . urlencode($GLOBALS['db']) . '">' . htmlspecialchars($GLOBALS['db']) . '</a></i>' . "\n";
if (!empty($GLOBALS['table'])) {
echo ' - ' . $GLOBALS['strTable'] . ' <i><a class="h1" href="' . $GLOBALS['cfg']['DefaultTabTable'] . $header_url_qry . '&amp;db=' . urlencode($GLOBALS['db']) . '&amp;table=' . urlencode($GLOBALS['table']) . '">' . htmlspecialchars($GLOBALS['table']) . '</a></i>' . "\n";
}
echo ' ' . sprintf($GLOBALS['strRunning'], '<i><a class="h1" href="' . $GLOBALS['cfg']['DefaultTabServer'] . $header_url_qry . '">' . htmlspecialchars($server_info) . '</a></i>');
} else {
echo ' ' . sprintf($GLOBALS['strServer'], '<i><a class="h1" href="' . $GLOBALS['cfg']['DefaultTabServer'] . $header_url_qry . '">' . htmlspecialchars($server_info) . '</a></i>');
}
echo "\n" . '</h1>' . "\n";
}
echo "\n";
/**
* Sets a variable to remember headers have been sent
*/
$GLOBALS['is_header_sent'] = TRUE;
include('./libraries/header_http.inc.php');
include('./libraries/header_meta_style.inc.php');
$title = '';
if (isset($GLOBALS['db'])) {
$title .= str_replace('\'', '\\\'', $GLOBALS['db']);
}
if (isset($GLOBALS['table'])) {
$title .= (empty($title) ? '' : '.') . str_replace('\'', '\\\'', $GLOBALS['table']);
}
if (!empty($GLOBALS['cfg']['Server']) && isset($GLOBALS['cfg']['Server']['host'])) {
$title .= (empty($title) ? 'phpMyAdmin ' : ' ')
. sprintf($GLOBALS['strRunning'], (empty($GLOBALS['cfg']['Server']['verbose']) ? str_replace('\'', '\\\'', $GLOBALS['cfg']['Server']['host']) : str_replace('\'', '\\\'', $GLOBALS['cfg']['Server']['verbose'])));
}
$title .= (empty($title) ? '' : ' - ') . 'phpMyAdmin ' . PMA_VERSION;
?>
<script type="text/javascript" language="javascript">
<!--
// Updates the title of the frameset if possible (ns4 does not allow this)
if (typeof(parent.document) != 'undefined' && typeof(parent.document) != 'unknown'
&& typeof(parent.document.title) == 'string') {
parent.document.title = '<?php echo $title; ?>';
}
<?php
// Add some javascript instructions if required
if (isset($js_to_run) && $js_to_run == 'functions.js') {
echo "\n";
?>
// js form validation stuff
var errorMsg0 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strFormEmpty']); ?>';
var errorMsg1 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotNumber']); ?>';
var errorMsg2 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotValidNumber']); ?>';
var noDropDbMsg = '<?php echo((!$GLOBALS['cfg']['AllowUserDropDatabase']) ? str_replace('\'', '\\\'', $GLOBALS['strNoDropDatabases']) : ''); ?>';
var confirmMsg = '<?php echo(($GLOBALS['cfg']['Confirm']) ? str_replace('\'', '\\\'', $GLOBALS['strDoYouReally']) : ''); ?>';
//-->
</script>
<script src="libraries/functions.js" type="text/javascript" language="javascript"></script>
<?php
} else if (isset($js_to_run) && $js_to_run == 'user_password.js') {
echo "\n";
?>
// js form validation stuff
var jsHostEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strHostEmpty']); ?>';
var jsUserEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strUserEmpty']); ?>';
var jsPasswordEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordEmpty']); ?>';
var jsPasswordNotSame = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordNotSame']); ?>';
//-->
</script>
<script src="libraries/user_password.js" type="text/javascript" language="javascript"></script>
<?php
} else if (isset($js_to_run) && $js_to_run == 'server_privileges.js') {
echo "\n";
?>
// js form validation stuff
var jsHostEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strHostEmpty']); ?>';
var jsUserEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strUserEmpty']); ?>';
var jsPasswordEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordEmpty']); ?>';
var jsPasswordNotSame = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordNotSame']); ?>';
//-->
</script>
<script src="libraries/server_privileges.js" type="text/javascript" language="javascript"></script>
<?php
} else if (isset($js_to_run) && $js_to_run == 'indexes.js') {
echo "\n";
?>
// js index validation stuff
var errorMsg0 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strFormEmpty']); ?>';
var errorMsg1 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotNumber']); ?>';
var errorMsg2 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotValidNumber']); ?>';
//-->
</script>
<script src="libraries/indexes.js" type="text/javascript" language="javascript"></script>
<?php
} else if (isset($js_to_run) && $js_to_run == 'tbl_change.js') {
echo "\n";
?>
//-->
</script>
<script src="libraries/tbl_change.js" type="text/javascript" language="javascript"></script>
<?php
} else {
echo "\n";
?>
//-->
</script>
<?php
}
echo "\n";
?>
<meta name="OBGZip" content="<?php echo ($cfg['OBGzip'] ? 'true' : 'false'); ?>" />
</head>
<?php
if ($GLOBALS['cfg']['RightBgImage'] != '') {
$bkg_img = ' background="' . $GLOBALS['cfg']['RightBgImage'] . '"';
} else {
$bkg_img = '';
}
?>
<body bgcolor="<?php echo $GLOBALS['cfg']['RightBgColor'] . '"' . $bkg_img; ?>>
<?php
if (!defined('PMA_DISPLAY_HEADING')) {
define('PMA_DISPLAY_HEADING', 1);
}
if (PMA_DISPLAY_HEADING) {
$header_url_qry = '?' . PMA_generate_common_url();
echo '<h1>' . "\n";
$server_info = (!empty($cfg['Server']['verbose'])
? $cfg['Server']['verbose']
: $server_info = $cfg['Server']['host'] . (empty($cfg['Server']['port'])
? ''
: ':' . $cfg['Server']['port']
)
);
if (isset($GLOBALS['db'])) {
echo ' ' . $GLOBALS['strDatabase'] . ' <i><a class="h1" href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . $header_url_qry . '&amp;db=' . urlencode($GLOBALS['db']) . '">' . htmlspecialchars($GLOBALS['db']) . '</a></i>' . "\n";
if (!empty($GLOBALS['table'])) {
echo ' - ' . $GLOBALS['strTable'] . ' <i><a class="h1" href="' . $GLOBALS['cfg']['DefaultTabTable'] . $header_url_qry . '&amp;db=' . urlencode($GLOBALS['db']) . '&amp;table=' . urlencode($GLOBALS['table']) . '">' . htmlspecialchars($GLOBALS['table']) . '</a></i>' . "\n";
}
echo ' ' . sprintf($GLOBALS['strRunning'], '<i><a class="h1" href="' . $GLOBALS['cfg']['DefaultTabServer'] . $header_url_qry . '">' . htmlspecialchars($server_info) . '</a></i>');
} else {
echo ' ' . sprintf($GLOBALS['strServer'], '<i><a class="h1" href="' . $GLOBALS['cfg']['DefaultTabServer'] . $header_url_qry . '">' . htmlspecialchars($server_info) . '</a></i>');
}
echo "\n" . '</h1>' . "\n";
}
echo "\n";
/**
* Sets a variable to remember headers have been sent
*/
$GLOBALS['is_header_sent'] = TRUE;
} // PMA_HEADER_INC_INCLUDED
?>

View File

@@ -5,8 +5,8 @@
/**
* Gets a core script and starts output buffering work
*/
require('./libraries/common.lib.php');
require('./libraries/ob.lib.php');
require_once('./libraries/common.lib.php');
require_once('./libraries/ob.lib.php');
if ($cfg['OBGzip']) {
$ob_mode = PMA_outBufferModeGet();
if ($ob_mode) {
@@ -23,7 +23,7 @@ PMA_checkParameters(array('db', 'full_sql_query'));
// to a seperate file. It can now be included by header.inc.php,
// queryframe.php, querywindow.php.
include('./libraries/header_http.inc.php');
require_once('./libraries/header_http.inc.php');
/**
* Sends the beginning of the html page then returns to the calling script

View File

@@ -6,8 +6,8 @@
/**
* Gets core libraries and defines some variables
*/
require('./libraries/grab_globals.lib.php');
require('./libraries/common.lib.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
// Gets the default font sizes
PMA_setFontSizes();
@@ -41,7 +41,7 @@ $url_query = PMA_generate_common_url(isset($db) ? $db : '');
header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
require('./libraries/relation.lib.php');
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
if ($cfg['QueryHistoryDB'] && $cfgRelation['historywork']) {

View File

@@ -18,8 +18,8 @@
/**
* Gets some core scripts
*/
require('./libraries/grab_globals.lib.php');
require('./libraries/common.lib.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
// Check parameters
@@ -80,9 +80,9 @@ if (isset($btnLDI) && isset($local_textfile) && $local_textfile != '') {
*/
if (isset($btnLDI) && empty($textfile)) {
$js_to_run = 'functions.js';
include('./header.inc.php');
require_once('./header.inc.php');
$message = $strMustSelectFile;
include('./ldi_table.php');
require('./ldi_table.php');
} elseif (isset($btnLDI) && ($textfile != 'none')) {
if (!isset($replace)) {
$replace = '';
@@ -91,7 +91,7 @@ if (isset($btnLDI) && empty($textfile)) {
// the error message does not correspond exactly to the error...
if (!@chmod($textfile, 0644)) {
echo $strFileCouldNotBeRead . ' ' . $textfile . '<br />';
exit();
require_once('./footer.inc.php');
}
// Kanji encoding convert appended by Y.Kawada
@@ -159,7 +159,7 @@ if (isset($btnLDI) && empty($textfile)) {
//
// The $goto in ldi_table.php is set to tbl_properties.php but maybe
// if would be better to Browse the latest inserted data.
include('./sql.php');
require('./sql.php');
if ($unlink_local_textfile) {
unlink($textfile);
}
@@ -170,6 +170,6 @@ if (isset($btnLDI) && empty($textfile)) {
* The form used to define the query hasn't been yet submitted -> loads it
*/
else {
include('./ldi_table.php');
require('./ldi_table.php');
}
?>

View File

@@ -7,12 +7,10 @@
* This file defines the forms used to insert a textfile into a table
*/
require('./libraries/grab_globals.lib.php');
require_once('./libraries/grab_globals.lib.php');
// Check parameters
if (!defined('PMA_COMMON_LIB_INCLUDED')) {
include('./libraries/common.lib.php');
}
require_once('./libraries/common.lib.php');
PMA_checkParameters(array('db', 'table'));
@@ -194,5 +192,5 @@ if (PMA_MYSQL_INT_VERSION > 40003) {
/**
* Displays the footer
*/
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -7,7 +7,7 @@
* Gets the variables sent to this script, retains the db name that may have
* been defined as startup option and include a core library
*/
require('./libraries/grab_globals.lib.php');
require_once('./libraries/grab_globals.lib.php');
if (isset($lightm_db) && !empty($lightm_db)) {
// no longer urlencoded because of html entities in the db name
// $db = urldecode($lightm_db);
@@ -22,8 +22,8 @@ if (!empty($db)) {
/**
* Gets a core script and starts output buffering work
*/
require('./libraries/common.lib.php');
require('./libraries/ob.lib.php');
require_once('./libraries/common.lib.php');
require_once('./libraries/ob.lib.php');
if ($cfg['OBGzip']) {
$ob_mode = PMA_outBufferModeGet();
if ($ob_mode) {
@@ -33,8 +33,8 @@ if ($cfg['OBGzip']) {
PMA_checkParameters(array('hash'));
include('./libraries/bookmark.lib.php');
require('./libraries/relation.lib.php');
require_once('./libraries/bookmark.lib.php');
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
function PMA_reduceNest($_table) {
@@ -192,7 +192,7 @@ if ($server > 0) {
// to a seperate file. It can now be included by header.inc.php,
// queryframe.php, querywindow.php.
include('./libraries/header_http.inc.php');
require_once('./libraries/header_http.inc.php');
/**
* Displays the frame

View File

@@ -8,92 +8,89 @@
// +--------------------------------------------------------------------------+
if (!defined('PMA_CONFIG_AUTH_INCLUDED')) {
define('PMA_CONFIG_AUTH_INCLUDED', 1);
/**
* Displays authentication form
*
* @return boolean always true
*
* @access public
*/
function PMA_auth()
{
return TRUE;
} // end of the 'PMA_auth()' function
/**
* Displays authentication form
*
* @return boolean always true
*
* @access public
*/
function PMA_auth()
{
return TRUE;
} // end of the 'PMA_auth()' function
/**
* Gets advanced authentication settings
*
* @return boolean always true
*
* @access public
*/
function PMA_auth_check()
{
return TRUE;
} // end of the 'PMA_auth_check()' function
/**
* Gets advanced authentication settings
*
* @return boolean always true
*
* @access public
*/
function PMA_auth_check()
{
return TRUE;
} // end of the 'PMA_auth_check()' function
/**
* Set the user and password after last checkings if required
*
* @return boolean always true
*
* @access public
*/
function PMA_auth_set_user()
{
return TRUE;
} // end of the 'PMA_auth_set_user()' function
/**
* Set the user and password after last checkings if required
*
* @return boolean always true
*
* @access public
*/
function PMA_auth_set_user()
{
return TRUE;
} // end of the 'PMA_auth_set_user()' function
/**
* User is not allowed to login to MySQL -> authentication failed
*
* @global string the MySQL error message PHP returns
* @global string the connection type (persistent or not)
* @global string the MySQL server port to use
* @global string the MySQL socket port to use
* @global array the current server settings
* @global string the font face to use in case of failure
* @global string the default font size to use in case of failure
* @global string the big font size to use in case of failure
* @global boolean tell the "PMA_mysqlDie()" function headers have been
* sent
*
* @return boolean always true (no return indeed)
*
* @access public
*/
function PMA_auth_fails()
{
global $php_errormsg;
global $connect_func, $server_port, $server_socket, $cfg;
global $right_font_family, $font_size, $font_bigger;
global $is_header_sent;
if (PMA_mysql_error()) {
$conn_error = PMA_mysql_error();
} else if (isset($php_errormsg)) {
$conn_error = $php_errormsg;
} else {
$conn_error = 'Cannot connect: invalid settings.';
}
/**
* User is not allowed to login to MySQL -> authentication failed
*
* @global string the MySQL error message PHP returns
* @global string the connection type (persistent or not)
* @global string the MySQL server port to use
* @global string the MySQL socket port to use
* @global array the current server settings
* @global string the font face to use in case of failure
* @global string the default font size to use in case of failure
* @global string the big font size to use in case of failure
* @global boolean tell the "PMA_mysqlDie()" function headers have been
* sent
*
* @return boolean always true (no return indeed)
*
* @access public
*/
function PMA_auth_fails()
{
global $php_errormsg;
global $connect_func, $server_port, $server_socket, $cfg;
global $right_font_family, $font_size, $font_bigger;
global $is_header_sent;
if (PMA_mysql_error()) {
$conn_error = PMA_mysql_error();
} else if (isset($php_errormsg)) {
$conn_error = $php_errormsg;
} else {
$conn_error = 'Cannot connect: invalid settings.';
}
/* Commented out by Nijel: This causes displaying login and password from
* config when connection to MySQL server can't be established. (SQL parser
* fails on this and then displays it as wrong SQL.
*/
/* $local_query = $connect_func . '('
. $cfg['Server']['host'] . $server_port . $server_socket . ', '
. $cfg['Server']['user'] . ', '
. $cfg['Server']['password'] . ')';*/
$local_query = '';
. $cfg['Server']['host'] . $server_port . $server_socket . ', '
. $cfg['Server']['user'] . ', '
. $cfg['Server']['password'] . ')';*/
$local_query = '';
// Defines the charset to be used
header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
?>
// Defines the charset to be used
header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $GLOBALS['available_languages'][$GLOBALS['lang']][2]; ?>" lang="<?php echo $GLOBALS['available_languages'][$GLOBALS['lang']][2]; ?>" dir="<?php echo $GLOBALS['text_dir']; ?>">
@@ -115,14 +112,13 @@ h1 {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo
<h1><?php echo sprintf($GLOBALS['strWelcome'], ' phpMyAdmin ' . PMA_VERSION); ?></h1>
</center>
<br />
<?php
echo "\n";
$is_header_sent = TRUE;
echo '<p>' . $GLOBALS['strAccessDeniedExplanation'] . '</p>' . "\n";
PMA_mysqlDie($conn_error, $local_query, FALSE);
<?php
echo "\n";
$is_header_sent = TRUE;
echo '<p>' . $GLOBALS['strAccessDeniedExplanation'] . '</p>' . "\n";
PMA_mysqlDie($conn_error, $local_query, FALSE);
return TRUE;
} // end of the 'PMA_auth_fails()' function
return TRUE;
} // end of the 'PMA_auth_fails()' function
} // $__PMA_CONFIG_AUTH_LIB__
?>

File diff suppressed because it is too large Load Diff

View File

@@ -8,31 +8,28 @@
// +--------------------------------------------------------------------------+
if (!defined('PMA_HTTP_AUTH_INCLUDED')) {
define('PMA_HTTP_AUTH_INCLUDED', 1);
/**
* Displays authentication form
*
* @global string the font face to use in case of failure
* @global string the default font size to use in case of failure
* @global string the big font size to use in case of failure
*
* @return boolean always true (no return indeed)
*
* @access public
*/
function PMA_auth()
{
global $right_font_family, $font_size, $font_bigger;
/**
* Displays authentication form
*
* @global string the font face to use in case of failure
* @global string the default font size to use in case of failure
* @global string the big font size to use in case of failure
*
* @return boolean always true (no return indeed)
*
* @access public
*/
function PMA_auth()
{
global $right_font_family, $font_size, $font_bigger;
header('WWW-Authenticate: Basic realm="phpMyAdmin ' . sprintf($GLOBALS['strRunning'], (empty($GLOBALS['cfg']['Server']['verbose']) ? str_replace('\'', '\\\'',$GLOBALS['cfg']['Server']['host']) : str_replace('\'', '\\\'', $GLOBALS['cfg']['Server']['verbose']))) . '"');
header('HTTP/1.0 401 Unauthorized');
header('status: 401 Unauthorized');
header('WWW-Authenticate: Basic realm="phpMyAdmin ' . sprintf($GLOBALS['strRunning'], (empty($GLOBALS['cfg']['Server']['verbose']) ? str_replace('\'', '\\\'',$GLOBALS['cfg']['Server']['host']) : str_replace('\'', '\\\'', $GLOBALS['cfg']['Server']['verbose']))) . '"');
header('HTTP/1.0 401 Unauthorized');
header('status: 401 Unauthorized');
// Defines the charset to be used
header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
?>
// Defines the charset to be used
header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $GLOBALS['available_languages'][$GLOBALS['lang']][2]; ?>" lang="<?php echo $GLOBALS['available_languages'][$GLOBALS['lang']][2]; ?>" dir="<?php echo $GLOBALS['text_dir']; ?>">
@@ -58,183 +55,182 @@ h1 {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo
</body>
</html>
<?php
echo "\n";
exit();
<?php
echo "\n";
exit();
return TRUE;
} // end of the 'PMA_auth()' function
/**
* Gets advanced authentication settings
*
* @global string the username if register_globals is on
* @global string the password if register_globals is on
* @global array the array of server variables if register_globals is
* off
* @global array the array of environment variables if register_globals
* is off
* @global string the username for the ? server
* @global string the password for the ? server
* @global string the username for the WebSite Professional server
* @global string the password for the WebSite Professional server
* @global string the username of the user who logs out
*
* @return boolean whether we get authentication settings or not
*
* @access public
*/
function PMA_auth_check()
{
global $PHP_AUTH_USER, $PHP_AUTH_PW;
global $REMOTE_USER, $AUTH_USER, $REMOTE_PASSWORD, $AUTH_PASSWORD;
global $HTTP_AUTHORIZATION;
global $old_usr;
// Grabs the $PHP_AUTH_USER variable whatever are the values of the
// 'register_globals' and the 'variables_order' directives
// loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
if (empty($PHP_AUTH_USER)) {
if (!empty($_SERVER) && isset($_SERVER['PHP_AUTH_USER'])) {
$PHP_AUTH_USER = $_SERVER['PHP_AUTH_USER'];
}
else if (isset($REMOTE_USER)) {
$PHP_AUTH_USER = $REMOTE_USER;
}
else if (!empty($_ENV) && isset($_ENV['REMOTE_USER'])) {
$PHP_AUTH_USER = $_ENV['REMOTE_USER'];
}
else if (@getenv('REMOTE_USER')) {
$PHP_AUTH_USER = getenv('REMOTE_USER');
}
// Fix from Matthias Fichtner for WebSite Professional - Part 1
else if (isset($AUTH_USER)) {
$PHP_AUTH_USER = $AUTH_USER;
}
else if (!empty($_ENV) && isset($_ENV['AUTH_USER'])) {
$PHP_AUTH_USER = $_ENV['AUTH_USER'];
}
else if (@getenv('AUTH_USER')) {
$PHP_AUTH_USER = getenv('AUTH_USER');
}
}
// Grabs the $PHP_AUTH_PW variable whatever are the values of the
// 'register_globals' and the 'variables_order' directives
// loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
if (empty($PHP_AUTH_PW)) {
if (!empty($_SERVER) && isset($_SERVER['PHP_AUTH_PW'])) {
$PHP_AUTH_PW = $_SERVER['PHP_AUTH_PW'];
}
else if (isset($REMOTE_PASSWORD)) {
$PHP_AUTH_PW = $REMOTE_PASSWORD;
}
else if (!empty($_ENV) && isset($_ENV['REMOTE_PASSWORD'])) {
$PHP_AUTH_PW = $_ENV['REMOTE_PASSWORD'];
}
else if (@getenv('REMOTE_PASSWORD')) {
$PHP_AUTH_PW = getenv('REMOTE_PASSWORD');
}
// Fix from Matthias Fichtner for WebSite Professional - Part 2
else if (isset($AUTH_PASSWORD)) {
$PHP_AUTH_PW = $AUTH_PASSWORD;
}
else if (!empty($_ENV) && isset($_ENV['AUTH_PASSWORD'])) {
$PHP_AUTH_PW = $_ENV['AUTH_PASSWORD'];
}
else if (@getenv('AUTH_PASSWORD')) {
$PHP_AUTH_PW = getenv('AUTH_PASSWORD');
}
}
// Gets authenticated user settings with IIS
if (empty($PHP_AUTH_USER) && empty($PHP_AUTH_PW)
&& function_exists('base64_decode')) {
if (!empty($HTTP_AUTHORIZATION)
&& substr($HTTP_AUTHORIZATION, 0, 6) == 'Basic ') {
list($PHP_AUTH_USER, $PHP_AUTH_PW) = explode(':', base64_decode(substr($HTTP_AUTHORIZATION, 6)));
}
else if (!empty($_ENV)
&& isset($_ENV['HTTP_AUTHORIZATION'])
&& substr($_ENV['HTTP_AUTHORIZATION'], 0, 6) == 'Basic ') {
list($PHP_AUTH_USER, $PHP_AUTH_PW) = explode(':', base64_decode(substr($_ENV['HTTP_AUTHORIZATION'], 6)));
}
else if (@getenv('HTTP_AUTHORIZATION')
&& substr(getenv('HTTP_AUTHORIZATION'), 0, 6) == 'Basic ') {
list($PHP_AUTH_USER, $PHP_AUTH_PW) = explode(':', base64_decode(substr(getenv('HTTP_AUTHORIZATION'), 6)));
}
} // end IIS
// User logged out -> ensure the new username is not the same
if (!empty($old_usr)
&& (isset($PHP_AUTH_USER) && $old_usr == $PHP_AUTH_USER)) {
$PHP_AUTH_USER = '';
}
// Returns whether we get authentication settings or not
if (empty($PHP_AUTH_USER)) {
return FALSE;
} else {
if (get_magic_quotes_gpc()) {
$PHP_AUTH_USER = stripslashes($PHP_AUTH_USER);
$PHP_AUTH_PW = stripslashes($PHP_AUTH_PW);
}
return TRUE;
} // end of the 'PMA_auth()' function
}
} // end of the 'PMA_auth_check()' function
/**
* Gets advanced authentication settings
*
* @global string the username if register_globals is on
* @global string the password if register_globals is on
* @global array the array of server variables if register_globals is
* off
* @global array the array of environment variables if register_globals
* is off
* @global string the username for the ? server
* @global string the password for the ? server
* @global string the username for the WebSite Professional server
* @global string the password for the WebSite Professional server
* @global string the username of the user who logs out
*
* @return boolean whether we get authentication settings or not
*
* @access public
*/
function PMA_auth_check()
{
global $PHP_AUTH_USER, $PHP_AUTH_PW;
global $REMOTE_USER, $AUTH_USER, $REMOTE_PASSWORD, $AUTH_PASSWORD;
global $HTTP_AUTHORIZATION;
global $old_usr;
/**
* Set the user and password after last checkings if required
*
* @global array the valid servers settings
* @global integer the id of the current server
* @global array the current server settings
* @global string the current username
* @global string the current password
*
* @return boolean always true
*
* @access public
*/
function PMA_auth_set_user()
{
global $cfg, $server;
global $PHP_AUTH_USER, $PHP_AUTH_PW;
// Grabs the $PHP_AUTH_USER variable whatever are the values of the
// 'register_globals' and the 'variables_order' directives
// loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
if (empty($PHP_AUTH_USER)) {
if (!empty($_SERVER) && isset($_SERVER['PHP_AUTH_USER'])) {
$PHP_AUTH_USER = $_SERVER['PHP_AUTH_USER'];
// Ensures valid authentication mode, 'only_db', bookmark database and
// table names and relation table name are used
if ($cfg['Server']['user'] != $PHP_AUTH_USER) {
$servers_cnt = count($cfg['Servers']);
for ($i = 1; $i <= $servers_cnt; $i++) {
if (isset($cfg['Servers'][$i])
&& ($cfg['Servers'][$i]['host'] == $cfg['Server']['host'] && $cfg['Servers'][$i]['user'] == $PHP_AUTH_USER)) {
$server = $i;
$cfg['Server'] = $cfg['Servers'][$i];
break;
}
else if (isset($REMOTE_USER)) {
$PHP_AUTH_USER = $REMOTE_USER;
}
else if (!empty($_ENV) && isset($_ENV['REMOTE_USER'])) {
$PHP_AUTH_USER = $_ENV['REMOTE_USER'];
}
else if (@getenv('REMOTE_USER')) {
$PHP_AUTH_USER = getenv('REMOTE_USER');
}
// Fix from Matthias Fichtner for WebSite Professional - Part 1
else if (isset($AUTH_USER)) {
$PHP_AUTH_USER = $AUTH_USER;
}
else if (!empty($_ENV) && isset($_ENV['AUTH_USER'])) {
$PHP_AUTH_USER = $_ENV['AUTH_USER'];
}
else if (@getenv('AUTH_USER')) {
$PHP_AUTH_USER = getenv('AUTH_USER');
}
}
// Grabs the $PHP_AUTH_PW variable whatever are the values of the
// 'register_globals' and the 'variables_order' directives
// loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
if (empty($PHP_AUTH_PW)) {
if (!empty($_SERVER) && isset($_SERVER['PHP_AUTH_PW'])) {
$PHP_AUTH_PW = $_SERVER['PHP_AUTH_PW'];
}
else if (isset($REMOTE_PASSWORD)) {
$PHP_AUTH_PW = $REMOTE_PASSWORD;
}
else if (!empty($_ENV) && isset($_ENV['REMOTE_PASSWORD'])) {
$PHP_AUTH_PW = $_ENV['REMOTE_PASSWORD'];
}
else if (@getenv('REMOTE_PASSWORD')) {
$PHP_AUTH_PW = getenv('REMOTE_PASSWORD');
}
// Fix from Matthias Fichtner for WebSite Professional - Part 2
else if (isset($AUTH_PASSWORD)) {
$PHP_AUTH_PW = $AUTH_PASSWORD;
}
else if (!empty($_ENV) && isset($_ENV['AUTH_PASSWORD'])) {
$PHP_AUTH_PW = $_ENV['AUTH_PASSWORD'];
}
else if (@getenv('AUTH_PASSWORD')) {
$PHP_AUTH_PW = getenv('AUTH_PASSWORD');
}
}
// Gets authenticated user settings with IIS
if (empty($PHP_AUTH_USER) && empty($PHP_AUTH_PW)
&& function_exists('base64_decode')) {
if (!empty($HTTP_AUTHORIZATION)
&& substr($HTTP_AUTHORIZATION, 0, 6) == 'Basic ') {
list($PHP_AUTH_USER, $PHP_AUTH_PW) = explode(':', base64_decode(substr($HTTP_AUTHORIZATION, 6)));
}
else if (!empty($_ENV)
&& isset($_ENV['HTTP_AUTHORIZATION'])
&& substr($_ENV['HTTP_AUTHORIZATION'], 0, 6) == 'Basic ') {
list($PHP_AUTH_USER, $PHP_AUTH_PW) = explode(':', base64_decode(substr($_ENV['HTTP_AUTHORIZATION'], 6)));
}
else if (@getenv('HTTP_AUTHORIZATION')
&& substr(getenv('HTTP_AUTHORIZATION'), 0, 6) == 'Basic ') {
list($PHP_AUTH_USER, $PHP_AUTH_PW) = explode(':', base64_decode(substr(getenv('HTTP_AUTHORIZATION'), 6)));
}
} // end IIS
} // end for
} // end if
// User logged out -> ensure the new username is not the same
if (!empty($old_usr)
&& (isset($PHP_AUTH_USER) && $old_usr == $PHP_AUTH_USER)) {
$PHP_AUTH_USER = '';
}
$cfg['Server']['user'] = $PHP_AUTH_USER;
$cfg['Server']['password'] = $PHP_AUTH_PW;
// Returns whether we get authentication settings or not
if (empty($PHP_AUTH_USER)) {
return FALSE;
} else {
if (get_magic_quotes_gpc()) {
$PHP_AUTH_USER = stripslashes($PHP_AUTH_USER);
$PHP_AUTH_PW = stripslashes($PHP_AUTH_PW);
}
return TRUE;
}
} // end of the 'PMA_auth_check()' function
return TRUE;
} // end of the 'PMA_auth_set_user()' function
/**
* Set the user and password after last checkings if required
*
* @global array the valid servers settings
* @global integer the id of the current server
* @global array the current server settings
* @global string the current username
* @global string the current password
*
* @return boolean always true
*
* @access public
*/
function PMA_auth_set_user()
{
global $cfg, $server;
global $PHP_AUTH_USER, $PHP_AUTH_PW;
/**
* User is not allowed to login to MySQL -> authentication failed
*
* @return boolean always true (no return indeed)
*
* @access public
*/
function PMA_auth_fails()
{
PMA_auth();
// Ensures valid authentication mode, 'only_db', bookmark database and
// table names and relation table name are used
if ($cfg['Server']['user'] != $PHP_AUTH_USER) {
$servers_cnt = count($cfg['Servers']);
for ($i = 1; $i <= $servers_cnt; $i++) {
if (isset($cfg['Servers'][$i])
&& ($cfg['Servers'][$i]['host'] == $cfg['Server']['host'] && $cfg['Servers'][$i]['user'] == $PHP_AUTH_USER)) {
$server = $i;
$cfg['Server'] = $cfg['Servers'][$i];
break;
}
} // end for
} // end if
return TRUE;
} // end of the 'PMA_auth_fails()' function
$cfg['Server']['user'] = $PHP_AUTH_USER;
$cfg['Server']['password'] = $PHP_AUTH_PW;
return TRUE;
} // end of the 'PMA_auth_set_user()' function
/**
* User is not allowed to login to MySQL -> authentication failed
*
* @return boolean always true (no return indeed)
*
* @access public
*/
function PMA_auth_fails()
{
PMA_auth();
return TRUE;
} // end of the 'PMA_auth_fails()' function
} // $__PMA_HTTP_AUTH_LIB__
?>

View File

@@ -7,174 +7,168 @@
*/
/**
* Defines the bookmark parameters for the current user
*
* @return array the bookmark parameters for the current user
*
* @global integer the id of the current server
*
* @access public
*/
function PMA_getBookmarksParam()
{
global $server;
if (!defined('PMA_BOOKMARK_LIB_INCLUDED')) {
define('PMA_BOOKMARK_LIB_INCLUDED', 1);
$cfgBookmark = '';
/**
* Defines the bookmark parameters for the current user
*
* @return array the bookmark parameters for the current user
*
* @global integer the id of the current server
*
* @access public
*/
function PMA_getBookmarksParam()
{
global $server;
// No server selected -> no bookmark table
if ($server == 0) {
return '';
}
$cfgBookmark = '';
$cfgBookmark['user'] = $GLOBALS['cfg']['Server']['user'];
$cfgBookmark['db'] = $GLOBALS['cfg']['Server']['pmadb'];
$cfgBookmark['table'] = $GLOBALS['cfg']['Server']['bookmarktable'];
// No server selected -> no bookmark table
if ($server == 0) {
return '';
return $cfgBookmark;
} // end of the 'PMA_getBookmarksParam()' function
/**
* Gets the list of bookmarks defined for the current database
*
* @param string the current database name
* @param array the bookmark parameters for the current user
*
* @return mixed the bookmarks list if defined, false else
*
* @access public
*/
function PMA_listBookmarks($db, $cfgBookmark)
{
$query = 'SELECT label, id FROM '. PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
. ' OR user = \'\')';
if (isset($GLOBALS['dbh'])) {
$result = PMA_mysql_query($query, $GLOBALS['dbh']);
} else {
$result = PMA_mysql_query($query);
}
// There is some bookmarks -> store them
if ($result > 0 && mysql_num_rows($result) > 0) {
$flag = 1;
while ($row = PMA_mysql_fetch_row($result)) {
$bookmark_list[$flag . ' - ' . $row[0]] = $row[1];
$flag++;
} // end while
return $bookmark_list;
}
// No bookmarks for the current database
else {
return FALSE;
}
} // end of the 'PMA_listBookmarks()' function
/**
* Gets the sql command from a bookmark
*
* @param string the current database name
* @param array the bookmark parameters for the current user
* @param mixed the id of the bookmark to get
* @param string which field to look up the $id
*
* @return string the sql query
*
* @access public
*/
function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id')
{
if (empty($cfgBookmark['db']) || empty($cfgBookmark['table'])) {
return '';
}
$query = 'SELECT query FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
. ' OR user = \'\')'
. ' AND ' . PMA_backquote($id_field) . ' = ' . $id;
if (isset($GLOBALS['dbh'])) {
$result = PMA_mysql_query($query, $GLOBALS['dbh']);
} else {
$result = PMA_mysql_query($query);
}
$bookmark_query = @PMA_mysql_result($result, 0, 'query') OR FALSE;
return $bookmark_query;
} // end of the 'PMA_queryBookmarks()' function
/**
* Adds a bookmark
*
* @param array the properties of the bookmark to add
* @param array the bookmark parameters for the current user
* @param boolean whether to make the bookmark available for all users
*
* @return boolean whether the INSERT succeeds or not
*
* @access public
*/
function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false)
{
$query = 'INSERT INTO ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' (id, dbase, user, query, label) VALUES (\'\', \'' . PMA_sqlAddslashes($fields['dbase']) . '\', \'' . ($all_users ? '' : PMA_sqlAddslashes($fields['user'])) . '\', \'' . PMA_sqlAddslashes(urldecode($fields['query'])) . '\', \'' . PMA_sqlAddslashes($fields['label']) . '\')';
if (isset($GLOBALS['dbh'])) {
$result = PMA_mysql_query($query, $GLOBALS['dbh']);
if (PMA_mysql_error($GLOBALS['dbh'])) {
$error = PMA_mysql_error($GLOBALS['dbh']);
require_once('./header.inc.php');
PMA_mysqlDie($error);
}
$cfgBookmark['user'] = $GLOBALS['cfg']['Server']['user'];
$cfgBookmark['db'] = $GLOBALS['cfg']['Server']['pmadb'];
$cfgBookmark['table'] = $GLOBALS['cfg']['Server']['bookmarktable'];
return $cfgBookmark;
} // end of the 'PMA_getBookmarksParam()' function
/**
* Gets the list of bookmarks defined for the current database
*
* @param string the current database name
* @param array the bookmark parameters for the current user
*
* @return mixed the bookmarks list if defined, false else
*
* @access public
*/
function PMA_listBookmarks($db, $cfgBookmark)
{
$query = 'SELECT label, id FROM '. PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
. ' OR user = \'\')';
if (isset($GLOBALS['dbh'])) {
$result = PMA_mysql_query($query, $GLOBALS['dbh']);
} else {
$result = PMA_mysql_query($query);
} else {
$result = PMA_mysql_query($query);
if (PMA_mysql_error()) {
$error = PMA_mysql_error();
require_once('./header.inc.php');
PMA_mysqlDie($error);
}
}
// There is some bookmarks -> store them
if ($result > 0 && mysql_num_rows($result) > 0) {
$flag = 1;
while ($row = PMA_mysql_fetch_row($result)) {
$bookmark_list[$flag . ' - ' . $row[0]] = $row[1];
$flag++;
} // end while
return $bookmark_list;
}
// No bookmarks for the current database
else {
return FALSE;
}
} // end of the 'PMA_listBookmarks()' function
return TRUE;
} // end of the 'PMA_addBookmarks()' function
/**
* Gets the sql command from a bookmark
*
* @param string the current database name
* @param array the bookmark parameters for the current user
* @param mixed the id of the bookmark to get
* @param string which field to look up the $id
*
* @return string the sql query
*
* @access public
*/
function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id')
{
if (empty($cfgBookmark['db']) || empty($cfgBookmark['table'])) {
return '';
}
$query = 'SELECT query FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
. ' OR user = \'\')'
. ' AND ' . PMA_backquote($id_field) . ' = ' . $id;
if (isset($GLOBALS['dbh'])) {
$result = PMA_mysql_query($query, $GLOBALS['dbh']);
} else {
$result = PMA_mysql_query($query);
}
$bookmark_query = @PMA_mysql_result($result, 0, 'query') OR FALSE;
return $bookmark_query;
} // end of the 'PMA_queryBookmarks()' function
/**
* Deletes a bookmark
*
* @param string the current database name
* @param array the bookmark parameters for the current user
* @param integer the id of the bookmark to get
*
* @access public
*/
function PMA_deleteBookmarks($db, $cfgBookmark, $id)
{
$query = 'DELETE FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' WHERE (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
. ' OR user = \'\')'
. ' AND id = ' . $id;
if (isset($GLOBALS['dbh'])) {
$result = PMA_mysql_query($query, $GLOBALS['dbh']);
} else {
$result = PMA_mysql_query($query);
}
} // end of the 'PMA_deleteBookmarks()' function
/**
* Adds a bookmark
*
* @param array the properties of the bookmark to add
* @param array the bookmark parameters for the current user
* @param boolean whether to make the bookmark available for all users
*
* @return boolean whether the INSERT succeeds or not
*
* @access public
*/
function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false)
{
$query = 'INSERT INTO ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' (id, dbase, user, query, label) VALUES (\'\', \'' . PMA_sqlAddslashes($fields['dbase']) . '\', \'' . ($all_users ? '' : PMA_sqlAddslashes($fields['user'])) . '\', \'' . PMA_sqlAddslashes(urldecode($fields['query'])) . '\', \'' . PMA_sqlAddslashes($fields['label']) . '\')';
if (isset($GLOBALS['dbh'])) {
$result = PMA_mysql_query($query, $GLOBALS['dbh']);
if (PMA_mysql_error($GLOBALS['dbh'])) {
$error = PMA_mysql_error($GLOBALS['dbh']);
include('./header.inc.php');
PMA_mysqlDie($error);
}
} else {
$result = PMA_mysql_query($query);
if (PMA_mysql_error()) {
$error = PMA_mysql_error();
include('./header.inc.php');
PMA_mysqlDie($error);
}
}
/**
* Bookmark Support
*/
$cfg['Bookmark'] = PMA_getBookmarksParam();
return TRUE;
} // end of the 'PMA_addBookmarks()' function
/**
* Deletes a bookmark
*
* @param string the current database name
* @param array the bookmark parameters for the current user
* @param integer the id of the bookmark to get
*
* @access public
*/
function PMA_deleteBookmarks($db, $cfgBookmark, $id)
{
$query = 'DELETE FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' WHERE (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
. ' OR user = \'\')'
. ' AND id = ' . $id;
if (isset($GLOBALS['dbh'])) {
$result = PMA_mysql_query($query, $GLOBALS['dbh']);
} else {
$result = PMA_mysql_query($query);
}
} // end of the 'PMA_deleteBookmarks()' function
/**
* Bookmark Support
*/
$cfg['Bookmark'] = PMA_getBookmarksParam();
} // $__PMA_BOOKMARK_LIB__
?>

View File

@@ -8,316 +8,293 @@
*/
if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
define('PMA_CHARSET_CONVERSION_LIB_INCLUDED', 1);
/**
* Loads the recode or iconv extensions if any of it is not loaded yet
*/
if (isset($cfg['AllowAnywhereRecoding'])
&& $cfg['AllowAnywhereRecoding']
&& $allow_recoding) {
/**
* Loads the recode or iconv extensions if any of it is not loaded yet
*/
if (isset($cfg['AllowAnywhereRecoding'])
&& $cfg['AllowAnywhereRecoding']
&& $allow_recoding) {
// Initializes configuration for default, if not set:
if (!isset($cfg['RecodingEngine'])) {
$cfg['RecodingEngine'] = 'auto';
}
if ($cfg['RecodingEngine'] == 'recode') {
if ($cfg['RecodingEngine'] == 'recode') {
if (!@extension_loaded('recode')) {
PMA_dl('recode');
if (!@extension_loaded('recode')) {
echo $strCantLoadRecodeIconv;
exit;
}
}
$PMA_recoding_engine = 'recode';
} else if ($cfg['RecodingEngine'] == 'iconv') {
if (!@extension_loaded('iconv')) {
PMA_dl('iconv');
if (!@extension_loaded('iconv')) {
echo $strCantLoadRecodeIconv;
exit;
}
}
$PMA_recoding_engine = 'iconv';
} else {
if (@extension_loaded('iconv')) {
$PMA_recoding_engine = 'iconv';
} else if (@extension_loaded('recode')) {
$PMA_recoding_engine = 'recode';
} else {
PMA_dl('iconv');
if (!@extension_loaded('iconv')) {
PMA_dl('recode');
if (!@extension_loaded('recode')) {
echo $strCantLoadRecodeIconv;
exit();
}
}
$PMA_recoding_engine = 'recode';
} else if ($cfg['RecodingEngine'] == 'iconv') {
if (!@extension_loaded('iconv')) {
PMA_dl('iconv');
if (!@extension_loaded('iconv')) {
echo $strCantLoadRecodeIconv;
exit();
}
}
$PMA_recoding_engine = 'iconv';
} else {
if (@extension_loaded('iconv')) {
$PMA_recoding_engine = 'iconv';
} else if (@extension_loaded('recode')) {
$PMA_recoding_engine = 'recode';
} else {
PMA_dl('iconv');
if (!@extension_loaded('iconv')) {
PMA_dl('recode');
if (!@extension_loaded('recode')) {
echo $strCantLoadRecodeIconv;
exit();
} else {
$PMA_recoding_engine = 'recode';
}
exit;
} else {
$PMA_recoding_engine = 'iconv';
$PMA_recoding_engine = 'recode';
}
} else {
$PMA_recoding_engine = 'iconv';
}
}
} // end load recode/iconv extension
define('PMA_CHARSET_NONE', 0);
define('PMA_CHARSET_ICONV', 1);
define('PMA_CHARSET_LIBICONV', 2);
define('PMA_CHARSET_RECODE', 3);
if (!isset($cfg['IconvExtraParams'])) {
$cfg['IconvExtraParams'] = '';
}
} // end load recode/iconv extension
// Finally detects which function will we use:
if (isset($cfg['AllowAnywhereRecoding'])
&& $cfg['AllowAnywhereRecoding']
&& $allow_recoding) {
define('PMA_CHARSET_NONE', 0);
define('PMA_CHARSET_ICONV', 1);
define('PMA_CHARSET_LIBICONV', 2);
define('PMA_CHARSET_RECODE', 3);
if (!isset($PMA_recoding_engine)) {
$PMA_recoding_engine = $cfg['RecodingEngine'];
}
if ($PMA_recoding_engine == 'iconv') {
if (@function_exists('iconv')) {
$PMA_recoding_engine = PMA_CHARSET_ICONV;
} else if (@function_exists('libiconv')) {
$PMA_recoding_engine = PMA_CHARSET_LIBICONV;
} else {
$PMA_recoding_engine = PMA_CHARSET_NONE;
if (!isset($cfg['IconvExtraParams'])) {
$cfg['IconvExtraParams'] = '';
}
if (!isset($GLOBALS['is_header_sent'])) {
include('./header.inc.php');
}
echo $strCantUseRecodeIconv;
include('./footer.inc.php');
exit();
}
} else if ($PMA_recoding_engine == 'recode') {
if (@function_exists('recode_string')) {
$PMA_recoding_engine = PMA_CHARSET_RECODE;
} else {
$PMA_recoding_engine = PMA_CHARSET_NONE;
// Finally detects which function will we use:
if (isset($cfg['AllowAnywhereRecoding'])
&& $cfg['AllowAnywhereRecoding']
&& $allow_recoding) {
if (!isset($GLOBALS['is_header_sent'])) {
include('./header.inc.php');
}
echo $strCantUseRecodeIconv;
include('./footer.inc.php');
exit();
}
if (!isset($PMA_recoding_engine)) {
$PMA_recoding_engine = $cfg['RecodingEngine'];
}
if ($PMA_recoding_engine == 'iconv') {
if (@function_exists('iconv')) {
$PMA_recoding_engine = PMA_CHARSET_ICONV;
} else if (@function_exists('libiconv')) {
$PMA_recoding_engine = PMA_CHARSET_LIBICONV;
} else {
if (@function_exists('iconv')) {
$PMA_recoding_engine = PMA_CHARSET_ICONV;
} else if (@function_exists('libiconv')) {
$PMA_recoding_engine = PMA_CHARSET_LIBICONV;
} elseif (@function_exists('recode_string')) {
$PMA_recoding_engine = PMA_CHARSET_RECODE;
} else {
$PMA_recoding_engine = PMA_CHARSET_NONE;
$PMA_recoding_engine = PMA_CHARSET_NONE;
if (!isset($GLOBALS['is_header_sent'])) {
include('./header.inc.php');
}
echo $strCantUseRecodeIconv;
include('./footer.inc.php');
exit();
if (!isset($GLOBALS['is_header_sent'])) {
include('./header.inc.php');
}
echo $strCantUseRecodeIconv;
require_once('./footer.inc.php');
exit();
}
} else if ($PMA_recoding_engine == 'recode') {
if (@function_exists('recode_string')) {
$PMA_recoding_engine = PMA_CHARSET_RECODE;
} else {
$PMA_recoding_engine = PMA_CHARSET_NONE;
require_once('./header.inc.php');
echo $strCantUseRecodeIconv;
require_once('./footer.inc.php');
exit;
}
} else {
$PMA_recoding_engine = PMA_CHARSET_NONE;
}
/**
* Converts encoding according to current settings.
*
* @param mixed what to convert (string or array of strings or object returned by mysql_fetch_field)
*
* @return string converted string or array of strings
*
* @global array the configuration array
* @global boolean whether recoding is allowed or not
* @global string the current charset
* @global array the charset to convert to
*
* @access public
*
* @author nijel
*/
function PMA_convert_display_charset($what) {
global $cfg, $allow_recoding, $charset, $convcharset;
if (!(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
return $what;
}
else if (is_array($what)) {
$result = array();
foreach($what AS $key => $val) {
if (is_string($val) || is_array($val)) {
if (is_string($key)) {
$result[PMA_convert_display_charset($key)] = PMA_convert_display_charset($val);
} else {
$result[$key] = PMA_convert_display_charset($val);
}
} else {
$result[$key] = $val;
}
} // end while
return $result;
}
else if (is_string($what)) {
switch ($GLOBALS['PMA_recoding_engine']) {
case PMA_CHARSET_RECODE:
return recode_string($convcharset . '..' . $charset, $what);
break;
case PMA_CHARSET_ICONV:
return iconv($convcharset, $charset . $cfg['IconvExtraParams'], $what);
break;
case PMA_CHARSET_LIBICONV:
return libiconv($convcharset, $charset, $what);
break;
default:
return $what;
}
}
else if (is_object($what)) {
// isn't it object returned from mysql_fetch_field ?
if (@is_string($what->name)) {
$what->name = PMA_convert_display_charset($what->name);
}
if (@is_string($what->table)) {
$what->table = PMA_convert_display_charset($what->table);
}
if (@is_string($what->Database)) {
$what->Database = PMA_convert_display_charset($what->Database);
}
return $what;
}
else {
// when we don't know what it is we don't touch it...
return $what;
}
} // end of the "PMA_convert_display_charset()" function
/**
* Converts encoding of text according to current settings.
*
* @param string what to convert
*
* @return string converted text
*
* @global array the configuration array
* @global boolean whether recoding is allowed or not
* @global string the current charset
* @global array the charset to convert to
*
* @access public
*
* @author nijel
*/
function PMA_convert_charset($what) {
global $cfg, $allow_recoding, $charset, $convcharset;
if (!(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
return $what;
if (@function_exists('iconv')) {
$PMA_recoding_engine = PMA_CHARSET_ICONV;
} else if (@function_exists('libiconv')) {
$PMA_recoding_engine = PMA_CHARSET_LIBICONV;
} elseif (@function_exists('recode_string')) {
$PMA_recoding_engine = PMA_CHARSET_RECODE;
} else {
switch ($GLOBALS['PMA_recoding_engine']) {
case PMA_CHARSET_RECODE:
return recode_string($charset . '..' . $convcharset, $what);
break;
case PMA_CHARSET_ICONV:
return iconv($charset, $convcharset . $cfg['IconvExtraParams'], $what);
break;
case PMA_CHARSET_LIBICONV:
return libiconv($charset, $convcharset, $what);
break;
default:
return $what;
}
}
} // end of the "PMA_convert_charset()" function
$PMA_recoding_engine = PMA_CHARSET_NONE;
/**
* Converts encoding of text according to parameters with detected
* conversion function.
*
* @param string source charset
* @param string target charset
* @param string what to convert
*
* @return string converted text
*
* @access public
*
* @author nijel
*/
function PMA_convert_string($src_charset, $dest_charset, $what) {
require_once('./header.inc.php');
echo $strCantUseRecodeIconv;
require_once('./footer.inc.php');
exit;
}
}
} else {
$PMA_recoding_engine = PMA_CHARSET_NONE;
}
/**
* Converts encoding according to current settings.
*
* @param mixed what to convert (string or array of strings or object returned by mysql_fetch_field)
*
* @return string converted string or array of strings
*
* @global array the configuration array
* @global boolean whether recoding is allowed or not
* @global string the current charset
* @global array the charset to convert to
*
* @access public
*
* @author nijel
*/
function PMA_convert_display_charset($what) {
global $cfg, $allow_recoding, $charset, $convcharset;
if (!(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
return $what;
}
else if (is_array($what)) {
$result = array();
foreach($what AS $key => $val) {
if (is_string($val) || is_array($val)) {
if (is_string($key)) {
$result[PMA_convert_display_charset($key)] = PMA_convert_display_charset($val);
} else {
$result[$key] = PMA_convert_display_charset($val);
}
} else {
$result[$key] = $val;
}
} // end while
return $result;
}
else if (is_string($what)) {
switch ($GLOBALS['PMA_recoding_engine']) {
case PMA_CHARSET_RECODE:
return recode_string($src_charset . '..' . $dest_charset, $what);
break;
return recode_string($convcharset . '..' . $charset, $what);
case PMA_CHARSET_ICONV:
return iconv($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $what);
break;
return iconv($convcharset, $charset . $cfg['IconvExtraParams'], $what);
case PMA_CHARSET_LIBICONV:
return libiconv($src_charset, $dest_charset, $what);
break;
return libiconv($convcharset, $charset, $what);
default:
return $what;
}
} // end of the "PMA_convert_string()" function
}
else if (is_object($what)) {
// isn't it object returned from mysql_fetch_field ?
if (@is_string($what->name)) {
$what->name = PMA_convert_display_charset($what->name);
}
if (@is_string($what->table)) {
$what->table = PMA_convert_display_charset($what->table);
}
if (@is_string($what->Database)) {
$what->Database = PMA_convert_display_charset($what->Database);
}
return $what;
}
else {
// when we don't know what it is we don't touch it...
return $what;
}
} // end of the "PMA_convert_display_charset()" function
/**
* Converts encoding of file according to parameters with detected
* conversion function. The old file will be unlinked and new created and
* its file name is returned.
*
* @param string source charset
* @param string target charset
* @param string file to convert
*
* @return string new temporay file
*
* @access public
*
* @author nijel
*/
function PMA_convert_file($src_charset, $dest_charset, $file) {
/**
* Converts encoding of text according to current settings.
*
* @param string what to convert
*
* @return string converted text
*
* @global array the configuration array
* @global boolean whether recoding is allowed or not
* @global string the current charset
* @global array the charset to convert to
*
* @access public
*
* @author nijel
*/
function PMA_convert_charset($what) {
global $cfg, $allow_recoding, $charset, $convcharset;
if (!(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
return $what;
} else {
switch ($GLOBALS['PMA_recoding_engine']) {
case PMA_CHARSET_RECODE:
return recode_string($charset . '..' . $convcharset, $what);
case PMA_CHARSET_ICONV:
return iconv($charset, $convcharset . $cfg['IconvExtraParams'], $what);
case PMA_CHARSET_LIBICONV:
$tmpfname = tempnam('', 'PMA_convert_file');
$fin = fopen($file, 'r');
$fout = fopen($tmpfname, 'w');
if ($GLOBALS['PMA_recoding_engine'] == PMA_CHARSET_RECODE) {
recode_file($src_charset . '..' . $dest_charset, $fin, $fout);
} else {
while (!feof($fin)) {
$line = fgets($fin, 4096);
if ($GLOBALS['PMA_recoding_engine'] == PMA_CHARSET_ICONV) {
$dist = iconv($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $line);
} else {
$dist = libiconv($src_charset, $dest_charset, $line);
}
fputs($fout, $dist);
} // end while
}
fclose($fin);
fclose($fout);
unlink($file);
return $tmpfname;
break;
return libiconv($charset, $convcharset, $what);
default:
return $file;
return $what;
}
} // end of the "PMA_convert_file()" function
}
} // end of the "PMA_convert_charset()" function
/**
* Converts encoding of text according to parameters with detected
* conversion function.
*
* @param string source charset
* @param string target charset
* @param string what to convert
*
* @return string converted text
*
* @access public
*
* @author nijel
*/
function PMA_convert_string($src_charset, $dest_charset, $what) {
switch ($GLOBALS['PMA_recoding_engine']) {
case PMA_CHARSET_RECODE:
return recode_string($src_charset . '..' . $dest_charset, $what);
case PMA_CHARSET_ICONV:
return iconv($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $what);
case PMA_CHARSET_LIBICONV:
return libiconv($src_charset, $dest_charset, $what);
default:
return $what;
}
} // end of the "PMA_convert_string()" function
/**
* Converts encoding of file according to parameters with detected
* conversion function. The old file will be unlinked and new created and
* its file name is returned.
*
* @param string source charset
* @param string target charset
* @param string file to convert
*
* @return string new temporay file
*
* @access public
*
* @author nijel
*/
function PMA_convert_file($src_charset, $dest_charset, $file) {
switch ($GLOBALS['PMA_recoding_engine']) {
case PMA_CHARSET_RECODE:
case PMA_CHARSET_ICONV:
case PMA_CHARSET_LIBICONV:
$tmpfname = tempnam('', 'PMA_convert_file');
$fin = fopen($file, 'r');
$fout = fopen($tmpfname, 'w');
if ($GLOBALS['PMA_recoding_engine'] == PMA_CHARSET_RECODE) {
recode_file($src_charset . '..' . $dest_charset, $fin, $fout);
} else {
while (!feof($fin)) {
$line = fgets($fin, 4096);
if ($GLOBALS['PMA_recoding_engine'] == PMA_CHARSET_ICONV) {
$dist = iconv($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $line);
} else {
$dist = libiconv($src_charset, $dest_charset, $line);
}
fputs($fout, $dist);
} // end while
}
fclose($fin);
fclose($fout);
unlink($file);
return $tmpfname;
default:
return $file;
}
} // end of the "PMA_convert_file()" function
} // $__PMA_CHARSET_CONVERSION_LIB__
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -8,88 +8,85 @@
* May 19, 2002
*/
if (!defined('PMA_DB_CONFIG_LIB_INCLUDED')) {
define('PMA_DB_CONFIG_LIB_INCLUDED', 1);
/**
* Converts attributes of an object to xml code
*
* Original obj2xml() function by <jgettys@gnuvox.com>
* as found on http://www.php.net/manual/en/function.get-defined-vars.php
* Fixed and improved by Robin Johnson <robbat2@users.sourceforge.net>
*
* @param object the source
* @param string identication
*
* @access public
*/
function obj2xml($v, $indent = '') {
$attr = '';
foreach($v AS $key => $val) {
if (is_string($key) && ($key == '__attr')) {
continue;
}
/**
* Converts attributes of an object to xml code
*
* Original obj2xml() function by <jgettys@gnuvox.com>
* as found on http://www.php.net/manual/en/function.get-defined-vars.php
* Fixed and improved by Robin Johnson <robbat2@users.sourceforge.net>
*
* @param object the source
* @param string identication
*
* @access public
*/
function obj2xml($v, $indent = '') {
$attr = '';
foreach($v AS $key => $val) {
if (is_string($key) && ($key == '__attr')) {
continue;
// Check for __attr
if (is_object($val->__attr)) {
foreach($val->__attr AS $key2 => $val2) {
$attr .= " $key2=\"$val2\"";
}
} else {
$attr = '';
}
// Check for __attr
if (is_object($val->__attr)) {
foreach($val->__attr AS $key2 => $val2) {
$attr .= " $key2=\"$val2\"";
}
// Preserve data type information
$attr .= ' type="' . gettype($val) . '"';
if (is_array($val) || is_object($val)) {
echo "$indent<$key$attr>\n";
obj2xml($val, $indent . ' ');
echo "$indent</$key>\n";
} else {
if (is_string($val) && ($val == '')) {
echo "$indent<$key$attr />\n";
} else {
$attr = '';
echo "$indent<$key$attr>$val</$key>\n";
}
// Preserve data type information
$attr .= ' type="' . gettype($val) . '"';
if (is_array($val) || is_object($val)) {
echo "$indent<$key$attr>\n";
obj2xml($val, $indent . ' ');
echo "$indent</$key>\n";
} else {
if (is_string($val) && ($val == '')) {
echo "$indent<$key$attr />\n";
} else {
echo "$indent<$key$attr>$val</$key>\n";
}
}
} // end while
} // end of the "obj2xml()" function
}
} // end while
} // end of the "obj2xml()" function
$cfg['DBConfig']['AllowUserOverride'] = array(
'Servers/*/bookmarkdb',
'Servers/*/bookmarktable',
'Servers/*/relation',
'Servers/*/pdf_table_position',
'ShowSQL',
'Confirm',
'LeftFrameLight',
'ShowTooltip',
'ShowBlob',
'NavigationBarIconic',
'ShowAll',
'MaxRows',
'Order',
'ProtectBinary',
'ShowFunctionFields',
'LeftWidth',
'LeftBgColor',
'LeftPointerColor',
'RightBgColor',
'Border',
'ThBgcolor',
'BgcolorOne',
'BgcolorTwo',
'BrowsePointerColor',
'BrowseMarkerColor',
'TextareaCols',
'TextareaRows',
'LimitChars',
'ModifyDeleteAtLeft',
'ModifyDeleteAtRight',
'DefaultDisplay',
'RepeatCells'
);
$cfg['DBConfig']['AllowUserOverride'] = array(
'Servers/*/bookmarkdb',
'Servers/*/bookmarktable',
'Servers/*/relation',
'Servers/*/pdf_table_position',
'ShowSQL',
'Confirm',
'LeftFrameLight',
'ShowTooltip',
'ShowBlob',
'NavigationBarIconic',
'ShowAll',
'MaxRows',
'Order',
'ProtectBinary',
'ShowFunctionFields',
'LeftWidth',
'LeftBgColor',
'LeftPointerColor',
'RightBgColor',
'Border',
'ThBgcolor',
'BgcolorOne',
'BgcolorTwo',
'BrowsePointerColor',
'BrowseMarkerColor',
'TextareaCols',
'TextareaRows',
'LimitChars',
'ModifyDeleteAtLeft',
'ModifyDeleteAtRight',
'DefaultDisplay',
'RepeatCells'
);
} // $__PMA_DB_CONFIG_LIB__
?>

View File

@@ -16,7 +16,7 @@ if (!isset($is_db) || !$is_db) {
if (!isset($is_transformation_wrapper)) {
header('Location: ' . $cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
}
exit();
exit;
}
} // end if (ensures db exists)
if (!isset($is_table) || !$is_table) {
@@ -29,7 +29,7 @@ if (!isset($is_table) || !$is_table) {
if (!isset($is_transformation_wrapper)) {
header('Location: ' . $cfg['PmaAbsoluteUri'] . 'db_details.php?' . PMA_generate_common_url($db, '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
}
exit();
exit;
} else if (isset($is_table)) {
mysql_free_result($is_table);
}

View File

@@ -2,87 +2,83 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
if (!defined('PMA_DBG_PROFILING_INCLUDED')) {
define('PMA_DBG_PROFILING_INCLUDED', 1);
if (isset($GLOBALS['DBG']) && $GLOBALS['DBG']
&& isset($GLOBALS['cfg']['DBG']['profile']['enable'])
&& $GLOBALS['cfg']['DBG']['profile']['enable']) {
if (isset($GLOBALS['DBG']) && $GLOBALS['DBG']
&& isset($GLOBALS['cfg']['DBG']['profile']['enable'])
&& $GLOBALS['cfg']['DBG']['profile']['enable']) {
/**
* Displays profiling results when called
* WARNING: this function is SLOW
/**
* Displays profiling results when called
* WARNING: this function is SLOW
*/
function dbg_dump_profiling_results() {
/* Applies to the original 'dbg_dump_profiling_results' function,
* sourced from http://dd.cron.ru/dbg/download.php?h=prof_sample2
* Copyright (c) 2002. Dmitri Dmitrienko
* LICENCE: This source file is subject to Mozilla Public License (MPL)
* AUTHOR: Dmitri Dmitrienko <dd@cron.ru>
*/
function dbg_dump_profiling_results() {
/* Applies to the original 'dbg_dump_profiling_results' function,
* sourced from http://dd.cron.ru/dbg/download.php?h=prof_sample2
* Copyright (c) 2002. Dmitri Dmitrienko
* LICENCE: This source file is subject to Mozilla Public License (MPL)
* AUTHOR: Dmitri Dmitrienko <dd@cron.ru>
*/
dbg_get_profiler_results(&$dbg_prof_results);
dbg_get_profiler_results(&$dbg_prof_results);
echo '<br><table width="1000" cellspacing="0" cellpadding="2" style="font:8pt courier">' . "\n" .
'<thead>' . "\n" .
'<tr style="background:#808080; color:#FFFFFF">' . "\n" .
'<td>' . $GLOBALS['strDBGModule'] . '</td>' . "\n" .
'<td>' . $GLOBALS['strDBGLine'] . '</td>' . "\n" .
'<td>' . $GLOBALS['strDBGHits'] . '</td>' . "\n" .
'<td>' . $GLOBALS['strDBGTimePerHitMs'] . '</td>' . "\n" .
'<td>' . $GLOBALS['strDBGTotalTimeMs'] . '</td>' . "\n" .
'<td>' . $GLOBALS['strDBGMinTimeMs'] . '</td>' . "\n" .
'<td>' . $GLOBALS['strDBGMaxTimeMs'] . '</td>' . "\n" .
'<td>' . $GLOBALS['strDBGContextID'] . '</td>' . "\n" .
'<td>' . $GLOBALS['strDBGContext'] . '</td>' . "\n" .
'</tr></thead>' . "\n" .
'<tbody style="vertical-align: top">' . "\n";
foreach($dbg_prof_results['line_no'] AS $idx => $line_no) {
$mod_no = $dbg_prof_results['mod_no'][$idx];
dbg_get_module_name($mod_no, &$mod_name);
echo '<br><table width="1000" cellspacing="0" cellpadding="2" style="font:8pt courier">' . "\n" .
'<thead>' . "\n" .
'<tr style="background:#808080; color:#FFFFFF">' . "\n" .
'<td>' . $GLOBALS['strDBGModule'] . '</td>' . "\n" .
'<td>' . $GLOBALS['strDBGLine'] . '</td>' . "\n" .
'<td>' . $GLOBALS['strDBGHits'] . '</td>' . "\n" .
'<td>' . $GLOBALS['strDBGTimePerHitMs'] . '</td>' . "\n" .
'<td>' . $GLOBALS['strDBGTotalTimeMs'] . '</td>' . "\n" .
'<td>' . $GLOBALS['strDBGMinTimeMs'] . '</td>' . "\n" .
'<td>' . $GLOBALS['strDBGMaxTimeMs'] . '</td>' . "\n" .
'<td>' . $GLOBALS['strDBGContextID'] . '</td>' . "\n" .
'<td>' . $GLOBALS['strDBGContext'] . '</td>' . "\n" .
'</tr></thead>' . "\n" .
'<tbody style="vertical-align: top">' . "\n";
foreach($dbg_prof_results['line_no'] AS $idx => $line_no) {
$mod_no = $dbg_prof_results['mod_no'][$idx];
dbg_get_module_name($mod_no, &$mod_name);
//if (strpos("!".$mod_name, 'dbg.php') > 0) continue;
//if (strpos("!".$mod_name, 'dbg.php') > 0) continue;
$hit_cnt = $dbg_prof_results['hit_count'][$idx];
$hit_cnt = $dbg_prof_results['hit_count'][$idx];
$time_sum = $dbg_prof_results['tm_sum'][$idx] * 1000;
$time_avg_hit = $time_sum / $hit_cnt;
$time_min = $dbg_prof_results['tm_min'][$idx] * 1000;
$time_max = $dbg_prof_results['tm_max'][$idx] * 1000;
$time_sum = $dbg_prof_results['tm_sum'][$idx] * 1000;
$time_avg_hit = $time_sum / $hit_cnt;
$time_min = $dbg_prof_results['tm_min'][$idx] * 1000;
$time_max = $dbg_prof_results['tm_max'][$idx] * 1000;
$time_sum = sprintf('%.3f', $time_sum);
$time_avg_hit = sprintf('%.3f', $time_avg_hit);
$time_min = sprintf('%.3f', $time_min);
$time_max = sprintf('%.3f', $time_max);
$time_sum = sprintf('%.3f', $time_sum);
$time_avg_hit = sprintf('%.3f', $time_avg_hit);
$time_min = sprintf('%.3f', $time_min);
$time_max = sprintf('%.3f', $time_max);
dbg_get_source_context($mod_no, $line_no, &$ctx_id);
dbg_get_source_context($mod_no, $line_no, &$ctx_id);
//use a default context name if needed
if (dbg_get_context_name($ctx_id, &$ctx_name)
&& strcmp($ctx_name,'') == 0) {
$ctx_name = "::main";
}
$bk = "#ffffff";
if (($idx & 1) == 0)
$bk = "#e0e0e0";
if($time_avg_hit > $GLOBALS['cfg']['DBG']['profile']['threshold'] ) {
echo '<tr style="background:' . $bk . '">' .
'<td>' . $mod_name . '</td>' .
'<td>' . $line_no . '</td>' .
'<td>' . $hit_cnt . '</td>' .
'<td>' . $time_avg_hit . '</td>' .
'<td>' . $time_sum . '</td>' .
'<td>' . $time_min . '</td>' .
'<td>' . $time_max . '</td>' .
'<td>' . $ctx_id . '</td>' .
'<td>' . $ctx_name . '</td>' .
'</tr>' . "\n";
}
//use a default context name if needed
if (dbg_get_context_name($ctx_id, &$ctx_name)
&& strcmp($ctx_name,'') == 0) {
$ctx_name = "::main";
}
$bk = "#ffffff";
if (($idx & 1) == 0)
$bk = "#e0e0e0";
if($time_avg_hit > $GLOBALS['cfg']['DBG']['profile']['threshold'] ) {
echo '<tr style="background:' . $bk . '">' .
'<td>' . $mod_name . '</td>' .
'<td>' . $line_no . '</td>' .
'<td>' . $hit_cnt . '</td>' .
'<td>' . $time_avg_hit . '</td>' .
'<td>' . $time_sum . '</td>' .
'<td>' . $time_min . '</td>' .
'<td>' . $time_max . '</td>' .
'<td>' . $ctx_id . '</td>' .
'<td>' . $ctx_name . '</td>' .
'</tr>' . "\n";
}
echo "</tbody></table>";
}
echo "</tbody></table>";
}
}

View File

@@ -2,23 +2,19 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
if (!defined('PMA_DBG_SETUP_INCLUDED')) {
define('PMA_DBG_SETUP_INCLUDED', 1);
if (isset($GLOBALS['cfg']['DBG']['enable']) && $GLOBALS['cfg']['DBG']['enable']) {
/**
* Loads the DBG extension if needed
*/
if (!@extension_loaded('dbg')) {
PMA_dl('dbg');
}
if (!@extension_loaded('dbg')) {
echo sprintf($strCantLoad, 'DBG') . '<br />' . "\n"
. '<a href="./Documentation.html#faqdbg" target="documentation">' . $GLOBALS['strDocu'] . '</a>' . "\n";
exit();
}
$GLOBALS['DBG'] = true;
if (isset($GLOBALS['cfg']['DBG']['enable']) && $GLOBALS['cfg']['DBG']['enable']) {
/**
* Loads the DBG extension if needed
*/
if (!@extension_loaded('dbg')) {
PMA_dl('dbg');
}
if (!@extension_loaded('dbg')) {
echo sprintf($strCantLoad, 'DBG') . '<br />' . "\n"
. '<a href="./Documentation.html#faqdbg" target="documentation">' . $GLOBALS['strDocu'] . '</a>' . "\n";
require_once('./footer.inc.php');
}
$GLOBALS['DBG'] = true;
}
?>

View File

@@ -5,54 +5,137 @@
/**
* DEFINES VARIABLES & CONSTANTS
* Overview:
* PMA_MYSQL_INT_VERSION (int) - eg: 32339 instead of 3.23.39
* PMA_VERSION (string) - phpMyAdmin version string
* PMA_PHP_INT_VERSION (int) - eg: 30017 instead of 3.0.17 or
* 40006 instead of 4.0.6RC3
* PMA_MYSQL_CLIENT_API (int) - the version number of the MySQL client
* API which php is built against.
* PMA_IS_WINDOWS (bool) - mark if phpMyAdmin running on windows
* server
* PMA_IS_GD2 (bool) - true is GD2 is present
* PMA_USR_OS (string) - the plateform (os) of the user
* PMA_USR_BROWSER_AGENT (string) - the browser of the user
* PMA_USR_BROWSER_VER (double) - the version of this browser
*/
// MySQL Version
if (!defined('PMA_MYSQL_INT_VERSION') && isset($userlink)) {
if (!empty($server)) {
$result = PMA_mysql_query('SELECT VERSION() AS version');
if ($result != FALSE && @mysql_num_rows($result) > 0) {
$row = PMA_mysql_fetch_array($result);
$match = explode('.', $row['version']);
} else {
$result = @PMA_mysql_query('SHOW VARIABLES LIKE \'version\'');
if ($result != FALSE && @mysql_num_rows($result) > 0){
$row = PMA_mysql_fetch_row($result);
$match = explode('.', $row[1]);
}
}
} // end server id is defined case
if (!isset($match) || !isset($match[0])) {
$match[0] = 3;
}
if (!isset($match[1])) {
$match[1] = 21;
}
if (!isset($match[2])) {
$match[2] = 0;
}
if(!isset($row)) {
$row['version'] = '3.21.0';
}
define('PMA_MYSQL_INT_VERSION', (int)sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2])));
define('PMA_MYSQL_STR_VERSION', $row['version']);
unset($match);
// phpMyAdmin release
if (!defined('PMA_VERSION')) {
define('PMA_VERSION', '2.5.5-dev');
}
// 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)) {
$result = preg_match('@([0-9]{1,2}).([0-9]{1,2})@', phpversion(), $match);
}
if (isset($match) && !empty($match[1])) {
if (!isset($match[2])) {
$match[2] = 0;
}
if (!isset($match[3])) {
$match[3] = 0;
}
define('PMA_PHP_INT_VERSION', (int)sprintf('%d%02d%02d', $match[1], $match[2], $match[3]));
unset($match);
} else {
define('PMA_PHP_INT_VERSION', 0);
}
define('PMA_PHP_STR_VERSION', phpversion());
}
// MySQL client API
if (!defined('PMA_MYSQL_CLIENT_API')) {
$client_api = explode('.', mysql_get_client_info());
define('PMA_MYSQL_CLIENT_API', (int)sprintf('%d%02d%02d', $client_api[0], $client_api[1], intval($client_api[2])));
unset($client_api);
}
// Whether the os php is running on is windows or not
if (!defined('PMA_IS_WINDOWS')) {
if (defined('PHP_OS') && stristr(PHP_OS, 'win')) {
define('PMA_IS_WINDOWS', 1);
} else {
define('PMA_IS_WINDOWS', 0);
}
}
function PMA_dl($module) {
if (!isset($GLOBALS['PMA_dl_allowed'])) {
if (!@ini_get('safe_mode') && @ini_get('enable_dl') && @function_exists('dl')) {
ob_start();
phpinfo(INFO_GENERAL); /* Only general info */
$a = strip_tags(ob_get_contents());
ob_end_clean();
/* Get GD version string from phpinfo output */
if (preg_match('@Thread Safety[[:space:]]*enabled@', $a)) {
if (preg_match('@Server API[[:space:]]*\(CGI\|CLI\)@', $a)) {
$GLOBALS['PMA_dl_allowed'] = TRUE;
} else {
$GLOBALS['PMA_dl_allowed'] = FALSE;
}
} else {
$GLOBALS['PMA_dl_allowed'] = TRUE;
}
} else {
$GLOBALS['PMA_dl_allowed'] = FALSE;
}
}
if (PMA_IS_WINDOWS) {
$suffix = '.dll';
} else {
$suffix = '.so';
}
if ($GLOBALS['PMA_dl_allowed']) {
return @dl($module . $suffix);
} else {
return FALSE;
}
}
// Whether GD2 is present
if (!defined('PMA_IS_GD2')) {
if ($cfg['GD2Available'] == 'yes') {
define('PMA_IS_GD2', 1);
} elseif ($cfg['GD2Available'] == 'no') {
define('PMA_IS_GD2', 0);
} else {
if (!@extension_loaded('gd')) {
PMA_dl('gd');
}
if (!@function_exists('imagecreatetruecolor')) {
define('PMA_IS_GD2', 0);
} else {
if (@function_exists('gd_info')) {
$gd_nfo = gd_info();
if (strstr($gd_nfo["GD Version"], '2.')) {
define('PMA_IS_GD2', 1);
} else {
define('PMA_IS_GD2', 0);
}
} else {
/* We must do hard way... */
ob_start();
phpinfo(INFO_MODULES); /* Only modules */
$a = strip_tags(ob_get_contents());
ob_end_clean();
/* Get GD version string from phpinfo output */
if (preg_match('@GD Version[[:space:]]*\(.*\)@', $a, $v)) {
if (strstr($v, '2.')) {
define('PMA_IS_GD2', 1);
} else {
define('PMA_IS_GD2', 0);
}
} else {
define('PMA_IS_GD2', 0);
}
}
}
}
}
// Determines platform (OS), browser and version of the user
// Based on a phpBuilder article:
// see http://www.phpbuilder.net/columns/tim20000821.php
if (!defined('PMA_USR_OS')) {
// loic1 - 2001/25/11: use the new globals arrays defined with
// php 4.1+
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
$HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
} else if (!isset($HTTP_USER_AGENT)) {
@@ -103,5 +186,6 @@ if (!defined('PMA_USR_OS')) {
define('PMA_USR_BROWSER_VER', 0);
define('PMA_USR_BROWSER_AGENT', 'OTHER');
}
} // $__PMA_DEFINES_LIB__
}
?>

View File

@@ -0,0 +1,40 @@
<?php
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* DEFINES MYSQL RELATED VARIABLES & CONSTANTS
* Overview:
* PMA_MYSQL_INT_VERSION (int) - eg: 32339 instead of 3.23.39
*/
if (!defined('PMA_MYSQL_INT_VERSION') && isset($userlink)) {
if (!empty($server)) {
$result = PMA_mysql_query('SELECT VERSION() AS version', $userlink);
if ($result != FALSE && @mysql_num_rows($result) > 0) {
$row = PMA_mysql_fetch_array($result);
$match = explode('.', $row['version']);
mysql_free_result($result);
}
} // end server id is defined case
if (!isset($match) || !isset($match[0])) {
$match[0] = 3;
}
if (!isset($match[1])) {
$match[1] = 23;
}
if (!isset($match[2])) {
$match[2] = 32;
}
if(!isset($row)) {
$row['version'] = '3.23.32';
}
define('PMA_MYSQL_INT_VERSION', (int)sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2])));
define('PMA_MYSQL_STR_VERSION', $row['version']);
unset($result, $row, $match);
}
?>

View File

@@ -1,132 +0,0 @@
<?php
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* DEFINES VARIABLES & CONSTANTS
* Overview:
* PMA_VERSION (string) - phpMyAdmin version string
* PMA_PHP_INT_VERSION (int) - eg: 30017 instead of 3.0.17 or
* 40006 instead of 4.0.6RC3
* PMA_MYSQL_CLIENT_API (int) - the version number of the MySQL client
* API which php is built against.
* PMA_IS_WINDOWS (bool) - mark if phpMyAdmin running on windows
* server
* PMA_IS_GD2 (bool) - true is GD2 is present
*/
// phpMyAdmin release
if (!defined('PMA_VERSION')) {
define('PMA_VERSION', '2.5.5-dev');
}
// 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)) {
$result = preg_match('@([0-9]{1,2}).([0-9]{1,2})@', phpversion(), $match);
}
if (isset($match) && !empty($match[1])) {
if (!isset($match[2])) {
$match[2] = 0;
}
if (!isset($match[3])) {
$match[3] = 0;
}
define('PMA_PHP_INT_VERSION', (int)sprintf('%d%02d%02d', $match[1], $match[2], $match[3]));
unset($match);
} else {
define('PMA_PHP_INT_VERSION', 0);
}
define('PMA_PHP_STR_VERSION', phpversion());
}
// MySQL client API
if (!defined('PMA_MYSQL_CLIENT_API')) {
$client_api = explode('.', mysql_get_client_info());
define('PMA_MYSQL_CLIENT_API', (int)sprintf('%d%02d%02d', $client_api[0], $client_api[1], intval($client_api[2])));
unset($client_api);
}
// Whether the os php is running on is windows or not
if (!defined('PMA_IS_WINDOWS')) {
if (defined('PHP_OS') && stristr(PHP_OS, 'win')) {
define('PMA_IS_WINDOWS', 1);
} else {
define('PMA_IS_WINDOWS', 0);
}
}
function PMA_dl($module) {
if (!isset($GLOBALS['PMA_dl_allowed'])) {
if (!@ini_get('safe_mode') && @ini_get('enable_dl') && @function_exists('dl')) {
ob_start();
phpinfo(INFO_GENERAL); /* Only general info */
$a = strip_tags(ob_get_contents());
ob_end_clean();
/* Get GD version string from phpinfo output */
if (preg_match('@Thread Safety[[:space:]]*enabled@', $a)) {
if (preg_match('@Server API[[:space:]]*\(CGI\|CLI\)@', $a)) {
$GLOBALS['PMA_dl_allowed'] = TRUE;
} else {
$GLOBALS['PMA_dl_allowed'] = FALSE;
}
} else {
$GLOBALS['PMA_dl_allowed'] = TRUE;
}
} else {
$GLOBALS['PMA_dl_allowed'] = FALSE;
}
}
if (PMA_IS_WINDOWS) {
$suffix = '.dll';
} else {
$suffix = '.so';
}
if ($GLOBALS['PMA_dl_allowed']) {
return @dl($module . $suffix);
} else {
return FALSE;
}
}
// Whether GD2 is present
if (!defined('PMA_IS_GD2')) {
if ($cfg['GD2Available'] == 'yes') {
define('PMA_IS_GD2', 1);
} elseif ($cfg['GD2Available'] == 'no') {
define('PMA_IS_GD2', 0);
} else {
if (!@extension_loaded('gd')) {
PMA_dl('gd');
}
if (!@function_exists('imagecreatetruecolor')) {
define('PMA_IS_GD2', 0);
} else {
if (@function_exists('gd_info')) {
$gd_nfo = gd_info();
if (strstr($gd_nfo["GD Version"], '2.')) {
define('PMA_IS_GD2', 1);
} else {
define('PMA_IS_GD2', 0);
}
} else {
/* We must do hard way... */
ob_start();
phpinfo(INFO_MODULES); /* Only modules */
$a = strip_tags(ob_get_contents());
ob_end_clean();
/* Get GD version string from phpinfo output */
if (preg_match('@GD Version[[:space:]]*\(.*\)@', $a, $v)) {
if (strstr($v, '2.')) {
define('PMA_IS_GD2', 1);
} else {
define('PMA_IS_GD2', 0);
}
} else {
define('PMA_IS_GD2', 0);
}
}
}
}
}
// $__PMA_DEFINES_PHP_LIB__
?>

View File

@@ -3,7 +3,7 @@
// vim: expandtab sw=4 ts=4 sts=4:
// Get relations & co. status
require('./libraries/relation.lib.php');
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
function PMA_exportCheckboxCheck($str) {

File diff suppressed because it is too large Load Diff

View File

@@ -2,20 +2,20 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
if (!empty($del_url)) {
echo ' <td align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n";
echo ' <input type="checkbox" name="rows_to_delete[]" value="' . $del_query . '" />' . "\n";
echo ' </td>' . "\n";
}
if (!empty($edit_url)) {
echo ' <td align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n";
echo PMA_linkOrButton($edit_url, $edit_str, '');
echo $bookmark_go;
echo ' </td>' . "\n";
}
if (!empty($del_url)) {
echo ' <td align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n";
echo PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''));
echo ' </td>' . "\n";
}
if (!empty($del_url)) {
echo ' <td align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n"
. ' <input type="checkbox" name="rows_to_delete[]" value="' . $del_query . '" />' . "\n"
. ' </td>' . "\n";
}
if (!empty($edit_url)) {
echo ' <td align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n"
. PMA_linkOrButton($edit_url, $edit_str, '')
. $bookmark_go
. ' </td>' . "\n";
}
if (!empty($del_url)) {
echo ' <td align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n"
. PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''))
. ' </td>' . "\n";
}
?>

View File

@@ -8,44 +8,40 @@
* Thanks to <markus@noga.de>
*/
// lem9
//if (!defined('PMA_GET_FOREIGN_LIB_INCLUDED')) {
// define('PMA_GET_FOREIGN_LIB_INCLUDED', 1);
// lem9: we always show the foreign field in the drop-down; if a display
// field is defined, we show it besides the foreign field
$foreign_link = false;
if ($foreigners && isset($foreigners[$field])) {
$foreigner = $foreigners[$field];
$foreign_db = $foreigner['foreign_db'];
$foreign_table = $foreigner['foreign_table'];
$foreign_field = $foreigner['foreign_field'];
// lem9: we always show the foreign field in the drop-down; if a display
// field is defined, we show it besides the foreign field
$foreign_link = false;
if ($foreigners && isset($foreigners[$field])) {
$foreigner = $foreigners[$field];
$foreign_db = $foreigner['foreign_db'];
$foreign_table = $foreigner['foreign_table'];
$foreign_field = $foreigner['foreign_field'];
// Count number of rows in the foreign table. Currently we do
// not use a drop-down if more than 200 rows in the foreign table,
// for speed reasons and because we need a better interface for this.
//
// We could also do the SELECT anyway, with a LIMIT, and ensure that
// the current value of the field is one of the choices.
// Count number of rows in the foreign table. Currently we do
// not use a drop-down if more than 200 rows in the foreign table,
// for speed reasons and because we need a better interface for this.
//
// We could also do the SELECT anyway, with a LIMIT, and ensure that
// the current value of the field is one of the choices.
$the_total = PMA_countRecords($foreign_db, $foreign_table, TRUE);
$the_total = PMA_countRecords($foreign_db, $foreign_table, TRUE);
if ((isset($override_total) && $override_total == true) || $the_total < 200) {
// foreign_display can be FALSE if no display field defined:
if ((isset($override_total) && $override_total == true) || $the_total < 200) {
// foreign_display can be FALSE if no display field defined:
$foreign_display = PMA_getDisplayField($foreign_db, $foreign_table);
$dispsql = 'SELECT ' . PMA_backquote($foreign_field)
. (($foreign_display == FALSE) ? '' : ', ' . PMA_backquote($foreign_display))
. ' FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table)
. (($foreign_display == FALSE) ? '' :' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display))
. (isset($foreign_limit) ? $foreign_limit : '');
$disp = PMA_mysql_query($dispsql);
}
else {
unset($disp);
$foreign_link = true;
}
} // end if $foreigners
$foreign_display = PMA_getDisplayField($foreign_db, $foreign_table);
$dispsql = 'SELECT ' . PMA_backquote($foreign_field)
. (($foreign_display == FALSE) ? '' : ', ' . PMA_backquote($foreign_display))
. ' FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table)
. (($foreign_display == FALSE) ? '' :' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display))
. (isset($foreign_limit) ? $foreign_limit : '');
$disp = PMA_mysql_query($dispsql);
}
else {
unset($disp);
$foreign_link = true;
}
} // end if $foreigners
//} // $__PMA_GET_FOREIGN_LIB_INCLUDED__
?>

View File

@@ -5,66 +5,64 @@
/**
* This library grabs the names and values of the variables sent or posted to a
* script in the '$HTTP_*_VARS' / $_* arrays and sets simple globals variables
* from them. It does the same work for the $PHP_SELF variable.
* script in the $_* arrays and sets simple globals variables from them. It does
* the same work for the $PHP_SELF, $HTTP_ACCEPT_LANGUAGE and
* $HTTP_AUTHORIZATION variables.
*
* loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
*/
if (!defined('PMA_GRAB_GLOBALS_INCLUDED')) {
define('PMA_GRAB_GLOBALS_INCLUDED', 1);
function PMA_gpc_extract($array, &$target) {
if (!is_array($array)) {
return FALSE;
}
$is_magic_quotes = get_magic_quotes_gpc();
foreach($array AS $key => $value) {
if (is_array($value)) {
// there could be a variable coming from a cookie of
// another application, with the same name as this array
unset($target[$key]);
PMA_gpc_extract($value, $target[$key]);
} else if ($is_magic_quotes) {
$target[$key] = stripslashes($value);
} else {
$target[$key] = $value;
}
}
return TRUE;
function PMA_gpc_extract($array, &$target) {
if (!is_array($array)) {
return FALSE;
}
$is_magic_quotes = get_magic_quotes_gpc();
foreach($array AS $key => $value) {
if (is_array($value)) {
// there could be a variable coming from a cookie of
// another application, with the same name as this array
unset($target[$key]);
if (!empty($_GET)) {
PMA_gpc_extract($_GET, $GLOBALS);
} // end if
if (!empty($_POST)) {
PMA_gpc_extract($_POST, $GLOBALS);
} // end if
if (!empty($_FILES)) {
foreach($_FILES AS $name => $value) {
$$name = $value['tmp_name'];
${$name . '_name'} = $value['name'];
PMA_gpc_extract($value, $target[$key]);
} else if ($is_magic_quotes) {
$target[$key] = stripslashes($value);
} else {
$target[$key] = $value;
}
} // end if
}
return TRUE;
}
if (!empty($_SERVER)) {
if (isset($_SERVER['PHP_SELF'])) {
$PHP_SELF = $_SERVER['PHP_SELF'];
}
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$HTTP_ACCEPT_LANGUAGE = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
}
if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
$HTTP_AUTHORIZATION = $_SERVER['HTTP_AUTHORIZATION'];
}
} // end if
if (!empty($_GET)) {
PMA_gpc_extract($_GET, $GLOBALS);
} // end if
// Security fix: disallow accessing serious server files via "?goto="
if (isset($goto) && strpos(' ' . $goto, '/') > 0 && substr($goto, 0, 2) != './') {
unset($goto);
} // end if
if (!empty($_POST)) {
PMA_gpc_extract($_POST, $GLOBALS);
} // end if
if (!empty($_FILES)) {
foreach($_FILES AS $name => $value) {
$$name = $value['tmp_name'];
${$name . '_name'} = $value['name'];
}
} // end if
if (!empty($_SERVER)) {
$server_vars = array('PHP_SELF', 'HTTP_ACCEPT_LANGUAGE', 'HTTP_AUTHORIZATION');
foreach ($server_vars as $current) {
if (isset($_SERVER[$current])) {
$$current = $_SERVER[$current];
} elseif (!isset($$current)) {
$$current = '';
}
}
unset($server_vars, $current);
} // end if
// Security fix: disallow accessing serious server files via "?goto="
if (isset($goto) && strpos(' ' . $goto, '/') > 0 && substr($goto, 0, 2) != './') {
unset($goto);
} // end if
} // $__PMA_GRAB_GLOBALS_LIB__
?>

View File

@@ -8,291 +8,287 @@
*/
if (!defined('PMA_ALLOW_DENY_LIB_INCLUDED')) {
define('PMA_ALLOW_DENY_LIB_INCLUDED', 1);
/**
* Gets the "true" IP address of the current user
*
* @return string the ip of the user
*
* @access private
*/
function PMA_getIp()
{
global $REMOTE_ADDR;
global $HTTP_X_FORWARDED_FOR, $HTTP_X_FORWARDED, $HTTP_FORWARDED_FOR, $HTTP_FORWARDED;
global $HTTP_VIA, $HTTP_X_COMING_FROM, $HTTP_COMING_FROM;
/**
* Gets the "true" IP address of the current user
*
* @return string the ip of the user
*
* @access private
*/
function PMA_getIp()
{
global $REMOTE_ADDR;
global $HTTP_X_FORWARDED_FOR, $HTTP_X_FORWARDED, $HTTP_FORWARDED_FOR, $HTTP_FORWARDED;
global $HTTP_VIA, $HTTP_X_COMING_FROM, $HTTP_COMING_FROM;
// Get some server/environment variables values
if (empty($REMOTE_ADDR)) {
if (!empty($_SERVER) && isset($_SERVER['REMOTE_ADDR'])) {
$REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
}
else if (!empty($_ENV) && isset($_ENV['REMOTE_ADDR'])) {
$REMOTE_ADDR = $_ENV['REMOTE_ADDR'];
}
else if (@getenv('REMOTE_ADDR')) {
$REMOTE_ADDR = getenv('REMOTE_ADDR');
}
} // end if
if (empty($HTTP_X_FORWARDED_FOR)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$HTTP_X_FORWARDED_FOR = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_X_FORWARDED_FOR'])) {
$HTTP_X_FORWARDED_FOR = $_ENV['HTTP_X_FORWARDED_FOR'];
}
else if (@getenv('HTTP_X_FORWARDED_FOR')) {
$HTTP_X_FORWARDED_FOR = getenv('HTTP_X_FORWARDED_FOR');
}
} // end if
if (empty($HTTP_X_FORWARDED)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_X_FORWARDED'])) {
$HTTP_X_FORWARDED = $_SERVER['HTTP_X_FORWARDED'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_X_FORWARDED'])) {
$HTTP_X_FORWARDED = $_ENV['HTTP_X_FORWARDED'];
}
else if (@getenv('HTTP_X_FORWARDED')) {
$HTTP_X_FORWARDED = getenv('HTTP_X_FORWARDED');
}
} // end if
if (empty($HTTP_FORWARDED_FOR)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_FORWARDED_FOR'])) {
$HTTP_FORWARDED_FOR = $_SERVER['HTTP_FORWARDED_FOR'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_FORWARDED_FOR'])) {
$HTTP_FORWARDED_FOR = $_ENV['HTTP_FORWARDED_FOR'];
}
else if (@getenv('HTTP_FORWARDED_FOR')) {
$HTTP_FORWARDED_FOR = getenv('HTTP_FORWARDED_FOR');
}
} // end if
if (empty($HTTP_FORWARDED)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_FORWARDED'])) {
$HTTP_FORWARDED = $_SERVER['HTTP_FORWARDED'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_FORWARDED'])) {
$HTTP_FORWARDED = $_ENV['HTTP_FORWARDED'];
}
else if (@getenv('HTTP_FORWARDED')) {
$HTTP_FORWARDED = getenv('HTTP_FORWARDED');
}
} // end if
if (empty($HTTP_VIA)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_VIA'])) {
$HTTP_VIA = $_SERVER['HTTP_VIA'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_VIA'])) {
$HTTP_VIA = $_ENV['HTTP_VIA'];
}
else if (@getenv('HTTP_VIA')) {
$HTTP_VIA = getenv('HTTP_VIA');
}
} // end if
if (empty($HTTP_X_COMING_FROM)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_X_COMING_FROM'])) {
$HTTP_X_COMING_FROM = $_SERVER['HTTP_X_COMING_FROM'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_X_COMING_FROM'])) {
$HTTP_X_COMING_FROM = $_ENV['HTTP_X_COMING_FROM'];
}
else if (@getenv('HTTP_X_COMING_FROM')) {
$HTTP_X_COMING_FROM = getenv('HTTP_X_COMING_FROM');
}
} // end if
if (empty($HTTP_COMING_FROM)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_COMING_FROM'])) {
$HTTP_COMING_FROM = $_SERVER['HTTP_COMING_FROM'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_COMING_FROM'])) {
$HTTP_COMING_FROM = $_ENV['HTTP_COMING_FROM'];
}
else if (@getenv('HTTP_COMING_FROM')) {
$HTTP_COMING_FROM = getenv('HTTP_COMING_FROM');
}
} // end if
// Gets the default ip sent by the user
if (!empty($REMOTE_ADDR)) {
$direct_ip = $REMOTE_ADDR;
// Get some server/environment variables values
if (empty($REMOTE_ADDR)) {
if (!empty($_SERVER) && isset($_SERVER['REMOTE_ADDR'])) {
$REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
}
else if (!empty($_ENV) && isset($_ENV['REMOTE_ADDR'])) {
$REMOTE_ADDR = $_ENV['REMOTE_ADDR'];
}
else if (@getenv('REMOTE_ADDR')) {
$REMOTE_ADDR = getenv('REMOTE_ADDR');
}
} // end if
if (empty($HTTP_X_FORWARDED_FOR)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$HTTP_X_FORWARDED_FOR = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_X_FORWARDED_FOR'])) {
$HTTP_X_FORWARDED_FOR = $_ENV['HTTP_X_FORWARDED_FOR'];
}
else if (@getenv('HTTP_X_FORWARDED_FOR')) {
$HTTP_X_FORWARDED_FOR = getenv('HTTP_X_FORWARDED_FOR');
}
} // end if
if (empty($HTTP_X_FORWARDED)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_X_FORWARDED'])) {
$HTTP_X_FORWARDED = $_SERVER['HTTP_X_FORWARDED'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_X_FORWARDED'])) {
$HTTP_X_FORWARDED = $_ENV['HTTP_X_FORWARDED'];
}
else if (@getenv('HTTP_X_FORWARDED')) {
$HTTP_X_FORWARDED = getenv('HTTP_X_FORWARDED');
}
} // end if
if (empty($HTTP_FORWARDED_FOR)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_FORWARDED_FOR'])) {
$HTTP_FORWARDED_FOR = $_SERVER['HTTP_FORWARDED_FOR'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_FORWARDED_FOR'])) {
$HTTP_FORWARDED_FOR = $_ENV['HTTP_FORWARDED_FOR'];
}
else if (@getenv('HTTP_FORWARDED_FOR')) {
$HTTP_FORWARDED_FOR = getenv('HTTP_FORWARDED_FOR');
}
} // end if
if (empty($HTTP_FORWARDED)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_FORWARDED'])) {
$HTTP_FORWARDED = $_SERVER['HTTP_FORWARDED'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_FORWARDED'])) {
$HTTP_FORWARDED = $_ENV['HTTP_FORWARDED'];
}
else if (@getenv('HTTP_FORWARDED')) {
$HTTP_FORWARDED = getenv('HTTP_FORWARDED');
}
} // end if
if (empty($HTTP_VIA)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_VIA'])) {
$HTTP_VIA = $_SERVER['HTTP_VIA'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_VIA'])) {
$HTTP_VIA = $_ENV['HTTP_VIA'];
}
else if (@getenv('HTTP_VIA')) {
$HTTP_VIA = getenv('HTTP_VIA');
}
} // end if
if (empty($HTTP_X_COMING_FROM)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_X_COMING_FROM'])) {
$HTTP_X_COMING_FROM = $_SERVER['HTTP_X_COMING_FROM'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_X_COMING_FROM'])) {
$HTTP_X_COMING_FROM = $_ENV['HTTP_X_COMING_FROM'];
}
else if (@getenv('HTTP_X_COMING_FROM')) {
$HTTP_X_COMING_FROM = getenv('HTTP_X_COMING_FROM');
}
} // end if
if (empty($HTTP_COMING_FROM)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_COMING_FROM'])) {
$HTTP_COMING_FROM = $_SERVER['HTTP_COMING_FROM'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_COMING_FROM'])) {
$HTTP_COMING_FROM = $_ENV['HTTP_COMING_FROM'];
}
else if (@getenv('HTTP_COMING_FROM')) {
$HTTP_COMING_FROM = getenv('HTTP_COMING_FROM');
}
} // end if
// Gets the proxy ip sent by the user
$proxy_ip = '';
if (!empty($HTTP_X_FORWARDED_FOR)) {
$proxy_ip = $HTTP_X_FORWARDED_FOR;
} else if (!empty($HTTP_X_FORWARDED)) {
$proxy_ip = $HTTP_X_FORWARDED;
} else if (!empty($HTTP_FORWARDED_FOR)) {
$proxy_ip = $HTTP_FORWARDED_FOR;
} else if (!empty($HTTP_FORWARDED)) {
$proxy_ip = $HTTP_FORWARDED;
} else if (!empty($HTTP_VIA)) {
$proxy_ip = $HTTP_VIA;
} else if (!empty($HTTP_X_COMING_FROM)) {
$proxy_ip = $HTTP_X_COMING_FROM;
} else if (!empty($HTTP_COMING_FROM)) {
$proxy_ip = $HTTP_COMING_FROM;
} // end if... else if...
// Gets the default ip sent by the user
if (!empty($REMOTE_ADDR)) {
$direct_ip = $REMOTE_ADDR;
}
// Returns the true IP if it has been found, else FALSE
if (empty($proxy_ip)) {
// True IP without proxy
return $direct_ip;
// Gets the proxy ip sent by the user
$proxy_ip = '';
if (!empty($HTTP_X_FORWARDED_FOR)) {
$proxy_ip = $HTTP_X_FORWARDED_FOR;
} else if (!empty($HTTP_X_FORWARDED)) {
$proxy_ip = $HTTP_X_FORWARDED;
} else if (!empty($HTTP_FORWARDED_FOR)) {
$proxy_ip = $HTTP_FORWARDED_FOR;
} else if (!empty($HTTP_FORWARDED)) {
$proxy_ip = $HTTP_FORWARDED;
} else if (!empty($HTTP_VIA)) {
$proxy_ip = $HTTP_VIA;
} else if (!empty($HTTP_X_COMING_FROM)) {
$proxy_ip = $HTTP_X_COMING_FROM;
} else if (!empty($HTTP_COMING_FROM)) {
$proxy_ip = $HTTP_COMING_FROM;
} // end if... else if...
// Returns the true IP if it has been found, else FALSE
if (empty($proxy_ip)) {
// True IP without proxy
return $direct_ip;
} else {
$is_ip = preg_match('|^([0-9]{1,3}\.){3,3}[0-9]{1,3}|', $proxy_ip, $regs);
if ($is_ip && (count($regs) > 0)) {
// True IP behind a proxy
return $regs[0];
} else {
$is_ip = preg_match('|^([0-9]{1,3}\.){3,3}[0-9]{1,3}|', $proxy_ip, $regs);
if ($is_ip && (count($regs) > 0)) {
// True IP behind a proxy
return $regs[0];
} else {
// Can't define IP: there is a proxy but we don't have
// information about the true IP
return FALSE;
}
} // end if... else...
} // end of the 'PMA_getIp()' function
/**
* Based on IP Pattern Matcher
* Originally by J.Adams <jna@retina.net>
* Found on <http://www.php.net/manual/en/function.ip2long.php>
* Modified by Robbat2 <robbat2@users.sourceforge.net>
*
* Matches:
* xxx.xxx.xxx.xxx (exact)
* xxx.xxx.xxx.[yyy-zzz] (range)
* xxx.xxx.xxx.xxx/nn (CIDR)
*
* Does not match:
* xxx.xxx.xxx.xx[yyy-zzz] (range, partial octets not supported)
*
* @param string string of IP range to match
* @param string string of IP to test against range
*
* @return boolean always true
*
* @access public
*/
function PMA_ipMaskTest($testRange, $ipToTest)
{
$result = TRUE;
if (preg_match('|([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/([0-9]+)|', $testRange, $regs)) {
// performs a mask match
$ipl = ip2long($ipToTest);
$rangel = ip2long($regs[1] . '.' . $regs[2] . '.' . $regs[3] . '.' . $regs[4]);
$maskl = 0;
for ($i = 0; $i < 31; $i++) {
if ($i < $regs[5] - 1) {
$maskl = $maskl + pow(2, (30 - $i));
} // end if
} // end for
if (($maskl & $rangel) == ($maskl & $ipl)) {
return TRUE;
} else {
return FALSE;
}
} else {
// range based
$maskocts = explode('.', $testRange);
$ipocts = explode('.', $ipToTest);
// perform a range match
for ($i = 0; $i < 4; $i++) {
if (preg_match('|\[([0-9]+)\-([0-9]+)\]|', $maskocts[$i], $regs)) {
if (($ipocts[$i] > $regs[2])
|| ($ipocts[$i] < $regs[1])) {
$result = FALSE;
} // end if
} else {
if ($maskocts[$i] <> $ipocts[$i]) {
$result = FALSE;
} // end if
} // end if/else
} //end for
} //end if/else
return $result;
} // end of the "PMA_IPMaskTest()" function
/**
* Runs through IP Allow/Deny rules the use of it below for more information
*
* @param string 'allow' | 'deny' type of rule to match
*
* @return bool Matched a rule ?
*
* @access public
*
* @see PMA_getIp()
*/
function PMA_allowDeny($type)
{
global $cfg;
// Grabs true IP of the user and returns if it can't be found
$remote_ip = PMA_getIp();
if (empty($remote_ip)) {
// Can't define IP: there is a proxy but we don't have
// information about the true IP
return FALSE;
}
} // end if... else...
} // end of the 'PMA_getIp()' function
// copy username
$username = $cfg['Server']['user'];
// copy rule database
$rules = $cfg['Server']['AllowDeny']['rules'];
/**
* Based on IP Pattern Matcher
* Originally by J.Adams <jna@retina.net>
* Found on <http://www.php.net/manual/en/function.ip2long.php>
* Modified by Robbat2 <robbat2@users.sourceforge.net>
*
* Matches:
* xxx.xxx.xxx.xxx (exact)
* xxx.xxx.xxx.[yyy-zzz] (range)
* xxx.xxx.xxx.xxx/nn (CIDR)
*
* Does not match:
* xxx.xxx.xxx.xx[yyy-zzz] (range, partial octets not supported)
*
* @param string string of IP range to match
* @param string string of IP to test against range
*
* @return boolean always true
*
* @access public
*/
function PMA_ipMaskTest($testRange, $ipToTest)
{
$result = TRUE;
// lookup table for some name shortcuts
$shortcuts = array(
'all' => '0.0.0.0/0',
'localhost' => '127.0.0.1/8'
);
if (preg_match('|([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/([0-9]+)|', $testRange, $regs)) {
// performs a mask match
$ipl = ip2long($ipToTest);
$rangel = ip2long($regs[1] . '.' . $regs[2] . '.' . $regs[3] . '.' . $regs[4]);
foreach($rules AS $rule) {
// extract rule data
$rule_data = explode(' ', $rule);
$maskl = 0;
// check for rule type
if ($rule_data[0] != $type) {
continue;
}
for ($i = 0; $i < 31; $i++) {
if ($i < $regs[5] - 1) {
$maskl = $maskl + pow(2, (30 - $i));
} // end if
} // end for
// check for username
if (($rule_data[1] != '%') //wildcarded first
&& ($rule_data[1] != $username)) {
continue;
}
if (($maskl & $rangel) == ($maskl & $ipl)) {
return TRUE;
} else {
return FALSE;
}
} else {
// range based
$maskocts = explode('.', $testRange);
$ipocts = explode('.', $ipToTest);
// check if the config file has the full string with an extra
// 'from' in it and if it does, just discard it
if ($rule_data[2] == 'from') {
$rule_data[2] = $rule_data[3];
}
// perform a range match
for ($i = 0; $i < 4; $i++) {
if (preg_match('|\[([0-9]+)\-([0-9]+)\]|', $maskocts[$i], $regs)) {
if (($ipocts[$i] > $regs[2])
|| ($ipocts[$i] < $regs[1])) {
$result = FALSE;
} // end if
} else {
if ($maskocts[$i] <> $ipocts[$i]) {
$result = FALSE;
} // end if
} // end if/else
} //end for
} //end if/else
// Handle shortcuts with above array
// DON'T use "array_key_exists" as it's only PHP 4.1 and newer.
if (isset($shortcuts[$rule_data[2]])) {
$rule_data[2] = $shortcuts[$rule_data[2]];
}
return $result;
} // end of the "PMA_IPMaskTest()" function
// Add code for host lookups here
// Excluded for the moment
// Do the actual matching now
if (PMA_ipMaskTest($rule_data[2], $remote_ip)) {
return TRUE;
}
} // end while
/**
* Runs through IP Allow/Deny rules the use of it below for more information
*
* @param string 'allow' | 'deny' type of rule to match
*
* @return bool Matched a rule ?
*
* @access public
*
* @see PMA_getIp()
*/
function PMA_allowDeny($type)
{
global $cfg;
// Grabs true IP of the user and returns if it can't be found
$remote_ip = PMA_getIp();
if (empty($remote_ip)) {
return FALSE;
} // end of the "PMA_AllowDeny()" function
}
// copy username
$username = $cfg['Server']['user'];
// copy rule database
$rules = $cfg['Server']['AllowDeny']['rules'];
// lookup table for some name shortcuts
$shortcuts = array(
'all' => '0.0.0.0/0',
'localhost' => '127.0.0.1/8'
);
foreach($rules AS $rule) {
// extract rule data
$rule_data = explode(' ', $rule);
// check for rule type
if ($rule_data[0] != $type) {
continue;
}
// check for username
if (($rule_data[1] != '%') //wildcarded first
&& ($rule_data[1] != $username)) {
continue;
}
// check if the config file has the full string with an extra
// 'from' in it and if it does, just discard it
if ($rule_data[2] == 'from') {
$rule_data[2] = $rule_data[3];
}
// Handle shortcuts with above array
// DON'T use "array_key_exists" as it's only PHP 4.1 and newer.
if (isset($shortcuts[$rule_data[2]])) {
$rule_data[2] = $shortcuts[$rule_data[2]];
}
// Add code for host lookups here
// Excluded for the moment
// Do the actual matching now
if (PMA_ipMaskTest($rule_data[2], $remote_ip)) {
return TRUE;
}
} // end while
return FALSE;
} // end of the "PMA_AllowDeny()" function
} // $__PMA_ALLOW_DENY_LIB__
?>

View File

@@ -12,141 +12,138 @@
*
* 2002/2/22 - by Yukihiro Kawada <kawada@den.fujifilm.co.jp>
*/
if (!defined('PMA_ENCODING_LIB_INCLUDED')) {
define('PMA_ENCODING_LIB_INCLUDED', 1);
/**
* Gets the php internal encoding codes and sets the available encoding
* codes list
* 2002/1/4 by Y.Kawada
*
* @global string the current encoding code
* @global string the available encoding codes list
*
* @return boolean always true
*/
function PMA_internal_enc_check() {
global $internal_enc, $enc_list;
/**
* Gets the php internal encoding codes and sets the available encoding
* codes list
* 2002/1/4 by Y.Kawada
*
* @global string the current encoding code
* @global string the available encoding codes list
*
* @return boolean always true
*/
function PMA_internal_enc_check() {
global $internal_enc, $enc_list;
$internal_enc = mb_internal_encoding();
if ($internal_enc == 'EUC-JP') {
$enc_list = 'ASCII,EUC-JP,SJIS,JIS';
} else {
$enc_list = 'ASCII,SJIS,EUC-JP,JIS';
}
$internal_enc = mb_internal_encoding();
if ($internal_enc == 'EUC-JP') {
$enc_list = 'ASCII,EUC-JP,SJIS,JIS';
} else {
$enc_list = 'ASCII,SJIS,EUC-JP,JIS';
}
return TRUE;
} // end of the 'PMA_internal_enc_check' function
return TRUE;
} // end of the 'PMA_internal_enc_check' function
/**
* Reverses SJIS & EUC-JP position in the encoding codes list
* 2002/1/4 by Y.Kawada
*
* @global string the available encoding codes list
*
* @return boolean always true
*/
function PMA_change_enc_order() {
global $enc_list;
/**
* Reverses SJIS & EUC-JP position in the encoding codes list
* 2002/1/4 by Y.Kawada
*
* @global string the available encoding codes list
*
* @return boolean always true
*/
function PMA_change_enc_order() {
global $enc_list;
$p = explode(',', $enc_list);
if ($p[1] == 'EUC-JP') {
$enc_list = 'ASCII,SJIS,EUC-JP,JIS';
} else {
$enc_list = 'ASCII,EUC-JP,SJIS,JIS';
}
$p = explode(',', $enc_list);
if ($p[1] == 'EUC-JP') {
$enc_list = 'ASCII,SJIS,EUC-JP,JIS';
} else {
$enc_list = 'ASCII,EUC-JP,SJIS,JIS';
}
return TRUE;
} // end of the 'PMA_change_enc_order' function
return TRUE;
} // end of the 'PMA_change_enc_order' function
/**
* Kanji string encoding convert
* 2002/1/4 by Y.Kawada
*
* @param string the string to convert
* @param string the destinasion encoding code
* @param string set 'kana' convert to JIS-X208-kana
*
* @global string the available encoding codes list
*
* @return string the converted string
*/
function PMA_kanji_str_conv($str, $enc, $kana) {
global $enc_list;
/**
* Kanji string encoding convert
* 2002/1/4 by Y.Kawada
*
* @param string the string to convert
* @param string the destinasion encoding code
* @param string set 'kana' convert to JIS-X208-kana
*
* @global string the available encoding codes list
*
* @return string the converted string
*/
function PMA_kanji_str_conv($str, $enc, $kana) {
global $enc_list;
if ($enc == '' && $kana == '') {
return $str;
}
$nw = mb_detect_encoding($str, $enc_list);
if ($enc == '' && $kana == '') {
return $str;
}
$nw = mb_detect_encoding($str, $enc_list);
if ($kana == 'kana') {
$dist = mb_convert_kana($str, 'KV', $nw);
$str = $dist;
}
if ($nw != $enc && $enc != '') {
$dist = mb_convert_encoding($str, $enc, $nw);
} else {
$dist = $str;
}
return $dist;
} // end of the 'PMA_kanji_str_conv' function
if ($kana == 'kana') {
$dist = mb_convert_kana($str, 'KV', $nw);
$str = $dist;
}
if ($nw != $enc && $enc != '') {
$dist = mb_convert_encoding($str, $enc, $nw);
} else {
$dist = $str;
}
return $dist;
} // end of the 'PMA_kanji_str_conv' function
/**
* Kanji file encoding convert
* 2002/1/4 by Y.Kawada
*
* @param string the name of the file to convert
* @param string the destinasion encoding code
* @param string set 'kana' convert to JIS-X208-kana
*
* @return string the name of the converted file
*/
function PMA_kanji_file_conv($file, $enc, $kana) {
if ($enc == '' && $kana == '') {
return $file;
}
/**
* Kanji file encoding convert
* 2002/1/4 by Y.Kawada
*
* @param string the name of the file to convert
* @param string the destinasion encoding code
* @param string set 'kana' convert to JIS-X208-kana
*
* @return string the name of the converted file
*/
function PMA_kanji_file_conv($file, $enc, $kana) {
if ($enc == '' && $kana == '') {
return $file;
}
$tmpfname = tempnam('', $enc);
$fpd = fopen($tmpfname, 'wb');
$fps = fopen($file, 'r');
PMA_change_enc_order();
while (!feof($fps)) {
$line = fgets($fps, 4096);
$dist = PMA_kanji_str_conv($line, $enc, $kana);
fputs($fpd, $dist);
} // end while
PMA_change_enc_order();
fclose($fps);
fclose($fpd);
unlink($file);
$tmpfname = tempnam('', $enc);
$fpd = fopen($tmpfname, 'wb');
$fps = fopen($file, 'r');
PMA_change_enc_order();
while (!feof($fps)) {
$line = fgets($fps, 4096);
$dist = PMA_kanji_str_conv($line, $enc, $kana);
fputs($fpd, $dist);
} // end while
PMA_change_enc_order();
fclose($fps);
fclose($fpd);
unlink($file);
return $tmpfname;
} // end of the 'PMA_kanji_file_conv' function
return $tmpfname;
} // end of the 'PMA_kanji_file_conv' function
/**
* Defines radio form fields to switch between encoding modes
* 2002/1/4 by Y.Kawada
*
* @param string spaces character to prepend the output with
*
* @return string xhtml code for the radio controls
*/
function PMA_set_enc_form($spaces) {
return "\n"
. $spaces . '<input type="radio" name="knjenc" value="" checked="checked" />non' . "\n"
. $spaces . '<input type="radio" name="knjenc" value="EUC-JP" />EUC' . "\n"
. $spaces . '<input type="radio" name="knjenc" value="SJIS" />SJIS' . "\n"
. $spaces . '&nbsp;' . $GLOBALS['strEncto'] . '<br />' . "\n"
. $spaces . '<input type="checkbox" name="xkana" value="kana" />' . "\n"
. $spaces . '&nbsp;' . $GLOBALS['strXkana'] . '<br />' . "\n";
} // end of the 'PMA_set_enc_form' function
/**
* Defines radio form fields to switch between encoding modes
* 2002/1/4 by Y.Kawada
*
* @param string spaces character to prepend the output with
*
* @return string xhtml code for the radio controls
*/
function PMA_set_enc_form($spaces) {
return "\n"
. $spaces . '<input type="radio" name="knjenc" value="" checked="checked" />non' . "\n"
. $spaces . '<input type="radio" name="knjenc" value="EUC-JP" />EUC' . "\n"
. $spaces . '<input type="radio" name="knjenc" value="SJIS" />SJIS' . "\n"
. $spaces . '&nbsp;' . $GLOBALS['strEncto'] . '<br />' . "\n"
. $spaces . '<input type="checkbox" name="xkana" value="kana" />' . "\n"
. $spaces . '&nbsp;' . $GLOBALS['strXkana'] . '<br />' . "\n";
} // end of the 'PMA_set_enc_form' function
PMA_internal_enc_check();
PMA_internal_enc_check();
} // $__PMA_ENCODING_LIB_INCLUDED
?>

View File

@@ -2,8 +2,7 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
if (!defined('PMA_MYSQL_CHARSETS_LIB_INCLUDED')){
define('PMA_MYSQL_CHARSETS_LIB_INCLUDED', 1);
if (PMA_MYSQL_INT_VERSION >= 40100){
$res = PMA_mysql_query('SHOW CHARACTER SET;', $userlink)
or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW CHARACTER SET;');
@@ -15,8 +14,7 @@ if (!defined('PMA_MYSQL_CHARSETS_LIB_INCLUDED')){
$mysql_charsets_descriptions[$row['Charset']] = $row['Description'];
}
@mysql_free_result($res);
unset($res);
unset($row);
unset($res, $row);
$res = PMA_mysql_query('SHOW COLLATION;', $userlink)
or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW COLLATION;');
@@ -44,8 +42,7 @@ if (!defined('PMA_MYSQL_CHARSETS_LIB_INCLUDED')){
}
@mysql_free_result($res);
unset($res);
unset($row);
unset($res, $row);
function PMA_getCollationDescr($collation) {
if ($collation == 'binary') {
@@ -205,6 +202,6 @@ if (!defined('PMA_MYSQL_CHARSETS_LIB_INCLUDED')){
return $descr;
}
} // $__PMA_MYSQL_CHARSETS_LIB__
}
?>

View File

@@ -9,116 +9,112 @@
*/
function PMA_mysql_dbname($result, $row, $field = FALSE) {
if ($field != FALSE) {
return PMA_convert_display_charset(mysql_dbname($result, $row, $field));
} else {
return PMA_convert_display_charset(mysql_dbname($result, $row));
}
}
if (!defined('PMA_MYSQL_WRAPPERS_LIB_INCLUDED')){
define('PMA_MYSQL_WRAPPERS_LIB_INCLUDED', 1);
function PMA_mysql_dbname($result, $row, $field = FALSE) {
if ($field != FALSE) {
return PMA_convert_display_charset(mysql_dbname($result, $row, $field));
} else {
return PMA_convert_display_charset(mysql_dbname($result, $row));
function PMA_mysql_error($id = FALSE) {
if ($id != FALSE) {
if (mysql_errno($id) != 0) {
return PMA_convert_display_charset('#' . mysql_errno($id) . ' - ' . mysql_error($id));
}
} elseif (mysql_errno() != 0) {
return PMA_convert_display_charset('#' . mysql_errno() . ' - ' . mysql_error());
}
function PMA_mysql_error($id = FALSE) {
if ($id != FALSE) {
if (mysql_errno($id) != 0) {
return PMA_convert_display_charset('#' . mysql_errno($id) . ' - ' . mysql_error($id));
}
} elseif (mysql_errno() != 0) {
return PMA_convert_display_charset('#' . mysql_errno() . ' - ' . mysql_error());
}
return FALSE;
}
return FALSE;
function PMA_mysql_fetch_array($result, $type = FALSE) {
global $cfg, $allow_recoding, $charset, $convcharset;
if ($type != FALSE) {
$data = mysql_fetch_array($result, $type);
} else {
$data = mysql_fetch_array($result);
}
function PMA_mysql_fetch_array($result, $type = FALSE) {
global $cfg, $allow_recoding, $charset, $convcharset;
if ($type != FALSE) {
$data = mysql_fetch_array($result, $type);
} else {
$data = mysql_fetch_array($result);
}
if (!(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
/* No recoding -> return data as we got them */
return $data;
} else {
$ret = array();
$num = mysql_num_fields($result);
$i = 0;
for($i = 0; $i < $num; $i++) {
$meta = mysql_fetch_field($result);
$name = mysql_field_name($result, $i);
if (!$meta) {
/* No meta information available -> we guess that it should be converted */
if (!(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
/* No recoding -> return data as we got them */
return $data;
} else {
$ret = array();
$num = mysql_num_fields($result);
$i = 0;
for($i = 0; $i < $num; $i++) {
$meta = mysql_fetch_field($result);
$name = mysql_field_name($result, $i);
if (!$meta) {
/* No meta information available -> we guess that it should be converted */
if (isset($data[$i])) $ret[$i] = PMA_convert_display_charset($data[$i]);
if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = PMA_convert_display_charset($data[$name]);
} else {
/* Meta information available -> check type of field and convert it according to the type */
if ($meta->blob || stristr($meta->type, 'BINARY')) {
if (isset($data[$i])) $ret[$i] = $data[$i];
if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = $data[$name];
} else {
if (isset($data[$i])) $ret[$i] = PMA_convert_display_charset($data[$i]);
if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = PMA_convert_display_charset($data[$name]);
} else {
/* Meta information available -> check type of field and convert it according to the type */
if ($meta->blob || stristr($meta->type, 'BINARY')) {
if (isset($data[$i])) $ret[$i] = $data[$i];
if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = $data[$name];
} else {
if (isset($data[$i])) $ret[$i] = PMA_convert_display_charset($data[$i]);
if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = PMA_convert_display_charset($data[$name]);
}
}
}
return $ret;
}
return $ret;
}
}
function PMA_mysql_fetch_field($result , $field_offset = FALSE) {
if ($field_offset != FALSE) {
return PMA_convert_display_charset(mysql_fetch_field($result, $field_offset));
function PMA_mysql_fetch_field($result , $field_offset = FALSE) {
if ($field_offset != FALSE) {
return PMA_convert_display_charset(mysql_fetch_field($result, $field_offset));
} else {
return PMA_convert_display_charset(mysql_fetch_field($result));
}
}
function PMA_mysql_fetch_row($result) {
/* nijel: This is not optimal, but keeps us from duplicating code, if
* speed really matters, duplicate here code from PMA_mysql_fetch_array
* with removing rows working with associative array. */
return PMA_mysql_fetch_array($result, MYSQL_NUM);
}
function PMA_mysql_field_flags($result, $field_offset) {
return PMA_convert_display_charset(mysql_field_flags($result, $field_offset));
}
function PMA_mysql_field_name($result, $field_index) {
return PMA_convert_display_charset(mysql_field_name($result, $field_index));
}
function PMA_mysql_field_type($result, $field_index) {
return PMA_convert_display_charset(mysql_field_type($result, $field_index));
}
function PMA_mysql_query($query, $link_identifier = FALSE, $result_mode = FALSE) {
if ($link_identifier != FALSE) {
if ($result_mode != FALSE) {
return mysql_query(PMA_convert_charset($query), $link_identifier, $result_mode);
} else {
return PMA_convert_display_charset(mysql_fetch_field($result));
}
}
function PMA_mysql_fetch_row($result) {
/* nijel: This is not optimal, but keeps us from duplicating code, if
* speed really matters, duplicate here code from PMA_mysql_fetch_array
* with removing rows working with associative array. */
return PMA_mysql_fetch_array($result, MYSQL_NUM);
}
function PMA_mysql_field_flags($result, $field_offset) {
return PMA_convert_display_charset(mysql_field_flags($result, $field_offset));
}
function PMA_mysql_field_name($result, $field_index) {
return PMA_convert_display_charset(mysql_field_name($result, $field_index));
}
function PMA_mysql_field_type($result, $field_index) {
return PMA_convert_display_charset(mysql_field_type($result, $field_index));
}
function PMA_mysql_query($query, $link_identifier = FALSE, $result_mode = FALSE) {
if ($link_identifier != FALSE) {
if ($result_mode != FALSE) {
return mysql_query(PMA_convert_charset($query), $link_identifier, $result_mode);
} else {
return mysql_query(PMA_convert_charset($query), $link_identifier);
}
} else {
return mysql_query(PMA_convert_charset($query));
return mysql_query(PMA_convert_charset($query), $link_identifier);
}
} else {
return mysql_query(PMA_convert_charset($query));
}
}
// mysql_list_tables() is deprecated, also we got report about weird results
// under some circumstances
function PMA_mysql_list_tables($database_name, $link_identifier = FALSE) {
if ($link_identifier != FALSE) {
return PMA_mysql_query('SHOW TABLES FROM ' . PMA_backquote(PMA_convert_charset($database_name)), $link_identifier);
} else {
return PMA_mysql_query('SHOW TABLES FROM ' . PMA_backquote(PMA_convert_charset($database_name)));
}
function PMA_mysql_list_tables($database_name, $link_identifier = FALSE) {
if ($link_identifier != FALSE) {
return PMA_mysql_query('SHOW TABLES FROM ' . PMA_backquote(PMA_convert_charset($database_name)), $link_identifier);
} else {
return PMA_mysql_query('SHOW TABLES FROM ' . PMA_backquote(PMA_convert_charset($database_name)));
}
}
// mysql_list_fields() is deprecated, also we got report about weird results
// under some circumstances
@@ -126,53 +122,51 @@ if (!defined('PMA_MYSQL_WRAPPERS_LIB_INCLUDED')){
// using SELECT * FROM db.table
// lets us use functions like mysql_field_name() on the result set
function PMA_mysql_list_fields_alternate($database_name, $table_name, $link_identifier = FALSE) {
if ($link_identifier != FALSE) {
$result = PMA_mysql_query('SHOW FIELDS FROM '
. PMA_backquote(PMA_convert_charset($database_name)) . '.'
. PMA_backquote(PMA_convert_charset($table_name)), $link_identifier);
} else {
$result = PMA_mysql_query('SHOW FIELDS FROM '
. PMA_backquote(PMA_convert_charset($database_name)) . '.'
. PMA_backquote(PMA_convert_charset($table_name)));
}
$fields = array();
while ($row = PMA_mysql_fetch_array($result)) {
$fields[] = $row;
}
return $fields;
function PMA_mysql_list_fields_alternate($database_name, $table_name, $link_identifier = FALSE) {
if ($link_identifier != FALSE) {
$result = PMA_mysql_query('SHOW FIELDS FROM '
. PMA_backquote(PMA_convert_charset($database_name)) . '.'
. PMA_backquote(PMA_convert_charset($table_name)), $link_identifier);
} else {
$result = PMA_mysql_query('SHOW FIELDS FROM '
. PMA_backquote(PMA_convert_charset($database_name)) . '.'
. PMA_backquote(PMA_convert_charset($table_name)));
}
function PMA_mysql_list_fields($database_name, $table_name, $link_identifier = FALSE) {
if ($link_identifier != FALSE) {
return mysql_list_fields(PMA_convert_charset($database_name), PMA_convert_charset($table_name), $link_identifier);
} else {
return mysql_list_fields(PMA_convert_charset($database_name), PMA_convert_charset($table_name));
}
$fields = array();
while ($row = PMA_mysql_fetch_array($result)) {
$fields[] = $row;
}
function PMA_mysql_result($result, $row, $field = FALSE) {
if ($field != FALSE) {
return PMA_convert_display_charset(mysql_result($result, $row, PMA_convert_charset($field)));
} else {
return PMA_convert_display_charset(mysql_result($result, $row));
}
return $fields;
}
function PMA_mysql_list_fields($database_name, $table_name, $link_identifier = FALSE) {
if ($link_identifier != FALSE) {
return mysql_list_fields(PMA_convert_charset($database_name), PMA_convert_charset($table_name), $link_identifier);
} else {
return mysql_list_fields(PMA_convert_charset($database_name), PMA_convert_charset($table_name));
}
}
function PMA_mysql_select_db($database_name, $link_identifier = FALSE) {
if ($link_identifier != FALSE) {
return mysql_select_db(PMA_convert_charset($database_name), $link_identifier);
} else {
return mysql_select_db(PMA_convert_charset($database_name));
}
function PMA_mysql_result($result, $row, $field = FALSE) {
if ($field != FALSE) {
return PMA_convert_display_charset(mysql_result($result, $row, PMA_convert_charset($field)));
} else {
return PMA_convert_display_charset(mysql_result($result, $row));
}
}
function PMA_mysql_tablename($result, $i) {
return PMA_convert_display_charset(mysql_tablename($result, $i));
function PMA_mysql_select_db($database_name, $link_identifier = FALSE) {
if ($link_identifier != FALSE) {
return mysql_select_db(PMA_convert_charset($database_name), $link_identifier);
} else {
return mysql_select_db(PMA_convert_charset($database_name));
}
}
function PMA_mysql_tablename($result, $i) {
return PMA_convert_display_charset(mysql_tablename($result, $i));
}
} // PMA_MYSQL_WRAPPERS_LIB_INCLUDED
?>

View File

@@ -3,131 +3,128 @@
// vim: expandtab sw=4 ts=4 sts=4:
if (!defined('PMA_OB_LIB_INCLUDED')) {
define('PMA_OB_LIB_INCLUDED', 1);
/**
* Output buffer functions for phpMyAdmin
*
* Copyright 2001 Jeremy Brand <jeremy@nirvani.net>
* http://www.jeremybrand.com/Jeremy/Brand/Jeremy_Brand.html
*
* Check for all the needed functions for output buffering
* Make some wrappers for the top and bottoms of our files.
*/
# Output buffer functions for phpMyAdmin
#
# Copyright 2001 Jeremy Brand <jeremy@nirvani.net>
# http://www.jeremybrand.com/Jeremy/Brand/Jeremy_Brand.html
#
# Check for all the needed functions for output buffering
# Make some wrappers for the top and bottoms of our files.
/**
* This function be used eventually to support more modes. It is needed
* because both header and footer functions must know what each other is
* doing.
*
* @return integer the output buffer mode
*/
function PMA_outBufferModeGet()
{
if (@function_exists('ob_start')) {
$mode = 1;
} else {
$mode = 0;
}
/**
* This function be used eventually to support more modes. It is needed
* because both header and footer functions must know what each other is
* doing.
*
* @return integer the output buffer mode
*/
function PMA_outBufferModeGet()
{
if (@function_exists('ob_start')) {
$mode = 1;
} else {
// If a user sets the output_handler in php.ini to ob_gzhandler, then
// any right frame file in phpMyAdmin will not be handled properly by
// the browser. My fix was to check the ini file within the
// PMA_outBufferModeGet() function.
//
// (Patch by Garth Gillespie, modified by Marc Delisle)
if (@ini_get('output_handler') == 'ob_gzhandler') {
$mode = 0;
}
if (@get_cfg_var('output_handler') == 'ob_gzhandler') {
$mode = 0;
}
// End patch
// If output buffering is enabled in php.ini it's not possible to
// add the ob_gzhandler without a warning message from php 4.3.0.
// Being better safe than sorry, check for any existing output handler
// instead of just checking the 'output_buffering' setting.
//
if (@function_exists('ob_get_level')) {
if (ob_get_level() > 0) {
$mode = 0;
}
}
// If a user sets the output_handler in php.ini to ob_gzhandler, then
// any right frame file in phpMyAdmin will not be handled properly by
// the browser. My fix was to check the ini file within the
// PMA_outBufferModeGet() function.
//
// (Patch by Garth Gillespie, modified by Marc Delisle)
if (@ini_get('output_handler') == 'ob_gzhandler') {
$mode = 0;
}
if (@get_cfg_var('output_handler') == 'ob_gzhandler') {
$mode = 0;
}
// End patch
// Zero (0) is no mode or in other words output buffering is OFF.
// Follow 2^0, 2^1, 2^2, 2^3 type values for the modes.
// Usefull if we ever decide to combine modes. Then a bitmask field of
// the sum of all modes will be the natural choice.
// If output buffering is enabled in php.ini it's not possible to
// add the ob_gzhandler without a warning message from php 4.3.0.
// Being better safe than sorry, check for any existing output handler
// instead of just checking the 'output_buffering' setting.
//
if (@function_exists('ob_get_level')) {
if (ob_get_level() > 0) {
$mode = 0;
}
}
header('X-ob_mode: ' . $mode);
// Zero (0) is no mode or in other words output buffering is OFF.
// Follow 2^0, 2^1, 2^2, 2^3 type values for the modes.
// Usefull if we ever decide to combine modes. Then a bitmask field of
// the sum of all modes will be the natural choice.
header('X-ob_mode: ' . $mode);
return $mode;
} // end of the 'PMA_outBufferModeGet()' function
return $mode;
} // end of the 'PMA_outBufferModeGet()' function
/**
* This function will need to run at the top of all pages if output
* output buffering is turned on. It also needs to be passed $mode from
* the PMA_outBufferModeGet() function or it will be useless.
*
* @param integer the output buffer mode
*
* @return boolean whether output buffering is enabled or not
*/
function PMA_outBufferPre($mode)
/**
* This function will need to run at the top of all pages if output
* output buffering is turned on. It also needs to be passed $mode from
* the PMA_outBufferModeGet() function or it will be useless.
*
* @param integer the output buffer mode
*
* @return boolean whether output buffering is enabled or not
*/
function PMA_outBufferPre($mode)
{
switch($mode)
{
switch($mode)
{
case 1:
ob_start('ob_gzhandler');
$retval = TRUE;
break;
case 1:
ob_start('ob_gzhandler');
$retval = TRUE;
break;
case 0:
$retval = FALSE;
break;
case 0:
$retval = FALSE;
break;
// loic1: php3 fix
default:
$retval = FALSE;
break;
} // end switch
// loic1: php3 fix
default:
$retval = FALSE;
break;
} // end switch
return $retval;
} // end of the 'PMA_outBufferPre()' function
return $retval;
} // end of the 'PMA_outBufferPre()' function
/**
* This function will need to run at the bottom of all pages if output
* buffering is turned on. It also needs to be passed $mode from the
* PMA_outBufferModeGet() function or it will be useless.
*
* @param integer the output buffer mode
*
* @return boolean whether data has been send from the buffer or not
*/
function PMA_outBufferPost($mode)
/**
* This function will need to run at the bottom of all pages if output
* buffering is turned on. It also needs to be passed $mode from the
* PMA_outBufferModeGet() function or it will be useless.
*
* @param integer the output buffer mode
*
* @return boolean whether data has been send from the buffer or not
*/
function PMA_outBufferPost($mode)
{
switch($mode)
{
switch($mode)
{
case 1:
# This output buffer doesn't need a footer.
$retval = TRUE;
break;
case 1:
# This output buffer doesn't need a footer.
$retval = TRUE;
break;
case 0:
$retval = FALSE;
break;
case 0:
$retval = FALSE;
break;
// loic1: php3 fix
default:
$retval = FALSE;
break;
} // end switch
// loic1: php3 fix
default:
$retval = FALSE;
break;
} // end switch
return $retval;
} // end of the 'PMA_outBufferPost()' function
} // $__PMA_OB_LIB__
return $retval;
} // end of the 'PMA_outBufferPost()' function
?>

View File

@@ -2,214 +2,210 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
if (!defined('PMA_READ_DUMP_INCLUDED')) {
define('PMA_READ_DUMP_INCLUDED', 1);
/**
* Removes comment lines and splits up large sql files into individual queries
*
* Last revision: September 23, 2001 - gandon
*
* @param array the splitted sql commands
* @param string the sql commands
* @param integer the MySQL release number (because certains php3 versions
* can't get the value of a constant from within a function)
*
* @return boolean always true
*
* @access public
*/
function PMA_splitSqlFile(&$ret, $sql, $release)
{
$sql = trim($sql);
$sql_len = strlen($sql);
$char = '';
$string_start = '';
$in_string = FALSE;
$time0 = time();
/**
* Removes comment lines and splits up large sql files into individual queries
*
* Last revision: September 23, 2001 - gandon
*
* @param array the splitted sql commands
* @param string the sql commands
* @param integer the MySQL release number (because certains php3 versions
* can't get the value of a constant from within a function)
*
* @return boolean always true
*
* @access public
*/
function PMA_splitSqlFile(&$ret, $sql, $release)
{
$sql = trim($sql);
$sql_len = strlen($sql);
$char = '';
$string_start = '';
$in_string = FALSE;
$time0 = time();
for ($i = 0; $i < $sql_len; ++$i) {
$char = $sql[$i];
for ($i = 0; $i < $sql_len; ++$i) {
$char = $sql[$i];
// We are in a string, check for not escaped end of strings except for
// backquotes that can't be escaped
if ($in_string) {
for (;;) {
$i = strpos($sql, $string_start, $i);
// No end of string found -> add the current substring to the
// returned array
if (!$i) {
$ret[] = $sql;
return TRUE;
}
// Backquotes or no backslashes before quotes: it's indeed the
// end of the string -> exit the loop
else if ($string_start == '`' || $sql[$i-1] != '\\') {
$string_start = '';
$in_string = FALSE;
break;
}
// one or more Backslashes before the presumed end of string...
else {
// ... first checks for escaped backslashes
$j = 2;
$escaped_backslash = FALSE;
while ($i-$j > 0 && $sql[$i-$j] == '\\') {
$escaped_backslash = !$escaped_backslash;
$j++;
}
// ... if escaped backslashes: it's really the end of the
// string -> exit the loop
if ($escaped_backslash) {
$string_start = '';
$in_string = FALSE;
break;
}
// ... else loop
else {
$i++;
}
} // end if...elseif...else
} // end for
} // end if (in string)
// We are not in a string, first check for delimiter...
else if ($char == ';') {
// if delimiter found, add the parsed part to the returned array
$ret[] = substr($sql, 0, $i);
$sql = ltrim(substr($sql, min($i + 1, $sql_len)));
$sql_len = strlen($sql);
if ($sql_len) {
$i = -1;
} else {
// The submited statement(s) end(s) here
// We are in a string, check for not escaped end of strings except for
// backquotes that can't be escaped
if ($in_string) {
for (;;) {
$i = strpos($sql, $string_start, $i);
// No end of string found -> add the current substring to the
// returned array
if (!$i) {
$ret[] = $sql;
return TRUE;
}
} // end else if (is delimiter)
// ... then check for start of a string,...
else if (($char == '"') || ($char == '\'') || ($char == '`')) {
$in_string = TRUE;
$string_start = $char;
} // end else if (is start of string)
// ... for start of a comment (and remove this comment if found)...
else if ($char == '#'
|| ($char == ' ' && $i > 1 && $sql[$i-2] . $sql[$i-1] == '--')) {
// starting position of the comment depends on the comment type
$start_of_comment = (($sql[$i] == '#') ? $i : $i-2);
// if no "\n" exits in the remaining string, checks for "\r"
// (Mac eol style)
$end_of_comment = (strpos(' ' . $sql, "\012", $i+2))
? strpos(' ' . $sql, "\012", $i+2)
: strpos(' ' . $sql, "\015", $i+2);
if (!$end_of_comment) {
// no eol found after '#', add the parsed part to the returned
// array if required and exit
if ($start_of_comment > 0) {
$ret[] = trim(substr($sql, 0, $start_of_comment));
// Backquotes or no backslashes before quotes: it's indeed the
// end of the string -> exit the loop
else if ($string_start == '`' || $sql[$i-1] != '\\') {
$string_start = '';
$in_string = FALSE;
break;
}
// one or more Backslashes before the presumed end of string...
else {
// ... first checks for escaped backslashes
$j = 2;
$escaped_backslash = FALSE;
while ($i-$j > 0 && $sql[$i-$j] == '\\') {
$escaped_backslash = !$escaped_backslash;
$j++;
}
return TRUE;
} else {
$sql = substr($sql, 0, $start_of_comment)
. ltrim(substr($sql, $end_of_comment));
$sql_len = strlen($sql);
$i--;
} // end if...else
} // end else if (is comment)
// ... if escaped backslashes: it's really the end of the
// string -> exit the loop
if ($escaped_backslash) {
$string_start = '';
$in_string = FALSE;
break;
}
// ... else loop
else {
$i++;
}
} // end if...elseif...else
} // end for
} // end if (in string)
// ... and finally disactivate the "/*!...*/" syntax if MySQL < 3.22.07
else if ($release < 32270
&& ($char == '!' && $i > 1 && $sql[$i-2] . $sql[$i-1] == '/*')) {
$sql[$i] = ' ';
} // end else if
// We are not in a string, first check for delimiter...
else if ($char == ';') {
// if delimiter found, add the parsed part to the returned array
$ret[] = substr($sql, 0, $i);
$sql = ltrim(substr($sql, min($i + 1, $sql_len)));
$sql_len = strlen($sql);
if ($sql_len) {
$i = -1;
} else {
// The submited statement(s) end(s) here
return TRUE;
}
} // end else if (is delimiter)
// loic1: send a fake header each 30 sec. to bypass browser timeout
$time1 = time();
if ($time1 >= $time0 + 30) {
$time0 = $time1;
header('X-pmaPing: Pong');
} // end if
} // end for
// ... then check for start of a string,...
else if (($char == '"') || ($char == '\'') || ($char == '`')) {
$in_string = TRUE;
$string_start = $char;
} // end else if (is start of string)
// add any rest to the returned array
if (!empty($sql) && preg_match('@[^[:space:]]+@', $sql)) {
$ret[] = $sql;
}
// ... for start of a comment (and remove this comment if found)...
else if ($char == '#'
|| ($char == ' ' && $i > 1 && $sql[$i-2] . $sql[$i-1] == '--')) {
// starting position of the comment depends on the comment type
$start_of_comment = (($sql[$i] == '#') ? $i : $i-2);
// if no "\n" exits in the remaining string, checks for "\r"
// (Mac eol style)
$end_of_comment = (strpos(' ' . $sql, "\012", $i+2))
? strpos(' ' . $sql, "\012", $i+2)
: strpos(' ' . $sql, "\015", $i+2);
if (!$end_of_comment) {
// no eol found after '#', add the parsed part to the returned
// array if required and exit
if ($start_of_comment > 0) {
$ret[] = trim(substr($sql, 0, $start_of_comment));
}
return TRUE;
} else {
$sql = substr($sql, 0, $start_of_comment)
. ltrim(substr($sql, $end_of_comment));
$sql_len = strlen($sql);
$i--;
} // end if...else
} // end else if (is comment)
return TRUE;
} // end of the 'PMA_splitSqlFile()' function
// ... and finally disactivate the "/*!...*/" syntax if MySQL < 3.22.07
else if ($release < 32270
&& ($char == '!' && $i > 1 && $sql[$i-2] . $sql[$i-1] == '/*')) {
$sql[$i] = ' ';
} // end else if
// loic1: send a fake header each 30 sec. to bypass browser timeout
$time1 = time();
if ($time1 >= $time0 + 30) {
$time0 = $time1;
header('X-pmaPing: Pong');
} // end if
} // end for
// add any rest to the returned array
if (!empty($sql) && preg_match('@[^[:space:]]+@', $sql)) {
$ret[] = $sql;
}
return TRUE;
} // end of the 'PMA_splitSqlFile()' function
/**
* Reads (and decompresses) a (compressed) file into a string
*
* @param string the path to the file
* @param string the MIME type of the file, if empty MIME type is autodetected
*
* @global array the phpMyAdmin configuration
*
* @return string the content of the file or
* boolean FALSE in case of an error.
*/
function PMA_readFile($path, $mime = '') {
global $cfg;
/**
* Reads (and decompresses) a (compressed) file into a string
*
* @param string the path to the file
* @param string the MIME type of the file, if empty MIME type is autodetected
*
* @global array the phpMyAdmin configuration
*
* @return string the content of the file or
* boolean FALSE in case of an error.
*/
function PMA_readFile($path, $mime = '') {
global $cfg;
if (!file_exists($path)) {
return FALSE;
}
switch ($mime) {
case '':
$file = @fopen($path, 'rb');
if (!file_exists($path)) {
return FALSE;
}
switch ($mime) {
case '':
$file = @fopen($path, 'rb');
if (!$file) {
return FALSE;
}
$test = fread($file, 3);
fclose($file);
if ($test[0] == chr(31) && $test[1] == chr(139)) return PMA_readFile($path, 'application/x-gzip');
if ($test == 'BZh') return PMA_readFile($path, 'application/x-bzip');
return PMA_readFile($path, 'text/plain');
case 'text/plain':
$file = @fopen($path, 'rb');
if (!$file) {
return FALSE;
}
$content = fread($file, filesize($path));
fclose($file);
break;
case 'application/x-gzip':
if ($cfg['GZipDump'] && @function_exists('gzopen')) {
$file = @gzopen($path, 'rb');
if (!$file) {
return FALSE;
}
$test = fread($file, 3);
fclose($file);
if ($test[0] == chr(31) && $test[1] == chr(139)) return PMA_readFile($path, 'application/x-gzip');
if ($test == 'BZh') return PMA_readFile($path, 'application/x-bzip');
return PMA_readFile($path, 'text/plain');
case 'text/plain':
$content = '';
while (!gzeof($file)) {
$content .= gzgetc($file);
}
gzclose($file);
} else {
return FALSE;
}
break;
case 'application/x-bzip':
if ($cfg['BZipDump'] && @function_exists('bzdecompress')) {
$file = @fopen($path, 'rb');
if (!$file) {
return FALSE;
}
$content = fread($file, filesize($path));
fclose($file);
break;
case 'application/x-gzip':
if ($cfg['GZipDump'] && @function_exists('gzopen')) {
$file = @gzopen($path, 'rb');
if (!$file) {
return FALSE;
}
$content = '';
while (!gzeof($file)) {
$content .= gzgetc($file);
}
gzclose($file);
} else {
return FALSE;
}
break;
case 'application/x-bzip':
if ($cfg['BZipDump'] && @function_exists('bzdecompress')) {
$file = @fopen($path, 'rb');
if (!$file) {
return FALSE;
}
$content = fread($file, filesize($path));
fclose($file);
$content = bzdecompress($content);
} else {
return FALSE;
}
break;
default:
return FALSE;
}
return $content;
$content = bzdecompress($content);
} else {
return FALSE;
}
break;
default:
return FALSE;
}
} // $__PMA_READ_DUMP_LIB__
return $content;
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -7,139 +7,135 @@
*/
if (!defined('PMA_RELATION_CLEANUP_LIB_INCLUDED')){
define('PMA_RELATION_CLEANUP_LIB_INCLUDED', 1);
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
include('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
function PMA_relationsCleanupColumn($db, $table, $column) {
global $cfgRelation;
if ($cfgRelation['commwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND column_name = \'' . PMA_sqlAddslashes(urldecode($column)) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
if ($cfgRelation['displaywork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND display_field = \'' . PMA_sqlAddslashes(urldecode($column)) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
if ($cfgRelation['relwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND master_field = \'' . PMA_sqlAddslashes(urldecode($column)) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND foreign_field = \'' . PMA_sqlAddslashes(urldecode($column)) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
function PMA_relationsCleanupColumn($db, $table, $column) {
global $cfgRelation;
if ($cfgRelation['commwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND column_name = \'' . PMA_sqlAddslashes(urldecode($column)) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
function PMA_relationsCleanupTable($db, $table) {
global $cfgRelation;
if ($cfgRelation['displaywork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND display_field = \'' . PMA_sqlAddslashes(urldecode($column)) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
if ($cfgRelation['commwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
if ($cfgRelation['relwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND master_field = \'' . PMA_sqlAddslashes(urldecode($column)) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
if ($cfgRelation['displaywork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_info'])
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND foreign_field = \'' . PMA_sqlAddslashes(urldecode($column)) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
}
function PMA_relationsCleanupTable($db, $table) {
global $cfgRelation;
if ($cfgRelation['commwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
if ($cfgRelation['pdfwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
if ($cfgRelation['relwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
}
function PMA_relationsCleanupDatabase($db) {
global $cfgRelation;
if ($cfgRelation['commwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
if ($cfgRelation['bookmarkwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['bookmark'])
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
if ($cfgRelation['displaywork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
if ($cfgRelation['pdfwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['pdf_pages'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
if ($cfgRelation['relwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
if ($cfgRelation['displaywork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
} // $__PMA_RELATION_CLEANUP_LIB__
if ($cfgRelation['pdfwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
if ($cfgRelation['relwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
}
function PMA_relationsCleanupDatabase($db) {
global $cfgRelation;
if ($cfgRelation['commwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
if ($cfgRelation['bookmarkwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['bookmark'])
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
if ($cfgRelation['displaywork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
if ($cfgRelation['pdfwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['pdf_pages'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
if ($cfgRelation['relwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
}
?>

View File

@@ -8,275 +8,257 @@
*/
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/';
/**
* We need some elements of the superglobal $_SERVER array.
*/
require_once('./libraries/grab_globals.lib.php');
/**
* 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 contain some informations about the
* charset (see the Russian case).
* 2. The first of the values associated to the key is used in a regular
* expression to find some keywords corresponding to the language inside two
* environment variables.
* These values contains:
* - the "official" ISO language code and, if required, the dialect code
* also ('bu' for Bulgarian, 'fr([-_][[:alpha:]]{2})?' for all French
* dialects, 'zh[-_]tw' for Chinese traditional...);
* - the '|' character (it means 'OR');
* - the full language name.
* 3. The second values associated to the key is the name of the file to load
* without the 'inc.php' extension.
* 4. The last values associated to the key is the language code as defined by
* the RFC1766.
*
* Beware that the sorting order (first values associated to keys by
* alphabetical reverse order in the array) is important: 'zh-tw' (chinese
* traditional) must be detected before 'zh' (chinese simplified) for
* example.
*
* When there are more than one charset for a language, we put the -utf-8
* first.
*
* For Russian, we put 1251 first, because MSIE does not accept 866
* and users would not see anything.
*/
$available_languages = array(
'af-utf-8' => array('af|afrikaans', 'afrikaans-utf-8', 'af'),
'af-iso-8859-1'=> array('af|afrikaans', 'afrikaans-iso-8859-1', 'af'),
'ar-utf-8' => array('ar([-_][[:alpha:]]{2})?|arabic', 'arabic-utf-8', 'ar'),
'ar-win1256' => array('ar([-_][[:alpha:]]{2})?|arabic', 'arabic-windows-1256', 'ar'),
'az-utf-8' => array('az|azerbaijani', 'azerbaijani-utf-8', 'az'),
'az-iso-8859-9'=> array('az|azerbaijani', 'azerbaijani-iso-8859-9', 'az'),
'bg-utf-8' => array('bg|bulgarian', 'bulgarian-utf-8', 'bg'),
'bg-win1251' => array('bg|bulgarian', 'bulgarian-windows-1251', 'bg'),
'bg-koi8-r' => array('bg|bulgarian', 'bulgarian-koi8-r', 'bg'),
'bs-utf-8' => array('bs|bosnian', 'bosnian-utf-8', 'bs'),
'bs-win1250' => array('bs|bosnian', 'bosnian-windows-1250', 'bs'),
'ca-utf-8' => array('ca|catalan', 'catalan-utf-8', 'ca'),
'ca-iso-8859-1'=> array('ca|catalan', 'catalan-iso-8859-1', 'ca'),
'cs-utf-8' => array('cs|czech', 'czech-utf-8', 'cs'),
'cs-iso-8859-2'=> array('cs|czech', 'czech-iso-8859-2', 'cs'),
'cs-win1250' => array('cs|czech', 'czech-windows-1250', 'cs'),
'da-utf-8' => array('da|danish', 'danish-utf-8', 'da'),
'da-iso-8859-1'=> array('da|danish', 'danish-iso-8859-1', 'da'),
'de-utf-8' => array('de([-_][[:alpha:]]{2})?|german', 'german-utf-8', 'de'),
'de-iso-8859-1'=> array('de([-_][[:alpha:]]{2})?|german', 'german-iso-8859-1', 'de'),
'el-utf-8' => array('el|greek', 'greek-utf-8', 'el'),
'el-iso-8859-7'=> array('el|greek', 'greek-iso-8859-7', 'el'),
'en-utf-8' => array('en([-_][[:alpha:]]{2})?|english', 'english-utf-8', 'en'),
'en-iso-8859-1'=> array('en([-_][[:alpha:]]{2})?|english', 'english-iso-8859-1', 'en'),
'es-utf-8' => array('es([-_][[:alpha:]]{2})?|spanish', 'spanish-utf-8', 'es'),
'es-iso-8859-1'=> array('es([-_][[:alpha:]]{2})?|spanish', 'spanish-iso-8859-1', 'es'),
'et-utf-8' => array('et|estonian', 'estonian-utf-8', 'et'),
'et-iso-8859-1'=> array('et|estonian', 'estonian-iso-8859-1', 'et'),
'fa-utf-8' => array('fa|persian', 'persian-utf-8', 'fa'),
'fa-win1256' => array('fa|persian', 'persian-windows-1256', 'fa'),
'fi-utf-8' => array('fi|finnish', 'finnish-utf-8', 'fi'),
'fi-iso-8859-1'=> array('fi|finnish', 'finnish-iso-8859-1', 'fi'),
'fr-utf-8' => array('fr([-_][[:alpha:]]{2})?|french', 'french-utf-8', 'fr'),
'fr-iso-8859-1'=> array('fr([-_][[:alpha:]]{2})?|french', 'french-iso-8859-1', 'fr'),
'gl-utf-8' => array('gl|galician', 'galician-utf-8', 'gl'),
'gl-iso-8859-1'=> array('gl|galician', 'galician-iso-8859-1', 'gl'),
'he-iso-8859-8-i'=> array('he|hebrew', 'hebrew-iso-8859-8-i', 'he'),
'hi-utf-8' => array('hi|hindi', 'hindi-utf-8', 'hi'),
'hr-utf-8' => array('hr|croatian', 'croatian-utf-8', 'hr'),
'hr-win1250' => array('hr|croatian', 'croatian-windows-1250', 'hr'),
'hr-iso-8859-2'=> array('hr|croatian', 'croatian-iso-8859-2', 'hr'),
'hu-utf-8' => array('hu|hungarian', 'hungarian-utf-8', 'hu'),
'hu-iso-8859-2'=> array('hu|hungarian', 'hungarian-iso-8859-2', 'hu'),
'id-utf-8' => array('id|indonesian', 'indonesian-utf-8', 'id'),
'id-iso-8859-1'=> array('id|indonesian', 'indonesian-iso-8859-1', 'id'),
'it-utf-8' => array('it|italian', 'italian-utf-8', 'it'),
'it-iso-8859-1'=> array('it|italian', 'italian-iso-8859-1', 'it'),
'ja-utf-8' => array('ja|japanese', 'japanese-utf-8', 'ja'),
'ja-euc' => array('ja|japanese', 'japanese-euc', 'ja'),
'ja-sjis' => array('ja|japanese', 'japanese-sjis', 'ja'),
'ko-ks_c_5601-1987'=> array('ko|korean', 'korean-ks_c_5601-1987', 'ko'),
'ka-utf-8' => array('ka|georgian', 'georgian-utf-8', 'ka'),
'lt-utf-8' => array('lt|lithuanian', 'lithuanian-utf-8', 'lt'),
'lt-win1257' => array('lt|lithuanian', 'lithuanian-windows-1257', 'lt'),
'lv-utf-8' => array('lv|latvian', 'latvian-utf-8', 'lv'),
'lv-win1257' => array('lv|latvian', 'latvian-windows-1257', 'lv'),
'ms-utf-8' => array('ms|malay', 'malay-utf-8', 'ms'),
'ms-iso-8859-1'=> array('ms|malay', 'malay-iso-8859-1', 'ms'),
'nl-utf-8' => array('nl([-_][[:alpha:]]{2})?|dutch', 'dutch-utf-8', 'nl'),
'nl-iso-8859-1'=> array('nl([-_][[:alpha:]]{2})?|dutch', 'dutch-iso-8859-1', 'nl'),
'no-utf-8' => array('no|norwegian', 'norwegian-utf-8', 'no'),
'no-iso-8859-1'=> array('no|norwegian', 'norwegian-iso-8859-1', 'no'),
'pl-utf-8' => array('pl|polish', 'polish-utf-8', 'pl'),
'pl-iso-8859-2'=> array('pl|polish', 'polish-iso-8859-2', 'pl'),
'pt-br-utf-8' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-utf-8', 'pt-BR'),
'pt-br-iso-8859-1' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-iso-8859-1', 'pt-BR'),
'pt-utf-8' => array('pt([-_][[:alpha:]]{2})?|portuguese', 'portuguese-utf-8', 'pt'),
'pt-iso-8859-1'=> array('pt([-_][[:alpha:]]{2})?|portuguese', 'portuguese-iso-8859-1', 'pt'),
'ro-utf-8' => array('ro|romanian', 'romanian-utf-8', 'ro'),
'ro-iso-8859-1'=> array('ro|romanian', 'romanian-iso-8859-1', 'ro'),
'ru-win1251' => array('ru|russian', 'russian-windows-1251', 'ru'),
'ru-utf-8' => array('ru|russian', 'russian-utf-8', 'ru'),
'ru-dos-866' => array('ru|russian', 'russian-dos-866', 'ru'),
'ru-koi8-r' => array('ru|russian', 'russian-koi8-r', 'ru'),
'sk-utf-8' => array('sk|slovak', 'slovak-utf-8', 'sk'),
'sk-iso-8859-2'=> array('sk|slovak', 'slovak-iso-8859-2', 'sk'),
'sk-win1250' => array('sk|slovak', 'slovak-windows-1250', 'sk'),
'sl-utf-8' => array('sl|slovenian', 'slovenian-utf-8', 'sl'),
'sl-iso-8859-2'=> array('sl|slovenian', 'slovenian-iso-8859-2', 'sl'),
'sl-win1250' => array('sl|slovenian', 'slovenian-windows-1250', 'sl'),
'sq-utf-8' => array('sq|albanian', 'albanian-utf-8', 'sq'),
'sq-iso-8859-1'=> array('sq|albanian', 'albanian-iso-8859-1', 'sq'),
'sr-utf-8' => array('sr|serbian', 'serbian_cyrillic-utf-8', 'sr'),
'sr-win1251' => array('sr|serbian', 'serbian_cyrillic-windows-1251', 'sr'),
'sr-lat-utf-8' => array('sr[-_]lat|serbian latin', 'serbian_latin-utf-8', 'sr-lat'),
'sr-lat-win1250'=> array('sr[-_]lat|serbian latin', 'serbian_latin-windows-1250', 'sr-lat'),
'sv-utf-8' => array('sv|swedish', 'swedish-utf-8', 'sv'),
'sv-iso-8859-1'=> array('sv|swedish', 'swedish-iso-8859-1', 'sv'),
'th-utf-8' => array('th|thai', 'thai-utf-8', 'th'),
'th-tis-620' => array('th|thai', 'thai-tis-620', 'th'),
'tr-utf-8' => array('tr|turkish', 'turkish-utf-8', 'tr'),
'tr-iso-8859-9'=> array('tr|turkish', 'turkish-iso-8859-9', 'tr'),
'uk-utf-8' => array('uk|ukrainian', 'ukrainian-utf-8', 'uk'),
'uk-win1251' => array('uk|ukrainian', 'ukrainian-windows-1251', 'uk'),
'zh-tw-utf-8' => array('zh[-_]tw|chinese traditional', 'chinese_big5-utf-8', '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' => array('zh|chinese simplified', 'chinese_gb', 'zh')
);
/**
* Define the path to the translations directory and get some variables
* from system arrays if 'register_globals' is set to 'off'
*/
$lang_path = 'lang/';
if (!defined('PMA_IS_LANG_DETECT_FUNCTION')) {
define('PMA_IS_LANG_DETECT_FUNCTION', 1);
/**
* Analyzes some PHP environment variables to find the most probable language
* that should be used
*
* @param string string to analyze
* @param integer type of the PHP environment variable which value is $str
*
* @global array the list of available translations
* @global string the retained translation keyword
*
* @access private
*/
function PMA_langDetect($str = '', $envType = '')
{
global $available_languages;
global $lang;
foreach($available_languages AS $key => $value) {
// $envType = 1 for the 'HTTP_ACCEPT_LANGUAGE' environment variable,
// 2 for the 'HTTP_USER_AGENT' one
if (($envType == 1 && eregi('^(' . $value[0] . ')(;q=[0-9]\\.[0-9])?$', $str))
|| ($envType == 2 && eregi('(\(|\[|;[[:space:]])(' . $value[0] . ')(;|\]|\))', $str))) {
$lang = $key;
break;
}
}
} // end of the 'PMA_langDetect()' function
} // end if
/**
* 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 contain some informations about the
* charset (see the Russian case).
* 2. The first of the values associated to the key is used in a regular
* expression to find some keywords corresponding to the language inside two
* environment variables.
* These values contains:
* - the "official" ISO language code and, if required, the dialect code
* also ('bu' for Bulgarian, 'fr([-_][[:alpha:]]{2})?' for all French
* dialects, 'zh[-_]tw' for Chinese traditional...);
* - the '|' character (it means 'OR');
* - the full language name.
* 3. The second values associated to the key is the name of the file to load
* without the 'inc.php' extension.
* 4. The last values associated to the key is the language code as defined by
* the RFC1766.
*
* Beware that the sorting order (first values associated to keys by
* alphabetical reverse order in the array) is important: 'zh-tw' (chinese
* traditional) must be detected before 'zh' (chinese simplified) for
* example.
*
* When there are more than one charset for a language, we put the -utf-8
* first.
*
* For Russian, we put 1251 first, because MSIE does not accept 866
* and users would not see anything.
*/
$available_languages = array(
'af-utf-8' => array('af|afrikaans', 'afrikaans-utf-8', 'af'),
'af-iso-8859-1'=> array('af|afrikaans', 'afrikaans-iso-8859-1', 'af'),
'ar-utf-8' => array('ar([-_][[:alpha:]]{2})?|arabic', 'arabic-utf-8', 'ar'),
'ar-win1256' => array('ar([-_][[:alpha:]]{2})?|arabic', 'arabic-windows-1256', 'ar'),
'az-utf-8' => array('az|azerbaijani', 'azerbaijani-utf-8', 'az'),
'az-iso-8859-9'=> array('az|azerbaijani', 'azerbaijani-iso-8859-9', 'az'),
'bg-utf-8' => array('bg|bulgarian', 'bulgarian-utf-8', 'bg'),
'bg-win1251' => array('bg|bulgarian', 'bulgarian-windows-1251', 'bg'),
'bg-koi8-r' => array('bg|bulgarian', 'bulgarian-koi8-r', 'bg'),
'bs-utf-8' => array('bs|bosnian', 'bosnian-utf-8', 'bs'),
'bs-win1250' => array('bs|bosnian', 'bosnian-windows-1250', 'bs'),
'ca-utf-8' => array('ca|catalan', 'catalan-utf-8', 'ca'),
'ca-iso-8859-1'=> array('ca|catalan', 'catalan-iso-8859-1', 'ca'),
'cs-utf-8' => array('cs|czech', 'czech-utf-8', 'cs'),
'cs-iso-8859-2'=> array('cs|czech', 'czech-iso-8859-2', 'cs'),
'cs-win1250' => array('cs|czech', 'czech-windows-1250', 'cs'),
'da-utf-8' => array('da|danish', 'danish-utf-8', 'da'),
'da-iso-8859-1'=> array('da|danish', 'danish-iso-8859-1', 'da'),
'de-utf-8' => array('de([-_][[:alpha:]]{2})?|german', 'german-utf-8', 'de'),
'de-iso-8859-1'=> array('de([-_][[:alpha:]]{2})?|german', 'german-iso-8859-1', 'de'),
'el-utf-8' => array('el|greek', 'greek-utf-8', 'el'),
'el-iso-8859-7'=> array('el|greek', 'greek-iso-8859-7', 'el'),
'en-utf-8' => array('en([-_][[:alpha:]]{2})?|english', 'english-utf-8', 'en'),
'en-iso-8859-1'=> array('en([-_][[:alpha:]]{2})?|english', 'english-iso-8859-1', 'en'),
'es-utf-8' => array('es([-_][[:alpha:]]{2})?|spanish', 'spanish-utf-8', 'es'),
'es-iso-8859-1'=> array('es([-_][[:alpha:]]{2})?|spanish', 'spanish-iso-8859-1', 'es'),
'et-utf-8' => array('et|estonian', 'estonian-utf-8', 'et'),
'et-iso-8859-1'=> array('et|estonian', 'estonian-iso-8859-1', 'et'),
'fa-utf-8' => array('fa|persian', 'persian-utf-8', 'fa'),
'fa-win1256' => array('fa|persian', 'persian-windows-1256', 'fa'),
'fi-utf-8' => array('fi|finnish', 'finnish-utf-8', 'fi'),
'fi-iso-8859-1'=> array('fi|finnish', 'finnish-iso-8859-1', 'fi'),
'fr-utf-8' => array('fr([-_][[:alpha:]]{2})?|french', 'french-utf-8', 'fr'),
'fr-iso-8859-1'=> array('fr([-_][[:alpha:]]{2})?|french', 'french-iso-8859-1', 'fr'),
'gl-utf-8' => array('gl|galician', 'galician-utf-8', 'gl'),
'gl-iso-8859-1'=> array('gl|galician', 'galician-iso-8859-1', 'gl'),
'he-iso-8859-8-i'=> array('he|hebrew', 'hebrew-iso-8859-8-i', 'he'),
'hi-utf-8' => array('hi|hindi', 'hindi-utf-8', 'hi'),
'hr-utf-8' => array('hr|croatian', 'croatian-utf-8', 'hr'),
'hr-win1250' => array('hr|croatian', 'croatian-windows-1250', 'hr'),
'hr-iso-8859-2'=> array('hr|croatian', 'croatian-iso-8859-2', 'hr'),
'hu-utf-8' => array('hu|hungarian', 'hungarian-utf-8', 'hu'),
'hu-iso-8859-2'=> array('hu|hungarian', 'hungarian-iso-8859-2', 'hu'),
'id-utf-8' => array('id|indonesian', 'indonesian-utf-8', 'id'),
'id-iso-8859-1'=> array('id|indonesian', 'indonesian-iso-8859-1', 'id'),
'it-utf-8' => array('it|italian', 'italian-utf-8', 'it'),
'it-iso-8859-1'=> array('it|italian', 'italian-iso-8859-1', 'it'),
'ja-utf-8' => array('ja|japanese', 'japanese-utf-8', 'ja'),
'ja-euc' => array('ja|japanese', 'japanese-euc', 'ja'),
'ja-sjis' => array('ja|japanese', 'japanese-sjis', 'ja'),
'ko-ks_c_5601-1987'=> array('ko|korean', 'korean-ks_c_5601-1987', 'ko'),
'ka-utf-8' => array('ka|georgian', 'georgian-utf-8', 'ka'),
'lt-utf-8' => array('lt|lithuanian', 'lithuanian-utf-8', 'lt'),
'lt-win1257' => array('lt|lithuanian', 'lithuanian-windows-1257', 'lt'),
'lv-utf-8' => array('lv|latvian', 'latvian-utf-8', 'lv'),
'lv-win1257' => array('lv|latvian', 'latvian-windows-1257', 'lv'),
'ms-utf-8' => array('ms|malay', 'malay-utf-8', 'ms'),
'ms-iso-8859-1'=> array('ms|malay', 'malay-iso-8859-1', 'ms'),
'nl-utf-8' => array('nl([-_][[:alpha:]]{2})?|dutch', 'dutch-utf-8', 'nl'),
'nl-iso-8859-1'=> array('nl([-_][[:alpha:]]{2})?|dutch', 'dutch-iso-8859-1', 'nl'),
'no-utf-8' => array('no|norwegian', 'norwegian-utf-8', 'no'),
'no-iso-8859-1'=> array('no|norwegian', 'norwegian-iso-8859-1', 'no'),
'pl-utf-8' => array('pl|polish', 'polish-utf-8', 'pl'),
'pl-iso-8859-2'=> array('pl|polish', 'polish-iso-8859-2', 'pl'),
'pt-br-utf-8' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-utf-8', 'pt-BR'),
'pt-br-iso-8859-1' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-iso-8859-1', 'pt-BR'),
'pt-utf-8' => array('pt([-_][[:alpha:]]{2})?|portuguese', 'portuguese-utf-8', 'pt'),
'pt-iso-8859-1'=> array('pt([-_][[:alpha:]]{2})?|portuguese', 'portuguese-iso-8859-1', 'pt'),
'ro-utf-8' => array('ro|romanian', 'romanian-utf-8', 'ro'),
'ro-iso-8859-1'=> array('ro|romanian', 'romanian-iso-8859-1', 'ro'),
'ru-win1251' => array('ru|russian', 'russian-windows-1251', 'ru'),
'ru-utf-8' => array('ru|russian', 'russian-utf-8', 'ru'),
'ru-dos-866' => array('ru|russian', 'russian-dos-866', 'ru'),
'ru-koi8-r' => array('ru|russian', 'russian-koi8-r', 'ru'),
'sk-utf-8' => array('sk|slovak', 'slovak-utf-8', 'sk'),
'sk-iso-8859-2'=> array('sk|slovak', 'slovak-iso-8859-2', 'sk'),
'sk-win1250' => array('sk|slovak', 'slovak-windows-1250', 'sk'),
'sl-utf-8' => array('sl|slovenian', 'slovenian-utf-8', 'sl'),
'sl-iso-8859-2'=> array('sl|slovenian', 'slovenian-iso-8859-2', 'sl'),
'sl-win1250' => array('sl|slovenian', 'slovenian-windows-1250', 'sl'),
'sq-utf-8' => array('sq|albanian', 'albanian-utf-8', 'sq'),
'sq-iso-8859-1'=> array('sq|albanian', 'albanian-iso-8859-1', 'sq'),
'sr-utf-8' => array('sr|serbian', 'serbian_cyrillic-utf-8', 'sr'),
'sr-win1251' => array('sr|serbian', 'serbian_cyrillic-windows-1251', 'sr'),
'sr-lat-utf-8' => array('sr[-_]lat|serbian latin', 'serbian_latin-utf-8', 'sr-lat'),
'sr-lat-win1250'=> array('sr[-_]lat|serbian latin', 'serbian_latin-windows-1250', 'sr-lat'),
'sv-utf-8' => array('sv|swedish', 'swedish-utf-8', 'sv'),
'sv-iso-8859-1'=> array('sv|swedish', 'swedish-iso-8859-1', 'sv'),
'th-utf-8' => array('th|thai', 'thai-utf-8', 'th'),
'th-tis-620' => array('th|thai', 'thai-tis-620', 'th'),
'tr-utf-8' => array('tr|turkish', 'turkish-utf-8', 'tr'),
'tr-iso-8859-9'=> array('tr|turkish', 'turkish-iso-8859-9', 'tr'),
'uk-utf-8' => array('uk|ukrainian', 'ukrainian-utf-8', 'uk'),
'uk-win1251' => array('uk|ukrainian', 'ukrainian-windows-1251', 'uk'),
'zh-tw-utf-8' => array('zh[-_]tw|chinese traditional', 'chinese_big5-utf-8', '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' => array('zh|chinese simplified', 'chinese_gb', 'zh')
);
/**
* 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'])) {
$HTTP_ACCEPT_LANGUAGE = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
}
/**
* Analyzes some PHP environment variables to find the most probable language
* that should be used
*
* @param string string to analyze
* @param integer type of the PHP environment variable which value is $str
*
* @global array the list of available translations
* @global string the retained translation keyword
*
* @access private
*/
function PMA_langDetect($str = '', $envType = '')
{
global $available_languages;
global $lang;
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
$HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
}
if (!isset($lang)) {
if (isset($_GET) && !empty($_GET['lang'])) {
$lang = $_GET['lang'];
}
else if (isset($_POST) && !empty($_POST['lang'])) {
$lang = $_POST['lang'];
}
else if (isset($_COOKIE) && !empty($_COOKIE['lang'])) {
$lang = $_COOKIE['lang'];
foreach($available_languages AS $key => $value) {
// $envType = 1 for the 'HTTP_ACCEPT_LANGUAGE' environment variable,
// 2 for the 'HTTP_USER_AGENT' one
if (($envType == 1 && eregi('^(' . $value[0] . ')(;q=[0-9]\\.[0-9])?$', $str))
|| ($envType == 2 && eregi('(\(|\[|;[[:space:]])(' . $value[0] . ')(;|\]|\))', $str))) {
$lang = $key;
break;
}
}
} // end of the 'PMA_langDetect()' function
/**
* Do the work!
*/
// compatibility with config.inc.php <= v1.80
if (!isset($cfg['Lang']) && isset($cfgLang)) {
$cfg['Lang'] = $cfgLang;
unset($cfgLang);
if (!isset($lang)) {
if (isset($_GET) && !empty($_GET['lang'])) {
$lang = $_GET['lang'];
}
if (!isset($cfg['DefaultLang']) && isset($cfgDefaultLang)) {
$cfg['DefaultLang'] = $cfgDefaultLang;
unset($cfgLang);
else if (isset($_POST) && !empty($_POST['lang'])) {
$lang = $_POST['lang'];
}
// 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();
foreach($available_language_files AS $tmp_lang => $tmp_lang_data) {
if (substr($tmp_lang, -5) != 'utf-8') {
$available_languages[$tmp_lang] = $tmp_lang_data;
}
} // end while
unset($tmp_lang);
unset($tmp_lang_data);
unset($available_language_files);
} // end if
// Lang forced
if (!empty($cfg['Lang'])) {
$lang = $cfg['Lang'];
else if (isset($_COOKIE) && !empty($_COOKIE['lang'])) {
$lang = $_COOKIE['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)) {
$accepted = explode(',', $HTTP_ACCEPT_LANGUAGE);
$acceptedCnt = count($accepted);
for ($i = 0; $i < $acceptedCnt && empty($lang); $i++) {
PMA_langDetect($accepted[$i], 1);
/**
* Do the work!
*/
// compatibility with config.inc.php <= v1.80
if (!isset($cfg['Lang']) && isset($cfgLang)) {
$cfg['Lang'] = $cfgLang;
unset($cfgLang);
}
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']) {
$available_language_files = $available_languages;
$available_languages = array();
foreach($available_language_files AS $tmp_lang => $tmp_lang_data) {
if (substr($tmp_lang, -5) != 'utf-8') {
$available_languages[$tmp_lang] = $tmp_lang_data;
}
}
// 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);
}
} // end while
unset($tmp_lang, $tmp_lang_data, $available_language_files);
} // end if
// 3. Didn't catch any valid lang : we use the default settings
if (empty($lang)) {
$lang = $cfg['DefaultLang'];
// 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])) {
$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)) {
$accepted = explode(',', $HTTP_ACCEPT_LANGUAGE);
$acceptedCnt = count($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)) {
PMA_langDetect($HTTP_USER_AGENT, 2);
}
// 4. Checks whether charset recoding should be allowed or not
$allow_recoding = FALSE; // Default fallback value
if (!isset($convcharset) || empty($convcharset)) {
$convcharset = $cfg['DefaultCharset'];
}
// 3. Didn't catch any valid lang : we use the default settings
if (empty($lang)) {
$lang = $cfg['DefaultLang'];
}
// 5. Defines the associated filename and load the translation
$lang_file = $lang_path . $available_languages[$lang][1] . '.inc.php';
include('./' . $lang_file);
// 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.php';
require_once('./' . $lang_file);
} // $__PMA_SELECT_LANG_LIB__
?>

View File

@@ -14,494 +14,490 @@
* (around 4.0.2) as well as the MySQL documentation.
*/
if (!defined('PMA_SQP_DATA_INCLUDED')) {
define('PMA_SQP_DATA_INCLUDED', 1);
$PMA_SQPdata_function_name = array (
'ABS',
'ACOS',
'ADDDATE',
'AES_ENCRYPT',
'AES_DECRYPT',
'ASCII',
'ASIN',
'ATAN',
'ATAN2',
'AVG',
'BENCHMARK',
'BIN',
'BIT_AND',
'BIT_COUNT',
'BIT_LENGTH',
'BIT_OR',
'CAST',
'CEIL',
'CEILING',
'CHAR_LENGTH',
'CHARACTER_LENGTH',
'COALESCE',
'CONCAT',
'CONCAT_WS',
'CONNECTION_ID',
'CONV',
'CONVERT',
'COS',
'COT',
'COUNT',
'CURDATE',
'CURRENT_DATE',
'CURRENT_TIME',
'CURRENT_TIMESTAMP',
'CURRENT_USER',
'CURTIME',
'DATABASE',
'DATE_ADD',
'DATE_FORMAT',
'DATE_SUB',
'DAYNAME',
'DAYOFMONTH',
'DAYOFWEEK',
'DAYOFYEAR',
'DECODE',
'DEGREES',
'DES_ENCRYPT',
'DES_DECRYPT',
'ELT',
'ENCODE',
'ENCRYPT',
'EXP',
'EXPORT_SET',
'EXTRACT',
'FIELD',
'FIND_IN_SET',
'FLOOR',
'FORMAT',
'FOUND_ROWS',
'FROM_DAYS',
'FROM_UNIXTIME',
'GET_LOCK',
'GREATEST',
'GROUP_UNIQUE_USERS',
'HEX',
'IFNULL',
'INET_ATON',
'INET_NTOA',
'INSTR',
'INTERVAL',
'IS_FREE_LOCK',
'ISNULL',
'LAST_INSERT_ID',
'LCASE',
'LEAST',
'LEFT',
'LENGTH',
'LN',
'LOAD_FILE',
'LOCATE',
'LOG',
'LOG2',
'LOG10',
'LOWER',
'LPAD',
'LTRIM',
'MAKE_SET',
'MASTER_POS_WAIT',
'MAX',
'MD5',
'MID',
'MIN',
'MOD',
'MONTH',
'MONTHNAME',
'NOW',
'NULLIF',
'OCT',
'OCTET_LENGTH',
'ORD',
'PASSWORD',
'PERIOD_ADD',
'PERIOD_DIFF',
'PI',
'POSITION',
'POW',
'POWER',
'QUARTER',
'QUOTE',
'RADIANS',
'RAND',
'RELEASE_LOCK',
'REPEAT',
'REVERSE',
'RIGHT',
'ROUND',
'RPAD',
'RTRIM',
'SEC_TO_TIME',
'SESSION_USER',
'SHA',
'SHA1',
'SIGN',
'SIN',
'SOUNDEX',
'SPACE',
'SQRT',
'STD',
'STDDEV',
'STRCMP',
'SUBDATE',
'SUBSTRING',
'SUBSTRING_INDEX',
'SUM',
'SYSDATE',
'SYSTEM_USER',
'TAN',
'TIME_FORMAT',
'TIME_TO_SEC',
'TO_DAYS',
'TRIM',
'UCASE',
'UNIQUE_USERS',
'UNIX_TIMESTAMP',
'UPPER',
'USER',
'VERSION',
'WEEK',
'WEEKDAY',
'YEAR',
'YEARWEEK'
);
//$PMA_SQPdata_function_name_cnt = count($PMA_SQPdata_function_name);
$PMA_SQPdata_function_name_cnt = 151;
$PMA_SQPdata_function_name = array (
'ABS',
'ACOS',
'ADDDATE',
'AES_ENCRYPT',
'AES_DECRYPT',
'ASCII',
'ASIN',
'ATAN',
'ATAN2',
'AVG',
'BENCHMARK',
'BIN',
'BIT_AND',
'BIT_COUNT',
'BIT_LENGTH',
'BIT_OR',
'CAST',
'CEIL',
'CEILING',
'CHAR_LENGTH',
'CHARACTER_LENGTH',
'COALESCE',
'CONCAT',
'CONCAT_WS',
'CONNECTION_ID',
'CONV',
'CONVERT',
'COS',
'COT',
'COUNT',
'CURDATE',
'CURRENT_DATE',
'CURRENT_TIME',
'CURRENT_TIMESTAMP',
'CURRENT_USER',
'CURTIME',
'DATABASE',
'DATE_ADD',
'DATE_FORMAT',
'DATE_SUB',
'DAYNAME',
'DAYOFMONTH',
'DAYOFWEEK',
'DAYOFYEAR',
'DECODE',
'DEGREES',
'DES_ENCRYPT',
'DES_DECRYPT',
'ELT',
'ENCODE',
'ENCRYPT',
'EXP',
'EXPORT_SET',
'EXTRACT',
'FIELD',
'FIND_IN_SET',
'FLOOR',
'FORMAT',
'FOUND_ROWS',
'FROM_DAYS',
'FROM_UNIXTIME',
'GET_LOCK',
'GREATEST',
'GROUP_UNIQUE_USERS',
'HEX',
'IFNULL',
'INET_ATON',
'INET_NTOA',
'INSTR',
'INTERVAL',
'IS_FREE_LOCK',
'ISNULL',
'LAST_INSERT_ID',
'LCASE',
'LEAST',
'LEFT',
'LENGTH',
'LN',
'LOAD_FILE',
'LOCATE',
'LOG',
'LOG2',
'LOG10',
'LOWER',
'LPAD',
'LTRIM',
'MAKE_SET',
'MASTER_POS_WAIT',
'MAX',
'MD5',
'MID',
'MIN',
'MOD',
'MONTH',
'MONTHNAME',
'NOW',
'NULLIF',
'OCT',
'OCTET_LENGTH',
'ORD',
'PASSWORD',
'PERIOD_ADD',
'PERIOD_DIFF',
'PI',
'POSITION',
'POW',
'POWER',
'QUARTER',
'QUOTE',
'RADIANS',
'RAND',
'RELEASE_LOCK',
'REPEAT',
'REVERSE',
'RIGHT',
'ROUND',
'RPAD',
'RTRIM',
'SEC_TO_TIME',
'SESSION_USER',
'SHA',
'SHA1',
'SIGN',
'SIN',
'SOUNDEX',
'SPACE',
'SQRT',
'STD',
'STDDEV',
'STRCMP',
'SUBDATE',
'SUBSTRING',
'SUBSTRING_INDEX',
'SUM',
'SYSDATE',
'SYSTEM_USER',
'TAN',
'TIME_FORMAT',
'TIME_TO_SEC',
'TO_DAYS',
'TRIM',
'UCASE',
'UNIQUE_USERS',
'UNIX_TIMESTAMP',
'UPPER',
'USER',
'VERSION',
'WEEK',
'WEEKDAY',
'YEAR',
'YEARWEEK'
);
//$PMA_SQPdata_function_name_cnt = count($PMA_SQPdata_function_name);
$PMA_SQPdata_function_name_cnt = 151;
$PMA_SQPdata_column_attrib = array (
'AUTO_INCREMENT',
'BDB',
'BERKELEYDB',
'BINARY',
'DEFAULT',
'INNOBASE',
'INNODB',
'ISAM',
'MRG_MYISAM',
'MYISAM',
'NATIONAL',
'PRECISION',
'UNSIGNED',
'VARYING',
'ZEROFILL'
);
//$PMA_SQPdata_column_attrib_cnt = count($PMA_SQPdata_column_attrib);
$PMA_SQPdata_column_attrib_cnt = 15;
$PMA_SQPdata_column_attrib = array (
'AUTO_INCREMENT',
'BDB',
'BERKELEYDB',
'BINARY',
'DEFAULT',
'INNOBASE',
'INNODB',
'ISAM',
'MRG_MYISAM',
'MYISAM',
'NATIONAL',
'PRECISION',
'UNSIGNED',
'VARYING',
'ZEROFILL'
);
//$PMA_SQPdata_column_attrib_cnt = count($PMA_SQPdata_column_attrib);
$PMA_SQPdata_column_attrib_cnt = 15;
$PMA_SQPdata_reserved_word = array (
'ACTION',
'ADD',
'AFTER',
'AGAINST',
'AGGREGATE',
'ALL',
'ALTER',
'ANALYSE',
'ANALYZE',
'AND',
'AS',
'ASC',
'AUTOCOMMIT',
'AUTO_INCREMENT',
'AVG_ROW_LENGTH',
'BACKUP',
'BEGIN',
'BETWEEN',
'BINLOG',
'BOTH',
'BY',
'CASCADE',
'CASE',
'CHANGE',
'CHANGED',
'CHARSET',
'CHECK',
'CHECKSUM',
'CLIENT',
'COLLATION',
'COLUMN',
'COLUMNS',
'COMMENT',
'COMMIT',
'COMMITTED',
'COMPRESSED',
'CONCURRENT',
'CONSTRAINT',
'CREATE',
'CROSS',
'DATA',
'DATABASE',
'DATABASES',
'DAY',
'DAY_HOUR',
'DAY_MINUTE',
'DAY_SECOND',
'DELAYED',
'DELAY_KEY_WRITE',
'DELETE',
'DESC',
'DESCRIBE',
'DISTINCT',
'DISTINCTROW',
'DIV',
'DO',
'DROP',
'DUMPFILE',
'DYNAMIC',
'ELSE',
'ENCLOSED',
'END',
'ESCAPE',
'ESCAPED',
'EVENTS',
'EXECUTE',
'EXISTS',
'EXPLAIN',
'EXTENDED',
'FAST',
'FIELDS',
'FILE',
'FIRST',
'FIXED',
'FLUSH',
'FOR',
'FOREIGN',
'FROM',
'FULL',
'FULLTEXT',
'FUNCTION',
'GEMINI',
'GEMINI_SPIN_RETRIES',
'GLOBAL',
'GRANT',
'GRANTS',
'GROUP',
'HAVING',
'HEAP',
'HIGH_PRIORITY',
'HOSTS',
'HOUR',
'HOUR_MINUTE',
'HOUR_SECOND',
'IDENTIFIED',
'IF',
'IGNORE',
'IN',
'INDEX',
'INDEXES',
'INFILE',
'INNER',
'INSERT',
'INSERT_ID',
'INSERT_METHOD',
'INTERVAL',
'INTO',
'IS',
'ISOLATION',
'JOIN',
'KEY',
'KEYS',
'KILL',
'LAST_INSERT_ID',
'LEADING',
'LEFT',
'LEVEL',
'LIKE',
'LIMIT',
'LINES',
'LOAD',
'LOCAL',
'LOCK',
'LOCKS',
'LOGS',
'LOW_PRIORITY',
'MASTER',
'MASTER_CONNECT_RETRY',
'MASTER_HOST',
'MASTER_LOG_FILE',
'MASTER_LOG_POS',
'MASTER_PASSWORD',
'MASTER_PORT',
'MASTER_USER',
'MATCH',
'MAX_CONNECTIONS_PER_HOUR',
'MAX_QUERIES_PER_HOUR',
'MAX_ROWS',
'MAX_UPDATES_PER_HOUR',
'MEDIUM',
'MERGE',
'MIN_ROWS',
'MINUTE',
'MINUTE_SECOND',
'MODE',
'MODIFY',
'MONTH',
'MRG_MYISAM',
'MYISAM',
'NATURAL',
// 'NO' is not allowed in SQL-99 but is allowed in MySQL
//'NO',
'NOT',
'NULL',
'ON',
'OPEN',
'OPTIMIZE',
'OPTION',
'OPTIONALLY',
'OR',
'ORDER',
'OUTER',
'OUTFILE',
'PACK_KEYS',
'PARTIAL',
'PASSWORD',
'PRIMARY',
'PRIVILEGES',
'PROCEDURE',
'PROCESS',
'PROCESSLIST',
'PURGE',
'QUICK',
'RAID0',
'RAID_CHUNKS',
'RAID_CHUNKSIZE',
'RAID_TYPE',
'READ',
'REFERENCES',
'REGEXP',
'RELOAD',
'RENAME',
'REPAIR',
'REPEATABLE',
'REPLACE',
'REPLICATION',
'RESET',
'RESTORE',
'RESTRICT',
'RETURNS',
'REVOKE',
'RIGHT',
'RLIKE',
'ROLLBACK',
'ROW',
'ROW_FORMAT',
'ROWS',
'SECOND',
'SELECT',
'SERIALIZABLE',
'SHARE',
'SHOW',
'SHUTDOWN',
'SLAVE',
'SONAME',
'SQL_AUTO_IS_NULL',
'SQL_BIG_RESULT',
'SQL_BIG_SELECTS',
'SQL_BIG_TABLES',
'SQL_BUFFER_RESULT',
'SQL_CACHE',
'SQL_LOG_BIN',
'SQL_LOG_OFF',
'SQL_LOG_UPDATE',
'SQL_LOW_PRIORITY_UPDATES',
'SQL_MAX_JOIN_SIZE',
'SQL_NO_CACHE',
'SQL_QUOTE_SHOW_CREATE',
'SQL_SAFE_UPDATES',
'SQL_SELECT_LIMIT',
'SQL_SLAVE_SKIP_COUNTER',
'SQL_SMALL_RESULT',
'SQL_WARNINGS',
'START',
'STARTING',
'STATUS',
'STOP',
'STRAIGHT_JOIN',
'STRING',
'STRIPED',
'SUPER',
'TABLE',
'TABLES',
'TEMPORARY',
'TERMINATED',
'THEN',
'TO',
'TRAILING',
'TRUNCATE',
'TYPE',
'UNCOMMITTED',
'UNION',
'UNIQUE',
'UNLOCK',
'UPDATE',
'USAGE',
'USE',
'USING',
'VALUES',
'VARIABLES',
'WHEN',
'WHERE',
'WITH',
'WORK',
'WRITE',
'XOR',
'YEAR_MONTH'
);
//$PMA_SQPdata_reserved_word_cnt = count($PMA_SQPdata_reserved_word);
$PMA_SQPdata_reserved_word_cnt = 255;
$PMA_SQPdata_reserved_word = array (
'ACTION',
'ADD',
'AFTER',
'AGAINST',
'AGGREGATE',
'ALL',
'ALTER',
'ANALYSE',
'ANALYZE',
'AND',
'AS',
'ASC',
'AUTOCOMMIT',
'AUTO_INCREMENT',
'AVG_ROW_LENGTH',
'BACKUP',
'BEGIN',
'BETWEEN',
'BINLOG',
'BOTH',
'BY',
'CASCADE',
'CASE',
'CHANGE',
'CHANGED',
'CHARSET',
'CHECK',
'CHECKSUM',
'CLIENT',
'COLLATION',
'COLUMN',
'COLUMNS',
'COMMENT',
'COMMIT',
'COMMITTED',
'COMPRESSED',
'CONCURRENT',
'CONSTRAINT',
'CREATE',
'CROSS',
'DATA',
'DATABASE',
'DATABASES',
'DAY',
'DAY_HOUR',
'DAY_MINUTE',
'DAY_SECOND',
'DELAYED',
'DELAY_KEY_WRITE',
'DELETE',
'DESC',
'DESCRIBE',
'DISTINCT',
'DISTINCTROW',
'DIV',
'DO',
'DROP',
'DUMPFILE',
'DYNAMIC',
'ELSE',
'ENCLOSED',
'END',
'ESCAPE',
'ESCAPED',
'EVENTS',
'EXECUTE',
'EXISTS',
'EXPLAIN',
'EXTENDED',
'FAST',
'FIELDS',
'FILE',
'FIRST',
'FIXED',
'FLUSH',
'FOR',
'FOREIGN',
'FROM',
'FULL',
'FULLTEXT',
'FUNCTION',
'GEMINI',
'GEMINI_SPIN_RETRIES',
'GLOBAL',
'GRANT',
'GRANTS',
'GROUP',
'HAVING',
'HEAP',
'HIGH_PRIORITY',
'HOSTS',
'HOUR',
'HOUR_MINUTE',
'HOUR_SECOND',
'IDENTIFIED',
'IF',
'IGNORE',
'IN',
'INDEX',
'INDEXES',
'INFILE',
'INNER',
'INSERT',
'INSERT_ID',
'INSERT_METHOD',
'INTERVAL',
'INTO',
'IS',
'ISOLATION',
'JOIN',
'KEY',
'KEYS',
'KILL',
'LAST_INSERT_ID',
'LEADING',
'LEFT',
'LEVEL',
'LIKE',
'LIMIT',
'LINES',
'LOAD',
'LOCAL',
'LOCK',
'LOCKS',
'LOGS',
'LOW_PRIORITY',
'MASTER',
'MASTER_CONNECT_RETRY',
'MASTER_HOST',
'MASTER_LOG_FILE',
'MASTER_LOG_POS',
'MASTER_PASSWORD',
'MASTER_PORT',
'MASTER_USER',
'MATCH',
'MAX_CONNECTIONS_PER_HOUR',
'MAX_QUERIES_PER_HOUR',
'MAX_ROWS',
'MAX_UPDATES_PER_HOUR',
'MEDIUM',
'MERGE',
'MIN_ROWS',
'MINUTE',
'MINUTE_SECOND',
'MODE',
'MODIFY',
'MONTH',
'MRG_MYISAM',
'MYISAM',
'NATURAL',
// 'NO' is not allowed in SQL-99 but is allowed in MySQL
//'NO',
'NOT',
'NULL',
'ON',
'OPEN',
'OPTIMIZE',
'OPTION',
'OPTIONALLY',
'OR',
'ORDER',
'OUTER',
'OUTFILE',
'PACK_KEYS',
'PARTIAL',
'PASSWORD',
'PRIMARY',
'PRIVILEGES',
'PROCEDURE',
'PROCESS',
'PROCESSLIST',
'PURGE',
'QUICK',
'RAID0',
'RAID_CHUNKS',
'RAID_CHUNKSIZE',
'RAID_TYPE',
'READ',
'REFERENCES',
'REGEXP',
'RELOAD',
'RENAME',
'REPAIR',
'REPEATABLE',
'REPLACE',
'REPLICATION',
'RESET',
'RESTORE',
'RESTRICT',
'RETURNS',
'REVOKE',
'RIGHT',
'RLIKE',
'ROLLBACK',
'ROW',
'ROW_FORMAT',
'ROWS',
'SECOND',
'SELECT',
'SERIALIZABLE',
'SHARE',
'SHOW',
'SHUTDOWN',
'SLAVE',
'SONAME',
'SQL_AUTO_IS_NULL',
'SQL_BIG_RESULT',
'SQL_BIG_SELECTS',
'SQL_BIG_TABLES',
'SQL_BUFFER_RESULT',
'SQL_CACHE',
'SQL_LOG_BIN',
'SQL_LOG_OFF',
'SQL_LOG_UPDATE',
'SQL_LOW_PRIORITY_UPDATES',
'SQL_MAX_JOIN_SIZE',
'SQL_NO_CACHE',
'SQL_QUOTE_SHOW_CREATE',
'SQL_SAFE_UPDATES',
'SQL_SELECT_LIMIT',
'SQL_SLAVE_SKIP_COUNTER',
'SQL_SMALL_RESULT',
'SQL_WARNINGS',
'START',
'STARTING',
'STATUS',
'STOP',
'STRAIGHT_JOIN',
'STRING',
'STRIPED',
'SUPER',
'TABLE',
'TABLES',
'TEMPORARY',
'TERMINATED',
'THEN',
'TO',
'TRAILING',
'TRUNCATE',
'TYPE',
'UNCOMMITTED',
'UNION',
'UNIQUE',
'UNLOCK',
'UPDATE',
'USAGE',
'USE',
'USING',
'VALUES',
'VARIABLES',
'WHEN',
'WHERE',
'WITH',
'WORK',
'WRITE',
'XOR',
'YEAR_MONTH'
);
//$PMA_SQPdata_reserved_word_cnt = count($PMA_SQPdata_reserved_word);
$PMA_SQPdata_reserved_word_cnt = 255;
$PMA_SQPdata_column_type = array (
'BIGINT',
'BIT',
'BLOB',
'BOOL',
'CHAR',
'CHARACTER',
'DATE',
'DATETIME',
'DEC',
'DECIMAL',
'DOUBLE',
'ENUM',
'FLOAT',
'FLOAT4',
'FLOAT8',
'INT',
'INT1',
'INT2',
'INT3',
'INT4',
'INT8',
'INTEGER',
'LONG',
'LONGBLOB',
'LONGTEXT',
'MEDIUMBLOB',
'MEDIUMINT',
'MEDIUMTEXT',
'MIDDLEINT',
'NCHAR',
'NUMERIC',
'REAL',
'SET',
'SMALLINT',
'TEXT',
'TIME',
'TIMESTAMP',
'TINYBLOB',
'TINYINT',
'TINYTEXT',
'VARBINARY',
'VARCHAR',
'YEAR'
);
//$PMA_SQPdata_column_type_cnt = count($PMA_SQPdata_column_type);
$PMA_SQPdata_column_type_cnt = 43;
$PMA_SQPdata_column_type = array (
'BIGINT',
'BIT',
'BLOB',
'BOOL',
'CHAR',
'CHARACTER',
'DATE',
'DATETIME',
'DEC',
'DECIMAL',
'DOUBLE',
'ENUM',
'FLOAT',
'FLOAT4',
'FLOAT8',
'INT',
'INT1',
'INT2',
'INT3',
'INT4',
'INT8',
'INTEGER',
'LONG',
'LONGBLOB',
'LONGTEXT',
'MEDIUMBLOB',
'MEDIUMINT',
'MEDIUMTEXT',
'MIDDLEINT',
'NCHAR',
'NUMERIC',
'REAL',
'SET',
'SMALLINT',
'TEXT',
'TIME',
'TIMESTAMP',
'TINYBLOB',
'TINYINT',
'TINYTEXT',
'VARBINARY',
'VARCHAR',
'YEAR'
);
//$PMA_SQPdata_column_type_cnt = count($PMA_SQPdata_column_type);
$PMA_SQPdata_column_type_cnt = 43;
} // $__PMA_SQP_DATA__
?>

File diff suppressed because it is too large Load Diff

View File

@@ -30,387 +30,382 @@
* @version $Id$
*/
if (!defined('PMA_SQL_VALIDATOR_CLASS_INCLUDED')) {
define('PMA_SQL_VALIDATOR_CLASS_INCLUDED', 1);
@include_once('SOAP/Client.php');
@include('SOAP/Client.php');
if (!function_exists('class_exists') || !class_exists('SOAP_Client')) {
$GLOBALS['sqlvalidator_error'] = TRUE;
} else {
// Ok, we have SOAP Support, so let's use it!
if (!function_exists('class_exists') || !class_exists('SOAP_Client')) {
$GLOBALS['sqlvalidator_error'] = TRUE;
} else {
// Ok, we have SOAP Support, so let's use it!
class PMA_SQLValidator {
class PMA_SQLValidator {
var $url;
var $service_name;
var $wsdl;
var $output_type;
var $url;
var $service_name;
var $wsdl;
var $output_type;
var $username;
var $password;
var $calling_program;
var $calling_program_version;
var $target_dbms;
var $target_dbms_version;
var $connectionTechnology;
var $connection_technology_version;
var $interactive;
var $username;
var $password;
var $calling_program;
var $calling_program_version;
var $target_dbms;
var $target_dbms_version;
var $connectionTechnology;
var $connection_technology_version;
var $interactive;
var $service_link = NULL;
var $session_data = NULL;
var $service_link = NULL;
var $session_data = NULL;
/**
* Private functions - You don't need to mess with these
*/
/**
* Private functions - You don't need to mess with these
*/
/**
* Service opening
*
* @param string URL of Mimer SQL Validator WSDL file
*
* @return object Object to use
*
* @access private
*/
function _openService($url)
{
$obj = new SOAP_Client($url, TRUE);
return $obj;
} // end of the "openService()" function
/**
* Service opening
*
* @param string URL of Mimer SQL Validator WSDL file
*
* @return object Object to use
*
* @access private
*/
function _openService($url)
{
$obj = new SOAP_Client($url, TRUE);
return $obj;
} // end of the "openService()" function
/**
* Service initializer to connect to server
*
* @param object Service object
* @param string Username
* @param string Password
* @param string Name of calling program
* @param string Version of calling program
* @param string Target DBMS
* @param string Version of target DBMS
* @param string Connection Technology
* @param string version of Connection Technology
* @param integer boolean of 1/0 to specify if we are an interactive system
*
* @return object stdClass return object with data
*
* @access private
*/
function _openSession($obj, $username, $password,
$calling_program, $calling_program_version,
$target_dbms, $target_dbms_version,
$connection_technology, $connection_technology_version,
$interactive)
{
$use_array = array( "a_userName" => $username, "a_password" => $password, "a_callingProgram" => $calling_program, "a_callingProgramVersion" => $calling_program_version, "a_targetDbms" => $target_dbms, "a_targetDbmsVersion" => $target_dbms_version, "a_connectionTechnology" => $connection_technology, "a_connectionTechnologyVersion" => $connection_technology_version, "a_interactive" => $interactive);
$ret = $obj->call("openSession",$use_array);
/**
* Service initializer to connect to server
*
* @param object Service object
* @param string Username
* @param string Password
* @param string Name of calling program
* @param string Version of calling program
* @param string Target DBMS
* @param string Version of target DBMS
* @param string Connection Technology
* @param string version of Connection Technology
* @param integer boolean of 1/0 to specify if we are an interactive system
*
* @return object stdClass return object with data
*
* @access private
*/
function _openSession($obj, $username, $password,
$calling_program, $calling_program_version,
$target_dbms, $target_dbms_version,
$connection_technology, $connection_technology_version,
$interactive)
{
$use_array = array( "a_userName" => $username, "a_password" => $password, "a_callingProgram" => $calling_program, "a_callingProgramVersion" => $calling_program_version, "a_targetDbms" => $target_dbms, "a_targetDbmsVersion" => $target_dbms_version, "a_connectionTechnology" => $connection_technology, "a_connectionTechnologyVersion" => $connection_technology_version, "a_interactive" => $interactive);
$ret = $obj->call("openSession",$use_array);
// This is the old version that needed the overload extension
/* $ret = $obj->openSession($username, $password,
$calling_program, $calling_program_version,
$target_dbms, $target_dbms_version,
$connection_technology, $connection_technology_version,
$interactive); */
// This is the old version that needed the overload extension
/* $ret = $obj->openSession($username, $password,
$calling_program, $calling_program_version,
$target_dbms, $target_dbms_version,
$connection_technology, $connection_technology_version,
$interactive); */
return $ret;
} // end of the "_openSession()" function
return $ret;
} // end of the "_openSession()" function
/**
* Validator sytem call
*
* @param object Service object
* @param object Session object
* @param string SQL Query to validate
* @param string Data return type
*
* @return object stClass return with data
*
* @access private
*/
function _validateSQL($obj, $session, $sql, $method)
{
$use_array = array("a_sessionId" => $session->sessionId, "a_sessionKey" => $session->sessionKey, "a_SQL" => $sql, "a_resultType" => $this->output_type);
$res = $obj->call("validateSQL",$use_array);
/**
* Validator sytem call
*
* @param object Service object
* @param object Session object
* @param string SQL Query to validate
* @param string Data return type
*
* @return object stClass return with data
*
* @access private
*/
function _validateSQL($obj, $session, $sql, $method)
{
$use_array = array("a_sessionId" => $session->sessionId, "a_sessionKey" => $session->sessionKey, "a_SQL" => $sql, "a_resultType" => $this->output_type);
$res = $obj->call("validateSQL",$use_array);
// This is the old version that needed the overload extension
// $res = $obj->validateSQL($session->sessionId, $session->sessionKey, $sql, $this->output_type);
return $res;
} // end of the "validateSQL()" function
// This is the old version that needed the overload extension
// $res = $obj->validateSQL($session->sessionId, $session->sessionKey, $sql, $this->output_type);
return $res;
} // end of the "validateSQL()" function
/**
* Validator sytem call
*
* @param string SQL Query to validate
*
* @return object stdClass return with data
*
* @access private
*
* @see validateSQL()
*/
function _validate($sql)
{
$ret = $this->_validateSQL($this->service_link, $this->session_data,
$sql, $this->output_type);
return $ret;
} // end of the "validate()" function
/**
* Validator sytem call
*
* @param string SQL Query to validate
*
* @return object stdClass return with data
*
* @access private
*
* @see validateSQL()
*/
function _validate($sql)
{
$ret = $this->_validateSQL($this->service_link, $this->session_data,
$sql, $this->output_type);
return $ret;
} // end of the "validate()" function
/**
* Public functions
*/
/**
* Public functions
*/
/**
* Constructor
*
* @access public
*/
function PMA_SQLValidator()
{
$this->url = 'http://sqlvalidator.mimer.com/v1/services';
$this->service_name = 'SQL99Validator';
$this->wsdl = '?wsdl';
/**
* Constructor
*
* @access public
*/
function PMA_SQLValidator()
{
$this->url = 'http://sqlvalidator.mimer.com/v1/services';
$this->service_name = 'SQL99Validator';
$this->wsdl = '?wsdl';
$this->output_type = 'html';
$this->output_type = 'html';
$this->username = 'anonymous';
$this->password = '';
$this->calling_program = 'PHP_SQLValidator';
$this->calling_program_version = '$Revision$';
$this->target_dbms = 'N/A';
$this->target_dbms_version = 'N/A';
$this->connection_technology = 'PHP';
$this->connection_technology_version = phpversion();
$this->interactive = 1;
$this->username = 'anonymous';
$this->password = '';
$this->calling_program = 'PHP_SQLValidator';
$this->calling_program_version = '$Revision$';
$this->target_dbms = 'N/A';
$this->target_dbms_version = 'N/A';
$this->connection_technology = 'PHP';
$this->connection_technology_version = phpversion();
$this->interactive = 1;
$this->service_link = NULL;
$this->session_data = NULL;
} // end of the "PMA_SQLValidator()" function
$this->service_link = NULL;
$this->session_data = NULL;
} // end of the "PMA_SQLValidator()" function
/**
* Sets credentials
*
* @param string the username
* @param string the password
*
* @access public
*/
function setCredentials($username, $password)
{
$this->username = $username;
$this->password = $password;
} // end of the "setCredentials()" function
/**
* Sets credentials
*
* @param string the username
* @param string the password
*
* @access public
*/
function setCredentials($username, $password)
{
$this->username = $username;
$this->password = $password;
} // end of the "setCredentials()" function
/**
* Sets the calling program
*
* @param string the calling program name
* @param string the calling program revision
*
* @access public
*/
function setCallingProgram($calling_program, $calling_program_version)
{
$this->calling_program = $calling_program;
$this->calling_program_version = $calling_program_version;
} // end of the "setCallingProgram()" function
/**
* Sets the calling program
*
* @param string the calling program name
* @param string the calling program revision
*
* @access public
*/
function setCallingProgram($calling_program, $calling_program_version)
{
$this->calling_program = $calling_program;
$this->calling_program_version = $calling_program_version;
} // end of the "setCallingProgram()" function
/**
* Appends the calling program
*
* @param string the calling program name
* @param string the calling program revision
*
* @access public
*/
function appendCallingProgram($calling_program, $calling_program_version)
{
$this->calling_program .= ' - ' . $calling_program;
$this->calling_program_version .= ' - ' . $calling_program_version;
} // end of the "appendCallingProgram()" function
/**
* Appends the calling program
*
* @param string the calling program name
* @param string the calling program revision
*
* @access public
*/
function appendCallingProgram($calling_program, $calling_program_version)
{
$this->calling_program .= ' - ' . $calling_program;
$this->calling_program_version .= ' - ' . $calling_program_version;
} // end of the "appendCallingProgram()" function
/**
* Sets the target DBMS
*
* @param string the target DBMS name
* @param string the target DBMS revision
*
* @access public
*/
function setTargetDbms($target_dbms, $target_dbms_version)
{
$this->target_dbms = $target_dbms;
$this->target_dbms_version = $target_dbms_version;
} // end of the "setTargetDbms()" function
/**
* Sets the target DBMS
*
* @param string the target DBMS name
* @param string the target DBMS revision
*
* @access public
*/
function setTargetDbms($target_dbms, $target_dbms_version)
{
$this->target_dbms = $target_dbms;
$this->target_dbms_version = $target_dbms_version;
} // end of the "setTargetDbms()" function
/**
* Appends the target DBMS
*
* @param string the target DBMS name
* @param string the target DBMS revision
*
* @access public
*/
function appendTargetDbms($target_dbms, $target_dbms_version)
{
$this->target_dbms .= ' - ' . $target_dbms;
$this->target_dbms_version .= ' - ' . $target_dbms_version;
} // end of the "appendTargetDbms()" function
/**
* Appends the target DBMS
*
* @param string the target DBMS name
* @param string the target DBMS revision
*
* @access public
*/
function appendTargetDbms($target_dbms, $target_dbms_version)
{
$this->target_dbms .= ' - ' . $target_dbms;
$this->target_dbms_version .= ' - ' . $target_dbms_version;
} // end of the "appendTargetDbms()" function
/**
* Sets the connection technology used
*
* @param string the connection technology name
* @param string the connection technology revision
*
* @access public
*/
function setConnectionTechnology($connection_technology, $connection_technology_version)
{
$this->connection_technology = $connection_technology;
$this->connection_technology_version = $connection_technology_version;
} // end of the "setConnectionTechnology()" function
/**
* Sets the connection technology used
*
* @param string the connection technology name
* @param string the connection technology revision
*
* @access public
*/
function setConnectionTechnology($connection_technology, $connection_technology_version)
{
$this->connection_technology = $connection_technology;
$this->connection_technology_version = $connection_technology_version;
} // end of the "setConnectionTechnology()" function
/**
* Appends the connection technology used
*
* @param string the connection technology name
* @param string the connection technology revision
*
* @access public
*/
function appendConnectionTechnology($connection_technology, $connection_technology_version)
{
$this->connection_technology .= ' - ' . $connection_technology;
$this->connection_technology_version .= ' - ' . $connection_technology_version;
} // end of the "appendConnectionTechnology()" function
/**
* Appends the connection technology used
*
* @param string the connection technology name
* @param string the connection technology revision
*
* @access public
*/
function appendConnectionTechnology($connection_technology, $connection_technology_version)
{
$this->connection_technology .= ' - ' . $connection_technology;
$this->connection_technology_version .= ' - ' . $connection_technology_version;
} // end of the "appendConnectionTechnology()" function
/**
* Sets whether interactive mode should be used or not
*
* @param integer whether interactive mode should be used or not
*
* @access public
*/
function setInteractive($interactive)
{
$this->interactive = $interactive;
} // end of the "setInteractive()" function
/**
* Sets whether interactive mode should be used or not
*
* @param integer whether interactive mode should be used or not
*
* @access public
*/
function setInteractive($interactive)
{
$this->interactive = $interactive;
} // end of the "setInteractive()" function
/**
* Sets the output type to use
*
* @param string the output type to use
*
* @access public
*/
function setOutputType($output_type)
{
$this->output_type = $output_type;
} // end of the "setOutputType()" function
/**
* Sets the output type to use
*
* @param string the output type to use
*
* @access public
*/
function setOutputType($output_type)
{
$this->output_type = $output_type;
} // end of the "setOutputType()" function
/**
* Starts service
*
* @access public
*/
function startService()
{
/**
* Starts service
*
* @access public
*/
function startService()
{
$this->service_link = $this->_openService($this->url . '/' . $this->service_name . $this->wsdl);
$this->service_link = $this->_openService($this->url . '/' . $this->service_name . $this->wsdl);
} // end of the "startService()" function
} // end of the "startService()" function
/**
* Starts session
*
* @access public
*/
function startSession()
{
$this->session_data = $this->_openSession($this->service_link, $this->username, $this->password,
$this->calling_program, $this->calling_program_version,
$this->target_dbms, $this->target_dbms_version,
$this->connection_technology, $this->connection_technology_version,
$this->interactive);
/**
* Starts session
*
* @access public
*/
function startSession()
{
$this->session_data = $this->_openSession($this->service_link, $this->username, $this->password,
$this->calling_program, $this->calling_program_version,
$this->target_dbms, $this->target_dbms_version,
$this->connection_technology, $this->connection_technology_version,
$this->interactive);
if (isset($this->session_data) && ($this->session_data != NULL)
&& ($this->session_data->target != $this->url)) {
// Reopens the service on the new URL that was provided
$url = $this->session_data->target;
$this->startService();
}
} // end of the "startSession()" function
/**
* Do start service and session
*
* @access public
*/
function start()
{
if (isset($this->session_data) && ($this->session_data != NULL)
&& ($this->session_data->target != $this->url)) {
// Reopens the service on the new URL that was provided
$url = $this->session_data->target;
$this->startService();
$this->startSession();
} // end of the "start()" function
}
} // end of the "startSession()" function
/**
* Call to determine just if a query is valid or not.
*
* @param string SQL statement to validate
*
* @return string Validator string from Mimer
*
* @see _validate
*/
function isValid($sql)
{
$res = $this->_validate($sql);
return $res->standard;
} // end of the "isValid()" function
/**
* Do start service and session
*
* @access public
*/
function start()
{
$this->startService();
$this->startSession();
} // end of the "start()" function
/**
* Call for complete validator response
*
* @param string SQL statement to validate
*
* @return string Validator string from Mimer
*
* @see _validate
*/
function validationString($sql)
{
$res = $this->_validate($sql);
return $res->data;
/**
* Call to determine just if a query is valid or not.
*
* @param string SQL statement to validate
*
* @return string Validator string from Mimer
*
* @see _validate
*/
function isValid($sql)
{
$res = $this->_validate($sql);
return $res->standard;
} // end of the "isValid()" function
} // end of the "validationString()" function
} // end class PMA_SQLValidator
//add an extra check to ensure that the class was defined without errors
if (!class_exists('PMA_SQLValidator')) {
$GLOBALS['sqlvalidator_error'] = TRUE;
}
/**
* Call for complete validator response
*
* @param string SQL statement to validate
*
* @return string Validator string from Mimer
*
* @see _validate
*/
function validationString($sql)
{
$res = $this->_validate($sql);
return $res->data;
} // end else
} // end of the "validationString()" function
} // end class PMA_SQLValidator
} // $__PMA_SQL_VALIDATOR_CLASS__
//add an extra check to ensure that the class was defined without errors
if (!class_exists('PMA_SQLValidator')) {
$GLOBALS['sqlvalidator_error'] = TRUE;
}
} // end else
?>

View File

@@ -32,78 +32,71 @@
*/
if (!defined('PMA_SQL_VALIDATOR_INCLUDED')) {
define('PMA_SQL_VALIDATOR_INCLUDED', 1);
// We need the PEAR libraries, so do a minimum version check first
// I'm not sure if PEAR was available before this point
// For now we actually use a configuration flag
if ($cfg['SQLValidator']['use'] == TRUE) {
// We cannot check && !defined(PMA_SQL_VALIDATOR_CLASS_INCLUDED))
// as it will produce a nasty warning message
include('./libraries/sqlvalidator.class.php');
} // if ($cfg['SQLValidator']['use'] == TRUE)
// We need the PEAR libraries, so do a minimum version check first
// I'm not sure if PEAR was available before this point
// For now we actually use a configuration flag
if ($cfg['SQLValidator']['use'] == TRUE) {
require_once('./libraries/sqlvalidator.class.php');
} // if ($cfg['SQLValidator']['use'] == TRUE)
/**
* This function utilizes the Mimer SQL Validator service
* to validate an SQL query
*
* <http://developer.mimer.com/validator/index.htm>
*
* @param string SQL query to validate
*
* @return string Validator result string
*
* @global array The PMA configuration array
*/
function PMA_validateSQL($sql)
{
global $cfg;
/**
* This function utilizes the Mimer SQL Validator service
* to validate an SQL query
*
* <http://developer.mimer.com/validator/index.htm>
*
* @param string SQL query to validate
*
* @return string Validator result string
*
* @global array The PMA configuration array
*/
function PMA_validateSQL($sql)
{
global $cfg;
$str = '';
$str = '';
if ($cfg['SQLValidator']['use']) {
if (isset($GLOBALS['sqlvalidator_error'])
&& $GLOBALS['sqlvalidator_error']) {
$str = sprintf($GLOBALS['strValidatorError'], '<a href="./Documentation.html#faqsqlvalidator" target="documentation">', '</a>');
} else {
// create new class instance
$srv = new PMA_SQLValidator();
if ($cfg['SQLValidator']['use']) {
if (isset($GLOBALS['sqlvalidator_error'])
&& $GLOBALS['sqlvalidator_error']) {
$str = sprintf($GLOBALS['strValidatorError'], '<a href="./Documentation.html#faqsqlvalidator" target="documentation">', '</a>');
} else {
// create new class instance
$srv = new PMA_SQLValidator();
// Checks for username settings
// The class defaults to anonymous with an empty password
// automatically
if ($cfg['SQLValidator']['username'] != '') {
$srv->setCredentials($cfg['SQLValidator']['username'], $cfg['SQLValidator']['password']);
}
// Identify ourselves to the server properly...
$srv->appendCallingProgram('phpMyAdmin', PMA_VERSION);
// ... and specify what database system we are using
$srv->setTargetDbms('MySQL', PMA_MYSQL_STR_VERSION);
// Log on to service
$srv->start();
// Do service validation
$str = $srv->validationString($sql);
// Checks for username settings
// The class defaults to anonymous with an empty password
// automatically
if ($cfg['SQLValidator']['username'] != '') {
$srv->setCredentials($cfg['SQLValidator']['username'], $cfg['SQLValidator']['password']);
}
} // end if
// Identify ourselves to the server properly...
$srv->appendCallingProgram('phpMyAdmin', PMA_VERSION);
/*
else {
// The service is not available so note that properly
$str = $GLOBALS['strValidatorDisabled'];
} // end if... else...
*/
// ... and specify what database system we are using
$srv->setTargetDbms('MySQL', PMA_MYSQL_STR_VERSION);
// Gives string back to caller
return $str;
} // end of the "PMA_validateSQL()" function
// Log on to service
$srv->start();
} // $__PMA_SQL_VALIDATOR__
// Do service validation
$str = $srv->validationString($sql);
}
} // end if
/*
else {
// The service is not available so note that properly
$str = $GLOBALS['strValidatorDisabled'];
} // end if... else...
*/
// Gives string back to caller
return $str;
} // end of the "PMA_validateSQL()" function
?>

View File

@@ -16,310 +16,305 @@
*/
if (!defined('PMA_STR_LIB_INCLUDED')) {
define('PMA_STR_LIB_INCLUDED', 1);
// This is for handling input better
if (defined('PMA_MULTIBYTE_ENCODING')) {
$GLOBALS['PMA_strlen'] = 'mb_strlen';
$GLOBALS['PMA_strpos'] = 'mb_strpos';
$GLOBALS['PMA_strrpos'] = 'mb_strrpos';
$GLOBALS['PMA_substr'] = 'mb_substr';
} else {
$GLOBALS['PMA_strlen'] = 'strlen';
$GLOBALS['PMA_strpos'] = 'strpos';
$GLOBALS['PMA_strrpos'] = 'strrpos';
$GLOBALS['PMA_substr'] = 'substr';
}
// This is for handling input better
if (defined('PMA_MULTIBYTE_ENCODING')) {
$GLOBALS['PMA_strlen'] = 'mb_strlen';
$GLOBALS['PMA_strpos'] = 'mb_strpos';
$GLOBALS['PMA_strrpos'] = 'mb_strrpos';
$GLOBALS['PMA_substr'] = 'mb_substr';
} else {
$GLOBALS['PMA_strlen'] = 'strlen';
$GLOBALS['PMA_strpos'] = 'strpos';
$GLOBALS['PMA_strrpos'] = 'strrpos';
$GLOBALS['PMA_substr'] = 'substr';
/**
* This checks if a string actually exists inside another string
* We try to do it in a PHP3-portable way.
* We don't care about the position it is in.
*
* @param string string to search for
* @param string string to search in
*
* @return boolean whether the needle is in the haystack or not
*/
function PMA_STR_strInStr($needle, $haystack)
{
// $GLOBALS['PMA_strpos']($haystack, $needle) !== FALSE
// return (is_integer($GLOBALS['PMA_strpos']($haystack, $needle)));
return $GLOBALS['PMA_strpos'](' ' . $haystack, $needle);
} // end of the "PMA_STR_strInStr()" function
/**
* Checks if a given character position in the string is escaped or not
*
* @param string string to check for
* @param integer the character to check for
* @param integer starting position in the string
*
* @return boolean whether the character is escaped or not
*/
function PMA_STR_charIsEscaped($string, $pos, $start = 0)
{
$len = $GLOBALS['PMA_strlen']($string);
// Base case:
// Check for string length or invalid input or special case of input
// (pos == $start)
if (($pos == $start) || ($len <= $pos)) {
return FALSE;
}
$p = $pos - 1;
$escaped = FALSE;
while (($p >= $start) && ($string[$p] == '\\')) {
$escaped = !$escaped;
$p--;
} // end while
/**
* This checks if a string actually exists inside another string
* We try to do it in a PHP3-portable way.
* We don't care about the position it is in.
*
* @param string string to search for
* @param string string to search in
*
* @return boolean whether the needle is in the haystack or not
*/
function PMA_STR_strInStr($needle, $haystack)
{
// $GLOBALS['PMA_strpos']($haystack, $needle) !== FALSE
// return (is_integer($GLOBALS['PMA_strpos']($haystack, $needle)));
return $GLOBALS['PMA_strpos'](' ' . $haystack, $needle);
} // end of the "PMA_STR_strInStr()" function
if ($pos < $start) {
// throw error about strings
}
return $escaped;
} // end of the "PMA_STR_charIsEscaped()" function
/**
* Checks if a given character position in the string is escaped or not
*
* @param string string to check for
* @param integer the character to check for
* @param integer starting position in the string
*
* @return boolean whether the character is escaped or not
*/
function PMA_STR_charIsEscaped($string, $pos, $start = 0)
{
$len = $GLOBALS['PMA_strlen']($string);
// Base case:
// Check for string length or invalid input or special case of input
// (pos == $start)
if (($pos == $start) || ($len <= $pos)) {
return FALSE;
/**
* Checks if a number is in a range
*
* @param integer number to check for
* @param integer lower bound
* @param integer upper bound
*
* @return boolean whether the number is in the range or not
*/
function PMA_STR_numberInRangeInclusive($num, $lower, $upper)
{
return (($num >= $lower) && ($num <= $upper));
} // end of the "PMA_STR_numberInRangeInclusive()" function
/**
* Checks if a character is a digit
*
* @param string character to check for
*
* @return boolean whether the character is a digit or not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isDigit($c)
{
$ord_zero = 48; //ord('0');
$ord_nine = 57; //ord('9');
$ord_c = ord($c);
return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
} // end of the "PMA_STR_isDigit()" function
/**
* Checks if a character is an hexadecimal digit
*
* @param string character to check for
*
* @return boolean whether the character is an hexadecimal digit or not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isHexDigit($c)
{
$ord_Aupper = 65; //ord('A');
$ord_Fupper = 70; //ord('F');
$ord_Alower = 97; //ord('a');
$ord_Flower = 102; //ord('f');
$ord_zero = 48; //ord('0');
$ord_nine = 57; //ord('9');
$ord_c = ord($c);
return (PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_Aupper, $ord_Fupper)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_Alower, $ord_Flower));
} // end of the "PMA_STR_isHexDigit()" function
/**
* Checks if a character is an upper alphabetic one
*
* @param string character to check for
*
* @return boolean whether the character is an upper alphabetic one or
* not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isUpper($c)
{
$ord_zero = 65; //ord('A');
$ord_nine = 90; //ord('Z');
$ord_c = ord($c);
return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
} // end of the "PMA_STR_isUpper()" function
/**
* Checks if a character is a lower alphabetic one
*
* @param string character to check for
*
* @return boolean whether the character is a lower alphabetic one or
* not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isLower($c)
{
$ord_zero = 97; //ord('a');
$ord_nine = 122; //ord('z');
$ord_c = ord($c);
return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
} // end of the "PMA_STR_isLower()" function
/**
* Checks if a character is an alphabetic one
*
* @param string character to check for
*
* @return boolean whether the character is an alphabetic one or not
*
* @see PMA_STR_isUpper()
* @see PMA_STR_isLower()
*/
function PMA_STR_isAlpha($c)
{
return (PMA_STR_isUpper($c) || PMA_STR_isLower($c));
} // end of the "PMA_STR_isAlpha()" function
/**
* Checks if a character is an alphanumeric one
*
* @param string character to check for
*
* @return boolean whether the character is an alphanumeric one or not
*
* @see PMA_STR_isUpper()
* @see PMA_STR_isLower()
* @see PMA_STR_isDigit()
*/
function PMA_STR_isAlnum($c)
{
return (PMA_STR_isUpper($c) || PMA_STR_isLower($c) || PMA_STR_isDigit($c));
} // end of the "PMA_STR_isAlnum()" function
/**
* Checks if a character is a space one
*
* @param string character to check for
*
* @return boolean whether the character is a space one or not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isSpace($c)
{
$ord_space = 32; //ord(' ')
$ord_tab = 9; //ord('\t')
$ord_CR = 13; //ord('\n')
$ord_NOBR = 160; //ord('U+00A0);
$ord_c = ord($c);
return (($ord_c == $ord_space)
|| ($ord_c == $ord_NOBR)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_tab, $ord_CR));
} // end of the "PMA_STR_isSpace()" function
/**
* Checks if a character is an accented character
*
* @note Presently this only works for some character sets. More work
* may be needed to fix it.
*
* @param string character to check for
*
* @return boolean whether the character is an upper alphabetic one or
* not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isAccented($c)
{
$ord_min1 = 192; //ord('A');
$ord_max1 = 214; //ord('Z');
$ord_min2 = 216; //ord('A');
$ord_max2 = 246; //ord('Z');
$ord_min3 = 248; //ord('A');
$ord_max3 = 255; //ord('Z');
$ord_c = ord($c);
return PMA_STR_numberInRangeInclusive($ord_c, $ord_min1, $ord_max1)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_min2, $ord_max2)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_min2, $ord_max2);
} // end of the "PMA_STR_isAccented()" function
/**
* Checks if a character is an SQL identifier
*
* @param string character to check for
* @param boolean whether the dot character is valid or not
*
* @return boolean whether the character is an SQL identifier or not
*
* @see PMA_STR_isAlnum()
*/
function PMA_STR_isSqlIdentifier($c, $dot_is_valid = FALSE)
{
return (PMA_STR_isAlnum($c)
|| PMA_STR_isAccented($c)
|| ($c == '_') || ($c == '$')
|| (($dot_is_valid != FALSE) && ($c == '.')));
} // end of the "PMA_STR_isSqlIdentifier()" function
/**
* Binary search of a value in a sorted array
*
* @param string string to search for
* @param array sorted array to search into
* @param integer size of sorted array to search into
*
* @return boolean whether the string has been found or not
*/
function PMA_STR_binarySearchInArr($str, $arr, $arrsize)
{
// $arr NUST be sorted, due to binary search
$top = $arrsize - 1;
$bottom = 0;
$found = FALSE;
while (($top >= $bottom) && ($found == FALSE)) {
$mid = intval(($top + $bottom) / 2);
$res = strcmp($str, $arr[$mid]);
if ($res == 0) {
$found = TRUE;
} else if ($res < 0) {
$top = $mid - 1;
} else {
$bottom = $mid + 1;
}
} // end while
$p = $pos - 1;
$escaped = FALSE;
while (($p >= $start) && ($string[$p] == '\\')) {
$escaped = !$escaped;
$p--;
} // end while
if ($pos < $start) {
// throw error about strings
}
return $escaped;
} // end of the "PMA_STR_charIsEscaped()" function
/**
* Checks if a number is in a range
*
* @param integer number to check for
* @param integer lower bound
* @param integer upper bound
*
* @return boolean whether the number is in the range or not
*/
function PMA_STR_numberInRangeInclusive($num, $lower, $upper)
{
return (($num >= $lower) && ($num <= $upper));
} // end of the "PMA_STR_numberInRangeInclusive()" function
/**
* Checks if a character is a digit
*
* @param string character to check for
*
* @return boolean whether the character is a digit or not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isDigit($c)
{
$ord_zero = 48; //ord('0');
$ord_nine = 57; //ord('9');
$ord_c = ord($c);
return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
} // end of the "PMA_STR_isDigit()" function
/**
* Checks if a character is an hexadecimal digit
*
* @param string character to check for
*
* @return boolean whether the character is an hexadecimal digit or not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isHexDigit($c)
{
$ord_Aupper = 65; //ord('A');
$ord_Fupper = 70; //ord('F');
$ord_Alower = 97; //ord('a');
$ord_Flower = 102; //ord('f');
$ord_zero = 48; //ord('0');
$ord_nine = 57; //ord('9');
$ord_c = ord($c);
return (PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_Aupper, $ord_Fupper)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_Alower, $ord_Flower));
} // end of the "PMA_STR_isHexDigit()" function
/**
* Checks if a character is an upper alphabetic one
*
* @param string character to check for
*
* @return boolean whether the character is an upper alphabetic one or
* not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isUpper($c)
{
$ord_zero = 65; //ord('A');
$ord_nine = 90; //ord('Z');
$ord_c = ord($c);
return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
} // end of the "PMA_STR_isUpper()" function
/**
* Checks if a character is a lower alphabetic one
*
* @param string character to check for
*
* @return boolean whether the character is a lower alphabetic one or
* not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isLower($c)
{
$ord_zero = 97; //ord('a');
$ord_nine = 122; //ord('z');
$ord_c = ord($c);
return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
} // end of the "PMA_STR_isLower()" function
/**
* Checks if a character is an alphabetic one
*
* @param string character to check for
*
* @return boolean whether the character is an alphabetic one or not
*
* @see PMA_STR_isUpper()
* @see PMA_STR_isLower()
*/
function PMA_STR_isAlpha($c)
{
return (PMA_STR_isUpper($c) || PMA_STR_isLower($c));
} // end of the "PMA_STR_isAlpha()" function
/**
* Checks if a character is an alphanumeric one
*
* @param string character to check for
*
* @return boolean whether the character is an alphanumeric one or not
*
* @see PMA_STR_isUpper()
* @see PMA_STR_isLower()
* @see PMA_STR_isDigit()
*/
function PMA_STR_isAlnum($c)
{
return (PMA_STR_isUpper($c) || PMA_STR_isLower($c) || PMA_STR_isDigit($c));
} // end of the "PMA_STR_isAlnum()" function
/**
* Checks if a character is a space one
*
* @param string character to check for
*
* @return boolean whether the character is a space one or not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isSpace($c)
{
$ord_space = 32; //ord(' ')
$ord_tab = 9; //ord('\t')
$ord_CR = 13; //ord('\n')
$ord_NOBR = 160; //ord('U+00A0);
$ord_c = ord($c);
return (($ord_c == $ord_space)
|| ($ord_c == $ord_NOBR)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_tab, $ord_CR));
} // end of the "PMA_STR_isSpace()" function
/**
* Checks if a character is an accented character
*
* @note Presently this only works for some character sets. More work
* may be needed to fix it.
*
* @param string character to check for
*
* @return boolean whether the character is an upper alphabetic one or
* not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isAccented($c)
{
$ord_min1 = 192; //ord('A');
$ord_max1 = 214; //ord('Z');
$ord_min2 = 216; //ord('A');
$ord_max2 = 246; //ord('Z');
$ord_min3 = 248; //ord('A');
$ord_max3 = 255; //ord('Z');
$ord_c = ord($c);
return PMA_STR_numberInRangeInclusive($ord_c, $ord_min1, $ord_max1)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_min2, $ord_max2)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_min2, $ord_max2);
} // end of the "PMA_STR_isAccented()" function
/**
* Checks if a character is an SQL identifier
*
* @param string character to check for
* @param boolean whether the dot character is valid or not
*
* @return boolean whether the character is an SQL identifier or not
*
* @see PMA_STR_isAlnum()
*/
function PMA_STR_isSqlIdentifier($c, $dot_is_valid = FALSE)
{
return (PMA_STR_isAlnum($c)
|| PMA_STR_isAccented($c)
|| ($c == '_') || ($c == '$')
|| (($dot_is_valid != FALSE) && ($c == '.')));
} // end of the "PMA_STR_isSqlIdentifier()" function
/**
* Binary search of a value in a sorted array
*
* @param string string to search for
* @param array sorted array to search into
* @param integer size of sorted array to search into
*
* @return boolean whether the string has been found or not
*/
function PMA_STR_binarySearchInArr($str, $arr, $arrsize)
{
// $arr NUST be sorted, due to binary search
$top = $arrsize - 1;
$bottom = 0;
$found = FALSE;
while (($top >= $bottom) && ($found == FALSE)) {
$mid = intval(($top + $bottom) / 2);
$res = strcmp($str, $arr[$mid]);
if ($res == 0) {
$found = TRUE;
} else if ($res < 0) {
$top = $mid - 1;
} else {
$bottom = $mid + 1;
}
} // end while
return $found;
} // end of the "PMA_STR_binarySearchInArr()" function
} // $__PMA_STR_LIB__
return $found;
} // end of the "PMA_STR_binarySearchInArr()" function
?>

View File

@@ -6,200 +6,195 @@
* Set of functions used with the relation and pdf feature
*/
function PMA_transformation_getOptions($string) {
$transform_options = array();
if (!defined('PMA_TRANSFORMATION_LIB_INCLUDED')){
define('PMA_TRANSFORMATION_LIB_INCLUDED', 1);
function PMA_transformation_getOptions($string) {
$transform_options = array();
if ($string != '') {
if ($string{0} == "'" && $string{strlen($string)-1} == "'") {
$transform_options = explode('\',\'', substr($string, 1, strlen($string)-2));
} else {
$transform_options = array(0 => $string);
}
}
return $transform_options;
}
/**
* Gets all available MIME-types
*
* @return array array[mimetype], array[transformation]
*
* @access public
*
* @author Garvin Hicking <me@supergarv.de>
*/
function PMA_getAvailableMIMEtypes() {
$handle = opendir('./libraries/transformations');
$stack = array();
$filestack = array();
while (($file = readdir($handle)) != false) {
$filestack[$file] = $file;
}
closedir($handle);
if (is_array($filestack)) {
@ksort($filestack);
foreach($filestack AS $key => $file) {
if (preg_match('|^.*__.*\.inc\.php(3?)$|', trim($file), $match)) {
// File contains transformation functions.
$base = explode('__', str_replace('.inc.php' . $match[1], '', $file));
$mimetype = str_replace('_', '/', $base[0]);
$stack['mimetype'][$mimetype] = $mimetype;
$stack['transformation'][] = $mimetype . ': ' . $base[1];
$stack['transformation_file'][] = $file;
} else if (preg_match('|^.*\.inc\.php(3?)$|', trim($file), $match)) {
// File is a plain mimetype, no functions.
$base = str_replace('.inc.php' . $match[1], '', $file);
if ($base != 'global') {
$mimetype = str_replace('_', '/', $base);
$stack['mimetype'][$mimetype] = $mimetype;
$stack['empty_mimetype'][$mimetype] = $mimetype;
}
}
}
}
return $stack;
}
/**
* Gets the mimetypes for all rows of a table
*
* @param string the name of the db to check for
* @param string the name of the table to check for
* @param string whether to include only results having a mimetype set
*
* @return array [field_name][field_key] = field_value
*
* @global array the list of relations settings
*
* @access public
*
* @author Mike Beck <mikebeck@users.sourceforge.net> / Garvin Hicking <me@supergarv.de>
*/
function PMA_getMIME($db, $table, $strict = false) {
global $cfgRelation;
$com_qry = 'SELECT column_name, mimetype, transformation, transformation_options FROM ' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND (mimetype != \'\'' . (!$strict ? ' OR transformation != \'\' OR transformation_options != \'\'' : '') . ')';
$com_rs = PMA_query_as_cu($com_qry);
while ($row = @PMA_mysql_fetch_array($com_rs)) {
$col = $row['column_name'];
$mime[$col]['mimetype'] = $row['mimetype'];
$mime[$col]['transformation'] = $row['transformation'];
$mime[$col]['transformation_options'] = $row['transformation_options'];
} // end while
if (isset($mime) && is_array($mime)) {
return $mime;
} else {
return FALSE;
}
} // end of the 'PMA_getMIME()' function
/**
* Set a single mimetype to a certain value.
*
* @param string the name of the db
* @param string the name of the table
* @param string the name of the column
* @param string the mimetype of the column
* @param string the transformation of the column
* @param string the transformation options of the column
* @param string (optional) force delete, will erase any existing comments for this column
*
* @return boolean true, if comment-query was made.
*
* @global array the list of relations settings
*
* @access public
*/
function PMA_setMIME($db, $table, $key, $mimetype, $transformation, $transformation_options, $forcedelete = false) {
global $cfgRelation;
$test_qry = 'SELECT mimetype, ' . PMA_backquote('comment') . ' FROM ' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\'';
$test_rs = PMA_query_as_cu($test_qry);
if ($test_rs && mysql_num_rows($test_rs) > 0) {
$row = @PMA_mysql_fetch_array($test_rs);
if (!$forcedelete && (strlen($mimetype) > 0 || strlen($transformation) > 0 || strlen($transformation_options) > 0 || strlen($row['comment']) > 0)) {
$upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_info'])
. ' SET mimetype = \'' . PMA_sqlAddslashes($mimetype) . '\','
. ' transformation = \'' . PMA_sqlAddslashes($transformation) . '\','
. ' transformation_options = \'' . PMA_sqlAddslashes($transformation_options) . '\''
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\'';
} else {
$upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\'';
}
} else if (strlen($mimetype) > 0 || strlen($transformation) > 0 || strlen($transformation_options) > 0) {
$upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['column_info'])
. ' (db_name, table_name, column_name, mimetype, transformation, transformation_options) '
. ' VALUES('
. '\'' . PMA_sqlAddslashes($db) . '\','
. '\'' . PMA_sqlAddslashes($table) . '\','
. '\'' . PMA_sqlAddslashes($key) . '\','
. '\'' . PMA_sqlAddslashes($mimetype) . '\','
. '\'' . PMA_sqlAddslashes($transformation) . '\','
. '\'' . PMA_sqlAddslashes($transformation_options) . '\')';
}
if (isset($upd_query)){
$upd_rs = PMA_query_as_cu($upd_query);
unset($upd_query);
return true;
if ($string != '') {
if ($string{0} == "'" && $string{strlen($string)-1} == "'") {
$transform_options = explode('\',\'', substr($string, 1, strlen($string)-2));
} else {
return false;
$transform_options = array(0 => $string);
}
} // end of 'PMA_setMIME()' function
}
/**
* Returns the real filename of a configured transformation
*
* @param string the current filename
*
* @return string the new filename
*
* @access public
*/
function PMA_sanitizeTransformationFile(&$filename) {
// garvin: for security, never allow to break out from transformations directory
return $transform_options;
}
$include_file = preg_replace('@\.\.*@', '.', $filename);
/**
* Gets all available MIME-types
*
* @return array array[mimetype], array[transformation]
*
* @access public
*
* @author Garvin Hicking <me@supergarv.de>
*/
function PMA_getAvailableMIMEtypes() {
$handle = opendir('./libraries/transformations');
$stack = array();
$filestack = array();
while (($file = readdir($handle)) != false) {
$filestack[$file] = $file;
}
closedir($handle);
if (is_array($filestack)) {
@ksort($filestack);
foreach($filestack AS $key => $file) {
if (preg_match('|^.*__.*\.inc\.php(3?)$|', trim($file), $match)) {
// File contains transformation functions.
$base = explode('__', str_replace('.inc.php' . $match[1], '', $file));
$mimetype = str_replace('_', '/', $base[0]);
$stack['mimetype'][$mimetype] = $mimetype;
$stack['transformation'][] = $mimetype . ': ' . $base[1];
$stack['transformation_file'][] = $file;
} else if (preg_match('|^.*\.inc\.php(3?)$|', trim($file), $match)) {
// File is a plain mimetype, no functions.
$base = str_replace('.inc.php' . $match[1], '', $file);
if ($base != 'global') {
$mimetype = str_replace('_', '/', $base);
$stack['mimetype'][$mimetype] = $mimetype;
$stack['empty_mimetype'][$mimetype] = $mimetype;
}
}
// This value can also contain a 'php3' value, in which case we map this filename to our new 'php' variant
$testfile = preg_replace('@\.inc\.php3$@', '.inc.php', $include_file);
if ($include_file{strlen($include_file)-1} == '3' && file_exists('./libraries/transformations/' . $testfile)) {
$include_file = $testfile;
$filename = $testfile; // Corrects the referenced variable for further actions on the filename;
}
}
return $include_file;
} // end of 'PMA_sanitizeTransformationFile()' function
} // $__PMA_TRANSFORMATION_LIB__
return $stack;
}
/**
* Gets the mimetypes for all rows of a table
*
* @param string the name of the db to check for
* @param string the name of the table to check for
* @param string whether to include only results having a mimetype set
*
* @return array [field_name][field_key] = field_value
*
* @global array the list of relations settings
*
* @access public
*
* @author Mike Beck <mikebeck@users.sourceforge.net> / Garvin Hicking <me@supergarv.de>
*/
function PMA_getMIME($db, $table, $strict = false) {
global $cfgRelation;
$com_qry = 'SELECT column_name, mimetype, transformation, transformation_options FROM ' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND (mimetype != \'\'' . (!$strict ? ' OR transformation != \'\' OR transformation_options != \'\'' : '') . ')';
$com_rs = PMA_query_as_cu($com_qry);
while ($row = @PMA_mysql_fetch_array($com_rs)) {
$col = $row['column_name'];
$mime[$col]['mimetype'] = $row['mimetype'];
$mime[$col]['transformation'] = $row['transformation'];
$mime[$col]['transformation_options'] = $row['transformation_options'];
} // end while
if (isset($mime) && is_array($mime)) {
return $mime;
} else {
return FALSE;
}
} // end of the 'PMA_getMIME()' function
/**
* Set a single mimetype to a certain value.
*
* @param string the name of the db
* @param string the name of the table
* @param string the name of the column
* @param string the mimetype of the column
* @param string the transformation of the column
* @param string the transformation options of the column
* @param string (optional) force delete, will erase any existing comments for this column
*
* @return boolean true, if comment-query was made.
*
* @global array the list of relations settings
*
* @access public
*/
function PMA_setMIME($db, $table, $key, $mimetype, $transformation, $transformation_options, $forcedelete = false) {
global $cfgRelation;
$test_qry = 'SELECT mimetype, ' . PMA_backquote('comment') . ' FROM ' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\'';
$test_rs = PMA_query_as_cu($test_qry);
if ($test_rs && mysql_num_rows($test_rs) > 0) {
$row = @PMA_mysql_fetch_array($test_rs);
if (!$forcedelete && (strlen($mimetype) > 0 || strlen($transformation) > 0 || strlen($transformation_options) > 0 || strlen($row['comment']) > 0)) {
$upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_info'])
. ' SET mimetype = \'' . PMA_sqlAddslashes($mimetype) . '\','
. ' transformation = \'' . PMA_sqlAddslashes($transformation) . '\','
. ' transformation_options = \'' . PMA_sqlAddslashes($transformation_options) . '\''
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\'';
} else {
$upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\'';
}
} else if (strlen($mimetype) > 0 || strlen($transformation) > 0 || strlen($transformation_options) > 0) {
$upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['column_info'])
. ' (db_name, table_name, column_name, mimetype, transformation, transformation_options) '
. ' VALUES('
. '\'' . PMA_sqlAddslashes($db) . '\','
. '\'' . PMA_sqlAddslashes($table) . '\','
. '\'' . PMA_sqlAddslashes($key) . '\','
. '\'' . PMA_sqlAddslashes($mimetype) . '\','
. '\'' . PMA_sqlAddslashes($transformation) . '\','
. '\'' . PMA_sqlAddslashes($transformation_options) . '\')';
}
if (isset($upd_query)){
$upd_rs = PMA_query_as_cu($upd_query);
unset($upd_query);
return true;
} else {
return false;
}
} // end of 'PMA_setMIME()' function
/**
* Returns the real filename of a configured transformation
*
* @param string the current filename
*
* @return string the new filename
*
* @access public
*/
function PMA_sanitizeTransformationFile(&$filename) {
// garvin: for security, never allow to break out from transformations directory
$include_file = preg_replace('@\.\.*@', '.', $filename);
// This value can also contain a 'php3' value, in which case we map this filename to our new 'php' variant
$testfile = preg_replace('@\.inc\.php3$@', '.inc.php', $include_file);
if ($include_file{strlen($include_file)-1} == '3' && file_exists('./libraries/transformations/' . $testfile)) {
$include_file = $testfile;
$filename = $testfile; // Corrects the referenced variable for further actions on the filename;
}
return $include_file;
} // end of 'PMA_sanitizeTransformationFile()' function
?>

View File

@@ -8,23 +8,21 @@
*
* For instructions, read the /Documentation.html file.
*
* The string ENTER_FILENAME_HERE shall be substituted with the filename without the '.inc.php'
* The string [ENTER_FILENAME_HERE] shall be substituted with the filename without the '.inc.php'
* extension. For further information regarding naming conventions see the /Documentation.html file.
*/
if (!defined('PMA_TRANSFORMATION_[ENTER_FILENAME_HERE]')){
define('PMA_TRANSFORMATION_[ENTER_FILENAME_HERE]', 1);
function PMA_transformation_[ENTER_FILENAME_HERE]($buffer, $options = array(), $meta = '') {
// possibly use a global transform and feed it with special options:
// include('./libraries/transformations/global.inc.php');
function PMA_transformation_[enter_filename_here]($buffer, $options = array(), $meta = '') {
// possibly use a global transform and feed it with special options:
// include('./libraries/transformations/global.inc.php');
// further operations on $buffer using the $options[] array.
// further operations on $buffer using the $options[] array.
// You can evaluate the propagated $meta Object. It's contained fields are described in http://www.php.net/mysql_fetch_field.
// This stored information can be used to get the field information about the transformed field.
// $meta->mimetype contains the original MimeType of the field (i.e. 'text/plain', 'image/jpeg' etc.)
// You can evaluate the propagated $meta Object. It's contained fields are described in http://www.php.net/mysql_fetch_field.
// This stored information can be used to get the field information about the transformed field.
// $meta->mimetype contains the original MimeType of the field (i.e. 'text/plain', 'image/jpeg' etc.)
return $buffer;
}
return $buffer;
}
?>

View File

@@ -10,4 +10,4 @@
* You can still use global or other mimetype's transforms with this mimetype.
*/
?>
?>

View File

@@ -23,28 +23,26 @@
*
*/
if (!defined('PMA_TRANSFORMATION_LIB_GLOBAL')){
define('PMA_TRANSFORMATION_LIB_GLOBAL', 1);
function PMA_transformation_global_plain($buffer, $options = array(), $meta = '') {
return htmlspecialchars($buffer);
}
function PMA_transformation_global_html($buffer, $options = array(), $meta = '') {
return $buffer;
}
function PMA_transformation_global_html_replace($buffer, $options = array(), $meta = '') {
if (!isset($options['string'])) {
$options['string'] = '';
}
if (isset($options['regex']) && isset($options['regex_replace'])) {
$buffer = preg_replace('@' . str_replace('@', '\@', $options['regex']) . '@si', $options['regex_replace'], $buffer);
}
// Replace occurences of [__BUFFER__] with actual text
$return = str_replace("[__BUFFER__]", $buffer, $options['string']);
return $return;
}
function PMA_transformation_global_plain($buffer, $options = array(), $meta = '') {
return htmlspecialchars($buffer);
}
function PMA_transformation_global_html($buffer, $options = array(), $meta = '') {
return $buffer;
}
function PMA_transformation_global_html_replace($buffer, $options = array(), $meta = '') {
if (!isset($options['string'])) {
$options['string'] = '';
}
if (isset($options['regex']) && isset($options['regex_replace'])) {
$buffer = preg_replace('@' . str_replace('@', '\@', $options['regex']) . '@si', $options['regex_replace'], $buffer);
}
// Replace occurences of [__BUFFER__] with actual text
$return = str_replace("[__BUFFER__]", $buffer, $options['string']);
return $return;
}
?>

View File

@@ -2,19 +2,17 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
if (!defined('PMA_TRANSFORMATION_IMAGE_JPEG__INLINE')){
define('PMA_TRANSFORMATION_IMAGE_JPEG__INLINE', 1);
function PMA_transformation_image_jpeg__inline($buffer, $options = array(), $meta = '') {
include('./libraries/transformations/global.inc.php');
function PMA_transformation_image_jpeg__inline($buffer, $options = array(), $meta = '') {
include('./libraries/transformations/global.inc.php');
if (PMA_IS_GD2) {
$transform_options = array ('string' => '<a href="transformation_wrapper.php' . $options['wrapper_link'] . '" target="_blank"><img src="transformation_wrapper.php' . $options['wrapper_link'] . '&amp;resize=jpeg&amp;newWidth=' . (isset($options[0]) ? $options[0] : '100') . '&amp;newHeight=' . (isset($options[1]) ? $options[1] : 100) . '" alt="[__BUFFER__]" border="0"></a>');
} else {
$transform_options = array ('string' => '<img src="transformation_wrapper.php' . $options['wrapper_link'] . '" alt="[__BUFFER__]" width="320" height="240">');
}
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);
return $buffer;
if (PMA_IS_GD2) {
$transform_options = array ('string' => '<a href="transformation_wrapper.php' . $options['wrapper_link'] . '" target="_blank"><img src="transformation_wrapper.php' . $options['wrapper_link'] . '&amp;resize=jpeg&amp;newWidth=' . (isset($options[0]) ? $options[0] : '100') . '&amp;newHeight=' . (isset($options[1]) ? $options[1] : 100) . '" alt="[__BUFFER__]" border="0"></a>');
} else {
$transform_options = array ('string' => '<img src="transformation_wrapper.php' . $options['wrapper_link'] . '" alt="[__BUFFER__]" width="320" height="240">');
}
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);
return $buffer;
}
?>

View File

@@ -2,15 +2,13 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
if (!defined('PMA_TRANSFORMATION_IMAGE_JPEG__LINK')){
define('PMA_TRANSFORMATION_IMAGE_JPEG__LINK', 1);
function PMA_transformation_image_jpeg__link($buffer, $options = array(), $meta = '') {
include('./libraries/transformations/global.inc.php');
function PMA_transformation_image_jpeg__link($buffer, $options = array(), $meta = '') {
include('./libraries/transformations/global.inc.php');
$transform_options = array ('string' => '<a href="transformation_wrapper.php' . $options['wrapper_link'] . '" alt="[__BUFFER__]">[BLOB]</a>');
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);
$transform_options = array ('string' => '<a href="transformation_wrapper.php' . $options['wrapper_link'] . '" alt="[__BUFFER__]">[BLOB]</a>');
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);
return $buffer;
}
return $buffer;
}
?>

View File

@@ -2,19 +2,17 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
if (!defined('PMA_TRANSFORMATION_IMAGE_PNG__INLINE')){
define('PMA_TRANSFORMATION_IMAGE_PNG__INLINE', 1);
function PMA_transformation_image_png__inline($buffer, $options = array(), $meta = '') {
include('./libraries/transformations/global.inc.php');
function PMA_transformation_image_png__inline($buffer, $options = array(), $meta = '') {
include('./libraries/transformations/global.inc.php');
if (PMA_IS_GD2) {
$transform_options = array ('string' => '<a href="transformation_wrapper.php' . $options['wrapper_link'] . '" target="_blank"><img src="transformation_wrapper.php' . $options['wrapper_link'] . '&amp;resize=png&amp;newWidth=' . (isset($options[0]) ? $options[0] : '100') . '&amp;newHeight=' . (isset($options[1]) ? $options[1] : 100) . '" alt="[__BUFFER__]" border="0"></a>');
} else {
$transform_options = array ('string' => '<img src="transformation_wrapper.php' . $options['wrapper_link'] . '" alt="[__BUFFER__]" width="320" height="240">');
}
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);
return $buffer;
if (PMA_IS_GD2) {
$transform_options = array ('string' => '<a href="transformation_wrapper.php' . $options['wrapper_link'] . '" target="_blank"><img src="transformation_wrapper.php' . $options['wrapper_link'] . '&amp;resize=png&amp;newWidth=' . (isset($options[0]) ? $options[0] : '100') . '&amp;newHeight=' . (isset($options[1]) ? $options[1] : 100) . '" alt="[__BUFFER__]" border="0"></a>');
} else {
$transform_options = array ('string' => '<img src="transformation_wrapper.php' . $options['wrapper_link'] . '" alt="[__BUFFER__]" width="320" height="240">');
}
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);
return $buffer;
}
?>

View File

@@ -16,17 +16,11 @@ define('PMA_DISPLAY_HEADING', 0);
/**
* Gets some core libraries and displays a top message if required
*/
if (!defined('PMA_GRAB_GLOBALS_INCLUDED')) {
include('./libraries/grab_globals.lib.php');
}
if (!defined('PMA_COMMON_LIB_INCLUDED')) {
include('./libraries/common.lib.php');
}
require('./header.inc.php');
require('./libraries/relation.lib.php');
require('./libraries/transformations.lib.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
require_once('./header.inc.php');
require_once('./libraries/relation.lib.php');
require_once('./libraries/transformations.lib.php');
$cfgRelation = PMA_getRelationsParam();
$types = PMA_getAvailableMIMEtypes();
@@ -78,5 +72,6 @@ foreach($types['transformation'] AS $key => $transform) {
* Displays the footer
*/
echo "\n";
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -2,62 +2,58 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
if (!defined('PMA_TRANSFORMATION_TEXT_PLAIN__DATEFORMAT')){
define('PMA_TRANSFORMATION_TEXT_PLAIN__DATEFORMAT', 1);
function PMA_transformation_text_plain__dateformat($buffer, $options = array(), $meta = '') {
// possibly use a global transform and feed it with special options:
// include('./libraries/transformations/global.inc.php');
function PMA_transformation_text_plain__dateformat($buffer, $options = array(), $meta = '') {
// possibly use a global transform and feed it with special options:
// include('./libraries/transformations/global.inc.php');
// further operations on $buffer using the $options[] array.
if (!isset($options[0]) || $options[0] == '') {
$options[0] = 0;
}
if (!isset($options[1]) || $options[1] == '') {
$options[1] = $GLOBALS['datefmt'];
}
$timestamp = -1;
// Detect TIMESTAMP(6 | 8 | 10 | 12 | 14), (2 | 4) not supported here.
if (preg_match('/^(\d{2}){3,7}$/', $buffer)) {
if (strlen($buffer) == 14 || strlen($buffer) == 8) {
$offset = 4;
} else {
$offset = 2;
}
$d = array();
$d['year'] = substr($buffer, 0, $offset);
$d['month'] = substr($buffer, $offset, 2);
$d['day'] = substr($buffer, $offset + 2, 2);
$d['hour'] = substr($buffer, $offset + 4, 2);
$d['minute'] = substr($buffer, $offset + 6, 2);
$d['second'] = substr($buffer, $offset + 8, 2);
if (checkdate($d['month'], $d['day'], $d['year'])) {
$timestamp = mktime($d['hour'], $d['minute'], $d['second'], $d['month'], $d['day'], $d['year']);
}
// If all fails, assume one of the dozens of valid strtime() syntaxes (http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html)
} else {
$timestamp = strtotime($buffer);
}
// If all above failed, maybe it's a Unix timestamp already?
if ($timestamp < 0 && preg_match('/^[1-9]\d{1,9}$/', $buffer)) {
$timestamp = $buffer;
}
// Reformat a valid timestamp
if ($timestamp >= 0) {
$timestamp -= $options[0] * 60 * 60;
$buffer = PMA_localisedDate($timestamp, $options[1]);
}
return $buffer;
// further operations on $buffer using the $options[] array.
if (!isset($options[0]) || $options[0] == '') {
$options[0] = 0;
}
}
?>
if (!isset($options[1]) || $options[1] == '') {
$options[1] = $GLOBALS['datefmt'];
}
$timestamp = -1;
// Detect TIMESTAMP(6 | 8 | 10 | 12 | 14), (2 | 4) not supported here.
if (preg_match('/^(\d{2}){3,7}$/', $buffer)) {
if (strlen($buffer) == 14 || strlen($buffer) == 8) {
$offset = 4;
} else {
$offset = 2;
}
$d = array();
$d['year'] = substr($buffer, 0, $offset);
$d['month'] = substr($buffer, $offset, 2);
$d['day'] = substr($buffer, $offset + 2, 2);
$d['hour'] = substr($buffer, $offset + 4, 2);
$d['minute'] = substr($buffer, $offset + 6, 2);
$d['second'] = substr($buffer, $offset + 8, 2);
if (checkdate($d['month'], $d['day'], $d['year'])) {
$timestamp = mktime($d['hour'], $d['minute'], $d['second'], $d['month'], $d['day'], $d['year']);
}
// If all fails, assume one of the dozens of valid strtime() syntaxes (http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html)
} else {
$timestamp = strtotime($buffer);
}
// If all above failed, maybe it's a Unix timestamp already?
if ($timestamp < 0 && preg_match('/^[1-9]\d{1,9}$/', $buffer)) {
$timestamp = $buffer;
}
// Reformat a valid timestamp
if ($timestamp >= 0) {
$timestamp -= $options[0] * 60 * 60;
$buffer = PMA_localisedDate($timestamp, $options[1]);
}
return $buffer;
}
?>

View File

@@ -2,64 +2,62 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
if (!defined('PMA_TRANSFORMATION_TEXT_PLAIN__EXTERNAL')){
define('PMA_TRANSFORMATION_TEXT_PLAIN__EXTERNAL', 1);
function PMA_EscapeShellArg($string, $prepend = '\'') {
return $prepend . ereg_replace("'", "'\\''", $string) . $prepend;
}
function PMA_transformation_text_plain__external_nowrap($options = array()) {
if (!isset($options[3]) || $options[3] == '') {
$nowrap = true;
} elseif ($options[3] == '1' || $options[3] == 1) {
$nowrap = true;
} else {
$nowrap = false;
}
return $nowrap;
}
function PMA_transformation_text_plain__external($buffer, $options = array(), $meta = '') {
// possibly use a global transform and feed it with special options:
// include('./libraries/transformations/global.inc.php');
// further operations on $buffer using the $options[] array.
$allowed_programs = array();
$allowed_programs[0] = '/usr/local/bin/tidy';
$allowed_programs[1] = '/usr/local/bin/validate';
if (!isset($options[0]) || $options[0] == '') {
$program = $allowed_programs[0];
} else {
$program = $allowed_programs[$options[0]];
}
if (!isset($options[1]) || $options[1] == '') {
$poptions = '-f /dev/null -i -wrap -q';
} else {
$poptions = $options[1];
}
if (!isset($options[2]) || $options[2] == '') {
$options[2] = 1;
}
if (!isset($options[3]) || $options[3] == '') {
$options[3] = 1;
}
$cmdline = 'echo ' . PMA_EscapeShellArg($buffer) . ' | ' . $program . ' ' . PMA_EscapeShellArg($poptions, '');
$newstring = `$cmdline`;
if ($options[2] == 1 || $options[2] == '2') {
$retstring = htmlspecialchars($newstring);
} else {
$retstring = $newstring;
}
return $retstring;
}
function PMA_EscapeShellArg($string, $prepend = '\'') {
return $prepend . ereg_replace("'", "'\\''", $string) . $prepend;
}
function PMA_transformation_text_plain__external_nowrap($options = array()) {
if (!isset($options[3]) || $options[3] == '') {
$nowrap = true;
} elseif ($options[3] == '1' || $options[3] == 1) {
$nowrap = true;
} else {
$nowrap = false;
}
return $nowrap;
}
function PMA_transformation_text_plain__external($buffer, $options = array(), $meta = '') {
// possibly use a global transform and feed it with special options:
// include('./libraries/transformations/global.inc.php');
// further operations on $buffer using the $options[] array.
$allowed_programs = array();
$allowed_programs[0] = '/usr/local/bin/tidy';
$allowed_programs[1] = '/usr/local/bin/validate';
if (!isset($options[0]) || $options[0] == '') {
$program = $allowed_programs[0];
} else {
$program = $allowed_programs[$options[0]];
}
if (!isset($options[1]) || $options[1] == '') {
$poptions = '-f /dev/null -i -wrap -q';
} else {
$poptions = $options[1];
}
if (!isset($options[2]) || $options[2] == '') {
$options[2] = 1;
}
if (!isset($options[3]) || $options[3] == '') {
$options[3] = 1;
}
$cmdline = 'echo ' . PMA_EscapeShellArg($buffer) . ' | ' . $program . ' ' . PMA_EscapeShellArg($poptions, '');
$newstring = `$cmdline`;
if ($options[2] == 1 || $options[2] == '2') {
$retstring = htmlspecialchars($newstring);
} else {
$retstring = $newstring;
}
return $retstring;
}
?>

View File

@@ -2,10 +2,8 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
if (!defined('PMA_TRANSFORMATION_TEXT_PLAIN__FORMATTED')){
define('PMA_TRANSFORMATION_TEXT_PLAIN__FORMATTED', 1);
function PMA_transformation_text_plain__formatted($buffer, $options = array(), $meta = '') {
return $buffer;
}
function PMA_transformation_text_plain__formatted($buffer, $options = array(), $meta = '') {
return $buffer;
}
?>

View File

@@ -2,14 +2,12 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
if (!defined('PMA_TRANSFORMATION_TEXT_PLAIN__IMAGELINK')){
define('PMA_TRANSFORMATION_TEXT_PLAIN__IMAGELINK', 1);
function PMA_transformation_text_plain__imagelink($buffer, $options = array(), $meta = '') {
include('./libraries/transformations/global.inc.php');
function PMA_transformation_text_plain__imagelink($buffer, $options = array(), $meta = '') {
include('./libraries/transformations/global.inc.php');
$transform_options = array ('string' => '<a href="' . (isset($options[0]) ? $options[0] : '') . $buffer . '" target="_blank"><img src="' . (isset($options[0]) ? $options[0] : '') . $buffer . '" border="0" width="' . (isset($options[1]) ? $options[1] : 100) . '" height="' . (isset($options[2]) ? $options[2] : 50) . '">' . $buffer . '</a>');
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);
return $buffer;
}
$transform_options = array ('string' => '<a href="' . (isset($options[0]) ? $options[0] : '') . $buffer . '" target="_blank"><img src="' . (isset($options[0]) ? $options[0] : '') . $buffer . '" border="0" width="' . (isset($options[1]) ? $options[1] : 100) . '" height="' . (isset($options[2]) ? $options[2] : 50) . '">' . $buffer . '</a>');
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);
return $buffer;
}
?>

View File

@@ -2,19 +2,17 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
if (!defined('PMA_TRANSFORMATION_TEXT_PLAIN__LINK')){
define('PMA_TRANSFORMATION_TEXT_PLAIN__LINK', 1);
function PMA_transformation_text_plain__link($buffer, $options = array(), $meta = '') {
require_once('./libraries/transformations/global.inc.php');
function PMA_transformation_text_plain__link($buffer, $options = array(), $meta = '') {
include('./libraries/transformations/global.inc.php');
// $transform_options = array ('string' => '<a href="' . (isset($options[0]) ? $options[0] : '') . '%1$s" title="' . (isset($options[1]) ? $options[1] : '%1$s') . '">' . (isset($options[1]) ? $options[1] : '%1$s') . '</a>');
// $transform_options = array ('string' => '<a href="' . (isset($options[0]) ? $options[0] : '') . '%1$s" title="' . (isset($options[1]) ? $options[1] : '%1$s') . '">' . (isset($options[1]) ? $options[1] : '%1$s') . '</a>');
$transform_options = array ('string' => '<a href="' . (isset($options[0]) ? $options[0] : '') . $buffer . '" title="' . (isset($options[1]) ? $options[1] : '') . '">' . (isset($options[1]) ? $options[1] : $buffer) . '</a>');
$transform_options = array ('string' => '<a href="' . (isset($options[0]) ? $options[0] : '') . $buffer . '" title="' . (isset($options[1]) ? $options[1] : '') . '">' . (isset($options[1]) ? $options[1] : $buffer) . '</a>');
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);
return $buffer;
return $buffer;
}
}
?>

View File

@@ -2,45 +2,43 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
if (!defined('PMA_TRANSFORMATION_TEXT_PLAIN__SUBSTR')){
define('PMA_TRANSFORMATION_TEXT_PLAIN__SUBSTR', 1);
function PMA_transformation_text_plain__substr($buffer, $options = array(), $meta = '') {
// possibly use a global transform and feed it with special options:
// include('./libraries/transformations/global.inc.php');
function PMA_transformation_text_plain__substr($buffer, $options = array(), $meta = '') {
// possibly use a global transform and feed it with special options:
// include('./libraries/transformations/global.inc.php');
// further operations on $buffer using the $options[] array.
if (!isset($options[0]) || $options[0] == '') {
$options[0] = 0;
}
if (!isset($options[1]) || $options[1] == '') {
$options[1] = 'all';
}
if (!isset($options[2]) || $options[2] == '') {
$options[2] = '...';
}
$newtext = '';
if ($options[1] != 'all') {
$newtext = substr($buffer, $options[0], $options[1]);
} else {
$newtext = substr($buffer, $options[0]);
}
$length = strlen($newtext);
$baselength = strlen($buffer);
if ($length != $baselength) {
if ($options[0] != 0) {
$newtext = $options[2] . $newtext;
}
if (($length + $options[0]) != $baselength) {
$newtext .= $options[2];
}
}
return $newtext;
// further operations on $buffer using the $options[] array.
if (!isset($options[0]) || $options[0] == '') {
$options[0] = 0;
}
if (!isset($options[1]) || $options[1] == '') {
$options[1] = 'all';
}
if (!isset($options[2]) || $options[2] == '') {
$options[2] = '...';
}
$newtext = '';
if ($options[1] != 'all') {
$newtext = substr($buffer, $options[0], $options[1]);
} else {
$newtext = substr($buffer, $options[0]);
}
$length = strlen($newtext);
$baselength = strlen($buffer);
if ($length != $baselength) {
if ($options[0] != 0) {
$newtext = $options[2] . $newtext;
}
if (($length + $options[0]) != $baselength) {
$newtext .= $options[2];
}
}
return $newtext;
}
?>

View File

@@ -8,83 +8,80 @@
*/
if (!defined('PMA_URL_GENERATION_LIB_INCLUDED')){
define('PMA_URL_GENERATION_LIB_INCLUDED', 1);
/**
* Generates text with hidden inputs.
*
* @param string optional database name
* @param string optional table name
* @param int indenting level
*
* @return string string with input fields
*
* @global string the current language
* @global string the current conversion charset
* @global string the current server
* @global array the configuration array
* @global boolean whether recoding is allowed or not
*
* @access public
*
* @author nijel
*/
function PMA_generate_common_hidden_inputs ($db = '', $table = '', $indent = 0)
{
global $lang, $convcharset, $server;
global $cfg, $allow_recoding;
/**
* Generates text with hidden inputs.
*
* @param string optional database name
* @param string optional table name
* @param int indenting level
*
* @return string string with input fields
*
* @global string the current language
* @global string the current conversion charset
* @global string the current server
* @global array the configuration array
* @global boolean whether recoding is allowed or not
*
* @access public
*
* @author nijel
*/
function PMA_generate_common_hidden_inputs ($db = '', $table = '', $indent = 0)
{
global $lang, $convcharset, $server;
global $cfg, $allow_recoding;
$spaces = '';
for ($i = 0; $i < $indent; $i++) {
$spaces .= ' ';
}
$result = $spaces . '<input type="hidden" name="lang" value="' . $lang . '" />' . "\n"
. $spaces . '<input type="hidden" name="server" value="' . $server . '" />' . "\n";
if (isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)
$result .= $spaces . '<input type="hidden" name="convcharset" value="' . $convcharset . '" />' . "\n";
if (!empty($db))
$result .= $spaces . '<input type="hidden" name="db" value="'.htmlspecialchars($db).'" />' . "\n";
if (!empty($table))
$result .= $spaces . '<input type="hidden" name="table" value="'.htmlspecialchars($table).'" />' . "\n";
return $result;
$spaces = '';
for ($i = 0; $i < $indent; $i++) {
$spaces .= ' ';
}
/**
* Generates text with URL parameters.
*
* @param string optional database name
* @param string optional table name
* @param string character to use instead of '&amp;' for deviding
* multiple URL parameters from each other
*
* @return string string with URL parameters
*
* @global string the current language
* @global string the current conversion charset
* @global string the current server
* @global array the configuration array
* @global boolean whether recoding is allowed or not
*
* @access public
*
* @author nijel
*/
function PMA_generate_common_url ($db = '', $table = '', $amp = '&amp;')
{
global $lang, $convcharset, $server;
global $cfg, $allow_recoding;
$result = 'lang=' . $lang
. $amp . 'server=' . $server;
if (isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)
$result .= $amp . 'convcharset=' . $convcharset;
if (!empty($db))
$result .= $amp . 'db='.urlencode($db);
if (!empty($table))
$result .= $amp . 'table='.urlencode($table);
return $result;
}
$result = $spaces . '<input type="hidden" name="lang" value="' . $lang . '" />' . "\n"
. $spaces . '<input type="hidden" name="server" value="' . $server . '" />' . "\n";
if (isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)
$result .= $spaces . '<input type="hidden" name="convcharset" value="' . $convcharset . '" />' . "\n";
if (!empty($db))
$result .= $spaces . '<input type="hidden" name="db" value="'.htmlspecialchars($db).'" />' . "\n";
if (!empty($table))
$result .= $spaces . '<input type="hidden" name="table" value="'.htmlspecialchars($table).'" />' . "\n";
return $result;
}
/**
* Generates text with URL parameters.
*
* @param string optional database name
* @param string optional table name
* @param string character to use instead of '&amp;' for deviding
* multiple URL parameters from each other
*
* @return string string with URL parameters
*
* @global string the current language
* @global string the current conversion charset
* @global string the current server
* @global array the configuration array
* @global boolean whether recoding is allowed or not
*
* @access public
*
* @author nijel
*/
function PMA_generate_common_url ($db = '', $table = '', $amp = '&amp;')
{
global $lang, $convcharset, $server;
global $cfg, $allow_recoding;
$result = 'lang=' . $lang
. $amp . 'server=' . $server;
if (isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)
$result .= $amp . 'convcharset=' . $convcharset;
if (!empty($db))
$result .= $amp . 'db='.urlencode($db);
if (!empty($table))
$result .= $amp . 'table='.urlencode($table);
return $result;
}
?>

View File

@@ -10,12 +10,8 @@ define('PMA_DISPLAY_HEADING', 0);
/**
* Gets some core libraries and displays a top message if required
*/
if (!defined('PMA_GRAB_GLOBALS_INCLUDED')) {
include('./libraries/grab_globals.lib.php');
}
if (!defined('PMA_COMMON_LIB_INCLUDED')) {
include('./libraries/common.lib.php');
}
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']);
@@ -33,7 +29,7 @@ if (isset($table)) {
unset($table);
}
$show_query = '1';
require('./header.inc.php');
require_once('./header.inc.php');
if (isset($message)) {
PMA_showMessage($message);
}
@@ -254,8 +250,7 @@ if ($server > 0) {
} // end elseif
} // end if
} // end while
unset($show_grants_dbname);
unset($show_grants_str);
unset($show_grants_dbname, $show_grants_str);
mysql_free_result($rs_usr);
} // end if
} // end elseif
@@ -550,8 +545,8 @@ if (isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding']
} else {
$selected = '';
}
echo ' ';
echo '<option value="' . $tmpcharset . '"' . $selected . '>' . $tmpcharset . '</option>' . "\n";
echo ' '
. '<option value="' . $tmpcharset . '"' . $selected . '>' . $tmpcharset . '</option>' . "\n";
}
?>
</select>
@@ -634,20 +629,20 @@ if (PMA_PHP_INT_VERSION == 40203 && @extension_loaded('mbstring')) {
*/
if (PMA_PHP_INT_VERSION < 40100) {
echo '<p class="warning">' . sprintf($strUpgrade, 'PHP', '4.1.x') . '</p>' . "\n";
echo '<p class="warning">' . sprintf($strUpgrade, 'PHP', '4.1.0') . '</p>' . "\n";
}
/**
* Warning for old MySQL version
*/
if (PMA_MYSQL_INT_VERSION < 32336) {
echo '<p class="warning">' . sprintf($strUpgrade, 'MySQL', '3.23.36') . '</p>' . "\n";
if (PMA_MYSQL_INT_VERSION < 32332) {
echo '<p class="warning">' . sprintf($strUpgrade, 'MySQL', '3.23.32') . '</p>' . "\n";
}
/**
* Displays the footer
*/
echo "\n";
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -19,8 +19,7 @@ if (!empty($submit_mult)
$what = 'drop_db';
} else if (!empty($selected_tbl)) {
if ($submit_mult == $strPrintView) {
include('./tbl_printview.php');
exit();
require('./tbl_printview.php');
} else {
$selected = $selected_tbl;
switch ($submit_mult) {
@@ -60,8 +59,7 @@ if (!empty($submit_mult)
if ($submit_mult == $strDrop) {
$what = 'drop_fld';
} else {
include('./tbl_alter.php');
exit();
require('./tbl_alter.php');
}
} else {
$what = 'row_delete';
@@ -77,13 +75,13 @@ if (!empty($submit_mult) && !empty($what)) {
$js_to_run = 'functions.js';
unset($message);
if (!empty($table)) {
include('./tbl_properties_common.php');
require('./tbl_properties_common.php');
$url_query .= '&amp;goto=tbl_properties.php&amp;back=tbl_properties.php';
include('./tbl_properties_table_info.php');
require('./tbl_properties_table_info.php');
}
elseif (!empty($db)) {
include('./db_details_common.php');
include('./db_details_db_info.php');
require('./db_details_common.php');
require('./db_details_db_info.php');
}
// Builds the query
$full_query = '';
@@ -168,8 +166,7 @@ if (!empty($submit_mult) && !empty($what)) {
<?php
echo"\n";
include('./footer.inc.php');
exit();
require_once('./footer.inc.php');
} // end if
@@ -179,7 +176,7 @@ if (!empty($submit_mult) && !empty($what)) {
else if ($mult_btn == $strYes) {
if ($query_type == 'drop_db' || $query_type == 'drop_tbl' || $query_type == 'drop_fld') {
include('./libraries/relation_cleanup.lib.php');
require_once('./libraries/relation_cleanup.lib.php');
}
$sql_query = '';
@@ -268,8 +265,7 @@ else if ($mult_btn == $strYes) {
|| $query_type == 'analyze_tbl'
|| $query_type == 'check_tbl'
|| $query_type == 'optimize_tbl') {
include('./sql.php');
exit();
require('./sql.php');
}
}

View File

@@ -6,15 +6,15 @@
/**
* Gets some core libraries
*/
require('./libraries/grab_globals.lib.php');
require('./libraries/common.lib.php');
require('./db_details_common.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
require_once('./db_details_common.php');
/**
* Settings for relation stuff
*/
require('./libraries/relation.lib.php');
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
@@ -29,13 +29,13 @@ $cfgRelation = PMA_getRelationsParam();
if (!$cfgRelation['relwork']) {
echo sprintf($strNotSet, 'relation', 'config.inc.php') . '<br />' . "\n"
. '<a href="./Documentation.html#relation" target="documentation">' . $strDocu . '</a>' . "\n";
exit();
require_once('./footer.inc.php');
}
if (!$cfgRelation['displaywork']) {
echo sprintf($strNotSet, 'table_info', 'config.inc.php') . '<br />' . "\n"
. '<a href="./Documentation.html#table_info" target="documentation">' . $strDocu . '</a>' . "\n";
exit();
require_once('./footer.inc.php');
}
if (!isset($cfgRelation['table_coords'])){
@@ -525,5 +525,5 @@ ToggleDragDrop('pdflayout');
* Displays the footer
*/
echo "\n";
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -11,15 +11,15 @@
/**
* Gets some core scripts
*/
require('./libraries/grab_globals.lib.php');
require('./libraries/common.lib.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
/**
* Settings for relation stuff
*/
require('./libraries/relation.lib.php');
require('./libraries/transformations.lib.php');
require_once('./libraries/relation.lib.php');
require_once('./libraries/transformations.lib.php');
$cfgRelation = PMA_getRelationsParam();
@@ -42,7 +42,7 @@ if (!$cfgRelation['pdfwork']) {
/**
* Gets the "fpdf" libraries and defines the pdf font path
*/
require('./libraries/fpdf/fpdf.php');
require_once('./libraries/fpdf/fpdf.php');
$FPDF_font_path = './libraries/fpdf/font/';
@@ -267,7 +267,7 @@ class PMA_PDF extends FPDF
global $server, $lang, $convcharset, $db;
global $charset, $text_dir, $strRunning, $strDatabase;
include('./header.inc.php');
require_once('./header.inc.php');
echo '<p><b>PDF - '. $GLOBALS['strError'] . '</b></p>' . "\n";
if (!empty($error_message)) {
@@ -281,8 +281,7 @@ class PMA_PDF extends FPDF
. '">' . $GLOBALS['strBack'] . '</a>';
echo "\n";
include('./footer.inc.php');
exit();
require_once('./footer.inc.php');
} // end of the "PMA_PDF_die()" function

View File

@@ -6,8 +6,8 @@
/**
* Gets core libraries and defines some variables
*/
require('./libraries/grab_globals.lib.php');
require('./libraries/common.lib.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
/**

View File

@@ -7,7 +7,7 @@
* Gets the variables sent to this script, retains the db name that may have
* been defined as startup option and include a core library
*/
require('./libraries/grab_globals.lib.php');
require_once('./libraries/grab_globals.lib.php');
if (!empty($db)) {
$db_start = $db;
}
@@ -16,8 +16,8 @@ if (!empty($db)) {
/**
* Gets a core script and starts output buffering work
*/
require('./libraries/common.lib.php');
require('./libraries/ob.lib.php');
require_once('./libraries/common.lib.php');
require_once('./libraries/ob.lib.php');
if ($cfg['OBGzip']) {
$ob_mode = PMA_outBufferModeGet();
if ($ob_mode) {
@@ -29,7 +29,7 @@ if ($cfg['OBGzip']) {
// to a seperate file. It can now be included by header.inc.php,
// queryframe.php, querywindow.php.
include('./libraries/header_http.inc.php');
require_once('./libraries/header_http.inc.php');
/**
* Displays the frame

View File

@@ -7,7 +7,7 @@
* Gets the variables sent to this script, retains the db name that may have
* been defined as startup option and include a core library
*/
require('./libraries/grab_globals.lib.php');
require_once('./libraries/grab_globals.lib.php');
if (!empty($db)) {
$db_start = $db;
}
@@ -16,8 +16,8 @@ if (!empty($db)) {
/**
* Gets a core script and starts output buffering work
*/
require('./libraries/common.lib.php');
require('./libraries/ob.lib.php');
require_once('./libraries/common.lib.php');
require_once('./libraries/ob.lib.php');
if ($cfg['OBGzip']) {
$ob_mode = PMA_outBufferModeGet();
if ($ob_mode) {
@@ -25,7 +25,7 @@ if ($cfg['OBGzip']) {
}
}
require('./libraries/relation.lib.php');
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
/**
@@ -43,8 +43,8 @@ if ($server > 0) {
// to a seperate file. It can now be included by header.inc.php,
// queryframe.php, querywindow.php.
include('./libraries/header_http.inc.php');
include('./libraries/header_meta_style.inc.php');
require_once('./libraries/header_http.inc.php');
require_once('./libraries/header_meta_style.inc.php');
?>
<script type="text/javascript" language="javascript">
@@ -219,7 +219,7 @@ if (!isset($goto)) {
$goto = '';
}
require './libraries/bookmark.lib.php';
require_once './libraries/bookmark.lib.php';
$is_inside_querywindow = TRUE;
require './tbl_query_box.php';

View File

@@ -5,9 +5,9 @@
/**
* Gets some core libraries
*/
require('./libraries/read_dump.lib.php');
require('./libraries/grab_globals.lib.php');
require('./libraries/common.lib.php');
require_once('./libraries/read_dump.lib.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
if (!isset($db)) {
$db = '';
@@ -49,7 +49,7 @@ if (!empty($sql_localfile) && !empty($cfg['UploadDir'])) {
* Bookmark Support: get a query back from bookmark if required
*/
if (!empty($id_bookmark)) {
include('./libraries/bookmark.lib.php');
require_once('./libraries/bookmark.lib.php');
switch ($action_bookmark) {
case 0: // bookmarked query that have to be run
$sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], $id_bookmark);
@@ -150,7 +150,7 @@ if (!$cfg['AllowUserDropDatabase']
// loic1: optimized query
$result = @PMA_mysql_query('USE mysql');
if (PMA_mysql_error()) {
include('./header.inc.php');
require_once('./header.inc.php');
PMA_mysqlDie($strNoDropDatabases, '', '', $err_url);
}
}
@@ -160,7 +160,7 @@ define('PMA_CHK_DROP', 1);
* Store a query as a bookmark before executing it?
*/
if (isset($SQLbookmark) && $sql_query != '') {
include('./libraries/bookmark.lib.php');
require_once('./libraries/bookmark.lib.php');
$bfields = array(
'dbase' => $db,
'user' => $cfg['Bookmark']['user'],
@@ -239,8 +239,7 @@ if ($sql_query != '') {
if (preg_match('@^(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)@i', $sql_query)) {
$reload = 1;
}
include('./sql.php');
exit();
require('./sql.php');
}
// Runs multiple queries
@@ -255,8 +254,7 @@ if ($sql_query != '') {
$complete_query = $sql_query;
$display_query = $sql_query;
$sql_query = $a_sql_query;
include('./sql.php');
exit();
require('./sql.php');
}
$result = PMA_mysql_query($a_sql_query);
@@ -320,7 +318,7 @@ if ($sql_query != '') {
*/
if (isset($my_die)) {
$js_to_run = 'functions.js';
include('./header.inc.php');
require_once('./header.inc.php');
if (is_array($my_die)) {
foreach($my_die AS $key => $die_string) {
PMA_mysqlDie('', $die_string, '', $err_url, FALSE);
@@ -387,7 +385,7 @@ if ($goto == 'db_details.php' || $goto == 'tbl_properties.php') {
$js_to_run = 'functions.js';
}
if ($goto != 'main.php') {
include('./header.inc.php');
require_once('./header.inc.php');
}
$active_page = $goto;
require('./' . $goto);

View File

@@ -64,7 +64,7 @@ cat <<END
Please ensure you have:
1. incremented rc count or version in CVS :
- in libraries/defines_php.lib.php the line
- in libraries/defines.lib.php the line
" define('PMA_VERSION', '$1'); "
- in Documentation.html the 2 lines
" <title>phpMyAdmin $1 - Documentation</title> "
@@ -177,7 +177,7 @@ Todo now:
phpmyadmin-news@lists.sourceforge.net
phpmyadmin-users@lists.sourceforge.net
8. increment rc count or version in CVS :
- in libraries/defines_php.lib.php the line
- in libraries/defines.lib.php the line
" define('PHPMYADMIN_VERSION', '2.2.2-rc1'); "
- in Documentation.html the 2 lines
" <title>phpMyAdmin 2.2.2-rc1 - Documentation</title> "

View File

@@ -28,15 +28,14 @@ echo '<h2>' . "\n"
*/
if (PMA_MYSQL_INT_VERSION < 40100) {
// TODO: Some nice Message :-)
include('./footer.inc.php');
exit;
require_once('./footer.inc.php');
}
/**
* Includes the required charset library
*/
require('./libraries/mysql_charsets.lib.php');
require_once('./libraries/mysql_charsets.lib.php');
/**
@@ -101,6 +100,6 @@ echo ' </table>' . "\n"
. ' </tr>' . "\n"
. '</table>' . "\n";
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -5,22 +5,13 @@
/**
* Gets some core libraries
*/
if (!defined('PMA_GRAB_GLOBALS_INCLUDED')) {
include('./libraries/grab_globals.lib.php');
}
if (!defined('PMA_COMMON_LIB_INCLUDED')) {
include('./libraries/common.lib.php');
}
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
/**
* Handles some variables that may have been sent by the calling script
*/
if (isset($db)) {
unset($db);
}
if (isset($table)) {
unset($table);
}
unset($db, $table);
/**
* Set parameters for links
@@ -35,7 +26,7 @@ $err_url = 'main.php' . $url_query;
/**
* Displays the headers
*/
require('./header.inc.php');
require_once('./header.inc.php');
/**
* Checks for superuser privileges

View File

@@ -6,7 +6,7 @@
/**
* Checks if the left frame has to be reloaded
*/
require('./libraries/grab_globals.lib.php');
require_once('./libraries/grab_globals.lib.php');
/**
@@ -74,7 +74,7 @@ if ((!empty($drop_selected_dbs) || isset($query_type)) && ($is_superuser || $cfg
$action = 'server_databases.php';
$submit_mult = 'drop_db' ;
$err_url = 'server_databases.php?' . PMA_generate_common_url();
include('./mult_submits.inc.php');
require('./mult_submits.inc.php');
$message = sprintf($strDatabasesDropped, count($selected));
// we need to reload the database list now.
PMA_availableDatabases();
@@ -102,8 +102,7 @@ echo '<h2>' . "\n"
*/
if (!empty($dbstats) && !$is_superuser) {
echo $strNoPrivileges . "\n";
include('./footer.inc.php');
exit;
require_once('./footer.inc.php');
}
@@ -373,6 +372,6 @@ if (count($statistics) > 0) {
/**
* Sends the footer
*/
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -6,7 +6,7 @@
/**
* Checks if the left frame has to be reloaded
*/
require('./libraries/grab_globals.lib.php');
require_once('./libraries/grab_globals.lib.php');
/**
@@ -62,11 +62,11 @@ $multi_values .= '<br />
<br /><br />';
$export_type = 'server';
require('./libraries/display_export.lib.php');
require_once('./libraries/display_export.lib.php');
/**
* Displays the footer
*/
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -4,9 +4,7 @@
// Check parameters
if (!defined('PMA_COMMON_LIB_INCLUDED')) {
include('./libraries/common.lib.php');
}
require_once('./libraries/common.lib.php');
PMA_checkParameters(array('is_superuser', 'url_query'));
/**

View File

@@ -27,13 +27,12 @@ if (!empty($pred_tablename)) {
* Checks if the user is allowed to do what he tries to...
*/
if (!$is_superuser) {
include('./server_links.inc.php');
require('./server_links.inc.php');
echo '<h2>' . "\n"
. ' ' . $strPrivileges . "\n"
. '</h2>' . "\n"
. $strNoPrivileges . "\n";
include('./footer.inc.php');
exit;
require_once('./footer.inc.php');
}
@@ -1021,8 +1020,7 @@ if (empty($adduser) && empty($checkprivs)) {
$res = PMA_mysql_query('SELECT "foo" FROM `user` WHERE `User` = "' . PMA_sqlAddslashes($username) . '" AND `Host` = "' . $hostname . '";', $userlink);
if (mysql_affected_rows($userlink) <= 0) {
echo $strUserNotFound;
include('./footer.inc.php');
exit;
require_once('./footer.inc.php');
}
mysql_free_result($res);
unset($res);
@@ -1427,6 +1425,6 @@ if (empty($adduser) && empty($checkprivs)) {
* Displays the footer
*/
echo "\n\n";
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -6,7 +6,7 @@
/**
* Does the common work
*/
require('./server_common.inc.php');
require_once('./server_common.inc.php');
/**
@@ -94,6 +94,6 @@ foreach($serverProcesses AS $name => $value) {
/**
* Sends the footer
*/
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -29,8 +29,7 @@ if (!empty($innodbstatus)) {
. htmlspecialchars($row[0]) . "\n"
. '</pre>' . "\n";
mysql_free_result($res);
include('./footer.inc.php');
exit;
require_once('./footer.inc.php');
}
/**
@@ -46,8 +45,7 @@ echo '<h2>' . "\n"
*/
if (!$is_superuser && !$cfg['ShowMysqlInfo']) {
echo $strNoPrivileges;
include('./footer.inc.php');
exit;
require_once('./footer.inc.php');
}
@@ -301,6 +299,6 @@ if ($res) {
/**
* Sends the footer
*/
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -28,8 +28,7 @@ echo '<h2>' . "\n"
*/
if (!$is_superuser && !$cfg['ShowMysqlVars']) {
echo $strNoPrivileges;
include('./footer.inc.php');
exit;
require_once('./footer.inc.php');
}
@@ -108,6 +107,6 @@ foreach ($serverVars as $name => $value) {
/**
* Sends the footer
*/
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

38
sql.php
View File

@@ -5,8 +5,8 @@
/**
* Gets some core libraries
*/
require('./libraries/grab_globals.lib.php');
require('./libraries/common.lib.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
/**
@@ -61,7 +61,7 @@ if (!defined('PMA_CHK_DROP')
// loic1: optimized query
$result = @PMA_mysql_query('USE mysql');
if (PMA_mysql_error()) {
include('./header.inc.php');
require_once('./header.inc.php');
PMA_mysqlDie($strNoDropDatabases, '', '', $err_url);
} // end if
} // end if
@@ -71,7 +71,7 @@ if (!defined('PMA_CHK_DROP')
* Bookmark add
*/
if (isset($store_bkm)) {
include('./libraries/bookmark.lib.php');
require_once('./libraries/bookmark.lib.php');
PMA_addBookmarks($fields, $cfg['Bookmark'], (isset($bkm_all_users) && $bkm_all_users == 'true' ? true : false));
header('Location: ' . $cfg['PmaAbsoluteUri'] . $goto);
} // end if
@@ -151,7 +151,7 @@ if (isset($btnDrop) && $btnDrop == $strNo) {
unset($table);
}
$active_page = $goto;
include('./' . preg_replace('@\.\.*@', '.', $goto));
require('./' . preg_replace('@\.\.*@', '.', $goto));
} else {
header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto));
}
@@ -187,7 +187,7 @@ if (!$cfg['Confirm']
if ($do_confirm) {
$stripped_sql_query = $sql_query;
include('./header.inc.php');
require_once('./header.inc.php');
echo $strDoYouReally . '&nbsp;:<br />' . "\n";
echo '<tt>' . htmlspecialchars($stripped_sql_query) . '</tt>&nbsp;?<br/>' . "\n";
?>
@@ -324,7 +324,7 @@ else {
// Displays an error message if required and stop parsing the script
if (PMA_mysql_error()) {
$error = PMA_mysql_error();
include('./header.inc.php');
require_once('./header.inc.php');
$full_err_url = (preg_match('@^(db_details|tbl_properties)@', $err_url))
? $err_url . '&amp;show_query=1&amp;sql_query=' . urlencode($sql_query)
: $err_url;
@@ -498,7 +498,7 @@ else {
// garvin: if a table or database gets dropped, check column comments.
if (isset($purge) && $purge == '1') {
include('./libraries/relation_cleanup.lib.php');
require_once('./libraries/relation_cleanup.lib.php');
if (isset($table) && isset($db) && !empty($table) && !empty($db)) {
PMA_relationsCleanupTable($db, $table);
@@ -513,7 +513,7 @@ else {
if (isset($cpurge) && $cpurge == '1' && isset($purgekey)
&& isset($db) && isset($table)
&& !empty($db) && !empty($table) && !empty($purgekey)) {
include('./libraries/relation_cleanup.lib.php');
require_once('./libraries/relation_cleanup.lib.php');
PMA_relationsCleanupColumn($db, $table, $purgekey);
} // end if column PMA_* purge
@@ -585,10 +585,10 @@ else {
$js_to_run = 'functions.js';
}
if ($goto != 'main.php') {
include('./header.inc.php');
require_once('./header.inc.php');
}
$active_page = $goto;
include('./' . $goto);
require('./' . $goto);
} // end if file_exist
else {
header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto) . '&message=' . urlencode($message));
@@ -603,22 +603,22 @@ else {
unset($show_query);
}
if (isset($printview) && $printview == '1') {
include('./header_printview.inc.php');
require_once('./header_printview.inc.php');
} else {
$js_to_run = 'functions.js';
unset($message);
if (!empty($table)) {
include('./tbl_properties_common.php');
require('./tbl_properties_common.php');
$url_query .= '&amp;goto=tbl_properties.php&amp;back=tbl_properties.php';
include('./tbl_properties_table_info.php');
require('./tbl_properties_table_info.php');
}
else {
include('./db_details_common.php');
include('./db_details_db_info.php');
require('./db_details_common.php');
require('./db_details_db_info.php');
}
}
include('./libraries/relation.lib.php');
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
// Gets the list of fields properties
@@ -641,7 +641,7 @@ else {
}
// Displays the results in a table
include('./libraries/display_tbl.lib.php');
require_once('./libraries/display_tbl.lib.php');
if (empty($disp_mode)) {
// see the "PMA_setDisplayMode()" function in
// libraries/display_tbl.lib.php
@@ -786,5 +786,5 @@ echo "\n\n";
/**
* Displays the footer
*/
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -6,9 +6,9 @@
/**
* Get some core libraries
*/
require('./libraries/grab_globals.lib.php');
require_once('./libraries/grab_globals.lib.php');
$js_to_run = 'functions.js';
require('./header.inc.php');
require_once('./header.inc.php');
// Check parameters
PMA_checkParameters(array('db', 'table'));
@@ -183,8 +183,8 @@ if (isset($submit)) {
} // end if
// garvin: If comments were sent, enable relation stuff
require('./libraries/relation.lib.php');
require('./libraries/transformations.lib.php');
require_once('./libraries/relation.lib.php');
require_once('./libraries/transformations.lib.php');
$cfgRelation = PMA_getRelationsParam();
@@ -207,8 +207,7 @@ if (isset($submit)) {
unset($sql_query_cpy);
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered;
$active_page = 'tbl_properties_structure.php';
include('./tbl_properties_structure.php');
exit();
require('./tbl_properties_structure.php');
} else {
PMA_mysqlDie('', '', '', $err_url, FALSE);
// garvin: An error happened while inserting/updating a table definition.
@@ -227,11 +226,11 @@ if (isset($submit)) {
*/
if ($abort == FALSE) {
$action = 'tbl_addfield.php';
include('./tbl_properties.inc.php');
require('./tbl_properties.inc.php');
// Diplays the footer
echo "\n";
include('./footer.inc.php');
require_once('./footer.inc.php');
}
?>

View File

@@ -6,9 +6,9 @@
/**
* Gets some core libraries
*/
require('./libraries/grab_globals.lib.php');
require_once('./libraries/grab_globals.lib.php');
$js_to_run = 'functions.js';
include('./header.inc.php');
require_once('./header.inc.php');
// Check parameters
PMA_checkParameters(array('db', 'table'));
@@ -84,8 +84,8 @@ if (isset($submit)) {
$btnDrop = 'Fake';
// garvin: If comments were sent, enable relation stuff
require('./libraries/relation.lib.php');
require('./libraries/transformations.lib.php');
require_once('./libraries/relation.lib.php');
require_once('./libraries/transformations.lib.php');
$cfgRelation = PMA_getRelationsParam();
@@ -142,8 +142,7 @@ if (isset($submit)) {
}
$active_page = 'tbl_properties_structure.php';
include('./tbl_properties_structure.php');
exit();
require('./tbl_properties_structure.php');
} else {
PMA_mysqlDie('', '', '', $err_url, FALSE);
// garvin: An error happened while inserting/updating a table definition.
@@ -184,12 +183,12 @@ if ($abort == FALSE) {
$num_fields = count($fields_meta);
$action = 'tbl_alter.php';
include('./tbl_properties.inc.php');
require('./tbl_properties.inc.php');
}
/**
* Displays the footer
*/
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -6,10 +6,10 @@
/**
* Get the variables sent or posted to this script and displays the header
*/
require('./libraries/grab_globals.lib.php');
require_once('./libraries/grab_globals.lib.php');
$js_to_run = 'tbl_change.js';
require('./header.inc.php');
require('./libraries/relation.lib.php'); // foreign keys
require_once('./header.inc.php');
require_once('./libraries/relation.lib.php'); // foreign keys
/**
@@ -453,7 +453,7 @@ for ($i = 0; $i < $fields_cnt; $i++) {
// The value column (depends on type)
// ----------------
include('./libraries/get_foreign.lib.php');
require('./libraries/get_foreign.lib.php');
if (isset($foreign_link) && $foreign_link == true) {
?>
@@ -780,5 +780,5 @@ if (!empty($disp_message)) {
* Displays the footer
*/
echo "\n";
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -6,15 +6,13 @@
/**
* Get some core libraries
*/
require('./libraries/grab_globals.lib.php');
require_once('./libraries/grab_globals.lib.php');
$js_to_run = 'functions.js';
require('./header.inc.php');
require_once('./header.inc.php');
// Check parameters
if (!defined('PMA_COMMON_LIB_INCLUDED')) {
include('./libraries/common.lib.php');
}
require_once('./libraries/common.lib.php');
PMA_checkParameters(array('db', 'table'));
@@ -185,8 +183,8 @@ if (isset($submit)) {
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenCreated;
// garvin: If comments were sent, enable relation stuff
require('./libraries/relation.lib.php');
require('./libraries/transformations.lib.php');
require_once('./libraries/relation.lib.php');
require_once('./libraries/transformations.lib.php');
$cfgRelation = PMA_getRelationsParam();
@@ -204,7 +202,7 @@ if (isset($submit)) {
}
}
include('./' . $cfg['DefaultTabTable']);
require('./' . $cfg['DefaultTabTable']);
$abort = TRUE;
exit();
} else {
@@ -235,10 +233,10 @@ if ($abort == FALSE) {
// Table name and number of fields are valid -> show the form
else {
$action = 'tbl_create.php';
include('./tbl_properties.inc.php');
require('./tbl_properties.inc.php');
// Diplays the footer
echo "\n";
include('./footer.inc.php');
require_once('./footer.inc.php');
}
}

View File

@@ -6,12 +6,8 @@
/**
* Gets some core libraries
*/
if (!defined('PMA_GRAB_GLOBALS_INCLUDED')) {
include('./libraries/grab_globals.lib.php');
}
if (!defined('PMA_COMMON_LIB_INCLUDED')) {
include('./libraries/common.lib.php');
}
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
/**
@@ -37,7 +33,7 @@ if (!defined('PMA_IDX_INCLUDED')) {
}
if (empty($db) || !$is_db) {
header('Location: ' . $cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
exit();
exit;
}
// Not a valid table name -> back to the default db_details sub-page
if (!empty($table)) {
@@ -46,14 +42,14 @@ if (!defined('PMA_IDX_INCLUDED')) {
if (empty($table)
|| !($is_table && @mysql_numrows($is_table))) {
header('Location: ' . $cfg['PmaAbsoluteUri'] . $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db, '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
exit();
exit;
} else if (isset($is_table)) {
mysql_free_result($is_table);
}
// Displays headers (if needed)
$js_to_run = ((isset($index) && isset($do_save_data)) ? 'functions.js' : 'indexes.js');
include('./header.inc.php');
require_once('./header.inc.php');
} // end if
@@ -209,8 +205,7 @@ if (!defined('PMA_IDX_INCLUDED')
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered;
$active_page = 'tbl_properties_structure.php';
include('./tbl_properties_structure.php');
exit();
require('./tbl_properties_structure.php');
} // end builds the new index
@@ -504,6 +499,6 @@ else if (!defined('PMA_IDX_INCLUDED')
echo "\n";
if (!defined('PMA_IDX_INCLUDED')){
include('./footer.inc.php');
require_once('./footer.inc.php');
}
?>

View File

@@ -4,11 +4,8 @@
// Check parameters
require('./libraries/grab_globals.lib.php');
if (!defined('PMA_COMMON_LIB_INCLUDED')) {
include('./libraries/common.lib.php');
}
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
PMA_checkParameters(array('db', 'table'));
@@ -107,8 +104,8 @@ global $cfgRelation;
/**
* Gets some core libraries
*/
require('./libraries/grab_globals.lib.php');
require('./libraries/common.lib.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php');
/**
@@ -150,7 +147,7 @@ if (isset($new_name) && trim($new_name) != '') {
// do not create the table if dataonly
if ($what != 'dataonly') {
include('./libraries/export/sql.php');
require('./libraries/export/sql.php');
$no_constraints_comments = true;
$sql_structure = PMA_getTableDef($db, $table, "\n", $err_url);
@@ -174,7 +171,7 @@ if (isset($new_name) && trim($new_name) != '') {
$drop_query = 'DROP TABLE IF EXISTS ' . PMA_backquote($target_db) . '.' . PMA_backquote($new_name);
$result = @PMA_mysql_query($drop_query);
if (PMA_mysql_error()) {
include('./header.inc.php');
require_once('./header.inc.php');
PMA_mysqlDie('', $sql_structure, '', $err_url);
}
@@ -191,7 +188,7 @@ if (isset($new_name) && trim($new_name) != '') {
$result = @PMA_mysql_query($sql_structure);
if (PMA_mysql_error()) {
include('./header.inc.php');
require_once('./header.inc.php');
PMA_mysqlDie('', $sql_structure, '', $err_url);
} else if (isset($sql_query)) {
$sql_query .= "\n" . $sql_structure . ';';
@@ -212,7 +209,7 @@ if (isset($new_name) && trim($new_name) != '') {
$sql_constraints = PMA_SQP_formatHtml($parsed_sql, 'query_only');
$result = @PMA_mysql_query($sql_constraints);
if (PMA_mysql_error()) {
include('./header.inc.php');
require_once('./header.inc.php');
PMA_mysqlDie('', $sql_structure, '', $err_url);
} else if (isset($sql_query)) {
$sql_query .= "\n" . $sql_constraints;
@@ -230,13 +227,13 @@ if (isset($new_name) && trim($new_name) != '') {
$sql_insert_data = 'INSERT INTO ' . $target . ' SELECT * FROM ' . $source;
$result = @PMA_mysql_query($sql_insert_data);
if (PMA_mysql_error()) {
include('./header.inc.php');
require_once('./header.inc.php');
PMA_mysqlDie('', $sql_insert_data, '', $err_url);
}
$sql_query .= "\n\n" . $sql_insert_data . ';';
}
include('./libraries/relation.lib.php');
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
// Drops old table if the user has requested to move it
@@ -249,7 +246,7 @@ if (isset($new_name) && trim($new_name) != '') {
$sql_drop_table = 'DROP TABLE ' . $source;
$result = @PMA_mysql_query($sql_drop_table);
if (PMA_mysql_error()) {
include('./header.inc.php');
require_once('./header.inc.php');
PMA_mysqlDie('', $sql_drop_table, '', $err_url);
}
@@ -431,7 +428,7 @@ if (isset($new_name) && trim($new_name) != '') {
}
}
}
include('./header.inc.php');
require_once('./header.inc.php');
} // end is target table name
@@ -439,7 +436,7 @@ if (isset($new_name) && trim($new_name) != '') {
* No new name for the table!
*/
else {
include('./header.inc.php');
require_once('./header.inc.php');
PMA_mysqlDie($strTableEmpty, '', '', $err_url);
}

View File

@@ -6,8 +6,8 @@
* Gets the variables sent or posted to this script, then displays headers
*/
if (!isset($selected_tbl)) {
include('./libraries/grab_globals.lib.php');
include('./header.inc.php');
require_once('./libraries/grab_globals.lib.php');
require_once('./header.inc.php');
}
// Check parameters
@@ -19,8 +19,8 @@ if (!isset($the_tables) || !is_array($the_tables)) {
/**
* Gets the relations settings
*/
require('./libraries/relation.lib.php');
require('./libraries/transformations.lib.php');
require_once('./libraries/relation.lib.php');
require_once('./libraries/transformations.lib.php');
$cfgRelation = PMA_getRelationsParam();
@@ -632,5 +632,5 @@ function printPage()
<?php
echo '<br /><br />&nbsp;<input type="button" style="visibility: ; width: 100px; height: 25px" id="print" value="' . $strPrint . '" onclick="printPage()">' . "\n";
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

View File

@@ -3,18 +3,12 @@
// vim: expandtab sw=4 ts=4 sts=4:
// Check parameters
if (!defined('PMA_COMMON_LIB_INCLUDED')) {
include('./libraries/common.lib.php');
}
require_once('./libraries/common.lib.php');
PMA_checkParameters(array('db','table','action','num_fields'));
// Get available character sets (MySQL >= 4.1)
if (PMA_MYSQL_INT_VERSION >= 40100 && !defined('PMA_MYSQL_CHARSETS_LIB_INCLUDED')) {
include('./libraries/mysql_charsets.lib.php');
}
// Get available character sets
require_once('./libraries/mysql_charsets.lib.php');
?>
<?php if ($cfg['CtrlArrowsMoving']) { ?>
@@ -98,8 +92,8 @@ $header_cells[] = $strNull;
$header_cells[] = $strDefault . '**';
$header_cells[] = $strExtra;
require('./libraries/relation.lib.php');
require('./libraries/transformations.lib.php');
require_once('./libraries/relation.lib.php');
require_once('./libraries/transformations.lib.php');
$cfgRelation = PMA_getRelationsParam();
$comments_map = array();

View File

@@ -35,5 +35,5 @@ require('./tbl_query_box.php');
* Displays the footer
*/
echo "\n";
require('./footer.inc.php');
require_once('./footer.inc.php');
?>

Some files were not shown because too many files have changed in this diff Show More