For Lo�c: Coding standards

This commit is contained in:
Alexander M. Turek
2002-08-21 09:30:53 +00:00
parent 73ce610905
commit 7184bb81c8
12 changed files with 179 additions and 164 deletions

View File

@@ -5,6 +5,12 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2002-08-21 Lo<4C>c Chapeaux <lolo@phpheaven.net>
* config.inc.php3, db_details.php3, db_details_export.php3,
db_details_qbe.php3, Documentation.html, ldi_check.php3, ldi_table.php3,
tbl_dump.php3, tbl_properties_export.php3, tbl_query_box.php3,
libraries/charset_conversion.lib.php3: Coding standards.
2002-08-21 Michal Cihar <nijel@users.sourceforge.net> 2002-08-21 Michal Cihar <nijel@users.sourceforge.net>
* libraries/common.lib.php3: revised to fit coding standards (by Lo<4C>c) and * libraries/common.lib.php3: revised to fit coding standards (by Lo<4C>c) and
added documentation about parameters for PMA_showMySQLDocu() added documentation about parameters for PMA_showMySQLDocu()

View File

@@ -1141,7 +1141,8 @@ $cfg['PmaAbsoluteUri'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
<dt><b>$cfg['MySQLManualBase']</b> string</dt> <dt><b>$cfg['MySQLManualBase']</b> string</dt>
<dd> <dd>
If set to an URL which points to the MySQL documentation (type depends If set to an URL which points to the MySQL documentation (type depends
on $cfg['MySQLManualType']), appropriate help links are generated. on <tt>$cfg['MySQLManualType']</tt>), appropriate help links are
generated.
<br /> <br />
See <a href="http://www.mysql.com/documentation/index.html">MySQL See <a href="http://www.mysql.com/documentation/index.html">MySQL
Documentation page</a> for more information about MySQL manuals and Documentation page</a> for more information about MySQL manuals and
@@ -1154,9 +1155,9 @@ $cfg['PmaAbsoluteUri'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
Type of MySQL documentation: Type of MySQL documentation:
<ul> <ul>
<li>old - old style used in phpMyAdmin 2.3.0 and sooner</li> <li>old - old style used in phpMyAdmin 2.3.0 and sooner</li>
<li>searchable - "Searchable, with user comments"</li> <li>searchable - &quot;Searchable, with user comments&quot;</li>
<li>chapters - "HTML, one page per chapter"</li> <li>chapters - &quot;HTML, one page per chapter&quot;</li>
<li>big - "HTML, all on one page"</li> <li>big - &quot;HTML, all on one page&quot;</li>
<li>none - do not show documentation links</li> <li>none - do not show documentation links</li>
</ul> </ul>
<br /><br /> <br /><br />
@@ -1200,7 +1201,8 @@ $cfg['PmaAbsoluteUri'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
<dt><b>$cfg['RecodingEngine'] </b>string</dt> <dt><b>$cfg['RecodingEngine'] </b>string</dt>
<dd> <dd>
You can select here which functions will be used for charset conversion. You can select here which functions will be used for charset
conversion.
Possible values are:<br /> Possible values are:<br />
<ul> <ul>
<li>auto - automatically use available one (first is tested <li>auto - automatically use available one (first is tested
@@ -1209,6 +1211,7 @@ $cfg['PmaAbsoluteUri'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
<li>recode - use recode_string function</li> <li>recode - use recode_string function</li>
</ul> </ul>
Default is auto. Default is auto.
<br /><br />
</dd> </dd>
<dt><b>$cfg['AvailableCharsets'] </b>array</dt> <dt><b>$cfg['AvailableCharsets'] </b>array</dt>
@@ -1303,8 +1306,8 @@ $cfg['PmaAbsoluteUri'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
<b>$cfg['TextareaAutoSelect'] </b>boolean<br /> <b>$cfg['TextareaAutoSelect'] </b>boolean<br />
</dt> </dt>
<dd> <dd>
Defines if the whole textarea of the query box will be selected Defines if the whole textarea of the query box will be selected on
on click. click.
<br /><br /> <br /><br />
</dd> </dd>
@@ -2118,7 +2121,7 @@ $cfg['PmaAbsoluteUri'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
<p> <p>
<b>[6.5] How can I restore (upload) my database or table using a dump? <b>[6.5] How can I restore (upload) my database or table using a dump?
How can I run a &quot;.sql&quot; file?</b> How can I run a &quot;.sql&quot; file?</b>
<br /> <br />
Click on a database name in the left frame, the properties will be Click on a database name in the left frame, the properties will be
local displayed. Then in the &quot;Run SQL query&quot; section, type in local displayed. Then in the &quot;Run SQL query&quot; section, type in

View File

@@ -234,11 +234,11 @@ $cfg['MySQLManualBase'] = 'http://www.mysql.com/doc/en';
/** /**
* Type of MySQL documentation: * Type of MySQL documentation:
* old - old style used in phpMyAdmin 2.3.0 and sooner * old - old style used in phpMyAdmin 2.3.0 and sooner
* searchable - "Searchable, with user comments" * searchable - "Searchable, with user comments"
* chapters - "HTML, one page per chapter" * chapters - "HTML, one page per chapter"
* big - "HTML, all on one page" * big - "HTML, all on one page"
* none - do not show documentation links * none - do not show documentation links
*/ */
$cfg['MySQLManualType'] = 'searchable'; $cfg['MySQLManualType'] = 'searchable';

View File

@@ -45,6 +45,10 @@ $is_upload = (PMA_PHP_INT_VERSION >= 40000 && function_exists('ini_get'))
? ((strtolower(ini_get('file_uploads')) == 'on' || ini_get('file_uploads') == 1) && intval(ini_get('upload_max_filesize'))) ? ((strtolower(ini_get('file_uploads')) == 'on' || ini_get('file_uploads') == 1) && intval(ini_get('upload_max_filesize')))
// loic1: php 3.0.15 and lower bug -> always enabled // loic1: php 3.0.15 and lower bug -> always enabled
: (PMA_PHP_INT_VERSION < 30016 || intval(@get_cfg_var('upload_max_filesize'))); : (PMA_PHP_INT_VERSION < 30016 || intval(@get_cfg_var('upload_max_filesize')));
$auto_sel = ($cfg['TextareaAutoSelect'])
? "\n" . ' onfocus="if (typeof(document.layers) == \'undefined\' || typeof(textarea_selected) == \'undefined\') {textarea_selected = 1; this.form.elements[\'sql_query\'].select();}"'
: '';
?> ?>
<!-- Query box, sql file loader and bookmark support --> <!-- Query box, sql file loader and bookmark support -->
<a name="querybox"></a> <a name="querybox"></a>
@@ -61,11 +65,7 @@ $is_upload = (PMA_PHP_INT_VERSION >= 40000 && function_exists('ini_get'))
<input type="hidden" name="prev_sql_query" value="<?php echo ((!empty($query_to_display)) ? urlencode($query_to_display) : ''); ?>" /> <input type="hidden" name="prev_sql_query" value="<?php echo ((!empty($query_to_display)) ? urlencode($query_to_display) : ''); ?>" />
<?php echo sprintf($strRunSQLQuery, $db) . ' ' . PMA_showMySQLDocu('Reference', 'SELECT'); ?>&nbsp;:<br /> <?php echo sprintf($strRunSQLQuery, $db) . ' ' . PMA_showMySQLDocu('Reference', 'SELECT'); ?>&nbsp;:<br />
<div style="margin-bottom: 5px"> <div style="margin-bottom: 5px">
<textarea name="sql_query" cols="<?php echo $cfg['TextareaCols'] * 2; ?>" rows="<?php echo $cfg['TextareaRows']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>"<?php <textarea name="sql_query" cols="<?php echo $cfg['TextareaCols'] * 2; ?>" rows="<?php echo $cfg['TextareaRows']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>"<?php echo $auto_sel; ?>>
if ($cfg['TextareaAutoSelect']) {
echo "\n" . ' onfocus="if (typeof(document.layers) == \'undefined\' || typeof(textarea_selected) == \'undefined\') {textarea_selected = 1; this.form.elements[\'sql_query\'].select();}"';
}
?>>
<?php echo ((!empty($query_to_display)) ? htmlspecialchars($query_to_display) : ''); ?> <?php echo ((!empty($query_to_display)) ? htmlspecialchars($query_to_display) : ''); ?>
</textarea><br /> </textarea><br />
<input type="checkbox" name="show_query" value="1" id="checkbox_show_query" checked="checked" />&nbsp; <input type="checkbox" name="show_query" value="1" id="checkbox_show_query" checked="checked" />&nbsp;

View File

@@ -108,28 +108,28 @@ echo "\n";
<td<?php echo $colspan; ?>> <td<?php echo $colspan; ?>>
<input type="checkbox" name="asfile" value="sendit" id="checkbox_dump_asfile" onclick="return checkTransmitDump(this.form, 'transmit')" /> <input type="checkbox" name="asfile" value="sendit" id="checkbox_dump_asfile" onclick="return checkTransmitDump(this.form, 'transmit')" />
<label for="checkbox_dump_asfile"><?php echo $strSend; ?></label> <label for="checkbox_dump_asfile"><?php echo $strSend; ?></label>
<?php <?php
if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) { // charset of file
$temp_charset = reset($cfg['AvailableCharsets']); if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
echo "\n, " . $strCharsetOfFile . "\n" $temp_charset = reset($cfg['AvailableCharsets']);
. ' <select name="charset_of_file" size="1">' . "\n" echo "\n" . ' , ' . $strCharsetOfFile . "\n"
. ' <option value="' . $temp_charset . '"'; . ' <select name="charset_of_file" size="1">' . "\n"
. ' <option value="' . $temp_charset . '"';
if ($temp_charset == $charset) {
echo ' selected="selected"';
}
echo '>' . $temp_charset . '</option>' . "\n";
while ($temp_charset = next($cfg['AvailableCharsets'])) {
echo ' <option value="' . $temp_charset . '"';
if ($temp_charset == $charset) { if ($temp_charset == $charset) {
echo ' selected="selected"'; echo ' selected="selected"';
} }
echo '>' . $temp_charset . '</option>' . "\n"; echo '>' . $temp_charset . '</option>' . "\n";
while ($temp_charset = next($cfg['AvailableCharsets'])) { } // end while
echo ' <option value="' . $temp_charset . '"'; echo ' </select>';
if ($temp_charset == $charset) { } // end if
echo ' selected="selected"'; echo "\n";
}
echo '>' . $temp_charset . '</option>' . "\n";
} // end while
echo ' </select>';
} // end if
echo "\n";
?>
<?php
// zip, gzip and bzip2 encode features // zip, gzip and bzip2 encode features
if (PMA_PHP_INT_VERSION >= 40004) { if (PMA_PHP_INT_VERSION >= 40004) {
$is_zip = (isset($cfg['ZipDump']) && $cfg['ZipDump'] && @function_exists('gzcompress')); $is_zip = (isset($cfg['ZipDump']) && $cfg['ZipDump'] && @function_exists('gzcompress'));

View File

@@ -775,15 +775,17 @@ if (isset($Field) && count($Field) > 0) {
// if there was nothing starting with '=' we have to use all we got in // if there was nothing starting with '=' we have to use all we got in
// the first place // the first place (we can't use an "&=" assignment because of PHP3
// compliance)
if (count($wheretabs) == 0) { if (count($wheretabs) == 0) {
$wheretabs = &$where; $wheretabs = $where;
} }
// when we want the fastest SELECT Statement, it would be great // When we want the fastest SELECT Statement, it would be great
// to have one Table as $master (that is the one that will be in FROM ... contrary to the // to have one Table as $master (that is the one that will be in
// rest which will just show in the LEFT JOIN lines) that has a good whereclause and is // FROM ... contrary to the rest which will just show in the LEFT JOIN
// FOREIGN table to as many tables as possible // lines) that has a good whereclause and is FOREIGN table to as many
// tables as possible
// We will need this a few times: // We will need this a few times:
$incrit = '(\'' . implode('\', \'', $alltabs) . '\')'; $incrit = '(\'' . implode('\', \'', $alltabs) . '\')';
@@ -791,12 +793,12 @@ if (isset($Field) && count($Field) > 0) {
$rel_query = 'SELECT foreign_table AS wer, COUNT(master_table) AS hits' $rel_query = 'SELECT foreign_table AS wer, COUNT(master_table) AS hits'
. ' FROM ' . PMA_backquote($cfgRelation['relation']) . ' FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . $db . '\'' . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND foreign_db = \'' . $db . '\'' . ' AND foreign_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND master_table IN ' . $incrit . ' AND master_table IN ' . $incrit
. ' AND foreign_table IN ' . $incrit; . ' AND foreign_table IN ' . $incrit;
if (!empty($column)) { if (!empty($column)) {
$rel_query .= ' AND foreign_field = \'' . $column . '\''; $rel_query .= ' AND foreign_field = \'' . PMA_sqlAddslashes($column) . '\'';
} }
$rel_query .= ' GROUP BY foreign_table ORDER BY hits DESC'; $rel_query .= ' GROUP BY foreign_table ORDER BY hits DESC';
$relations = PMA_query_as_cu($rel_query); $relations = PMA_query_as_cu($rel_query);
@@ -804,8 +806,9 @@ if (isset($Field) && count($Field) > 0) {
$bpm = FALSE; $bpm = FALSE;
while ($row = PMA_mysql_fetch_array($relations)) { while ($row = PMA_mysql_fetch_array($relations)) {
// in case we will not find any foreign table that is also in the // in case we will not find any foreign table that is also in the
// where clause AND we do not find a master table later, then we // where clause AND we do not find a master table later, then we
// just use the most popular foreign table (allthough chances are remote) // just use the most popular foreign table (allthough chances are
// remote)
if (!isset($master)) { if (!isset($master)) {
$master = $row['wer']; $master = $row['wer'];
} }
@@ -821,41 +824,42 @@ if (isset($Field) && count($Field) > 0) {
} }
} // end while } // end while
// if we didn't find any best possible master at this point, then we will settle // if we didn't find any best possible master at this point, then we
// for the most popular master_table in the whereclause (sbpm = second best possible master ;-) // will settle for the most popular master_table in the where clause
// or if that fails as well, then rather the most popular master table than the // (sbpm = second best possible master ;-) or if that fails as well,
// most popular foreign_table // then rather the most popular master table than the most popular
// foreign_table
if ($bpm == FALSE) { if ($bpm == FALSE) {
$sbpm = FALSE; $sbpm = FALSE;
// easier to just save any bad master we had and use it if we do not // Easier to just save any bad master we had and use it if we do
// find anything better // not find anything better
if (isset($master)) { if (isset($master)) {
$badmaster = $master; $badmaster = $master;
unset($master); unset($master);
} }
$rel_query = 'SELECT master_table AS wer, COUNT(foreign_table) AS hits' $rel_query = 'SELECT master_table AS wer, COUNT(foreign_table) AS hits'
. ' FROM ' . PMA_backquote($cfgRelation['relation']) . ' FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . $db . '\'' . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND foreign_db = \'' . $db . '\'' . ' AND foreign_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND master_table IN ' . $incrit . ' AND master_table IN ' . $incrit
. ' AND foreign_table IN ' . $incrit; . ' AND foreign_table IN ' . $incrit;
if (!empty($column)) { if (!empty($column)) {
$rel_query .= ' AND master_field = \'' . $column . '\''; $rel_query .= ' AND master_field = \'' . PMA_sqlAddslashes($column) . '\'';
} }
$rel_query .= ' GROUP BY master_table ORDER BY hits DESC'; $rel_query .= ' GROUP BY master_table ORDER BY hits DESC';
$relations = PMA_query_as_cu($rel_query); $relations = PMA_query_as_cu($rel_query);
while ($row = PMA_mysql_fetch_array($relations)) { while ($row = PMA_mysql_fetch_array($relations)) {
// we want the first one (highest number of hits) or the first one // we want the first one (highest number of hits) or the first one
// that is in the WHERE clause // that is in the WHERE clause
if (!isset($master)) { if (!isset($master)) {
$master = $row['wer']; $master = $row['wer'];
} }
if ($sbpm == FALSE) { if ($sbpm == FALSE) {
while (list($key, $value) = each($wheretabs)) { while (list($key, $value) = each($wheretabs)) {
if ($row['wer'] == $key) { if ($row['wer'] == $key) {
$master = $row['wer']; $master = $row['wer'];
$sbpm = TRUE; $sbpm = TRUE;
break; break;
} }
} // end while } // end while
@@ -863,15 +867,15 @@ if (isset($Field) && count($Field) > 0) {
} }
} // end while } // end while
if (!isset($master) && isset($badmaster)) { if (!isset($master) && isset($badmaster)) {
$master = $badmaster; $master = $badmaster;
unset($badmaster); unset($badmaster);
} }
} // end if bpm==FALSE } // end if bpm == FALSE
// if we still don't have a master at this point we might as well // if we still don't have a master at this point we might as well
// give up ;-) // give up ;-)
if (isset ($master) && $master != '') { if (isset($master) && $master != '') {
$qry_from = PMA_backquote($master); $qry_from = PMA_backquote($master);
// now we want one Array that has all tablenames but master // now we want one Array that has all tablenames but master
@@ -883,20 +887,20 @@ if (isset($Field) && count($Field) > 0) {
} // end while } // end while
// everything but the first table // everything but the first table
$incrit_s = '(\'' . implode('\', \'', $reltabs) . '\')'; $incrit_s = '(\'' . implode('\', \'', $reltabs) . '\')';
$rel_query = 'SELECT *' $rel_query = 'SELECT *'
. ' FROM ' . PMA_backquote($cfgRelation['relation']) . ' FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . $db . '\'' . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND foreign_db = \'' . $db . '\''; . ' AND foreign_db = \'' . PMA_sqlAddslashes($db) . '\'';
if($bpm == TRUE){ // which means that my $master is a foreign table if ($bpm == TRUE) { // means that my $master is a foreign table
$rel_query .= ' AND master_table IN ' . $incrit_s $rel_query .= ' AND master_table IN ' . $incrit_s
. ' AND foreign_table IN ' . $incrit; . ' AND foreign_table IN ' . $incrit;
if (!empty($column)) { if (!empty($column)) {
$rel_query .= ' AND foreign_field = \'' . $column . '\''; $rel_query .= ' AND foreign_field = \'' . PMA_sqlAddslashes($column) . '\'';
} }
} else { } else {
$rel_query .= ' AND foreign_table IN ' . $incrit_s $rel_query .= ' AND foreign_table IN ' . $incrit_s
. ' AND master_table IN ' . $incrit; . ' AND master_table IN ' . $incrit;
if (!empty($column)) { if (!empty($column)) {
$rel_query .= ' AND master_field = \'' . $column . '\''; $rel_query .= ' AND master_field = \'' . $column . '\'';
} }
@@ -912,7 +916,7 @@ if (isset($Field) && count($Field) > 0) {
PMA_mysql_select_db($db); PMA_mysql_select_db($db);
} }
if($bpm == TRUE){ // which means that my $master is a foreign table if ($bpm == TRUE) { // means that my $master is a foreign table
while ($row = PMA_mysql_fetch_array($relations)) { while ($row = PMA_mysql_fetch_array($relations)) {
$master_table = $row['master_table']; $master_table = $row['master_table'];
if ($rel[$master_table]['mcon'] == 0) { if ($rel[$master_table]['mcon'] == 0) {
@@ -942,8 +946,7 @@ if (isset($Field) && count($Field) > 0) {
} // end while } // end while
} }
// possibly we still don't have all - there might be some that are // possibly we still don't have all - there might be some that are
// only found in relation to one of those that we // only found in relation to one of those that we already have
// already have
if ($master != '') { if ($master != '') {
$found[] = $master; $found[] = $master;
$qry_from = PMA_backquote($master); $qry_from = PMA_backquote($master);
@@ -957,8 +960,8 @@ if (isset($Field) && count($Field) > 0) {
} }
} // end while } // end while
if (count($rest) > 0) { if (count($rest) > 0) {
$incrit_d = '(\'' . implode('\', \'', $found) . '\')'; $incrit_d = '(\'' . implode('\', \'', $found) . '\')';
$incrit_s = '(\'' . implode('\', \'', $rest) . '\')'; $incrit_s = '(\'' . implode('\', \'', $rest) . '\')';
if ($bpm == TRUE) { if ($bpm == TRUE) {
$from_table = 'foreign_table'; $from_table = 'foreign_table';
$from_field = 'foreign_field'; $from_field = 'foreign_field';
@@ -968,17 +971,16 @@ if (isset($Field) && count($Field) > 0) {
$from_field = 'master_field'; $from_field = 'master_field';
$to_table = 'foreign_table'; $to_table = 'foreign_table';
} }
$rel_query = 'SELECT *' $rel_query = 'SELECT *'
. ' FROM ' . PMA_backquote($cfgRelation['relation']) . ' FROM ' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . $db . '\'' . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND foreign_db = \'' . $db . '\'' . ' AND foreign_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND ' . $from_table . ' IN ' . $incrit_s . ' AND ' . $from_table . ' IN ' . $incrit_s
. ' AND ' . $to_table . ' IN ' . $incrit_d; . ' AND ' . $to_table . ' IN ' . $incrit_d;
if (!empty($column)) { if (!empty($column)) {
$rel_query .= ' AND ' . $from_field . ' = \'' . $column . '\''; $rel_query .= ' AND ' . $from_field . ' = \'' . PMA_sqlAddslashes($column) . '\'';
} }
if (isset($dbh)) { if (isset($dbh)) {
PMA_mysql_select_db($cfgRelation['db'], $dbh); PMA_mysql_select_db($cfgRelation['db'], $dbh);
$relations = @PMA_mysql_query($rel_query, $dbh) or PMA_mysqlDie(PMA_mysql_error($dbh), $rel_query, '', $err_url_0); $relations = @PMA_mysql_query($rel_query, $dbh) or PMA_mysqlDie(PMA_mysql_error($dbh), $rel_query, '', $err_url_0);
@@ -1007,7 +1009,7 @@ if (isset($Field) && count($Field) > 0) {
// in extreme cases we hadn't found a master yet, so // in extreme cases we hadn't found a master yet, so
// let's use the one we found now // let's use the one we found now
if ($master == '') { if ($master == '') {
$master = $found_table; $master = $found_table;
} }
if ($other_table == $master) { if ($other_table == $master) {
$rel[$found_table]['mcon'] = 1; $rel[$found_table]['mcon'] = 1;

View File

@@ -36,7 +36,7 @@ if (isset($btnLDI) && ($textfile != 'none')) {
if (function_exists('PMA_kanji_file_conv')) { if (function_exists('PMA_kanji_file_conv')) {
$textfile = PMA_kanji_file_conv($textfile, $knjenc, isset($xkana) ? $xkana : ''); $textfile = PMA_kanji_file_conv($textfile, $knjenc, isset($xkana) ? $xkana : '');
} }
// Convert the file's charset if necessary // Convert the file's charset if necessary
if ($cfg['AllowAnywhereRecoding'] && $allow_recoding if ($cfg['AllowAnywhereRecoding'] && $allow_recoding
&& isset($charset_of_file) && $charset_of_file != $charset) { && isset($charset_of_file) && $charset_of_file != $charset) {
@@ -102,7 +102,7 @@ if (isset($btnLDI) && ($textfile != 'none')) {
$sql_query = $query; $sql_query = $query;
} }
// Set an empty sub_part to avoid an undefined variable. // Set an empty sub_part to avoid an undefined variable.
// We could also rename the ldi* scripts // We could also rename the ldi* scripts
// to tbl_properties_ldi* to improve consistency with the other sub-pages. // to tbl_properties_ldi* to improve consistency with the other sub-pages.
// //

View File

@@ -26,31 +26,31 @@ require('./tbl_properties_table_info.php3');
<td><?php echo $strLocationTextfile; ?></td> <td><?php echo $strLocationTextfile; ?></td>
<td colspan="2"><input type="file" name="textfile" /></td> <td colspan="2"><input type="file" name="textfile" /></td>
</tr> </tr>
<?php <?php
if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) { if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
$temp_charset = reset($cfg['AvailableCharsets']); $temp_charset = reset($cfg['AvailableCharsets']);
echo '<tr>' . "\n" echo ' <tr>' . "\n"
. ' <td>'.$strCharsetOfFile . "</td>\n" . ' <td>' . $strCharsetOfFile . '</td>' . "\n"
. ' <td colspan="2">'. "\n" . ' <td colspan="2">' . "\n"
. ' <select name="charset_of_file" size="1">' . "\n" . ' <select name="charset_of_file" size="1">' . "\n"
. ' <option value="' . $temp_charset . '"'; . ' <option value="' . $temp_charset . '"';
if ($temp_charset == $charset) {
echo ' selected="selected"';
}
echo '>' . $temp_charset . '</option>' . "\n";
while ($temp_charset = next($cfg['AvailableCharsets'])) {
echo ' <option value="' . $temp_charset . '"';
if ($temp_charset == $charset) { if ($temp_charset == $charset) {
echo ' selected="selected"'; echo ' selected="selected"';
} }
echo '>' . $temp_charset . '</option>' . "\n"; echo '>' . $temp_charset . '</option>' . "\n";
while ($temp_charset = next($cfg['AvailableCharsets'])) { } // end while
echo ' <option value="' . $temp_charset . '"'; echo ' </select>' . "\n";
if ($temp_charset == $charset) { echo ' </td>' . "\n";
echo ' selected="selected"'; echo ' </tr>';
} } // end if
echo '>' . $temp_charset . '</option>' . "\n"; echo "\n";
} // end while ?>
echo ' </select>' . "\n";
echo ' </td>' . "\n";
echo ' </tr>' . "\n";
} // end if
echo "\n";
?>
<tr> <tr>
<td><?php echo $strReplaceTable; ?></td> <td><?php echo $strReplaceTable; ?></td>
<td><input type="checkbox" name="replace" value="REPLACE" id="checkbox_replace" /><?php echo $strReplace; ?></td> <td><input type="checkbox" name="replace" value="REPLACE" id="checkbox_replace" /><?php echo $strReplace; ?></td>

View File

@@ -31,32 +31,34 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
$suffix = '.so'; $suffix = '.so';
} }
// Initialize configuration for default, if not set: // Initializes configuration for default, if not set:
if (!isset($cfg['RecodingEngine'])) $cfg['RecodingEngine'] = 'auto'; if (!isset($cfg['RecodingEngine'])) {
$cfg['RecodingEngine'] = 'auto';
}
if ($cfg['RecodingEngine'] == 'recode') { if ($cfg['RecodingEngine'] == 'recode') {
if (! @extension_loaded('recode')) { if (!@extension_loaded('recode')) {
dl('recode' . $suffix); dl('recode' . $suffix);
if (!@extension_loaded('recode')) { if (!@extension_loaded('recode')) {
echo $strCantLoadRecodeIconv; echo $strCantLoadRecodeIconv;
exit(); exit();
} }
} }
$PMA_recoding_engine = 'recode'; $PMA_recoding_engine = 'recode';
} elseif ($cfg['RecodingEngine'] == 'iconv') { } else if ($cfg['RecodingEngine'] == 'iconv') {
if (! @extension_loaded('iconv')) { if (!@extension_loaded('iconv')) {
dl('iconv' . $suffix); dl('iconv' . $suffix);
if (!@extension_loaded('iconv')) { if (!@extension_loaded('iconv')) {
echo $strCantLoadRecodeIconv; echo $strCantLoadRecodeIconv;
exit(); exit();
} }
} }
$PMA_recoding_engine = 'iconv'; $PMA_recoding_engine = 'iconv';
} else { } else {
if (@extension_loaded('iconv')) { if (@extension_loaded('iconv')) {
$PMA_recoding_engine = 'iconv'; $PMA_recoding_engine = 'iconv';
} elseif (@extension_loaded('recode')) { } else if (@extension_loaded('recode')) {
$PMA_recoding_engine = 'recode'; $PMA_recoding_engine = 'recode';
} else { } else {
dl('iconv' . $suffix); dl('iconv' . $suffix);
if (!@extension_loaded('iconv')) { if (!@extension_loaded('iconv')) {
@@ -68,31 +70,33 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
$PMA_recoding_engine = 'recode'; $PMA_recoding_engine = 'recode';
} }
} else { } else {
$PMA_recoding_engine = 'iconv'; $PMA_recoding_engine = 'iconv';
} }
} }
} }
} // end load recode/iconv extension } // end load recode/iconv extension
define('PMA_CHARSET_NONE', 0); define('PMA_CHARSET_NONE', 0);
define('PMA_CHARSET_ICONV', 1); define('PMA_CHARSET_ICONV', 1);
define('PMA_CHARSET_LIBICONV', 2); define('PMA_CHARSET_LIBICONV', 2);
define('PMA_CHARSET_RECODE', 3); define('PMA_CHARSET_RECODE', 3);
// finally detect which function will we use: // Finally detects which function will we use:
if (isset($cfg['AllowAnywhereRecoding']) if (isset($cfg['AllowAnywhereRecoding'])
&& $cfg['AllowAnywhereRecoding'] && $cfg['AllowAnywhereRecoding']
&& $allow_recoding) { && $allow_recoding) {
if (!isset($PMA_recoding_engine)) $PMA_recoding_engine = $cfg['RecodingEngine']; if (!isset($PMA_recoding_engine)) {
$PMA_recoding_engine = $cfg['RecodingEngine'];
}
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')) { } else if (@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;
if (!isset($GLOBALS['is_header_sent'])) { if (!isset($GLOBALS['is_header_sent'])) {
include('./header.inc.php3'); include('./header.inc.php3');
} }
@@ -100,12 +104,11 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
include('./footer.inc.php3'); include('./footer.inc.php3');
exit(); exit();
} }
} elseif ($PMA_recoding_engine == 'recode') { } else if ($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 {
$PMA_recoding_engine = PMA_CHARSET_NONE; $PMA_recoding_engine = PMA_CHARSET_NONE;
if (!isset($GLOBALS['is_header_sent'])) { if (!isset($GLOBALS['is_header_sent'])) {
include('./header.inc.php3'); include('./header.inc.php3');
@@ -116,14 +119,13 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
} }
} 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')) { } else if (@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;
} else { } else {
$PMA_recoding_engine = PMA_CHARSET_NONE; $PMA_recoding_engine = PMA_CHARSET_NONE;
if (!isset($GLOBALS['is_header_sent'])) { if (!isset($GLOBALS['is_header_sent'])) {
include('./header.inc.php3'); include('./header.inc.php3');
@@ -134,9 +136,10 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
} }
} }
} else { } else {
$PMA_recoding_engine = PMA_CHARSET_NONE; $PMA_recoding_engine = PMA_CHARSET_NONE;
} }
/** /**
* Converts encoding according to current settings. * Converts encoding according to current settings.
* *
@@ -162,7 +165,7 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
else if (is_array($what)) { else if (is_array($what)) {
$result = array(); $result = array();
reset($what); reset($what);
while(list($key, $val) = each($what)) { while (list($key, $val) = each($what)) {
if (is_string($val) || is_array($val)) { if (is_string($val) || is_array($val)) {
if (is_string($key)) { if (is_string($key)) {
$result[PMA_convert_display_charset($key)] = PMA_convert_display_charset($val); $result[PMA_convert_display_charset($key)] = PMA_convert_display_charset($val);
@@ -249,7 +252,7 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
} // end of the "PMA_convert_charset()" function } // end of the "PMA_convert_charset()" function
/** /**
* Converts encoding of text according to pametres with detected * Converts encoding of text according to parameters with detected
* conversion function. * conversion function.
* *
* @param string source charset * @param string source charset
@@ -278,8 +281,9 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
} }
} // end of the "PMA_convert_string()" function } // end of the "PMA_convert_string()" function
/** /**
* Converts encoding of file according to pametres with detected * Converts encoding of file according to parameters with detected
* conversion function. The old file will be unlinked and new created and * conversion function. The old file will be unlinked and new created and
* its file name is returned. * its file name is returned.
* *

View File

@@ -18,14 +18,14 @@ function PMA_myHandler($sql_insert)
if (function_exists('PMA_kanji_str_conv')) { if (function_exists('PMA_kanji_str_conv')) {
$sql_insert = PMA_kanji_str_conv($sql_insert, $GLOBALS['knjenc'], isset($GLOBALS['xkana']) ? $GLOBALS['xkana'] : ''); $sql_insert = PMA_kanji_str_conv($sql_insert, $GLOBALS['knjenc'], isset($GLOBALS['xkana']) ? $GLOBALS['xkana'] : '');
} }
// Convert the charset if required. // Convert the charset if required.
if ($GLOBALS['cfg']['AllowAnywhereRecoding'] && $GLOBALS['allow_recoding'] if ($GLOBALS['cfg']['AllowAnywhereRecoding'] && $GLOBALS['allow_recoding']
&& isset($GLOBALS['charset_of_file']) && $GLOBALS['charset_of_file'] != $GLOBALS['charset'] && isset($GLOBALS['charset_of_file']) && $GLOBALS['charset_of_file'] != $GLOBALS['charset']
&& (!empty($GLOBALS['asfile']))) { && (!empty($GLOBALS['asfile']))) {
$sql_insert = PMA_convert_string($GLOBALS['charset'], $GLOBALS['charset_of_file'], $sql_insert); $sql_insert = PMA_convert_string($GLOBALS['charset'], $GLOBALS['charset_of_file'], $sql_insert);
} }
// Defines the end of line delimiter to use // Defines the end of line delimiter to use
$eol_dlm = (isset($GLOBALS['extended_ins']) && ($GLOBALS['current_row'] < $GLOBALS['rows_cnt'])) $eol_dlm = (isset($GLOBALS['extended_ins']) && ($GLOBALS['current_row'] < $GLOBALS['rows_cnt']))
? ',' ? ','
@@ -265,8 +265,9 @@ else {
. '#' . $crlf .$crlf; . '#' . $crlf .$crlf;
if (function_exists('PMA_kanji_str_conv')) { // Y.Kawada if (function_exists('PMA_kanji_str_conv')) { // Y.Kawada
$dump_buffer .= PMA_kanji_str_conv($tcmt, $knjenc, isset($xkana) ? $xkana : ''); $dump_buffer .= PMA_kanji_str_conv($tcmt, $knjenc, isset($xkana) ? $xkana : '');
} elseif ($GLOBALS['cfg']['AllowAnywhereRecoding'] && $GLOBALS['allow_recoding'] }
// Convert the charset if required. // Converts the charset if required.
else if ($GLOBALS['cfg']['AllowAnywhereRecoding'] && $GLOBALS['allow_recoding']
&& isset($GLOBALS['charset_of_file']) && $GLOBALS['charset_of_file'] != $GLOBALS['charset'] && isset($GLOBALS['charset_of_file']) && $GLOBALS['charset_of_file'] != $GLOBALS['charset']
&& (!empty($GLOBALS['asfile']))) { && (!empty($GLOBALS['asfile']))) {
$dump_buffer .= PMA_convert_string($GLOBALS['charset'], $GLOBALS['charset_of_file'], $tcmt); $dump_buffer .= PMA_convert_string($GLOBALS['charset'], $GLOBALS['charset_of_file'], $tcmt);

View File

@@ -92,28 +92,28 @@ echo "\n";
<td colspan="2" align="center"> <td colspan="2" align="center">
<input type="checkbox" name="asfile" value="sendit" id="checkbox_dump_asfile" onclick="return checkTransmitDump(this.form, 'transmit')" /> <input type="checkbox" name="asfile" value="sendit" id="checkbox_dump_asfile" onclick="return checkTransmitDump(this.form, 'transmit')" />
<label for="checkbox_dump_asfile"><?php echo $strSend; ?></label> <label for="checkbox_dump_asfile"><?php echo $strSend; ?></label>
<?php <?php
if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) { // charset of file
$temp_charset = reset($cfg['AvailableCharsets']); if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
echo "\n, " . $strCharsetOfFile . "\n" $temp_charset = reset($cfg['AvailableCharsets']);
. ' <select name="charset_of_file" size="1">' . "\n" echo "\n" . ' , ' . $strCharsetOfFile . "\n"
. ' <option value="' . $temp_charset . '"'; . ' <select name="charset_of_file" size="1">' . "\n"
. ' <option value="' . $temp_charset . '"';
if ($temp_charset == $charset) {
echo ' selected="selected"';
}
echo '>' . $temp_charset . '</option>' . "\n";
while ($temp_charset = next($cfg['AvailableCharsets'])) {
echo ' <option value="' . $temp_charset . '"';
if ($temp_charset == $charset) { if ($temp_charset == $charset) {
echo ' selected="selected"'; echo ' selected="selected"';
} }
echo '>' . $temp_charset . '</option>' . "\n"; echo '>' . $temp_charset . '</option>' . "\n";
while ($temp_charset = next($cfg['AvailableCharsets'])) { } // end while
echo ' <option value="' . $temp_charset . '"'; echo ' </select>';
if ($temp_charset == $charset) { } // end if
echo ' selected="selected"'; echo "\n";
}
echo '>' . $temp_charset . '</option>' . "\n";
} // end while
echo ' </select>';
} // end if
echo "\n";
?>
<?php
// zip, gzip and bzip2 encode features // zip, gzip and bzip2 encode features
if (PMA_PHP_INT_VERSION >= 40004) { if (PMA_PHP_INT_VERSION >= 40004) {
$is_zip = (isset($cfg['ZipDump']) && $cfg['ZipDump'] && @function_exists('gzcompress')); $is_zip = (isset($cfg['ZipDump']) && $cfg['ZipDump'] && @function_exists('gzcompress'));

View File

@@ -52,6 +52,9 @@ $is_upload = (PMA_PHP_INT_VERSION >= 40000 && function_exists('ini_get'))
// loic1: php 3.0.15 and lower bug -> always enabled // loic1: php 3.0.15 and lower bug -> always enabled
: (PMA_PHP_INT_VERSION < 30016 || intval(@get_cfg_var('upload_max_filesize'))); : (PMA_PHP_INT_VERSION < 30016 || intval(@get_cfg_var('upload_max_filesize')));
$auto_sel = ($cfg['TextareaAutoSelect'])
? "\n" . ' onfocus="if (typeof(document.layers) == \'undefined\' || typeof(textarea_selected) == \'undefined\') {textarea_selected = 1; this.form.elements[\'sql_query\'].select();}"'
: '';
?> ?>
<!-- Query box and bookmark support --> <!-- Query box and bookmark support -->
<li> <li>
@@ -81,11 +84,7 @@ for ($i = 0 ; $i < $fields_cnt; $i++) {
<input type="button" name="insert" value="<?php echo($strInsert); ?>" onclick="sqlform.sql_query.value = sqlform.sql_query.value + sqlform.dummy.value" /> <input type="button" name="insert" value="<?php echo($strInsert); ?>" onclick="sqlform.sql_query.value = sqlform.sql_query.value + sqlform.dummy.value" />
<br /> <br />
<div style="margin-bottom: 5px"> <div style="margin-bottom: 5px">
<textarea name="sql_query" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols'] * 2; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>"<?php <textarea name="sql_query" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols'] * 2; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>"<?php echo $auto_sel; ?>>
if ($cfg['TextareaAutoSelect']) {
echo "\n" . ' onfocus="if (typeof(document.layers) == \'undefined\' || typeof(textarea_selected) == \'undefined\') {textarea_selected = 1; this.form.elements[\'sql_query\'].select();}"';
}
?>>
<?php echo ((!empty($query_to_display)) ? htmlspecialchars($query_to_display) : 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE 1'); ?> <?php echo ((!empty($query_to_display)) ? htmlspecialchars($query_to_display) : 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE 1'); ?>
</textarea><br /> </textarea><br />
<input type="checkbox" name="show_query" value="1" id="checkbox_show_query" checked="checked" />&nbsp; <input type="checkbox" name="show_query" value="1" id="checkbox_show_query" checked="checked" />&nbsp;