(not complete) PEAR coding standard

This commit is contained in:
Sebastian Mendel
2006-01-17 17:03:02 +00:00
parent 9518c45bdf
commit 0ae8842353
97 changed files with 4447 additions and 3950 deletions

View File

@@ -17,6 +17,7 @@ $Source$
- clarified some variable names - clarified some variable names
* db_sarch.php: * db_sarch.php:
fixed bug: Undefined variable: num_tables fixed bug: Undefined variable: num_tables
* [really much files]: (not complete) PEAR coding standard
2006-01-16 Marc Delisle <lem9@users.sourceforge.net> 2006-01-16 Marc Delisle <lem9@users.sourceforge.net>
* server_privileges.php: typo * server_privileges.php: typo

View File

@@ -52,7 +52,7 @@ if ($cfgRelation['commwork']) {
* Selects the database and gets tables names * Selects the database and gets tables names
*/ */
PMA_DBI_select_db($db); PMA_DBI_select_db($db);
$rowset = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); $rowset = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
$count = 0; $count = 0;
while ($row = PMA_DBI_fetch_assoc($rowset)) { while ($row = PMA_DBI_fetch_assoc($rowset)) {
@@ -128,7 +128,7 @@ while ($row = PMA_DBI_fetch_assoc($rowset)) {
/** /**
* Gets fields properties * Gets fields properties
*/ */
$result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', NULL, PMA_DBI_QUERY_STORE); $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
$fields_cnt = PMA_DBI_num_rows($result); $fields_cnt = PMA_DBI_num_rows($result);
// Check if we can use Relations (Mike Beck) // Check if we can use Relations (Mike Beck)
if (!empty($cfgRelation['relation'])) { if (!empty($cfgRelation['relation'])) {
@@ -141,8 +141,7 @@ while ($row = PMA_DBI_fetch_assoc($rowset)) {
} else { } else {
$have_rel = FALSE; $have_rel = FALSE;
} }
} } else {
else {
$have_rel = FALSE; $have_rel = FALSE;
} // end if } // end if
@@ -237,7 +236,7 @@ while ($row = PMA_DBI_fetch_assoc($rowset)) {
<td<?php echo $type_nowrap; ?> xml:lang="en" dir="ltr"><?php echo $type; ?></td> <td<?php echo $type_nowrap; ?> xml:lang="en" dir="ltr"><?php echo $type; ?></td>
<?php /* <td<?php echo $type_nowrap; ?>><?php echo $strAttribute; ?></td>*/ ?> <?php /* <td<?php echo $type_nowrap; ?>><?php echo $strAttribute; ?></td>*/ ?>
<td><?php echo (($row['Null'] == '' || $row['Null'] == 'NO') ? $strNo : $strYes); ?></td> <td><?php echo (($row['Null'] == '' || $row['Null'] == 'NO') ? $strNo : $strYes); ?></td>
<td nowrap="nowrap"><?php if (isset($row['Default'])) echo $row['Default']; ?></td> <td nowrap="nowrap"><?php if (isset($row['Default'])) { echo $row['Default']; } ?></td>
<?php /* <td<?php echo $type_nowrap; ?>><?php echo $row['Extra']; ?></td>*/ ?> <?php /* <td<?php echo $type_nowrap; ?>><?php echo $row['Extra']; ?></td>*/ ?>
<?php <?php
if ($have_rel) { if ($have_rel) {

View File

@@ -62,7 +62,7 @@ if (isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])) {
if (isset($lines) && is_array($lines) && count($lines) > 0) { if (isset($lines) && is_array($lines) && count($lines) > 0) {
foreach ($lines AS $lkey => $line) { foreach ($lines AS $lkey => $line) {
//echo '<p>' . $line . '</p>'; //echo '<p>' . $line . '</p>';
$inf = explode('|',$line); $inf = explode('|', $line);
if (!empty($inf[1]) && strlen(trim($inf[1])) > 0) { if (!empty($inf[1]) && strlen(trim($inf[1])) > 0) {
$qry = ' $qry = '
INSERT INTO INSERT INTO
@@ -125,14 +125,11 @@ if (isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])) {
if (empty($DOCUMENT_ROOT)) { if (empty($DOCUMENT_ROOT)) {
if (!empty($_SERVER) && isset($_SERVER['DOCUMENT_ROOT'])) { if (!empty($_SERVER) && isset($_SERVER['DOCUMENT_ROOT'])) {
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT']; $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
} } elseif (!empty($_ENV) && isset($_ENV['DOCUMENT_ROOT'])) {
else if (!empty($_ENV) && isset($_ENV['DOCUMENT_ROOT'])) {
$DOCUMENT_ROOT = $_ENV['DOCUMENT_ROOT']; $DOCUMENT_ROOT = $_ENV['DOCUMENT_ROOT'];
} } elseif (@getenv('DOCUMENT_ROOT')) {
else if (@getenv('DOCUMENT_ROOT')) {
$DOCUMENT_ROOT = getenv('DOCUMENT_ROOT'); $DOCUMENT_ROOT = getenv('DOCUMENT_ROOT');
} } else {
else {
$DOCUMENT_ROOT = '.'; $DOCUMENT_ROOT = '.';
} }
} // end if } // end if
@@ -173,15 +170,13 @@ if (isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])) {
echo $strFileCouldNotBeRead; echo $strFileCouldNotBeRead;
exit(); exit();
} }
} } else {
else {
$sql_file_new = $tmp_subdir . basename($sql_file); $sql_file_new = $tmp_subdir . basename($sql_file);
move_uploaded_file($sql_file, $sql_file_new); move_uploaded_file($sql_file, $sql_file_new);
$docsql_text = PMA_readFile($sql_file_new, $sql_file_compression); $docsql_text = PMA_readFile($sql_file_new, $sql_file_compression);
unlink($sql_file_new); unlink($sql_file_new);
} }
} } else {
else {
// read from the normal upload dir // read from the normal upload dir
$docsql_text = PMA_readFile($sql_file, $sql_file_compression); $docsql_text = PMA_readFile($sql_file, $sql_file_compression);
} }
@@ -228,7 +223,7 @@ if (isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])) {
*/ */
?> ?>
<form method="post" action="db_details_importdocsql.php" <?php if ($is_upload) echo ' enctype="multipart/form-data"'; ?>> <form method="post" action="db_details_importdocsql.php" <?php if ($is_upload) { echo ' enctype="multipart/form-data"'; } ?>>
<?php echo PMA_generate_common_hidden_inputs($db); ?> <?php echo PMA_generate_common_hidden_inputs($db); ?>
<input type="hidden" name="submit_show" value="true" /> <input type="hidden" name="submit_show" value="true" />
<input type="hidden" name="do" value="import" /> <input type="hidden" name="do" value="import" />

View File

@@ -152,7 +152,7 @@ $row_count = 0;
$hidden_fields = array(); $hidden_fields = array();
$odd_row = true; $odd_row = true;
foreach ( $tables as $keyname => $each_table ) { foreach ( $tables as $keyname => $each_table ) {
if ( $each_table['TABLE_ROWS'] === NULL || $each_table['TABLE_ROWS'] < $GLOBALS['cfg']['MaxExactCount']) { if ( $each_table['TABLE_ROWS'] === null || $each_table['TABLE_ROWS'] < $GLOBALS['cfg']['MaxExactCount']) {
$each_table['TABLE_ROWS'] = PMA_countRecords( $db, $each_table['TABLE_ROWS'] = PMA_countRecords( $db,
$each_table['TABLE_NAME'], $return = true, $force_exact = true ); $each_table['TABLE_NAME'], $return = true, $force_exact = true );
} }
@@ -452,21 +452,21 @@ echo ' <option value="' . $strAnalyzeTable . '" >'
/* Printable view of a table */ /* Printable view of a table */
echo '<p>'; echo '<p>';
echo '<a href="db_printview.php?' . $url_query . '">'; echo '<a href="db_printview.php?' . $url_query . '">';
if ( $cfg['PropertiesIconic'] ) { if ($cfg['PropertiesIconic']) {
echo '<img class="icon" src="' . $pmaThemeImage echo '<img class="icon" src="' . $pmaThemeImage
.'b_print.png" width="16" height="16" alt="" />'; .'b_print.png" width="16" height="16" alt="" />';
} }
echo $strPrintView . '</a> '; echo $strPrintView . '</a> ';
echo '<a href="./db_datadict.php?' . $url_query . '">'; echo '<a href="./db_datadict.php?' . $url_query . '">';
if($cfg['PropertiesIconic']){ if ($cfg['PropertiesIconic']) {
echo '<img class="icon" src="' . $pmaThemeImage echo '<img class="icon" src="' . $pmaThemeImage
.'b_tblanalyse.png" width="16" height="16" alt="" />'; .'b_tblanalyse.png" width="16" height="16" alt="" />';
} }
echo $strDataDict . '</a>'; echo $strDataDict . '</a>';
echo '</p>'; echo '</p>';
if ( empty( $db_is_information_schema ) ) { if (empty($db_is_information_schema)) {
require('./libraries/display_create_table.lib.php'); require('./libraries/display_create_table.lib.php');
} // end if (Create Table dialog) } // end if (Create Table dialog)

View File

@@ -80,7 +80,7 @@ if (isset($db) &&
// Duplicate the bookmarks for this db (done once for each db) // Duplicate the bookmarks for this db (done once for each db)
if ($db != $newname) { if ($db != $newname) {
$get_fields = array('user','label','query'); $get_fields = array('user', 'label', 'query');
$where_fields = array('dbase' => $db); $where_fields = array('dbase' => $db);
$new_fields = array('dbase' => $newname); $new_fields = array('dbase' => $newname);
PMA_duplicate_table_info('bookmarkwork', 'bookmark', $get_fields, PMA_duplicate_table_info('bookmarkwork', 'bookmark', $get_fields,
@@ -332,7 +332,7 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?>
SELECT * SELECT *
FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) . ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) . '
WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''; WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$test_rs = PMA_query_as_cu($test_query, NULL, PMA_DBI_QUERY_STORE); $test_rs = PMA_query_as_cu($test_query, null, PMA_DBI_QUERY_STORE);
if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) { ?> if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) { ?>
<!-- PDF schema --> <!-- PDF schema -->

View File

@@ -44,7 +44,7 @@ if ($cfg['SkipLockedTables'] == TRUE) {
unset($result); unset($result);
if (isset($sot_cache)) { if (isset($sot_cache)) {
$result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
if ($result != FALSE && PMA_DBI_num_rows($result) > 0) { if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
while ($tmp = PMA_DBI_fetch_row($result)) { while ($tmp = PMA_DBI_fetch_row($result)) {
if (!isset($sot_cache[$tmp[0]])) { if (!isset($sot_cache[$tmp[0]])) {
@@ -134,7 +134,7 @@ else {
if (isset($sts_data['Type'])) { if (isset($sts_data['Type'])) {
if ($sts_data['Type'] == 'MRG_MyISAM') { if ($sts_data['Type'] == 'MRG_MyISAM') {
$mergetable = TRUE; $mergetable = TRUE;
} else if (!preg_match('@ISAM|HEAP@i', $sts_data['Type'])) { } elseif (!preg_match('@ISAM|HEAP@i', $sts_data['Type'])) {
$nonisam = TRUE; $nonisam = TRUE;
} }
} }
@@ -149,18 +149,17 @@ else {
} else { } else {
list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0); list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
} }
} else if ($cfg['ShowStats']) { } elseif ($cfg['ShowStats']) {
$formated_size = '&nbsp;-&nbsp;'; $formated_size = '&nbsp;-&nbsp;';
$unit = ''; $unit = '';
} }
$sum_entries += $sts_data['Rows']; $sum_entries += $sts_data['Rows'];
} }
// MyISAM MERGE Table // MyISAM MERGE Table
else if ($cfg['ShowStats'] && $mergetable == TRUE) { elseif ($cfg['ShowStats'] && $mergetable == TRUE) {
$formated_size = '&nbsp;-&nbsp;'; $formated_size = '&nbsp;-&nbsp;';
$unit = ''; $unit = '';
} } elseif ($cfg['ShowStats']) {
else if ($cfg['ShowStats']) {
$formated_size = 'unknown'; $formated_size = 'unknown';
$unit = ''; $unit = '';
} }

View File

@@ -59,10 +59,11 @@ header('Content-Type: text/html; charset=' . $charset);
<body> <body>
<h1>phpMyAdmin - <?php echo $type; ?></h1> <h1>phpMyAdmin - <?php echo $type; ?></h1>
<p><?php <p><?php
if (get_magic_quotes_gpc()) if (get_magic_quotes_gpc()) {
echo PMA_sanitize(stripslashes($_REQUEST['error'])); echo PMA_sanitize(stripslashes($_REQUEST['error']));
else } else {
echo PMA_sanitize($_REQUEST['error']); echo PMA_sanitize($_REQUEST['error']);
}
?></p> ?></p>
</body> </body>
</html> </html>

View File

@@ -80,7 +80,7 @@ function PMA_exportOutputHandler($line)
$dump_buffer = bzcompress($dump_buffer); $dump_buffer = bzcompress($dump_buffer);
} }
// as a gzipped file // as a gzipped file
else if ($GLOBALS['compression'] == 'gzip' && @function_exists('gzencode')) { elseif ($GLOBALS['compression'] == 'gzip' && @function_exists('gzencode')) {
// without the optional parameter level because it bug // without the optional parameter level because it bug
$dump_buffer = gzencode($dump_buffer); $dump_buffer = gzencode($dump_buffer);
} }
@@ -172,17 +172,26 @@ $onfly_compression = $GLOBALS['cfg']['CompressOnFly'] && isset($compression) &&
if ($onfly_compression) { if ($onfly_compression) {
$memory_limit = trim(@ini_get('memory_limit')); $memory_limit = trim(@ini_get('memory_limit'));
// 2 MB as default // 2 MB as default
if (empty($memory_limit)) $memory_limit = 2 * 1024 * 1024; if (empty($memory_limit)) {
$memory_limit = 2 * 1024 * 1024;
}
if (strtolower(substr($memory_limit, -1)) == 'm') $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024; if (strtolower(substr($memory_limit, -1)) == 'm') {
elseif (strtolower(substr($memory_limit, -1)) == 'k') $memory_limit = (int)substr($memory_limit, 0, -1) * 1024; $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
elseif (strtolower(substr($memory_limit, -1)) == 'g') $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024; } elseif (strtolower(substr($memory_limit, -1)) == 'k') {
else $memory_limit = (int)$memory_limit; $memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
} elseif (strtolower(substr($memory_limit, -1)) == 'g') {
$memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
} else {
$memory_limit = (int)$memory_limit;
}
// Some of memory is needed for other thins and as treshold. // Some of memory is needed for other thins and as treshold.
// Nijel: During export I had allocated (see memory_get_usage function) // Nijel: During export I had allocated (see memory_get_usage function)
// approx 1.2MB so this comes from that. // approx 1.2MB so this comes from that.
if ($memory_limit > 1500000) $memory_limit -= 1500000; if ($memory_limit > 1500000) {
$memory_limit -= 1500000;
}
// Some memory is needed for compression, assume 1/3 // Some memory is needed for compression, assume 1/3
$memory_limit *= 2/3; $memory_limit *= 2/3;
@@ -193,17 +202,17 @@ if ($asfile) {
$pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']); $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
if ($export_type == 'server') { if ($export_type == 'server') {
if (isset($remember_template)) { if (isset($remember_template)) {
setcookie('pma_server_filename_template', $filename_template , 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); setcookie('pma_server_filename_template', $filename_template, 0, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
} }
$filename = str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template)); $filename = str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template));
} elseif ($export_type == 'database') { } elseif ($export_type == 'database') {
if (isset($remember_template)) { if (isset($remember_template)) {
setcookie('pma_db_filename_template', $filename_template , 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); setcookie('pma_db_filename_template', $filename_template, 0, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
} }
$filename = str_replace('__DB__', $db, str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template))); $filename = str_replace('__DB__', $db, str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template)));
} else { } else {
if (isset($remember_template)) { if (isset($remember_template)) {
setcookie('pma_table_filename_template', $filename_template , 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); setcookie('pma_table_filename_template', $filename_template, 0, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
} }
$filename = str_replace('__TABLE__', $table, str_replace('__DB__', $db, str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template)))); $filename = str_replace('__TABLE__', $table, str_replace('__DB__', $db, str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template))));
} }
@@ -219,22 +228,22 @@ if ($asfile) {
if ($type == 'csv') { if ($type == 'csv') {
$filename .= '.csv'; $filename .= '.csv';
$mime_type = 'text/comma-separated-values'; $mime_type = 'text/comma-separated-values';
} else if ($type == 'htmlexcel') { } elseif ($type == 'htmlexcel') {
$filename .= '.xls'; $filename .= '.xls';
$mime_type = 'application/vnd.ms-excel'; $mime_type = 'application/vnd.ms-excel';
} else if ($type == 'htmlword') { } elseif ($type == 'htmlword') {
$filename .= '.doc'; $filename .= '.doc';
$mime_type = 'application/vnd.ms-word'; $mime_type = 'application/vnd.ms-word';
} else if ($type == 'xls') { } elseif ($type == 'xls') {
$filename .= '.xls'; $filename .= '.xls';
$mime_type = 'application/vnd.ms-excel'; $mime_type = 'application/vnd.ms-excel';
} else if ($type == 'xml') { } elseif ($type == 'xml') {
$filename .= '.xml'; $filename .= '.xml';
$mime_type = 'text/xml'; $mime_type = 'text/xml';
} else if ($type == 'latex') { } elseif ($type == 'latex') {
$filename .= '.tex'; $filename .= '.tex';
$mime_type = 'application/x-tex'; $mime_type = 'application/x-tex';
} else if ($type == 'pdf') { } elseif ($type == 'pdf') {
$filename .= '.pdf'; $filename .= '.pdf';
$mime_type = 'application/pdf'; $mime_type = 'application/pdf';
} else { } else {
@@ -255,7 +264,7 @@ if ($asfile) {
// browsers don't like this: // browsers don't like this:
//$content_encoding = 'x-bzip2'; //$content_encoding = 'x-bzip2';
$mime_type = 'application/x-bzip2'; $mime_type = 'application/x-bzip2';
} else if (isset($compression) && $compression == 'gzip') { } elseif (isset($compression) && $compression == 'gzip') {
$filename .= '.gz'; $filename .= '.gz';
// Needed to avoid recompression by server modules like mod_gzip. // Needed to avoid recompression by server modules like mod_gzip.
// It seems necessary to check about zlib.output_compression // It seems necessary to check about zlib.output_compression
@@ -264,7 +273,7 @@ if ($asfile) {
$content_encoding = 'x-gzip'; $content_encoding = 'x-gzip';
$mime_type = 'application/x-gzip'; $mime_type = 'application/x-gzip';
} }
} else if (isset($compression) && $compression == 'zip') { } elseif (isset($compression) && $compression == 'zip') {
$filename .= '.zip'; $filename .= '.zip';
$mime_type = 'application/zip'; $mime_type = 'application/zip';
} }
@@ -272,7 +281,7 @@ if ($asfile) {
// Open file on server if needed // Open file on server if needed
if ($save_on_server) { if ($save_on_server) {
$save_filename = PMA_userDir($cfg['SaveDir']) . preg_replace('@[/\\\\]@','_',$filename); $save_filename = PMA_userDir($cfg['SaveDir']) . preg_replace('@[/\\\\]@', '_', $filename);
unset($message); unset($message);
if (file_exists($save_filename) && empty($onserverover)) { if (file_exists($save_filename) && empty($onserverover)) {
$message = sprintf($strFileAlreadyExists, htmlspecialchars($save_filename)); $message = sprintf($strFileAlreadyExists, htmlspecialchars($save_filename));
@@ -374,7 +383,9 @@ if ($export_type == 'database') {
do { do {
// Add possibly some comments to export // Add possibly some comments to export
if (!PMA_exportHeader()) break; if (!PMA_exportHeader()) {
break;
}
// Will we need relation & co. setup? // Will we need relation & co. setup?
$do_relation = isset($GLOBALS[$what . '_relation']); $do_relation = isset($GLOBALS[$what . '_relation']);
@@ -411,29 +422,35 @@ if ($export_type == 'server') {
foreach ($dblist AS $current_db) { foreach ($dblist AS $current_db) {
if ((isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|')) if ((isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|'))
|| !isset($tmp_select)) { || !isset($tmp_select)) {
if (!PMA_exportDBHeader($current_db)) if (!PMA_exportDBHeader($current_db)) {
break 2; break 2;
if (!PMA_exportDBCreate($current_db)) }
if (!PMA_exportDBCreate($current_db)) {
break 2; break 2;
}
$tables = PMA_DBI_get_tables($current_db); $tables = PMA_DBI_get_tables($current_db);
foreach ($tables as $table) { foreach ($tables as $table) {
$local_query = 'SELECT * FROM ' . PMA_backquote($current_db) . '.' . PMA_backquote($table); $local_query = 'SELECT * FROM ' . PMA_backquote($current_db) . '.' . PMA_backquote($table);
if (isset($GLOBALS[$what . '_structure'])) { if (isset($GLOBALS[$what . '_structure'])) {
if (!PMA_exportStructure($current_db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates)) if (!PMA_exportStructure($current_db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates)) {
break 3; break 3;
} }
}
if (isset($GLOBALS[$what . '_data'])) { if (isset($GLOBALS[$what . '_data'])) {
if (!PMA_exportData($current_db, $table, $crlf, $err_url, $local_query)) if (!PMA_exportData($current_db, $table, $crlf, $err_url, $local_query)) {
break 3; break 3;
} }
} }
if (!PMA_exportDBFooter($current_db)) }
if (!PMA_exportDBFooter($current_db)) {
break 2; break 2;
} }
} }
}
} elseif ($export_type == 'database') { } elseif ($export_type == 'database') {
if (!PMA_exportDBHeader($db)) if (!PMA_exportDBHeader($db)) {
break; break;
}
if (isset($table_select)) { if (isset($table_select)) {
$tmp_select = implode($table_select, '|'); $tmp_select = implode($table_select, '|');
@@ -446,20 +463,24 @@ if ($export_type == 'server') {
|| !isset($tmp_select)) { || !isset($tmp_select)) {
if (isset($GLOBALS[$what . '_structure'])) { if (isset($GLOBALS[$what . '_structure'])) {
if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates)) if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates)) {
break 2; break 2;
} }
}
if (isset($GLOBALS[$what . '_data'])) { if (isset($GLOBALS[$what . '_data'])) {
if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
break 2; break 2;
} }
} }
} }
if (!PMA_exportDBFooter($db)) }
if (!PMA_exportDBFooter($db)) {
break; break;
}
} else { } else {
if (!PMA_exportDBHeader($db)) if (!PMA_exportDBHeader($db)) {
break; break;
}
// We export just one table // We export just one table
if ($limit_to > 0 && $limit_from >= 0) { if ($limit_to > 0 && $limit_from >= 0) {
@@ -478,17 +499,22 @@ if ($export_type == 'server') {
} }
if (isset($GLOBALS[$what . '_structure'])) { if (isset($GLOBALS[$what . '_structure'])) {
if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates)) if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates)) {
break; break;
} }
}
if (isset($GLOBALS[$what . '_data'])) { if (isset($GLOBALS[$what . '_data'])) {
if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
break; break;
} }
if (!PMA_exportDBFooter($db)) }
if (!PMA_exportDBFooter($db)) {
break;
}
}
if (!PMA_exportFooter()) {
break; break;
} }
if (!PMA_exportFooter()) break;
} while (FALSE); } while (FALSE);
// End of fake loop // End of fake loop
@@ -528,7 +554,7 @@ if (!empty($asfile)) {
} }
} }
// 2. as a bzipped file // 2. as a bzipped file
else if (isset($compression) && $compression == 'bzip') { elseif (isset($compression) && $compression == 'bzip') {
if (@function_exists('bzcompress')) { if (@function_exists('bzcompress')) {
$dump_buffer = bzcompress($dump_buffer); $dump_buffer = bzcompress($dump_buffer);
if ($dump_buffer === -8) { if ($dump_buffer === -8) {
@@ -539,7 +565,7 @@ if (!empty($asfile)) {
} }
} }
// 3. as a gzipped file // 3. as a gzipped file
else if (isset($compression) && $compression == 'gzip') { elseif (isset($compression) && $compression == 'gzip') {
if (@function_exists('gzencode')) { if (@function_exists('gzencode')) {
// without the optional parameter level because it bug // without the optional parameter level because it bug
$dump_buffer = gzencode($dump_buffer); $dump_buffer = gzencode($dump_buffer);
@@ -592,7 +618,7 @@ else {
if (document.getElementById('textSQLDUMP')) { if (document.getElementById('textSQLDUMP')) {
bodyWidth = self.innerWidth; bodyWidth = self.innerWidth;
bodyHeight = self.innerHeight; bodyHeight = self.innerHeight;
if(!bodyWidth && !bodyHeight){ if (!bodyWidth && !bodyHeight) {
if (document.compatMode && document.compatMode == "BackCompat") { if (document.compatMode && document.compatMode == "BackCompat") {
bodyWidth = document.body.clientWidth; bodyWidth = document.body.clientWidth;
bodyHeight = document.body.clientHeight; bodyHeight = document.body.clientHeight;

View File

@@ -125,7 +125,7 @@ if (!empty($id_bookmark)) {
require_once('./libraries/bookmark.lib.php'); require_once('./libraries/bookmark.lib.php');
switch ($action_bookmark) { switch ($action_bookmark) {
case 0: // bookmarked query that have to be run case 0: // bookmarked query that have to be run
$import_text = PMA_queryBookmarks($db, $cfg['Bookmark'], $id_bookmark,'id', isset($action_bookmark_all)); $import_text = PMA_queryBookmarks($db, $cfg['Bookmark'], $id_bookmark, 'id', isset($action_bookmark_all));
if (isset($bookmark_variable) && !empty($bookmark_variable)) { if (isset($bookmark_variable) && !empty($bookmark_variable)) {
$import_text = preg_replace('|/\*(.*)\[VARIABLE\](.*)\*/|imsU', '${1}' . PMA_sqlAddslashes($bookmark_variable) . '${2}', $import_text); $import_text = preg_replace('|/\*(.*)\[VARIABLE\](.*)\*/|imsU', '${1}' . PMA_sqlAddslashes($bookmark_variable) . '${2}', $import_text);
} }
@@ -156,7 +156,7 @@ if (!empty($bkm_label) && !empty($import_text)) {
// Should we replace bookmark? // Should we replace bookmark?
if (isset($bkm_replace)) { if (isset($bkm_replace)) {
$bookmarks = PMA_listBookmarks($db, $cfg['Bookmark']); $bookmarks = PMA_listBookmarks($db, $cfg['Bookmark']);
foreach($bookmarks as $key => $val) { foreach ($bookmarks as $key => $val) {
if ($val == $bkm_label) { if ($val == $bkm_label) {
PMA_deleteBookmarks($db, $cfg['Bookmark'], $key); PMA_deleteBookmarks($db, $cfg['Bookmark'], $key);
} }
@@ -180,10 +180,15 @@ if ($memory_limit = -1) {
} }
// Calculate value of the limit // Calculate value of the limit
if (strtolower(substr($memory_limit, -1)) == 'm') $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024; if (strtolower(substr($memory_limit, -1)) == 'm') {
elseif (strtolower(substr($memory_limit, -1)) == 'k') $memory_limit = (int)substr($memory_limit, 0, -1) * 1024; $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
elseif (strtolower(substr($memory_limit, -1)) == 'g') $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024; } elseif (strtolower(substr($memory_limit, -1)) == 'k') {
else $memory_limit = (int)$memory_limit; $memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
} elseif (strtolower(substr($memory_limit, -1)) == 'g') {
$memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
} else {
$memory_limit = (int)$memory_limit;
}
$read_limit = $memory_limit / 4; // Just to be sure, there might be lot of memory needed for uncompression $read_limit = $memory_limit / 4; // Just to be sure, there might be lot of memory needed for uncompression
@@ -194,7 +199,7 @@ if (!empty($local_import_file) && !empty($cfg['UploadDir'])) {
$local_import_file = PMA_securePath($local_import_file); $local_import_file = PMA_securePath($local_import_file);
$import_file = PMA_userDir($cfg['UploadDir']) . $local_import_file; $import_file = PMA_userDir($cfg['UploadDir']) . $local_import_file;
} else if (empty($import_file) || !is_uploaded_file($import_file)) { } elseif (empty($import_file) || !is_uploaded_file($import_file)) {
$import_file = 'none'; $import_file = 'none';
} }
@@ -300,7 +305,7 @@ if ($cfg['AllowAnywhereRecoding'] && $allow_recoding
if ($charset_of_file != $charset) { if ($charset_of_file != $charset) {
$charset_conversion = TRUE; $charset_conversion = TRUE;
} }
} else if (PMA_MYSQL_INT_VERSION >= 40100 } elseif (PMA_MYSQL_INT_VERSION >= 40100
&& isset($charset_of_file) && $charset_of_file != 'utf8') { && isset($charset_of_file) && $charset_of_file != 'utf8') {
PMA_DBI_query('SET NAMES \'' . $charset_of_file . '\''); PMA_DBI_query('SET NAMES \'' . $charset_of_file . '\'');
// We can not show query in this case, it is in different charset // We can not show query in this case, it is in different charset

View File

@@ -48,11 +48,9 @@ session_write_close();
if (empty($HTTP_HOST)) { if (empty($HTTP_HOST)) {
if (!empty($_ENV) && isset($_ENV['HTTP_HOST'])) { if (!empty($_ENV) && isset($_ENV['HTTP_HOST'])) {
$HTTP_HOST = $_ENV['HTTP_HOST']; $HTTP_HOST = $_ENV['HTTP_HOST'];
} } elseif (@getenv('HTTP_HOST')) {
elseif (@getenv('HTTP_HOST')) {
$HTTP_HOST = getenv('HTTP_HOST'); $HTTP_HOST = getenv('HTTP_HOST');
} } else {
else {
$HTTP_HOST = ''; $HTTP_HOST = '';
} }
} }
@@ -72,7 +70,7 @@ unset( $cfgRelation );
$drops = array( 'lang', 'server', 'convcharset', 'collation_connection', $drops = array( 'lang', 'server', 'convcharset', 'collation_connection',
'db', 'table' ); 'db', 'table' );
foreach( $drops as $each_drop ) { foreach ( $drops as $each_drop ) {
if ( ! array_key_exists( $each_drop, $_GET ) ) { if ( ! array_key_exists( $each_drop, $_GET ) ) {
unset( $_GET[$each_drop] ); unset( $_GET[$each_drop] );
} }
@@ -122,7 +120,7 @@ header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
// <![CDATA[ // <![CDATA[
// definitions used in querywindow.js // definitions used in querywindow.js
var common_query = '<?php echo PMA_generate_common_url('','','&');?>'; var common_query = '<?php echo PMA_generate_common_url('', '', '&');?>';
var opendb_url = '<?php echo $GLOBALS['cfg']['DefaultTabDatabase']; ?>'; var opendb_url = '<?php echo $GLOBALS['cfg']['DefaultTabDatabase']; ?>';
var safari_browser = <?php echo PMA_USR_BROWSER_AGENT == 'SAFARI' ? 'true' : 'false' ?>; var safari_browser = <?php echo PMA_USR_BROWSER_AGENT == 'SAFARI' ? 'true' : 'false' ?>;
var querywindow_height = <?php echo $GLOBALS['cfg']['QueryWindowHeight']; ?>; var querywindow_height = <?php echo $GLOBALS['cfg']['QueryWindowHeight']; ?>;

View File

@@ -430,7 +430,7 @@ function PMA_displayTableList($tables, $visible = false,
} else { } else {
echo '<ul id="subel' . $element_counter . '" style="display: none">'; echo '<ul id="subel' . $element_counter . '" style="display: none">';
} }
foreach( $tables as $group => $table ) { foreach ( $tables as $group => $table ) {
if ( isset( $table['is' . $sep . 'group'] ) ) { if ( isset( $table['is' . $sep . 'group'] ) ) {
$common_url_query = $GLOBALS['common_url_query'] $common_url_query = $GLOBALS['common_url_query']
. '&amp;tbl_group=' . urlencode( $tab_group_full . $group ); . '&amp;tbl_group=' . urlencode( $tab_group_full . $group );

View File

@@ -158,7 +158,7 @@ class PMA_Config
} elseif (preg_match('@OmniWeb/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) { } elseif (preg_match('@OmniWeb/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
$this->set('PMA_USR_BROWSER_VER', $log_version[1]); $this->set('PMA_USR_BROWSER_VER', $log_version[1]);
$this->set('PMA_USR_BROWSER_AGENT', 'OMNIWEB'); $this->set('PMA_USR_BROWSER_AGENT', 'OMNIWEB');
//} else if (ereg('Konqueror/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { //} elseif (ereg('Konqueror/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
// Konqueror 2.2.2 says Konqueror/2.2.2 // Konqueror 2.2.2 says Konqueror/2.2.2
// Konqueror 3.0.3 says Konqueror/3 // Konqueror 3.0.3 says Konqueror/3
} elseif (preg_match('@(Konqueror/)(.*)(;)@', $HTTP_USER_AGENT, $log_version)) { } elseif (preg_match('@(Konqueror/)(.*)(;)@', $HTTP_USER_AGENT, $log_version)) {

View File

@@ -34,53 +34,56 @@ class PMA_Theme_Manager {
/** /**
* @var object PMA_Theme active theme * @var object PMA_Theme active theme
*/ */
var $theme = NULL; var $theme = null;
function __construct() { function __construct()
$this->themes_path = trim( $GLOBALS['cfg']['ThemePath'] ) ; {
$this->themes_path = trim($GLOBALS['cfg']['ThemePath']) ;
$this->per_server = (bool) $GLOBALS['cfg']['ThemePerServer']; $this->per_server = (bool) $GLOBALS['cfg']['ThemePerServer'];
$this->theme = new PMA_Theme; $this->theme = new PMA_Theme;
if ( ! $this->_checkThemeFolder( $this->themes_path ) ) { if ( ! $this->_checkThemeFolder($this->themes_path)) {
return; return;
} }
$this->loadThemes( $this->themes_path ); $this->loadThemes($this->themes_path);
if ( ! $this->checkTheme( $GLOBALS['cfg']['ThemeDefault'] ) ) { if ( ! $this->checkTheme($GLOBALS['cfg']['ThemeDefault'])) {
$GLOBALS['PMA_errors'][] = sprintf( $GLOBALS['strThemeDefaultNotFound'], $GLOBALS['PMA_errors'][] = sprintf( $GLOBALS['strThemeDefaultNotFound'],
$GLOBALS['cfg']['ThemeDefault'] ); $GLOBALS['cfg']['ThemeDefault'] );
trigger_error( trigger_error(
sprintf( $GLOBALS['strThemeDefaultNotFound'], sprintf($GLOBALS['strThemeDefaultNotFound'],
$GLOBALS['cfg']['ThemeDefault'] ), $GLOBALS['cfg']['ThemeDefault']),
E_USER_WARNING ); E_USER_WARNING);
$GLOBALS['cfg']['ThemeDefault'] = false; $GLOBALS['cfg']['ThemeDefault'] = false;
} }
$this->theme_default = $GLOBALS['cfg']['ThemeDefault']; $this->theme_default = $GLOBALS['cfg']['ThemeDefault'];
// check if user have a theme cookie // check if user have a theme cookie
if ( ! $this->getThemeCookie() if (! $this->getThemeCookie()
|| ! $this->setActiveTheme( $this->getThemeCookie() ) ) { || ! $this->setActiveTheme($this->getThemeCookie())) {
if ( $GLOBALS['cfg']['ThemeDefault'] ) { if ($GLOBALS['cfg']['ThemeDefault']) {
$this->setActiveTheme( $GLOBALS['cfg']['ThemeDefault'] ); $this->setActiveTheme($GLOBALS['cfg']['ThemeDefault']);
} else { } else {
$this->setActiveTheme( 'original' ); $this->setActiveTheme('original');
} }
} }
} }
function __wakeup() { function __wakeup()
$this->loadThemes( $this->themes_path ); {
$this->loadThemes($this->themes_path);
} }
function setActiveTheme( $theme = NULL ) { function setActiveTheme($theme = null)
if ( ! $this->checkTheme( $theme ) ) { {
$GLOBALS['PMA_errors'][] = sprintf( $GLOBALS['strThemeNotFound'], if ( ! $this->checkTheme($theme)) {
$theme ); $GLOBALS['PMA_errors'][] = sprintf($GLOBALS['strThemeNotFound'],
$theme);
trigger_error( trigger_error(
sprintf( $GLOBALS['strThemeNotFound'], $theme ), sprintf($GLOBALS['strThemeNotFound'], $theme),
E_USER_WARNING ); E_USER_WARNING);
return false; return false;
} }
@@ -96,9 +99,10 @@ class PMA_Theme_Manager {
/** /**
* @return string cookie name * @return string cookie name
*/ */
function getThemeCookieName() { function getThemeCookieName()
{
// Allow different theme per server // Allow different theme per server
if ( isset( $GLOBALS['server'] ) && $this->per_server ) { if (isset($GLOBALS['server']) && $this->per_server) {
return $this->cookie_name . '-' . $GLOBALS['server']; return $this->cookie_name . '-' . $GLOBALS['server'];
} else { } else {
return $this->cookie_name; return $this->cookie_name;
@@ -109,8 +113,9 @@ class PMA_Theme_Manager {
* returns name of theme stored in the cookie * returns name of theme stored in the cookie
* @return string theme name from cookie * @return string theme name from cookie
*/ */
function getThemeCookie() { function getThemeCookie()
if ( isset( $_COOKIE[$this->getThemeCookieName()] ) ) { {
if (isset($_COOKIE[$this->getThemeCookieName()])) {
return $_COOKIE[$this->getThemeCookieName()]; return $_COOKIE[$this->getThemeCookieName()];
} }
@@ -126,16 +131,18 @@ class PMA_Theme_Manager {
* @uses PMA_Theme_Manager::$theme_default * @uses PMA_Theme_Manager::$theme_default
* @uses PMA_Theme::getId() * @uses PMA_Theme::getId()
*/ */
function setThemeCookie() { function setThemeCookie()
PMA_setCookie( $this->getThemeCookieName(), $this->theme->id, {
$this->theme_default ); PMA_setCookie($this->getThemeCookieName(), $this->theme->id,
$this->theme_default);
return true; return true;
} }
/** /**
* old PHP 4 constructor * old PHP 4 constructor
*/ */
function PMA_Theme_Manager() { function PMA_Theme_Manager()
{
$this->__construct(); $this->__construct();
} }
@@ -144,15 +151,16 @@ class PMA_Theme_Manager {
* @param string $folder * @param string $folder
* @return boolean * @return boolean
*/ */
/*private*/ function _checkThemeFolder( $folder ) { /*private*/ function _checkThemeFolder($folder)
if ( ! is_dir( $folder ) ) { {
if (! is_dir($folder)) {
$GLOBALS['PMA_errors'][] = $GLOBALS['PMA_errors'][] =
sprintf( $GLOBALS['strThemePathNotFound'], sprintf($GLOBALS['strThemePathNotFound'],
$folder ); $folder);
trigger_error( trigger_error(
sprintf( $GLOBALS['strThemePathNotFound'], sprintf($GLOBALS['strThemePathNotFound'],
$folder ), $folder),
E_USER_WARNING ); E_USER_WARNING);
return false; return false;
} }
@@ -164,31 +172,32 @@ class PMA_Theme_Manager {
* *
* @param string $folder themes folders * @param string $folder themes folders
*/ */
function loadThemes( $folder ) { function loadThemes($folder)
if ( $handleThemes = opendir( $folder ) ) { {
if ($handleThemes = opendir($folder)) {
// check for themes directory // check for themes directory
while ( FALSE !== ($PMA_Theme = readdir($handleThemes)) ) { while (FALSE !== ($PMA_Theme = readdir($handleThemes))) {
if ( array_key_exists( $PMA_Theme, $this->themes ) ) { if (array_key_exists($PMA_Theme, $this->themes)) {
$new_themes[$PMA_Theme] = $this->themes[$PMA_Theme]; $new_themes[$PMA_Theme] = $this->themes[$PMA_Theme];
continue; continue;
} }
$new_theme = PMA_Theme::load( $folder . '/' . $PMA_Theme ); $new_theme = PMA_Theme::load($folder . '/' . $PMA_Theme);
if ( $new_theme ) { if ($new_theme) {
$new_theme->setId( $PMA_Theme ); $new_theme->setId($PMA_Theme);
$new_themes[$PMA_Theme] = $new_theme; $new_themes[$PMA_Theme] = $new_theme;
} }
} // end get themes } // end get themes
closedir( $handleThemes ); closedir($handleThemes);
} else { } else {
trigger_error( trigger_error(
'phpMyAdmin-ERROR: can not open themes folder: ' . $folder, 'phpMyAdmin-ERROR: can not open themes folder: ' . $folder,
E_USER_WARNING ); E_USER_WARNING);
return false; return false;
} // end check for themes directory } // end check for themes directory
$this->themes = $new_themes; $this->themes = $new_themes;
ksort( $this->themes ); ksort($this->themes);
} }
/** /**
@@ -196,8 +205,9 @@ class PMA_Theme_Manager {
* *
* @param string $theme name fo theme to check for * @param string $theme name fo theme to check for
*/ */
function checkTheme( $theme ) { function checkTheme($theme)
if ( ! array_key_exists( $theme, $this->themes ) ) { {
if (! array_key_exists($theme, $this->themes)) {
return false; return false;
} }
@@ -209,10 +219,11 @@ class PMA_Theme_Manager {
* *
* @param boolean $form wether enclosed by from tags or not * @param boolean $form wether enclosed by from tags or not
*/ */
function getHtmlSelectBox( $form = true ) { function getHtmlSelectBox($form = true)
{
$select_box = ''; $select_box = '';
if ( $form ) { if ($form) {
$select_box .= '<form name="setTheme" method="post" action="index.php"' $select_box .= '<form name="setTheme" method="post" action="index.php"'
.' target="_parent">'; .' target="_parent">';
$select_box .= PMA_generate_common_hidden_inputs(); $select_box .= PMA_generate_common_hidden_inputs();
@@ -227,16 +238,16 @@ class PMA_Theme_Manager {
$select_box .= '<select name="set_theme" xml:lang="en" dir="ltr"' $select_box .= '<select name="set_theme" xml:lang="en" dir="ltr"'
.' onchange="this.form.submit();" >'; .' onchange="this.form.submit();" >';
foreach ( $this->themes as $each_theme_id => $each_theme ) { foreach ($this->themes as $each_theme_id => $each_theme) {
$select_box .= '<option value="' . $each_theme_id . '"'; $select_box .= '<option value="' . $each_theme_id . '"';
if ( $this->active_theme === $each_theme_id ) { if ($this->active_theme === $each_theme_id) {
$select_box .= ' selected="selected"'; $select_box .= ' selected="selected"';
} }
$select_box .= '>' . htmlspecialchars( $each_theme->getName() ) . '</option>'; $select_box .= '>' . htmlspecialchars($each_theme->getName()) . '</option>';
} }
$select_box .= '</select>'; $select_box .= '</select>';
if ( $form ) { if ($form) {
$select_box .= '<noscript><input type="submit" value="' . $GLOBALS['strGo'] . '" /></noscript>'; $select_box .= '<noscript><input type="submit" value="' . $GLOBALS['strGo'] . '" /></noscript>';
$select_box .= '</form>'; $select_box .= '</form>';
} }
@@ -247,7 +258,8 @@ class PMA_Theme_Manager {
/** /**
* enables backward compatibility * enables backward compatibility
*/ */
function makeBc() { function makeBc()
{
$GLOBALS['theme'] = $this->theme->getId(); $GLOBALS['theme'] = $this->theme->getId();
$GLOBALS['pmaThemePath'] = $this->theme->getPath(); $GLOBALS['pmaThemePath'] = $this->theme->getPath();
$GLOBALS['pmaThemeImage'] = $this->theme->getImgPath(); $GLOBALS['pmaThemeImage'] = $this->theme->getImgPath();
@@ -255,8 +267,8 @@ class PMA_Theme_Manager {
/** /**
* load layout file if exists * load layout file if exists
*/ */
if ( @file_exists( $GLOBALS['pmaThemePath'] . 'layout.inc.php' ) ) { if (@file_exists($GLOBALS['pmaThemePath'] . 'layout.inc.php')) {
include( $GLOBALS['pmaThemePath'] . 'layout.inc.php' ); include $GLOBALS['pmaThemePath'] . 'layout.inc.php';
} }
@@ -268,9 +280,9 @@ class PMA_Theme_Manager {
* @uses $this->themes * @uses $this->themes
* @uses PMA_Theme::printPreview() * @uses PMA_Theme::printPreview()
*/ */
function printPreviews() { function printPreviews()
foreach ( $this->themes as $each_theme ) { {
foreach ($this->themes as $each_theme) {
$each_theme->printPreview(); $each_theme->printPreview();
} // end 'open themes' } // end 'open themes'
} }

View File

@@ -82,14 +82,12 @@ function PMA_auth()
// server name // server name
if (!empty($GLOBALS['pma_cookie_servername'])) { if (!empty($GLOBALS['pma_cookie_servername'])) {
$default_server = $GLOBALS['pma_cookie_servername']; $default_server = $GLOBALS['pma_cookie_servername'];
} } elseif (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_servername-' . $server])) {
else if (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_servername-' . $server])) {
$default_server = $_COOKIE['pma_cookie_servername-' . $server]; $default_server = $_COOKIE['pma_cookie_servername-' . $server];
} }
$autocomplete = ''; $autocomplete = '';
} } else {
else {
$default_user = ''; $default_user = '';
$autocomplete = ' autocomplete="off"'; $autocomplete = ' autocomplete="off"';
} }
@@ -231,7 +229,7 @@ echo sprintf( $GLOBALS['strWelcome'],
<?php <?php
if ( ! empty( $GLOBALS['PMA_errors'] ) && is_array( $GLOBALS['PMA_errors'] ) ) { if ( ! empty( $GLOBALS['PMA_errors'] ) && is_array( $GLOBALS['PMA_errors'] ) ) {
foreach( $GLOBALS['PMA_errors'] as $error ) { foreach ( $GLOBALS['PMA_errors'] as $error ) {
echo '<div class="error">' . $error . '</div>' . "\n"; echo '<div class="error">' . $error . '</div>' . "\n";
} }
} }
@@ -297,11 +295,11 @@ function PMA_auth_check()
// The user wants to be logged out -> delete password cookie // The user wants to be logged out -> delete password cookie
if (!empty($old_usr)) { if (!empty($old_usr)) {
setcookie('pma_cookie_password-' . $server, '', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); setcookie('pma_cookie_password-' . $server, '', 0, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
} }
// The user just logged in // The user just logged in
else if (!empty($pma_username)) { elseif (!empty($pma_username)) {
$PHP_AUTH_USER = $pma_username; $PHP_AUTH_USER = $pma_username;
$PHP_AUTH_PW = (empty($pma_password)) ? '' : $pma_password; $PHP_AUTH_PW = (empty($pma_password)) ? '' : $pma_password;
if ($GLOBALS['cfg']['AllowArbitraryServer']) { if ($GLOBALS['cfg']['AllowArbitraryServer']) {
@@ -319,8 +317,7 @@ function PMA_auth_check()
if (!empty($pma_cookie_servername)) { if (!empty($pma_cookie_servername)) {
$pma_auth_server = $pma_cookie_servername; $pma_auth_server = $pma_cookie_servername;
$from_cookie = TRUE; $from_cookie = TRUE;
} } elseif (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_servername-' . $server])) {
else if (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_servername-' . $server])) {
$pma_auth_server = $_COOKIE['pma_cookie_servername-' . $server]; $pma_auth_server = $_COOKIE['pma_cookie_servername-' . $server];
$from_cookie = TRUE; $from_cookie = TRUE;
} }
@@ -356,11 +353,9 @@ function PMA_auth_check()
// password // password
if (!empty($pma_cookie_password)) { if (!empty($pma_cookie_password)) {
$PHP_AUTH_PW = $pma_cookie_password; $PHP_AUTH_PW = $pma_cookie_password;
} } elseif (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_password-' . $server])) {
else if (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_password-' . $server])) {
$PHP_AUTH_PW = $_COOKIE['pma_cookie_password-' . $server]; $PHP_AUTH_PW = $_COOKIE['pma_cookie_password-' . $server];
} } else {
else {
$from_cookie = FALSE; $from_cookie = FALSE;
} }
$PHP_AUTH_PW = PMA_blowfish_decrypt($PHP_AUTH_PW, $GLOBALS['cfg']['blowfish_secret'] . $decrypted_time); $PHP_AUTH_PW = PMA_blowfish_decrypt($PHP_AUTH_PW, $GLOBALS['cfg']['blowfish_secret'] . $decrypted_time);
@@ -458,7 +453,7 @@ function PMA_auth_set_user()
$GLOBALS['is_https']); $GLOBALS['is_https']);
} else { } else {
// Delete servername cookie // Delete servername cookie
setcookie('pma_cookie_servername-' . $server, '', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); setcookie('pma_cookie_servername-' . $server, '', 0, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
} }
} }
@@ -502,19 +497,19 @@ function PMA_auth_fails()
global $conn_error, $server; global $conn_error, $server;
// Deletes password cookie and displays the login form // Deletes password cookie and displays the login form
setcookie('pma_cookie_password-' . $server, '', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); setcookie('pma_cookie_password-' . $server, '', 0, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
if (isset($GLOBALS['allowDeny_forbidden']) && $GLOBALS['allowDeny_forbidden']) { if (isset($GLOBALS['allowDeny_forbidden']) && $GLOBALS['allowDeny_forbidden']) {
$conn_error = $GLOBALS['strAccessDenied']; $conn_error = $GLOBALS['strAccessDenied'];
} else if (isset($GLOBALS['no_activity']) && $GLOBALS['no_activity']) { } elseif (isset($GLOBALS['no_activity']) && $GLOBALS['no_activity']) {
$conn_error = sprintf($GLOBALS['strNoActivity'],$GLOBALS['cfg']['LoginCookieValidity']); $conn_error = sprintf($GLOBALS['strNoActivity'], $GLOBALS['cfg']['LoginCookieValidity']);
// Remember where we got timeout to return on same place // Remember where we got timeout to return on same place
if (isset($_SERVER['SCRIPT_NAME'])) { if (isset($_SERVER['SCRIPT_NAME'])) {
$GLOBALS['target'] = basename($_SERVER['SCRIPT_NAME']); $GLOBALS['target'] = basename($_SERVER['SCRIPT_NAME']);
} }
} else if (PMA_DBI_getError()) { } elseif (PMA_DBI_getError()) {
$conn_error = PMA_sanitize(PMA_DBI_getError()); $conn_error = PMA_sanitize(PMA_DBI_getError());
} else if (isset($php_errormsg)) { } elseif (isset($php_errormsg)) {
$conn_error = $php_errormsg; $conn_error = $php_errormsg;
} else { } else {
$conn_error = $GLOBALS['strCannotLogin']; $conn_error = $GLOBALS['strCannotLogin'];

View File

@@ -21,7 +21,7 @@
*/ */
function PMA_auth() { function PMA_auth() {
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('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('HTTP/1.0 401 Unauthorized');
header('status: 401 Unauthorized'); header('status: 401 Unauthorized');
@@ -83,19 +83,19 @@ function PMA_auth_check()
$PHP_AUTH_USER = $_SERVER['PHP_AUTH_USER']; $PHP_AUTH_USER = $_SERVER['PHP_AUTH_USER'];
} }
// CGI, might be encoded, see bellow // CGI, might be encoded, see bellow
else if (@getenv('REMOTE_USER')) { elseif (@getenv('REMOTE_USER')) {
$PHP_AUTH_USER = getenv('REMOTE_USER'); $PHP_AUTH_USER = getenv('REMOTE_USER');
} }
// WebSite Professional // WebSite Professional
else if (@getenv('AUTH_USER')) { elseif (@getenv('AUTH_USER')) {
$PHP_AUTH_USER = getenv('AUTH_USER'); $PHP_AUTH_USER = getenv('AUTH_USER');
} }
// IIS, might be encoded, see bellow // IIS, might be encoded, see bellow
else if (@getenv('HTTP_AUTHORIZATION')) { elseif (@getenv('HTTP_AUTHORIZATION')) {
$PHP_AUTH_USER = getenv('HTTP_AUTHORIZATION'); $PHP_AUTH_USER = getenv('HTTP_AUTHORIZATION');
} }
// FastCGI, might be encoded, see bellow // FastCGI, might be encoded, see bellow
else if (@getenv('Authorization')) { elseif (@getenv('Authorization')) {
$PHP_AUTH_USER = getenv('Authorization'); $PHP_AUTH_USER = getenv('Authorization');
} }
} }
@@ -107,11 +107,11 @@ function PMA_auth_check()
$PHP_AUTH_PW = $_SERVER['PHP_AUTH_PW']; $PHP_AUTH_PW = $_SERVER['PHP_AUTH_PW'];
} }
// Apache/CGI // Apache/CGI
else if (@getenv('REMOTE_PASSWORD')) { elseif (@getenv('REMOTE_PASSWORD')) {
$PHP_AUTH_PW = getenv('REMOTE_PASSWORD'); $PHP_AUTH_PW = getenv('REMOTE_PASSWORD');
} }
// WebSite Professional // WebSite Professional
else if (@getenv('AUTH_PASSWORD')) { elseif (@getenv('AUTH_PASSWORD')) {
$PHP_AUTH_PW = getenv('AUTH_PASSWORD'); $PHP_AUTH_PW = getenv('AUTH_PASSWORD');
} }
} }

View File

@@ -441,10 +441,10 @@ class Horde_Cipher_blowfish {
$R = null; $R = null;
$retarray = array_values(unpack('N*', $block)); $retarray = array_values(unpack('N*', $block));
if(isset($retarray[0])) { if (isset($retarray[0])) {
$L = $retarray[0]; $L = $retarray[0];
} }
if(isset($retarray[1])) { if (isset($retarray[1])) {
$R = $retarray[1]; $R = $retarray[1];
} }
// end change for phpMyAdmin // end change for phpMyAdmin
@@ -534,7 +534,7 @@ function PMA_blowfish_encrypt($data, $secret) {
for ($i=0; $i<strlen($data); $i+=8) { for ($i=0; $i<strlen($data); $i+=8) {
$block = substr($data, $i, 8); $block = substr($data, $i, 8);
if (strlen($block) < 8) { if (strlen($block) < 8) {
$block = full_str_pad($block,8,"\0", 1); $block = full_str_pad($block, 8, "\0", 1);
} }
$encrypt .= $pma_cipher->encryptBlock($block, $secret); $encrypt .= $pma_cipher->encryptBlock($block, $secret);
} }

View File

@@ -102,7 +102,9 @@ function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id', $action_bo
. ' OR user = \'\')' ) . ' OR user = \'\')' )
. ' AND ' . PMA_backquote($id_field) . ' = ' . $id; . ' AND ' . PMA_backquote($id_field) . ' = ' . $id;
$result = PMA_DBI_try_query($query, $controllink); $result = PMA_DBI_try_query($query, $controllink);
if (!$result) return FALSE; if (!$result) {
return FALSE;
}
list($bookmark_query) = PMA_DBI_fetch_row($result) or array(FALSE); list($bookmark_query) = PMA_DBI_fetch_row($result) or array(FALSE);
return $bookmark_query; return $bookmark_query;
@@ -132,7 +134,7 @@ function &PMA_queryDBBookmarks($db, $cfgBookmark, &$table_array)
} }
$search_for = array(); $search_for = array();
foreach($table_array AS $table => $table_sortkey) { foreach ($table_array AS $table => $table_sortkey) {
$search_for[] = "'" . PMA_sqlAddslashes($table) . "'"; $search_for[] = "'" . PMA_sqlAddslashes($table) . "'";
} }
@@ -140,7 +142,9 @@ function &PMA_queryDBBookmarks($db, $cfgBookmark, &$table_array)
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\'' . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
. (count($search_for) > 0 ? ' AND label IN (' . implode(', ', $search_for) . ')' : ''); . (count($search_for) > 0 ? ' AND label IN (' . implode(', ', $search_for) . ')' : '');
$result = PMA_DBI_try_query($query, $controllink, PMA_DBI_QUERY_STORE); $result = PMA_DBI_try_query($query, $controllink, PMA_DBI_QUERY_STORE);
if (!$result || PMA_DBI_num_rows($result) < 1) return $bookmarks; if (!$result || PMA_DBI_num_rows($result) < 1) {
return $bookmarks;
}
while ($row = PMA_DBI_fetch_assoc($result)) { while ($row = PMA_DBI_fetch_assoc($result)) {
$bookmarks[$row['label']] = $row['query']; $bookmarks[$row['label']] = $row['query'];
} }

View File

@@ -24,7 +24,7 @@ if (isset($cfg['AllowAnywhereRecoding'])
} }
} }
$PMA_recoding_engine = 'recode'; $PMA_recoding_engine = 'recode';
} else if ($cfg['RecodingEngine'] == 'iconv') { } elseif ($cfg['RecodingEngine'] == 'iconv') {
if (!@extension_loaded('iconv')) { if (!@extension_loaded('iconv')) {
PMA_dl('iconv'); PMA_dl('iconv');
if (!@extension_loaded('iconv')) { if (!@extension_loaded('iconv')) {
@@ -36,7 +36,7 @@ if (isset($cfg['AllowAnywhereRecoding'])
} else { } else {
if (@extension_loaded('iconv')) { if (@extension_loaded('iconv')) {
$PMA_recoding_engine = 'iconv'; $PMA_recoding_engine = 'iconv';
} else if (@extension_loaded('recode')) { } elseif (@extension_loaded('recode')) {
$PMA_recoding_engine = 'recode'; $PMA_recoding_engine = 'recode';
} else { } else {
PMA_dl('iconv'); PMA_dl('iconv');
@@ -75,7 +75,7 @@ if (isset($cfg['AllowAnywhereRecoding'])
if ($PMA_recoding_engine == 'iconv') { if ($PMA_recoding_engine == 'iconv') {
if (@function_exists('iconv')) { if (@function_exists('iconv')) {
$PMA_recoding_engine = PMA_CHARSET_ICONV; $PMA_recoding_engine = PMA_CHARSET_ICONV;
} else if (@function_exists('libiconv')) { } elseif (@function_exists('libiconv')) {
$PMA_recoding_engine = PMA_CHARSET_LIBICONV; $PMA_recoding_engine = PMA_CHARSET_LIBICONV;
} else { } else {
$PMA_recoding_engine = PMA_CHARSET_NONE; $PMA_recoding_engine = PMA_CHARSET_NONE;
@@ -87,7 +87,7 @@ if (isset($cfg['AllowAnywhereRecoding'])
require_once('./libraries/footer.inc.php'); require_once('./libraries/footer.inc.php');
exit(); exit();
} }
} else if ($PMA_recoding_engine == 'recode') { } elseif ($PMA_recoding_engine == 'recode') {
if (@function_exists('recode_string')) { if (@function_exists('recode_string')) {
$PMA_recoding_engine = PMA_CHARSET_RECODE; $PMA_recoding_engine = PMA_CHARSET_RECODE;
} else { } else {
@@ -101,7 +101,7 @@ if (isset($cfg['AllowAnywhereRecoding'])
} else { } else {
if (@function_exists('iconv')) { if (@function_exists('iconv')) {
$PMA_recoding_engine = PMA_CHARSET_ICONV; $PMA_recoding_engine = PMA_CHARSET_ICONV;
} else if (@function_exists('libiconv')) { } elseif (@function_exists('libiconv')) {
$PMA_recoding_engine = PMA_CHARSET_LIBICONV; $PMA_recoding_engine = PMA_CHARSET_LIBICONV;
} elseif (@function_exists('recode_string')) { } elseif (@function_exists('recode_string')) {
$PMA_recoding_engine = PMA_CHARSET_RECODE; $PMA_recoding_engine = PMA_CHARSET_RECODE;
@@ -143,8 +143,7 @@ function PMA_convert_display_charset($what) {
// this constant is not defined before the login: // this constant is not defined before the login:
|| (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION >= 40100) ) { // lem9: even if AllowAnywhereRecoding is TRUE, do not recode for MySQL >= 4.1.x since MySQL does the job || (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION >= 40100) ) { // lem9: even if AllowAnywhereRecoding is TRUE, do not recode for MySQL >= 4.1.x since MySQL does the job
return $what; return $what;
} } elseif (is_array($what)) {
else if (is_array($what)) {
$result = array(); $result = array();
foreach ($what AS $key => $val) { foreach ($what AS $key => $val) {
if (is_string($val) || is_array($val)) { if (is_string($val) || is_array($val)) {
@@ -158,8 +157,7 @@ function PMA_convert_display_charset($what) {
} }
} // end while } // end while
return $result; return $result;
} } elseif (is_string($what)) {
else if (is_string($what)) {
switch ($GLOBALS['PMA_recoding_engine']) { switch ($GLOBALS['PMA_recoding_engine']) {
case PMA_CHARSET_RECODE: case PMA_CHARSET_RECODE:
@@ -171,8 +169,7 @@ function PMA_convert_display_charset($what) {
default: default:
return $what; return $what;
} }
} } elseif (is_object($what)) {
else if (is_object($what)) {
// isn't it object returned from mysql_fetch_field ? // isn't it object returned from mysql_fetch_field ?
if (@is_string($what->name)) { if (@is_string($what->name)) {
$what->name = PMA_convert_display_charset($what->name); $what->name = PMA_convert_display_charset($what->name);
@@ -184,8 +181,7 @@ function PMA_convert_display_charset($what) {
$what->Database = PMA_convert_display_charset($what->Database); $what->Database = PMA_convert_display_charset($what->Database);
} }
return $what; return $what;
} } else {
else {
// when we don't know what it is we don't touch it... // when we don't know what it is we don't touch it...
return $what; return $what;
} }
@@ -243,7 +239,9 @@ function PMA_convert_charset($what) {
* @author nijel * @author nijel
*/ */
function PMA_convert_string($src_charset, $dest_charset, $what) { function PMA_convert_string($src_charset, $dest_charset, $what) {
if ($src_charset == $dest_charset) return $what; if ($src_charset == $dest_charset) {
return $what;
}
switch ($GLOBALS['PMA_recoding_engine']) { switch ($GLOBALS['PMA_recoding_engine']) {
case PMA_CHARSET_RECODE: case PMA_CHARSET_RECODE:
return recode_string($src_charset . '..' . $dest_charset, $what); return recode_string($src_charset . '..' . $dest_charset, $what);

View File

@@ -33,9 +33,9 @@ function PMA_analyseShowGrant($rs_usr, &$is_create_db_priv, &$db_to_create, &$is
$re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards $re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards
$re1 = '(^|[^\])(\\\)+'; // escaped wildcards $re1 = '(^|[^\])(\\\)+'; // escaped wildcards
while ($row = PMA_DBI_fetch_row($rs_usr)) { while ($row = PMA_DBI_fetch_row($rs_usr)) {
$show_grants_dbname = substr($row[0], strpos($row[0], ' ON ') + 4,(strpos($row[0], '.', strpos($row[0], ' ON ')) - strpos($row[0], ' ON ') - 4)); $show_grants_dbname = substr($row[0], strpos($row[0], ' ON ') + 4, (strpos($row[0], '.', strpos($row[0], ' ON ')) - strpos($row[0], ' ON ') - 4));
$show_grants_dbname = ereg_replace('^`(.*)`','\\1', $show_grants_dbname); $show_grants_dbname = ereg_replace('^`(.*)`', '\\1', $show_grants_dbname);
$show_grants_str = substr($row[0],6,(strpos($row[0],' ON ')-6)); $show_grants_str = substr($row[0], 6, (strpos($row[0], ' ON ') - 6));
if ($show_grants_str == 'RELOAD') { if ($show_grants_str == 'RELOAD') {
$is_reload_priv = true; $is_reload_priv = true;
} }
@@ -47,8 +47,7 @@ function PMA_analyseShowGrant($rs_usr, &$is_create_db_priv, &$db_to_create, &$is
$db_to_create = ''; $db_to_create = '';
$dbs_where_create_table_allowed[] = '*'; $dbs_where_create_table_allowed[] = '*';
break; break;
} // end if } else {
else {
// this array may contain wildcards // this array may contain wildcards
$dbs_where_create_table_allowed[] = $show_grants_dbname; $dbs_where_create_table_allowed[] = $show_grants_dbname;
@@ -67,7 +66,7 @@ function PMA_analyseShowGrant($rs_usr, &$is_create_db_priv, &$db_to_create, &$is
if ( (ereg($re0 . '%|_', $show_grants_dbname) if ( (ereg($re0 . '%|_', $show_grants_dbname)
&& !ereg('\\\\%|\\\\_', $show_grants_dbname)) && !ereg('\\\\%|\\\\_', $show_grants_dbname))
// does this db exist? // does this db exist?
|| (!PMA_DBI_try_query('USE ' . ereg_replace($re1 .'(%|_)', '\\1\\3',$dbname_to_test), NULL, PMA_DBI_QUERY_STORE) && substr(PMA_DBI_getError(), 1, 4) != 1044) || (!PMA_DBI_try_query('USE ' . ereg_replace($re1 .'(%|_)', '\\1\\3', $dbname_to_test), null, PMA_DBI_QUERY_STORE) && substr(PMA_DBI_getError(), 1, 4) != 1044)
) { ) {
$db_to_create = ereg_replace($re0 . '%', '\\1...', ereg_replace($re0 . '_', '\\1?', $show_grants_dbname)); $db_to_create = ereg_replace($re0 . '%', '\\1...', ereg_replace($re0 . '_', '\\1?', $show_grants_dbname));
$db_to_create = ereg_replace($re1 . '(%|_)', '\\1\\3', $db_to_create); $db_to_create = ereg_replace($re1 . '(%|_)', '\\1\\3', $db_to_create);
@@ -93,7 +92,7 @@ function PMA_analyseShowGrant($rs_usr, &$is_create_db_priv, &$db_to_create, &$is
if (PMA_MYSQL_INT_VERSION >= 40102) { if (PMA_MYSQL_INT_VERSION >= 40102) {
$rs_usr = PMA_DBI_try_query('SHOW GRANTS', $userlink, PMA_DBI_QUERY_STORE); $rs_usr = PMA_DBI_try_query('SHOW GRANTS', $userlink, PMA_DBI_QUERY_STORE);
if ($rs_usr) { if ($rs_usr) {
PMA_analyseShowGrant($rs_usr,$is_create_db_priv, $db_to_create, $is_reload_priv, $dbs_where_create_table_allowed); PMA_analyseShowGrant($rs_usr, $is_create_db_priv, $db_to_create, $is_reload_priv, $dbs_where_create_table_allowed);
PMA_DBI_free_result($rs_usr); PMA_DBI_free_result($rs_usr);
unset($rs_usr); unset($rs_usr);
} }
@@ -104,7 +103,7 @@ if (PMA_MYSQL_INT_VERSION >= 40102) {
// $userlink so maybe the SELECT will fail // $userlink so maybe the SELECT will fail
if (!$is_create_db_priv) { if (!$is_create_db_priv) {
$res = PMA_DBI_query('SELECT USER();', NULL, PMA_DBI_QUERY_STORE); $res = PMA_DBI_query('SELECT USER();', null, PMA_DBI_QUERY_STORE);
list($mysql_cur_user_and_host) = PMA_DBI_fetch_row($res); list($mysql_cur_user_and_host) = PMA_DBI_fetch_row($res);
$mysql_cur_user = substr($mysql_cur_user_and_host, 0, strrpos($mysql_cur_user_and_host, '@')); $mysql_cur_user = substr($mysql_cur_user_and_host, 0, strrpos($mysql_cur_user_and_host, '@'));
@@ -149,8 +148,7 @@ if (PMA_MYSQL_INT_VERSION >= 40102) {
} // end while } // end while
PMA_DBI_free_result($rs_usr); PMA_DBI_free_result($rs_usr);
unset($rs_usr, $row, $re0, $re1); unset($rs_usr, $row, $re0, $re1);
} // end if } else {
else {
// Finally, let's try to get the user's privileges by using SHOW // Finally, let's try to get the user's privileges by using SHOW
// GRANTS... // GRANTS...
// Maybe we'll find a little CREATE priv there :) // Maybe we'll find a little CREATE priv there :)
@@ -162,7 +160,7 @@ if (PMA_MYSQL_INT_VERSION >= 40102) {
} }
unset($local_query); unset($local_query);
if ($rs_usr) { if ($rs_usr) {
PMA_analyseShowGrant($rs_usr,$is_create_db_priv, $db_to_create, $is_reload_priv, $dbs_where_create_table_allowed); PMA_analyseShowGrant($rs_usr, $is_create_db_priv, $db_to_create, $is_reload_priv, $dbs_where_create_table_allowed);
PMA_DBI_free_result($rs_usr); PMA_DBI_free_result($rs_usr);
unset($rs_usr); unset($rs_usr);
} // end if } // end if

View File

@@ -54,7 +54,7 @@
function PMA_securePath($path) function PMA_securePath($path)
{ {
// change .. to . // change .. to .
$path = preg_replace('@\.\.*@','.',$path); $path = preg_replace('@\.\.*@', '.', $path);
return $path; return $path;
} // end function } // end function
@@ -280,8 +280,7 @@ function PMA_safe_db_list($only_db_check, $controllink, $dblist_cnt, $userlink,
while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) { while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) {
$dblist[] = $uva_row[0]; $dblist[] = $uva_row[0];
} // end while } // end while
} // end if } else {
else {
while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) { while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) {
$uva_db = $uva_row[0]; $uva_db = $uva_row[0];
if (isset($uva_mydbs[$uva_db]) && $uva_mydbs[$uva_db] == 1) { if (isset($uva_mydbs[$uva_db]) && $uva_mydbs[$uva_db] == 1) {
@@ -648,11 +647,11 @@ if (!defined('PMA_MINIMUM_COMMON')) {
} }
break; break;
case 'html': case 'html':
$formatted_sql = PMA_SQP_formatHtml($parsed_sql,'color'); $formatted_sql = PMA_SQP_formatHtml($parsed_sql, 'color');
break; break;
case 'text': case 'text':
//$formatted_sql = PMA_SQP_formatText($parsed_sql); //$formatted_sql = PMA_SQP_formatText($parsed_sql);
$formatted_sql = PMA_SQP_formatHtml($parsed_sql,'text'); $formatted_sql = PMA_SQP_formatHtml($parsed_sql, 'text');
break; break;
default: default:
break; break;
@@ -677,7 +676,9 @@ if (!defined('PMA_MINIMUM_COMMON')) {
{ {
global $cfg; global $cfg;
if ($cfg['MySQLManualType'] == 'none' || empty($cfg['MySQLManualBase'])) return ''; if ($cfg['MySQLManualType'] == 'none' || empty($cfg['MySQLManualBase'])) {
return '';
}
// Fixup for newly used names: // Fixup for newly used names:
$chapter = str_replace('_', '-', strtolower($chapter)); $chapter = str_replace('_', '-', strtolower($chapter));
@@ -685,19 +686,25 @@ if (!defined('PMA_MINIMUM_COMMON')) {
switch ($cfg['MySQLManualType']) { switch ($cfg['MySQLManualType']) {
case 'chapters': case 'chapters':
if (empty($chapter)) $chapter = 'index'; if (empty($chapter)) {
$chapter = 'index';
}
$url = $cfg['MySQLManualBase'] . '/' . $chapter . '.html#' . $link; $url = $cfg['MySQLManualBase'] . '/' . $chapter . '.html#' . $link;
break; break;
case 'big': case 'big':
$url = $cfg['MySQLManualBase'] . '#' . $link; $url = $cfg['MySQLManualBase'] . '#' . $link;
break; break;
case 'searchable': case 'searchable':
if (empty($link)) $link = 'index'; if (empty($link)) {
$link = 'index';
}
$url = $cfg['MySQLManualBase'] . '/' . $link . '.html'; $url = $cfg['MySQLManualBase'] . '/' . $link . '.html';
break; break;
case 'viewable': case 'viewable':
default: default:
if (empty($link)) $link = 'index'; if (empty($link)) {
$link = 'index';
}
$mysql = '5.0'; $mysql = '5.0';
if (defined('PMA_MYSQL_INT_VERSION')) { if (defined('PMA_MYSQL_INT_VERSION')) {
if (PMA_MYSQL_INT_VERSION < 50000) { if (PMA_MYSQL_INT_VERSION < 50000) {
@@ -716,7 +723,7 @@ if (!defined('PMA_MINIMUM_COMMON')) {
return '<a href="' . $url . '" target="mysql_doc"><img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_sqlhelp.png" width="16" height="16" alt="' . $GLOBALS['strDocu'] . '" title="' . $GLOBALS['strDocu'] . '" /></a>'; return '<a href="' . $url . '" target="mysql_doc"><img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_sqlhelp.png" width="16" height="16" alt="' . $GLOBALS['strDocu'] . '" title="' . $GLOBALS['strDocu'] . '" /></a>';
} elseif ($GLOBALS['cfg']['ReplaceHelpImg']) { } elseif ($GLOBALS['cfg']['ReplaceHelpImg']) {
return '<a href="' . $url . '" target="mysql_doc"><img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_help.png" width="11" height="11" alt="' . $GLOBALS['strDocu'] . '" title="' . $GLOBALS['strDocu'] . '" /></a>'; return '<a href="' . $url . '" target="mysql_doc"><img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_help.png" width="11" height="11" alt="' . $GLOBALS['strDocu'] . '" title="' . $GLOBALS['strDocu'] . '" /></a>';
}else{ } else {
return '[<a href="' . $url . '" target="mysql_doc">' . $GLOBALS['strDocu'] . '</a>]'; return '[<a href="' . $url . '" target="mysql_doc">' . $GLOBALS['strDocu'] . '</a>]';
} }
} // end of the 'PMA_showMySQLDocu()' function } // end of the 'PMA_showMySQLDocu()' function
@@ -789,7 +796,7 @@ if (!defined('PMA_MINIMUM_COMMON')) {
// --- // ---
// modified to show me the help on sql errors (Michael Keck) // modified to show me the help on sql errors (Michael Keck)
echo ' <p><strong>' . $GLOBALS['strSQLQuery'] . ':</strong>' . "\n"; echo ' <p><strong>' . $GLOBALS['strSQLQuery'] . ':</strong>' . "\n";
if (strstr(strtolower($formatted_sql),'select')) { // please show me help to the error on select if (strstr(strtolower($formatted_sql), 'select')) { // please show me help to the error on select
echo PMA_showMySQLDocu('SQL-Syntax', 'SELECT'); echo PMA_showMySQLDocu('SQL-Syntax', 'SELECT');
} }
if ($is_modify_link && isset($db)) { if ($is_modify_link && isset($db)) {
@@ -1816,8 +1823,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
if ($tab['text'] == $GLOBALS['strEmpty'] if ($tab['text'] == $GLOBALS['strEmpty']
|| $tab['text'] == $GLOBALS['strDrop']) { || $tab['text'] == $GLOBALS['strDrop']) {
$tab['class'] = 'caution'; $tab['class'] = 'caution';
} } elseif (!empty($tab['active'])
elseif (!empty($tab['active'])
|| (isset($GLOBALS['active_page']) || (isset($GLOBALS['active_page'])
&& $GLOBALS['active_page'] == $tab['link']) && $GLOBALS['active_page'] == $tab['link'])
|| basename($_SERVER['PHP_SELF']) == $tab['link']) || basename($_SERVER['PHP_SELF']) == $tab['link'])
@@ -1910,24 +1916,22 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
function PMA_linkOrButton($url, $message, $tag_params = array(), function PMA_linkOrButton($url, $message, $tag_params = array(),
$new_form = true, $strip_img = false, $target = '') $new_form = true, $strip_img = false, $target = '')
{ {
if (!is_array($tag_params)) if (! is_array($tag_params)) {
{
$tmp = $tag_params; $tmp = $tag_params;
$tag_params = array(); $tag_params = array();
if (!empty($tmp)) if (!empty($tmp)) {
{
$tag_params['onclick'] = 'return confirmLink(this, \'' . $tmp . '\')'; $tag_params['onclick'] = 'return confirmLink(this, \'' . $tmp . '\')';
} }
unset($tmp); unset($tmp);
} }
if (!empty($target)) { if (! empty($target)) {
$tag_params['target'] = htmlentities($target); $tag_params['target'] = htmlentities($target);
} }
$tag_params_strings = array(); $tag_params_strings = array();
foreach ($tag_params as $par_name => $par_value) { foreach ($tag_params as $par_name => $par_value) {
// htmlentities() only on non javascript // htmlentities() only on non javascript
$par_value = substr($par_name,0 ,2) == 'on' $par_value = substr($par_name, 0, 2) == 'on'
? $par_value ? $par_value
: htmlentities($par_value); : htmlentities($par_value);
$tag_params_strings[] = $par_name . '="' . $par_value . '"'; $tag_params_strings[] = $par_name . '="' . $par_value . '"';
@@ -1939,8 +1943,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
$ret = "\n" . '<a href="' . $url . '" ' $ret = "\n" . '<a href="' . $url . '" '
. implode(' ', $tag_params_strings) . '>' . implode(' ', $tag_params_strings) . '>'
. $message . '</a>' . "\n"; . $message . '</a>' . "\n";
} } else {
else {
// no spaces (linebreaks) at all // no spaces (linebreaks) at all
// or after the hidden fields // or after the hidden fields
// IE will display them all // IE will display them all
@@ -2103,14 +2106,18 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
{ {
global $PHP_SELF, $checked_special; global $PHP_SELF, $checked_special;
if (!isset($checked_special)) $checked_special = false; if (!isset($checked_special)) {
$checked_special = false;
}
$reported_script_name = basename($PHP_SELF); $reported_script_name = basename($PHP_SELF);
$found_error = false; $found_error = false;
$error_message = ''; $error_message = '';
foreach ($params AS $param) { foreach ($params AS $param) {
if ($request && $param != 'db' && $param != 'table') $checked_special = true; if ($request && $param != 'db' && $param != 'table') {
$checked_special = true;
}
if (!isset($GLOBALS[$param])) { if (!isset($GLOBALS[$param])) {
$error_message .= $reported_script_name . ': Missing parameter: ' . $param . ' <a href="./Documentation.html#faqmissingparameters" target="documentation"> (FAQ 2.8)</a><br />'; $error_message .= $reported_script_name . ': Missing parameter: ' . $param . ' <a href="./Documentation.html#faqmissingparameters" target="documentation"> (FAQ 2.8)</a><br />';
@@ -2313,7 +2320,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
$i = $sliceStart; $i = $sliceStart;
$x = $nbTotalPage - $sliceEnd; $x = $nbTotalPage - $sliceEnd;
$met_boundary = false; $met_boundary = false;
while($i <= $x) { while ($i <= $x) {
if ($i >= ($pageNow - $range) && $i <= ($pageNow + $range)) { if ($i >= ($pageNow - $range) && $i <= ($pageNow + $range)) {
// If our pageselector comes near the current page, we use 1 // If our pageselector comes near the current page, we use 1
// counter increments // counter increments
@@ -2392,7 +2399,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
} }
} }
if ($default_current_timestamp && strpos(' ' . strtoupper($type),'TIMESTAMP') == 1) { if ($default_current_timestamp && strpos(' ' . strtoupper($type), 'TIMESTAMP') == 1) {
$query .= ' DEFAULT CURRENT_TIMESTAMP'; $query .= ' DEFAULT CURRENT_TIMESTAMP';
// 0 is empty in PHP // 0 is empty in PHP
} elseif (!empty($default) || $default == '0' || $default != $default_orig) { } elseif (!empty($default) || $default == '0' || $default != $default_orig) {

View File

@@ -288,7 +288,7 @@ function PMA_DBI_get_tables_full($database, $table = false,
FROM `information_schema`.`TABLES` FROM `information_schema`.`TABLES`
WHERE `TABLE_SCHEMA` IN (\'' . implode("', '", $databases) . '\') WHERE `TABLE_SCHEMA` IN (\'' . implode("', '", $databases) . '\')
' . $sql_where_table; ' . $sql_where_table;
$tables = PMA_DBI_fetch_result($sql, array('TABLE_SCHEMA','TABLE_NAME'), $tables = PMA_DBI_fetch_result($sql, array('TABLE_SCHEMA', 'TABLE_NAME'),
null, $link); null, $link);
unset( $sql_where_table, $sql ); unset( $sql_where_table, $sql );
} else { } else {
@@ -964,7 +964,7 @@ function PMA_DBI_fetch_result( $result, $key = null, $value = null,
if ( is_array($key) ) { if ( is_array($key) ) {
while ( $row = $fetch_function($result) ) { while ( $row = $fetch_function($result) ) {
$result_target =& $resultrows; $result_target =& $resultrows;
foreach( $key as $key_index ) { foreach ( $key as $key_index ) {
if ( ! isset( $result_target[$row[$key_index]] ) ) { if ( ! isset( $result_target[$row[$key_index]] ) ) {
$result_target[$row[$key_index]] = array(); $result_target[$row[$key_index]] = array();
} }
@@ -981,7 +981,7 @@ function PMA_DBI_fetch_result( $result, $key = null, $value = null,
if ( is_array($key) ) { if ( is_array($key) ) {
while ( $row = $fetch_function($result) ) { while ( $row = $fetch_function($result) ) {
$result_target =& $resultrows; $result_target =& $resultrows;
foreach( $key as $key_index ) { foreach ( $key as $key_index ) {
if ( ! isset( $result_target[$row[$key_index]] ) ) { if ( ! isset( $result_target[$row[$key_index]] ) ) {
$result_target[$row[$key_index]] = array(); $result_target[$row[$key_index]] = array();
} }

View File

@@ -68,7 +68,7 @@ if ( true === $cfg['SkipLockedTables'] ) {
PMA_DBI_free_result($db_info_result); PMA_DBI_free_result($db_info_result);
if (isset($sot_cache)) { if (isset($sot_cache)) {
$db_info_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . $tbl_group_sql . ';', NULL, PMA_DBI_QUERY_STORE); $db_info_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . $tbl_group_sql . ';', null, PMA_DBI_QUERY_STORE);
if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) { if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
while ($tmp = PMA_DBI_fetch_row($db_info_result)) { while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
if (!isset($sot_cache[$tmp[0]])) { if (!isset($sot_cache[$tmp[0]])) {
@@ -123,7 +123,7 @@ if ( ! isset( $sot_ready ) ) {
} }
if ( $cfg['ShowTooltip'] ) { if ( $cfg['ShowTooltip'] ) {
foreach( $tables as $each_table ) { foreach ( $tables as $each_table ) {
fillTooltip( $tooltip_truename, $tooltip_aliasname, $each_table ); fillTooltip( $tooltip_truename, $tooltip_aliasname, $each_table );
} }
} }

View File

@@ -19,7 +19,7 @@ if (empty($sub_part)) {
// priv CREATE TEMPORARY TABLES or LOCK TABLES can do a 'USE mysql' // priv CREATE TEMPORARY TABLES or LOCK TABLES can do a 'USE mysql'
// (even if they cannot see the tables) // (even if they cannot see the tables)
$is_superuser = PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user', NULL, PMA_DBI_QUERY_STORE); $is_superuser = PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user', null, PMA_DBI_QUERY_STORE);
/** /**
* Prepares links * Prepares links

View File

@@ -21,7 +21,7 @@ if (!isset($is_db) || !$is_db) {
if (!isset($is_table) || !$is_table) { if (!isset($is_table) || !$is_table) {
// Not a valid table name -> back to the db_details.php // Not a valid table name -> back to the db_details.php
if (isset($table) && strlen($table)) { if (isset($table) && strlen($table)) {
$is_table = PMA_DBI_try_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';', NULL, PMA_DBI_QUERY_STORE); $is_table = PMA_DBI_try_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';', null, PMA_DBI_QUERY_STORE);
} }
if (! isset($table) && ! strlen($table) if (! isset($table) && ! strlen($table)
|| !($is_table && @PMA_DBI_num_rows($is_table))) { || !($is_table && @PMA_DBI_num_rows($is_table))) {
@@ -31,7 +31,7 @@ if (!isset($is_table) || !$is_table) {
if (isset($table) && strlen($table)) { if (isset($table) && strlen($table)) {
PMA_DBI_free_result($is_table); PMA_DBI_free_result($is_table);
// SHOW TABLES doesn't show temporary tables, so try select (as it can happen just in case temporary table, it should be fast): // SHOW TABLES doesn't show temporary tables, so try select (as it can happen just in case temporary table, it should be fast):
$is_table2 = PMA_DBI_try_query('SELECT COUNT(*) FROM `' . PMA_sqlAddslashes($table, TRUE) . '`;', NULL, PMA_DBI_QUERY_STORE); $is_table2 = PMA_DBI_try_query('SELECT COUNT(*) FROM `' . PMA_sqlAddslashes($table, TRUE) . '`;', null, PMA_DBI_QUERY_STORE);
$redirect = !($is_table2 && @PMA_DBI_num_rows($is_table2)); $redirect = !($is_table2 && @PMA_DBI_num_rows($is_table2));
PMA_DBI_free_result($is_table2); PMA_DBI_free_result($is_table2);
} }
@@ -40,8 +40,10 @@ if (!isset($is_table) || !$is_table) {
PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'db_details.php?' . PMA_generate_common_url($db, '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1'); PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'db_details.php?' . PMA_generate_common_url($db, '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
} }
} }
if ($redirect) exit; if ($redirect) {
} else if (isset($is_table)) { exit;
}
} elseif (isset($is_table)) {
PMA_DBI_free_result($is_table); PMA_DBI_free_result($is_table);
} }
} // end if (ensures table exists) } // end if (ensures table exists)

View File

@@ -67,8 +67,8 @@ if ( ! empty( $GLOBALS['DBG'] )
if ( $time_avg_hit > $GLOBALS['cfg']['DBG']['profile']['threshold'] ) { if ( $time_avg_hit > $GLOBALS['cfg']['DBG']['profile']['threshold'] ) {
echo '<tr class="' . $odd_row ? 'odd' : 'even' . '">' . echo '<tr class="' . $odd_row ? 'odd' : 'even' . '">' .
// gma changed "$mod_name" to "substr($mod_name,$cwdlen+1)" // gma changed "$mod_name" to "substr($mod_name, $cwdlen+1)"
'<td>' . substr($mod_name,$cwdlen+1) . '</td>' . '<td>' . substr($mod_name, $cwdlen+1) . '</td>' .
'<td>' . $line_no . '</td>' . '<td>' . $line_no . '</td>' .
'<td>' . $dbg_prof_results['hit_count'][$idx] . '</td>' . '<td>' . $dbg_prof_results['hit_count'][$idx] . '</td>' .
'<td>' . $time_avg_hit . '</td>' . '<td>' . $time_avg_hit . '</td>' .

View File

@@ -60,7 +60,7 @@ function PMA_DBI_connect($user, $password, $is_controluser = FALSE) {
return $link; return $link;
} }
function PMA_DBI_select_db($dbname, $link = NULL) { function PMA_DBI_select_db($dbname, $link = null) {
if (empty($link)) { if (empty($link)) {
if (isset($GLOBALS['userlink'])) { if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink']; $link = $GLOBALS['userlink'];
@@ -74,7 +74,7 @@ function PMA_DBI_select_db($dbname, $link = NULL) {
return mysql_select_db($dbname, $link); return mysql_select_db($dbname, $link);
} }
function PMA_DBI_try_query($query, $link = NULL, $options = 0) { function PMA_DBI_try_query($query, $link = null, $options = 0) {
if (empty($link)) { if (empty($link)) {
if (isset($GLOBALS['userlink'])) { if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink']; $link = $GLOBALS['userlink'];
@@ -106,7 +106,9 @@ function PMA_mysql_fetch_array($result, $type = FALSE) {
} }
/* No data returned => do not touch it */ /* No data returned => do not touch it */
if (! $data) return $data; if (! $data) {
return $data;
}
if (!defined('PMA_MYSQL_INT_VERSION') || PMA_MYSQL_INT_VERSION >= 40100 if (!defined('PMA_MYSQL_INT_VERSION') || PMA_MYSQL_INT_VERSION >= 40100
|| !(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) { || !(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
@@ -121,11 +123,19 @@ function PMA_mysql_fetch_array($result, $type = FALSE) {
$flags = mysql_field_flags($result, $i); $flags = mysql_field_flags($result, $i);
/* Field is BINARY (either marked manually, or it is BLOB) => do not convert it */ /* Field is BINARY (either marked manually, or it is BLOB) => do not convert it */
if (stristr($flags, 'BINARY')) { if (stristr($flags, 'BINARY')) {
if (isset($data[$i])) $ret[$i] = $data[$i]; if (isset($data[$i])) {
if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = $data[$name]; $ret[$i] = $data[$i];
}
if (isset($data[$name])) {
$ret[PMA_convert_display_charset($name)] = $data[$name];
}
} else { } else {
if (isset($data[$i])) $ret[$i] = PMA_convert_display_charset($data[$i]); if (isset($data[$i])) {
if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = PMA_convert_display_charset($data[$name]); $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;
@@ -165,15 +175,16 @@ function PMA_DBI_free_result() {
* @param resource $link mysql link * @param resource $link mysql link
* @return string type of connection used * @return string type of connection used
*/ */
function PMA_DBI_get_host_info( $link = NULL ) { function PMA_DBI_get_host_info($link = null)
if ( NULL === $link ) { {
if ( isset( $GLOBALS['userlink'] ) ) { if (null === $link) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink']; $link = $GLOBALS['userlink'];
} else { } else {
return false; return false;
} }
} }
return mysql_get_host_info( $link ); return mysql_get_host_info($link);
} }
/** /**
@@ -183,15 +194,16 @@ function PMA_DBI_get_host_info( $link = NULL ) {
* @param resource $link mysql link * @param resource $link mysql link
* @return integer version of the MySQL protocol used * @return integer version of the MySQL protocol used
*/ */
function PMA_DBI_get_proto_info( $link = NULL ) { function PMA_DBI_get_proto_info($link = null)
if ( NULL === $link ) { {
if ( isset( $GLOBALS['userlink'] ) ) { if (null === $link) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink']; $link = $GLOBALS['userlink'];
} else { } else {
return false; return false;
} }
} }
return mysql_get_proto_info( $link ); return mysql_get_proto_info($link);
} }
/** /**
@@ -219,9 +231,10 @@ function PMA_DBI_get_client_info() {
* @param resource $link mysql link * @param resource $link mysql link
* @return string|boolean $error or false * @return string|boolean $error or false
*/ */
function PMA_DBI_getError( $link = NULL ) { function PMA_DBI_getError($link = null)
unset( $GLOBALS['errno'] ); {
if ( NULL === $link && isset( $GLOBALS['userlink'] ) ) { unset($GLOBALS['errno']);
if (null === $link && isset($GLOBALS['userlink'])) {
$link =& $GLOBALS['userlink']; $link =& $GLOBALS['userlink'];
// Do not stop now. On the initial connection, we don't have a $link, // Do not stop now. On the initial connection, we don't have a $link,
@@ -230,38 +243,39 @@ function PMA_DBI_getError( $link = NULL ) {
// return FALSE; // return FALSE;
} }
if ( NULL !== $link ) { if (null !== $link) {
$error_number = mysql_errno( $link ); $error_number = mysql_errno($link);
$error_message = mysql_error( $link ); $error_message = mysql_error($link);
} else { } else {
$error_number = mysql_errno(); $error_number = mysql_errno();
$error_message = mysql_error(); $error_message = mysql_error();
} }
if ( 0 == $error_number ) { if (0 == $error_number) {
return false; return false;
} }
// keep the error number for further check after the call to PMA_DBI_getError() // keep the error number for further check after the call to PMA_DBI_getError()
$GLOBALS['errno'] = $error_number; $GLOBALS['errno'] = $error_number;
if ( ! empty( $error_message ) ) { if (! empty($error_message)) {
$error_message = PMA_DBI_convert_message( $error_message ); $error_message = PMA_DBI_convert_message($error_message);
} }
// Some errors messages cannot be obtained by mysql_error() // Some errors messages cannot be obtained by mysql_error()
if ( $error_number == 2002 ) { if ($error_number == 2002) {
$error = '#' . ((string) $error_number) . ' - ' . $GLOBALS['strServerNotResponding'] . ' ' . $GLOBALS['strSocketProblem']; $error = '#' . ((string) $error_number) . ' - ' . $GLOBALS['strServerNotResponding'] . ' ' . $GLOBALS['strSocketProblem'];
} elseif ( $error_number == 2003 ) { } elseif ($error_number == 2003 ) {
$error = '#' . ((string) $error_number ) . ' - ' . $GLOBALS['strServerNotResponding']; $error = '#' . ((string) $error_number) . ' - ' . $GLOBALS['strServerNotResponding'];
} elseif ( defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION >= 40100 ) { } elseif (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION >= 40100) {
$error = '#' . ((string) $error_number ) . ' - ' . $error_message; $error = '#' . ((string) $error_number) . ' - ' . $error_message;
} else { } else {
$error = '#' . ((string) $error_number ) . ' - ' . PMA_convert_display_charset( $error_message ); $error = '#' . ((string) $error_number) . ' - ' . PMA_convert_display_charset($error_message);
} }
return $error; return $error;
} }
function PMA_DBI_close($link = NULL) { function PMA_DBI_close($link = null)
{
if (empty($link)) { if (empty($link)) {
if (isset($GLOBALS['userlink'])) { if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink']; $link = $GLOBALS['userlink'];
@@ -280,7 +294,8 @@ function PMA_DBI_num_rows($result) {
} }
} }
function PMA_DBI_insert_id($link = NULL) { function PMA_DBI_insert_id($link = null)
{
if (empty($link)) { if (empty($link)) {
if (isset($GLOBALS['userlink'])) { if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink']; $link = $GLOBALS['userlink'];
@@ -291,7 +306,8 @@ function PMA_DBI_insert_id($link = NULL) {
return mysql_insert_id($link); return mysql_insert_id($link);
} }
function PMA_DBI_affected_rows($link = NULL) { function PMA_DBI_affected_rows($link = null)
{
if (empty($link)) { if (empty($link)) {
if (isset($GLOBALS['userlink'])) { if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink']; $link = $GLOBALS['userlink'];

View File

@@ -31,7 +31,8 @@ define('NUM_FLAG', 32768);
define('PART_KEY_FLAG', 16384); define('PART_KEY_FLAG', 16384);
define('UNIQUE_FLAG', 65536); define('UNIQUE_FLAG', 65536);
function PMA_DBI_connect($user, $password, $is_controluser = FALSE) { function PMA_DBI_connect($user, $password, $is_controluser = FALSE)
{
global $cfg, $php_errormsg; global $cfg, $php_errormsg;
$server_port = (empty($cfg['Server']['port'])) $server_port = (empty($cfg['Server']['port']))
@@ -44,7 +45,7 @@ function PMA_DBI_connect($user, $password, $is_controluser = FALSE) {
// NULL enables connection to the default socket // NULL enables connection to the default socket
$server_socket = (empty($cfg['Server']['socket'])) $server_socket = (empty($cfg['Server']['socket']))
? NULL ? null
: $cfg['Server']['socket']; : $cfg['Server']['socket'];
$link = mysqli_init(); $link = mysqli_init();
@@ -64,7 +65,8 @@ function PMA_DBI_connect($user, $password, $is_controluser = FALSE) {
return $link; return $link;
} }
function PMA_DBI_select_db($dbname, $link = NULL) { function PMA_DBI_select_db($dbname, $link = null)
{
if (empty($link)) { if (empty($link)) {
if (isset($GLOBALS['userlink'])) { if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink']; $link = $GLOBALS['userlink'];
@@ -78,7 +80,8 @@ function PMA_DBI_select_db($dbname, $link = NULL) {
return mysqli_select_db($link, $dbname); return mysqli_select_db($link, $dbname);
} }
function PMA_DBI_try_query($query, $link = NULL, $options = 0) { function PMA_DBI_try_query($query, $link = null, $options = 0)
{
if ($options == ($options | PMA_DBI_QUERY_STORE)) { if ($options == ($options | PMA_DBI_QUERY_STORE)) {
$method = MYSQLI_STORE_RESULT; $method = MYSQLI_STORE_RESULT;
} elseif ($options == ($options | PMA_DBI_QUERY_UNBUFFERED)) { } elseif ($options == ($options | PMA_DBI_QUERY_UNBUFFERED)) {
@@ -107,7 +110,8 @@ function PMA_DBI_try_query($query, $link = NULL, $options = 0) {
// The following function is meant for internal use only. // The following function is meant for internal use only.
// Do not call it from outside this library! // Do not call it from outside this library!
function PMA_mysqli_fetch_array($result, $type = FALSE) { function PMA_mysqli_fetch_array($result, $type = FALSE)
{
global $cfg, $allow_recoding, $charset, $convcharset; global $cfg, $allow_recoding, $charset, $convcharset;
if ($type != FALSE) { if ($type != FALSE) {
@@ -117,7 +121,9 @@ function PMA_mysqli_fetch_array($result, $type = FALSE) {
} }
/* No data returned => do not touch it */ /* No data returned => do not touch it */
if (! $data) return $data; if (! $data) {
return $data;
}
if (!defined('PMA_MYSQL_INT_VERSION') || PMA_MYSQL_INT_VERSION >= 40100 if (!defined('PMA_MYSQL_INT_VERSION') || PMA_MYSQL_INT_VERSION >= 40100
|| !(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) { || !(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
@@ -167,15 +173,18 @@ function PMA_mysqli_fetch_array($result, $type = FALSE) {
} }
} }
function PMA_DBI_fetch_array($result) { function PMA_DBI_fetch_array($result)
{
return PMA_mysqli_fetch_array($result, MYSQLI_BOTH); return PMA_mysqli_fetch_array($result, MYSQLI_BOTH);
} }
function PMA_DBI_fetch_assoc($result) { function PMA_DBI_fetch_assoc($result)
{
return PMA_mysqli_fetch_array($result, MYSQLI_ASSOC); return PMA_mysqli_fetch_array($result, MYSQLI_ASSOC);
} }
function PMA_DBI_fetch_row($result) { function PMA_DBI_fetch_row($result)
{
return PMA_mysqli_fetch_array($result, MYSQLI_NUM); return PMA_mysqli_fetch_array($result, MYSQLI_NUM);
} }
@@ -184,10 +193,11 @@ function PMA_DBI_fetch_row($result) {
* *
* @param result $result,... one or more mysql result resources * @param result $result,... one or more mysql result resources
*/ */
function PMA_DBI_free_result() { function PMA_DBI_free_result()
foreach ( func_get_args() as $result ) { {
if ( is_object($result) foreach (func_get_args() as $result) {
&& is_a($result, 'mysqli_result') ) { if (is_object($result)
&& is_a($result, 'mysqli_result')) {
mysqli_free_result($result); mysqli_free_result($result);
} }
} }
@@ -200,15 +210,16 @@ function PMA_DBI_free_result() {
* @param resource $link mysql link * @param resource $link mysql link
* @return string type of connection used * @return string type of connection used
*/ */
function PMA_DBI_get_host_info( $link = NULL ) { function PMA_DBI_get_host_info($link = null)
if ( NULL === $link ) { {
if ( isset( $GLOBALS['userlink'] ) ) { if (null === $link) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink']; $link = $GLOBALS['userlink'];
} else { } else {
return false; return false;
} }
} }
return mysqli_get_host_info( $link ); return mysqli_get_host_info($link);
} }
/** /**
@@ -218,15 +229,16 @@ function PMA_DBI_get_host_info( $link = NULL ) {
* @param resource $link mysql link * @param resource $link mysql link
* @return integer version of the MySQL protocol used * @return integer version of the MySQL protocol used
*/ */
function PMA_DBI_get_proto_info( $link = NULL ) { function PMA_DBI_get_proto_info( $link = null )
if ( NULL === $link ) { {
if ( isset( $GLOBALS['userlink'] ) ) { if (null === $link) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink']; $link = $GLOBALS['userlink'];
} else { } else {
return false; return false;
} }
} }
return mysqli_get_proto_info( $link ); return mysqli_get_proto_info($link);
} }
/** /**
@@ -256,10 +268,11 @@ function PMA_DBI_get_client_info() {
* @param resource $link mysql link * @param resource $link mysql link
* @return string|boolean $error or false * @return string|boolean $error or false
*/ */
function PMA_DBI_getError( $link = NULL ) { function PMA_DBI_getError($link = null)
unset( $GLOBALS['errno'] ); {
unset($GLOBALS['errno']);
if ( NULL === $link && isset( $GLOBALS['userlink'] ) ) { if (null === $link && isset($GLOBALS['userlink'])) {
$link =& $GLOBALS['userlink']; $link =& $GLOBALS['userlink'];
// Do not stop now. We still can get the error code // Do not stop now. We still can get the error code
// with mysqli_connect_errno() // with mysqli_connect_errno()
@@ -267,27 +280,27 @@ function PMA_DBI_getError( $link = NULL ) {
// return false; // return false;
} }
if ( NULL !== $link ) { if (null !== $link) {
$error_number = mysqli_errno( $link ); $error_number = mysqli_errno($link);
$error_message = mysqli_error( $link ); $error_message = mysqli_error($link);
} else { } else {
$error_number = mysqli_connect_errno(); $error_number = mysqli_connect_errno();
$error_message = mysqli_connect_error(); $error_message = mysqli_connect_error();
} }
if ( 0 == $error_number ) { if (0 == $error_number) {
return false; return false;
} }
// keep the error number for further check after the call to PMA_DBI_getError() // keep the error number for further check after the call to PMA_DBI_getError()
$GLOBALS['errno'] = $error_number; $GLOBALS['errno'] = $error_number;
if ( ! empty( $error_message ) ) { if (! empty($error_message)) {
$error_message = PMA_DBI_convert_message( $error_message ); $error_message = PMA_DBI_convert_message($error_message);
} }
if ( $error_number == 2002 ) { if ($error_number == 2002) {
$error = '#' . ((string) $error_number) . ' - ' . $GLOBALS['strServerNotResponding'] . ' ' . $GLOBALS['strSocketProblem']; $error = '#' . ((string) $error_number) . ' - ' . $GLOBALS['strServerNotResponding'] . ' ' . $GLOBALS['strSocketProblem'];
} elseif ( defined( 'PMA_MYSQL_INT_VERSION' ) && PMA_MYSQL_INT_VERSION >= 40100 ) { } elseif (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION >= 40100) {
$error = '#' . ((string) $error_number) . ' - ' . $error_message; $error = '#' . ((string) $error_number) . ' - ' . $error_message;
} else { } else {
$error = '#' . ((string) $error_number) . ' - ' . PMA_convert_display_charset($error_message); $error = '#' . ((string) $error_number) . ' - ' . PMA_convert_display_charset($error_message);
@@ -295,7 +308,8 @@ function PMA_DBI_getError( $link = NULL ) {
return $error; return $error;
} }
function PMA_DBI_close($link = NULL) { function PMA_DBI_close($link = null)
{
if (empty($link)) { if (empty($link)) {
if (isset($GLOBALS['userlink'])) { if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink']; $link = $GLOBALS['userlink'];
@@ -306,7 +320,8 @@ function PMA_DBI_close($link = NULL) {
return @mysqli_close($link); return @mysqli_close($link);
} }
function PMA_DBI_num_rows($result) { function PMA_DBI_num_rows($result)
{
// see the note for PMA_DBI_try_query(); // see the note for PMA_DBI_try_query();
if (!is_bool($result)) { if (!is_bool($result)) {
return @mysqli_num_rows($result); return @mysqli_num_rows($result);
@@ -315,7 +330,8 @@ function PMA_DBI_num_rows($result) {
} }
} }
function PMA_DBI_insert_id($link = '') { function PMA_DBI_insert_id($link = '')
{
if (empty($link)) { if (empty($link)) {
if (isset($GLOBALS['userlink'])) { if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink']; $link = $GLOBALS['userlink'];
@@ -326,7 +342,8 @@ function PMA_DBI_insert_id($link = '') {
return mysqli_insert_id($link); return mysqli_insert_id($link);
} }
function PMA_DBI_affected_rows($link = NULL) { function PMA_DBI_affected_rows($link = null)
{
if (empty($link)) { if (empty($link)) {
if (isset($GLOBALS['userlink'])) { if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink']; $link = $GLOBALS['userlink'];
@@ -337,7 +354,8 @@ function PMA_DBI_affected_rows($link = NULL) {
return mysqli_affected_rows($link); return mysqli_affected_rows($link);
} }
function PMA_DBI_get_fields_meta($result) { function PMA_DBI_get_fields_meta($result)
{
// Build an associative array for a type look up // Build an associative array for a type look up
$typeAr = Array(); $typeAr = Array();
$typeAr[MYSQLI_TYPE_DECIMAL] = 'real'; $typeAr[MYSQLI_TYPE_DECIMAL] = 'real';
@@ -392,23 +410,27 @@ function PMA_DBI_get_fields_meta($result) {
return $fields; return $fields;
} }
function PMA_DBI_num_fields($result) { function PMA_DBI_num_fields($result)
{
return mysqli_num_fields($result); return mysqli_num_fields($result);
} }
function PMA_DBI_field_len($result, $i) { function PMA_DBI_field_len($result, $i)
{
$info = mysqli_fetch_field_direct($result, $i); $info = mysqli_fetch_field_direct($result, $i);
// stdClass::$length will be integrated in // stdClass::$length will be integrated in
// mysqli-ext when mysql4.1 has been released. // mysqli-ext when mysql4.1 has been released.
return @$info->length; return @$info->length;
} }
function PMA_DBI_field_name($result, $i) { function PMA_DBI_field_name($result, $i)
{
$info = mysqli_fetch_field_direct($result, $i); $info = mysqli_fetch_field_direct($result, $i);
return $info->name; return $info->name;
} }
function PMA_DBI_field_flags($result, $i) { function PMA_DBI_field_flags($result, $i)
{
$f = mysqli_fetch_field_direct($result, $i); $f = mysqli_fetch_field_direct($result, $i);
$f = $f->flags; $f = $f->flags;
$flags = ''; $flags = '';

View File

@@ -17,7 +17,7 @@ if ($is_create_db_priv) {
<?php <?php
if (PMA_MYSQL_INT_VERSION >= 40101) { if (PMA_MYSQL_INT_VERSION >= 40101) {
require_once('./libraries/mysql_charsets.lib.php'); require_once('./libraries/mysql_charsets.lib.php');
echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'db_collation', NULL, NULL, TRUE, 5); echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'db_collation', null, null, TRUE, 5);
} }
?> ?>
<input type="submit" value="<?php echo $strCreate; ?>" id="buttonGo" /> <input type="submit" value="<?php echo $strCreate; ?>" id="buttonGo" />

View File

@@ -22,7 +22,7 @@ if (PMA_MYSQL_INT_VERSION >= 40100) {
$is_create_table_priv = true; $is_create_table_priv = true;
} }
foreach( $dbs_where_create_table_allowed as $allowed_db ) { foreach ( $dbs_where_create_table_allowed as $allowed_db ) {
// if we find the exact db name, we stop here // if we find the exact db name, we stop here
if ($allowed_db == $db) { if ($allowed_db == $db) {

View File

@@ -853,7 +853,7 @@ function show_checked_option() {
$temp_charset = reset($cfg['AvailableCharsets']); $temp_charset = reset($cfg['AvailableCharsets']);
echo ' <select id="select_charset_of_file" name="charset_of_file" size="1">' . "\n"; echo ' <select id="select_charset_of_file" name="charset_of_file" size="1">' . "\n";
foreach($cfg['AvailableCharsets'] as $key => $temp_charset) { foreach ($cfg['AvailableCharsets'] as $key => $temp_charset) {
echo ' <option value="' . $temp_charset . '"'; echo ' <option value="' . $temp_charset . '"';
if ((empty($cfg['Export']['charset']) && $temp_charset == $charset) if ((empty($cfg['Export']['charset']) && $temp_charset == $charset)
|| $temp_charset == $cfg['Export']['charset']) { || $temp_charset == $cfg['Export']['charset']) {

View File

@@ -48,8 +48,10 @@ echo PMA_pluginGetJavascript($import_list);
<?php <?php
if (!empty($cfg['UploadDir'])) { if (!empty($cfg['UploadDir'])) {
$extensions = ''; $extensions = '';
foreach($import_list as $key => $val) { foreach ($import_list as $key => $val) {
if (!empty($extensions)) $extensions .= '|'; if (!empty($extensions)) {
$extensions .= '|';
}
$extensions .= $val['extension']; $extensions .= $val['extension'];
} }
$matcher = '@\.(' . $extensions . ')(\.(' . PMA_supportedDecompressions() . '))?$@'; $matcher = '@\.(' . $extensions . ')(\.(' . PMA_supportedDecompressions() . '))?$@';
@@ -101,9 +103,15 @@ echo '</div>' . "\n";
// zip, gzip and bzip2 encode features // zip, gzip and bzip2 encode features
$compressions = $strNone; $compressions = $strNone;
if ($cfg['GZipDump'] && @function_exists('gzopen')) $compressions .= ', gzip'; if ($cfg['GZipDump'] && @function_exists('gzopen')) {
if ($cfg['BZipDump'] && @function_exists('bzopen')) $compressions .= ', bzip2'; $compressions .= ', gzip';
if ($cfg['ZipDump'] && @function_exists('gzinflate')) $compressions .= ', zip'; }
if ($cfg['BZipDump'] && @function_exists('bzopen')) {
$compressions .= ', bzip2';
}
if ($cfg['ZipDump'] && @function_exists('gzinflate')) {
$compressions .= ', zip';
}
// We don't have show anything about compression, when no supported // We don't have show anything about compression, when no supported
if ($compressions != $strNone) { if ($compressions != $strNone) {

View File

@@ -86,7 +86,7 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
// 2.1 Statement is a "SELECT COUNT", a // 2.1 Statement is a "SELECT COUNT", a
// "CHECK/ANALYZE/REPAIR/OPTIMIZE", an "EXPLAIN" one or // "CHECK/ANALYZE/REPAIR/OPTIMIZE", an "EXPLAIN" one or
// contains a "PROC ANALYSE" part // contains a "PROC ANALYSE" part
else if ($GLOBALS['is_count'] || $GLOBALS['is_analyse'] || $GLOBALS['is_maint'] || $GLOBALS['is_explain']) { elseif ($GLOBALS['is_count'] || $GLOBALS['is_analyse'] || $GLOBALS['is_maint'] || $GLOBALS['is_explain']) {
$do_display['edit_lnk'] = 'nn'; // no edit link $do_display['edit_lnk'] = 'nn'; // no edit link
$do_display['del_lnk'] = 'nn'; // no delete link $do_display['del_lnk'] = 'nn'; // no delete link
$do_display['sort_lnk'] = (string) '0'; $do_display['sort_lnk'] = (string) '0';
@@ -101,14 +101,13 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
$do_display['pview_lnk'] = (string) '1'; $do_display['pview_lnk'] = (string) '1';
} }
// 2.2 Statement is a "SHOW..." // 2.2 Statement is a "SHOW..."
else if ($GLOBALS['is_show']) { elseif ($GLOBALS['is_show']) {
// 2.2.1 TODO : defines edit/delete links depending on show statement // 2.2.1 TODO : defines edit/delete links depending on show statement
$tmp = preg_match('@^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS|DATABASES|FIELDS)@i', $GLOBALS['sql_query'], $which = array() ); $tmp = preg_match('@^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS|DATABASES|FIELDS)@i', $GLOBALS['sql_query'], $which = array() );
if (isset($which[1]) && strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0) { if (isset($which[1]) && strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0) {
$do_display['edit_lnk'] = 'nn'; // no edit link $do_display['edit_lnk'] = 'nn'; // no edit link
$do_display['del_lnk'] = 'kp'; // "kill process" type edit link $do_display['del_lnk'] = 'kp'; // "kill process" type edit link
} } else {
else {
// Default case -> no links // Default case -> no links
$do_display['edit_lnk'] = 'nn'; // no edit link $do_display['edit_lnk'] = 'nn'; // no edit link
$do_display['del_lnk'] = 'nn'; // no delete link $do_display['del_lnk'] = 'nn'; // no delete link
@@ -155,8 +154,7 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
// 3. Gets the total number of rows if it is unknown // 3. Gets the total number of rows if it is unknown
if (isset($unlim_num_rows) && $unlim_num_rows != '') { if (isset($unlim_num_rows) && $unlim_num_rows != '') {
$the_total = $unlim_num_rows; $the_total = $unlim_num_rows;
} } elseif (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1')
else if (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1')
&& (isset($db) && strlen($db) && !empty($table))) { && (isset($db) && strlen($db) && !empty($table))) {
$the_total = PMA_countRecords($db, $table, TRUE); $the_total = PMA_countRecords($db, $table, TRUE);
} }
@@ -477,10 +475,10 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// we need $sort_expression and $sort_expression_nodir // we need $sort_expression and $sort_expression_nodir
// even if there are many table references // even if there are many table references
$sort_expression = trim(str_replace(' ', ' ',$analyzed_sql[0]['order_by_clause'])); $sort_expression = trim(str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause']));
// Get rid of ASC|DESC (TODO: analyzer) // Get rid of ASC|DESC (TODO: analyzer)
preg_match('@(.*)([[:space:]]*(ASC|DESC))@si',$sort_expression,$matches = array()); preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches = array());
$sort_expression_nodir = isset($matches[1]) ? trim($matches[1]) : $sort_expression; $sort_expression_nodir = isset($matches[1]) ? trim($matches[1]) : $sort_expression;
// sorting by indexes, only if it makes sense (only one table ref) // sorting by indexes, only if it makes sense (only one table ref)
@@ -526,9 +524,15 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
$span = $fields_cnt; $span = $fields_cnt;
if ($is_display['edit_lnk'] != 'nn') $span++; if ($is_display['edit_lnk'] != 'nn') {
if ($is_display['del_lnk'] != 'nn') $span++; $span++;
if ($is_display['del_lnk'] != 'kp' && $is_display['del_lnk'] != 'nn') $span++; }
if ($is_display['del_lnk'] != 'nn') {
$span++;
}
if ($is_display['del_lnk'] != 'kp' && $is_display['del_lnk'] != 'nn') {
$span++;
}
} else { } else {
$span = $num_rows + floor($num_rows/$repeat_cells) + 1; $span = $num_rows + floor($num_rows/$repeat_cells) + 1;
} }
@@ -651,7 +655,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
} // end vertical mode } // end vertical mode
} }
// ... else if no button, displays empty(ies) col(s) if required // ... elseif no button, displays empty(ies) col(s) if required
elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft'] elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft']
&& ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')) { && ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')) {
$vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0; $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
@@ -807,10 +811,10 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// enable sord order swapping for image // enable sord order swapping for image
$order_link_params = array(); $order_link_params = array();
if (isset($order_img) && $order_img!='') { if (isset($order_img) && $order_img!='') {
if (strstr($order_img,'asc')) { if (strstr($order_img, 'asc')) {
$order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }'; $order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
$order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }'; $order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
} else if (strstr($order_img,'desc')) { } elseif (strstr($order_img, 'desc')) {
$order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }'; $order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
$order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }'; $order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
} }
@@ -825,7 +829,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
?> ?>
<th <?php echo $column_style; ?> <?php if ($disp_direction == 'horizontalflipped') echo 'valign="bottom"'; ?>> <th <?php echo $column_style; ?> <?php if ($disp_direction == 'horizontalflipped') { echo 'valign="bottom"'; } ?>>
<?php echo $order_link; ?> <?php echo $order_link; ?>
<?php echo $comments; ?> <?php echo $comments; ?>
</th> </th>
@@ -841,7 +845,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
else { else {
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
?> ?>
<th <?php echo $column_style; ?> <?php if ($disp_direction == 'horizontalflipped') echo 'valign="bottom"'; ?> <?php echo ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'css' ? 'style="direction: ltr; writing-mode: tb-rl;"' : ''); ?>> <th <?php echo $column_style; ?> <?php if ($disp_direction == 'horizontalflipped') { echo 'valign="bottom"'; } ?> <?php echo ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'css' ? 'style="direction: ltr; writing-mode: tb-rl;"' : ''); ?>>
<?php echo ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake'? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name)) . "\n"; ?> <?php echo ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake'? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name)) . "\n"; ?>
<?php echo $comments; ?> <?php echo $comments; ?>
</th> </th>
@@ -875,9 +879,9 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
} // end vertical mode } // end vertical mode
} }
// ... else if no button, displays empty cols if required // ... elseif no button, displays empty cols if required
// (unless coming from Browse mode print view) // (unless coming from Browse mode print view)
else if ($GLOBALS['cfg']['ModifyDeleteAtRight'] elseif ($GLOBALS['cfg']['ModifyDeleteAtRight']
&& ($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn') && ($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
&& (!$GLOBALS['is_header_sent'])) { && (!$GLOBALS['is_header_sent'])) {
$vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 1; $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 1;
@@ -1118,7 +1122,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$del_str .= ' ' . $GLOBALS['strDelete'] . '</div>'; $del_str .= ' ' . $GLOBALS['strDelete'] . '</div>';
} }
} }
} else if ($is_display['del_lnk'] == 'kp') { // kill process case } elseif ($is_display['del_lnk'] == 'kp') { // kill process case
$lnk_goto = 'sql.php' $lnk_goto = 'sql.php'
. '?' . str_replace('&amp;', '&', $url_query) . '?' . str_replace('&amp;', '&', $url_query)
. '&sql_query=' . urlencode($url_sql_query) . '&sql_query=' . urlencode($url_sql_query)
@@ -1223,7 +1227,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
//if (!isset($row[$meta->name]) //if (!isset($row[$meta->name])
if (!isset($row[$i]) || is_null($row[$i])) { if (!isset($row[$i]) || is_null($row[$i])) {
$vertical_display['data'][$row_no][$i] = ' <td align="right"' . $column_style . $bgcolor . '><i>NULL</i></td>' . "\n"; $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $column_style . $bgcolor . '><i>NULL</i></td>' . "\n";
} else if ($row[$i] != '') { } elseif ($row[$i] != '') {
$vertical_display['data'][$row_no][$i] = ' <td align="right"' . $column_style . $bgcolor . ' class="nowrap">'; $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $column_style . $bgcolor . ' class="nowrap">';
if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) { if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
@@ -1245,16 +1249,14 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
. ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
. ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' WHERE ' . PMA_backquote($map[$meta->name][1])
. ' = ' . $row[$i]; . ' = ' . $row[$i];
$dispresult = PMA_DBI_try_query($dispsql, NULL, PMA_DBI_QUERY_STORE); $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) { if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
list($dispval) = PMA_DBI_fetch_row($dispresult, 0); list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
} } else {
else {
$dispval = $GLOBALS['strLinkNotFound']; $dispval = $GLOBALS['strLinkNotFound'];
} }
@PMA_DBI_free_result($dispresult); @PMA_DBI_free_result($dispresult);
} } else {
else {
$dispval = ''; $dispval = '';
} // end if... else... } // end if... else...
@@ -1279,7 +1281,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
// b l o b // b l o b
} else if ($GLOBALS['cfg']['ShowBlob'] == FALSE && stristr($meta->type, 'BLOB')) { } elseif ($GLOBALS['cfg']['ShowBlob'] == FALSE && stristr($meta->type, 'BLOB')) {
// loic1 : PMA_mysql_fetch_fields returns BLOB in place of // loic1 : PMA_mysql_fetch_fields returns BLOB in place of
// TEXT fields type, however TEXT fields must be displayed // TEXT fields type, however TEXT fields must be displayed
// even if $GLOBALS['cfg']['ShowBlob'] is false -> get the true type // even if $GLOBALS['cfg']['ShowBlob'] is false -> get the true type
@@ -1302,7 +1304,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
} else { } else {
if (!isset($row[$i]) || is_null($row[$i])) { if (!isset($row[$i]) || is_null($row[$i])) {
$vertical_display['data'][$row_no][$i] = ' <td' . $column_style . $bgcolor . '><i>NULL</i></td>' . "\n"; $vertical_display['data'][$row_no][$i] = ' <td' . $column_style . $bgcolor . '><i>NULL</i></td>' . "\n";
} else if ($row[$i] != '') { } elseif ($row[$i] != '') {
// garvin: if a transform function for blob is set, none of these replacements will be made // garvin: if a transform function for blob is set, none of these replacements will be made
if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) { if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) {
$row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...'; $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
@@ -1319,7 +1321,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
} else { } else {
if (!isset($row[$i]) || is_null($row[$i])) { if (!isset($row[$i]) || is_null($row[$i])) {
$vertical_display['data'][$row_no][$i] = ' <td' . $column_style . $bgcolor . '><i>NULL</i></td>' . "\n"; $vertical_display['data'][$row_no][$i] = ' <td' . $column_style . $bgcolor . '><i>NULL</i></td>' . "\n";
} else if ($row[$i] != '') { } elseif ($row[$i] != '') {
// loic1: support blanks in the key // loic1: support blanks in the key
$relation_id = $row[$i]; $relation_id = $row[$i];
@@ -1371,16 +1373,14 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
. ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
. ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' WHERE ' . PMA_backquote($map[$meta->name][1])
. ' = \'' . PMA_sqlAddslashes($row[$i]) . '\''; . ' = \'' . PMA_sqlAddslashes($row[$i]) . '\'';
$dispresult = PMA_DBI_try_query($dispsql, NULL, PMA_DBI_QUERY_STORE); $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) { if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
list($dispval) = PMA_DBI_fetch_row($dispresult); list($dispval) = PMA_DBI_fetch_row($dispresult);
@PMA_DBI_free_result($dispresult); @PMA_DBI_free_result($dispresult);
} } else {
else {
$dispval = $GLOBALS['strLinkNotFound']; $dispval = $GLOBALS['strLinkNotFound'];
} }
} } else {
else {
$dispval = ''; $dispval = '';
} }
$title = (!empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : ''; $title = (!empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';
@@ -1716,7 +1716,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
? $total - 1 ? $total - 1
: $pos_next - 1; : $pos_next - 1;
PMA_showMessage($GLOBALS['strShowingRecords'] . " $pos - $last_shown_rec (" . PMA_formatNumber( $total, 0 ) . ' ' . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')'); PMA_showMessage($GLOBALS['strShowingRecords'] . " $pos - $last_shown_rec (" . PMA_formatNumber( $total, 0 ) . ' ' . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')');
} else if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
PMA_showMessage($GLOBALS['strSQLQuery']); PMA_showMessage($GLOBALS['strSQLQuery']);
} }
@@ -1735,7 +1735,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
if ($is_display['nav_bar'] == '1') { if ($is_display['nav_bar'] == '1') {
PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query); PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
echo "\n"; echo "\n";
} else if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
echo "\n" . '<br /><br />' . "\n"; echo "\n" . '<br /><br />' . "\n";
} }
@@ -1762,7 +1762,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
$exist_rel = PMA_getForeigners($db, $table, '', 'both'); $exist_rel = PMA_getForeigners($db, $table, '', 'both');
if ($exist_rel) { if ($exist_rel) {
foreach ($exist_rel AS $master_field => $rel) { foreach ($exist_rel AS $master_field => $rel) {
$display_field = PMA_getDisplayField($rel['foreign_db'],$rel['foreign_table']); $display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']);
$map[$master_field] = array($rel['foreign_table'], $map[$master_field] = array($rel['foreign_table'],
$rel['foreign_field'], $rel['foreign_field'],
$display_field, $display_field,
@@ -1862,7 +1862,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
if ($is_display['nav_bar'] == '1') { if ($is_display['nav_bar'] == '1') {
echo '<br />' . "\n"; echo '<br />' . "\n";
PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query); PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
} else if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
echo "\n" . '<br /><br />' . "\n"; echo "\n" . '<br /><br />' . "\n";
} }
} // end of the 'PMA_displayTable()' function } // end of the 'PMA_displayTable()' function

View File

@@ -28,7 +28,7 @@ if ( $doWriteModifyAt == 'left' ){
. PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''), FALSE) . PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''), FALSE)
. ' </td>' . "\n"; . ' </td>' . "\n";
} }
} else if ($doWriteModifyAt == 'right') { } elseif ($doWriteModifyAt == 'right') {
if (!empty($del_url)) { if (!empty($del_url)) {
echo ' <td align="center">' . "\n" echo ' <td align="center">' . "\n"
. PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''), FALSE) . PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''), FALSE)

View File

@@ -124,7 +124,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $escaped; global $escaped;
// Gets the data from the database // Gets the data from the database
$result = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED); $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result); $fields_cnt = PMA_DBI_num_fields($result);
// If required, get fields name at the first line // If required, get fields name at the first line
@@ -141,7 +141,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$schema_insert .= $export_separator; $schema_insert .= $export_separator;
} // end for } // end for
$schema_insert =trim(substr($schema_insert, 0, -1)); $schema_insert =trim(substr($schema_insert, 0, -1));
if (!PMA_exportOutputHandler($schema_insert . $add_character)) return FALSE; if (!PMA_exportOutputHandler($schema_insert . $add_character)) {
return FALSE;
}
} // end if } // end if
// Format the data // Format the data
@@ -150,8 +152,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
for ($j = 0; $j < $fields_cnt; $j++) { for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) { if (!isset($row[$j]) || is_null($row[$j])) {
$schema_insert .= $GLOBALS[$what . '_replace_null']; $schema_insert .= $GLOBALS[$what . '_replace_null'];
} } elseif ($row[$j] == '0' || $row[$j] != '') {
else if ($row[$j] == '0' || $row[$j] != '') {
// loic1 : always enclose fields // loic1 : always enclose fields
if ($what == 'excel') { if ($what == 'excel') {
$row[$j] = ereg_replace("\015(\012)?", "\012", $row[$j]); $row[$j] = ereg_replace("\015(\012)?", "\012", $row[$j]);
@@ -163,8 +164,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
. str_replace($enclosed, $escaped . $enclosed, $row[$j]) . str_replace($enclosed, $escaped . $enclosed, $row[$j])
. $enclosed; . $enclosed;
} }
} } else {
else {
$schema_insert .= ''; $schema_insert .= '';
} }
if ($j < $fields_cnt-1) { if ($j < $fields_cnt-1) {
@@ -172,7 +172,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
} }
} // end for } // end for
if (!PMA_exportOutputHandler($schema_insert . $add_character)) return FALSE; if (!PMA_exportOutputHandler($schema_insert . $add_character)) {
return FALSE;
}
} // end while } // end while
PMA_DBI_free_result($result); PMA_DBI_free_result($result);

View File

@@ -122,7 +122,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $what; global $what;
// Gets the data from the database // Gets the data from the database
$result = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED); $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result); $fields_cnt = PMA_DBI_num_fields($result);
// If required, get fields name at the first line // If required, get fields name at the first line
@@ -132,7 +132,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$schema_insert .= '<td class=xl2216681 nowrap><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>'; $schema_insert .= '<td class=xl2216681 nowrap><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>';
} // end for } // end for
$schema_insert .= '</tr>'; $schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) return FALSE; if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
} // end if } // end if
// Format the data // Format the data
@@ -141,7 +143,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
for ($j = 0; $j < $fields_cnt; $j++) { for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) { if (!isset($row[$j]) || is_null($row[$j])) {
$value = $GLOBALS[$what . '_replace_null']; $value = $GLOBALS[$what . '_replace_null'];
} else if ($row[$j] == '0' || $row[$j] != '') { } elseif ($row[$j] == '0' || $row[$j] != '') {
$value = $row[$j]; $value = $row[$j];
} else { } else {
$value = ''; $value = '';
@@ -149,7 +151,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$schema_insert .= '<td class=xl2216681 nowrap>' . htmlspecialchars($value) . '</td>'; $schema_insert .= '<td class=xl2216681 nowrap>' . htmlspecialchars($value) . '</td>';
} // end for } // end for
$schema_insert .= '</tr>'; $schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) return FALSE; if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
} // end while } // end while
PMA_DBI_free_result($result); PMA_DBI_free_result($result);

View File

@@ -101,14 +101,19 @@ function PMA_exportDBCreate($db) {
* *
* @access public * @access public
*/ */
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) { function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $what; global $what;
if (!PMA_exportOutputHandler('<h2>' . $GLOBALS['strDumpingData'] . ' ' .$table . '</h2>')) return FALSE; if (!PMA_exportOutputHandler('<h2>' . $GLOBALS['strDumpingData'] . ' ' . $table . '</h2>')) {
if (!PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) return FALSE; return FALSE;
}
if (!PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) {
return FALSE;
}
// Gets the data from the database // Gets the data from the database
$result = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED); $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result); $fields_cnt = PMA_DBI_num_fields($result);
// If required, get fields name at the first line // If required, get fields name at the first line
@@ -118,7 +123,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>'; $schema_insert .= '<td class="print"><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>';
} // end for } // end for
$schema_insert .= '</tr>'; $schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) return FALSE; if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
} // end if } // end if
// Format the data // Format the data
@@ -127,7 +134,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
for ($j = 0; $j < $fields_cnt; $j++) { for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) { if (!isset($row[$j]) || is_null($row[$j])) {
$value = $GLOBALS[$what . '_replace_null']; $value = $GLOBALS[$what . '_replace_null'];
} else if ($row[$j] == '0' || $row[$j] != '') { } elseif ($row[$j] == '0' || $row[$j] != '') {
$value = $row[$j]; $value = $row[$j];
} else { } else {
$value = ''; $value = '';
@@ -135,10 +142,14 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$schema_insert .= '<td class="print">' . htmlspecialchars($value) . '</td>'; $schema_insert .= '<td class="print">' . htmlspecialchars($value) . '</td>';
} // end for } // end for
$schema_insert .= '</tr>'; $schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) return FALSE; if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
} // end while } // end while
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
if (!PMA_exportOutputHandler('</table>')) return FALSE; if (!PMA_exportOutputHandler('</table>')) {
return FALSE;
}
return TRUE; return TRUE;
} }
@@ -147,7 +158,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
{ {
global $cfgRelation; global $cfgRelation;
if (!PMA_exportOutputHandler('<h2>' . $GLOBALS['strTableStructure'] . ' ' .$table . '</h2>')) return FALSE; if (!PMA_exportOutputHandler('<h2>' . $GLOBALS['strTableStructure'] . ' ' .$table . '</h2>')) {
return FALSE;
}
/** /**
* Get the unique keys in the table * Get the unique keys in the table
@@ -156,7 +169,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$keys_result = PMA_DBI_query($keys_query); $keys_result = PMA_DBI_query($keys_query);
$unique_keys = array(); $unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) { while ($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) $unique_keys[] = $key['Column_name']; if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
} }
PMA_DBI_free_result($keys_result); PMA_DBI_free_result($keys_result);
@@ -179,15 +194,16 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
} else { } else {
$have_rel = FALSE; $have_rel = FALSE;
} }
} } else {
else {
$have_rel = FALSE; $have_rel = FALSE;
} // end if } // end if
/** /**
* Displays the table structure * Displays the table structure
*/ */
if (!PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) return FALSE; if (!PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) {
return FALSE;
}
$columns_cnt = 4; $columns_cnt = 4;
if ($do_relation && $have_rel) { if ($do_relation && $have_rel) {
@@ -218,7 +234,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
} }
$schema_insert .= '</tr>'; $schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) return FALSE; if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
while ($row = PMA_DBI_fetch_assoc($result)) { while ($row = PMA_DBI_fetch_assoc($result)) {
@@ -294,7 +312,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$schema_insert .= '</tr>'; $schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) return FALSE; if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
} // end while } // end while
PMA_DBI_free_result($result); PMA_DBI_free_result($result);

View File

@@ -129,7 +129,7 @@ function PMA_exportDBCreate($db) {
* @access public * @access public
*/ */
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) { function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$result = PMA_DBI_try_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED); $result = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$columns_cnt = PMA_DBI_num_fields($result); $columns_cnt = PMA_DBI_num_fields($result);
for ($i = 0; $i < $columns_cnt; $i++) { for ($i = 0; $i < $columns_cnt; $i++) {
@@ -150,7 +150,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$buffer .= ' \\caption{' . str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_data_caption']) $buffer .= ' \\caption{' . str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_data_caption'])
. '} \\label{' . str_replace('__TABLE__', $table, $GLOBALS['latex_data_label']) . '} \\\\'; . '} \\label{' . str_replace('__TABLE__', $table, $GLOBALS['latex_data_label']) . '} \\\\';
} }
if (!PMA_exportOutputHandler($buffer)) return FALSE; if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
// show column names // show column names
if (isset($GLOBALS['latex_showcolumns'])) { if (isset($GLOBALS['latex_showcolumns'])) {
@@ -159,14 +161,20 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$buffer .= '\\multicolumn{1}{|c|}{\\textbf{' . PMA_texEscape(stripslashes($columns[$i])) . '}} & '; $buffer .= '\\multicolumn{1}{|c|}{\\textbf{' . PMA_texEscape(stripslashes($columns[$i])) . '}} & ';
} }
$buffer = substr($buffer,0,-2) . '\\\\ \\hline \hline '; $buffer = substr($buffer, 0, -2) . '\\\\ \\hline \hline ';
if (!PMA_exportOutputHandler($buffer . ' \\endfirsthead ' . $crlf)) return FALSE; if (!PMA_exportOutputHandler($buffer . ' \\endfirsthead ' . $crlf)) {
return FALSE;
}
if (isset($GLOBALS['latex_caption'])) { if (isset($GLOBALS['latex_caption'])) {
if (!PMA_exportOutputHandler('\\caption{' . str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_data_continued_caption']) . '} \\\\ ')) return FALSE; if (!PMA_exportOutputHandler('\\caption{' . str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_data_continued_caption']) . '} \\\\ ')) return FALSE;
} }
if (!PMA_exportOutputHandler($buffer . '\\endhead \\endfoot' . $crlf)) return FALSE; if (!PMA_exportOutputHandler($buffer . '\\endhead \\endfoot' . $crlf)) {
return FALSE;
}
} else { } else {
if (!PMA_exportOutputHandler('\\\\ \hline')) return FALSE; if (!PMA_exportOutputHandler('\\\\ \hline')) {
return FALSE;
}
} }
// print the whole table // print the whole table
@@ -189,11 +197,15 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
} }
} }
$buffer .= ' \\\\ \\hline ' . $crlf; $buffer .= ' \\\\ \\hline ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) return FALSE; if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
} }
$buffer = ' \\end{longtable}' . $crlf; $buffer = ' \\end{longtable}' . $crlf;
if (!PMA_exportOutputHandler($buffer)) return FALSE; if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
return TRUE; return TRUE;
@@ -227,7 +239,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$keys_result = PMA_DBI_query($keys_query); $keys_result = PMA_DBI_query($keys_query);
$unique_keys = array(); $unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) { while ($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) $unique_keys[] = $key['Column_name']; if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
} }
PMA_DBI_free_result($keys_result); PMA_DBI_free_result($keys_result);
@@ -250,8 +264,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
} else { } else {
$have_rel = FALSE; $have_rel = FALSE;
} }
} } else {
else {
$have_rel = FALSE; $have_rel = FALSE;
} // end if } // end if
@@ -260,7 +273,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
*/ */
$buffer = $crlf . '%' . $crlf . '% ' . $GLOBALS['strStructure'] . ': ' . $table . $crlf . '%' . $crlf $buffer = $crlf . '%' . $crlf . '% ' . $GLOBALS['strStructure'] . ': ' . $table . $crlf . '%' . $crlf
. ' \\begin{longtable}{'; . ' \\begin{longtable}{';
if (!PMA_exportOutputHandler($buffer)) return FALSE; if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
$columns_cnt = 4; $columns_cnt = 4;
$alignment = '|l|c|c|c|'; $alignment = '|l|c|c|c|';
@@ -308,7 +323,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
} }
$buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot '; $buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ';
if (!PMA_exportOutputHandler($buffer)) return FALSE; if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
while ($row = PMA_DBI_fetch_assoc($result)) { while ($row = PMA_DBI_fetch_assoc($result)) {
@@ -379,16 +396,18 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$local_buffer = PMA_texEscape($local_buffer); $local_buffer = PMA_texEscape($local_buffer);
if ($row['Key']=='PRI') { if ($row['Key']=='PRI') {
$pos=strpos($local_buffer, "\000"); $pos=strpos($local_buffer, "\000");
$local_buffer = '\\textit{' . substr($local_buffer,0,$pos) . '}' . substr($local_buffer,$pos); $local_buffer = '\\textit{' . substr($local_buffer, 0, $pos) . '}' . substr($local_buffer, $pos);
} }
if (in_array($field_name, $unique_keys)) { if (in_array($field_name, $unique_keys)) {
$pos=strpos($local_buffer, "\000"); $pos=strpos($local_buffer, "\000");
$local_buffer = '\\textbf{' . substr($local_buffer,0,$pos) . '}' . substr($local_buffer,$pos); $local_buffer = '\\textbf{' . substr($local_buffer, 0, $pos) . '}' . substr($local_buffer, $pos);
} }
$buffer = str_replace("\000", ' & ', $local_buffer); $buffer = str_replace("\000", ' & ', $local_buffer);
$buffer .= ' \\\\ \\hline ' . $crlf; $buffer .= ' \\\\ \\hline ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) return FALSE; if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
} // end while } // end while
PMA_DBI_free_result($result); PMA_DBI_free_result($result);

View File

@@ -83,7 +83,7 @@ class PMA_PDF extends PMA_FPDF
} }
$this->SetY(($this->tMargin) - ($this->FontSizePt/$this->k)*2); $this->SetY(($this->tMargin) - ($this->FontSizePt/$this->k)*2);
$this->cellFontSize = $this->FontSizePt ; $this->cellFontSize = $this->FontSizePt ;
$this->SetFont(PMA_PDF_FONT, '' ,($this->titleFontSize ? $this->titleFontSize : $this->FontSizePt )); $this->SetFont(PMA_PDF_FONT, '', ($this->titleFontSize ? $this->titleFontSize : $this->FontSizePt));
$this->Cell(0, $this->FontSizePt, $this->titleText, 0, 1, 'C'); $this->Cell(0, $this->FontSizePt, $this->titleText, 0, 1, 'C');
$l = ($this->lMargin); $l = ($this->lMargin);
$this->SetFont(PMA_PDF_FONT, '', $this->cellFontSize); $this->SetFont(PMA_PDF_FONT, '', $this->cellFontSize);
@@ -204,7 +204,7 @@ class PMA_PDF extends PMA_FPDF
// Pass 1 for column widths // Pass 1 for column widths
// TODO: force here a LIMIT to speed up pass 1 ? // TODO: force here a LIMIT to speed up pass 1 ?
$this->results = PMA_DBI_query($query, NULL, PMA_DBI_QUERY_UNBUFFERED); $this->results = PMA_DBI_query($query, null, PMA_DBI_QUERY_UNBUFFERED);
$this->numFields = PMA_DBI_num_fields($this->results); $this->numFields = PMA_DBI_num_fields($this->results);
$this->fields = PMA_DBI_get_fields_meta($this->results); $this->fields = PMA_DBI_get_fields_meta($this->results);
@@ -272,7 +272,7 @@ class PMA_PDF extends PMA_FPDF
// Pass 2 // Pass 2
$this->results = PMA_DBI_query($query, NULL, PMA_DBI_QUERY_UNBUFFERED); $this->results = PMA_DBI_query($query, null, PMA_DBI_QUERY_UNBUFFERED);
$this->Open(); $this->Open();
$this->setY($this->tMargin); $this->setY($this->tMargin);
$this->AddPage(); $this->AddPage();

View File

@@ -14,7 +14,7 @@ $GLOBALS['comment_marker'] = '-- ';
* Avoids undefined variables, use NULL so isset() returns false * Avoids undefined variables, use NULL so isset() returns false
*/ */
if ( ! isset( $use_backquotes ) ) { if ( ! isset( $use_backquotes ) ) {
$use_backquotes = NULL; $use_backquotes = null;
} }
/** /**
@@ -24,7 +24,8 @@ if ( ! isset( $use_backquotes ) ) {
* *
* @return bool Whether it suceeded * @return bool Whether it suceeded
*/ */
function PMA_exportComment($text) { function PMA_exportComment($text)
{
return PMA_exportOutputHandler($GLOBALS['comment_marker'] . $text . $GLOBALS['crlf']); return PMA_exportOutputHandler($GLOBALS['comment_marker'] . $text . $GLOBALS['crlf']);
} }
@@ -35,7 +36,8 @@ function PMA_exportComment($text) {
* *
* @access public * @access public
*/ */
function PMA_exportFooter() { function PMA_exportFooter()
{
global $crlf; global $crlf;
$foot = ''; $foot = '';
@@ -58,7 +60,8 @@ function PMA_exportFooter() {
* *
* @access public * @access public
*/ */
function PMA_exportHeader() { function PMA_exportHeader()
{
global $crlf; global $crlf;
global $cfg; global $cfg;
@@ -107,10 +110,13 @@ function PMA_exportHeader() {
* *
* @access public * @access public
*/ */
function PMA_exportDBCreate($db) { function PMA_exportDBCreate($db)
{
global $crlf; global $crlf;
if (isset($GLOBALS['drop_database'])) { if (isset($GLOBALS['drop_database'])) {
if (!PMA_exportOutputHandler('DROP DATABASE ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : $db) . ';' . $crlf)) return FALSE; if (!PMA_exportOutputHandler('DROP DATABASE ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : $db) . ';' . $crlf)) {
return FALSE;
}
} }
$create_query = 'CREATE DATABASE ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : $db); $create_query = 'CREATE DATABASE ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : $db);
if (PMA_MYSQL_INT_VERSION >= 40101) { if (PMA_MYSQL_INT_VERSION >= 40101) {
@@ -122,7 +128,9 @@ function PMA_exportDBCreate($db) {
} }
} }
$create_query .= ';' . $crlf; $create_query .= ';' . $crlf;
if (!PMA_exportOutputHandler($create_query)) return FALSE; if (!PMA_exportOutputHandler($create_query)) {
return FALSE;
}
if (isset($GLOBALS['use_backquotes']) && PMA_MYSQL_INT_VERSION >= 40100 && isset($GLOBALS['sql_compat']) && $GLOBALS['sql_compat'] == 'NONE') { if (isset($GLOBALS['use_backquotes']) && PMA_MYSQL_INT_VERSION >= 40100 && isset($GLOBALS['sql_compat']) && $GLOBALS['sql_compat'] == 'NONE') {
return PMA_exportOutputHandler('USE ' . PMA_backquote($db) . ';' . $crlf); return PMA_exportOutputHandler('USE ' . PMA_backquote($db) . ';' . $crlf);
} }
@@ -138,7 +146,8 @@ function PMA_exportDBCreate($db) {
* *
* @access public * @access public
*/ */
function PMA_exportDBHeader($db) { function PMA_exportDBHeader($db)
{
global $crlf; global $crlf;
$head = $GLOBALS['comment_marker'] . $crlf $head = $GLOBALS['comment_marker'] . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf . $GLOBALS['comment_marker'] . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
@@ -155,7 +164,8 @@ function PMA_exportDBHeader($db) {
* *
* @access public * @access public
*/ */
function PMA_exportDBFooter($db) { function PMA_exportDBFooter($db)
{
$result = TRUE; $result = TRUE;
if (isset($GLOBALS['sql_constraints'])) { if (isset($GLOBALS['sql_constraints'])) {
$result = PMA_exportOutputHandler($GLOBALS['sql_constraints']); $result = PMA_exportOutputHandler($GLOBALS['sql_constraints']);
@@ -193,7 +203,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
$new_crlf = $crlf; $new_crlf = $crlf;
// need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli // need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli
$result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table) . '\'', NULL, PMA_DBI_QUERY_STORE); $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table) . '\'', null, PMA_DBI_QUERY_STORE);
if ($result != FALSE) { if ($result != FALSE) {
if (PMA_DBI_num_rows($result) > 0) { if (PMA_DBI_num_rows($result) > 0) {
$tmpres = PMA_DBI_fetch_assoc($result); $tmpres = PMA_DBI_fetch_assoc($result);
@@ -233,7 +243,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 0'); PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 0');
} }
$result = PMA_DBI_query('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), NULL, PMA_DBI_QUERY_UNBUFFERED); $result = PMA_DBI_query('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), null, PMA_DBI_QUERY_UNBUFFERED);
if ($result != FALSE && ($row = PMA_DBI_fetch_row($result))) { if ($result != FALSE && ($row = PMA_DBI_fetch_row($result))) {
$create_query = $row[1]; $create_query = $row[1];
unset($row); unset($row);
@@ -261,7 +271,9 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
// lets find first line with constraints // lets find first line with constraints
for ($i = 0; $i < $sql_count; $i++) { for ($i = 0; $i < $sql_count; $i++) {
if (preg_match('@^[\s]*(CONSTRAINT|FOREIGN[\s]+KEY)@', $sql_lines[$i])) break; if (preg_match('@^[\s]*(CONSTRAINT|FOREIGN[\s]+KEY)@', $sql_lines[$i])) {
break;
}
} }
// If we really found a constraint // If we really found a constraint
@@ -292,7 +304,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
$sql_constraints .= 'ALTER TABLE ' . PMA_backquote($table) . $crlf; $sql_constraints .= 'ALTER TABLE ' . PMA_backquote($table) . $crlf;
$first = TRUE; $first = TRUE;
for($j = $i; $j < $sql_count; $j++) { for ($j = $i; $j < $sql_count; $j++) {
if (preg_match('@CONSTRAINT|FOREIGN[\s]+KEY@', $sql_lines[$j])) { if (preg_match('@CONSTRAINT|FOREIGN[\s]+KEY@', $sql_lines[$j])) {
if (!$first) { if (!$first) {
$sql_constraints .= $crlf; $sql_constraints .= $crlf;
@@ -362,13 +374,14 @@ function PMA_getTableComments($db, $table, $crlf, $do_relation = false, $do_comm
} else { } else {
$have_rel = FALSE; $have_rel = FALSE;
} }
} } else {
else {
$have_rel = FALSE; $have_rel = FALSE;
} // end if } // end if
if ($do_mime && $cfgRelation['mimework']) { if ($do_mime && $cfgRelation['mimework']) {
if (!($mime_map = PMA_getMIME($db, $table, true))) unset($mime_map); if (!($mime_map = PMA_getMIME($db, $table, true))) {
unset($mime_map);
}
} }
if (isset($comments_map) && count($comments_map) > 0) { if (isset($comments_map) && count($comments_map) > 0) {
@@ -422,7 +435,8 @@ function PMA_getTableComments($db, $table, $crlf, $do_relation = false, $do_comm
* *
* @access public * @access public
*/ */
function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE, $comments = FALSE, $mime = FALSE, $dates = FALSE) { function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE, $comments = FALSE, $mime = FALSE, $dates = FALSE)
{
$formatted_table_name = (isset($GLOBALS['use_backquotes'])) $formatted_table_name = (isset($GLOBALS['use_backquotes']))
? PMA_backquote($table) ? PMA_backquote($table)
: '\'' . $table . '\''; : '\'' . $table . '\'';
@@ -475,7 +489,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
. $GLOBALS['comment_marker'] . $GLOBALS['strDumpingData'] . ' ' . $formatted_table_name . $crlf . $GLOBALS['comment_marker'] . $GLOBALS['strDumpingData'] . ' ' . $formatted_table_name . $crlf
. $GLOBALS['comment_marker'] . $crlf .$crlf; . $GLOBALS['comment_marker'] . $crlf .$crlf;
if (!PMA_exportOutputHandler($head)) return FALSE; if (!PMA_exportOutputHandler($head)) {
return FALSE;
}
$buffer = ''; $buffer = '';
@@ -484,7 +500,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
// are used, we did not get the true column name in case of aliases) // are used, we did not get the true column name in case of aliases)
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($sql_query)); $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($sql_query));
$result = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED); $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
if ($result != FALSE) { if ($result != FALSE) {
$fields_cnt = PMA_DBI_num_fields($result); $fields_cnt = PMA_DBI_num_fields($result);
@@ -506,8 +522,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'update') { if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'update') {
// update // update
$schema_insert = 'UPDATE '; $schema_insert = 'UPDATE ';
if (isset($GLOBALS['sql_ignore'])) if (isset($GLOBALS['sql_ignore'])) {
$schema_insert .= 'IGNORE '; $schema_insert .= 'IGNORE ';
}
$schema_insert .= PMA_backquote($table, $use_backquotes) . ' SET '; $schema_insert .= PMA_backquote($table, $use_backquotes) . ' SET ';
} else { } else {
// insert or replace // insert or replace
@@ -601,7 +618,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
} else { } else {
$insert_line = '(' . implode(', ', $values) . ')'; $insert_line = '(' . implode(', ', $values) . ')';
if (isset($GLOBALS['max_query_size']) && $GLOBALS['max_query_size'] > 0 && $query_size + strlen($insert_line) > $GLOBALS['max_query_size']) { if (isset($GLOBALS['max_query_size']) && $GLOBALS['max_query_size'] > 0 && $query_size + strlen($insert_line) > $GLOBALS['max_query_size']) {
if (!PMA_exportOutputHandler(';' . $crlf)) return FALSE; if (!PMA_exportOutputHandler(';' . $crlf)) {
return FALSE;
}
$query_size = 0; $query_size = 0;
$current_row = 1; $current_row = 1;
$insert_line = $schema_insert . $insert_line; $insert_line = $schema_insert . $insert_line;
@@ -616,11 +635,15 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
} }
unset($values); unset($values);
if (!PMA_exportOutputHandler(($current_row == 1 ? '' : $separator . $crlf) . $insert_line)) return FALSE; if (!PMA_exportOutputHandler(($current_row == 1 ? '' : $separator . $crlf) . $insert_line)) {
return FALSE;
}
} // end while } // end while
if ($current_row > 0) { if ($current_row > 0) {
if (!PMA_exportOutputHandler(';' . $crlf)) return FALSE; if (!PMA_exportOutputHandler(';' . $crlf)) {
return FALSE;
}
} }
} // end if ($result != FALSE) } // end if ($result != FALSE)
PMA_DBI_free_result($result); PMA_DBI_free_result($result);

View File

@@ -15,7 +15,8 @@ require_once('Spreadsheet/Excel/Writer.php');
* *
* @return bool Whether it suceeded * @return bool Whether it suceeded
*/ */
function PMA_exportComment($text) { function PMA_exportComment($text)
{
return TRUE; return TRUE;
} }
@@ -26,7 +27,8 @@ function PMA_exportComment($text) {
* *
* @access public * @access public
*/ */
function PMA_exportFooter() { function PMA_exportFooter()
{
global $workbook; global $workbook;
global $tmp_filename; global $tmp_filename;
@@ -35,7 +37,9 @@ function PMA_exportFooter() {
echo $res->getMessage(); echo $res->getMessage();
return FALSE; return FALSE;
} }
if (!PMA_exportOutputHandler(file_get_contents($tmp_filename))) return FALSE; if (!PMA_exportOutputHandler(file_get_contents($tmp_filename))) {
return FALSE;
}
unlink($tmp_filename); unlink($tmp_filename);
return TRUE; return TRUE;
@@ -48,11 +52,14 @@ function PMA_exportFooter() {
* *
* @access public * @access public
*/ */
function PMA_exportHeader() { function PMA_exportHeader()
{
global $workbook; global $workbook;
global $tmp_filename; global $tmp_filename;
if (empty($GLOBALS['cfg']['TempDir'])) return FALSE; if (empty($GLOBALS['cfg']['TempDir'])) {
return FALSE;
}
$tmp_filename = tempnam(realpath($GLOBALS['cfg']['TempDir']), 'pma_xls_'); $tmp_filename = tempnam(realpath($GLOBALS['cfg']['TempDir']), 'pma_xls_');
$workbook = new Spreadsheet_Excel_Writer($tmp_filename); $workbook = new Spreadsheet_Excel_Writer($tmp_filename);
@@ -68,7 +75,8 @@ function PMA_exportHeader() {
* *
* @access public * @access public
*/ */
function PMA_exportDBHeader($db) { function PMA_exportDBHeader($db)
{
return TRUE; return TRUE;
} }
@@ -81,7 +89,8 @@ function PMA_exportDBHeader($db) {
* *
* @access public * @access public
*/ */
function PMA_exportDBFooter($db) { function PMA_exportDBFooter($db)
{
return TRUE; return TRUE;
} }
@@ -94,7 +103,8 @@ function PMA_exportDBFooter($db) {
* *
* @access public * @access public
*/ */
function PMA_exportDBCreate($db) { function PMA_exportDBCreate($db)
{
return TRUE; return TRUE;
} }
@@ -111,7 +121,8 @@ function PMA_exportDBCreate($db) {
* *
* @access public * @access public
*/ */
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) { function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $what; global $what;
global $workbook; global $workbook;
@@ -119,7 +130,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$workbook->setTempDir(realpath($GLOBALS['cfg']['TempDir'])); $workbook->setTempDir(realpath($GLOBALS['cfg']['TempDir']));
// Gets the data from the database // Gets the data from the database
$result = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED); $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result); $fields_cnt = PMA_DBI_num_fields($result);
$col = 0; $col = 0;
@@ -138,7 +149,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
for ($j = 0; $j < $fields_cnt; $j++) { for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) { if (!isset($row[$j]) || is_null($row[$j])) {
$worksheet->write($col, $j, $GLOBALS['xls_replace_null']); $worksheet->write($col, $j, $GLOBALS['xls_replace_null']);
} else if ($row[$j] == '0' || $row[$j] != '') { } elseif ($row[$j] == '0' || $row[$j] != '') {
// FIXME: we should somehow handle character set here! // FIXME: we should somehow handle character set here!
$worksheet->write($col, $j, $row[$j]); $worksheet->write($col, $j, $row[$j]);
} else { } else {

View File

@@ -124,7 +124,7 @@ function PMA_exportDBCreate($db) {
* @access public * @access public
*/ */
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) { function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$result = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED); $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$columns_cnt = PMA_DBI_num_fields($result); $columns_cnt = PMA_DBI_num_fields($result);
for ($i = 0; $i < $columns_cnt; $i++) { for ($i = 0; $i < $columns_cnt; $i++) {
@@ -133,7 +133,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
unset($i); unset($i);
$buffer = ' <!-- ' . $GLOBALS['strTable'] . ' ' . $table . ' -->' . $crlf; $buffer = ' <!-- ' . $GLOBALS['strTable'] . ' ' . $table . ' -->' . $crlf;
if (!PMA_exportOutputHandler($buffer)) return FALSE; if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
while ($record = PMA_DBI_fetch_row($result)) { while ($record = PMA_DBI_fetch_row($result)) {
$buffer = ' <' . $table . '>' . $crlf; $buffer = ' <' . $table . '>' . $crlf;
@@ -145,7 +147,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
} }
$buffer .= ' </' . $table . '>' . $crlf; $buffer .= ' </' . $table . '>' . $crlf;
if (!PMA_exportOutputHandler($buffer)) return FALSE; if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
} }
PMA_DBI_free_result($result); PMA_DBI_free_result($result);

View File

@@ -10,7 +10,8 @@
* @param string regullar expression to match files * @param string regullar expression to match files
* @returns array sorted file list on success, FALSE on failure * @returns array sorted file list on success, FALSE on failure
*/ */
function PMA_getDirContent($dir, $expression = '') { function PMA_getDirContent($dir, $expression = '')
{
if ($handle = @opendir($dir)) { if ($handle = @opendir($dir)) {
$result = array(); $result = array();
if (substr($dir, -1) != '/') { if (substr($dir, -1) != '/') {
@@ -37,11 +38,14 @@ function PMA_getDirContent($dir, $expression = '') {
* @param string currently active choice * @param string currently active choice
* @returns array sorted file list on success, FALSE on failure * @returns array sorted file list on success, FALSE on failure
*/ */
function PMA_getFileSelectOptions($dir, $extensions = '', $active = '') { function PMA_getFileSelectOptions($dir, $extensions = '', $active = '')
{
$list = PMA_getDirContent($dir, $extensions); $list = PMA_getDirContent($dir, $extensions);
if ($list === FALSE) return FALSE; if ($list === FALSE) {
return FALSE;
}
$result = ''; $result = '';
foreach($list as $key => $val) { foreach ($list as $key => $val) {
$result .= '<option value="'. htmlspecialchars($val) . '"'; $result .= '<option value="'. htmlspecialchars($val) . '"';
if ($val == $active) { if ($val == $active) {
$result .= ' selected="selected"'; $result .= ' selected="selected"';
@@ -56,21 +60,28 @@ function PMA_getFileSelectOptions($dir, $extensions = '', $active = '') {
* *
* @returns string | separated list of extensions usable in PMA_getDirContent * @returns string | separated list of extensions usable in PMA_getDirContent
*/ */
function PMA_supportedDecompressions() { function PMA_supportedDecompressions()
{
global $cfg; global $cfg;
$compressions = ''; $compressions = '';
if ($cfg['GZipDump'] && @function_exists('gzopen')) { if ($cfg['GZipDump'] && @function_exists('gzopen')) {
if (!empty($compressions)) $compressions .= '|'; if (!empty($compressions)) {
$compressions .= '|';
}
$compressions .= 'gz'; $compressions .= 'gz';
} }
if ($cfg['BZipDump'] && @function_exists('bzopen')) { if ($cfg['BZipDump'] && @function_exists('bzopen')) {
if (!empty($compressions)) $compressions .= '|'; if (!empty($compressions)) {
$compressions .= '|';
}
$compressions .= 'bz2'; $compressions .= 'bz2';
} }
if ($cfg['ZipDump'] && @function_exists('gzinflate')) { if ($cfg['ZipDump'] && @function_exists('gzinflate')) {
if (!empty($compressions)) $compressions .= '|'; if (!empty($compressions)) {
$compressions .= '|';
}
$compressions .= 'zip'; $compressions .= 'zip';
} }

View File

@@ -68,13 +68,17 @@ require_once('./libraries/relation.lib.php'); // for PMA_setHistory()
<?php <?php
// Link to itself to replicate windows including frameset // Link to itself to replicate windows including frameset
if (!isset($GLOBALS['checked_special'])) $GLOBALS['checked_special'] = FALSE; if (!isset($GLOBALS['checked_special'])) {
$GLOBALS['checked_special'] = FALSE;
}
if (isset($_SERVER['SCRIPT_NAME']) && empty($_POST) && !$GLOBALS['checked_special']) { if (isset($_SERVER['SCRIPT_NAME']) && empty($_POST) && !$GLOBALS['checked_special']) {
echo '<div id="selflink">' . "\n"; echo '<div id="selflink">' . "\n";
echo '<a href="index.php?target=' . basename($_SERVER['SCRIPT_NAME']); echo '<a href="index.php?target=' . basename($_SERVER['SCRIPT_NAME']);
$url = PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : ''); $url = PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : '');
if (!empty($url)) echo '&amp;' . $url; if (!empty($url)) {
echo '&amp;' . $url;
}
echo '" target="_blank">' . $GLOBALS['strOpenNewWindow'] . '</a>' . "\n"; echo '" target="_blank">' . $GLOBALS['strOpenNewWindow'] . '</a>' . "\n";
echo '</div>' . "\n"; echo '</div>' . "\n";
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,394 +1,493 @@
<?php <?php
/*******************************************************************************
* Software: UFPDF, Unicode Free PDF generator *
* Version: 0.1 *
* based on FPDF 1.52 by Olivier PLATHEY *
* Date: 2004-09-01 *
* Author: Steven Wittens <steven@acko.net> *
* License: GPL *
* *
* UFPDF is a modification of FPDF to support Unicode through UTF-8. *
* *
*******************************************************************************/
if(!class_exists('UFPDF')) /**
{ * Software: UFPDF, Unicode Free PDF generator *
define('UFPDF_VERSION','0.1'); *
* Version: 0.1 *
*
* based on FPDF 1.52 by Olivier PLATHEY *
*
* Date: 2004-09-01 *
*
* Author: Steven Wittens <steven@acko.net> *
*
* License: GPL *
*
*
*
* UFPDF is a modification of FPDF to support Unicode through UTF-8. *
*/
include_once './libraries/fpdf/fpdf.php'; if (!class_exists('UFPDF')) {
define('UFPDF_VERSION', '0.1');
class UFPDF extends FPDF include_once './libraries/fpdf/fpdf.php';
{
/******************************************************************************* class UFPDF extends FPDF {
* * /**
* Public methods * * Public methods *
* * */
*******************************************************************************/
function UFPDF($orientation='P',$unit='mm',$format='A4') function UFPDF($orientation = 'P', $unit = 'mm', $format = 'A4')
{ {
FPDF::FPDF($orientation, $unit, $format); FPDF::FPDF($orientation, $unit, $format);
}
function GetStringWidth($s)
{
//Get width of a string in the current font
$s = (string)$s;
$codepoints=$this->utf8_to_codepoints($s);
$cw=&$this->CurrentFont['cw'];
$w=0;
foreach($codepoints as $cp)
$w+=isset($cw[$cp])?$cw[$cp]:0;
return $w*$this->FontSize/1000;
}
function AddFont($family,$style='',$file='')
{
//Add a TrueType or Type1 font
$family=strtolower($family);
if($family=='arial')
$family='helvetica';
$style=strtoupper($style);
if($style=='IB')
$style='BI';
if(isset($this->fonts[$family.$style]))
$this->Error('Font already added: '.$family.' '.$style);
if($file=='')
$file=str_replace(' ','',$family).strtolower($style).'.php';
if(defined('FPDF_FONTPATH'))
$file=FPDF_FONTPATH.$file;
include($file);
if(!isset($name))
$this->Error('Could not include font definition file');
$i=count($this->fonts)+1;
$this->fonts[$family.$style]=array('i'=>$i,'type'=>$type,'name'=>$name,'desc'=>$desc,'up'=>$up,'ut'=>$ut,'cw'=>$cw,'file'=>$file,'ctg'=>$ctg);
if($file)
{
if($type=='TrueTypeUnicode')
$this->FontFiles[$file]=array('length1'=>$originalsize);
else
$this->FontFiles[$file]=array('length1'=>$size1,'length2'=>$size2);
} }
}
function Text($x,$y,$txt) function GetStringWidth($s)
{ {
//Output a string // Get width of a string in the current font
$s=sprintf('BT %.2f %.2f Td %s Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escapetext($txt)); $s = (string)$s;
if($this->underline and $txt!='') $codepoints = $this->utf8_to_codepoints($s);
$s.=' '.$this->_dounderline($x,$y,$this->GetStringWidth($txt),$txt); $cw = &$this->CurrentFont['cw'];
if($this->ColorFlag) $w = 0;
$s='q '.$this->TextColor.' '.$s.' Q';
foreach ($codepoints as $cp) {
$w += isset($cw[$cp])?$cw[$cp]:0;
}
return $w * $this->FontSize / 1000;
}
function AddFont($family, $style = '', $file = '')
{
// Add a TrueType or Type1 font
$family = strtolower($family);
if ($family == 'arial') {
$family = 'helvetica';
}
$style = strtoupper($style);
if ($style == 'IB') {
$style = 'BI';
}
if (isset($this->fonts[$family . $style])) {
$this->Error('Font already added: ' . $family . ' ' . $style);
}
if ($file == '') {
$file = str_replace(' ', '', $family) . strtolower($style) . '.php';
}
if (defined('FPDF_FONTPATH')) {
$file = FPDF_FONTPATH . $file;
}
include($file);
if (!isset($name)) {
$this->Error('Could not include font definition file');
}
$i = count($this->fonts) + 1;
$this->fonts[$family . $style] = array('i' => $i, 'type' => $type, 'name' => $name, 'desc' => $desc, 'up' => $up, 'ut' => $ut, 'cw' => $cw, 'file' => $file, 'ctg' => $ctg);
if ($file) {
if ($type == 'TrueTypeUnicode') {
$this->FontFiles[$file] = array('length1' => $originalsize);
} else {
$this->FontFiles[$file] = array('length1' => $size1, 'length2' => $size2);
}
}
}
function Text($x, $y, $txt)
{
// Output a string
$s = sprintf('BT %.2f %.2f Td %s Tj ET', $x * $this->k, ($this->h - $y) * $this->k, $this->_escapetext($txt));
if ($this->underline and $txt != '') {
$s .= ' ' . $this->_dounderline($x, $y, $this->GetStringWidth($txt), $txt);
}
if ($this->ColorFlag) {
$s = 'q ' . $this->TextColor . ' ' . $s . ' Q';
}
$this->_out($s); $this->_out($s);
} }
function AcceptPageBreak() function AcceptPageBreak()
{ {
//Accept automatic page break or not // Accept automatic page break or not
return $this->AutoPageBreak; return $this->AutoPageBreak;
} }
function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='') function Cell($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = 0, $link = '')
{
//Output a cell
$k=$this->k;
if($this->y+$h>$this->PageBreakTrigger and !$this->InFooter and $this->AcceptPageBreak())
{ {
//Automatic page break // Output a cell
$x=$this->x; $k = $this->k;
$ws=$this->ws;
if($ws>0) if ($this->y + $h > $this->PageBreakTrigger and !$this->InFooter and $this->AcceptPageBreak()) {
{ // Automatic page break
$this->ws=0; $x = $this->x;
$ws = $this->ws;
if ($ws > 0) {
$this->ws = 0;
$this->_out('0 Tw'); $this->_out('0 Tw');
} }
$this->AddPage($this->CurOrientation); $this->AddPage($this->CurOrientation);
$this->x=$x; $this->x = $x;
if($ws>0)
{ if ($ws > 0) {
$this->ws=$ws; $this->ws = $ws;
$this->_out(sprintf('%.3f Tw',$ws*$k)); $this->_out(sprintf('%.3f Tw', $ws * $k));
} }
} }
if($w==0)
$w=$this->w-$this->rMargin-$this->x; if ($w == 0) {
$s=''; $w = $this->w - $this->rMargin - $this->x;
if($fill==1 or $border==1)
{
if($fill==1)
$op=($border==1) ? 'B' : 'f';
else
$op='S';
$s=sprintf('%.2f %.2f %.2f %.2f re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
} }
if(is_string($border))
{ $s = '';
$x=$this->x;
$y=$this->y; if ($fill == 1 or $border == 1) {
if(is_int(strpos($border,'L'))) if ($fill == 1) {
$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); $op = ($border == 1) ? 'B' : 'f';
if(is_int(strpos($border,'T'))) } else {
$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); $op = 'S';
if(is_int(strpos($border,'R')))
$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
if(is_int(strpos($border,'B')))
$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
} }
if($txt!='')
{ $s = sprintf('%.2f %.2f %.2f %.2f re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, - $h * $k, $op);
}
if (is_string($border)) {
$x = $this->x;
$y = $this->y;
if (is_int(strpos($border, 'L'))) {
$s .= sprintf('%.2f %.2f m %.2f %.2f l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k);
}
if (is_int(strpos($border, 'T'))) {
$s .= sprintf('%.2f %.2f m %.2f %.2f l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k);
}
if (is_int(strpos($border, 'R'))) {
$s .= sprintf('%.2f %.2f m %.2f %.2f l S ', ($x + $w) * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
}
if (is_int(strpos($border, 'B'))) {
$s .= sprintf('%.2f %.2f m %.2f %.2f l S ', $x * $k, ($this->h - ($y + $h)) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
}
}
if ($txt != '') {
$width = $this->GetStringWidth($txt); $width = $this->GetStringWidth($txt);
if($align=='R')
$dx=$w-$this->cMargin-$width; if ($align == 'R') {
elseif($align=='C') $dx = $w - $this->cMargin - $width;
$dx=($w-$width)/2; } elseif ($align == 'C') {
else $dx = ($w - $width) / 2;
$dx=$this->cMargin; } else {
if($this->ColorFlag) $dx = $this->cMargin;
$s.='q '.$this->TextColor.' ';
$txtstring=$this->_escapetext($txt);
$s.=sprintf('BT %.2f %.2f Td %s Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txtstring);
if($this->underline)
$s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$width,$txt);
if($this->ColorFlag)
$s.=' Q';
if($link)
$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$width,$this->FontSize,$link);
} }
if($s)
if ($this->ColorFlag) {
$s .= 'q ' . $this->TextColor . ' ';
}
$txtstring = $this->_escapetext($txt);
$s .= sprintf('BT %.2f %.2f Td %s Tj ET', ($this->x + $dx) * $k, ($this->h - ($this->y + .5 * $h + .3 * $this->FontSize)) * $k, $txtstring);
if ($this->underline) {
$s .= ' ' . $this->_dounderline($this->x + $dx, $this->y + .5 * $h + .3 * $this->FontSize, $width, $txt);
}
if ($this->ColorFlag) {
$s .= ' Q';
}
if ($link) {
$this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $width, $this->FontSize, $link);
}
}
if ($s) {
$this->_out($s); $this->_out($s);
$this->lasth=$h;
if($ln>0)
{
//Go to next line
$this->y+=$h;
if($ln==1)
$this->x=$this->lMargin;
} }
else
$this->x+=$w;
}
/******************************************************************************* $this->lasth = $h;
* *
* Protected methods *
* *
*******************************************************************************/
function _puttruetypeunicode($font) { if ($ln > 0) {
//Type0 Font // Go to next line
$this->y += $h;
if ($ln == 1) {
$this->x = $this->lMargin;
}
} else {
$this->x += $w;
}
}
/**
* Protected methods *
*/
function _puttruetypeunicode($font)
{
// Type0 Font
$this->_newobj(); $this->_newobj();
$this->_out('<</Type /Font'); $this->_out('<</Type /Font');
$this->_out('/Subtype /Type0'); $this->_out('/Subtype /Type0');
$this->_out('/BaseFont /'. $font['name'] .'-UCS'); $this->_out('/BaseFont /' . $font['name'] . '-UCS');
$this->_out('/Encoding /Identity-H'); $this->_out('/Encoding /Identity-H');
$this->_out('/DescendantFonts ['. ($this->n + 1) .' 0 R]'); $this->_out('/DescendantFonts [' . ($this->n + 1) . ' 0 R]');
$this->_out('>>'); $this->_out('>>');
$this->_out('endobj'); $this->_out('endobj');
// CIDFont
//CIDFont
$this->_newobj(); $this->_newobj();
$this->_out('<</Type /Font'); $this->_out('<</Type /Font');
$this->_out('/Subtype /CIDFontType2'); $this->_out('/Subtype /CIDFontType2');
$this->_out('/BaseFont /'. $font['name']); $this->_out('/BaseFont /' . $font['name']);
$this->_out('/CIDSystemInfo <</Registry (Adobe) /Ordering (UCS) /Supplement 0>>'); $this->_out('/CIDSystemInfo <</Registry (Adobe) /Ordering (UCS) /Supplement 0>>');
$this->_out('/FontDescriptor '. ($this->n + 1) .' 0 R'); $this->_out('/FontDescriptor ' . ($this->n + 1) . ' 0 R');
$c = 0; $c = 0;
$widths = ''; $widths = '';
foreach ($font['cw'] as $i => $w) { foreach ($font['cw'] as $i => $w) {
$widths .= $i .' ['. $w.'] '; $widths .= $i . ' [' . $w . '] ';
} }
$this->_out('/W ['. $widths .']');
$this->_out('/CIDToGIDMap '. ($this->n + 2) .' 0 R'); $this->_out('/W [' . $widths . ']');
$this->_out('/CIDToGIDMap ' . ($this->n + 2) . ' 0 R');
$this->_out('>>'); $this->_out('>>');
$this->_out('endobj'); $this->_out('endobj');
// Font descriptor
//Font descriptor
$this->_newobj(); $this->_newobj();
$this->_out('<</Type /FontDescriptor'); $this->_out('<</Type /FontDescriptor');
$this->_out('/FontName /'.$font['name']); $this->_out('/FontName /' . $font['name']);
$s = ''; $s = '';
foreach ($font['desc'] as $k => $v) { foreach ($font['desc'] as $k => $v) {
$s .= ' /'. $k .' '. $v; $s .= ' /' . $k . ' ' . $v;
} }
if ($font['file']) { if ($font['file']) {
$s .= ' /FontFile2 '. $this->FontFiles[$font['file']]['n'] .' 0 R'; $s .= ' /FontFile2 ' . $this->FontFiles[$font['file']]['n'] . ' 0 R';
} }
$this->_out($s); $this->_out($s);
$this->_out('>>'); $this->_out('>>');
$this->_out('endobj'); $this->_out('endobj');
// Embed CIDToGIDMap
//Embed CIDToGIDMap
$this->_newobj(); $this->_newobj();
if(defined('FPDF_FONTPATH'))
$file=FPDF_FONTPATH.$font['ctg']; if (defined('FPDF_FONTPATH')) {
else $file = FPDF_FONTPATH . $font['ctg'];
$file=$font['ctg']; } else {
$size=filesize($file); $file = $font['ctg'];
if(!$size) }
$size = filesize($file);
if (!$size) {
$this->Error('Font file not found'); $this->Error('Font file not found');
$this->_out('<</Length '.$size); }
if(substr($file,-2) == '.z')
$this->_out('<</Length ' . $size);
if (substr($file, -2) == '.z') {
$this->_out('/Filter /FlateDecode'); $this->_out('/Filter /FlateDecode');
}
$this->_out('>>'); $this->_out('>>');
$f = fopen($file,'rb'); $f = fopen($file, 'rb');
$this->_putstream(fread($f,$size)); $this->_putstream(fread($f, $size));
fclose($f); fclose($f);
$this->_out('endobj'); $this->_out('endobj');
} }
function _dounderline($x,$y,$width,$txt) function _dounderline($x, $y, $width, $txt)
{ {
//Underline text // Underline text
$up=$this->CurrentFont['up']; $up = $this->CurrentFont['up'];
$ut=$this->CurrentFont['ut']; $ut = $this->CurrentFont['ut'];
$w=$width+$this->ws*substr_count($txt,' '); $w = $width + $this->ws * substr_count($txt, ' ');
return sprintf('%.2f %.2f %.2f %.2f re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt); return sprintf('%.2f %.2f %.2f %.2f re f', $x * $this->k, ($this->h - ($y - $up / 1000 * $this->FontSize)) * $this->k, $w * $this->k, - $ut / 1000 * $this->FontSizePt);
} }
function _textstring($s) function _textstring($s)
{ {
//Convert to UTF-16BE // Convert to UTF-16BE
$s = $this->utf8_to_utf16be($s); $s = $this->utf8_to_utf16be($s);
//Escape necessary characters // Escape necessary characters
return '('. strtr($s, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\')) .')'; return '(' . strtr($s, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\')) . ')';
} }
function _strreplace($what, $to, $where) { function _strreplace($what, $to, $where)
{
$to = '' . $to; $to = '' . $to;
return str_replace($this->utf8_to_utf16be($what, false), $this->utf8_to_utf16be($to, false), $where); return str_replace($this->utf8_to_utf16be($what, false), $this->utf8_to_utf16be($to, false), $where);
} }
function _escapetext($s) function _escapetext($s)
{ {
//Convert to UTF-16BE // Convert to UTF-16BE
$s = $this->utf8_to_utf16be($s, false); $s = $this->utf8_to_utf16be($s, false);
//Escape necessary characters // Escape necessary characters
return '('. strtr($s, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\')) .')'; return '(' . strtr($s, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\')) . ')';
} }
function _putinfo() function _putinfo()
{ {
$this->_out('/Producer '.$this->_textstring('UFPDF '. UFPDF_VERSION)); $this->_out('/Producer ' . $this->_textstring('UFPDF ' . UFPDF_VERSION));
if(!empty($this->title))
$this->_out('/Title '.$this->_textstring($this->title));
if(!empty($this->subject))
$this->_out('/Subject '.$this->_textstring($this->subject));
if(!empty($this->author))
$this->_out('/Author '.$this->_textstring($this->author));
if(!empty($this->keywords))
$this->_out('/Keywords '.$this->_textstring($this->keywords));
if(!empty($this->creator))
$this->_out('/Creator '.$this->_textstring($this->creator));
$this->_out('/CreationDate '.$this->_textstring('D:'.date('YmdHis')));
}
// UTF-8 to UTF-16BE conversion. if (!empty($this->title)) {
// Correctly handles all illegal UTF-8 sequences. $this->_out('/Title ' . $this->_textstring($this->title));
function utf8_to_utf16be(&$txt, $bom = true) { }
if (!empty($this->subject)) {
$this->_out('/Subject ' . $this->_textstring($this->subject));
}
if (!empty($this->author)) {
$this->_out('/Author ' . $this->_textstring($this->author));
}
if (!empty($this->keywords)) {
$this->_out('/Keywords ' . $this->_textstring($this->keywords));
}
if (!empty($this->creator)) {
$this->_out('/Creator ' . $this->_textstring($this->creator));
}
$this->_out('/CreationDate ' . $this->_textstring('D:' . date('YmdHis')));
}
// UTF-8 to UTF-16BE conversion.
// Correctly handles all illegal UTF-8 sequences.
function utf8_to_utf16be(&$txt, $bom = true)
{
$l = strlen($txt); $l = strlen($txt);
$out = $bom ? "\xFE\xFF" : ''; $out = $bom ? "\xFE\xFF" : '';
for ($i = 0; $i < $l; ++$i) { for ($i = 0; $i < $l; ++$i) {
$c = ord($txt{$i}); $c = ord($txt{$i});
// ASCII // ASCII
if ($c < 0x80) { if ($c < 0x80) {
$out .= "\x00". $txt{$i}; $out .= "\x00" . $txt{$i};
} }
// Lost continuation byte // Lost continuation byte
else if ($c < 0xC0) { elseif ($c < 0xC0) {
$out .= "\xFF\xFD"; $out .= "\xFF\xFD";
continue; continue;
} }
// Multibyte sequence leading byte // Multibyte sequence leading byte
else { else {
if ($c < 0xE0) { if ($c < 0xE0) {
$s = 2; $s = 2;
} } elseif ($c < 0xF0) {
else if ($c < 0xF0) {
$s = 3; $s = 3;
} } elseif ($c < 0xF8) {
else if ($c < 0xF8) {
$s = 4; $s = 4;
} }
// 5/6 byte sequences not possible for Unicode. // 5/6 byte sequences not possible for Unicode.
else { else {
$out .= "\xFF\xFD"; $out .= "\xFF\xFD";
while (ord($txt{$i + 1}) >= 0x80 && ord($txt{$i + 1}) < 0xC0) { ++$i; }
while (ord($txt{$i + 1}) >= 0x80 && ord($txt{$i + 1}) < 0xC0) {
++$i;
}
continue; continue;
} }
$q = array($c); $q = array($c);
// Fetch rest of sequence // Fetch rest of sequence
$l = strlen($txt); $l = strlen($txt);
while ($i + 1 < $l && ord($txt{$i + 1}) >= 0x80 && ord($txt{$i + 1}) < 0xC0) { ++$i; $q[] = ord($txt{$i}); }
while ($i + 1 < $l && ord($txt{$i + 1}) >= 0x80 && ord($txt{$i + 1}) < 0xC0) {
++$i;
$q[] = ord($txt{$i});
}
// Check length // Check length
if (count($q) != $s) { if (count($q) != $s) {
$out .= "\xFF\xFD"; $out .= "\xFF\xFD";
continue; continue;
} }
switch ($s) { switch ($s) {
case 2: case 2:
$cp = (($q[0] ^ 0xC0) << 6) | ($q[1] ^ 0x80); $cp = (($q[0] ^ 0xC0) << 6) | ($q[1] ^ 0x80);
// Overlong sequence // Overlong sequence
if ($cp < 0x80) { if ($cp < 0x80) {
$out .= "\xFF\xFD"; $out .= "\xFF\xFD";
} } else {
else {
$out .= chr($cp >> 8); $out .= chr($cp >> 8);
$out .= chr($cp & 0xFF);
$out .= chr($cp &0xFF);
} }
continue; continue;
case 3: case 3:
$cp = (($q[0] ^ 0xE0) << 12) | (($q[1] ^ 0x80) << 6) | ($q[2] ^ 0x80); $cp = (($q[0] ^ 0xE0) << 12) | (($q[1] ^ 0x80) << 6) | ($q[2] ^ 0x80);
// Overlong sequence // Overlong sequence
if ($cp < 0x800) { if ($cp < 0x800) {
$out .= "\xFF\xFD"; $out .= "\xFF\xFD";
} }
// Check for UTF-8 encoded surrogates (caused by a bad UTF-8 encoder) // Check for UTF-8 encoded surrogates (caused by a bad UTF-8 encoder)
else if ($c > 0xD800 && $c < 0xDFFF) { elseif ($c > 0xD800 && $c < 0xDFFF) {
$out .= "\xFF\xFD"; $out .= "\xFF\xFD";
} } else {
else {
$out .= chr($cp >> 8); $out .= chr($cp >> 8);
$out .= chr($cp & 0xFF);
$out .= chr($cp &0xFF);
} }
continue; continue;
case 4: case 4:
$cp = (($q[0] ^ 0xF0) << 18) | (($q[1] ^ 0x80) << 12) | (($q[2] ^ 0x80) << 6) | ($q[3] ^ 0x80); $cp = (($q[0] ^ 0xF0) << 18) | (($q[1] ^ 0x80) << 12) | (($q[2] ^ 0x80) << 6) | ($q[3] ^ 0x80);
// Overlong sequence // Overlong sequence
if ($cp < 0x10000) { if ($cp < 0x10000) {
$out .= "\xFF\xFD"; $out .= "\xFF\xFD";
} }
// Outside of the Unicode range // Outside of the Unicode range
else if ($cp >= 0x10FFFF) { elseif ($cp >= 0x10FFFF) {
$out .= "\xFF\xFD"; $out .= "\xFF\xFD";
} } else {
else {
// Use surrogates // Use surrogates
$cp -= 0x10000; $cp -= 0x10000;
$s1 = 0xD800 | ($cp >> 10); $s1 = 0xD800 | ($cp >> 10);
$s2 = 0xDC00 | ($cp & 0x3FF);
$s2 = 0xDC00 | ($cp &0x3FF);
$out .= chr($s1 >> 8); $out .= chr($s1 >> 8);
$out .= chr($s1 & 0xFF);
$out .= chr($s1 &0xFF);
$out .= chr($s2 >> 8); $out .= chr($s2 >> 8);
$out .= chr($s2 & 0xFF);
$out .= chr($s2 &0xFF);
} }
continue; continue;
} }
} }
} }
return $out;
}
// UTF-8 to codepoint array conversion. return $out;
// Correctly handles all illegal UTF-8 sequences. }
function utf8_to_codepoints(&$txt) { // UTF-8 to codepoint array conversion.
// Correctly handles all illegal UTF-8 sequences.
function utf8_to_codepoints(&$txt)
{
$l = strlen($txt); $l = strlen($txt);
$out = array(); $out = array();
for ($i = 0; $i < $l; ++$i) { for ($i = 0; $i < $l; ++$i) {
$c = ord($txt{$i}); $c = ord($txt{$i});
// ASCII // ASCII
@@ -396,88 +495,98 @@ function utf8_to_codepoints(&$txt) {
$out[] = ord($txt{$i}); $out[] = ord($txt{$i});
} }
// Lost continuation byte // Lost continuation byte
else if ($c < 0xC0) { elseif ($c < 0xC0) {
$out[] = 0xFFFD; $out[] = 0xFFFD;
continue; continue;
} }
// Multibyte sequence leading byte // Multibyte sequence leading byte
else { else {
if ($c < 0xE0) { if ($c < 0xE0) {
$s = 2; $s = 2;
} } elseif ($c < 0xF0) {
else if ($c < 0xF0) {
$s = 3; $s = 3;
} } elseif ($c < 0xF8) {
else if ($c < 0xF8) {
$s = 4; $s = 4;
} }
// 5/6 byte sequences not possible for Unicode. // 5/6 byte sequences not possible for Unicode.
else { else {
$out[] = 0xFFFD; $out[] = 0xFFFD;
while (ord($txt{$i + 1}) >= 0x80 && ord($txt{$i + 1}) < 0xC0) { ++$i; }
while (ord($txt{$i + 1}) >= 0x80 && ord($txt{$i + 1}) < 0xC0) {
++$i;
}
continue; continue;
} }
$q = array($c); $q = array($c);
// Fetch rest of sequence // Fetch rest of sequence
$l = strlen($txt); $l = strlen($txt);
while ($i + 1 < $l && ord($txt{$i + 1}) >= 0x80 && ord($txt{$i + 1}) < 0xC0) { ++$i; $q[] = ord($txt{$i}); }
while ($i + 1 < $l && ord($txt{$i + 1}) >= 0x80 && ord($txt{$i + 1}) < 0xC0) {
++$i;
$q[] = ord($txt{$i});
}
// Check length // Check length
if (count($q) != $s) { if (count($q) != $s) {
$out[] = 0xFFFD; $out[] = 0xFFFD;
continue; continue;
} }
switch ($s) { switch ($s) {
case 2: case 2:
$cp = (($q[0] ^ 0xC0) << 6) | ($q[1] ^ 0x80); $cp = (($q[0] ^ 0xC0) << 6) | ($q[1] ^ 0x80);
// Overlong sequence // Overlong sequence
if ($cp < 0x80) { if ($cp < 0x80) {
$out[] = 0xFFFD; $out[] = 0xFFFD;
} } else {
else {
$out[] = $cp; $out[] = $cp;
} }
continue; continue;
case 3: case 3:
$cp = (($q[0] ^ 0xE0) << 12) | (($q[1] ^ 0x80) << 6) | ($q[2] ^ 0x80); $cp = (($q[0] ^ 0xE0) << 12) | (($q[1] ^ 0x80) << 6) | ($q[2] ^ 0x80);
// Overlong sequence // Overlong sequence
if ($cp < 0x800) { if ($cp < 0x800) {
$out[] = 0xFFFD; $out[] = 0xFFFD;
} }
// Check for UTF-8 encoded surrogates (caused by a bad UTF-8 encoder) // Check for UTF-8 encoded surrogates (caused by a bad UTF-8 encoder)
else if ($c > 0xD800 && $c < 0xDFFF) { elseif ($c > 0xD800 && $c < 0xDFFF) {
$out[] = 0xFFFD; $out[] = 0xFFFD;
} } else {
else {
$out[] = $cp; $out[] = $cp;
} }
continue; continue;
case 4: case 4:
$cp = (($q[0] ^ 0xF0) << 18) | (($q[1] ^ 0x80) << 12) | (($q[2] ^ 0x80) << 6) | ($q[3] ^ 0x80); $cp = (($q[0] ^ 0xF0) << 18) | (($q[1] ^ 0x80) << 12) | (($q[2] ^ 0x80) << 6) | ($q[3] ^ 0x80);
// Overlong sequence // Overlong sequence
if ($cp < 0x10000) { if ($cp < 0x10000) {
$out[] = 0xFFFD; $out[] = 0xFFFD;
} }
// Outside of the Unicode range // Outside of the Unicode range
else if ($cp >= 0x10FFFF) { elseif ($cp >= 0x10FFFF) {
$out[] = 0xFFFD; $out[] = 0xFFFD;
} } else {
else {
$out[] = $cp; $out[] = $cp;
} }
continue; continue;
} }
} }
} }
return $out; return $out;
}
// End of class
}
} }
//End of class
}
}
?> ?>

View File

@@ -64,8 +64,7 @@ if ($foreigners && isset($foreigners[$field])) {
} }
@PMA_DBI_free_result($disp); @PMA_DBI_free_result($disp);
} }
} } else {
else {
unset($disp_row); unset($disp_row);
$foreign_link = true; $foreign_link = true;
} }

View File

@@ -63,7 +63,7 @@ if (empty($GLOBALS['is_header_sent'])) {
</script> </script>
<script src="./js/functions.js" type="text/javascript" language="javascript"></script> <script src="./js/functions.js" type="text/javascript" language="javascript"></script>
<?php <?php
} else if (isset($js_to_run) && $js_to_run == 'user_password.js') { } elseif (isset($js_to_run) && $js_to_run == 'user_password.js') {
echo "\n"; echo "\n";
?> ?>
// js form validation stuff // js form validation stuff
@@ -75,7 +75,7 @@ if (empty($GLOBALS['is_header_sent'])) {
</script> </script>
<script src="./js/user_password.js" type="text/javascript" language="javascript"></script> <script src="./js/user_password.js" type="text/javascript" language="javascript"></script>
<?php <?php
} else if (isset($js_to_run) && $js_to_run == 'server_privileges.js') { } elseif (isset($js_to_run) && $js_to_run == 'server_privileges.js') {
echo "\n"; echo "\n";
?> ?>
// js form validation stuff // js form validation stuff
@@ -88,7 +88,7 @@ if (empty($GLOBALS['is_header_sent'])) {
<script src="./js/server_privileges.js" type="text/javascript" language="javascript"></script> <script src="./js/server_privileges.js" type="text/javascript" language="javascript"></script>
<script src="./js/functions.js" type="text/javascript" language="javascript"></script> <script src="./js/functions.js" type="text/javascript" language="javascript"></script>
<?php <?php
} else if (isset($js_to_run) && $js_to_run == 'indexes.js') { } elseif (isset($js_to_run) && $js_to_run == 'indexes.js') {
echo "\n"; echo "\n";
?> ?>
// js index validation stuff // js index validation stuff
@@ -98,7 +98,7 @@ if (empty($GLOBALS['is_header_sent'])) {
</script> </script>
<script src="./js/indexes.js" type="text/javascript" language="javascript"></script> <script src="./js/indexes.js" type="text/javascript" language="javascript"></script>
<?php <?php
} else if (isset($js_to_run) && $js_to_run == 'tbl_change.js') { } elseif (isset($js_to_run) && $js_to_run == 'tbl_change.js') {
echo "\n"; echo "\n";
?> ?>
//--> //-->
@@ -194,7 +194,7 @@ if (empty($GLOBALS['is_header_sent'])) {
*/ */
if (!empty($show_comment) && !isset($GLOBALS['avoid_show_comment'])) { if (!empty($show_comment) && !isset($GLOBALS['avoid_show_comment'])) {
if (strstr($show_comment, '; InnoDB free')) { if (strstr($show_comment, '; InnoDB free')) {
$show_comment = preg_replace('@; InnoDB free:.*?$@' , '', $show_comment); $show_comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
} }
echo '<span class="table_comment" id="span_table_comment">' echo '<span class="table_comment" id="span_table_comment">'
.'&quot;' . htmlspecialchars($show_comment) .'&quot;' . htmlspecialchars($show_comment)

View File

@@ -28,10 +28,11 @@ echo "<?xml version=\"1.0\" encoding=\"" . $GLOBALS['charset'] . "\"?".">";
<link rel="icon" href="./favicon.ico" type="image/x-icon" /> <link rel="icon" href="./favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
<title><?php <title><?php
if(!empty($page_title)) if (!empty($page_title)) {
echo htmlspecialchars($page_title); echo htmlspecialchars($page_title);
else } else {
echo 'phpMyAdmin'; echo 'phpMyAdmin';
}
?></title> ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $GLOBALS['charset']; ?>" /> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $GLOBALS['charset']; ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo defined('PMA_PATH_TO_BASEDIR') ? PMA_PATH_TO_BASEDIR : './'; ?>css/phpmyadmin.css.php?<?php echo PMA_generate_common_url(); ?>&amp;js_frame=<?php echo isset($print_view) ? 'print' : 'right'; ?>" /> <link rel="stylesheet" type="text/css" href="<?php echo defined('PMA_PATH_TO_BASEDIR') ? PMA_PATH_TO_BASEDIR : './'; ?>css/phpmyadmin.css.php?<?php echo PMA_generate_common_url(); ?>&amp;js_frame=<?php echo isset($print_view) ? 'print' : 'right'; ?>" />

View File

@@ -15,7 +15,8 @@ define('PMA_CHK_DROP', 1);
* @return boolean true if timeout is close * @return boolean true if timeout is close
* @access public * @access public
*/ */
function PMA_checkTimeout() { function PMA_checkTimeout()
{
global $timestamp, $maximum_time, $timeout_passed; global $timestamp, $maximum_time, $timeout_passed;
if ($maximum_time == 0) { if ($maximum_time == 0) {
return FALSE; return FALSE;
@@ -37,16 +38,23 @@ function PMA_checkTimeout() {
* @return string MIME type of compression, none for none * @return string MIME type of compression, none for none
* @access public * @access public
*/ */
function PMA_detectCompression($filepath) { function PMA_detectCompression($filepath)
{
$file = @fopen($filepath, 'rb'); $file = @fopen($filepath, 'rb');
if (!$file) { if (!$file) {
return FALSE; return FALSE;
} }
$test = fread($file, 4); $test = fread($file, 4);
fclose($file); fclose($file);
if ($test[0] == chr(31) && $test[1] == chr(139)) return 'application/gzip'; if ($test[0] == chr(31) && $test[1] == chr(139)) {
if (substr($test, 0, 3) == 'BZh') return 'application/bzip2'; return 'application/gzip';
if ($test == "PK\003\004") return 'application/zip'; }
if (substr($test, 0, 3) == 'BZh') {
return 'application/bzip2';
}
if ($test == "PK\003\004") {
return 'application/zip';
}
return 'none'; return 'none';
} }
@@ -58,7 +66,8 @@ function PMA_detectCompression($filepath) {
* @param string query to display, this might be commented * @param string query to display, this might be commented
* @access public * @access public
*/ */
function PMA_importRunQuery($sql = '', $full = '') { function PMA_importRunQuery($sql = '', $full = '')
{
global $import_run_buffer, $go_sql, $complete_query, $display_query, $sql_query, $cfg, $my_die, $error, $reload, $finished, $timeout_passed, $skip_queries, $executed_queries, $max_sql_len, $read_multiply, $cfg, $sql_query_disabled, $db, $run_query, $is_superuser; global $import_run_buffer, $go_sql, $complete_query, $display_query, $sql_query, $cfg, $my_die, $error, $reload, $finished, $timeout_passed, $skip_queries, $executed_queries, $max_sql_len, $read_multiply, $cfg, $sql_query_disabled, $db, $run_query, $is_superuser;
$read_multiply = 1; $read_multiply = 1;
if (isset($import_run_buffer)) { if (isset($import_run_buffer)) {
@@ -110,7 +119,7 @@ function PMA_importRunQuery($sql = '', $full = '') {
$error = TRUE; $error = TRUE;
return; return;
} }
} else if ($cfg['VerboseMultiSubmit']) { } elseif ($cfg['VerboseMultiSubmit']) {
$a_num_rows = (int)@PMA_DBI_num_rows($result); $a_num_rows = (int)@PMA_DBI_num_rows($result);
$a_aff_rows = (int)@PMA_DBI_affected_rows(); $a_aff_rows = (int)@PMA_DBI_affected_rows();
if ($a_num_rows > 0) { if ($a_num_rows > 0) {
@@ -181,19 +190,29 @@ function PMA_importRunQuery($sql = '', $full = '') {
* @return string part of file/buffer * @return string part of file/buffer
* @access public * @access public
*/ */
function PMA_importGetNextChunk($size = 32768) { function PMA_importGetNextChunk($size = 32768)
{
global $import_file, $import_text, $finished, $compression, $import_handle, $offset, $charset_conversion, $charset_of_file, $charset, $read_multiply, $read_limit; global $import_file, $import_text, $finished, $compression, $import_handle, $offset, $charset_conversion, $charset_of_file, $charset, $read_multiply, $read_limit;
// Add some progression while reading large amount of data // Add some progression while reading large amount of data
if ($read_multiply <= 8) $size *= $read_multiply; if ($read_multiply <= 8) {
else $size *= 8; $size *= $read_multiply;
} else {
$size *= 8;
}
$read_multiply++; $read_multiply++;
// We can not read too much // We can not read too much
if ($size > $read_limit) $size = $read_limit; if ($size > $read_limit) {
$size = $read_limit;
}
if (PMA_checkTimeout()) return FALSE; if (PMA_checkTimeout()) {
if ($finished) return TRUE; return FALSE;
}
if ($finished) {
return TRUE;
}
if ($import_file == 'none') { if ($import_file == 'none') {
// Well this is not yet supported and tested, but should return content of textarea // Well this is not yet supported and tested, but should return content of textarea

View File

@@ -75,7 +75,7 @@ if ($plugin_param == 'table') {
} }
$val = trim($val); $val = trim($val);
$found = FALSE; $found = FALSE;
foreach($tmp_fields as $id => $field) { foreach ($tmp_fields as $id => $field) {
if ($field['Field'] == $val) { if ($field['Field'] == $val) {
$found = TRUE; $found = TRUE;
break; break;
@@ -118,7 +118,9 @@ if ($plugin_param == 'table') {
$buffer .= $data; $buffer .= $data;
// Do not parse string when we're not at the end and don't have new line inside // Do not parse string when we're not at the end and don't have new line inside
if (($csv_new_line == 'auto' && strpos($buffer, "\r") === FALSE && strpos($buffer, "\n") === FALSE) if (($csv_new_line == 'auto' && strpos($buffer, "\r") === FALSE && strpos($buffer, "\n") === FALSE)
|| ($csv_new_line != 'auto' && strpos($buffer, $csv_new_line) === FALSE)) continue; || ($csv_new_line != 'auto' && strpos($buffer, $csv_new_line) === FALSE)) {
continue;
}
} }
// Current length of our buffer // Current length of our buffer
@@ -140,7 +142,9 @@ if ($plugin_param == 'table') {
// Grab empty field // Grab empty field
if ($ch == $csv_terminated) { if ($ch == $csv_terminated) {
$values[] = ''; $values[] = '';
if ($i == $len - 1) break; if ($i == $len - 1) {
break;
}
$i++; $i++;
$ch = $buffer[$i]; $ch = $buffer[$i];
continue; continue;
@@ -149,7 +153,9 @@ if ($plugin_param == 'table') {
// Grab one field // Grab one field
if ($ch == $csv_enclosed) { if ($ch == $csv_enclosed) {
$need_end = TRUE; $need_end = TRUE;
if ($i == $len - 1) break; if ($i == $len - 1) {
break;
}
$i++; $i++;
$ch = $buffer[$i]; $ch = $buffer[$i];
} else { } else {
@@ -157,7 +163,7 @@ if ($plugin_param == 'table') {
} }
$fail = FALSE; $fail = FALSE;
$value = ''; $value = '';
while(($need_end && $ch != $csv_enclosed) || (!$need_end && !($ch == $csv_terminated || $ch == $csv_new_line || ($csv_new_line == 'auto' && ($ch == "\r" || $ch == "\n"))))) { while (($need_end && $ch != $csv_enclosed) || (!$need_end && !($ch == $csv_terminated || $ch == $csv_new_line || ($csv_new_line == 'auto' && ($ch == "\r" || $ch == "\n"))))) {
if ($ch == $csv_escaped) { if ($ch == $csv_escaped) {
if ($i == $len - 1) { if ($i == $len - 1) {
$fail = TRUE; $fail = TRUE;
@@ -176,11 +182,15 @@ if ($plugin_param == 'table') {
$i++; $i++;
$ch = $buffer[$i]; $ch = $buffer[$i];
} }
if ($fail) break; if ($fail) {
break;
}
$values[] = $value; $values[] = $value;
// Need to strip trailing enclosing char? // Need to strip trailing enclosing char?
if ($need_end && $ch == $csv_enclosed) { if ($need_end && $ch == $csv_enclosed) {
if ($i == $len - 1) break; if ($i == $len - 1) {
break;
}
$i++; $i++;
$ch = $buffer[$i]; $ch = $buffer[$i];
} }
@@ -190,7 +200,9 @@ if ($plugin_param == 'table') {
} }
// Go to next char // Go to next char
if ($ch == $csv_terminated) { if ($ch == $csv_terminated) {
if ($i == $len - 1) break; if ($i == $len - 1) {
break;
}
$i++; $i++;
$ch = $buffer[$i]; $ch = $buffer[$i];
} }
@@ -199,7 +211,9 @@ if ($plugin_param == 'table') {
// End of line // End of line
if ($csv_finish || $ch == $csv_new_line || ($csv_new_line == 'auto' && ($ch == "\r" || $ch == "\n"))) { if ($csv_finish || $ch == $csv_new_line || ($csv_new_line == 'auto' && ($ch == "\r" || $ch == "\n"))) {
if ($csv_new_line == 'auto' && $ch == "\r") { // Handle "\r\n" if ($csv_new_line == 'auto' && $ch == "\r") { // Handle "\r\n"
if ($i >= ($len - 2) && !$finished) break; // We need more data to decide new line if ($i >= ($len - 2) && !$finished) {
break; // We need more data to decide new line
}
if ($buffer[$i + 1] == "\n") { if ($buffer[$i + 1] == "\n") {
$i++; $i++;
} }
@@ -218,7 +232,7 @@ if ($plugin_param == 'table') {
$first = TRUE; $first = TRUE;
$sql = $sql_template; $sql = $sql_template;
foreach($values as $key => $val) { foreach ($values as $key => $val) {
if (!$first) { if (!$first) {
$sql .= ', '; $sql .= ', ';
} }

View File

@@ -29,34 +29,52 @@ if (isset($plugin_list)) {
// Append new data to buffer // Append new data to buffer
$buffer .= $data; $buffer .= $data;
// Do not parse string when we're not at the end and don't have ; inside // Do not parse string when we're not at the end and don't have ; inside
if ((strpos($buffer, ';') === FALSE) && !$finished) continue; if ((strpos($buffer, ';') === FALSE) && !$finished) {
continue;
}
} }
// Current length of our buffer // Current length of our buffer
$len = strlen($buffer); $len = strlen($buffer);
// Grab some SQL queries out of it // Grab some SQL queries out of it
while($i < $len) { while ($i < $len) {
// Find first interesting character, several strpos seem to be faster than simple loop in php: // Find first interesting character, several strpos seem to be faster than simple loop in php:
//while(($i < $len) && (strpos('\'";#-/', $buffer[$i]) === FALSE)) $i++; //while (($i < $len) && (strpos('\'";#-/', $buffer[$i]) === FALSE)) $i++;
//if ($i == $len) break; //if ($i == $len) break;
$oi = $i; $oi = $i;
$p1 = strpos($buffer, '\'', $i); $p1 = strpos($buffer, '\'', $i);
if ($p1 === FALSE) $p1 = 2147483647; if ($p1 === FALSE) {
$p1 = 2147483647;
}
$p2 = strpos($buffer, '"', $i); $p2 = strpos($buffer, '"', $i);
if ($p2 === FALSE) $p2 = 2147483647; if ($p2 === FALSE) {
$p2 = 2147483647;
}
$p3 = strpos($buffer, ';', $i); $p3 = strpos($buffer, ';', $i);
if ($p3 === FALSE) $p3 = 2147483647; if ($p3 === FALSE) {
$p3 = 2147483647;
}
$p4 = strpos($buffer, '#', $i); $p4 = strpos($buffer, '#', $i);
if ($p4 === FALSE) $p4 = 2147483647; if ($p4 === FALSE) {
$p4 = 2147483647;
}
$p5 = strpos($buffer, '--', $i); $p5 = strpos($buffer, '--', $i);
if ($p5 === FALSE) $p5 = 2147483647; if ($p5 === FALSE) {
$p5 = 2147483647;
}
$p6 = strpos($buffer, '/*', $i); $p6 = strpos($buffer, '/*', $i);
if ($p6 === FALSE) $p6 = 2147483647; if ($p6 === FALSE) {
$p6 = 2147483647;
}
$p7 = strpos($buffer, '`', $i); $p7 = strpos($buffer, '`', $i);
if ($p7 === FALSE) $p7 = 2147483647; if ($p7 === FALSE) {
$p7 = 2147483647;
}
$i = min ($p1, $p2, $p3, $p4, $p5, $p6, $p7); $i = min ($p1, $p2, $p3, $p4, $p5, $p6, $p7);
if ($i == 2147483647) { if ($i == 2147483647) {
$i = $oi; $i = $oi;
if (!$finished) break; if (!$finished) {
break;
}
// at the end there might be some whitespace... // at the end there might be some whitespace...
if (trim($buffer) == '') { if (trim($buffer) == '') {
$buffer = ''; $buffer = '';
@@ -94,7 +112,9 @@ if (isset($plugin_list)) {
// Skip the string // Skip the string
$i = $pos; $i = $pos;
} }
if (!$endq) break; if (!$endq) {
break;
}
$i++; $i++;
// Aren't we at the end? // Aren't we at the end?
if ($finished && $i == $len) { if ($finished && $i == $len) {
@@ -131,7 +151,9 @@ if (isset($plugin_list)) {
} }
} }
// Skip * // Skip *
if ($ch == '/') $i++; if ($ch == '/') {
$i++;
}
// Skip last char // Skip last char
$i++; $i++;
// Next query part will start here // Next query part will start here
@@ -161,7 +183,9 @@ if (isset($plugin_list)) {
$i = 0; $i = 0;
$start_pos = 0; $start_pos = 0;
// Any chance we will get a complete query? // Any chance we will get a complete query?
if ((strpos($buffer, ';') === FALSE) && !$finished) break; if ((strpos($buffer, ';') === FALSE) && !$finished) {
break;
}
} else { } else {
$i++; $i++;
$start_pos = $i; $start_pos = $i;

View File

@@ -25,88 +25,72 @@ function PMA_getIp()
if (empty($REMOTE_ADDR)) { if (empty($REMOTE_ADDR)) {
if (!empty($_SERVER) && isset($_SERVER['REMOTE_ADDR'])) { if (!empty($_SERVER) && isset($_SERVER['REMOTE_ADDR'])) {
$REMOTE_ADDR = $_SERVER['REMOTE_ADDR']; $REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
} } elseif (!empty($_ENV) && isset($_ENV['REMOTE_ADDR'])) {
else if (!empty($_ENV) && isset($_ENV['REMOTE_ADDR'])) {
$REMOTE_ADDR = $_ENV['REMOTE_ADDR']; $REMOTE_ADDR = $_ENV['REMOTE_ADDR'];
} } elseif (@getenv('REMOTE_ADDR')) {
else if (@getenv('REMOTE_ADDR')) {
$REMOTE_ADDR = getenv('REMOTE_ADDR'); $REMOTE_ADDR = getenv('REMOTE_ADDR');
} }
} // end if } // end if
if (empty($HTTP_X_FORWARDED_FOR)) { if (empty($HTTP_X_FORWARDED_FOR)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { if (!empty($_SERVER) && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$HTTP_X_FORWARDED_FOR = $_SERVER['HTTP_X_FORWARDED_FOR']; $HTTP_X_FORWARDED_FOR = $_SERVER['HTTP_X_FORWARDED_FOR'];
} } elseif (!empty($_ENV) && isset($_ENV['HTTP_X_FORWARDED_FOR'])) {
else if (!empty($_ENV) && isset($_ENV['HTTP_X_FORWARDED_FOR'])) {
$HTTP_X_FORWARDED_FOR = $_ENV['HTTP_X_FORWARDED_FOR']; $HTTP_X_FORWARDED_FOR = $_ENV['HTTP_X_FORWARDED_FOR'];
} } elseif (@getenv('HTTP_X_FORWARDED_FOR')) {
else if (@getenv('HTTP_X_FORWARDED_FOR')) {
$HTTP_X_FORWARDED_FOR = getenv('HTTP_X_FORWARDED_FOR'); $HTTP_X_FORWARDED_FOR = getenv('HTTP_X_FORWARDED_FOR');
} }
} // end if } // end if
if (empty($HTTP_X_FORWARDED)) { if (empty($HTTP_X_FORWARDED)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_X_FORWARDED'])) { if (!empty($_SERVER) && isset($_SERVER['HTTP_X_FORWARDED'])) {
$HTTP_X_FORWARDED = $_SERVER['HTTP_X_FORWARDED']; $HTTP_X_FORWARDED = $_SERVER['HTTP_X_FORWARDED'];
} } elseif (!empty($_ENV) && isset($_ENV['HTTP_X_FORWARDED'])) {
else if (!empty($_ENV) && isset($_ENV['HTTP_X_FORWARDED'])) {
$HTTP_X_FORWARDED = $_ENV['HTTP_X_FORWARDED']; $HTTP_X_FORWARDED = $_ENV['HTTP_X_FORWARDED'];
} } elseif (@getenv('HTTP_X_FORWARDED')) {
else if (@getenv('HTTP_X_FORWARDED')) {
$HTTP_X_FORWARDED = getenv('HTTP_X_FORWARDED'); $HTTP_X_FORWARDED = getenv('HTTP_X_FORWARDED');
} }
} // end if } // end if
if (empty($HTTP_FORWARDED_FOR)) { if (empty($HTTP_FORWARDED_FOR)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_FORWARDED_FOR'])) { if (!empty($_SERVER) && isset($_SERVER['HTTP_FORWARDED_FOR'])) {
$HTTP_FORWARDED_FOR = $_SERVER['HTTP_FORWARDED_FOR']; $HTTP_FORWARDED_FOR = $_SERVER['HTTP_FORWARDED_FOR'];
} } elseif (!empty($_ENV) && isset($_ENV['HTTP_FORWARDED_FOR'])) {
else if (!empty($_ENV) && isset($_ENV['HTTP_FORWARDED_FOR'])) {
$HTTP_FORWARDED_FOR = $_ENV['HTTP_FORWARDED_FOR']; $HTTP_FORWARDED_FOR = $_ENV['HTTP_FORWARDED_FOR'];
} } elseif (@getenv('HTTP_FORWARDED_FOR')) {
else if (@getenv('HTTP_FORWARDED_FOR')) {
$HTTP_FORWARDED_FOR = getenv('HTTP_FORWARDED_FOR'); $HTTP_FORWARDED_FOR = getenv('HTTP_FORWARDED_FOR');
} }
} // end if } // end if
if (empty($HTTP_FORWARDED)) { if (empty($HTTP_FORWARDED)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_FORWARDED'])) { if (!empty($_SERVER) && isset($_SERVER['HTTP_FORWARDED'])) {
$HTTP_FORWARDED = $_SERVER['HTTP_FORWARDED']; $HTTP_FORWARDED = $_SERVER['HTTP_FORWARDED'];
} } elseif (!empty($_ENV) && isset($_ENV['HTTP_FORWARDED'])) {
else if (!empty($_ENV) && isset($_ENV['HTTP_FORWARDED'])) {
$HTTP_FORWARDED = $_ENV['HTTP_FORWARDED']; $HTTP_FORWARDED = $_ENV['HTTP_FORWARDED'];
} } elseif (@getenv('HTTP_FORWARDED')) {
else if (@getenv('HTTP_FORWARDED')) {
$HTTP_FORWARDED = getenv('HTTP_FORWARDED'); $HTTP_FORWARDED = getenv('HTTP_FORWARDED');
} }
} // end if } // end if
if (empty($HTTP_VIA)) { if (empty($HTTP_VIA)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_VIA'])) { if (!empty($_SERVER) && isset($_SERVER['HTTP_VIA'])) {
$HTTP_VIA = $_SERVER['HTTP_VIA']; $HTTP_VIA = $_SERVER['HTTP_VIA'];
} } elseif (!empty($_ENV) && isset($_ENV['HTTP_VIA'])) {
else if (!empty($_ENV) && isset($_ENV['HTTP_VIA'])) {
$HTTP_VIA = $_ENV['HTTP_VIA']; $HTTP_VIA = $_ENV['HTTP_VIA'];
} } elseif (@getenv('HTTP_VIA')) {
else if (@getenv('HTTP_VIA')) {
$HTTP_VIA = getenv('HTTP_VIA'); $HTTP_VIA = getenv('HTTP_VIA');
} }
} // end if } // end if
if (empty($HTTP_X_COMING_FROM)) { if (empty($HTTP_X_COMING_FROM)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_X_COMING_FROM'])) { if (!empty($_SERVER) && isset($_SERVER['HTTP_X_COMING_FROM'])) {
$HTTP_X_COMING_FROM = $_SERVER['HTTP_X_COMING_FROM']; $HTTP_X_COMING_FROM = $_SERVER['HTTP_X_COMING_FROM'];
} } elseif (!empty($_ENV) && isset($_ENV['HTTP_X_COMING_FROM'])) {
else if (!empty($_ENV) && isset($_ENV['HTTP_X_COMING_FROM'])) {
$HTTP_X_COMING_FROM = $_ENV['HTTP_X_COMING_FROM']; $HTTP_X_COMING_FROM = $_ENV['HTTP_X_COMING_FROM'];
} } elseif (@getenv('HTTP_X_COMING_FROM')) {
else if (@getenv('HTTP_X_COMING_FROM')) {
$HTTP_X_COMING_FROM = getenv('HTTP_X_COMING_FROM'); $HTTP_X_COMING_FROM = getenv('HTTP_X_COMING_FROM');
} }
} // end if } // end if
if (empty($HTTP_COMING_FROM)) { if (empty($HTTP_COMING_FROM)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_COMING_FROM'])) { if (!empty($_SERVER) && isset($_SERVER['HTTP_COMING_FROM'])) {
$HTTP_COMING_FROM = $_SERVER['HTTP_COMING_FROM']; $HTTP_COMING_FROM = $_SERVER['HTTP_COMING_FROM'];
} } elseif (!empty($_ENV) && isset($_ENV['HTTP_COMING_FROM'])) {
else if (!empty($_ENV) && isset($_ENV['HTTP_COMING_FROM'])) {
$HTTP_COMING_FROM = $_ENV['HTTP_COMING_FROM']; $HTTP_COMING_FROM = $_ENV['HTTP_COMING_FROM'];
} } elseif (@getenv('HTTP_COMING_FROM')) {
else if (@getenv('HTTP_COMING_FROM')) {
$HTTP_COMING_FROM = getenv('HTTP_COMING_FROM'); $HTTP_COMING_FROM = getenv('HTTP_COMING_FROM');
} }
} // end if } // end if
@@ -120,19 +104,19 @@ function PMA_getIp()
$proxy_ip = ''; $proxy_ip = '';
if (!empty($HTTP_X_FORWARDED_FOR)) { if (!empty($HTTP_X_FORWARDED_FOR)) {
$proxy_ip = $HTTP_X_FORWARDED_FOR; $proxy_ip = $HTTP_X_FORWARDED_FOR;
} else if (!empty($HTTP_X_FORWARDED)) { } elseif (!empty($HTTP_X_FORWARDED)) {
$proxy_ip = $HTTP_X_FORWARDED; $proxy_ip = $HTTP_X_FORWARDED;
} else if (!empty($HTTP_FORWARDED_FOR)) { } elseif (!empty($HTTP_FORWARDED_FOR)) {
$proxy_ip = $HTTP_FORWARDED_FOR; $proxy_ip = $HTTP_FORWARDED_FOR;
} else if (!empty($HTTP_FORWARDED)) { } elseif (!empty($HTTP_FORWARDED)) {
$proxy_ip = $HTTP_FORWARDED; $proxy_ip = $HTTP_FORWARDED;
} else if (!empty($HTTP_VIA)) { } elseif (!empty($HTTP_VIA)) {
$proxy_ip = $HTTP_VIA; $proxy_ip = $HTTP_VIA;
} else if (!empty($HTTP_X_COMING_FROM)) { } elseif (!empty($HTTP_X_COMING_FROM)) {
$proxy_ip = $HTTP_X_COMING_FROM; $proxy_ip = $HTTP_X_COMING_FROM;
} else if (!empty($HTTP_COMING_FROM)) { } elseif (!empty($HTTP_COMING_FROM)) {
$proxy_ip = $HTTP_COMING_FROM; $proxy_ip = $HTTP_COMING_FROM;
} // end if... else if... } // end if... elseif...
// Returns the true IP if it has been found, else FALSE // Returns the true IP if it has been found, else FALSE
if (empty($proxy_ip)) { if (empty($proxy_ip)) {

View File

@@ -232,7 +232,7 @@ if ( !empty($submit_mult) && !empty($what)) {
echo PMA_generate_common_hidden_inputs($db); echo PMA_generate_common_hidden_inputs($db);
} elseif (strpos(' ' . $action, 'tbl_properties') == 1 } elseif (strpos(' ' . $action, 'tbl_properties') == 1
|| $what == 'row_delete') { || $what == 'row_delete') {
echo PMA_generate_common_hidden_inputs($db,$table); echo PMA_generate_common_hidden_inputs($db, $table);
} else { } else {
echo PMA_generate_common_hidden_inputs(); echo PMA_generate_common_hidden_inputs();
} }
@@ -393,7 +393,7 @@ elseif ($mult_btn == $strYes) {
break; break;
} // end switch } // end switch
// All "DROP TABLE","DROP FIELD", "OPTIMIZE TABLE" and "REPAIR TABLE" // All "DROP TABLE", "DROP FIELD", "OPTIMIZE TABLE" and "REPAIR TABLE"
// statements will be run at once below // statements will be run at once below
if ($run_parts) { if ($run_parts) {
$sql_query .= $a_query . ';' . "\n"; $sql_query .= $a_query . ';' . "\n";

View File

@@ -50,7 +50,7 @@ if (PMA_MYSQL_INT_VERSION >= 40100){
define('PMA_CSDROPDOWN_COLLATION', 0); define('PMA_CSDROPDOWN_COLLATION', 0);
define('PMA_CSDROPDOWN_CHARSET', 1); define('PMA_CSDROPDOWN_CHARSET', 1);
function PMA_generateCharsetDropdownBox($type = PMA_CSDROPDOWN_COLLATION, $name = NULL, $id = NULL, $default = NULL, $label = TRUE, $indent = 0, $submitOnChange = FALSE, $displayUnavailable = FALSE) { function PMA_generateCharsetDropdownBox($type = PMA_CSDROPDOWN_COLLATION, $name = null, $id = null, $default = null, $label = TRUE, $indent = 0, $submitOnChange = FALSE, $displayUnavailable = FALSE) {
global $mysql_charsets, $mysql_charsets_descriptions, $mysql_charsets_available, $mysql_collations, $mysql_collations_available; global $mysql_charsets, $mysql_charsets_descriptions, $mysql_charsets_available, $mysql_collations, $mysql_collations_available;
if (empty($name)) { if (empty($name)) {

View File

@@ -242,7 +242,7 @@ function PMA_pluginGetJavascript(&$list) {
//<![CDATA[ //<![CDATA[
function hide_them_all() { function hide_them_all() {
'; ';
foreach($list as $plugin_name => $val) { foreach ($list as $plugin_name => $val) {
$ret .= 'document.getElementById("' . $plugin_name . '_options").style.display = "none";' . "\n"; $ret .= 'document.getElementById("' . $plugin_name . '_options").style.display = "none";' . "\n";
} }
$ret .= ' $ret .= '
@@ -251,7 +251,7 @@ function PMA_pluginGetJavascript(&$list) {
function init_options() { function init_options() {
hide_them_all(); hide_them_all();
'; ';
foreach($list as $plugin_name => $val) { foreach ($list as $plugin_name => $val) {
$ret .= 'if (document.getElementById("radio_plugin_' . $plugin_name . '").checked) {' . "\n"; $ret .= 'if (document.getElementById("radio_plugin_' . $plugin_name . '").checked) {' . "\n";
$ret .= 'document.getElementById("' . $plugin_name . '_options").style.display = "block";' . "\n"; $ret .= 'document.getElementById("' . $plugin_name . '_options").style.display = "block";' . "\n";
$ret .= ' } else ' . "\n"; $ret .= ' } else ' . "\n";
@@ -269,7 +269,7 @@ function PMA_pluginGetJavascript(&$list) {
if (farr[len - 1] == "gz" || farr[len - 1] == "bz2" || farr[len -1] == "zip") len--; if (farr[len - 1] == "gz" || farr[len - 1] == "bz2" || farr[len -1] == "zip") len--;
switch (farr[len - 1]) { switch (farr[len - 1]) {
'; ';
foreach($list as $plugin_name => $val) { foreach ($list as $plugin_name => $val) {
$ret .= 'case "' . $val['extension'] . '" :'; $ret .= 'case "' . $val['extension'] . '" :';
$ret .= 'document.getElementById("radio_plugin_' . $plugin_name . '").checked = true;'; $ret .= 'document.getElementById("radio_plugin_' . $plugin_name . '").checked = true;';
$ret .= 'init_options();'; $ret .= 'init_options();';

View File

@@ -44,7 +44,7 @@ function PMA_splitSqlFile(&$ret, $sql, $release)
} }
// Backquotes or no backslashes before quotes: it's indeed the // Backquotes or no backslashes before quotes: it's indeed the
// end of the string -> exit the loop // end of the string -> exit the loop
else if ($string_start == '`' || $sql[$i-1] != '\\') { elseif ($string_start == '`' || $sql[$i-1] != '\\') {
$string_start = ''; $string_start = '';
$in_string = FALSE; $in_string = FALSE;
break; break;
@@ -74,17 +74,19 @@ function PMA_splitSqlFile(&$ret, $sql, $release)
} // end if (in string) } // end if (in string)
// lets skip comments (/*, -- and #) // lets skip comments (/*, -- and #)
else if (($char == '-' && $sql_len > $i + 2 && $sql[$i + 1] == '-' && $sql[$i + 2] <= ' ') || $char == '#' || ($char == '/' && $sql_len > $i + 1 && $sql[$i + 1] == '*')) { elseif (($char == '-' && $sql_len > $i + 2 && $sql[$i + 1] == '-' && $sql[$i + 2] <= ' ') || $char == '#' || ($char == '/' && $sql_len > $i + 1 && $sql[$i + 1] == '*')) {
$i = strpos($sql, $char == '/' ? '*/' : "\n", $i); $i = strpos($sql, $char == '/' ? '*/' : "\n", $i);
// didn't we hit end of string? // didn't we hit end of string?
if ($i === FALSE) { if ($i === FALSE) {
break; break;
} }
if ($char == '/') $i++; if ($char == '/') {
$i++;
}
} }
// We are not in a string, first check for delimiter... // We are not in a string, first check for delimiter...
else if ($char == ';') { elseif ($char == ';') {
// if delimiter found, add the parsed part to the returned array // if delimiter found, add the parsed part to the returned array
$ret[] = array('query' => substr($sql, 0, $i), 'empty' => $nothing); $ret[] = array('query' => substr($sql, 0, $i), 'empty' => $nothing);
$nothing = TRUE; $nothing = TRUE;
@@ -96,14 +98,14 @@ function PMA_splitSqlFile(&$ret, $sql, $release)
// The submited statement(s) end(s) here // The submited statement(s) end(s) here
return TRUE; return TRUE;
} }
} // end else if (is delimiter) } // end elseif (is delimiter)
// ... then check for start of a string,... // ... then check for start of a string,...
else if (($char == '"') || ($char == '\'') || ($char == '`')) { elseif (($char == '"') || ($char == '\'') || ($char == '`')) {
$in_string = TRUE; $in_string = TRUE;
$nothing = FALSE; $nothing = FALSE;
$string_start = $char; $string_start = $char;
} // end else if (is start of string) } // end elseif (is start of string)
elseif ($nothing) { elseif ($nothing) {
$nothing = FALSE; $nothing = FALSE;
@@ -151,8 +153,12 @@ function PMA_readFile($path, $mime = '') {
} }
$test = fread($file, 3); $test = fread($file, 3);
fclose($file); fclose($file);
if ($test[0] == chr(31) && $test[1] == chr(139)) return PMA_readFile($path, 'application/x-gzip'); if ($test[0] == chr(31) && $test[1] == chr(139)) {
if ($test == 'BZh') return PMA_readFile($path, 'application/x-bzip'); return PMA_readFile($path, 'application/x-gzip');
}
if ($test == 'BZh') {
return PMA_readFile($path, 'application/x-bzip');
}
return PMA_readFile($path, 'text/plain'); return PMA_readFile($path, 'text/plain');
case 'text/plain': case 'text/plain':
$file = @fopen($path, 'rb'); $file = @fopen($path, 'rb');

View File

@@ -119,17 +119,17 @@ function PMA_getRelationsParam($verbose = FALSE)
while ($curr_table = @PMA_DBI_fetch_row($tab_rs)) { while ($curr_table = @PMA_DBI_fetch_row($tab_rs)) {
if ($curr_table[0] == $cfg['Server']['bookmarktable']) { if ($curr_table[0] == $cfg['Server']['bookmarktable']) {
$cfgRelation['bookmark'] = $curr_table[0]; $cfgRelation['bookmark'] = $curr_table[0];
} else if ($curr_table[0] == $cfg['Server']['relation']) { } elseif ($curr_table[0] == $cfg['Server']['relation']) {
$cfgRelation['relation'] = $curr_table[0]; $cfgRelation['relation'] = $curr_table[0];
} else if ($curr_table[0] == $cfg['Server']['table_info']) { } elseif ($curr_table[0] == $cfg['Server']['table_info']) {
$cfgRelation['table_info'] = $curr_table[0]; $cfgRelation['table_info'] = $curr_table[0];
} else if ($curr_table[0] == $cfg['Server']['table_coords']) { } elseif ($curr_table[0] == $cfg['Server']['table_coords']) {
$cfgRelation['table_coords'] = $curr_table[0]; $cfgRelation['table_coords'] = $curr_table[0];
} else if ($curr_table[0] == $cfg['Server']['column_info']) { } elseif ($curr_table[0] == $cfg['Server']['column_info']) {
$cfgRelation['column_info'] = $curr_table[0]; $cfgRelation['column_info'] = $curr_table[0];
} else if ($curr_table[0] == $cfg['Server']['pdf_pages']) { } elseif ($curr_table[0] == $cfg['Server']['pdf_pages']) {
$cfgRelation['pdf_pages'] = $curr_table[0]; $cfgRelation['pdf_pages'] = $curr_table[0];
} else if ($curr_table[0] == $cfg['Server']['history']) { } elseif ($curr_table[0] == $cfg['Server']['history']) {
$cfgRelation['history'] = $curr_table[0]; $cfgRelation['history'] = $curr_table[0];
} }
} // end while } // end while
@@ -157,9 +157,9 @@ function PMA_getRelationsParam($verbose = FALSE)
while ($curr_mime_field = @PMA_DBI_fetch_row($mime_rs)) { while ($curr_mime_field = @PMA_DBI_fetch_row($mime_rs)) {
if ($curr_mime_field[0] == 'mimetype') { if ($curr_mime_field[0] == 'mimetype') {
$mime_field_mimetype = TRUE; $mime_field_mimetype = TRUE;
} else if ($curr_mime_field[0] == 'transformation') { } elseif ($curr_mime_field[0] == 'transformation') {
$mime_field_transformation = TRUE; $mime_field_transformation = TRUE;
} else if ($curr_mime_field[0] == 'transformation_options') { } elseif ($curr_mime_field[0] == 'transformation_options') {
$mime_field_transformation_options = TRUE; $mime_field_transformation_options = TRUE;
} }
} }
@@ -315,7 +315,7 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both') {
$show_create_table_query = 'SHOW CREATE TABLE ' $show_create_table_query = 'SHOW CREATE TABLE '
. PMA_backquote($db) . '.' . PMA_backquote($table); . PMA_backquote($db) . '.' . PMA_backquote($table);
$show_create_table_res = PMA_DBI_query($show_create_table_query); $show_create_table_res = PMA_DBI_query($show_create_table_query);
list(,$show_create_table) = PMA_DBI_fetch_row($show_create_table_res); list(, $show_create_table) = PMA_DBI_fetch_row($show_create_table_res);
PMA_DBI_free_result($show_create_table_res); PMA_DBI_free_result($show_create_table_res);
unset($show_create_table_res, $show_create_table_query); unset($show_create_table_res, $show_create_table_query);
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table)); $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
@@ -468,7 +468,7 @@ function PMA_getComments($db, $table = '') {
if (PMA_MYSQL_INT_VERSION >= 40100) { if (PMA_MYSQL_INT_VERSION >= 40100) {
$fields = PMA_DBI_get_fields($db, $table); $fields = PMA_DBI_get_fields($db, $table);
if ($fields) { if ($fields) {
foreach($fields as $key=>$field) { foreach ($fields as $key=>$field) {
$tmp_col = $field['Field']; $tmp_col = $field['Field'];
if (!empty($field['Comment'])) { if (!empty($field['Comment'])) {
$native_comment[$tmp_col] = $field['Comment']; $native_comment[$tmp_col] = $field['Comment'];
@@ -520,9 +520,9 @@ function PMA_getComments($db, $table = '') {
$comment[$col] = $native_comment[$col]; $comment[$col] = $native_comment[$col];
} else { } else {
// no native comment, so migrate pmadb-style to native // no native comment, so migrate pmadb-style to native
PMA_setComment($db, $table, $col, $comment[$col],'','native'); PMA_setComment($db, $table, $col, $comment[$col], '', 'native');
// and erase the pmadb-style comment // and erase the pmadb-style comment
PMA_setComment($db, $table, $col, '','','pmadb'); PMA_setComment($db, $table, $col, '', '', 'pmadb');
} }
} }
} }
@@ -583,7 +583,7 @@ function PMA_setComment($db, $table, $col, $comment, $removekey = '', $mode='aut
if ($mode == 'native' && isset($table) && strlen($table)) { if ($mode == 'native' && isset($table) && strlen($table)) {
$query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHANGE ' $query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHANGE '
. PMA_generateAlterTable($col, $col, '', '', '', '', FALSE, '', FALSE, '', $comment, '', ''); . PMA_generateAlterTable($col, $col, '', '', '', '', FALSE, '', FALSE, '', $comment, '', '');
PMA_DBI_try_query($query, NULL, PMA_DBI_QUERY_STORE); PMA_DBI_try_query($query, null, PMA_DBI_QUERY_STORE);
return TRUE; return TRUE;
} }
@@ -636,7 +636,7 @@ function PMA_setComment($db, $table, $col, $comment, $removekey = '', $mode='aut
AND ' . $cols['table_name'] . ' = \'' . PMA_sqlAddslashes($table) . '\' AND ' . $cols['table_name'] . ' = \'' . PMA_sqlAddslashes($table) . '\'
AND ' . $cols['column_name'] . ' = \'' . PMA_sqlAddslashes($col) . '\''; AND ' . $cols['column_name'] . ' = \'' . PMA_sqlAddslashes($col) . '\'';
} }
} else if (strlen($comment) > 0) { } elseif (strlen($comment) > 0) {
$upd_query = ' $upd_query = '
INSERT INTO INSERT INTO
' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . ' ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
@@ -879,18 +879,18 @@ function PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, $ma
// put the dropdown sections in correct order // put the dropdown sections in correct order
$c = count($cfg['ForeignKeyDropdownOrder']); $c = count($cfg['ForeignKeyDropdownOrder']);
if($c == 2) { if ($c == 2) {
$top = $reloptions[$cfg['ForeignKeyDropdownOrder'][0]]; $top = $reloptions[$cfg['ForeignKeyDropdownOrder'][0]];
$bot = $reloptions[$cfg['ForeignKeyDropdownOrder'][1]]; $bot = $reloptions[$cfg['ForeignKeyDropdownOrder'][1]];
} elseif($c == 1) { } elseif ($c == 1) {
$bot = $reloptions[$cfg['ForeignKeyDropdownOrder'][0]]; $bot = $reloptions[$cfg['ForeignKeyDropdownOrder'][0]];
$top = NULL; $top = null;
} else { } else {
$top = $reloptions['id-content']; $top = $reloptions['id-content'];
$bot = $reloptions['content-id']; $bot = $reloptions['content-id'];
} }
$str_bot = implode('', $bot); $str_bot = implode('', $bot);
if($top !== NULL) { if ($top !== null) {
$str_top = implode('', $top); $str_top = implode('', $top);
$top_count = count($top); $top_count = count($top);
if ($max == -1 || $top_count < $max) { if ($max == -1 || $top_count < $max) {

View File

@@ -23,10 +23,11 @@
* @uses explode() * @uses explode()
* @return bool success if valid lang is found, otherwise false * @return bool success if valid lang is found, otherwise false
*/ */
function PMA_langCheck() { function PMA_langCheck()
{
// check forced language // check forced language
if ( ! empty( $GLOBALS['cfg']['Lang'] ) ) { if (! empty($GLOBALS['cfg']['Lang'])) {
if ( PMA_langSet( $GLOBALS['cfg']['Lang'] ) ) { if (PMA_langSet($GLOBALS['cfg']['Lang'])) {
return true; return true;
} else { } else {
$GLOBALS['lang_failed_cfg'] = $GLOBALS['cfg']['Lang']; $GLOBALS['lang_failed_cfg'] = $GLOBALS['cfg']['Lang'];
@@ -34,8 +35,8 @@ function PMA_langCheck() {
} }
// check user requested language // check user requested language
if ( ! empty( $_REQUEST['lang'] ) ) { if (! empty($_REQUEST['lang'])) {
if ( PMA_langSet( $_REQUEST['lang'] ) ) { if (PMA_langSet($_REQUEST['lang'])) {
return true; return true;
} else { } else {
$GLOBALS['lang_failed_request'] = $_REQUEST['lang']; $GLOBALS['lang_failed_request'] = $_REQUEST['lang'];
@@ -43,8 +44,8 @@ function PMA_langCheck() {
} }
// check previous set language // check previous set language
if ( ! empty( $_COOKIE['pma_lang'] ) ) { if (! empty($_COOKIE['pma_lang'])) {
if ( PMA_langSet( $_COOKIE['pma_lang'] ) ) { if (PMA_langSet($_COOKIE['pma_lang'])) {
return true; return true;
} else { } else {
$GLOBALS['lang_failed_cookie'] = $_COOKIE['pma_lang']; $GLOBALS['lang_failed_cookie'] = $_COOKIE['pma_lang'];
@@ -52,21 +53,21 @@ function PMA_langCheck() {
} }
// try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE variable // try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE variable
if ( ! empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) { if (! empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
foreach ( explode( ',', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) as $lang ) { foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $lang) {
if ( PMA_langDetect( $lang, 1 ) ) { if (PMA_langDetect($lang, 1)) {
return true; return true;
} }
} }
} }
// try to findout user's language by checking its HTTP_USER_AGENT variable // try to findout user's language by checking its HTTP_USER_AGENT variable
if ( PMA_langDetect($_SERVER['HTTP_USER_AGENT'], 2) ) { if (PMA_langDetect($_SERVER['HTTP_USER_AGENT'], 2)) {
return true; return true;
} }
// Didn't catch any valid lang : we use the default settings // Didn't catch any valid lang : we use the default settings
if ( PMA_langSet($GLOBALS['cfg']['DefaultLang']) ) { if (PMA_langSet($GLOBALS['cfg']['DefaultLang'])) {
return true; return true;
} }
@@ -82,8 +83,9 @@ function PMA_langCheck() {
* @param string $lang language to set * @param string $lang language to set
* @return bool success * @return bool success
*/ */
function PMA_langSet( &$lang ) { function PMA_langSet(&$lang)
if ( empty( $lang ) || empty( $GLOBALS['available_languages'][$lang] ) ) { {
if (empty($lang) || empty($GLOBALS['available_languages'][$lang])) {
return false; return false;
} }
$GLOBALS['lang'] = $lang; $GLOBALS['lang'] = $lang;
@@ -103,9 +105,14 @@ function PMA_langSet( &$lang ) {
* *
* @access private * @access private
*/ */
function PMA_langDetect( &$str, $envType ) { function PMA_langDetect(&$str, $envType)
if ( empty( $str ) ) return false; {
if ( empty( $GLOBALS['available_languages'] ) ) return false; if (empty($str)) {
return false;
}
if (empty($GLOBALS['available_languages'])) {
return false;
}
foreach ($GLOBALS['available_languages'] as $lang => $value) { foreach ($GLOBALS['available_languages'] as $lang => $value) {
// $envType = 1 for the 'HTTP_ACCEPT_LANGUAGE' environment variable, // $envType = 1 for the 'HTTP_ACCEPT_LANGUAGE' environment variable,
@@ -116,7 +123,7 @@ function PMA_langDetect( &$str, $envType ) {
} }
if (($envType == 1 && eregi('^(' . $expr . ')(;q=[0-9]\\.[0-9])?$', $str)) if (($envType == 1 && eregi('^(' . $expr . ')(;q=[0-9]\\.[0-9])?$', $str))
|| ($envType == 2 && eregi('(\(|\[|;[[:space:]])(' . $expr . ')(;|\]|\))', $str))) { || ($envType == 2 && eregi('(\(|\[|;[[:space:]])(' . $expr . ')(;|\]|\))', $str))) {
if ( PMA_langSet( $lang ) ) { if (PMA_langSet($lang)) {
return true; return true;
} }
} }
@@ -133,14 +140,14 @@ $lang_path = './lang/';
/** /**
* first check for lang dir exists * first check for lang dir exists
*/ */
if ( ! is_dir( $lang_path ) ) { if (! is_dir($lang_path)) {
// language directory not found // language directory not found
trigger_error( 'phpMyAdmin-ERROR: path not found: ' trigger_error('phpMyAdmin-ERROR: path not found: '
. $lang_path . ', check your language directory.', . $lang_path . ', check your language directory.',
E_USER_WARNING ); E_USER_WARNING);
// and tell the user // and tell the user
PMA_sendHeaderLocation( 'error.php?error=' PMA_sendHeaderLocation('error.php?error='
. urlencode( 'path to languages is invalid: ' . $lang_path ) ); . urlencode( 'path to languages is invalid: ' . $lang_path));
// stop execution // stop execution
exit; exit;
} }
@@ -318,9 +325,9 @@ $available_languages = array(
); );
// Language filtering support // Language filtering support
if ( ! empty( $GLOBALS['cfg']['FilterLanguages'] ) ) { if (! empty($GLOBALS['cfg']['FilterLanguages'])) {
$new_lang = array(); $new_lang = array();
foreach($available_languages as $key => $val) { foreach ($available_languages as $key => $val) {
if (preg_match('@' . $GLOBALS['cfg']['FilterLanguages'] . '@', $key)) { if (preg_match('@' . $GLOBALS['cfg']['FilterLanguages'] . '@', $key)) {
$new_lang[$key] = $val; $new_lang[$key] = $val;
} }
@@ -328,18 +335,18 @@ if ( ! empty( $GLOBALS['cfg']['FilterLanguages'] ) ) {
if (count($new_lang) > 0) { if (count($new_lang) > 0) {
$available_languages = $new_lang; $available_languages = $new_lang;
} }
unset( $key, $val, $new_lang ); unset($key, $val, $new_lang);
} }
/** /**
* check for language files * check for language files
*/ */
foreach ( $available_languages as $each_lang_key => $each_lang ) { foreach ($available_languages as $each_lang_key => $each_lang) {
if ( ! file_exists( $lang_path . $each_lang[1] . '.inc.php' ) ) { if (! file_exists($lang_path . $each_lang[1] . '.inc.php')) {
unset( $available_languages[$each_lang_key] ); unset($available_languages[$each_lang_key]);
} }
} }
unset( $each_lang_key, $each_lang ); unset($each_lang_key, $each_lang);
// MySQL charsets map // MySQL charsets map
$mysql_charset_map = array( $mysql_charset_map = array(
@@ -373,7 +380,7 @@ $mysql_charset_map = array(
*/ */
// Checks whether charset recoding should be allowed or not // Checks whether charset recoding should be allowed or not
$allow_recoding = FALSE; // Default fallback value $allow_recoding = FALSE; // Default fallback value
if ( empty($convcharset) ) { if (empty($convcharset)) {
if (isset($_COOKIE['pma_charset'])) { if (isset($_COOKIE['pma_charset'])) {
$convcharset = $_COOKIE['pma_charset']; $convcharset = $_COOKIE['pma_charset'];
} else { } else {
@@ -381,36 +388,36 @@ if ( empty($convcharset) ) {
} }
} }
if ( ! PMA_langCheck() ) { if (! PMA_langCheck()) {
// fallback language // fallback language
$fall_back_lang = 'en-utf-8'; $line = __LINE__; $fall_back_lang = 'en-utf-8'; $line = __LINE__;
if ( ! PMA_langSet( $fall_back_lang ) ) { if (! PMA_langSet($fall_back_lang)) {
trigger_error( 'phpMyAdmin-ERROR: invalid lang code: ' trigger_error('phpMyAdmin-ERROR: invalid lang code: '
. __FILE__ . '#' . $line . ', check hard coded fall back language.', . __FILE__ . '#' . $line . ', check hard coded fall back language.',
E_USER_WARNING ); E_USER_WARNING);
// stop execution // stop execution
// and tell the user that his choosen language is invalid // and tell the user that his choosen language is invalid
PMA_sendHeaderLocation( 'error.php?error=' PMA_sendHeaderLocation('error.php?error='
. urlencode( 'Could not load any language, please check your language settings and folder' ) ); . urlencode('Could not load any language, please check your language settings and folder'));
exit; exit;
} }
} }
// Defines the associated filename and load the translation // Defines the associated filename and load the translation
$lang_file = $lang_path . $available_languages[$GLOBALS['lang']][1] . '.inc.php'; $lang_file = $lang_path . $available_languages[$GLOBALS['lang']][1] . '.inc.php';
require_once( $lang_file ); require_once($lang_file);
// now, that we have loaded the language strings we can send the errors // now, that we have loaded the language strings we can send the errors
if ( $lang_failed_cfg ) { if ($lang_failed_cfg) {
$GLOBALS['PMA_errors'][] = sprintf( $strLanguageUnknown, $lang_failed_cfg ); $GLOBALS['PMA_errors'][] = sprintf($strLanguageUnknown, $lang_failed_cfg);
} }
if ( $lang_failed_cookie ) { if ($lang_failed_cookie) {
$GLOBALS['PMA_errors'][] = sprintf( $strLanguageUnknown, $lang_failed_cookie ); $GLOBALS['PMA_errors'][] = sprintf($strLanguageUnknown, $lang_failed_cookie);
} }
if ( $lang_failed_request ) { if ($lang_failed_request) {
$GLOBALS['PMA_errors'][] = sprintf( $strLanguageUnknown, $lang_failed_request ); $GLOBALS['PMA_errors'][] = sprintf($strLanguageUnknown, $lang_failed_request);
} }
unset( $lang_file, $lang_path, $strLanguageFileNotFound, $line, $fall_back_lang, unset($lang_file, $lang_path, $strLanguageFileNotFound, $line, $fall_back_lang,
$lang_failed_cfg, $lang_failed_cookie, $lang_failed_request, $strLanguageUnknown ); $lang_failed_cfg, $lang_failed_cookie, $lang_failed_request, $strLanguageUnknown);
?> ?>

View File

@@ -56,7 +56,7 @@ function PMA_select_server($form, $left) {
if ($list){ if ($list){
if ($selected && !$left) { if ($selected && !$left) {
echo '&raquo; <b>' . htmlspecialchars($label) . '</b><br />'; echo '&raquo; <b>' . htmlspecialchars($label) . '</b><br />';
}else{ } else {
echo '&raquo; <a class="item" href="index.php?server=' . $key . '&amp;lang=' . $lang . '&amp;convcharset=' . $convcharset . '" target="_top">' . htmlspecialchars($label) . '</a><br />'; echo '&raquo; <a class="item" href="index.php?server=' . $key . '&amp;lang=' . $lang . '&amp;convcharset=' . $convcharset . '" target="_top">' . htmlspecialchars($label) . '</a><br />';
} }
} else { } else {

View File

@@ -51,7 +51,7 @@ if ($is_superuser) {
} }
$has_binlogs = FALSE; $has_binlogs = FALSE;
$binlogs = PMA_DBI_try_query('SHOW MASTER LOGS', NULL, PMA_DBI_QUERY_STORE); $binlogs = PMA_DBI_try_query('SHOW MASTER LOGS', null, PMA_DBI_QUERY_STORE);
if ($binlogs) { if ($binlogs) {
if (PMA_DBI_num_rows($binlogs) > 0) { if (PMA_DBI_num_rows($binlogs) > 0) {
$binary_logs = array(); $binary_logs = array();

View File

@@ -24,52 +24,50 @@ if (!@function_exists('session_name')) {
require_once('./libraries/select_lang.lib.php'); require_once('./libraries/select_lang.lib.php');
// Displays the error message // Displays the error message
// (do not use &amp; for parameters sent by header) // (do not use &amp; for parameters sent by header)
header( 'Location: error.php' header('Location: error.php'
. '?lang=' . urlencode( $available_languages[$lang][2] ) . '?lang=' . urlencode($available_languages[$lang][2])
. '&char=' . urlencode( $charset ) . '&char=' . urlencode($charset)
. '&dir=' . urlencode( $text_dir ) . '&dir=' . urlencode($text_dir)
. '&type=' . urlencode( $strError ) . '&type=' . urlencode($strError)
. '&error=' . urlencode( . '&error=' . urlencode(sprintf($strCantLoad, 'session')));
sprintf($strCantLoad, 'session'))
);
exit(); exit();
} }
// session cookie settings // session cookie settings
session_set_cookie_params( 0, PMA_Config::getCookiePath(), session_set_cookie_params(0, PMA_Config::getCookiePath(),
'', PMA_Config::isHttps() ); '', PMA_Config::isHttps());
// disable starting of sessions before all settings are done // disable starting of sessions before all settings are done
ini_set( 'session.auto_start', false ); ini_set('session.auto_start', false);
// cookies are safer // cookies are safer
ini_set( 'session.use_cookies', true ); ini_set('session.use_cookies', true);
// but not all user allow cookies // but not all user allow cookies
ini_set( 'session.use_only_cookies', false ); ini_set('session.use_only_cookies', false);
ini_set( 'session.use_trans_sid', true ); ini_set('session.use_trans_sid', true);
ini_set( 'url_rewriter.tags', ini_set('url_rewriter.tags',
'a=href,frame=src,input=src,form=fakeentry,fieldset=' ); 'a=href,frame=src,input=src,form=fakeentry,fieldset=');
ini_set( 'arg_separator.output' , '&amp;' ); ini_set('arg_separator.output', '&amp;');
// delete session/cookies when browser is closed // delete session/cookies when browser is closed
ini_set( 'session.cookie_lifetime', 0 ); ini_set('session.cookie_lifetime', 0);
// warn but dont work with bug // warn but dont work with bug
ini_set( 'session.bug_compat_42', false ); ini_set('session.bug_compat_42', false);
ini_set( 'session.bug_compat_warn', true ); ini_set('session.bug_compat_warn', true);
// use more secure session ids (with PHP 5) // use more secure session ids (with PHP 5)
if ( version_compare( PHP_VERSION, '5.0.0', 'ge' ) if (version_compare( PHP_VERSION, '5.0.0', 'ge')
&& substr( PHP_OS, 0 ,3 ) != 'WIN' ) { && substr(PHP_OS, 0, 3) != 'WIN') {
ini_set( 'session.hash_function', 1 ); ini_set('session.hash_function', 1);
ini_set( 'session.hash_bits_per_character', 6 ); ini_set('session.hash_bits_per_character', 6);
} }
// start the session // start the session
// on some servers (for example, sourceforge.net), we get a permission error // on some servers (for example, sourceforge.net), we get a permission error
// on the session data directory, so I add some "@" // on the session data directory, so I add some "@"
@session_name( 'phpMyAdmin' ); @session_name('phpMyAdmin');
@session_start(); @session_start();
/** /**
@@ -82,12 +80,13 @@ if ( version_compare( PHP_VERSION, '5.0.0', 'ge' )
* @uses strip_tags() to prevent XSS attacks in SID * @uses strip_tags() to prevent XSS attacks in SID
* @uses function_exists() for session_regenerate_id() * @uses function_exists() for session_regenerate_id()
*/ */
function PMA_secureSession() { function PMA_secureSession()
{
// prevent session fixation and XSS // prevent session fixation and XSS
if ( function_exists( 'session_regenerate_id' ) ) { if (function_exists('session_regenerate_id')) {
session_regenerate_id( true ); session_regenerate_id(true);
} else { } else {
session_id( strip_tags( session_id() ) ); session_id(strip_tags(session_id()));
} }
} }
?> ?>

View File

@@ -58,9 +58,10 @@ require_once('./libraries/bookmark.lib.php'); // used for file listing
* what part to display * what part to display
* false if not inside querywindow * false if not inside querywindow
*/ */
function PMA_sqlQueryForm( $query = true, $display_tab = false ) { function PMA_sqlQueryForm($query = true, $display_tab = false)
{
// check tab to display if inside querywindow // check tab to display if inside querywindow
if ( ! $display_tab ) { if (! $display_tab) {
$display_tab = 'full'; $display_tab = 'full';
$is_querywindow = false; $is_querywindow = false;
} else { } else {
@@ -68,12 +69,12 @@ function PMA_sqlQueryForm( $query = true, $display_tab = false ) {
} }
// query to show // query to show
if ( true === $query ) { if (true === $query) {
$query = empty( $GLOBALS['sql_query'] ) ? '' : $GLOBALS['sql_query']; $query = empty($GLOBALS['sql_query']) ? '' : $GLOBALS['sql_query'];
} }
// set enctype to multipart for file uploads // set enctype to multipart for file uploads
if ( $GLOBALS['is_upload'] ) { if ($GLOBALS['is_upload']) {
$enctype = ' enctype="multipart/form-data"'; $enctype = ' enctype="multipart/form-data"';
} else { } else {
$enctype = ''; $enctype = '';
@@ -81,25 +82,25 @@ function PMA_sqlQueryForm( $query = true, $display_tab = false ) {
$table = ''; $table = '';
$db = ''; $db = '';
if ( ! isset( $GLOBALS['db'] ) || ! strlen($GLOBALS['db']) ) { if (! isset($GLOBALS['db']) || ! strlen($GLOBALS['db'])) {
// prepare for server related // prepare for server related
$goto = empty( $GLOBALS['goto'] ) ? $goto = empty($GLOBALS['goto']) ?
'server_sql.php' : $GLOBALS['goto']; 'server_sql.php' : $GLOBALS['goto'];
} elseif ( ! isset( $GLOBALS['table'] ) || ! strlen($GLOBALS['table']) ) { } elseif (! isset($GLOBALS['table']) || ! strlen($GLOBALS['table'])) {
// prepare for db related // prepare for db related
$db = $GLOBALS['db']; $db = $GLOBALS['db'];
$goto = empty( $GLOBALS['goto'] ) ? $goto = empty($GLOBALS['goto']) ?
'db_details.php' : $GLOBALS['goto']; 'db_details.php' : $GLOBALS['goto'];
} else { } else {
$table = $GLOBALS['table']; $table = $GLOBALS['table'];
$db = $GLOBALS['db']; $db = $GLOBALS['db'];
$goto = empty( $GLOBALS['goto'] ) ? $goto = empty($GLOBALS['goto']) ?
'tbl_properties.php' : $GLOBALS['goto']; 'tbl_properties.php' : $GLOBALS['goto'];
} }
// start output // start output
if ( $is_querywindow ) { if ($is_querywindow) {
?> ?>
<form method="post" id="sqlqueryform" target="frame_content" <form method="post" id="sqlqueryform" target="frame_content"
action="import.php"<?php echo $enctype; ?> name="sqlform" action="import.php"<?php echo $enctype; ?> name="sqlform"
@@ -113,45 +114,45 @@ function PMA_sqlQueryForm( $query = true, $display_tab = false ) {
.' onsubmit="return checkSqlQuery(this)" name="sqlform">' . "\n"; .' onsubmit="return checkSqlQuery(this)" name="sqlform">' . "\n";
} }
if ( $is_querywindow ) { if ($is_querywindow) {
echo '<input type="hidden" name="focus_querywindow" value="true" />' echo '<input type="hidden" name="focus_querywindow" value="true" />'
."\n"; ."\n";
if ( $display_tab != 'sql' && $display_tab != 'full' ) { if ($display_tab != 'sql' && $display_tab != 'full') {
echo '<input type="hidden" name="sql_query" value="" />' . "\n"; echo '<input type="hidden" name="sql_query" value="" />' . "\n";
echo '<input type="hidden" name="show_query" value="1" />' . "\n"; echo '<input type="hidden" name="show_query" value="1" />' . "\n";
} }
} }
echo '<input type="hidden" name="is_js_confirmed" value="0" />' . "\n" echo '<input type="hidden" name="is_js_confirmed" value="0" />' . "\n"
.PMA_generate_common_hidden_inputs( $db, $table ) . "\n" .PMA_generate_common_hidden_inputs($db, $table) . "\n"
.'<input type="hidden" name="pos" value="0" />' . "\n" .'<input type="hidden" name="pos" value="0" />' . "\n"
.'<input type="hidden" name="goto" value="' .'<input type="hidden" name="goto" value="'
.htmlspecialchars( $goto ) . '" />' . "\n" .htmlspecialchars($goto) . '" />' . "\n"
.'<input type="hidden" name="zero_rows" value="' .'<input type="hidden" name="zero_rows" value="'
. htmlspecialchars( $GLOBALS['strSuccess'] ) . '" />' . "\n" . htmlspecialchars($GLOBALS['strSuccess']) . '" />' . "\n"
.'<input type="hidden" name="prev_sql_query" value="' .'<input type="hidden" name="prev_sql_query" value="'
. htmlspecialchars( $query ) . '" />' . "\n"; . htmlspecialchars($query) . '" />' . "\n";
// display querybox // display querybox
if ( $display_tab === 'full' || $display_tab === 'sql' ) { if ($display_tab === 'full' || $display_tab === 'sql') {
PMA_sqlQueryFormInsert( $query, $is_querywindow ); PMA_sqlQueryFormInsert($query, $is_querywindow);
} }
// display uploads // display uploads
if ( $display_tab === 'files' && $GLOBALS['is_upload'] ) { if ($display_tab === 'files' && $GLOBALS['is_upload']) {
PMA_sqlQueryFormUpload(); PMA_sqlQueryFormUpload();
} }
// Bookmark Support // Bookmark Support
if ( $display_tab === 'full' || $display_tab === 'history' ) { if ($display_tab === 'full' || $display_tab === 'history') {
if ( ! empty( $GLOBALS['cfg']['Bookmark'] ) if (! empty( $GLOBALS['cfg']['Bookmark'])
&& $GLOBALS['cfg']['Bookmark']['db'] && $GLOBALS['cfg']['Bookmark']['db']
&& $GLOBALS['cfg']['Bookmark']['table'] ) { && $GLOBALS['cfg']['Bookmark']['table']) {
PMA_sqlQueryFormBookmark(); PMA_sqlQueryFormBookmark();
} }
} }
// Encoding setting form appended by Y.Kawada // Encoding setting form appended by Y.Kawada
if ( function_exists('PMA_set_enc_form') ) { if (function_exists('PMA_set_enc_form')) {
echo PMA_set_enc_form(' '); echo PMA_set_enc_form(' ');
} }
@@ -177,17 +178,18 @@ function PMA_sqlQueryForm( $query = true, $display_tab = false ) {
* @param string $query query to display in the textarea * @param string $query query to display in the textarea
* @param boolean $is_querywindow if inside querywindow or not * @param boolean $is_querywindow if inside querywindow or not
*/ */
function PMA_sqlQueryFormInsert( $query = '', $is_querywindow = false ) { function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false)
{
// enable auto select text in textarea // enable auto select text in textarea
if ( $GLOBALS['cfg']['TextareaAutoSelect'] ) { if ($GLOBALS['cfg']['TextareaAutoSelect']) {
$auto_sel = ' onfocus="selectContent( this, sql_box_locked, true )"'; $auto_sel = ' onfocus="selectContent( this, sql_box_locked, true )"';
} else { } else {
$auto_sel = ''; $auto_sel = '';
} }
// enable locking if inside query window // enable locking if inside query window
if ( $is_querywindow ) { if ($is_querywindow) {
$locking = ' onkeypress="document.sqlform.elements[\'LockFromUpdate\'].' $locking = ' onkeypress="document.sqlform.elements[\'LockFromUpdate\'].'
.'checked = true;"'; .'checked = true;"';
} else { } else {
@@ -197,29 +199,29 @@ function PMA_sqlQueryFormInsert( $query = '', $is_querywindow = false ) {
$table = ''; $table = '';
$db = ''; $db = '';
$fields_list = array(); $fields_list = array();
if ( ! isset( $GLOBALS['db'] ) || ! strlen($GLOBALS['db']) ) { if (! isset($GLOBALS['db']) || ! strlen($GLOBALS['db'])) {
// prepare for server related // prepare for server related
$legend = sprintf( $GLOBALS['strRunSQLQueryOnServer'], $legend = sprintf($GLOBALS['strRunSQLQueryOnServer'],
htmlspecialchars( htmlspecialchars(
$GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host'] ) ); $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host']));
} elseif ( ! isset( $GLOBALS['table'] ) || ! strlen($GLOBALS['table']) ) { } elseif (! isset($GLOBALS['table']) || ! strlen($GLOBALS['table'])) {
// prepare for db related // prepare for db related
$db = $GLOBALS['db']; $db = $GLOBALS['db'];
// if you want navigation: // if you want navigation:
$strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] $strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase']
. '?' . PMA_generate_common_url( $db ) . '"'; . '?' . PMA_generate_common_url($db) . '"';
if ( $is_querywindow ) { if ($is_querywindow) {
$strDBLink .= ' target="_self"' $strDBLink .= ' target="_self"'
. ' onclick="this.target=window.opener.frames[1].name"'; . ' onclick="this.target=window.opener.frames[1].name"';
} }
$strDBLink .= '>' $strDBLink .= '>'
. htmlspecialchars( $db ) . '</a>'; . htmlspecialchars($db) . '</a>';
// else use // else use
// $strDBLink = htmlspecialchars( $db ); // $strDBLink = htmlspecialchars($db);
$legend = sprintf( $GLOBALS['strRunSQLQuery'], $strDBLink ); $legend = sprintf($GLOBALS['strRunSQLQuery'], $strDBLink);
if ( empty( $query ) ) { if (empty($query)) {
$query = str_replace( '%d', $query = str_replace('%d',
PMA_backquote( $db ), $GLOBALS['cfg']['DefaultQueryDatabase'] ); PMA_backquote($db), $GLOBALS['cfg']['DefaultQueryDatabase']);
} }
} else { } else {
$table = $GLOBALS['table']; $table = $GLOBALS['table'];
@@ -228,37 +230,37 @@ function PMA_sqlQueryFormInsert( $query = '', $is_querywindow = false ) {
// we do a try_query here, because we could be in the query window, // we do a try_query here, because we could be in the query window,
// trying to synchonize and the table has not yet been created // trying to synchonize and the table has not yet been created
$fields_list = PMA_DBI_fetch_result( $fields_list = PMA_DBI_fetch_result(
'SHOW FULL COLUMNS FROM ' . PMA_backquote( $db ) 'SHOW FULL COLUMNS FROM ' . PMA_backquote($db)
. '.' . PMA_backquote( $GLOBALS['table'] )); . '.' . PMA_backquote($GLOBALS['table']));
$strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] $strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase']
. '?' . PMA_generate_common_url( $db ) . '"'; . '?' . PMA_generate_common_url($db) . '"';
if ( $is_querywindow ) { if ($is_querywindow) {
$strDBLink .= ' target="_self"' $strDBLink .= ' target="_self"'
. ' onclick="this.target=window.opener.frames[1].name"'; . ' onclick="this.target=window.opener.frames[1].name"';
} }
$strDBLink .= '>' $strDBLink .= '>'
. htmlspecialchars( $db ) . '</a>'; . htmlspecialchars($db) . '</a>';
// else use // else use
// $strDBLink = htmlspecialchars( $db ); // $strDBLink = htmlspecialchars($db);
$legend = sprintf( $GLOBALS['strRunSQLQuery'], $strDBLink ); $legend = sprintf($GLOBALS['strRunSQLQuery'], $strDBLink);
if ( empty( $query ) && count( $fields_list ) ) { if (empty($query) && count($fields_list)) {
$field_names = array(); $field_names = array();
foreach ( $fields_list as $field ) { foreach ($fields_list as $field) {
$field_names[] = PMA_backquote($field['Field']); $field_names[] = PMA_backquote($field['Field']);
} }
$query = $query =
str_replace( '%d', PMA_backquote( $db ), str_replace('%d', PMA_backquote($db),
str_replace( '%t', PMA_backquote( $table ), str_replace('%t', PMA_backquote($table),
str_replace( '%f', str_replace('%f',
implode( ', ', $field_names ), implode(', ', $field_names ),
$GLOBALS['cfg']['DefaultQueryTable'] ) ) ); $GLOBALS['cfg']['DefaultQueryTable'])));
unset($field_names); unset($field_names);
} }
} }
$legend .= ': ' . PMA_showMySQLDocu( 'SQL-Syntax', 'SELECT' ); $legend .= ': ' . PMA_showMySQLDocu('SQL-Syntax', 'SELECT');
if ( count( $fields_list ) ) { if (count($fields_list)) {
$sqlquerycontainer_id = 'sqlquerycontainer'; $sqlquerycontainer_id = 'sqlquerycontainer';
} else { } else {
$sqlquerycontainer_id = 'sqlquerycontainerfull'; $sqlquerycontainer_id = 'sqlquerycontainerfull';
@@ -277,17 +279,17 @@ function PMA_sqlQueryFormInsert( $query = '', $is_querywindow = false ) {
.$auto_sel . $locking . '>' . $query . '</textarea>' . "\n"; .$auto_sel . $locking . '>' . $query . '</textarea>' . "\n";
echo '</div>' . "\n"; echo '</div>' . "\n";
if ( count( $fields_list ) ) { if (count($fields_list)) {
echo '<div id="tablefieldscontainer">' . "\n" echo '<div id="tablefieldscontainer">' . "\n"
.'<label>' . $GLOBALS['strFields'] . '</label>' . "\n" .'<label>' . $GLOBALS['strFields'] . '</label>' . "\n"
.'<select id="tablefields" name="dummy" ' .'<select id="tablefields" name="dummy" '
.'size="' . ($GLOBALS['cfg']['TextareaRows'] - 2) . '" ' .'size="' . ($GLOBALS['cfg']['TextareaRows'] - 2) . '" '
.'multiple="multiple" ondblclick="insertValueQuery()">' . "\n"; .'multiple="multiple" ondblclick="insertValueQuery()">' . "\n";
foreach ( $fields_list as $field ) { foreach ($fields_list as $field) {
echo '<option value="' echo '<option value="'
.PMA_backquote( htmlspecialchars( $field['Field'] ) ) . '"'; .PMA_backquote(htmlspecialchars($field['Field'])) . '"';
if ( isset( $field['Field'] ) && strlen($field['Field']) && isset($field['Comment']) ) { if (isset($field['Field']) && strlen($field['Field']) && isset($field['Comment'])) {
echo ' title="' . htmlspecialchars( $field['Comment'] ) . '"'; echo ' title="' . htmlspecialchars($field['Comment']) . '"';
} }
echo '>' . htmlspecialchars( $field['Field'] ) . '</option>' . "\n"; echo '>' . htmlspecialchars( $field['Field'] ) . '</option>' . "\n";
} }
@@ -309,9 +311,9 @@ function PMA_sqlQueryFormInsert( $query = '', $is_querywindow = false ) {
echo '<div class="clearfloat"></div>' . "\n"; echo '<div class="clearfloat"></div>' . "\n";
echo '</div>' . "\n"; echo '</div>' . "\n";
if ( ! empty( $GLOBALS['cfg']['Bookmark'] ) if (! empty($GLOBALS['cfg']['Bookmark'])
&& $GLOBALS['cfg']['Bookmark']['db'] && $GLOBALS['cfg']['Bookmark']['db']
&& $GLOBALS['cfg']['Bookmark']['table'] ) { && $GLOBALS['cfg']['Bookmark']['table']) {
?> ?>
<div id="bookmarkoptions"> <div id="bookmarkoptions">
<div class="formelement"> <div class="formelement">
@@ -341,7 +343,7 @@ function PMA_sqlQueryFormInsert( $query = '', $is_querywindow = false ) {
echo '<fieldset id="queryboxfooter" class="tblFooters">' . "\n"; echo '<fieldset id="queryboxfooter" class="tblFooters">' . "\n";
echo '<div class="formelement">' . "\n"; echo '<div class="formelement">' . "\n";
if ( $is_querywindow ) { if ($is_querywindow) {
?> ?>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
//<![CDATA[ //<![CDATA[
@@ -382,9 +384,10 @@ function PMA_sqlQueryFormInsert( $query = '', $is_querywindow = false ) {
* @uses count() * @uses count()
* @uses htmlspecialchars() * @uses htmlspecialchars()
*/ */
function PMA_sqlQueryFormBookmark() { function PMA_sqlQueryFormBookmark()
{
$bookmark_list = PMA_listBookmarks(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', $GLOBALS['cfg']['Bookmark'] ); $bookmark_list = PMA_listBookmarks(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', $GLOBALS['cfg']['Bookmark'] );
if ( ! $bookmark_list || count( $bookmark_list ) < 1 ) { if (! $bookmark_list || count($bookmark_list) < 1) {
return; return;
} }
@@ -394,16 +397,16 @@ function PMA_sqlQueryFormBookmark() {
echo '<div class="formelement">'; echo '<div class="formelement">';
echo '<select name="id_bookmark">' . "\n"; echo '<select name="id_bookmark">' . "\n";
echo '<option value=""></option>' . "\n"; echo '<option value=""></option>' . "\n";
foreach ( $bookmark_list as $key => $value ) { foreach ($bookmark_list as $key => $value) {
echo '<option value="' . htmlspecialchars( $key ) . '">' echo '<option value="' . htmlspecialchars($key) . '">'
.htmlspecialchars( $value ) . '</option>' . "\n"; .htmlspecialchars($value) . '</option>' . "\n";
} }
// &nbsp; is required for correct display with styles/line height // &nbsp; is required for correct display with styles/line height
echo '</select>&nbsp;' . "\n"; echo '</select>&nbsp;' . "\n";
echo '</div>' . "\n"; echo '</div>' . "\n";
echo '<div class="formelement">' . "\n"; echo '<div class="formelement">' . "\n";
echo $GLOBALS['strVar']; echo $GLOBALS['strVar'];
if ( $GLOBALS['cfg']['ReplaceHelpImg'] ) { if ($GLOBALS['cfg']['ReplaceHelpImg']) {
echo ' <a href="./Documentation.html#faqbookmark"' echo ' <a href="./Documentation.html#faqbookmark"'
.' target="documentation">' .' target="documentation">'
.'<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_help.png"' .'<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_help.png"'
@@ -470,7 +473,7 @@ function PMA_sqlQueryFormBookmark() {
* @uses PMA_CSDROPDOWN_CHARSET * @uses PMA_CSDROPDOWN_CHARSET
* @uses empty() * @uses empty()
*/ */
function PMA_sqlQueryFormUpload() { function PMA_sqlQueryFormUpload(){
$errors = array (); $errors = array ();
$matcher = '@\.sql(\.(' . PMA_supportedDecompressions() . '))?$@'; // we allow only SQL here $matcher = '@\.sql(\.(' . PMA_supportedDecompressions() . '))?$@'; // we allow only SQL here
@@ -487,9 +490,9 @@ function PMA_sqlQueryFormUpload() {
echo $GLOBALS['strLocationTextfile'] . '</legend>'; echo $GLOBALS['strLocationTextfile'] . '</legend>';
echo '<div class="formelement">'; echo '<div class="formelement">';
echo '<input type="file" name="sql_file" class="textfield" /> '; echo '<input type="file" name="sql_file" class="textfield" /> ';
echo PMA_displayMaximumUploadSize( $GLOBALS['max_upload_size'] ); echo PMA_displayMaximumUploadSize($GLOBALS['max_upload_size']);
// some browsers should respect this :) // some browsers should respect this :)
echo PMA_generateHiddenMaxFileSize( $GLOBALS['max_upload_size'] ) . "\n"; echo PMA_generateHiddenMaxFileSize($GLOBALS['max_upload_size']) . "\n";
echo '</div>'; echo '</div>';
if ($files === FALSE) { if ($files === FALSE) {
@@ -514,25 +517,25 @@ function PMA_sqlQueryFormUpload() {
&& $GLOBALS['allow_recoding'] ) { && $GLOBALS['allow_recoding'] ) {
echo $GLOBALS['strCharsetOfFile'] . "\n" echo $GLOBALS['strCharsetOfFile'] . "\n"
. '<select name="charset_of_file" size="1">' . "\n"; . '<select name="charset_of_file" size="1">' . "\n";
foreach( $GLOBALS['cfg']['AvailableCharsets'] as $temp_charset ) { foreach ($GLOBALS['cfg']['AvailableCharsets'] as $temp_charset) {
echo '<option value="' . $temp_charset . '"'; echo '<option value="' . $temp_charset . '"';
if ( $temp_charset == $GLOBALS['charset'] ) { if ($temp_charset == $GLOBALS['charset']) {
echo ' selected="selected"'; echo ' selected="selected"';
} }
echo '>' . $temp_charset . '</option>' . "\n"; echo '>' . $temp_charset . '</option>' . "\n";
} }
echo '</select>' . "\n"; echo '</select>' . "\n";
} elseif ( PMA_MYSQL_INT_VERSION >= 40100 ) { } elseif (PMA_MYSQL_INT_VERSION >= 40100) {
echo $GLOBALS['strCharsetOfFile'] . "\n"; echo $GLOBALS['strCharsetOfFile'] . "\n";
echo PMA_generateCharsetDropdownBox( PMA_CSDROPDOWN_CHARSET, echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET,
'charset_of_file', NULL, 'utf8', FALSE ); 'charset_of_file', null, 'utf8', FALSE);
} // end if (recoding) } // end if (recoding)
echo '<input type="submit" name="SQL" value="' . $GLOBALS['strGo'] echo '<input type="submit" name="SQL" value="' . $GLOBALS['strGo']
.'" />' . "\n"; .'" />' . "\n";
echo '<div class="clearfloat"></div>' . "\n"; echo '<div class="clearfloat"></div>' . "\n";
echo '</fieldset>'; echo '</fieldset>';
foreach( $errors as $error => $message ) { foreach ( $errors as $error => $message ) {
echo '<div>' . $error . '</div>'; echo '<div>' . $error . '</div>';
echo '<div>' . $message . '</div>'; echo '<div>' . $message . '</div>';
} }

View File

@@ -64,7 +64,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
global $timer; global $timer;
$t = $timer; $t = $timer;
$arr[] = array('type' => $type, 'data' => $data , 'time' => $t); $arr[] = array('type' => $type, 'data' => $data, 'time' => $t);
$timer = microtime(); $timer = microtime();
$arrsize++; $arrsize++;
} // end of the "PMA_SQP_arrayAdd()" function } // end of the "PMA_SQP_arrayAdd()" function
@@ -77,7 +77,8 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
* @access public * @access public
*/ */
// Added, Robbat2 - 13 Janurary 2003, 2:59PM // Added, Robbat2 - 13 Janurary 2003, 2:59PM
function PMA_SQP_resetError() { function PMA_SQP_resetError()
{
global $SQP_errorString; global $SQP_errorString;
$SQP_errorString = ''; $SQP_errorString = '';
unset($SQP_errorString); unset($SQP_errorString);
@@ -91,7 +92,8 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
* @access public * @access public
*/ */
// Added, Robbat2 - 13 Janurary 2003, 2:59PM // Added, Robbat2 - 13 Janurary 2003, 2:59PM
function PMA_SQP_getErrorString() { function PMA_SQP_getErrorString()
{
global $SQP_errorString; global $SQP_errorString;
return isset($SQP_errorString) ? $SQP_errorString : ''; return isset($SQP_errorString) ? $SQP_errorString : '';
} }
@@ -104,7 +106,8 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
* @access public * @access public
*/ */
// Added, Robbat2 - 13 Janurary 2003, 2:59PM // Added, Robbat2 - 13 Janurary 2003, 2:59PM
function PMA_SQP_isError() { function PMA_SQP_isError()
{
global $SQP_errorString; global $SQP_errorString;
return isset($SQP_errorString) && !empty($SQP_errorString); return isset($SQP_errorString) && !empty($SQP_errorString);
} }
@@ -320,7 +323,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
if (($pos < $len) && PMA_STR_charIsEscaped($sql, $pos)) { if (($pos < $len) && PMA_STR_charIsEscaped($sql, $pos)) {
$pos ++; $pos ++;
continue; continue;
} else if (($pos + 1 < $len) && (PMA_substr($sql, $pos, 1) == $quotetype) && (PMA_substr($sql, $pos + 1, 1) == $quotetype)) { } elseif (($pos + 1 < $len) && (PMA_substr($sql, $pos, 1) == $quotetype) && (PMA_substr($sql, $pos + 1, 1) == $quotetype)) {
$pos = $pos + 2; $pos = $pos + 2;
continue; continue;
} else { } else {
@@ -394,11 +397,15 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
if ($is_hex_digit) { if ($is_hex_digit) {
$count2++; $count2++;
$pos = strspn($sql, '0123456789abcdefABCDEF', $count2); $pos = strspn($sql, '0123456789abcdefABCDEF', $count2);
if ($pos > $count2) $count2 = $pos; if ($pos > $count2) {
$count2 = $pos;
}
unset($pos); unset($pos);
} elseif ($is_digit) { } elseif ($is_digit) {
$pos = strspn($sql, '0123456789', $count2); $pos = strspn($sql, '0123456789', $count2);
if ($pos > $count2) $count2 = $pos; if ($pos > $count2) {
$count2 = $pos;
}
unset($pos); unset($pos);
} }
} }
@@ -451,13 +458,12 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
$type = 'digit'; $type = 'digit';
if ($is_float_digit) { if ($is_float_digit) {
$type .= '_float'; $type .= '_float';
} else if ($is_hex_digit) { } elseif ($is_hex_digit) {
$type .= '_hex'; $type .= '_hex';
} else { } else {
$type .= '_integer'; $type .= '_integer';
} }
} } else {
else {
if ($is_sql_variable != FALSE) { if ($is_sql_variable != FALSE) {
$type = 'alpha_variable'; $type = 'alpha_variable';
} else { } else {
@@ -499,12 +505,10 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
break; break;
} }
PMA_SQP_arrayAdd($sql_array, 'punct' . $t_suffix, $punct_data, $arraysize); PMA_SQP_arrayAdd($sql_array, 'punct' . $t_suffix, $punct_data, $arraysize);
} } elseif (PMA_STR_binarySearchInArr($punct_data, $allpunct_list_pair, $allpunct_list_pair_size)) {
else if (PMA_STR_binarySearchInArr($punct_data, $allpunct_list_pair, $allpunct_list_pair_size)) {
// Ok, we have one of the valid combined punct expressions // Ok, we have one of the valid combined punct expressions
PMA_SQP_arrayAdd($sql_array, 'punct', $punct_data, $arraysize); PMA_SQP_arrayAdd($sql_array, 'punct', $punct_data, $arraysize);
} } else {
else {
// Bad luck, lets split it up more // Bad luck, lets split it up more
$first = $punct_data[0]; $first = $punct_data[0];
$first2 = $punct_data[0] . $punct_data[1]; $first2 = $punct_data[0] . $punct_data[1];
@@ -513,17 +517,17 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
if (($first == ',') || ($first == ';') || ($first == '.') || ($first == '*')) { if (($first == ',') || ($first == ';') || ($first == '.') || ($first == '*')) {
$count2 = $count1 + 1; $count2 = $count1 + 1;
$punct_data = $first; $punct_data = $first;
} else if (($last2 == '/*') || (($last2 == '--') && ($count2 == $len || PMA_substr($sql, $count2, 1) <= ' ') )) { } elseif (($last2 == '/*') || (($last2 == '--') && ($count2 == $len || PMA_substr($sql, $count2, 1) <= ' ') )) {
$count2 -= 2; $count2 -= 2;
$punct_data = PMA_substr($sql, $count1, $count2 - $count1); $punct_data = PMA_substr($sql, $count1, $count2 - $count1);
} else if (($last == '-') || ($last == '+') || ($last == '!')) { } elseif (($last == '-') || ($last == '+') || ($last == '!')) {
$count2--; $count2--;
$punct_data = PMA_substr($sql, $count1, $count2 - $count1); $punct_data = PMA_substr($sql, $count1, $count2 - $count1);
// TODO: for negation operator, split in 2 tokens ? // TODO: for negation operator, split in 2 tokens ?
// "select x&~1 from t" // "select x&~1 from t"
// becomes "select x & ~ 1 from t" ? // becomes "select x & ~ 1 from t" ?
} else if ($last != '~') { } elseif ($last != '~') {
$debugstr = $GLOBALS['strSQPBugUnknownPunctuation'] . ' @ ' . ($count1+1) . "\n" $debugstr = $GLOBALS['strSQPBugUnknownPunctuation'] . ' @ ' . ($count1+1) . "\n"
. 'STR: ' . htmlspecialchars($punct_data); . 'STR: ' . htmlspecialchars($punct_data);
PMA_SQP_throwError($debugstr, $sql); PMA_SQP_throwError($debugstr, $sql);
@@ -531,7 +535,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
} }
PMA_SQP_arrayAdd($sql_array, 'punct', $punct_data, $arraysize); PMA_SQP_arrayAdd($sql_array, 'punct', $punct_data, $arraysize);
continue; continue;
} // end if... else if... else } // end if... elseif... else
continue; continue;
} }
@@ -587,7 +591,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
$t_suffix = '_identifier'; $t_suffix = '_identifier';
if (($t_next == 'punct_qualifier') || ($t_prev == 'punct_qualifier')) { if (($t_next == 'punct_qualifier') || ($t_prev == 'punct_qualifier')) {
$t_suffix = '_identifier'; $t_suffix = '_identifier';
} else if (($t_next == 'punct_bracket_open_round') } elseif (($t_next == 'punct_bracket_open_round')
&& PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_function_name, $PMA_SQPdata_function_name_cnt)) { && PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_function_name, $PMA_SQPdata_function_name_cnt)) {
// FIXME-2005-10-16: in the case of a CREATE TABLE containing a TIMESTAMP, // FIXME-2005-10-16: in the case of a CREATE TABLE containing a TIMESTAMP,
// since TIMESTAMP() is also a function, it's found here and // since TIMESTAMP() is also a function, it's found here and
@@ -595,7 +599,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
// compensate for this when analysing for timestamp_not_null // compensate for this when analysing for timestamp_not_null
// later in this script. // later in this script.
$t_suffix = '_functionName'; $t_suffix = '_functionName';
} else if (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_column_type, $PMA_SQPdata_column_type_cnt)) { } elseif (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_column_type, $PMA_SQPdata_column_type_cnt)) {
$t_suffix = '_columnType'; $t_suffix = '_columnType';
// Temporary fix for BUG #621357 // Temporary fix for BUG #621357
@@ -620,9 +624,9 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
// $sql_array[$i-1]['type'] = 'alpha_identifier'; // $sql_array[$i-1]['type'] = 'alpha_identifier';
//} //}
} else if (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_reserved_word, $PMA_SQPdata_reserved_word_cnt)) { } elseif (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_reserved_word, $PMA_SQPdata_reserved_word_cnt)) {
$t_suffix = '_reservedWord'; $t_suffix = '_reservedWord';
} else if (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_column_attrib, $PMA_SQPdata_column_attrib_cnt)) { } elseif (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_column_attrib, $PMA_SQPdata_column_attrib_cnt)) {
$t_suffix = '_columnAttrib'; $t_suffix = '_columnAttrib';
// INNODB is a MySQL table type, but in "SHOW INNODB STATUS", // INNODB is a MySQL table type, but in "SHOW INNODB STATUS",
// it should be regarded as a reserved word. // it should be regarded as a reserved word.
@@ -684,7 +688,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
return TRUE; return TRUE;
} else { } else {
if (strpos($whatWeWant, $typeSeperator) === FALSE) { if (strpos($whatWeWant, $typeSeperator) === FALSE) {
return strncmp($whatWeWant, $toCheck , strpos($toCheck, $typeSeperator)) == 0; return strncmp($whatWeWant, $toCheck, strpos($toCheck, $typeSeperator)) == 0;
} else { } else {
return FALSE; return FALSE;
} }
@@ -703,7 +707,9 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
*/ */
function PMA_SQP_analyze($arr) function PMA_SQP_analyze($arr)
{ {
if ($arr == array()) return array(); if ($arr == array()) {
return array();
}
$result = array(); $result = array();
$size = $arr['len']; $size = $arr['len'];
$subresult = array( $subresult = array(
@@ -959,7 +965,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
// ============================================================== // ==============================================================
if ($arr[$i]['type'] == 'alpha_reservedWord' if ($arr[$i]['type'] == 'alpha_reservedWord'
// && $arr[$i]['forbidden'] == FALSE) { // && $arr[$i]['forbidden'] == FALSE) {
){ ) {
// We don't know what type of query yet, so run this // We don't know what type of query yet, so run this
if ($subresult['querytype'] == '') { if ($subresult['querytype'] == '') {
$subresult['querytype'] = strtoupper($arr[$i]['data']); $subresult['querytype'] = strtoupper($arr[$i]['data']);
@@ -1019,13 +1025,13 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
//TODO: check embedded double quotes or backticks? //TODO: check embedded double quotes or backticks?
// and/or remove just the first and last character? // and/or remove just the first and last character?
case 'quote_backtick': case 'quote_backtick':
$identifier = str_replace('`','',$arr[$i]['data']); $identifier = str_replace('`', '', $arr[$i]['data']);
break; break;
case 'quote_double': case 'quote_double':
$identifier = str_replace('"','',$arr[$i]['data']); $identifier = str_replace('"', '', $arr[$i]['data']);
break; break;
case 'quote_single': case 'quote_single':
$identifier = str_replace("'","",$arr[$i]['data']); $identifier = str_replace("'", "", $arr[$i]['data']);
break; break;
} // end switch } // end switch
@@ -1726,7 +1732,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
if ($arr[$i]['type'] == 'quote_backtick') { if ($arr[$i]['type'] == 'quote_backtick') {
// remove backquotes // remove backquotes
$identifier = str_replace('`','',$arr[$i]['data']); $identifier = str_replace('`', '', $arr[$i]['data']);
} else { } else {
$identifier = $arr[$i]['data']; $identifier = $arr[$i]['data'];
} }
@@ -1763,7 +1769,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
} else { } else {
// for MySQL 4.0.16, identifier is // for MySQL 4.0.16, identifier is
// `table` or `db.table` // `table` or `db.table`
$db_table = explode('.',$identifier); $db_table = explode('.', $identifier);
if (isset($db_table[1])) { if (isset($db_table[1])) {
$foreign[$foreign_key_number]['ref_db_name'] = $db_table[0]; $foreign[$foreign_key_number]['ref_db_name'] = $db_table[0];
$foreign[$foreign_key_number]['ref_table_name'] = $db_table[1]; $foreign[$foreign_key_number]['ref_table_name'] = $db_table[1];
@@ -1978,7 +1984,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
// array_push($typearr, $arr[$i + 1]['type']); // array_push($typearr, $arr[$i + 1]['type']);
$typearr[4] = $arr[$i + 1]['type']; $typearr[4] = $arr[$i + 1]['type'];
} else { } else {
//array_push($typearr, NULL); //array_push($typearr, null);
$typearr[4] = ''; $typearr[4] = '';
} }

View File

@@ -54,8 +54,8 @@ if (!function_exists('class_exists') || !class_exists('SOAP_Client')) {
var $connection_technology_version; var $connection_technology_version;
var $interactive; var $interactive;
var $service_link = NULL; var $service_link = null;
var $session_data = NULL; var $session_data = null;
/** /**
@@ -103,7 +103,7 @@ if (!function_exists('class_exists') || !class_exists('SOAP_Client')) {
$interactive) $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); $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); $ret = $obj->call("openSession", $use_array);
// This is the old version that needed the overload extension // This is the old version that needed the overload extension
/* $ret = $obj->openSession($username, $password, /* $ret = $obj->openSession($username, $password,
@@ -131,7 +131,7 @@ if (!function_exists('class_exists') || !class_exists('SOAP_Client')) {
function _validateSQL($obj, $session, $sql, $method) 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); $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); $res = $obj->call("validateSQL", $use_array);
// This is the old version that needed the overload extension // This is the old version that needed the overload extension
// $res = $obj->validateSQL($session->sessionId, $session->sessionKey, $sql, $this->output_type); // $res = $obj->validateSQL($session->sessionId, $session->sessionKey, $sql, $this->output_type);
@@ -185,8 +185,8 @@ if (!function_exists('class_exists') || !class_exists('SOAP_Client')) {
$this->connection_technology_version = phpversion(); $this->connection_technology_version = phpversion();
$this->interactive = 1; $this->interactive = 1;
$this->service_link = NULL; $this->service_link = null;
$this->session_data = NULL; $this->session_data = null;
} // end of the "PMA_SQLValidator()" function } // end of the "PMA_SQLValidator()" function
@@ -347,7 +347,7 @@ if (!function_exists('class_exists') || !class_exists('SOAP_Client')) {
$this->connection_technology, $this->connection_technology_version, $this->connection_technology, $this->connection_technology_version,
$this->interactive); $this->interactive);
if (isset($this->session_data) && ($this->session_data != NULL) if (isset($this->session_data) && ($this->session_data != null)
&& ($this->session_data->target != $this->url)) { && ($this->session_data->target != $this->url)) {
// Reopens the service on the new URL that was provided // Reopens the service on the new URL that was provided
$url = $this->session_data->target; $url = $this->session_data->target;

View File

@@ -371,7 +371,7 @@ function PMA_STR_binarySearchInArr($str, $arr, $arrsize)
$res = strcmp($str, $arr[$mid]); $res = strcmp($str, $arr[$mid]);
if ($res == 0) { if ($res == 0) {
$found = TRUE; $found = TRUE;
} else if ($res < 0) { } elseif ($res < 0) {
$top = $mid - 1; $top = $mid - 1;
} else { } else {
$bottom = $mid + 1; $bottom = $mid + 1;

View File

@@ -60,14 +60,14 @@ function PMA_check_indexes($idx_collection, $table = true) {
return $output; return $output;
} }
foreach($idx_collection['ALL'] AS $w_keyname => $w_count) { foreach ($idx_collection['ALL'] AS $w_keyname => $w_count) {
if (isset($idx_collection['PRIMARY'][$w_keyname]) && (isset($idx_collection['INDEX'][$w_keyname]) || isset($idx_collection['UNIQUE'][$w_keyname]))) { if (isset($idx_collection['PRIMARY'][$w_keyname]) && (isset($idx_collection['INDEX'][$w_keyname]) || isset($idx_collection['UNIQUE'][$w_keyname]))) {
$output .= PMA_index_warning(sprintf($GLOBALS['strIndexWarningPrimary'], htmlspecialchars($w_keyname)), $table); $output .= PMA_index_warning(sprintf($GLOBALS['strIndexWarningPrimary'], htmlspecialchars($w_keyname)), $table);
} elseif (isset($idx_collection['UNIQUE'][$w_keyname]) && isset($idx_collection['INDEX'][$w_keyname])) { } elseif (isset($idx_collection['UNIQUE'][$w_keyname]) && isset($idx_collection['INDEX'][$w_keyname])) {
$output .= PMA_index_warning(sprintf($GLOBALS['strIndexWarningUnique'], htmlspecialchars($w_keyname)), $table); $output .= PMA_index_warning(sprintf($GLOBALS['strIndexWarningUnique'], htmlspecialchars($w_keyname)), $table);
} }
foreach($index_types AS $index_type) { foreach ($index_types AS $index_type) {
if (isset($idx_collection[$index_type][$w_keyname]) && $idx_collection[$index_type][$w_keyname] > 1) { if (isset($idx_collection[$index_type][$w_keyname]) && $idx_collection[$index_type][$w_keyname] > 1) {
$output .= PMA_index_warning(sprintf($GLOBALS['strIndexWarningMultiple'], $index_type, htmlspecialchars($w_keyname)), $table); $output .= PMA_index_warning(sprintf($GLOBALS['strIndexWarningMultiple'], $index_type, htmlspecialchars($w_keyname)), $table);
} }

View File

@@ -4,7 +4,7 @@
// Check parameters // Check parameters
require_once('./libraries/common.lib.php'); require_once('./libraries/common.lib.php');
PMA_checkParameters(array('db','table','action','num_fields')); PMA_checkParameters(array('db', 'table', 'action', 'num_fields'));
// Get available character sets and storage engines // Get available character sets and storage engines
@@ -50,8 +50,7 @@ if ($action == 'tbl_create.php') {
?> ?>
<input type="hidden" name="reload" value="1" /> <input type="hidden" name="reload" value="1" />
<?php <?php
} } elseif ($action == 'tbl_addfield.php') {
elseif ($action == 'tbl_addfield.php') {
?> ?>
<input type="hidden" name="field_where" value="<?php echo $field_where; ?>" /> <input type="hidden" name="field_where" value="<?php echo $field_where; ?>" />
<input type="hidden" name="after_field" value="<?php echo $after_field; ?>" /> <input type="hidden" name="after_field" value="<?php echo $after_field; ?>" />
@@ -244,8 +243,7 @@ for ( $i = 0 ; $i <= $num_fields; $i++ ) {
if (empty($row['Type'])) { if (empty($row['Type'])) {
$row['Type'] = ''; $row['Type'] = '';
$type = ''; $type = '';
} } else {
else {
$type = $row['Type']; $type = $row['Type'];
} }
// set or enum types: slashes single quotes inside options // set or enum types: slashes single quotes inside options
@@ -323,7 +321,7 @@ for ( $i = 0 ; $i <= $num_fields; $i++ ) {
$ci++; $ci++;
if (PMA_MYSQL_INT_VERSION >= 40100) { if (PMA_MYSQL_INT_VERSION >= 40100) {
$tmp_collation = empty($row['Collation']) ? NULL : $row['Collation']; $tmp_collation = empty($row['Collation']) ? null : $row['Collation'];
$content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'field_collation[]', 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, FALSE); $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'field_collation[]', 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, FALSE);
unset($tmp_collation); unset($tmp_collation);
$ci++; $ci++;
@@ -613,7 +611,7 @@ var odd_row = <?php echo $odd_row; ?>;
function addField() { function addField() {
var new_fields = document.getElementById('added_fields').value; var new_fields = document.getElementById('added_fields').value;
var new_field_container = document.getElementById('table_columns'); var new_field_container = document.getElementById('table_columns');
var new_field = '<?php echo preg_replace( '<27>\s+<2B>', ' ', preg_replace( '<27>\'<27>', '\\\'', $new_field ) ); ?>'; var new_field = '<?php echo preg_replace( '<27>\s+<2B>', ' ', preg_replace( '<27>\'<27>', '\\\'', $new_field ) ); ?>';
var i = 0; var i = 0;
for ( i = 0; i < new_fields; i++ ) { for ( i = 0; i < new_fields; i++ ) {
if ( odd_row ) { if ( odd_row ) {
@@ -653,13 +651,13 @@ if ($action == 'tbl_create.php') {
</td> </td>
<td width="25">&nbsp;</td> <td width="25">&nbsp;</td>
<td> <td>
<?php echo PMA_generateEnginesDropdown('tbl_type', NULL, FALSE, (isset($GLOBALS['tbl_type']) ? $GLOBALS['tbl_type'] : NULL), 3); ?> <?php echo PMA_generateEnginesDropdown('tbl_type', null, FALSE, (isset($GLOBALS['tbl_type']) ? $GLOBALS['tbl_type'] : null), 3); ?>
</td> </td>
<?php <?php
if ( PMA_MYSQL_INT_VERSION >= 40100 ) { if ( PMA_MYSQL_INT_VERSION >= 40100 ) {
echo ' <td width="25">&nbsp;</td>' . "\n" echo ' <td width="25">&nbsp;</td>' . "\n"
. ' <td>' . "\n" . ' <td>' . "\n"
. PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation', NULL, (isset($tbl_collation) ? $tbl_collation : NULL), FALSE, 3) . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation', null, (isset($tbl_collation) ? $tbl_collation : null), FALSE, 3)
. ' </td>' . "\n"; . ' </td>' . "\n";
} }
?> ?>

View File

@@ -10,7 +10,7 @@ require_once('./libraries/common.lib.php');
require_once('./libraries/bookmark.lib.php'); require_once('./libraries/bookmark.lib.php');
// Check parameters // Check parameters
PMA_checkParameters(array('db','table')); PMA_checkParameters(array('db', 'table'));
if ( PMA_MYSQL_INT_VERSION >= 50002 && $db === 'information_schema' ) { if ( PMA_MYSQL_INT_VERSION >= 50002 && $db === 'information_schema' ) {
$db_is_information_schema = true; $db_is_information_schema = true;

View File

@@ -66,7 +66,7 @@ $tabs['export']['args']['single_table'] = 'true';
$tabs['export']['text'] = $strExport; $tabs['export']['text'] = $strExport;
/** /**
* Don't display , "Import", "Operations" and "Empty" * Don't display "Import", "Operations" and "Empty"
* for views and information_schema * for views and information_schema
*/ */
if ( ! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_schema )) { if ( ! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_schema )) {

View File

@@ -9,7 +9,7 @@
require_once('./libraries/common.lib.php'); require_once('./libraries/common.lib.php');
PMA_checkParameters(array('db','encoded_key')); PMA_checkParameters(array('db', 'encoded_key'));
// f i e l d u p l o a d e d f r o m a f i l e // f i e l d u p l o a d e d f r o m a f i l e
@@ -112,8 +112,11 @@ if (!$check_stop) {
// f i e l d v a l u e i n t h e f o r m // f i e l d v a l u e i n t h e f o r m
if (isset($me_fields_type[$encoded_key])) $type = $me_fields_type[$encoded_key]; if (isset($me_fields_type[$encoded_key])) {
else $type = ''; $type = $me_fields_type[$encoded_key];
} else {
$type = '';
}
$f = 'field_' . md5($key); $f = 'field_' . md5($key);
$t_fval = (isset($$f) ? $$f : null); $t_fval = (isset($$f) ? $$f : null);

View File

@@ -19,7 +19,7 @@ function PMA_transformation_getOptions($string) {
// strip possible slashes to behave like documentation says // strip possible slashes to behave like documentation says
$result = array(); $result = array();
foreach($transform_options as $val) { foreach ($transform_options as $val) {
$result[] = stripslashes($val); $result[] = stripslashes($val);
} }
return $result; return $result;
@@ -59,7 +59,7 @@ function PMA_getAvailableMIMEtypes() {
$stack['transformation'][] = $mimetype . ': ' . $base[1]; $stack['transformation'][] = $mimetype . ': ' . $base[1];
$stack['transformation_file'][] = $file; $stack['transformation_file'][] = $file;
} else if (preg_match('|^.*\.inc\.php$|', trim($file), $match)) { } elseif (preg_match('|^.*\.inc\.php$|', trim($file), $match)) {
// File is a plain mimetype, no functions. // File is a plain mimetype, no functions.
$base = str_replace('.inc.php', '', $file); $base = str_replace('.inc.php', '', $file);
@@ -161,7 +161,7 @@ function PMA_setMIME($db, $table, $key, $mimetype, $transformation, $transformat
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\''; . ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\'';
} }
} else if (strlen($mimetype) > 0 || strlen($transformation) > 0 || strlen($transformation_options) > 0) { } elseif (strlen($mimetype) > 0 || strlen($transformation) > 0 || strlen($transformation_options) > 0) {
$upd_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info']) $upd_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
. ' (db_name, table_name, column_name, mimetype, transformation, transformation_options) ' . ' (db_name, table_name, column_name, mimetype, transformation, transformation_options) '
. ' VALUES(' . ' VALUES('

View File

@@ -106,8 +106,9 @@
* @uses SimpleUnzip::ReadFile() Opens file on new if specified * @uses SimpleUnzip::ReadFile() Opens file on new if specified
* @since 1.0 * @since 1.0
*/ */
function SimpleUnzip($in_FileName = '') { function SimpleUnzip($in_FileName = '')
if($in_FileName !== '') { {
if ($in_FileName !== '') {
SimpleUnzip::ReadFile($in_FileName); SimpleUnzip::ReadFile($in_FileName);
} }
} // end of the 'SimpleUnzip' constructor } // end of the 'SimpleUnzip' constructor
@@ -120,7 +121,8 @@
* @uses $Entries * @uses $Entries
* @since 1.0 * @since 1.0
*/ */
function Count() { function Count()
{
return count($this->Entries); return count($this->Entries);
} // end of the 'Count()' method } // end of the 'Count()' method
@@ -133,7 +135,8 @@
* @access public * @access public
* @since 1.0 * @since 1.0
*/ */
function GetData($in_Index) { function GetData($in_Index)
{
return $this->Entries[$in_Index]->Data; return $this->Entries[$in_Index]->Data;
} // end of the 'GetData()' method } // end of the 'GetData()' method
@@ -146,7 +149,8 @@
* @access public * @access public
* @since 1.0 * @since 1.0
*/ */
function GetEntry($in_Index) { function GetEntry($in_Index)
{
return $this->Entries[$in_Index]; return $this->Entries[$in_Index];
} // end of the 'GetEntry()' method } // end of the 'GetEntry()' method
@@ -159,7 +163,8 @@
* @access public * @access public
* @since 1.0 * @since 1.0
*/ */
function GetError($in_Index) { function GetError($in_Index)
{
return $this->Entries[$in_Index]->Error; return $this->Entries[$in_Index]->Error;
} // end of the 'GetError()' method } // end of the 'GetError()' method
@@ -172,7 +177,8 @@
* @access public * @access public
* @since 1.0 * @since 1.0
*/ */
function GetErrorMsg($in_Index) { function GetErrorMsg($in_Index)
{
return $this->Entries[$in_Index]->ErrorMsg; return $this->Entries[$in_Index]->ErrorMsg;
} // end of the 'GetErrorMsg()' method } // end of the 'GetErrorMsg()' method
@@ -185,7 +191,8 @@
* @access public * @access public
* @since 1.0 * @since 1.0
*/ */
function GetName($in_Index) { function GetName($in_Index)
{
return $this->Entries[$in_Index]->Name; return $this->Entries[$in_Index]->Name;
} // end of the 'GetName()' method } // end of the 'GetName()' method
@@ -198,7 +205,8 @@
* @access public * @access public
* @since 1.0 * @since 1.0
*/ */
function GetPath($in_Index) { function GetPath($in_Index)
{
return $this->Entries[$in_Index]->Path; return $this->Entries[$in_Index]->Path;
} // end of the 'GetPath()' method } // end of the 'GetPath()' method
@@ -211,7 +219,8 @@
* @access public * @access public
* @since 1.0 * @since 1.0
*/ */
function GetTime($in_Index) { function GetTime($in_Index)
{
return $this->Entries[$in_Index]->Time; return $this->Entries[$in_Index]->Time;
} // end of the 'GetTime()' method } // end of the 'GetTime()' method
@@ -224,7 +233,8 @@
* @access public * @access public
* @since 1.0 * @since 1.0
*/ */
function ReadFile($in_FileName) { function ReadFile($in_FileName)
{
$this->Entries = array(); $this->Entries = array();
// Get file parameters // Get file parameters
@@ -261,7 +271,7 @@
array_shift($aE); array_shift($aE);
// Loop through the entries // Loop through the entries
foreach($aE as $vZ) { foreach ($aE as $vZ) {
$aI = array(); $aI = array();
$aI['E'] = 0; $aI['E'] = 0;
$aI['EM'] = ''; $aI['EM'] = '';
@@ -272,7 +282,7 @@
$nF = $aP['FNL']; $nF = $aP['FNL'];
// Special case : value block after the compressed data // Special case : value block after the compressed data
if($aP['GPF'] & 0x0008) { if ($aP['GPF'] & 0x0008) {
$aP1 = unpack('V1CRC/V1CS/V1UCS', substr($vZ, -12)); $aP1 = unpack('V1CRC/V1CS/V1UCS', substr($vZ, -12));
$aP['CRC'] = $aP1['CRC']; $aP['CRC'] = $aP1['CRC'];
@@ -285,7 +295,7 @@
// Getting stored filename // Getting stored filename
$aI['N'] = substr($vZ, 26, $nF); $aI['N'] = substr($vZ, 26, $nF);
if(substr($aI['N'], -1) == '/') { if (substr($aI['N'], -1) == '/') {
// is a directory entry - will be skipped // is a directory entry - will be skipped
continue; continue;
} }
@@ -297,16 +307,14 @@
$vZ = substr($vZ, 26 + $nF); $vZ = substr($vZ, 26 + $nF);
if(strlen($vZ) != $aP['CS']) { if (strlen($vZ) != $aP['CS']) {
$aI['E'] = 1; $aI['E'] = 1;
$aI['EM'] = 'Compressed size is not equal with the value in header information.'; $aI['EM'] = 'Compressed size is not equal with the value in header information.';
} } else {
else { if ($bE) {
if($bE) {
$aI['E'] = 5; $aI['E'] = 5;
$aI['EM'] = 'File is encrypted, which is not supported from this class.'; $aI['EM'] = 'File is encrypted, which is not supported from this class.';
} } else {
else {
switch($aP['CM']) { switch($aP['CM']) {
case 0: // Stored case 0: // Stored
// Here is nothing to do, the file ist flat. // Here is nothing to do, the file ist flat.
@@ -318,21 +326,19 @@
case 12: // BZIP2 case 12: // BZIP2
// 2003-12-02 - HB > // 2003-12-02 - HB >
if(! extension_loaded('bz2')) { if (! extension_loaded('bz2')) {
if(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
@dl('php_bz2.dll'); @dl('php_bz2.dll');
} } else {
else {
@dl('bz2.so'); @dl('bz2.so');
} }
} }
if(extension_loaded('bz2')) { if (extension_loaded('bz2')) {
// 2003-12-02 - HB < // 2003-12-02 - HB <
$vZ = bzdecompress($vZ); $vZ = bzdecompress($vZ);
// 2003-12-02 - HB > // 2003-12-02 - HB >
} } else {
else {
$aI['E'] = 7; $aI['E'] = 7;
$aI['EM'] = "PHP BZIP2 extension not available."; $aI['EM'] = "PHP BZIP2 extension not available.";
} }
@@ -346,19 +352,17 @@
} }
// 2003-12-02 - HB > // 2003-12-02 - HB >
if(! $aI['E']) { if (! $aI['E']) {
// 2003-12-02 - HB < // 2003-12-02 - HB <
if($vZ === FALSE) { if ($vZ === FALSE) {
$aI['E'] = 2; $aI['E'] = 2;
$aI['EM'] = 'Decompression of data failed.'; $aI['EM'] = 'Decompression of data failed.';
} } else {
else { if (strlen($vZ) != $aP['UCS']) {
if(strlen($vZ) != $aP['UCS']) {
$aI['E'] = 3; $aI['E'] = 3;
$aI['EM'] = 'Uncompressed size is not equal with the value in header information.'; $aI['EM'] = 'Uncompressed size is not equal with the value in header information.';
} } else {
else { if (crc32($vZ) != $aP['CRC']) {
if(crc32($vZ) != $aP['CRC']) {
$aI['E'] = 4; $aI['E'] = 4;
$aI['EM'] = 'CRC32 checksum is not equal with the value in header information.'; $aI['EM'] = 'CRC32 checksum is not equal with the value in header information.';
} }
@@ -475,7 +479,8 @@
* @access public * @access public
* @since 1.0 * @since 1.0
*/ */
function SimpleUnzipEntry($in_Entry) { function SimpleUnzipEntry($in_Entry)
{
$this->Data = $in_Entry['D']; $this->Data = $in_Entry['D'];
$this->Error = $in_Entry['E']; $this->Error = $in_Entry['E'];
$this->ErrorMsg = $in_Entry['EM']; $this->ErrorMsg = $in_Entry['EM'];

View File

@@ -65,17 +65,21 @@ function PMA_generate_common_hidden_inputs( $db = '', $table = '', $indent = 0,
} }
if ( ! is_array($skip) ) { if ( ! is_array($skip) ) {
if ( isset( $params[$skip] ) ) unset( $params[$skip] ); if ( isset( $params[$skip] ) ) {
unset( $params[$skip] );
}
} else { } else {
foreach( $skip as $skipping ) { foreach ( $skip as $skipping ) {
if ( isset( $params[$skipping] ) ) unset( $params[$skipping] ); if ( isset( $params[$skipping] ) ) {
unset( $params[$skipping] );
}
} }
} }
$spaces = str_repeat( ' ', $indent ); $spaces = str_repeat( ' ', $indent );
$return = ''; $return = '';
foreach( $params as $key => $val ) { foreach ( $params as $key => $val ) {
$return .= $spaces . '<input type="hidden" name="' . htmlspecialchars( $key ) . '" value="' . htmlspecialchars( $val ) . '" />' . "\n"; $return .= $spaces . '<input type="hidden" name="' . htmlspecialchars( $key ) . '" value="' . htmlspecialchars( $val ) . '" />' . "\n";
} }
@@ -184,7 +188,7 @@ function PMA_generate_common_url ($db = '', $table = '', $delim = '&amp;')
} }
$param_strings = array(); $param_strings = array();
foreach( $params as $key => $val ) { foreach ( $params as $key => $val ) {
$param_strings[] = urlencode( $key ) . '=' . urlencode( $val ); $param_strings[] = urlencode( $key ) . '=' . urlencode( $val );
} }

View File

@@ -90,8 +90,8 @@ if (!$cfg['LeftDisplayServers'] && (count($cfg['Servers']) > 1 || $server == 0 &
if ( $server > 0 ) { if ( $server > 0 ) {
echo '<ul>' . "\n"; echo '<ul>' . "\n";
PMA_printListItem( $strProtocolVersion . ': ' . PMA_DBI_get_proto_info() PMA_printListItem( $strProtocolVersion . ': ' . PMA_DBI_get_proto_info(),
, 'li_mysql_proto' ); 'li_mysql_proto' );
PMA_printListItem( $strServer . ': ' . $server_info, 'li_server_info' ); PMA_printListItem( $strServer . ': ' . $server_info, 'li_server_info' );
PMA_printListItem( $strUser . ': ' . htmlspecialchars( $mysql_cur_user_and_host ), PMA_printListItem( $strUser . ': ' . htmlspecialchars( $mysql_cur_user_and_host ),
'li_user_info' ); 'li_user_info' );
@@ -131,7 +131,7 @@ if ( $server > 0 ) {
. ' </li>' . "\n" . ' </li>' . "\n"
. ' <li id="li_select_mysql_collation">'; . ' <li id="li_select_mysql_collation">';
echo ' <form method="post" action="index.php" target="_parent">' . "\n" echo ' <form method="post" action="index.php" target="_parent">' . "\n"
. PMA_generate_common_hidden_inputs(NULL, NULL, 4, 'collation_connection') . PMA_generate_common_hidden_inputs(null, null, 4, 'collation_connection')
. ' <label for="select_collation_connection">' . "\n" . ' <label for="select_collation_connection">' . "\n"
. ' ' . $strMySQLConnectionCollation . ': ' . "\n" . ' ' . $strMySQLConnectionCollation . ': ' . "\n"
. ' </label>' . "\n" . ' </label>' . "\n"
@@ -172,7 +172,7 @@ if ( $server > 0 ) {
'./server_privileges.php?' . $common_url_query ); './server_privileges.php?' . $common_url_query );
} }
$binlogs = PMA_DBI_try_query('SHOW MASTER LOGS', NULL, PMA_DBI_QUERY_STORE); $binlogs = PMA_DBI_try_query('SHOW MASTER LOGS', null, PMA_DBI_QUERY_STORE);
if ( $binlogs ) { if ( $binlogs ) {
if (PMA_DBI_num_rows($binlogs) > 0) { if (PMA_DBI_num_rows($binlogs) > 0) {
PMA_printListItem( $strBinaryLog, 'li_mysql_binlogs', PMA_printListItem( $strBinaryLog, 'li_mysql_binlogs',
@@ -300,7 +300,7 @@ PMA_printListItem( $strHomepageOfficial, 'li_pma_homepage', 'http://www.phpMyAdm
<?php <?php
if ( ! empty( $GLOBALS['PMA_errors'] ) && is_array( $GLOBALS['PMA_errors'] ) ) { if ( ! empty( $GLOBALS['PMA_errors'] ) && is_array( $GLOBALS['PMA_errors'] ) ) {
foreach( $GLOBALS['PMA_errors'] as $error ) { foreach ( $GLOBALS['PMA_errors'] as $error ) {
echo '<div class="error">' . $error . '</div>' . "\n"; echo '<div class="error">' . $error . '</div>' . "\n";
} }
} }
@@ -371,19 +371,20 @@ if (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION < 32332) {
* @param string $id id, used for css styles * @param string $id id, used for css styles
* @param string $url make item as link with $url as target * @param string $url make item as link with $url as target
*/ */
function PMA_printListItem( $name, $id = NULL, $url = NULL, $mysql_help_page = NULL ) { function PMA_printListItem($name, $id = null, $url = null, $mysql_help_page = null)
{
echo '<li id="' . $id . '">'; echo '<li id="' . $id . '">';
if ( NULL !== $url ) { if (null !== $url) {
echo '<a href="' . $url . '">'; echo '<a href="' . $url . '">';
} }
echo $name; echo $name;
if ( NULL !== $url ) { if (null !== $url) {
echo '</a>' . "\n"; echo '</a>' . "\n";
} }
if ( NULL !== $mysql_help_page ) { if (null !== $mysql_help_page) {
echo PMA_showMySQLDocu( '', $mysql_help_page ); echo PMA_showMySQLDocu('', $mysql_help_page);
} }
echo '</li>'; echo '</li>';
} }

View File

@@ -99,7 +99,7 @@ if ($cfgRelation['pdfwork']) {
// first put all the master tables at beginning // first put all the master tables at beginning
// of the list, so they are near the center of // of the list, so they are near the center of
// the schema // the schema
while (list(,$master_table) = PMA_DBI_fetch_row($master_tables_rs)) { while (list(, $master_table) = PMA_DBI_fetch_row($master_tables_rs)) {
$all_tables[] = $master_table; $all_tables[] = $master_table;
} }
@@ -223,7 +223,7 @@ if ($cfgRelation['pdfwork']) {
// We will need an array of all tables in this db // We will need an array of all tables in this db
$selectboxall = array('--'); $selectboxall = array('--');
$alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); $alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
while ($val = @PMA_DBI_fetch_row($alltab_rs)) { while ($val = @PMA_DBI_fetch_row($alltab_rs)) {
$selectboxall[] = $val[0]; $selectboxall[] = $val[0];
} }

File diff suppressed because it is too large Load Diff

View File

@@ -93,8 +93,7 @@ if (!empty($bug_encoded)) {
} else { } else {
$result = 'Error: &quot;gzuncompress()&quot; is unavailable!' . "\n"; $result = 'Error: &quot;gzuncompress()&quot; is unavailable!' . "\n";
} }
} } else {
else {
$result = PMA_printDecodedBug($bug_decoded); $result = PMA_printDecodedBug($bug_decoded);
} // end if... else... } // end if... else...

View File

@@ -339,7 +339,7 @@ function get_action($name, $title, $added = '', $enabled = TRUE) {
function get_url_action($url, $title, $params = array()) { function get_url_action($url, $title, $params = array()) {
$ret = ''; $ret = '';
$ret .= '<form class="action" method="GET" action="' . $url . '" target="_blank">'; $ret .= '<form class="action" method="GET" action="' . $url . '" target="_blank">';
foreach($params as $key => $val) { foreach ($params as $key => $val) {
$ret .= '<input type="hidden" name="' . $key . '" value="' . $val . '" />'; $ret .= '<input type="hidden" name="' . $key . '" value="' . $val . '" />';
} }
$ret .= '<input type="submit" value="' . $title . '" />'; $ret .= '<input type="submit" value="' . $title . '" />';
@@ -418,7 +418,7 @@ function get_cfg_val($name, $val) {
$ret = ''; $ret = '';
if (is_array($val)) { if (is_array($val)) {
$ret .= "\n"; $ret .= "\n";
foreach($val as $k => $v) { foreach ($val as $k => $v) {
if (!isset($type)) { if (!isset($type)) {
if (is_string($k)) { if (is_string($k)) {
$type = 'string'; $type = 'string';
@@ -463,9 +463,9 @@ function get_cfg_string($cfg) {
if (count($c['Servers']) > 0) { if (count($c['Servers']) > 0) {
$ret .= "/* Servers configuration */\n\$i = 0;\n"; $ret .= "/* Servers configuration */\n\$i = 0;\n";
foreach($c['Servers'] as $cnt => $srv) { foreach ($c['Servers'] as $cnt => $srv) {
$ret .= "\n/* Server " . get_server_name($srv, $cnt) . " */\n\$i++;\n"; $ret .= "\n/* Server " . get_server_name($srv, $cnt) . " */\n\$i++;\n";
foreach($srv as $key => $val) { foreach ($srv as $key => $val) {
$ret .= get_cfg_val("\$cfg['Servers'][\$i]['$key']", $val); $ret .= get_cfg_val("\$cfg['Servers'][\$i]['$key']", $val);
} }
} }
@@ -473,7 +473,7 @@ function get_cfg_string($cfg) {
} }
unset($c['Servers']); unset($c['Servers']);
foreach($c as $key => $val) { foreach ($c as $key => $val) {
$ret .= get_cfg_val("\$cfg['$key']", $val); $ret .= get_cfg_val("\$cfg['$key']", $val);
} }
@@ -510,12 +510,15 @@ function compress_servers(&$cfg) {
* *
* @return array array with grabbed values * @return array array with grabbed values
*/ */
function grab_values($list) { function grab_values($list)
{
$a = split(';', $list); $a = split(';', $list);
$res = array(); $res = array();
foreach($a as $val) { foreach ($a as $val) {
$v = split(':', $val); $v = split(':', $val);
if (!isset($v[1])) $v[1] = ''; if (!isset($v[1])) {
$v[1] = '';
}
switch($v[1]) { switch($v[1]) {
case 'bool': case 'bool':
$res[$v[0]] = isset($_POST[$v[0]]); $res[$v[0]] = isset($_POST[$v[0]]);
@@ -535,7 +538,7 @@ function grab_values($list) {
$cur = $_POST[$v[0]]; $cur = $_POST[$v[0]];
if ($cur == 'TRUE') { if ($cur == 'TRUE') {
$res[$v[0]] = TRUE; $res[$v[0]] = TRUE;
} else if ($cur == 'FALSE') { } elseif ($cur == 'FALSE') {
$res[$v[0]] = FALSE; $res[$v[0]] = FALSE;
} else { } else {
$res[$v[0]] = $cur; $res[$v[0]] = $cur;
@@ -566,7 +569,7 @@ function grab_values($list) {
function show_overview($title, $list, $buttons = '') { function show_overview($title, $list, $buttons = '') {
echo '<fieldset class="overview">' . "\n"; echo '<fieldset class="overview">' . "\n";
echo '<legend>' . $title . '</legend>' . "\n"; echo '<legend>' . $title . '</legend>' . "\n";
foreach($list as $val) { foreach ($list as $val) {
echo '<div class="row">'; echo '<div class="row">';
echo '<div class="desc">'; echo '<div class="desc">';
echo $val[0]; echo $val[0];
@@ -605,18 +608,24 @@ function show_overview($title, $list, $buttons = '') {
function show_config_form($list, $legend, $help, $defaults = array(), $save = '', $prefix = '') { function show_config_form($list, $legend, $help, $defaults = array(), $save = '', $prefix = '') {
global $PMA_Config; global $PMA_Config;
if (empty($save)) $save = 'Update'; if (empty($save)) {
$save = 'Update';
}
echo '<fieldset class="optbox">' . "\n"; echo '<fieldset class="optbox">' . "\n";
echo '<legend>' . $legend . '</legend>' . "\n"; echo '<legend>' . $legend . '</legend>' . "\n";
echo '<p>' . $help . '</p>' . "\n"; echo '<p>' . $help . '</p>' . "\n";
foreach($list as $val) { foreach ($list as $val) {
echo '<div class="opts">'; echo '<div class="opts">';
$type = 'text'; $type = 'text';
if (isset($val[3])) { if (isset($val[3])) {
if (is_array($val[3])) $type = 'select'; if (is_array($val[3])) {
elseif (is_bool($val[3])) $type = 'check'; $type = 'select';
elseif ($val[3] == 'password') $type = 'password'; } elseif (is_bool($val[3])) {
$type = 'check';
} elseif ($val[3] == 'password') {
$type = 'password';
}
} }
switch ($type) { switch ($type) {
case 'text': case 'text':
@@ -866,7 +875,7 @@ function show_server_form($defaults = array(), $number = FALSE) {
echo '<input type="hidden" name="server" value="' . $number . '" />'; echo '<input type="hidden" name="server" value="' . $number . '" />';
} }
$hi = array ('bookmarktable', 'relation', 'table_info', 'table_coords', 'pdf_pages', 'column_info', 'history', 'AllowDeny'); $hi = array ('bookmarktable', 'relation', 'table_info', 'table_coords', 'pdf_pages', 'column_info', 'history', 'AllowDeny');
foreach($hi as $k) { foreach ($hi as $k) {
if (isset($defaults[$k]) && (!is_string($defaults[$k]) || strlen($defaults[$k]) > 0)) { if (isset($defaults[$k]) && (!is_string($defaults[$k]) || strlen($defaults[$k]) > 0)) {
echo '<input type="hidden" name="' . $k . '" value="' . htmlspecialchars(serialize($defaults[$k])) . '" />'; echo '<input type="hidden" name="' . $k . '" value="' . htmlspecialchars(serialize($defaults[$k])) . '" />';
} }
@@ -1078,7 +1087,9 @@ function show_window_form($defaults = array()) {
* @return string HTML for server selection * @return string HTML for server selection
*/ */
function get_server_selection($cfg) { function get_server_selection($cfg) {
if (count($cfg['Servers']) == 0) return ''; if (count($cfg['Servers']) == 0) {
return '';
}
$ret = '<select name="server">'; $ret = '<select name="server">';
foreach ($cfg['Servers'] as $key => $val) { foreach ($cfg['Servers'] as $key => $val) {
$ret .= '<option value="' . $key . '">' . get_server_name($val, $key) . '</option>'; $ret .= '<option value="' . $key . '">' . get_server_name($val, $key) . '</option>';
@@ -1287,7 +1298,7 @@ switch ($action) {
} }
if (function_exists('mysqli_get_client_info')) { if (function_exists('mysqli_get_client_info')) {
$defaults['extension'] = 'mysqli'; $defaults['extension'] = 'mysqli';
} else if (function_exists('mysql_get_client_info')) { } elseif (function_exists('mysql_get_client_info')) {
$defaults['extension'] = 'mysql'; $defaults['extension'] = 'mysql';
} else { } else {
message('warning', 'Could not load neither mysql nor mysqli extension, you might not be able to use phpMyAdmin!'); message('warning', 'Could not load neither mysql nor mysqli extension, you might not be able to use phpMyAdmin!');
@@ -1300,11 +1311,15 @@ switch ($action) {
show_server_form($defaults); show_server_form($defaults);
break; break;
case 'editserver': case 'editserver':
if (!isset($_POST['server'])) footer(); if (!isset($_POST['server'])) {
footer();
}
show_server_form($configuration['Servers'][$_POST['server']], $_POST['server']); show_server_form($configuration['Servers'][$_POST['server']], $_POST['server']);
break; break;
case 'deleteserver': case 'deleteserver':
if (!isset($_POST['server'])) footer(); if (!isset($_POST['server'])) {
footer();
}
message('notice', 'Deleted server ' . get_server_name($configuration['Servers'][$_POST['server']], $_POST['server'])); message('notice', 'Deleted server ' . get_server_name($configuration['Servers'][$_POST['server']], $_POST['server']));
unset($configuration['Servers'][$_POST['server']]); unset($configuration['Servers'][$_POST['server']]);
compress_servers($configuration); compress_servers($configuration);
@@ -1314,7 +1329,7 @@ switch ($action) {
if (count($configuration['Servers']) == 0) { if (count($configuration['Servers']) == 0) {
message('notice', 'No servers defined, so none can be shown'); message('notice', 'No servers defined, so none can be shown');
} else { } else {
foreach($configuration['Servers'] as $i => $srv) { foreach ($configuration['Servers'] as $i => $srv) {
$data = array(); $data = array();
if (!empty($srv['verbose'])) { if (!empty($srv['verbose'])) {
$data[] = array('Verbose name', $srv['verbose']); $data[] = array('Verbose name', $srv['verbose']);
@@ -1434,7 +1449,7 @@ switch ($action) {
if (!isset($d['RecodingEngine'])) { if (!isset($d['RecodingEngine'])) {
if (@extension_loaded('iconv')) { if (@extension_loaded('iconv')) {
$d['RecodingEngine'] = 'iconv'; $d['RecodingEngine'] = 'iconv';
} else if (@extension_loaded('recode')) { } elseif (@extension_loaded('recode')) {
$d['RecodingEngine'] = 'recode'; $d['RecodingEngine'] = 'recode';
} else { } else {
PMA_dl('iconv'); PMA_dl('iconv');

View File

@@ -77,7 +77,7 @@ if (open(LATEST, "wget -o /dev/null -O - $source_url|")) {
my $i = 0; my $i = 0;
while(my $line = <LATEST>) { while (my $line = <LATEST>) {
chomp($line); chomp($line);
if ($line =~ /http/) { if ($line =~ /http/) {
$urls[$i++] = $line; $urls[$i++] = $line;
@@ -107,7 +107,7 @@ if (open(DEFINES, $targetdirectory .'/libraries/Config.class.php')) {
my $versionStatus = 0; my $versionStatus = 0;
$installedversion = "unknownversion"; $installedversion = "unknownversion";
while(my $line = <DEFINES>) { while (my $line = <DEFINES>) {
next unless $line =~ /'PMA_VERSION',\ '(.*)?'\);$/; next unless $line =~ /'PMA_VERSION',\ '(.*)?'\);$/;
$installedversion = $1; $installedversion = $1;

View File

@@ -24,7 +24,9 @@ echo '<h2>' . "\n"
. ' ' . $strBinaryLog . "\n" . ' ' . $strBinaryLog . "\n"
. '</h2>' . "\n"; . '</h2>' . "\n";
if (!isset($log)) $log = ''; if (!isset($log)) {
$log = '';
}
/** /**
* Display log selector. * Display log selector.
@@ -35,7 +37,7 @@ if (count($binary_logs) > 1) {
echo '<fieldset><legend>'; echo '<fieldset><legend>';
echo $strSelectBinaryLog; echo $strSelectBinaryLog;
echo '</legend><select name="log">'; echo '</legend><select name="log">';
foreach($binary_logs as $name) { foreach ($binary_logs as $name) {
echo '<option value="' . $name . '"' . ($name == $log ? ' selected="selected"' : '') . '>' . $name . '</option>'; echo '<option value="' . $name . '"' . ($name == $log ? ' selected="selected"' : '') . '>' . $name . '</option>';
} }
echo '</select>'; echo '</select>';
@@ -48,7 +50,9 @@ if (count($binary_logs) > 1) {
$sql_query = 'SHOW BINLOG EVENTS'; $sql_query = 'SHOW BINLOG EVENTS';
if (!empty($log)) $sql_query .= ' IN \'' . $log . '\''; if (!empty($log)) {
$sql_query .= ' IN \'' . $log . '\'';
}
/** /**
* Sends the query and buffers the result * Sends the query and buffers the result

View File

@@ -110,8 +110,8 @@ echo '<h2>' . "\n"
/** /**
* Gets the databases list * Gets the databases list
*/ */
if ( $server > 0 ) { if ($server > 0) {
$databases = PMA_DBI_get_databases_full( NULL, $dbstats ); $databases = PMA_DBI_get_databases_full(null, $dbstats);
} else { } else {
$databases = array(); $databases = array();
} }
@@ -120,13 +120,13 @@ if ( $server > 0 ) {
/** /**
* Displays the page * Displays the page
*/ */
if ( count($databases) > 0 ) { if (count($databases) > 0) {
// sorts the array // sorts the array
usort( $databases, 'PMA_dbCmp' ); usort( $databases, 'PMA_dbCmp' );
// table col order // table col order
// there is no db specific collation or charset prior 4.1.0 // there is no db specific collation or charset prior 4.1.0
if ( PMA_MYSQL_INT_VERSION >= 40100 ) { if (PMA_MYSQL_INT_VERSION >= 40100) {
$column_order['DEFAULT_COLLATION_NAME'] = array( $column_order['DEFAULT_COLLATION_NAME'] = array(
'disp_name' => $strCollation, 'disp_name' => $strCollation,
'description_function' => 'PMA_getCollationDescr', 'description_function' => 'PMA_getCollationDescr',

View File

@@ -120,7 +120,7 @@ function PMA_extractPrivInfo($row = '', $enableHTML = FALSE)
$GLOBALS['userlink'] ); $GLOBALS['userlink'] );
$row1 = PMA_DBI_fetch_assoc($res); $row1 = PMA_DBI_fetch_assoc($res);
PMA_DBI_free_result($res); PMA_DBI_free_result($res);
$av_grants = explode ('\',\'' , substr($row1['Type'], 5, strlen($row1['Type']) - 7)); $av_grants = explode ('\',\'', substr($row1['Type'], 5, strlen($row1['Type']) - 7));
unset($row1); unset($row1);
$users_grants = explode(',', $row['Table_priv']); $users_grants = explode(',', $row['Table_priv']);
foreach ($av_grants as $current_grant) { foreach ($av_grants as $current_grant) {
@@ -158,7 +158,7 @@ function PMA_extractPrivInfo($row = '', $enableHTML = FALSE)
} else { } else {
$privs[] = 'USAGE'; $privs[] = 'USAGE';
} }
} else if ($allPrivileges && (!isset($GLOBALS['grant_count']) || count($privs) == $GLOBALS['grant_count'])) { } elseif ($allPrivileges && (!isset($GLOBALS['grant_count']) || count($privs) == $GLOBALS['grant_count'])) {
if ($enableHTML) { if ($enableHTML) {
$privs = array('<dfn title="' . $GLOBALS['strPrivDescAllPrivileges'] . '">ALL PRIVILEGES</dfn>'); $privs = array('<dfn title="' . $GLOBALS['strPrivDescAllPrivileges'] . '">ALL PRIVILEGES</dfn>');
} else { } else {
@@ -255,7 +255,7 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent =
if ($table == '*') { if ($table == '*') {
if ($db == '*') { if ($db == '*') {
$sql_query = 'SHOW COLUMNS FROM `mysql`.`user`;'; $sql_query = 'SHOW COLUMNS FROM `mysql`.`user`;';
} else if ($table == '*') { } elseif ($table == '*') {
$sql_query = 'SHOW COLUMNS FROM `mysql`.`db`;'; $sql_query = 'SHOW COLUMNS FROM `mysql`.`db`;';
} }
$res = PMA_DBI_query($sql_query); $res = PMA_DBI_query($sql_query);
@@ -282,7 +282,7 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent =
$row1 = PMA_DBI_fetch_assoc($res); $row1 = PMA_DBI_fetch_assoc($res);
PMA_DBI_free_result($res); PMA_DBI_free_result($res);
$av_grants = explode ('\',\'' , substr($row1['Type'], strpos($row1['Type'], '(') + 2, strpos($row1['Type'], ')') - strpos($row1['Type'], '(') - 3)); $av_grants = explode ('\',\'', substr($row1['Type'], strpos($row1['Type'], '(') + 2, strpos($row1['Type'], ')') - strpos($row1['Type'], '(') - 3));
unset($res, $row1); unset($res, $row1);
$users_grants = explode(',', $row['Table_priv']); $users_grants = explode(',', $row['Table_priv']);
@@ -349,7 +349,7 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent =
// privs that are not attached to a specific column // privs that are not attached to a specific column
echo $spaces . ' <div class="item">' . "\n"; echo $spaces . ' <div class="item">' . "\n";
foreach($row as $current_grant => $current_grant_value) { foreach ($row as $current_grant => $current_grant_value) {
if (in_array(substr($current_grant, 0, (strlen($current_grant) - 5)), array('Select', 'Insert', 'Update', 'References'))) { if (in_array(substr($current_grant, 0, (strlen($current_grant) - 5)), array('Select', 'Insert', 'Update', 'References'))) {
continue; continue;
} }
@@ -374,7 +374,7 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent =
echo $spaces . ' <label for="checkbox_' . $current_grant . '"><tt><dfn title="' . (isset($GLOBALS['strPrivDesc' . substr($tmp_current_grant, 0, (strlen($tmp_current_grant) - 5))]) ? $GLOBALS['strPrivDesc' . substr($tmp_current_grant, 0, (strlen($tmp_current_grant) - 5))] : $GLOBALS['strPrivDesc' . substr($tmp_current_grant, 0, (strlen($tmp_current_grant) - 5)) . 'Tbl']) . '">' . strtoupper(substr($current_grant, 0, strlen($current_grant) - 5)) . '</dfn></tt></label>' . "\n" echo $spaces . ' <label for="checkbox_' . $current_grant . '"><tt><dfn title="' . (isset($GLOBALS['strPrivDesc' . substr($tmp_current_grant, 0, (strlen($tmp_current_grant) - 5))]) ? $GLOBALS['strPrivDesc' . substr($tmp_current_grant, 0, (strlen($tmp_current_grant) - 5))] : $GLOBALS['strPrivDesc' . substr($tmp_current_grant, 0, (strlen($tmp_current_grant) - 5)) . 'Tbl']) . '">' . strtoupper(substr($current_grant, 0, strlen($current_grant) - 5)) . '</dfn></tt></label>' . "\n"
. $spaces . ' </div>' . "\n"; . $spaces . ' </div>' . "\n";
} // end foreach() } // end foreach ()
echo $spaces . ' </div>' . "\n"; echo $spaces . ' </div>' . "\n";
// for Safari 2.0.2 // for Safari 2.0.2
@@ -563,15 +563,19 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0 ) {
$fields_info = PMA_DBI_get_fields('mysql', 'user'); $fields_info = PMA_DBI_get_fields('mysql', 'user');
$username_length = 16; $username_length = 16;
$hostname_length = 41; $hostname_length = 41;
foreach($fields_info as $key => $val) { foreach ($fields_info as $key => $val) {
if ($val['Field'] == 'User') { if ($val['Field'] == 'User') {
strtok($val['Type'], '()'); strtok($val['Type'], '()');
$v = strtok('()'); $v = strtok('()');
if (is_int($v)) $username_length = $v; if (is_int($v)) {
$username_length = $v;
}
} elseif ($val['Field'] == 'Host') { } elseif ($val['Field'] == 'Host') {
strtok($val['Type'], '()'); strtok($val['Type'], '()');
$v = strtok('()'); $v = strtok('()');
if (is_int($v)) $hostname_length = $v; if (is_int($v)) {
$hostname_length = $v;
}
} }
} }
unset($fields_info); unset($fields_info);
@@ -743,7 +747,7 @@ if (!empty($adduser_submit) || !empty($change_copy)) {
.' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') .' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted')
.' AND ' . PMA_convert_using('Host') .' AND ' . PMA_convert_using('Host')
.' = ' . PMA_convert_using($hostname, 'quoted') . ';', .' = ' . PMA_convert_using($hostname, 'quoted') . ';',
NULL, PMA_DBI_QUERY_STORE ); null, PMA_DBI_QUERY_STORE);
if (PMA_DBI_num_rows($res) == 1) { if (PMA_DBI_num_rows($res) == 1) {
PMA_DBI_free_result($res); PMA_DBI_free_result($res);
$message = sprintf($GLOBALS['strUserAlreadyExists'], '[i]\'' . $username . '\'@\'' . $hostname . '\'[/i]'); $message = sprintf($GLOBALS['strUserAlreadyExists'], '[i]\'' . $username . '\'@\'' . $hostname . '\'[/i]');
@@ -751,7 +755,7 @@ if (!empty($adduser_submit) || !empty($change_copy)) {
} else { } else {
PMA_DBI_free_result($res); PMA_DBI_free_result($res);
if ( 50002 <= PMA_MYSQL_INT_VERSION ) { if (50002 <= PMA_MYSQL_INT_VERSION) {
// MySQL 5 requires CREATE USER before any GRANT on this user can done // MySQL 5 requires CREATE USER before any GRANT on this user can done
$create_user_real = 'CREATE USER \'' . PMA_sqlAddslashes($username) . '\'@\'' . $hostname . '\''; $create_user_real = 'CREATE USER \'' . PMA_sqlAddslashes($username) . '\'@\'' . $hostname . '\'';
} }
@@ -884,7 +888,7 @@ if (!empty($change_copy)) {
.' AND ' . PMA_convert_using('`Table_name`') .' AND ' . PMA_convert_using('`Table_name`')
.' = ' . PMA_convert_using($row['Table_name'], 'quoted') .' = ' . PMA_convert_using($row['Table_name'], 'quoted')
.';', .';',
NULL, PMA_DBI_QUERY_STORE ); null, PMA_DBI_QUERY_STORE);
$tmp_privs1 = PMA_extractPrivInfo($row); $tmp_privs1 = PMA_extractPrivInfo($row);
$tmp_privs2 = array( $tmp_privs2 = array(
@@ -1062,9 +1066,9 @@ if (!empty($change_pw)) {
$sql_query = 'SET PASSWORD FOR \'' . $username . '\'@\'' . $hostname . '\' = \'\';'; $sql_query = 'SET PASSWORD FOR \'' . $username . '\'@\'' . $hostname . '\' = \'\';';
PMA_DBI_query($sql_query); PMA_DBI_query($sql_query);
$message = sprintf($GLOBALS['strPasswordChanged'], '\'' . $username . '\'@\'' . $hostname . '\''); $message = sprintf($GLOBALS['strPasswordChanged'], '\'' . $username . '\'@\'' . $hostname . '\'');
} else if (empty($pma_pw) || empty($pma_pw2)) { } elseif (empty($pma_pw) || empty($pma_pw2)) {
$message = $GLOBALS['strPasswordEmpty']; $message = $GLOBALS['strPasswordEmpty'];
} else if ($pma_pw != $pma_pw2) { } elseif ($pma_pw != $pma_pw2) {
$message = $GLOBALS['strPasswordNotSame']; $message = $GLOBALS['strPasswordNotSame'];
} else { } else {
$hidden_pw = ''; $hidden_pw = '';
@@ -1286,16 +1290,16 @@ if ( empty( $adduser ) && ( ! isset( $checkprivs ) || ! strlen($checkprivs) ) )
$sql_query .= (isset($initial) ? PMA_RangeOfUsers($initial) : ''); $sql_query .= (isset($initial) ? PMA_RangeOfUsers($initial) : '');
$sql_query .= ' ORDER BY `User` ASC, `Host` ASC;'; $sql_query .= ' ORDER BY `User` ASC, `Host` ASC;';
$res = PMA_DBI_try_query($sql_query, NULL, PMA_DBI_QUERY_STORE); $res = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_STORE);
if ( ! $res ) { if (! $res) {
// the query failed! This may have two reasons: // the query failed! This may have two reasons:
// - the user does not have enough privileges // - the user does not have enough privileges
// - the privilege tables use a structure of an earlier version. // - the privilege tables use a structure of an earlier version.
// so let's try a more simple query // so let's try a more simple query
$sql_query = 'SELECT * FROM `mysql`.`user`'; $sql_query = 'SELECT * FROM `mysql`.`user`';
$res = PMA_DBI_try_query($sql_query, NULL, PMA_DBI_QUERY_STORE); $res = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_STORE);
if (!$res) { if (!$res) {
echo '<i>' . $GLOBALS['strNoPrivileges'] . '</i>' . "\n"; echo '<i>' . $GLOBALS['strNoPrivileges'] . '</i>' . "\n";
@@ -1377,7 +1381,7 @@ if ( empty( $adduser ) && ( ! isset( $checkprivs ) || ! strlen($checkprivs) ) )
} }
} }
$initials = PMA_DBI_try_query('SELECT DISTINCT UPPER(LEFT(' . PMA_convert_using('User') . ',1)) FROM `user` ORDER BY `User` ASC', NULL, PMA_DBI_QUERY_STORE); $initials = PMA_DBI_try_query('SELECT DISTINCT UPPER(LEFT(' . PMA_convert_using('User') . ',1)) FROM `user` ORDER BY `User` ASC', null, PMA_DBI_QUERY_STORE);
while (list($tmp_initial) = PMA_DBI_fetch_row($initials)) { while (list($tmp_initial) = PMA_DBI_fetch_row($initials)) {
$array_initials[$tmp_initial] = TRUE; $array_initials[$tmp_initial] = TRUE;
} }
@@ -1557,7 +1561,7 @@ if ( empty( $adduser ) && ( ! isset( $checkprivs ) || ! strlen($checkprivs) ) )
} }
} }
echo ' : ' . $GLOBALS['strEditPrivileges'] . '</h2>' . "\n"; echo ' : ' . $GLOBALS['strEditPrivileges'] . '</h2>' . "\n";
$res = PMA_DBI_query('SELECT \'foo\' FROM `mysql`.`user` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ';', NULL, PMA_DBI_QUERY_STORE); $res = PMA_DBI_query('SELECT \'foo\' FROM `mysql`.`user` WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted') . ' AND ' . PMA_convert_using('Host') . ' = ' . PMA_convert_using($hostname, 'quoted') . ';', null, PMA_DBI_QUERY_STORE);
$user_does_not_exists = (PMA_DBI_num_rows( $res ) < 1); $user_does_not_exists = (PMA_DBI_num_rows( $res ) < 1);
PMA_DBI_free_result($res); PMA_DBI_free_result($res);
unset($res); unset($res);
@@ -1842,7 +1846,7 @@ if ( empty( $adduser ) && ( ! isset( $checkprivs ) || ! strlen($checkprivs) ) )
} else { } else {
echo ' <input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '"/>' . "\n" echo ' <input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '"/>' . "\n"
. ' <label for="text_tablename">' . $GLOBALS['strAddPrivilegesOnTbl'] . ':</label>' . "\n"; . ' <label for="text_tablename">' . $GLOBALS['strAddPrivilegesOnTbl'] . ':</label>' . "\n";
if ($res = @PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($dbname) . ';', NULL, PMA_DBI_QUERY_STORE)) { if ($res = @PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($dbname) . ';', null, PMA_DBI_QUERY_STORE)) {
$pred_tbl_array = array(); $pred_tbl_array = array();
while ($row = PMA_DBI_fetch_row($res)) { while ($row = PMA_DBI_fetch_row($res)) {
if (!isset($found_rows) || !in_array($row[0], $found_rows)) { if (!isset($found_rows) || !in_array($row[0], $found_rows)) {
@@ -2121,7 +2125,7 @@ if ( empty( $adduser ) && ( ! isset( $checkprivs ) || ! strlen($checkprivs) ) )
} }
echo '</tbody>' . "\n" echo '</tbody>' . "\n"
. '</table>' . "\n"; . '</table>' . "\n";
} // end if (empty($adduser) && empty($checkprivs)) ... else if ... else ... } // end if (empty($adduser) && empty($checkprivs)) ... elseif ... else ...
/** /**

View File

@@ -304,7 +304,7 @@ foreach ( $server_status as $name => $value ) {
unset( $server_status[$name] ); unset( $server_status[$name] );
} else { } else {
foreach ( $allocations as $filter => $section ) { foreach ( $allocations as $filter => $section ) {
if ( preg_match( '<27>^' . $filter . '<27>i', $name ) if ( preg_match( '<27>^' . $filter . '<27>i', $name )
&& isset( $server_status[$name] ) ) { && isset( $server_status[$name] ) ) {
unset( $server_status[$name] ); unset( $server_status[$name] );
$sections[$section]['vars'][$name] = $value; $sections[$section]['vars'][$name] = $value;
@@ -446,7 +446,7 @@ foreach ( $sections as $section_name => $section ) {
$server_status['Connections'] > 0 $server_status['Connections'] > 0
? number_format( ? number_format(
$server_status['Aborted_clients'] * 100 / $server_status['Connections'], $server_status['Aborted_clients'] * 100 / $server_status['Connections'],
2 , $GLOBALS['number_decimal_separator'], 2, $GLOBALS['number_decimal_separator'],
$GLOBALS['number_thousands_separator']) . '%' $GLOBALS['number_thousands_separator']) . '%'
: '--- '; ?></td> : '--- '; ?></td>
</tr> </tr>

49
sql.php
View File

@@ -276,7 +276,7 @@ else {
// Gets the number of rows per page // Gets the number of rows per page
if (empty($session_max_rows)) { if (empty($session_max_rows)) {
$session_max_rows = $cfg['MaxRows']; $session_max_rows = $cfg['MaxRows'];
} else if ($session_max_rows != 'all') { } elseif ($session_max_rows != 'all') {
$cfg['MaxRows'] = $session_max_rows; $cfg['MaxRows'] = $session_max_rows;
} }
// Defines the display mode (horizontal/vertical) and header "frequency" // Defines the display mode (horizontal/vertical) and header "frequency"
@@ -303,19 +303,19 @@ else {
$is_count = !$is_group && (preg_match('@^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)@i', $sql_query)); $is_count = !$is_group && (preg_match('@^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)@i', $sql_query));
$is_export = (preg_match('@[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+@i', $sql_query)); $is_export = (preg_match('@[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+@i', $sql_query));
$is_analyse = (preg_match('@[[:space:]]+PROCEDURE[[:space:]]+ANALYSE@i', $sql_query)); $is_analyse = (preg_match('@[[:space:]]+PROCEDURE[[:space:]]+ANALYSE@i', $sql_query));
} else if (preg_match('@^EXPLAIN[[:space:]]+@i', $sql_query)) { } elseif (preg_match('@^EXPLAIN[[:space:]]+@i', $sql_query)) {
$is_explain = TRUE; $is_explain = TRUE;
} else if (preg_match('@^DELETE[[:space:]]+@i', $sql_query)) { } elseif (preg_match('@^DELETE[[:space:]]+@i', $sql_query)) {
$is_delete = TRUE; $is_delete = TRUE;
$is_affected = TRUE; $is_affected = TRUE;
} else if (preg_match('@^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+@i', $sql_query)) { } elseif (preg_match('@^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+@i', $sql_query)) {
$is_insert = TRUE; $is_insert = TRUE;
$is_affected = TRUE; $is_affected = TRUE;
} else if (preg_match('@^UPDATE[[:space:]]+@i', $sql_query)) { } elseif (preg_match('@^UPDATE[[:space:]]+@i', $sql_query)) {
$is_affected = TRUE; $is_affected = TRUE;
} else if (preg_match('@^SHOW[[:space:]]+@i', $sql_query)) { } elseif (preg_match('@^SHOW[[:space:]]+@i', $sql_query)) {
$is_show = TRUE; $is_show = TRUE;
} else if (preg_match('@^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+@i', $sql_query)) { } elseif (preg_match('@^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+@i', $sql_query)) {
$is_maint = TRUE; $is_maint = TRUE;
} }
@@ -372,15 +372,14 @@ else {
if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) { if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
unset($result); unset($result);
$num_rows = 0; $num_rows = 0;
} } else {
else {
// garvin: Measure query time. TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411 // garvin: Measure query time. TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411
list($usec, $sec) = explode(' ',microtime()); list($usec, $sec) = explode(' ', microtime());
$querytime_before = ((float)$usec + (float)$sec); $querytime_before = ((float)$usec + (float)$sec);
$result = @PMA_DBI_try_query($full_sql_query, NULL, PMA_DBI_QUERY_STORE); $result = @PMA_DBI_try_query($full_sql_query, null, PMA_DBI_QUERY_STORE);
list($usec, $sec) = explode(' ',microtime()); list($usec, $sec) = explode(' ', microtime());
$querytime_after = ((float)$usec + (float)$sec); $querytime_after = ((float)$usec + (float)$sec);
$GLOBALS['querytime'] = $querytime_after - $querytime_before; $GLOBALS['querytime'] = $querytime_after - $querytime_before;
@@ -401,7 +400,7 @@ else {
if (!$is_affected) { if (!$is_affected) {
$num_rows = ($result) ? @PMA_DBI_num_rows($result) : 0; $num_rows = ($result) ? @PMA_DBI_num_rows($result) : 0;
} else if (!isset($num_rows)) { } elseif (!isset($num_rows)) {
$num_rows = @PMA_DBI_affected_rows(); $num_rows = @PMA_DBI_affected_rows();
} }
@@ -409,7 +408,7 @@ else {
// This could happen if the user sends a query like "USE `database`;" // This could happen if the user sends a query like "USE `database`;"
$res = PMA_DBI_query('SELECT DATABASE() AS \'db\';'); $res = PMA_DBI_query('SELECT DATABASE() AS \'db\';');
$row = PMA_DBI_fetch_row($res); $row = PMA_DBI_fetch_row($res);
if (is_array($row) && isset($row[0]) && (strcasecmp($db,$row[0]) != 0)) { if (is_array($row) && isset($row[0]) && (strcasecmp($db, $row[0]) != 0)) {
$db = $row[0]; $db = $row[0];
$reload = 1; $reload = 1;
} }
@@ -430,8 +429,7 @@ else {
// if we did not append a limit, set this to get a correct // if we did not append a limit, set this to get a correct
// "Showing rows..." message // "Showing rows..." message
$GLOBALS['session_max_rows'] = 'all'; $GLOBALS['session_max_rows'] = 'all';
} } elseif ($is_select) {
else if ($is_select) {
// c o u n t q u e r y // c o u n t q u e r y
@@ -465,7 +463,7 @@ else {
if (isset($analyzed_sql[0]['queryflags']['distinct'])) { if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
$count_what = 'DISTINCT '; $count_what = 'DISTINCT ';
$first_expr = TRUE; $first_expr = TRUE;
foreach($analyzed_sql[0]['select_expr'] as $part) { foreach ($analyzed_sql[0]['select_expr'] as $part) {
$count_what .= (!$first_expr ? ', ' : '') . $part['expr']; $count_what .= (!$first_expr ? ', ' : '') . $part['expr'];
$first_expr = FALSE; $first_expr = FALSE;
} }
@@ -599,14 +597,14 @@ else {
if ($num_rows < 1 || $is_affected) { if ($num_rows < 1 || $is_affected) {
if ($is_delete) { if ($is_delete) {
$message = $strDeletedRows . '&nbsp;' . $num_rows; $message = $strDeletedRows . '&nbsp;' . $num_rows;
} else if ($is_insert) { } elseif ($is_insert) {
$message = $strInsertedRows . '&nbsp;' . $num_rows; $message = $strInsertedRows . '&nbsp;' . $num_rows;
$insert_id = PMA_DBI_insert_id(); $insert_id = PMA_DBI_insert_id();
if ($insert_id != 0) { if ($insert_id != 0) {
// insert_id is id of FIRST record inserted in one insert, so if we inserted multiple rows, we had to increment this // insert_id is id of FIRST record inserted in one insert, so if we inserted multiple rows, we had to increment this
$message .= '[br]'.$strInsertedRowId . '&nbsp;' . ($insert_id + $num_rows - 1); $message .= '[br]'.$strInsertedRowId . '&nbsp;' . ($insert_id + $num_rows - 1);
} }
} else if ($is_affected) { } elseif ($is_affected) {
$message = $strAffectedRows . '&nbsp;' . $num_rows; $message = $strAffectedRows . '&nbsp;' . $num_rows;
// Ok, here is an explanation for the !$is_select. // Ok, here is an explanation for the !$is_select.
@@ -617,11 +615,11 @@ else {
// The $zero_rows containing $strSuccess and sent with // The $zero_rows containing $strSuccess and sent with
// the form should not have priority over // the form should not have priority over
// errors like $strEmptyResultSet // errors like $strEmptyResultSet
} else if (!empty($zero_rows) && !$is_select) { } elseif (!empty($zero_rows) && !$is_select) {
$message = $zero_rows; $message = $zero_rows;
} else if (!empty($GLOBALS['show_as_php'])) { } elseif (!empty($GLOBALS['show_as_php'])) {
$message = $strPhp; $message = $strPhp;
} else if (!empty($GLOBALS['validatequery'])) { } elseif (!empty($GLOBALS['validatequery'])) {
$message = $strValidateSQL; $message = $strValidateSQL;
} else { } else {
$message = $strEmptyResultSet; $message = $strEmptyResultSet;
@@ -643,7 +641,7 @@ else {
if (!isset($table)) { if (!isset($table)) {
$goto = 'db_details.php'; $goto = 'db_details.php';
} else { } else {
$is_table = @PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';', NULL, PMA_DBI_QUERY_STORE); $is_table = @PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';', null, PMA_DBI_QUERY_STORE);
if (!($is_table && @PMA_DBI_num_rows($is_table))) { if (!($is_table && @PMA_DBI_num_rows($is_table))) {
$goto = 'db_details.php'; $goto = 'db_details.php';
unset($table); unset($table);
@@ -675,8 +673,7 @@ else {
} }
$active_page = $goto; $active_page = $goto;
require('./' . $goto); require('./' . $goto);
} // end if file_exist } else {
else {
PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto) . '&message=' . urlencode($message)); PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto) . '&message=' . urlencode($message));
} // end else } // end else
exit(); exit();
@@ -747,7 +744,7 @@ else {
// BEGIN INDEX CHECK See if indexes should be checked. // BEGIN INDEX CHECK See if indexes should be checked.
if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) { if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) {
foreach($selected AS $idx => $tbl_name) { foreach ($selected AS $idx => $tbl_name) {
$indexes = $indexes_info = $indexes_data = array(); $indexes = $indexes_info = $indexes_data = array();
$tbl_ret_keys = PMA_get_indexes(urldecode($tbl_name), $err_url_0); $tbl_ret_keys = PMA_get_indexes(urldecode($tbl_name), $err_url_0);

View File

@@ -32,7 +32,7 @@ if (isset($submit_num_fields)) {
} }
$num_fields = $orig_num_fields + $added_fields; $num_fields = $orig_num_fields + $added_fields;
$regenerate = TRUE; $regenerate = TRUE;
} else if (isset($do_save_data)) { } elseif (isset($do_save_data)) {
$query = ''; $query = '';
// Transforms the radio button field_key into 3 arrays // Transforms the radio button field_key into 3 arrays

View File

@@ -136,7 +136,7 @@ unset($show_create_table);
* Get the list of the fields of the current table * Get the list of the fields of the current table
*/ */
PMA_DBI_select_db($db); PMA_DBI_select_db($db);
$table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', NULL, PMA_DBI_QUERY_STORE); $table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
if (isset($primary_key)) { if (isset($primary_key)) {
if (is_array($primary_key)) { if (is_array($primary_key)) {
$primary_key_array = $primary_key; $primary_key_array = $primary_key;
@@ -148,7 +148,7 @@ if (isset($primary_key)) {
$result = array(); $result = array();
foreach ($primary_key_array AS $rowcount => $primary_key) { foreach ($primary_key_array AS $rowcount => $primary_key) {
$local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';'; $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';';
$result[$rowcount] = PMA_DBI_query($local_query, NULL, PMA_DBI_QUERY_STORE); $result[$rowcount] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE);
$row[$rowcount] = PMA_DBI_fetch_assoc($result[$rowcount]); $row[$rowcount] = PMA_DBI_fetch_assoc($result[$rowcount]);
$primary_keys[$rowcount] = $primary_key; $primary_keys[$rowcount] = $primary_key;
@@ -178,7 +178,7 @@ if (isset($primary_key)) {
} // end if (no record returned) } // end if (no record returned)
} }
} else { } else {
$result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1;', NULL, PMA_DBI_QUERY_STORE); $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1;', null, PMA_DBI_QUERY_STORE);
unset($row); unset($row);
} }
@@ -212,7 +212,7 @@ document.onkeydown = onKeyDownArrowsHandler;
<?php } ?> <?php } ?>
<!-- Change table properties form --> <!-- Change table properties form -->
<form method="post" action="tbl_replace.php" name="insertForm" <?php if ($is_upload) echo ' enctype="multipart/form-data"'; ?>> <form method="post" action="tbl_replace.php" name="insertForm" <?php if ($is_upload) { echo ' enctype="multipart/form-data"'; } ?>>
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?> <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="goto" value="<?php echo urlencode($goto); ?>" /> <input type="hidden" name="goto" value="<?php echo urlencode($goto); ?>" />
<input type="hidden" name="pos" value="<?php echo isset($pos) ? $pos : 0; ?>" /> <input type="hidden" name="pos" value="<?php echo isset($pos) ? $pos : 0; ?>" />
@@ -361,7 +361,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
&& !isset($row_table_def['Default']) && !isset($row_table_def['Default'])
&& isset($row_table_def['Null']) && isset($row_table_def['Null'])
&& $row_table_def['Null'] == 'YES') { && $row_table_def['Null'] == 'YES') {
$row_table_def['Default'] = NULL; $row_table_def['Default'] = null;
} }
if ($row_table_def['Type'] == 'datetime' if ($row_table_def['Type'] == 'datetime'
@@ -378,7 +378,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
// UPDATE case with an empty and not NULL value under PHP4 // UPDATE case with an empty and not NULL value under PHP4
elseif (empty($vrow[$rowfield]) && is_null($vrow[$rowfield])) { elseif (empty($vrow[$rowfield]) && is_null($vrow[$rowfield])) {
$vrow[$rowfield] = date('Y-m-d H:i:s', time()); $vrow[$rowfield] = date('Y-m-d H:i:s', time());
} // end if... else if... } // end if... elseif...
} }
$len = (preg_match('@float|double@', $row_table_def['Type'])) $len = (preg_match('@float|double@', $row_table_def['Type']))
? 100 ? 100
@@ -484,7 +484,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
if (($cfg['ProtectBinary'] && $is_blob && !$is_upload) if (($cfg['ProtectBinary'] && $is_blob && !$is_upload)
|| ($cfg['ProtectBinary'] == 'all' && $is_binary)) { || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
echo ' <td align="center" bgcolor="'. $bgcolor . '">' . $strBinary . '</td>' . "\n"; echo ' <td align="center" bgcolor="'. $bgcolor . '">' . $strBinary . '</td>' . "\n";
} else if (strstr($row_table_def['True_Type'], 'enum') || strstr($row_table_def['True_Type'], 'set')) { } elseif (strstr($row_table_def['True_Type'], 'enum') || strstr($row_table_def['True_Type'], 'set')) {
echo ' <td align="center" bgcolor="'. $bgcolor . '">--</td>' . "\n"; echo ' <td align="center" bgcolor="'. $bgcolor . '">--</td>' . "\n";
} else { } else {
?> ?>
@@ -591,9 +591,9 @@ foreach ($loop_array AS $vrowcount => $vrow) {
} else { } else {
$onclick .= '2, '; $onclick .= '2, ';
} }
} else if (strstr($row_table_def['True_Type'], 'set')) { } elseif (strstr($row_table_def['True_Type'], 'set')) {
$onclick .= '3, '; $onclick .= '3, ';
} else if ($foreigners && isset($foreigners[$field])) { } elseif ($foreigners && isset($foreigners[$field])) {
$onclick .= '4, '; $onclick .= '4, ';
} else { } else {
$onclick .= '5, '; $onclick .= '5, ';
@@ -624,7 +624,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
</script> </script>
</td> </td>
<?php <?php
} else if (isset($disp_row) && is_array($disp_row)) { } elseif (isset($disp_row) && is_array($disp_row)) {
?> ?>
<td bgcolor="<?php echo $bgcolor; ?>"> <td bgcolor="<?php echo $bgcolor; ?>">
<?php echo $backup_field . "\n"; ?> <?php echo $backup_field . "\n"; ?>
@@ -636,8 +636,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
</td> </td>
<?php <?php
unset($disp_row); unset($disp_row);
} } elseif ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) {
else if ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) {
?> ?>
<td bgcolor="<?php echo $bgcolor; ?>">&nbsp;</td> <td bgcolor="<?php echo $bgcolor; ?>">&nbsp;</td>
</tr> </tr>
@@ -648,8 +647,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
<?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"><?php echo $special_chars; ?></textarea> <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"><?php echo $special_chars; ?></textarea>
</td> </td>
<?php <?php
} } elseif (strstr($type, 'text')) {
else if (strstr($type, 'text')) {
?> ?>
<td bgcolor="<?php echo $bgcolor; ?>"> <td bgcolor="<?php echo $bgcolor; ?>">
<?php echo $backup_field . "\n"; ?> <?php echo $backup_field . "\n"; ?>
@@ -661,8 +659,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
if (strlen($special_chars) > 32000) { if (strlen($special_chars) > 32000) {
echo ' <td bgcolor="' . $bgcolor . '">' . $strTextAreaLength . '</td>' . "\n"; echo ' <td bgcolor="' . $bgcolor . '">' . $strTextAreaLength . '</td>' . "\n";
} }
} } elseif ($type == 'enum') {
else if ($type == 'enum') {
$enum = PMA_getEnumSetOptions($row_table_def['Type']); $enum = PMA_getEnumSetOptions($row_table_def['Type']);
$enum_cnt = count($enum); $enum_cnt = count($enum);
?> ?>
@@ -698,8 +695,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
?> ?>
</select> </select>
<?php <?php
} // end if } else {
else {
echo "\n"; echo "\n";
for ($j = 0; $j < $enum_cnt; $j++) { for ($j = 0; $j < $enum_cnt; $j++) {
// Removes automatic MySQL escape format // Removes automatic MySQL escape format
@@ -721,8 +717,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
</td> </td>
<?php <?php
echo "\n"; echo "\n";
} } elseif ($type == 'set') {
else if ($type == 'set') {
$set = PMA_getEnumSetOptions($row_table_def['Type']); $set = PMA_getEnumSetOptions($row_table_def['Type']);
if (isset($vset)) { if (isset($vset)) {
@@ -757,7 +752,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
} }
// Change by Bernard M. Piller <bernard@bmpsystems.com> // Change by Bernard M. Piller <bernard@bmpsystems.com>
// We don't want binary data destroyed // We don't want binary data destroyed
else if ($is_binary || $is_blob) { elseif ($is_binary || $is_blob) {
if (($cfg['ProtectBinary'] && $is_blob) if (($cfg['ProtectBinary'] && $is_blob)
|| ($cfg['ProtectBinary'] == 'all' && $is_binary)) { || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
echo "\n"; echo "\n";
@@ -775,7 +770,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
<input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="protected" /> <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="protected" />
<input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" /> <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" />
<?php <?php
} else if ($is_blob) { } elseif ($is_blob) {
echo "\n"; echo "\n";
?> ?>
<td bgcolor="<?php echo $bgcolor; ?>"> <td bgcolor="<?php echo $bgcolor; ?>">
@@ -844,7 +839,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
echo '</td>'; echo '</td>';
} // end else if ( binary or blob) } // end elseif ( binary or blob)
else { else {
// For char or varchar, respect the maximum length (M); for other // For char or varchar, respect the maximum length (M); for other
// types (int or float), the length is not a limit on the values that // types (int or float), the length is not a limit on the values that
@@ -855,8 +850,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
if ($is_char) { if ($is_char) {
$fieldsize = (($len > 40) ? 40 : $len); $fieldsize = (($len > 40) ? 40 : $len);
$maxlength = $len; $maxlength = $len;
} } else {
else {
$fieldsize = 20; $fieldsize = 20;
$maxlength = 99; $maxlength = 99;
} // end if... else... } // end if... else...
@@ -948,15 +942,15 @@ if (!empty($disp_message)) {
<option value="back" <?php echo $selected_after_insert_back; ?>><?php echo $strAfterInsertBack; ?></option> <option value="back" <?php echo $selected_after_insert_back; ?>><?php echo $strAfterInsertBack; ?></option>
<option value="new_insert" <?php echo $selected_after_insert_new_insert; ?>><?php echo $strAfterInsertNewInsert; ?></option> <option value="new_insert" <?php echo $selected_after_insert_new_insert; ?>><?php echo $strAfterInsertNewInsert; ?></option>
<?php <?php
if (isset($primary_key)) if (isset($primary_key)) {
{?> ?>
<option value="same_insert"><?php echo $strAfterInsertSame; ?></option> <option value="same_insert"><?php echo $strAfterInsertSame; ?></option>
<?php <?php
// If we have just numeric primary key, we can also edit next // If we have just numeric primary key, we can also edit next
if (preg_match('@^[\s]*`[^`]*` = [0-9]+@', $primary_key)) { if (preg_match('@^[\s]*`[^`]*` = [0-9]+@', $primary_key)) {
?> ?>
<option value="edit_next"><?php echo $strAfterInsertNext; ?></option> <option value="edit_next"><?php echo $strAfterInsertNext; ?></option>
<?php <?php
} }
} }
?> ?>

View File

@@ -37,7 +37,7 @@ $abort = FALSE;
if (isset($submit_num_fields)) { if (isset($submit_num_fields)) {
$regenerate = TRUE; $regenerate = TRUE;
$num_fields = $orig_num_fields + $added_fields; $num_fields = $orig_num_fields + $added_fields;
} else if (isset($do_save_data)) { } elseif (isset($do_save_data)) {
$sql_query = $query_cpy = ''; $sql_query = $query_cpy = '';
// Transforms the radio button field_key into 3 arrays // Transforms the radio button field_key into 3 arrays

View File

@@ -36,7 +36,7 @@ if (!defined('PMA_IDX_INCLUDED')) {
// Not a valid table name -> back to the default db_details sub-page // Not a valid table name -> back to the default db_details sub-page
if ( isset($table) && strlen($table) ) { if ( isset($table) && strlen($table) ) {
$is_table = PMA_DBI_query('SHOW TABLES LIKE \'' $is_table = PMA_DBI_query('SHOW TABLES LIKE \''
. PMA_sqlAddslashes($table, TRUE) . '\'', NULL, PMA_DBI_QUERY_STORE); . PMA_sqlAddslashes($table, TRUE) . '\'', null, PMA_DBI_QUERY_STORE);
} }
if ( ! isset($table) || ! strlen($table) if ( ! isset($table) || ! strlen($table)
|| !( $is_table && PMA_DBI_num_rows($is_table) ) ) { || !( $is_table && PMA_DBI_num_rows($is_table) ) ) {
@@ -125,10 +125,10 @@ if (!defined('PMA_IDX_INCLUDED')
if ($index_type == 'PRIMARY') { if ($index_type == 'PRIMARY') {
if ($index == '') { if ($index == '') {
$index = 'PRIMARY'; $index = 'PRIMARY';
} else if ($index != 'PRIMARY') { } elseif ($index != 'PRIMARY') {
PMA_mysqlDie($strPrimaryKeyName, '', FALSE, $err_url); PMA_mysqlDie($strPrimaryKeyName, '', FALSE, $err_url);
} }
} else if ($index == 'PRIMARY') { } elseif ($index == 'PRIMARY') {
PMA_mysqlDie($strCantRenameIdxToPrimary, '', FALSE, $err_url); PMA_mysqlDie($strCantRenameIdxToPrimary, '', FALSE, $err_url);
} }
@@ -191,7 +191,7 @@ if (!defined('PMA_IDX_INCLUDED')
/** /**
* Edits an index or defines a new one * Edits an index or defines a new one
*/ */
else if (!defined('PMA_IDX_INCLUDED') elseif (!defined('PMA_IDX_INCLUDED')
&& (isset($index) || isset($create_index))) { && (isset($index) || isset($create_index))) {
// Prepares the form values // Prepares the form values
@@ -227,9 +227,9 @@ else if (!defined('PMA_IDX_INCLUDED')
|| (PMA_MYSQL_INT_VERSION >= 40002 || (PMA_MYSQL_INT_VERSION >= 40002
&& $edited_index_info['Index_type'] == 'FULLTEXT')) { && $edited_index_info['Index_type'] == 'FULLTEXT')) {
$index_type = 'FULLTEXT'; $index_type = 'FULLTEXT';
} else if ($index == 'PRIMARY') { } elseif ($index == 'PRIMARY') {
$index_type = 'PRIMARY'; $index_type = 'PRIMARY';
} else if ($edited_index_info['Non_unique'] == '0') { } elseif ($edited_index_info['Non_unique'] == '0') {
$index_type = 'UNIQUE'; $index_type = 'UNIQUE';
} else { } else {
$index_type = 'INDEX'; $index_type = 'INDEX';
@@ -343,7 +343,7 @@ else if (!defined('PMA_IDX_INCLUDED')
<tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>"> <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
<td><select name="column[]"> <td><select name="column[]">
<option value="--ignore--" <option value="--ignore--"
<?php if ('--ignore--' == $selected) echo ' selected="selected"'; ?>> <?php if ('--ignore--' == $selected) { echo ' selected="selected"'; } ?>>
-- <?php echo $strIgnore; ?> --</option> -- <?php echo $strIgnore; ?> --</option>
<?php <?php
foreach ($fields_names AS $key => $val) { foreach ($fields_names AS $key => $val) {

View File

@@ -43,11 +43,11 @@ if (isset($new_name) && trim($new_name) != '') {
} else { } else {
$pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']); $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
if (isset($switch_to_new) && $switch_to_new == 'true') { if (isset($switch_to_new) && $switch_to_new == 'true') {
setcookie('pma_switch_to_new', 'true', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); setcookie('pma_switch_to_new', 'true', 0, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
$db = $target_db; $db = $target_db;
$table = $new_name; $table = $new_name;
} else { } else {
setcookie('pma_switch_to_new', '', 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']); setcookie('pma_switch_to_new', '', 0, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
} }
} }
} }

View File

@@ -44,12 +44,12 @@ PMA_DBI_select_db($db);
/** /**
* Multi-tables printview thanks to Christophe Gesch<63> from the "MySQL Form * Multi-tables printview thanks to Christophe Gesch<63> from the "MySQL Form
* Generator for PHPMyAdmin" (http://sourceforge.net/projects/phpmysqlformgen/) * Generator for PHPMyAdmin" (http://sourceforge.net/projects/phpmysqlformgen/)
*/ */
if (isset($selected_tbl) && is_array($selected_tbl)) { if (isset($selected_tbl) && is_array($selected_tbl)) {
$the_tables = $selected_tbl; $the_tables = $selected_tbl;
} else if (isset($table)) { } elseif (isset($table)) {
$the_tables[] = $table; $the_tables[] = $table;
} }
$multi_tables = (count($the_tables) > 1); $multi_tables = (count($the_tables) > 1);
@@ -102,7 +102,7 @@ foreach ($the_tables AS $key => $table) {
/** /**
* Gets fields properties * Gets fields properties
*/ */
$result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', NULL, PMA_DBI_QUERY_STORE); $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
$fields_cnt = PMA_DBI_num_rows($result); $fields_cnt = PMA_DBI_num_rows($result);
// Check if we can use Relations (Mike Beck) // Check if we can use Relations (Mike Beck)
@@ -116,8 +116,7 @@ foreach ($the_tables AS $key => $table) {
} else { } else {
$have_rel = FALSE; $have_rel = FALSE;
} }
} } else {
else {
$have_rel = FALSE; $have_rel = FALSE;
} // end if } // end if
@@ -220,7 +219,7 @@ foreach ($the_tables AS $key => $table) {
<td width="80" class="print"<?php echo $type_nowrap; ?>><?php echo $type; ?><bdo dir="ltr"></bdo></td> <td width="80" class="print"<?php echo $type_nowrap; ?>><?php echo $type; ?><bdo dir="ltr"></bdo></td>
<!--<td width="50" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"><?php echo $strAttribute; ?></td>--> <!--<td width="50" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"><?php echo $strAttribute; ?></td>-->
<td width="40" class="print"><?php echo (($row['Null'] == '' || $row['Null'] == 'NO') ? $strNo : $strYes); ?>&nbsp;</td> <td width="40" class="print"><?php echo (($row['Null'] == '' || $row['Null'] == 'NO') ? $strNo : $strYes); ?>&nbsp;</td>
<td width="70" class="print" nowrap="nowrap"><?php if (isset($row['Default'])) echo $row['Default']; ?>&nbsp;</td> <td width="70" class="print" nowrap="nowrap"><?php if (isset($row['Default'])) {7echo $row['Default']; } ?>&nbsp;</td>
<!--<td width="50" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"><?php echo $row['Extra']; ?>&nbsp;</td>--> <!--<td width="50" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"><?php echo $row['Extra']; ?>&nbsp;</td>-->
<?php <?php
echo "\n"; echo "\n";
@@ -413,7 +412,7 @@ foreach ($the_tables AS $key => $table) {
echo ' '; echo ' ';
if ($showtable['Row_format'] == 'Fixed') { if ($showtable['Row_format'] == 'Fixed') {
echo $strFixed; echo $strFixed;
} else if ($showtable['Row_format'] == 'Dynamic') { } elseif ($showtable['Row_format'] == 'Dynamic') {
echo $strDynamic; echo $strDynamic;
} else { } else {
echo $showtable['Row_format']; echo $showtable['Row_format'];

View File

@@ -215,7 +215,7 @@ if (strstr($show_comment, '; InnoDB free') === false) {
} }
} else { } else {
// remove InnoDB comment from end, just the minimal part (*? is non greedy) // remove InnoDB comment from end, just the minimal part (*? is non greedy)
$comment = preg_replace('@; InnoDB free:.*?$@' , '', $show_comment); $comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
} }
// PACK_KEYS: MyISAM or ISAM // PACK_KEYS: MyISAM or ISAM

View File

@@ -75,7 +75,7 @@ while ($row = PMA_DBI_fetch_assoc($result)) {
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
// 3. Get fields // 3. Get fields
$fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', NULL, PMA_DBI_QUERY_STORE); $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
$fields_cnt = PMA_DBI_num_rows($fields_rs); $fields_cnt = PMA_DBI_num_rows($fields_rs);
// Get more complete field information // Get more complete field information
@@ -362,7 +362,7 @@ while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
<?php echo PMA_MYSQL_INT_VERSION >= 40100 ? ' <td>' . (empty($field_charset) ? '' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>') . '</td>' . "\n" : '' ?> <?php echo PMA_MYSQL_INT_VERSION >= 40100 ? ' <td>' . (empty($field_charset) ? '' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>') . '</td>' . "\n" : '' ?>
<td nowrap="nowrap" style="font-size: 70%"><?php echo $attribute; ?></td> <td nowrap="nowrap" style="font-size: 70%"><?php echo $attribute; ?></td>
<td><?php echo (($row['Null'] == 'YES') ? $strYes : $strNo); ?></td> <td><?php echo (($row['Null'] == 'YES') ? $strYes : $strNo); ?></td>
<td nowrap="nowrap"><?php if (isset($row['Default'])) echo $row['Default']; ?></td> <td nowrap="nowrap"><?php if (isset($row['Default'])) { echo $row['Default']; } ?></td>
<td nowrap="nowrap"><?php echo $row['Extra']; ?></td> <td nowrap="nowrap"><?php echo $row['Extra']; ?></td>
<td align="center"> <td align="center">
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode( 'SELECT COUNT(*) AS `' . $strRows . '`, `' . $row['Field'] . '` FROM `' . $table . '` GROUP BY `' . $row['Field'] . '` ORDER BY `' . $row['Field'] . '`' ); ?>"> <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode( 'SELECT COUNT(*) AS `' . $strRows . '`, `' . $row['Field'] . '` FROM `' . $table . '` GROUP BY `' . $row['Field'] . '` ORDER BY `' . $row['Field'] . '`' ); ?>">
@@ -411,7 +411,7 @@ while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
} else { } else {
echo "\n"; echo "\n";
?> ?>
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strAnIndex ,htmlspecialchars($row['Field']))); ?>"> <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strAnIndex, htmlspecialchars($row['Field']))); ?>">
<?php echo $titles['Index']; ?></a> <?php echo $titles['Index']; ?></a>
<?php <?php
} }
@@ -425,7 +425,7 @@ while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
} else { } else {
echo "\n"; echo "\n";
?> ?>
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strAnIndex , htmlspecialchars($row['Field']))); ?>"> <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strAnIndex, htmlspecialchars($row['Field']))); ?>">
<?php echo $titles['Unique']; ?></a> <?php echo $titles['Unique']; ?></a>
<?php <?php
} }
@@ -438,7 +438,7 @@ while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
echo "\n"; echo "\n";
?> ?>
<td align="center" nowrap="nowrap"> <td align="center" nowrap="nowrap">
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strAnIndex , htmlspecialchars($row['Field']))); ?>"> <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strAnIndex, htmlspecialchars($row['Field']))); ?>">
<?php echo $titles['IdxFulltext']; ?></a> <?php echo $titles['IdxFulltext']; ?></a>
</td> </td>
<?php <?php
@@ -461,7 +461,7 @@ while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
echo '</tbody>' . "\n" echo '</tbody>' . "\n"
.'</table>' . "\n"; .'</table>' . "\n";
$checkall_url = 'tbl_properties_structure.php?' . PMA_generate_common_url($db,$table); $checkall_url = 'tbl_properties_structure.php?' . PMA_generate_common_url($db, $table);
?> ?>
<img class="selectallarrow" src="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>" <img class="selectallarrow" src="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
@@ -723,11 +723,9 @@ if ( $cfg['ShowStats'] ) {
<td class="value"><?php <td class="value"><?php
if ($showtable['Row_format'] == 'Fixed') { if ($showtable['Row_format'] == 'Fixed') {
echo $strFixed; echo $strFixed;
} } elseif ($showtable['Row_format'] == 'Dynamic') {
else if ($showtable['Row_format'] == 'Dynamic') {
echo $strDynamic; echo $strDynamic;
} } else {
else {
echo $showtable['Row_format']; echo $showtable['Row_format'];
} }
?></td> ?></td>

View File

@@ -39,8 +39,8 @@ $options_array = array('CASCADE' => 'CASCADE', 'SET_NULL' => 'SET NULL', 'NO_ACT
* *
* @access public * @access public
*/ */
function PMA_generate_dropdown($dropdown_question,$radio_name,$choices,$selected_value) { function PMA_generate_dropdown($dropdown_question, $radio_name, $choices, $selected_value)
{
echo $dropdown_question . '&nbsp;&nbsp;'; echo $dropdown_question . '&nbsp;&nbsp;';
echo '<select name="' . $radio_name . '">' . "\n"; echo '<select name="' . $radio_name . '">' . "\n";
@@ -281,7 +281,7 @@ if ($cfgRelation['relwork'] || $tbl_type=='INNODB') {
} }
// [0] of the row is the name // [0] of the row is the name
$tab_rs = PMA_DBI_query($tab_query, NULL, PMA_DBI_QUERY_STORE); $tab_rs = PMA_DBI_query($tab_query, null, PMA_DBI_QUERY_STORE);
$selectboxall['nix'] = '--'; $selectboxall['nix'] = '--';
$selectboxall_innodb['nix'] = '--'; $selectboxall_innodb['nix'] = '--';
@@ -290,7 +290,7 @@ if ($cfgRelation['relwork'] || $tbl_type=='INNODB') {
PMA_DBI_select_db($db); PMA_DBI_select_db($db);
// need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli // need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli
$fi_rs = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($curr_table[0]) . ';', NULL, PMA_DBI_QUERY_STORE); $fi_rs = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($curr_table[0]) . ';', null, PMA_DBI_QUERY_STORE);
if ($fi_rs && PMA_DBI_num_rows($fi_rs) > 0) { if ($fi_rs && PMA_DBI_num_rows($fi_rs) > 0) {
$seen_a_primary = FALSE; $seen_a_primary = FALSE;
while ($curr_field = PMA_DBI_fetch_assoc($fi_rs)) { while ($curr_field = PMA_DBI_fetch_assoc($fi_rs)) {
@@ -337,7 +337,7 @@ if ($cfgRelation['relwork'] || $tbl_type=='INNODB') {
PMA_DBI_select_db($db); PMA_DBI_select_db($db);
// need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli // need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli
$fi_rs = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($curr_table[0]) . ';', NULL, PMA_DBI_QUERY_STORE); $fi_rs = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($curr_table[0]) . ';', null, PMA_DBI_QUERY_STORE);
if ($fi_rs && PMA_DBI_num_rows($fi_rs) > 0) { if ($fi_rs && PMA_DBI_num_rows($fi_rs) > 0) {
while ($curr_field = PMA_DBI_fetch_assoc($fi_rs)) { while ($curr_field = PMA_DBI_fetch_assoc($fi_rs)) {
$field_full = $db . '.' . $curr_field['Table'] . '.' . $curr_field['Column_name']; $field_full = $db . '.' . $curr_field['Table'] . '.' . $curr_field['Column_name'];
@@ -358,7 +358,7 @@ if ($cfgRelation['relwork'] || $tbl_type=='INNODB') {
// Now find out the columns of our $table // Now find out the columns of our $table
// need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli // need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli
$col_rs = PMA_DBI_try_query('SHOW COLUMNS FROM ' . PMA_backquote($table) . ';', NULL, PMA_DBI_QUERY_STORE); $col_rs = PMA_DBI_try_query('SHOW COLUMNS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
if ($col_rs && PMA_DBI_num_rows($col_rs) > 0) { if ($col_rs && PMA_DBI_num_rows($col_rs) > 0) {
while ($row = PMA_DBI_fetch_assoc($col_rs)) { while ($row = PMA_DBI_fetch_assoc($col_rs)) {

View File

@@ -8,7 +8,7 @@
require_once('./libraries/common.lib.php'); require_once('./libraries/common.lib.php');
// Check parameters // Check parameters
PMA_checkParameters(array('db','table','goto')); PMA_checkParameters(array('db', 'table', 'goto'));
PMA_DBI_select_db($db); PMA_DBI_select_db($db);
@@ -122,7 +122,9 @@ $message = '';
foreach ($loop_array AS $primary_key_index => $enc_primary_key) { foreach ($loop_array AS $primary_key_index => $enc_primary_key) {
// skip fields to be ignored // skip fields to be ignored
if (!$using_key && isset($GLOBALS['insert_ignore_' . $enc_primary_key])) continue; if (!$using_key && isset($GLOBALS['insert_ignore_' . $enc_primary_key])) {
continue;
}
// Restore the "primary key" to a convenient format // Restore the "primary key" to a convenient format
$primary_key = urldecode($enc_primary_key); $primary_key = urldecode($enc_primary_key);
@@ -155,9 +157,9 @@ foreach ($loop_array AS $primary_key_index => $enc_primary_key) {
if (empty($me_funcs[$encoded_key])) { if (empty($me_funcs[$encoded_key])) {
$cur_value = $val . ', '; $cur_value = $val . ', ';
} else if (preg_match('@^(UNIX_TIMESTAMP)$@', $me_funcs[$encoded_key]) && $val != '\'\'') { } elseif (preg_match('@^(UNIX_TIMESTAMP)$@', $me_funcs[$encoded_key]) && $val != '\'\'') {
$cur_value = $me_funcs[$encoded_key] . '(' . $val . '), '; $cur_value = $me_funcs[$encoded_key] . '(' . $val . '), ';
} else if (preg_match('@^(NOW|CURDATE|CURTIME|UNIX_TIMESTAMP|RAND|USER|LAST_INSERT_ID)$@', $me_funcs[$encoded_key])) { } elseif (preg_match('@^(NOW|CURDATE|CURTIME|UNIX_TIMESTAMP|RAND|USER|LAST_INSERT_ID)$@', $me_funcs[$encoded_key])) {
$cur_value = $me_funcs[$encoded_key] . '(), '; $cur_value = $me_funcs[$encoded_key] . '(), ';
} else { } else {
$cur_value = $me_funcs[$encoded_key] . '(' . $val . '), '; $cur_value = $me_funcs[$encoded_key] . '(' . $val . '), ';
@@ -166,17 +168,17 @@ foreach ($loop_array AS $primary_key_index => $enc_primary_key) {
if ($is_insert) { if ($is_insert) {
// insert, no need to add column // insert, no need to add column
$valuelist .= $cur_value; $valuelist .= $cur_value;
} else if (isset($me_fields_null_prev) && isset($me_fields_null_prev[$encoded_key]) && !isset($me_fields_null[$encoded_key])) { } elseif (isset($me_fields_null_prev) && isset($me_fields_null_prev[$encoded_key]) && !isset($me_fields_null[$encoded_key])) {
// field had the null checkbox // field had the null checkbox
// field no longer has the null checkbox // field no longer has the null checkbox
// field does not have the same value // field does not have the same value
$valuelist .= PMA_backquote($key) . ' = ' . $cur_value; $valuelist .= PMA_backquote($key) . ' = ' . $cur_value;
} else if (empty($me_funcs[$encoded_key]) } elseif (empty($me_funcs[$encoded_key])
&& isset($me_fields_prev) && isset($me_fields_prev[$encoded_key]) && isset($me_fields_prev) && isset($me_fields_prev[$encoded_key])
&& ("'" . PMA_sqlAddslashes(urldecode($me_fields_prev[$encoded_key])) . "'" == $val)) { && ("'" . PMA_sqlAddslashes(urldecode($me_fields_prev[$encoded_key])) . "'" == $val)) {
// No change for this column and no MySQL function is used -> next column // No change for this column and no MySQL function is used -> next column
continue; continue;
} else if (!empty($val)) { } elseif (!empty($val)) {
// TODO: avoid setting a field to NULL when it's already NULL // TODO: avoid setting a field to NULL when it's already NULL
$valuelist .= PMA_backquote($key) . ' = ' . $cur_value; $valuelist .= PMA_backquote($key) . ' = ' . $cur_value;
} }

View File

@@ -49,7 +49,7 @@ if (!isset($param) || $param[0] == '') {
$err_url = $goto . '?' . PMA_generate_common_url($db, $table); $err_url = $goto . '?' . PMA_generate_common_url($db, $table);
// Gets the list and number of fields // Gets the list and number of fields
$result = PMA_DBI_query('SHOW' . (PMA_MYSQL_INT_VERSION >= 40100 ? ' FULL' : '') . ' FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); $result = PMA_DBI_query('SHOW' . (PMA_MYSQL_INT_VERSION >= 40100 ? ' FULL' : '') . ' FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
$fields_cnt = PMA_DBI_num_rows($result); $fields_cnt = PMA_DBI_num_rows($result);
// rabue: we'd better ensure, that all arrays are empty. // rabue: we'd better ensure, that all arrays are empty.
$fields_list = $fields_null = $fields_type = $fields_collation = array(); $fields_list = $fields_null = $fields_type = $fields_collation = array();

View File

@@ -22,12 +22,12 @@ require_once('./libraries/db_table_exists.lib.php');
* Get the list of the fields of the current table * Get the list of the fields of the current table
*/ */
PMA_DBI_select_db($db); PMA_DBI_select_db($db);
$table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table), NULL, PMA_DBI_QUERY_STORE); $table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table), null, PMA_DBI_QUERY_STORE);
if (isset($primary_key)) { if (isset($primary_key)) {
$result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';', NULL, PMA_DBI_QUERY_STORE); $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';', null, PMA_DBI_QUERY_STORE);
$row = PMA_DBI_fetch_assoc($result); $row = PMA_DBI_fetch_assoc($result);
} else { } else {
$result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1;', NULL, PMA_DBI_QUERY_STORE); $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1;', null, PMA_DBI_QUERY_STORE);
$row = PMA_DBI_fetch_assoc($result); $row = PMA_DBI_fetch_assoc($result);
} }
@@ -87,7 +87,7 @@ if (!isset($resize)) {
if ($ratioWidth < $ratioHeight){ if ($ratioWidth < $ratioHeight){
$destWidth = $srcWidth/$ratioHeight; $destWidth = $srcWidth/$ratioHeight;
$destHeight = $newHeight; $destHeight = $newHeight;
}else{ } else {
$destWidth = $newWidth; $destWidth = $newWidth;
$destHeight = $srcHeight/$ratioWidth; $destHeight = $srcHeight/$ratioWidth;
} }
@@ -101,7 +101,7 @@ if (!isset($resize)) {
ImageCopyResampled( $destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight ); ImageCopyResampled( $destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight );
if ($resize == 'jpeg') { if ($resize == 'jpeg') {
ImageJPEG( $destImage,'',75 ); ImageJPEG( $destImage, '', 75 );
} }
if ($resize == 'png') { if ($resize == 'png') {
ImagePNG( $destImage); ImagePNG( $destImage);