(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
* db_sarch.php:
fixed bug: Undefined variable: num_tables
* [really much files]: (not complete) PEAR coding standard
2006-01-16 Marc Delisle <lem9@users.sourceforge.net>
* server_privileges.php: typo

View File

@@ -52,7 +52,7 @@ if ($cfgRelation['commwork']) {
* Selects the database and gets tables names
*/
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;
while ($row = PMA_DBI_fetch_assoc($rowset)) {
@@ -128,7 +128,7 @@ while ($row = PMA_DBI_fetch_assoc($rowset)) {
/**
* 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);
// Check if we can use Relations (Mike Beck)
if (!empty($cfgRelation['relation'])) {
@@ -141,8 +141,7 @@ while ($row = PMA_DBI_fetch_assoc($rowset)) {
} else {
$have_rel = FALSE;
}
}
else {
} else {
$have_rel = FALSE;
} // 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>
<?php /* <td<?php echo $type_nowrap; ?>><?php echo $strAttribute; ?></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
if ($have_rel) {

View File

@@ -125,14 +125,11 @@ if (isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])) {
if (empty($DOCUMENT_ROOT)) {
if (!empty($_SERVER) && isset($_SERVER['DOCUMENT_ROOT'])) {
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
}
else if (!empty($_ENV) && isset($_ENV['DOCUMENT_ROOT'])) {
} elseif (!empty($_ENV) && isset($_ENV['DOCUMENT_ROOT'])) {
$DOCUMENT_ROOT = $_ENV['DOCUMENT_ROOT'];
}
else if (@getenv('DOCUMENT_ROOT')) {
} elseif (@getenv('DOCUMENT_ROOT')) {
$DOCUMENT_ROOT = getenv('DOCUMENT_ROOT');
}
else {
} else {
$DOCUMENT_ROOT = '.';
}
} // end if
@@ -173,15 +170,13 @@ if (isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])) {
echo $strFileCouldNotBeRead;
exit();
}
}
else {
} else {
$sql_file_new = $tmp_subdir . basename($sql_file);
move_uploaded_file($sql_file, $sql_file_new);
$docsql_text = PMA_readFile($sql_file_new, $sql_file_compression);
unlink($sql_file_new);
}
}
else {
} else {
// read from the normal upload dir
$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); ?>
<input type="hidden" name="submit_show" value="true" />
<input type="hidden" name="do" value="import" />

View File

@@ -152,7 +152,7 @@ $row_count = 0;
$hidden_fields = array();
$odd_row = true;
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_NAME'], $return = true, $force_exact = true );
}

View File

@@ -332,7 +332,7 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?>
SELECT *
FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) . '
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) { ?>
<!-- PDF schema -->

View File

@@ -44,7 +44,7 @@ if ($cfg['SkipLockedTables'] == TRUE) {
unset($result);
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) {
while ($tmp = PMA_DBI_fetch_row($result)) {
if (!isset($sot_cache[$tmp[0]])) {
@@ -159,8 +159,7 @@ else {
elseif ($cfg['ShowStats'] && $mergetable == TRUE) {
$formated_size = '&nbsp;-&nbsp;';
$unit = '';
}
else if ($cfg['ShowStats']) {
} elseif ($cfg['ShowStats']) {
$formated_size = 'unknown';
$unit = '';
}

View File

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

View File

@@ -172,17 +172,26 @@ $onfly_compression = $GLOBALS['cfg']['CompressOnFly'] && isset($compression) &&
if ($onfly_compression) {
$memory_limit = trim(@ini_get('memory_limit'));
// 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;
elseif (strtolower(substr($memory_limit, -1)) == 'k') $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;
if (strtolower(substr($memory_limit, -1)) == 'm') {
$memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
} elseif (strtolower(substr($memory_limit, -1)) == 'k') {
$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.
// Nijel: During export I had allocated (see memory_get_usage function)
// 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
$memory_limit *= 2/3;
@@ -374,7 +383,9 @@ if ($export_type == 'database') {
do {
// Add possibly some comments to export
if (!PMA_exportHeader()) break;
if (!PMA_exportHeader()) {
break;
}
// Will we need relation & co. setup?
$do_relation = isset($GLOBALS[$what . '_relation']);
@@ -411,29 +422,35 @@ if ($export_type == 'server') {
foreach ($dblist AS $current_db) {
if ((isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|'))
|| !isset($tmp_select)) {
if (!PMA_exportDBHeader($current_db))
if (!PMA_exportDBHeader($current_db)) {
break 2;
if (!PMA_exportDBCreate($current_db))
}
if (!PMA_exportDBCreate($current_db)) {
break 2;
}
$tables = PMA_DBI_get_tables($current_db);
foreach ($tables as $table) {
$local_query = 'SELECT * FROM ' . PMA_backquote($current_db) . '.' . PMA_backquote($table);
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;
}
}
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;
}
}
if (!PMA_exportDBFooter($current_db))
}
if (!PMA_exportDBFooter($current_db)) {
break 2;
}
}
}
} elseif ($export_type == 'database') {
if (!PMA_exportDBHeader($db))
if (!PMA_exportDBHeader($db)) {
break;
}
if (isset($table_select)) {
$tmp_select = implode($table_select, '|');
@@ -446,20 +463,24 @@ if ($export_type == 'server') {
|| !isset($tmp_select)) {
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;
}
}
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;
}
}
}
if (!PMA_exportDBFooter($db))
}
if (!PMA_exportDBFooter($db)) {
break;
}
} else {
if (!PMA_exportDBHeader($db))
if (!PMA_exportDBHeader($db)) {
break;
}
// We export just one table
if ($limit_to > 0 && $limit_from >= 0) {
@@ -478,17 +499,22 @@ if ($export_type == 'server') {
}
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;
}
}
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;
}
if (!PMA_exportDBFooter($db))
}
if (!PMA_exportDBFooter($db)) {
break;
}
}
if (!PMA_exportFooter()) {
break;
}
if (!PMA_exportFooter()) break;
} while (FALSE);
// End of fake loop

View File

@@ -180,10 +180,15 @@ if ($memory_limit = -1) {
}
// Calculate value of the limit
if (strtolower(substr($memory_limit, -1)) == 'm') $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
elseif (strtolower(substr($memory_limit, -1)) == 'k') $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;
if (strtolower(substr($memory_limit, -1)) == 'm') {
$memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
} elseif (strtolower(substr($memory_limit, -1)) == 'k') {
$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

View File

@@ -48,11 +48,9 @@ session_write_close();
if (empty($HTTP_HOST)) {
if (!empty($_ENV) && isset($_ENV['HTTP_HOST'])) {
$HTTP_HOST = $_ENV['HTTP_HOST'];
}
elseif (@getenv('HTTP_HOST')) {
} elseif (@getenv('HTTP_HOST')) {
$HTTP_HOST = getenv('HTTP_HOST');
}
else {
} else {
$HTTP_HOST = '';
}
}

View File

@@ -34,9 +34,10 @@ class PMA_Theme_Manager {
/**
* @var object PMA_Theme active theme
*/
var $theme = NULL;
var $theme = null;
function __construct() {
function __construct()
{
$this->themes_path = trim($GLOBALS['cfg']['ThemePath']) ;
$this->per_server = (bool) $GLOBALS['cfg']['ThemePerServer'];
$this->theme = new PMA_Theme;
@@ -70,11 +71,13 @@ class PMA_Theme_Manager {
}
}
function __wakeup() {
function __wakeup()
{
$this->loadThemes($this->themes_path);
}
function setActiveTheme( $theme = NULL ) {
function setActiveTheme($theme = null)
{
if ( ! $this->checkTheme($theme)) {
$GLOBALS['PMA_errors'][] = sprintf($GLOBALS['strThemeNotFound'],
$theme);
@@ -96,7 +99,8 @@ class PMA_Theme_Manager {
/**
* @return string cookie name
*/
function getThemeCookieName() {
function getThemeCookieName()
{
// Allow different theme per server
if (isset($GLOBALS['server']) && $this->per_server) {
return $this->cookie_name . '-' . $GLOBALS['server'];
@@ -109,7 +113,8 @@ class PMA_Theme_Manager {
* returns name of theme stored in the cookie
* @return string theme name from cookie
*/
function getThemeCookie() {
function getThemeCookie()
{
if (isset($_COOKIE[$this->getThemeCookieName()])) {
return $_COOKIE[$this->getThemeCookieName()];
}
@@ -126,7 +131,8 @@ class PMA_Theme_Manager {
* @uses PMA_Theme_Manager::$theme_default
* @uses PMA_Theme::getId()
*/
function setThemeCookie() {
function setThemeCookie()
{
PMA_setCookie($this->getThemeCookieName(), $this->theme->id,
$this->theme_default);
return true;
@@ -135,7 +141,8 @@ class PMA_Theme_Manager {
/**
* old PHP 4 constructor
*/
function PMA_Theme_Manager() {
function PMA_Theme_Manager()
{
$this->__construct();
}
@@ -144,7 +151,8 @@ class PMA_Theme_Manager {
* @param string $folder
* @return boolean
*/
/*private*/ function _checkThemeFolder( $folder ) {
/*private*/ function _checkThemeFolder($folder)
{
if (! is_dir($folder)) {
$GLOBALS['PMA_errors'][] =
sprintf($GLOBALS['strThemePathNotFound'],
@@ -164,7 +172,8 @@ class PMA_Theme_Manager {
*
* @param string $folder themes folders
*/
function loadThemes( $folder ) {
function loadThemes($folder)
{
if ($handleThemes = opendir($folder)) {
// check for themes directory
while (FALSE !== ($PMA_Theme = readdir($handleThemes))) {
@@ -196,7 +205,8 @@ class PMA_Theme_Manager {
*
* @param string $theme name fo theme to check for
*/
function checkTheme( $theme ) {
function checkTheme($theme)
{
if (! array_key_exists($theme, $this->themes)) {
return false;
}
@@ -209,7 +219,8 @@ class PMA_Theme_Manager {
*
* @param boolean $form wether enclosed by from tags or not
*/
function getHtmlSelectBox( $form = true ) {
function getHtmlSelectBox($form = true)
{
$select_box = '';
if ($form) {
@@ -247,7 +258,8 @@ class PMA_Theme_Manager {
/**
* enables backward compatibility
*/
function makeBc() {
function makeBc()
{
$GLOBALS['theme'] = $this->theme->getId();
$GLOBALS['pmaThemePath'] = $this->theme->getPath();
$GLOBALS['pmaThemeImage'] = $this->theme->getImgPath();
@@ -256,7 +268,7 @@ class PMA_Theme_Manager {
* load layout file if exists
*/
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 PMA_Theme::printPreview()
*/
function printPreviews() {
function printPreviews()
{
foreach ($this->themes as $each_theme) {
$each_theme->printPreview();
} // end 'open themes'
}

View File

@@ -82,14 +82,12 @@ function PMA_auth()
// server name
if (!empty($GLOBALS['pma_cookie_servername'])) {
$default_server = $GLOBALS['pma_cookie_servername'];
}
else if (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_servername-' . $server])) {
} elseif (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_servername-' . $server])) {
$default_server = $_COOKIE['pma_cookie_servername-' . $server];
}
$autocomplete = '';
}
else {
} else {
$default_user = '';
$autocomplete = ' autocomplete="off"';
}
@@ -319,8 +317,7 @@ function PMA_auth_check()
if (!empty($pma_cookie_servername)) {
$pma_auth_server = $pma_cookie_servername;
$from_cookie = TRUE;
}
else if (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_servername-' . $server])) {
} elseif (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_servername-' . $server])) {
$pma_auth_server = $_COOKIE['pma_cookie_servername-' . $server];
$from_cookie = TRUE;
}
@@ -356,11 +353,9 @@ function PMA_auth_check()
// password
if (!empty($pma_cookie_password)) {
$PHP_AUTH_PW = $pma_cookie_password;
}
else if (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_password-' . $server])) {
} elseif (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_password-' . $server])) {
$PHP_AUTH_PW = $_COOKIE['pma_cookie_password-' . $server];
}
else {
} else {
$from_cookie = FALSE;
}
$PHP_AUTH_PW = PMA_blowfish_decrypt($PHP_AUTH_PW, $GLOBALS['cfg']['blowfish_secret'] . $decrypted_time);

View File

@@ -102,7 +102,9 @@ function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id', $action_bo
. ' OR user = \'\')' )
. ' AND ' . PMA_backquote($id_field) . ' = ' . $id;
$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);
return $bookmark_query;
@@ -140,7 +142,9 @@ function &PMA_queryDBBookmarks($db, $cfgBookmark, &$table_array)
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
. (count($search_for) > 0 ? ' AND label IN (' . implode(', ', $search_for) . ')' : '');
$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)) {
$bookmarks[$row['label']] = $row['query'];
}

View File

@@ -143,8 +143,7 @@ function PMA_convert_display_charset($what) {
// 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
return $what;
}
else if (is_array($what)) {
} elseif (is_array($what)) {
$result = array();
foreach ($what AS $key => $val) {
if (is_string($val) || is_array($val)) {
@@ -158,8 +157,7 @@ function PMA_convert_display_charset($what) {
}
} // end while
return $result;
}
else if (is_string($what)) {
} elseif (is_string($what)) {
switch ($GLOBALS['PMA_recoding_engine']) {
case PMA_CHARSET_RECODE:
@@ -171,8 +169,7 @@ function PMA_convert_display_charset($what) {
default:
return $what;
}
}
else if (is_object($what)) {
} elseif (is_object($what)) {
// isn't it object returned from mysql_fetch_field ?
if (@is_string($what->name)) {
$what->name = PMA_convert_display_charset($what->name);
@@ -184,8 +181,7 @@ function PMA_convert_display_charset($what) {
$what->Database = PMA_convert_display_charset($what->Database);
}
return $what;
}
else {
} else {
// when we don't know what it is we don't touch it...
return $what;
}
@@ -243,7 +239,9 @@ function PMA_convert_charset($what) {
* @author nijel
*/
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']) {
case PMA_CHARSET_RECODE:
return recode_string($src_charset . '..' . $dest_charset, $what);

View File

@@ -47,8 +47,7 @@ function PMA_analyseShowGrant($rs_usr, &$is_create_db_priv, &$db_to_create, &$is
$db_to_create = '';
$dbs_where_create_table_allowed[] = '*';
break;
} // end if
else {
} else {
// this array may contain wildcards
$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)
&& !ereg('\\\\%|\\\\_', $show_grants_dbname))
// 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($re1 . '(%|_)', '\\1\\3', $db_to_create);
@@ -104,7 +103,7 @@ if (PMA_MYSQL_INT_VERSION >= 40102) {
// $userlink so maybe the SELECT will fail
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);
$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
PMA_DBI_free_result($rs_usr);
unset($rs_usr, $row, $re0, $re1);
} // end if
else {
} else {
// Finally, let's try to get the user's privileges by using SHOW
// GRANTS...
// Maybe we'll find a little CREATE priv there :)

View File

@@ -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)) {
$dblist[] = $uva_row[0];
} // end while
} // end if
else {
} else {
while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) {
$uva_db = $uva_row[0];
if (isset($uva_mydbs[$uva_db]) && $uva_mydbs[$uva_db] == 1) {
@@ -677,7 +676,9 @@ if (!defined('PMA_MINIMUM_COMMON')) {
{
global $cfg;
if ($cfg['MySQLManualType'] == 'none' || empty($cfg['MySQLManualBase'])) return '';
if ($cfg['MySQLManualType'] == 'none' || empty($cfg['MySQLManualBase'])) {
return '';
}
// Fixup for newly used names:
$chapter = str_replace('_', '-', strtolower($chapter));
@@ -685,19 +686,25 @@ if (!defined('PMA_MINIMUM_COMMON')) {
switch ($cfg['MySQLManualType']) {
case 'chapters':
if (empty($chapter)) $chapter = 'index';
if (empty($chapter)) {
$chapter = 'index';
}
$url = $cfg['MySQLManualBase'] . '/' . $chapter . '.html#' . $link;
break;
case 'big':
$url = $cfg['MySQLManualBase'] . '#' . $link;
break;
case 'searchable':
if (empty($link)) $link = 'index';
if (empty($link)) {
$link = 'index';
}
$url = $cfg['MySQLManualBase'] . '/' . $link . '.html';
break;
case 'viewable':
default:
if (empty($link)) $link = 'index';
if (empty($link)) {
$link = 'index';
}
$mysql = '5.0';
if (defined('PMA_MYSQL_INT_VERSION')) {
if (PMA_MYSQL_INT_VERSION < 50000) {
@@ -1816,8 +1823,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
if ($tab['text'] == $GLOBALS['strEmpty']
|| $tab['text'] == $GLOBALS['strDrop']) {
$tab['class'] = 'caution';
}
elseif (!empty($tab['active'])
} elseif (!empty($tab['active'])
|| (isset($GLOBALS['active_page'])
&& $GLOBALS['active_page'] == $tab['link'])
|| basename($_SERVER['PHP_SELF']) == $tab['link'])
@@ -1910,12 +1916,10 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
function PMA_linkOrButton($url, $message, $tag_params = array(),
$new_form = true, $strip_img = false, $target = '')
{
if (!is_array($tag_params))
{
if (! is_array($tag_params)) {
$tmp = $tag_params;
$tag_params = array();
if (!empty($tmp))
{
if (!empty($tmp)) {
$tag_params['onclick'] = 'return confirmLink(this, \'' . $tmp . '\')';
}
unset($tmp);
@@ -1939,8 +1943,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
$ret = "\n" . '<a href="' . $url . '" '
. implode(' ', $tag_params_strings) . '>'
. $message . '</a>' . "\n";
}
else {
} else {
// no spaces (linebreaks) at all
// or after the hidden fields
// 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;
if (!isset($checked_special)) $checked_special = false;
if (!isset($checked_special)) {
$checked_special = false;
}
$reported_script_name = basename($PHP_SELF);
$found_error = false;
$error_message = '';
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])) {
$error_message .= $reported_script_name . ': Missing parameter: ' . $param . ' <a href="./Documentation.html#faqmissingparameters" target="documentation"> (FAQ 2.8)</a><br />';

View File

@@ -68,7 +68,7 @@ if ( true === $cfg['SkipLockedTables'] ) {
PMA_DBI_free_result($db_info_result);
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) {
while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
if (!isset($sot_cache[$tmp[0]])) {

View File

@@ -19,7 +19,7 @@ if (empty($sub_part)) {
// priv CREATE TEMPORARY TABLES or LOCK TABLES can do a 'USE mysql'
// (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

View File

@@ -21,7 +21,7 @@ if (!isset($is_db) || !$is_db) {
if (!isset($is_table) || !$is_table) {
// Not a valid table name -> back to the db_details.php
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)
|| !($is_table && @PMA_DBI_num_rows($is_table))) {
@@ -31,7 +31,7 @@ if (!isset($is_table) || !$is_table) {
if (isset($table) && strlen($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):
$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));
PMA_DBI_free_result($is_table2);
}
@@ -40,7 +40,9 @@ 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');
}
}
if ($redirect) exit;
if ($redirect) {
exit;
}
} elseif (isset($is_table)) {
PMA_DBI_free_result($is_table);
}

View File

@@ -60,7 +60,7 @@ function PMA_DBI_connect($user, $password, $is_controluser = FALSE) {
return $link;
}
function PMA_DBI_select_db($dbname, $link = NULL) {
function PMA_DBI_select_db($dbname, $link = null) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@@ -74,7 +74,7 @@ function PMA_DBI_select_db($dbname, $link = NULL) {
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 (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@@ -106,7 +106,9 @@ function PMA_mysql_fetch_array($result, $type = FALSE) {
}
/* 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
|| !(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);
/* Field is BINARY (either marked manually, or it is BLOB) => do not convert it */
if (stristr($flags, 'BINARY')) {
if (isset($data[$i])) $ret[$i] = $data[$i];
if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = $data[$name];
if (isset($data[$i])) {
$ret[$i] = $data[$i];
}
if (isset($data[$name])) {
$ret[PMA_convert_display_charset($name)] = $data[$name];
}
} else {
if (isset($data[$i])) $ret[$i] = PMA_convert_display_charset($data[$i]);
if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = PMA_convert_display_charset($data[$name]);
if (isset($data[$i])) {
$ret[$i] = PMA_convert_display_charset($data[$i]);
}
if (isset($data[$name])) {
$ret[PMA_convert_display_charset($name)] = PMA_convert_display_charset($data[$name]);
}
}
}
return $ret;
@@ -165,8 +175,9 @@ function PMA_DBI_free_result() {
* @param resource $link mysql link
* @return string type of connection used
*/
function PMA_DBI_get_host_info( $link = NULL ) {
if ( NULL === $link ) {
function PMA_DBI_get_host_info($link = null)
{
if (null === $link) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
@@ -183,8 +194,9 @@ function PMA_DBI_get_host_info( $link = NULL ) {
* @param resource $link mysql link
* @return integer version of the MySQL protocol used
*/
function PMA_DBI_get_proto_info( $link = NULL ) {
if ( NULL === $link ) {
function PMA_DBI_get_proto_info($link = null)
{
if (null === $link) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
@@ -219,9 +231,10 @@ function PMA_DBI_get_client_info() {
* @param resource $link mysql link
* @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'] ) ) {
if (null === $link && isset($GLOBALS['userlink'])) {
$link =& $GLOBALS['userlink'];
// Do not stop now. On the initial connection, we don't have a $link,
@@ -230,7 +243,7 @@ function PMA_DBI_getError( $link = NULL ) {
// return FALSE;
}
if ( NULL !== $link ) {
if (null !== $link) {
$error_number = mysql_errno($link);
$error_message = mysql_error($link);
} else {
@@ -261,7 +274,8 @@ function PMA_DBI_getError( $link = NULL ) {
return $error;
}
function PMA_DBI_close($link = NULL) {
function PMA_DBI_close($link = null)
{
if (empty($link)) {
if (isset($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 (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@@ -291,7 +306,8 @@ function PMA_DBI_insert_id($link = NULL) {
return mysql_insert_id($link);
}
function PMA_DBI_affected_rows($link = NULL) {
function PMA_DBI_affected_rows($link = null)
{
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];

View File

@@ -31,7 +31,8 @@ define('NUM_FLAG', 32768);
define('PART_KEY_FLAG', 16384);
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;
$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
$server_socket = (empty($cfg['Server']['socket']))
? NULL
? null
: $cfg['Server']['socket'];
$link = mysqli_init();
@@ -64,7 +65,8 @@ function PMA_DBI_connect($user, $password, $is_controluser = FALSE) {
return $link;
}
function PMA_DBI_select_db($dbname, $link = NULL) {
function PMA_DBI_select_db($dbname, $link = null)
{
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@@ -78,7 +80,8 @@ function PMA_DBI_select_db($dbname, $link = NULL) {
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)) {
$method = MYSQLI_STORE_RESULT;
} 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.
// 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;
if ($type != FALSE) {
@@ -117,7 +121,9 @@ function PMA_mysqli_fetch_array($result, $type = FALSE) {
}
/* 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
|| !(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);
}
function PMA_DBI_fetch_assoc($result) {
function PMA_DBI_fetch_assoc($result)
{
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);
}
@@ -184,7 +193,8 @@ function PMA_DBI_fetch_row($result) {
*
* @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)
&& is_a($result, 'mysqli_result')) {
@@ -200,8 +210,9 @@ function PMA_DBI_free_result() {
* @param resource $link mysql link
* @return string type of connection used
*/
function PMA_DBI_get_host_info( $link = NULL ) {
if ( NULL === $link ) {
function PMA_DBI_get_host_info($link = null)
{
if (null === $link) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
@@ -218,8 +229,9 @@ function PMA_DBI_get_host_info( $link = NULL ) {
* @param resource $link mysql link
* @return integer version of the MySQL protocol used
*/
function PMA_DBI_get_proto_info( $link = NULL ) {
if ( NULL === $link ) {
function PMA_DBI_get_proto_info( $link = null )
{
if (null === $link) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
@@ -256,10 +268,11 @@ function PMA_DBI_get_client_info() {
* @param resource $link mysql link
* @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'] ) ) {
if (null === $link && isset($GLOBALS['userlink'])) {
$link =& $GLOBALS['userlink'];
// Do not stop now. We still can get the error code
// with mysqli_connect_errno()
@@ -267,7 +280,7 @@ function PMA_DBI_getError( $link = NULL ) {
// return false;
}
if ( NULL !== $link ) {
if (null !== $link) {
$error_number = mysqli_errno($link);
$error_message = mysqli_error($link);
} else {
@@ -295,7 +308,8 @@ function PMA_DBI_getError( $link = NULL ) {
return $error;
}
function PMA_DBI_close($link = NULL) {
function PMA_DBI_close($link = null)
{
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@@ -306,7 +320,8 @@ function PMA_DBI_close($link = NULL) {
return @mysqli_close($link);
}
function PMA_DBI_num_rows($result) {
function PMA_DBI_num_rows($result)
{
// see the note for PMA_DBI_try_query();
if (!is_bool($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 (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@@ -326,7 +342,8 @@ function PMA_DBI_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 (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@@ -337,7 +354,8 @@ function PMA_DBI_affected_rows($link = NULL) {
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
$typeAr = Array();
$typeAr[MYSQLI_TYPE_DECIMAL] = 'real';
@@ -392,23 +410,27 @@ function PMA_DBI_get_fields_meta($result) {
return $fields;
}
function PMA_DBI_num_fields($result) {
function PMA_DBI_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);
// stdClass::$length will be integrated in
// mysqli-ext when mysql4.1 has been released.
return @$info->length;
}
function PMA_DBI_field_name($result, $i) {
function PMA_DBI_field_name($result, $i)
{
$info = mysqli_fetch_field_direct($result, $i);
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 = $f->flags;
$flags = '';

View File

@@ -17,7 +17,7 @@ if ($is_create_db_priv) {
<?php
if (PMA_MYSQL_INT_VERSION >= 40101) {
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" />

View File

@@ -49,7 +49,9 @@ echo PMA_pluginGetJavascript($import_list);
if (!empty($cfg['UploadDir'])) {
$extensions = '';
foreach ($import_list as $key => $val) {
if (!empty($extensions)) $extensions .= '|';
if (!empty($extensions)) {
$extensions .= '|';
}
$extensions .= $val['extension'];
}
$matcher = '@\.(' . $extensions . ')(\.(' . PMA_supportedDecompressions() . '))?$@';
@@ -101,9 +103,15 @@ echo '</div>' . "\n";
// zip, gzip and bzip2 encode features
$compressions = $strNone;
if ($cfg['GZipDump'] && @function_exists('gzopen')) $compressions .= ', gzip';
if ($cfg['BZipDump'] && @function_exists('bzopen')) $compressions .= ', bzip2';
if ($cfg['ZipDump'] && @function_exists('gzinflate')) $compressions .= ', zip';
if ($cfg['GZipDump'] && @function_exists('gzopen')) {
$compressions .= ', gzip';
}
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
if ($compressions != $strNone) {

View File

@@ -107,8 +107,7 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
if (isset($which[1]) && strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0) {
$do_display['edit_lnk'] = 'nn'; // no edit link
$do_display['del_lnk'] = 'kp'; // "kill process" type edit link
}
else {
} else {
// Default case -> no links
$do_display['edit_lnk'] = 'nn'; // no edit 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
if (isset($unlim_num_rows) && $unlim_num_rows != '') {
$the_total = $unlim_num_rows;
}
else if (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1')
} elseif (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1')
&& (isset($db) && strlen($db) && !empty($table))) {
$the_total = PMA_countRecords($db, $table, TRUE);
}
@@ -526,9 +524,15 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
$span = $fields_cnt;
if ($is_display['edit_lnk'] != 'nn') $span++;
if ($is_display['del_lnk'] != 'nn') $span++;
if ($is_display['del_lnk'] != 'kp' && $is_display['del_lnk'] != 'nn') $span++;
if ($is_display['edit_lnk'] != 'nn') {
$span++;
}
if ($is_display['del_lnk'] != 'nn') {
$span++;
}
if ($is_display['del_lnk'] != 'kp' && $is_display['del_lnk'] != 'nn') {
$span++;
}
} else {
$span = $num_rows + floor($num_rows/$repeat_cells) + 1;
}
@@ -825,7 +829,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
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 $comments; ?>
</th>
@@ -841,7 +845,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
else {
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 $comments; ?>
</th>
@@ -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])
. ' WHERE ' . PMA_backquote($map[$meta->name][1])
. ' = ' . $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) {
list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
}
else {
} else {
$dispval = $GLOBALS['strLinkNotFound'];
}
@PMA_DBI_free_result($dispresult);
}
else {
} else {
$dispval = '';
} // end if... else...
@@ -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])
. ' WHERE ' . PMA_backquote($map[$meta->name][1])
. ' = \'' . 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) {
list($dispval) = PMA_DBI_fetch_row($dispresult);
@PMA_DBI_free_result($dispresult);
}
else {
} else {
$dispval = $GLOBALS['strLinkNotFound'];
}
}
else {
} else {
$dispval = '';
}
$title = (!empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';

View File

@@ -124,7 +124,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $escaped;
// 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);
// 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;
} // end for
$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
// Format the data
@@ -150,8 +152,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) {
$schema_insert .= $GLOBALS[$what . '_replace_null'];
}
else if ($row[$j] == '0' || $row[$j] != '') {
} elseif ($row[$j] == '0' || $row[$j] != '') {
// loic1 : always enclose fields
if ($what == 'excel') {
$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])
. $enclosed;
}
}
else {
} else {
$schema_insert .= '';
}
if ($j < $fields_cnt-1) {
@@ -172,7 +172,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
}
} // end for
if (!PMA_exportOutputHandler($schema_insert . $add_character)) return FALSE;
if (!PMA_exportOutputHandler($schema_insert . $add_character)) {
return FALSE;
}
} // end while
PMA_DBI_free_result($result);

View File

@@ -122,7 +122,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $what;
// 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);
// 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>';
} // end for
$schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) return FALSE;
if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
} // end if
// Format the data
@@ -149,7 +151,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$schema_insert .= '<td class=xl2216681 nowrap>' . htmlspecialchars($value) . '</td>';
} // end for
$schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) return FALSE;
if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
} // end while
PMA_DBI_free_result($result);

View File

@@ -101,14 +101,19 @@ function PMA_exportDBCreate($db) {
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $what;
if (!PMA_exportOutputHandler('<h2>' . $GLOBALS['strDumpingData'] . ' ' .$table . '</h2>')) return FALSE;
if (!PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) return FALSE;
if (!PMA_exportOutputHandler('<h2>' . $GLOBALS['strDumpingData'] . ' ' . $table . '</h2>')) {
return FALSE;
}
if (!PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) {
return FALSE;
}
// 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);
// 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>';
} // end for
$schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) return FALSE;
if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
} // end if
// Format the data
@@ -135,10 +142,14 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$schema_insert .= '<td class="print">' . htmlspecialchars($value) . '</td>';
} // end for
$schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) return FALSE;
if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
} // end while
PMA_DBI_free_result($result);
if (!PMA_exportOutputHandler('</table>')) return FALSE;
if (!PMA_exportOutputHandler('</table>')) {
return FALSE;
}
return TRUE;
}
@@ -147,7 +158,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
{
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
@@ -156,7 +169,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
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);
@@ -179,15 +194,16 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
} else {
$have_rel = FALSE;
}
}
else {
} else {
$have_rel = FALSE;
} // end if
/**
* 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;
if ($do_relation && $have_rel) {
@@ -218,7 +234,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
}
$schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) return FALSE;
if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
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>';
if (!PMA_exportOutputHandler($schema_insert)) return FALSE;
if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
} // end while
PMA_DBI_free_result($result);

View File

@@ -129,7 +129,7 @@ function PMA_exportDBCreate($db) {
* @access public
*/
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);
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'])
. '} \\label{' . str_replace('__TABLE__', $table, $GLOBALS['latex_data_label']) . '} \\\\';
}
if (!PMA_exportOutputHandler($buffer)) return FALSE;
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
// show column names
if (isset($GLOBALS['latex_showcolumns'])) {
@@ -160,13 +162,19 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
}
$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 (!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 {
if (!PMA_exportOutputHandler('\\\\ \hline')) return FALSE;
if (!PMA_exportOutputHandler('\\\\ \hline')) {
return FALSE;
}
}
// print the whole table
@@ -189,11 +197,15 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
}
}
$buffer .= ' \\\\ \\hline ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) return FALSE;
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
}
$buffer = ' \\end{longtable}' . $crlf;
if (!PMA_exportOutputHandler($buffer)) return FALSE;
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
PMA_DBI_free_result($result);
return TRUE;
@@ -227,7 +239,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
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);
@@ -250,8 +264,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
} else {
$have_rel = FALSE;
}
}
else {
} else {
$have_rel = FALSE;
} // 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
. ' \\begin{longtable}{';
if (!PMA_exportOutputHandler($buffer)) return FALSE;
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
$columns_cnt = 4;
$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 ';
if (!PMA_exportOutputHandler($buffer)) return FALSE;
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
while ($row = PMA_DBI_fetch_assoc($result)) {
@@ -388,7 +405,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$buffer = str_replace("\000", ' & ', $local_buffer);
$buffer .= ' \\\\ \\hline ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) return FALSE;
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
} // end while
PMA_DBI_free_result($result);

View File

@@ -204,7 +204,7 @@ class PMA_PDF extends PMA_FPDF
// Pass 1 for column widths
// 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->fields = PMA_DBI_get_fields_meta($this->results);
@@ -272,7 +272,7 @@ class PMA_PDF extends PMA_FPDF
// 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->setY($this->tMargin);
$this->AddPage();

View File

@@ -14,7 +14,7 @@ $GLOBALS['comment_marker'] = '-- ';
* Avoids undefined variables, use NULL so isset() returns false
*/
if ( ! isset( $use_backquotes ) ) {
$use_backquotes = NULL;
$use_backquotes = null;
}
/**
@@ -24,7 +24,8 @@ if ( ! isset( $use_backquotes ) ) {
*
* @return bool Whether it suceeded
*/
function PMA_exportComment($text) {
function PMA_exportComment($text)
{
return PMA_exportOutputHandler($GLOBALS['comment_marker'] . $text . $GLOBALS['crlf']);
}
@@ -35,7 +36,8 @@ function PMA_exportComment($text) {
*
* @access public
*/
function PMA_exportFooter() {
function PMA_exportFooter()
{
global $crlf;
$foot = '';
@@ -58,7 +60,8 @@ function PMA_exportFooter() {
*
* @access public
*/
function PMA_exportHeader() {
function PMA_exportHeader()
{
global $crlf;
global $cfg;
@@ -107,10 +110,13 @@ function PMA_exportHeader() {
*
* @access public
*/
function PMA_exportDBCreate($db) {
function PMA_exportDBCreate($db)
{
global $crlf;
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);
if (PMA_MYSQL_INT_VERSION >= 40101) {
@@ -122,7 +128,9 @@ function PMA_exportDBCreate($db) {
}
}
$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') {
return PMA_exportOutputHandler('USE ' . PMA_backquote($db) . ';' . $crlf);
}
@@ -138,7 +146,8 @@ function PMA_exportDBCreate($db) {
*
* @access public
*/
function PMA_exportDBHeader($db) {
function PMA_exportDBHeader($db)
{
global $crlf;
$head = $GLOBALS['comment_marker'] . $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
*/
function PMA_exportDBFooter($db) {
function PMA_exportDBFooter($db)
{
$result = TRUE;
if (isset($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;
// 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 (PMA_DBI_num_rows($result) > 0) {
$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');
}
$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))) {
$create_query = $row[1];
unset($row);
@@ -261,7 +271,9 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
// lets find first line with constraints
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
@@ -362,13 +374,14 @@ function PMA_getTableComments($db, $table, $crlf, $do_relation = false, $do_comm
} else {
$have_rel = FALSE;
}
}
else {
} else {
$have_rel = FALSE;
} // end if
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) {
@@ -422,7 +435,8 @@ function PMA_getTableComments($db, $table, $crlf, $do_relation = false, $do_comm
*
* @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']))
? PMA_backquote($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'] . $crlf .$crlf;
if (!PMA_exportOutputHandler($head)) return FALSE;
if (!PMA_exportOutputHandler($head)) {
return FALSE;
}
$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)
$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) {
$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') {
// update
$schema_insert = 'UPDATE ';
if (isset($GLOBALS['sql_ignore']))
if (isset($GLOBALS['sql_ignore'])) {
$schema_insert .= 'IGNORE ';
}
$schema_insert .= PMA_backquote($table, $use_backquotes) . ' SET ';
} else {
// insert or replace
@@ -601,7 +618,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
} else {
$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 (!PMA_exportOutputHandler(';' . $crlf)) return FALSE;
if (!PMA_exportOutputHandler(';' . $crlf)) {
return FALSE;
}
$query_size = 0;
$current_row = 1;
$insert_line = $schema_insert . $insert_line;
@@ -616,11 +635,15 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
}
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
if ($current_row > 0) {
if (!PMA_exportOutputHandler(';' . $crlf)) return FALSE;
if (!PMA_exportOutputHandler(';' . $crlf)) {
return FALSE;
}
}
} // end if ($result != FALSE)
PMA_DBI_free_result($result);

View File

@@ -15,7 +15,8 @@ require_once('Spreadsheet/Excel/Writer.php');
*
* @return bool Whether it suceeded
*/
function PMA_exportComment($text) {
function PMA_exportComment($text)
{
return TRUE;
}
@@ -26,7 +27,8 @@ function PMA_exportComment($text) {
*
* @access public
*/
function PMA_exportFooter() {
function PMA_exportFooter()
{
global $workbook;
global $tmp_filename;
@@ -35,7 +37,9 @@ function PMA_exportFooter() {
echo $res->getMessage();
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);
return TRUE;
@@ -48,11 +52,14 @@ function PMA_exportFooter() {
*
* @access public
*/
function PMA_exportHeader() {
function PMA_exportHeader()
{
global $workbook;
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_');
$workbook = new Spreadsheet_Excel_Writer($tmp_filename);
@@ -68,7 +75,8 @@ function PMA_exportHeader() {
*
* @access public
*/
function PMA_exportDBHeader($db) {
function PMA_exportDBHeader($db)
{
return TRUE;
}
@@ -81,7 +89,8 @@ function PMA_exportDBHeader($db) {
*
* @access public
*/
function PMA_exportDBFooter($db) {
function PMA_exportDBFooter($db)
{
return TRUE;
}
@@ -94,7 +103,8 @@ function PMA_exportDBFooter($db) {
*
* @access public
*/
function PMA_exportDBCreate($db) {
function PMA_exportDBCreate($db)
{
return TRUE;
}
@@ -111,7 +121,8 @@ function PMA_exportDBCreate($db) {
*
* @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 $workbook;
@@ -119,7 +130,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$workbook->setTempDir(realpath($GLOBALS['cfg']['TempDir']));
// 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);
$col = 0;

View File

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

View File

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

View File

@@ -68,13 +68,17 @@ require_once('./libraries/relation.lib.php'); // for PMA_setHistory()
<?php
// 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']) {
echo '<div id="selflink">' . "\n";
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'] : '');
if (!empty($url)) echo '&amp;' . $url;
if (!empty($url)) {
echo '&amp;' . $url;
}
echo '" target="_blank">' . $GLOBALS['strOpenNewWindow'] . '</a>' . "\n";
echo '</div>' . "\n";
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,30 +1,33 @@
<?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 *
*
* 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')) {
define('UFPDF_VERSION', '0.1');
include_once './libraries/fpdf/fpdf.php';
class UFPDF extends FPDF
{
/*******************************************************************************
* *
class UFPDF extends FPDF {
/**
* Public methods *
* *
*******************************************************************************/
*/
function UFPDF($orientation = 'P', $unit = 'mm', $format = 'A4')
{
FPDF::FPDF($orientation, $unit, $format);
@@ -37,8 +40,11 @@ function GetStringWidth($s)
$codepoints = $this->utf8_to_codepoints($s);
$cw = &$this->CurrentFont['cw'];
$w = 0;
foreach($codepoints as $cp)
foreach ($codepoints as $cp) {
$w += isset($cw[$cp])?$cw[$cp]:0;
}
return $w * $this->FontSize / 1000;
}
@@ -46,39 +52,60 @@ function AddFont($family,$style='',$file='')
{
// Add a TrueType or Type1 font
$family = strtolower($family);
if($family=='arial')
if ($family == 'arial') {
$family = 'helvetica';
}
$style = strtoupper($style);
if($style=='IB')
if ($style == 'IB') {
$style = 'BI';
if(isset($this->fonts[$family.$style]))
}
if (isset($this->fonts[$family . $style])) {
$this->Error('Font already added: ' . $family . ' ' . $style);
if($file=='')
}
if ($file == '') {
$file = str_replace(' ', '', $family) . strtolower($style) . '.php';
if(defined('FPDF_FONTPATH'))
}
if (defined('FPDF_FONTPATH')) {
$file = FPDF_FONTPATH . $file;
}
include($file);
if(!isset($name))
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')
if ($file) {
if ($type == 'TrueTypeUnicode') {
$this->FontFiles[$file] = array('length1' => $originalsize);
else
} 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!='')
if ($this->underline and $txt != '') {
$s .= ' ' . $this->_dounderline($x, $y, $this->GetStringWidth($txt), $txt);
if($this->ColorFlag)
}
if ($this->ColorFlag) {
$s = 'q ' . $this->TextColor . ' ' . $s . ' Q';
}
$this->_out($s);
}
@@ -92,89 +119,118 @@ 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())
{
if ($this->y + $h > $this->PageBreakTrigger and !$this->InFooter and $this->AcceptPageBreak()) {
// Automatic page break
$x = $this->x;
$ws = $this->ws;
if($ws>0)
{
if ($ws > 0) {
$this->ws = 0;
$this->_out('0 Tw');
}
$this->AddPage($this->CurOrientation);
$this->x = $x;
if($ws>0)
{
if ($ws > 0) {
$this->ws = $ws;
$this->_out(sprintf('%.3f Tw', $ws * $k));
}
}
if($w==0)
if ($w == 0) {
$w = $this->w - $this->rMargin - $this->x;
}
$s = '';
if($fill==1 or $border==1)
{
if($fill==1)
if ($fill == 1 or $border == 1) {
if ($fill == 1) {
$op = ($border == 1) ? 'B' : 'f';
else
} 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))
{
if (is_string($border)) {
$x = $this->x;
$y = $this->y;
if(is_int(strpos($border,'L')))
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')))
}
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')))
}
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')))
}
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!='')
{
}
if ($txt != '') {
$width = $this->GetStringWidth($txt);
if($align=='R')
if ($align == 'R') {
$dx = $w - $this->cMargin - $width;
elseif($align=='C')
} elseif ($align == 'C') {
$dx = ($w - $width) / 2;
else
} else {
$dx = $this->cMargin;
if($this->ColorFlag)
}
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)
if ($this->underline) {
$s .= ' ' . $this->_dounderline($this->x + $dx, $this->y + .5 * $h + .3 * $this->FontSize, $width, $txt);
if($this->ColorFlag)
}
if ($this->ColorFlag) {
$s .= ' Q';
if($link)
}
if ($link) {
$this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $width, $this->FontSize, $link);
}
if($s)
}
if ($s) {
$this->_out($s);
}
$this->lasth = $h;
if($ln>0)
{
if ($ln > 0) {
// Go to next line
$this->y += $h;
if($ln==1)
if ($ln == 1) {
$this->x = $this->lMargin;
}
else
} else {
$this->x += $w;
}
}
/*******************************************************************************
* *
/**
* Protected methods *
* *
*******************************************************************************/
*/
function _puttruetypeunicode($font) {
function _puttruetypeunicode($font)
{
// Type0 Font
$this->_newobj();
$this->_out('<</Type /Font');
@@ -184,7 +240,6 @@ function _puttruetypeunicode($font) {
$this->_out('/DescendantFonts [' . ($this->n + 1) . ' 0 R]');
$this->_out('>>');
$this->_out('endobj');
// CIDFont
$this->_newobj();
$this->_out('<</Type /Font');
@@ -194,41 +249,53 @@ function _puttruetypeunicode($font) {
$this->_out('/FontDescriptor ' . ($this->n + 1) . ' 0 R');
$c = 0;
$widths = '';
foreach ($font['cw'] as $i => $w) {
$widths .= $i . ' [' . $w . '] ';
}
$this->_out('/W [' . $widths . ']');
$this->_out('/CIDToGIDMap ' . ($this->n + 2) . ' 0 R');
$this->_out('>>');
$this->_out('endobj');
// Font descriptor
$this->_newobj();
$this->_out('<</Type /FontDescriptor');
$this->_out('/FontName /' . $font['name']);
$s = '';
foreach ($font['desc'] as $k => $v) {
$s .= ' /' . $k . ' ' . $v;
}
if ($font['file']) {
$s .= ' /FontFile2 ' . $this->FontFiles[$font['file']]['n'] . ' 0 R';
}
$this->_out($s);
$this->_out('>>');
$this->_out('endobj');
// Embed CIDToGIDMap
$this->_newobj();
if(defined('FPDF_FONTPATH'))
if (defined('FPDF_FONTPATH')) {
$file = FPDF_FONTPATH . $font['ctg'];
else
} else {
$file = $font['ctg'];
}
$size = filesize($file);
if(!$size)
if (!$size) {
$this->Error('Font file not found');
}
$this->_out('<</Length ' . $size);
if(substr($file,-2) == '.z')
if (substr($file, -2) == '.z') {
$this->_out('/Filter /FlateDecode');
}
$this->_out('>>');
$f = fopen($file, 'rb');
$this->_putstream(fread($f, $size));
@@ -253,7 +320,8 @@ function _textstring($s)
return '(' . strtr($s, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\')) . ')';
}
function _strreplace($what, $to, $where) {
function _strreplace($what, $to, $where)
{
$to = '' . $to;
return str_replace($this->utf8_to_utf16be($what, false), $this->utf8_to_utf16be($to, false), $where);
}
@@ -269,24 +337,36 @@ function _escapetext($s)
function _putinfo()
{
$this->_out('/Producer ' . $this->_textstring('UFPDF ' . UFPDF_VERSION));
if(!empty($this->title))
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')));
}
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) {
function utf8_to_utf16be(&$txt, $bom = true)
{
$l = strlen($txt);
$out = $bom ? "\xFE\xFF" : '';
for ($i = 0; $i < $l; ++$i) {
$c = ord($txt{$i});
// ASCII
@@ -296,51 +376,61 @@ function utf8_to_utf16be(&$txt, $bom = true) {
// Lost continuation byte
elseif ($c < 0xC0) {
$out .= "\xFF\xFD";
continue;
}
// Multibyte sequence leading byte
else {
if ($c < 0xE0) {
$s = 2;
}
else if ($c < 0xF0) {
} elseif ($c < 0xF0) {
$s = 3;
}
else if ($c < 0xF8) {
} elseif ($c < 0xF8) {
$s = 4;
}
// 5/6 byte sequences not possible for Unicode.
else {
$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;
}
$q = array($c);
// Fetch rest of sequence
$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
if (count($q) != $s) {
$out .= "\xFF\xFD";
continue;
}
switch ($s) {
case 2:
$cp = (($q[0] ^ 0xC0) << 6) | ($q[1] ^ 0x80);
// Overlong sequence
if ($cp < 0x80) {
$out .= "\xFF\xFD";
}
else {
} else {
$out .= chr($cp >> 8);
$out .= chr($cp &0xFF);
}
continue;
case 3:
$cp = (($q[0] ^ 0xE0) << 12) | (($q[1] ^ 0x80) << 6) | ($q[2] ^ 0x80);
// Overlong sequence
if ($cp < 0x800) {
@@ -349,14 +439,16 @@ function utf8_to_utf16be(&$txt, $bom = true) {
// Check for UTF-8 encoded surrogates (caused by a bad UTF-8 encoder)
elseif ($c > 0xD800 && $c < 0xDFFF) {
$out .= "\xFF\xFD";
}
else {
} else {
$out .= chr($cp >> 8);
$out .= chr($cp &0xFF);
}
continue;
case 4:
$cp = (($q[0] ^ 0xF0) << 18) | (($q[1] ^ 0x80) << 12) | (($q[2] ^ 0x80) << 6) | ($q[3] ^ 0x80);
// Overlong sequence
if ($cp < 0x10000) {
@@ -365,30 +457,37 @@ function utf8_to_utf16be(&$txt, $bom = true) {
// Outside of the Unicode range
elseif ($cp >= 0x10FFFF) {
$out .= "\xFF\xFD";
}
else {
} else {
// Use surrogates
$cp -= 0x10000;
$s1 = 0xD800 | ($cp >> 10);
$s2 = 0xDC00 | ($cp &0x3FF);
$out .= chr($s1 >> 8);
$out .= chr($s1 &0xFF);
$out .= chr($s2 >> 8);
$out .= chr($s2 &0xFF);
}
continue;
}
}
}
return $out;
}
// UTF-8 to codepoint array conversion.
// Correctly handles all illegal UTF-8 sequences.
function utf8_to_codepoints(&$txt) {
function utf8_to_codepoints(&$txt)
{
$l = strlen($txt);
$out = array();
for ($i = 0; $i < $l; ++$i) {
$c = ord($txt{$i});
// ASCII
@@ -398,50 +497,59 @@ function utf8_to_codepoints(&$txt) {
// Lost continuation byte
elseif ($c < 0xC0) {
$out[] = 0xFFFD;
continue;
}
// Multibyte sequence leading byte
else {
if ($c < 0xE0) {
$s = 2;
}
else if ($c < 0xF0) {
} elseif ($c < 0xF0) {
$s = 3;
}
else if ($c < 0xF8) {
} elseif ($c < 0xF8) {
$s = 4;
}
// 5/6 byte sequences not possible for Unicode.
else {
$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;
}
$q = array($c);
// Fetch rest of sequence
$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
if (count($q) != $s) {
$out[] = 0xFFFD;
continue;
}
switch ($s) {
case 2:
$cp = (($q[0] ^ 0xC0) << 6) | ($q[1] ^ 0x80);
// Overlong sequence
if ($cp < 0x80) {
$out[] = 0xFFFD;
}
else {
} else {
$out[] = $cp;
}
continue;
case 3:
$cp = (($q[0] ^ 0xE0) << 12) | (($q[1] ^ 0x80) << 6) | ($q[2] ^ 0x80);
// Overlong sequence
if ($cp < 0x800) {
@@ -450,13 +558,14 @@ function utf8_to_codepoints(&$txt) {
// Check for UTF-8 encoded surrogates (caused by a bad UTF-8 encoder)
elseif ($c > 0xD800 && $c < 0xDFFF) {
$out[] = 0xFFFD;
}
else {
} else {
$out[] = $cp;
}
continue;
case 4:
$cp = (($q[0] ^ 0xF0) << 18) | (($q[1] ^ 0x80) << 12) | (($q[2] ^ 0x80) << 6) | ($q[3] ^ 0x80);
// Overlong sequence
if ($cp < 0x10000) {
@@ -465,19 +574,19 @@ function utf8_to_codepoints(&$txt) {
// Outside of the Unicode range
elseif ($cp >= 0x10FFFF) {
$out[] = 0xFFFD;
}
else {
} else {
$out[] = $cp;
}
continue;
}
}
}
return $out;
}
// End of class
}
}
?>

View File

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

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="shortcut icon" href="./favicon.ico" type="image/x-icon" />
<title><?php
if(!empty($page_title))
if (!empty($page_title)) {
echo htmlspecialchars($page_title);
else
} else {
echo 'phpMyAdmin';
}
?></title>
<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'; ?>" />

View File

@@ -15,7 +15,8 @@ define('PMA_CHK_DROP', 1);
* @return boolean true if timeout is close
* @access public
*/
function PMA_checkTimeout() {
function PMA_checkTimeout()
{
global $timestamp, $maximum_time, $timeout_passed;
if ($maximum_time == 0) {
return FALSE;
@@ -37,16 +38,23 @@ function PMA_checkTimeout() {
* @return string MIME type of compression, none for none
* @access public
*/
function PMA_detectCompression($filepath) {
function PMA_detectCompression($filepath)
{
$file = @fopen($filepath, 'rb');
if (!$file) {
return FALSE;
}
$test = fread($file, 4);
fclose($file);
if ($test[0] == chr(31) && $test[1] == chr(139)) return 'application/gzip';
if (substr($test, 0, 3) == 'BZh') return 'application/bzip2';
if ($test == "PK\003\004") return 'application/zip';
if ($test[0] == chr(31) && $test[1] == chr(139)) {
return 'application/gzip';
}
if (substr($test, 0, 3) == 'BZh') {
return 'application/bzip2';
}
if ($test == "PK\003\004") {
return 'application/zip';
}
return 'none';
}
@@ -58,7 +66,8 @@ function PMA_detectCompression($filepath) {
* @param string query to display, this might be commented
* @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;
$read_multiply = 1;
if (isset($import_run_buffer)) {
@@ -181,19 +190,29 @@ function PMA_importRunQuery($sql = '', $full = '') {
* @return string part of file/buffer
* @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;
// Add some progression while reading large amount of data
if ($read_multiply <= 8) $size *= $read_multiply;
else $size *= 8;
if ($read_multiply <= 8) {
$size *= $read_multiply;
} else {
$size *= 8;
}
$read_multiply++;
// 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 ($finished) return TRUE;
if (PMA_checkTimeout()) {
return FALSE;
}
if ($finished) {
return TRUE;
}
if ($import_file == 'none') {
// Well this is not yet supported and tested, but should return content of textarea

View File

@@ -118,7 +118,9 @@ if ($plugin_param == 'table') {
$buffer .= $data;
// 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)
|| ($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
@@ -140,7 +142,9 @@ if ($plugin_param == 'table') {
// Grab empty field
if ($ch == $csv_terminated) {
$values[] = '';
if ($i == $len - 1) break;
if ($i == $len - 1) {
break;
}
$i++;
$ch = $buffer[$i];
continue;
@@ -149,7 +153,9 @@ if ($plugin_param == 'table') {
// Grab one field
if ($ch == $csv_enclosed) {
$need_end = TRUE;
if ($i == $len - 1) break;
if ($i == $len - 1) {
break;
}
$i++;
$ch = $buffer[$i];
} else {
@@ -176,11 +182,15 @@ if ($plugin_param == 'table') {
$i++;
$ch = $buffer[$i];
}
if ($fail) break;
if ($fail) {
break;
}
$values[] = $value;
// Need to strip trailing enclosing char?
if ($need_end && $ch == $csv_enclosed) {
if ($i == $len - 1) break;
if ($i == $len - 1) {
break;
}
$i++;
$ch = $buffer[$i];
}
@@ -190,7 +200,9 @@ if ($plugin_param == 'table') {
}
// Go to next char
if ($ch == $csv_terminated) {
if ($i == $len - 1) break;
if ($i == $len - 1) {
break;
}
$i++;
$ch = $buffer[$i];
}
@@ -199,7 +211,9 @@ if ($plugin_param == 'table') {
// End of line
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 ($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") {
$i++;
}

View File

@@ -29,7 +29,9 @@ if (isset($plugin_list)) {
// Append new data to buffer
$buffer .= $data;
// 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
$len = strlen($buffer);
@@ -40,23 +42,39 @@ if (isset($plugin_list)) {
//if ($i == $len) break;
$oi = $i;
$p1 = strpos($buffer, '\'', $i);
if ($p1 === FALSE) $p1 = 2147483647;
if ($p1 === FALSE) {
$p1 = 2147483647;
}
$p2 = strpos($buffer, '"', $i);
if ($p2 === FALSE) $p2 = 2147483647;
if ($p2 === FALSE) {
$p2 = 2147483647;
}
$p3 = strpos($buffer, ';', $i);
if ($p3 === FALSE) $p3 = 2147483647;
if ($p3 === FALSE) {
$p3 = 2147483647;
}
$p4 = strpos($buffer, '#', $i);
if ($p4 === FALSE) $p4 = 2147483647;
if ($p4 === FALSE) {
$p4 = 2147483647;
}
$p5 = strpos($buffer, '--', $i);
if ($p5 === FALSE) $p5 = 2147483647;
if ($p5 === FALSE) {
$p5 = 2147483647;
}
$p6 = strpos($buffer, '/*', $i);
if ($p6 === FALSE) $p6 = 2147483647;
if ($p6 === FALSE) {
$p6 = 2147483647;
}
$p7 = strpos($buffer, '`', $i);
if ($p7 === FALSE) $p7 = 2147483647;
if ($p7 === FALSE) {
$p7 = 2147483647;
}
$i = min ($p1, $p2, $p3, $p4, $p5, $p6, $p7);
if ($i == 2147483647) {
$i = $oi;
if (!$finished) break;
if (!$finished) {
break;
}
// at the end there might be some whitespace...
if (trim($buffer) == '') {
$buffer = '';
@@ -94,7 +112,9 @@ if (isset($plugin_list)) {
// Skip the string
$i = $pos;
}
if (!$endq) break;
if (!$endq) {
break;
}
$i++;
// Aren't we at the end?
if ($finished && $i == $len) {
@@ -131,7 +151,9 @@ if (isset($plugin_list)) {
}
}
// Skip *
if ($ch == '/') $i++;
if ($ch == '/') {
$i++;
}
// Skip last char
$i++;
// Next query part will start here
@@ -161,7 +183,9 @@ if (isset($plugin_list)) {
$i = 0;
$start_pos = 0;
// Any chance we will get a complete query?
if ((strpos($buffer, ';') === FALSE) && !$finished) break;
if ((strpos($buffer, ';') === FALSE) && !$finished) {
break;
}
} else {
$i++;
$start_pos = $i;

View File

@@ -25,88 +25,72 @@ function PMA_getIp()
if (empty($REMOTE_ADDR)) {
if (!empty($_SERVER) && isset($_SERVER['REMOTE_ADDR'])) {
$REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
}
else if (!empty($_ENV) && isset($_ENV['REMOTE_ADDR'])) {
} elseif (!empty($_ENV) && isset($_ENV['REMOTE_ADDR'])) {
$REMOTE_ADDR = $_ENV['REMOTE_ADDR'];
}
else if (@getenv('REMOTE_ADDR')) {
} elseif (@getenv('REMOTE_ADDR')) {
$REMOTE_ADDR = getenv('REMOTE_ADDR');
}
} // end if
if (empty($HTTP_X_FORWARDED_FOR)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$HTTP_X_FORWARDED_FOR = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_X_FORWARDED_FOR'])) {
} elseif (!empty($_ENV) && isset($_ENV['HTTP_X_FORWARDED_FOR'])) {
$HTTP_X_FORWARDED_FOR = $_ENV['HTTP_X_FORWARDED_FOR'];
}
else if (@getenv('HTTP_X_FORWARDED_FOR')) {
} elseif (@getenv('HTTP_X_FORWARDED_FOR')) {
$HTTP_X_FORWARDED_FOR = getenv('HTTP_X_FORWARDED_FOR');
}
} // end if
if (empty($HTTP_X_FORWARDED)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_X_FORWARDED'])) {
$HTTP_X_FORWARDED = $_SERVER['HTTP_X_FORWARDED'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_X_FORWARDED'])) {
} elseif (!empty($_ENV) && isset($_ENV['HTTP_X_FORWARDED'])) {
$HTTP_X_FORWARDED = $_ENV['HTTP_X_FORWARDED'];
}
else if (@getenv('HTTP_X_FORWARDED')) {
} elseif (@getenv('HTTP_X_FORWARDED')) {
$HTTP_X_FORWARDED = getenv('HTTP_X_FORWARDED');
}
} // end if
if (empty($HTTP_FORWARDED_FOR)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_FORWARDED_FOR'])) {
$HTTP_FORWARDED_FOR = $_SERVER['HTTP_FORWARDED_FOR'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_FORWARDED_FOR'])) {
} elseif (!empty($_ENV) && isset($_ENV['HTTP_FORWARDED_FOR'])) {
$HTTP_FORWARDED_FOR = $_ENV['HTTP_FORWARDED_FOR'];
}
else if (@getenv('HTTP_FORWARDED_FOR')) {
} elseif (@getenv('HTTP_FORWARDED_FOR')) {
$HTTP_FORWARDED_FOR = getenv('HTTP_FORWARDED_FOR');
}
} // end if
if (empty($HTTP_FORWARDED)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_FORWARDED'])) {
$HTTP_FORWARDED = $_SERVER['HTTP_FORWARDED'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_FORWARDED'])) {
} elseif (!empty($_ENV) && isset($_ENV['HTTP_FORWARDED'])) {
$HTTP_FORWARDED = $_ENV['HTTP_FORWARDED'];
}
else if (@getenv('HTTP_FORWARDED')) {
} elseif (@getenv('HTTP_FORWARDED')) {
$HTTP_FORWARDED = getenv('HTTP_FORWARDED');
}
} // end if
if (empty($HTTP_VIA)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_VIA'])) {
$HTTP_VIA = $_SERVER['HTTP_VIA'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_VIA'])) {
} elseif (!empty($_ENV) && isset($_ENV['HTTP_VIA'])) {
$HTTP_VIA = $_ENV['HTTP_VIA'];
}
else if (@getenv('HTTP_VIA')) {
} elseif (@getenv('HTTP_VIA')) {
$HTTP_VIA = getenv('HTTP_VIA');
}
} // end if
if (empty($HTTP_X_COMING_FROM)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_X_COMING_FROM'])) {
$HTTP_X_COMING_FROM = $_SERVER['HTTP_X_COMING_FROM'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_X_COMING_FROM'])) {
} elseif (!empty($_ENV) && isset($_ENV['HTTP_X_COMING_FROM'])) {
$HTTP_X_COMING_FROM = $_ENV['HTTP_X_COMING_FROM'];
}
else if (@getenv('HTTP_X_COMING_FROM')) {
} elseif (@getenv('HTTP_X_COMING_FROM')) {
$HTTP_X_COMING_FROM = getenv('HTTP_X_COMING_FROM');
}
} // end if
if (empty($HTTP_COMING_FROM)) {
if (!empty($_SERVER) && isset($_SERVER['HTTP_COMING_FROM'])) {
$HTTP_COMING_FROM = $_SERVER['HTTP_COMING_FROM'];
}
else if (!empty($_ENV) && isset($_ENV['HTTP_COMING_FROM'])) {
} elseif (!empty($_ENV) && isset($_ENV['HTTP_COMING_FROM'])) {
$HTTP_COMING_FROM = $_ENV['HTTP_COMING_FROM'];
}
else if (@getenv('HTTP_COMING_FROM')) {
} elseif (@getenv('HTTP_COMING_FROM')) {
$HTTP_COMING_FROM = getenv('HTTP_COMING_FROM');
}
} // end if

View File

@@ -50,7 +50,7 @@ if (PMA_MYSQL_INT_VERSION >= 40100){
define('PMA_CSDROPDOWN_COLLATION', 0);
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;
if (empty($name)) {

View File

@@ -80,7 +80,9 @@ function PMA_splitSqlFile(&$ret, $sql, $release)
if ($i === FALSE) {
break;
}
if ($char == '/') $i++;
if ($char == '/') {
$i++;
}
}
// We are not in a string, first check for delimiter...
@@ -151,8 +153,12 @@ function PMA_readFile($path, $mime = '') {
}
$test = fread($file, 3);
fclose($file);
if ($test[0] == chr(31) && $test[1] == chr(139)) return PMA_readFile($path, 'application/x-gzip');
if ($test == 'BZh') return PMA_readFile($path, 'application/x-bzip');
if ($test[0] == chr(31) && $test[1] == chr(139)) {
return PMA_readFile($path, 'application/x-gzip');
}
if ($test == 'BZh') {
return PMA_readFile($path, 'application/x-bzip');
}
return PMA_readFile($path, 'text/plain');
case 'text/plain':
$file = @fopen($path, 'rb');

View File

@@ -583,7 +583,7 @@ function PMA_setComment($db, $table, $col, $comment, $removekey = '', $mode='aut
if ($mode == 'native' && isset($table) && strlen($table)) {
$query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHANGE '
. 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;
}
@@ -884,13 +884,13 @@ function PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, $ma
$bot = $reloptions[$cfg['ForeignKeyDropdownOrder'][1]];
} elseif ($c == 1) {
$bot = $reloptions[$cfg['ForeignKeyDropdownOrder'][0]];
$top = NULL;
$top = null;
} else {
$top = $reloptions['id-content'];
$bot = $reloptions['content-id'];
}
$str_bot = implode('', $bot);
if($top !== NULL) {
if ($top !== null) {
$str_top = implode('', $top);
$top_count = count($top);
if ($max == -1 || $top_count < $max) {

View File

@@ -23,7 +23,8 @@
* @uses explode()
* @return bool success if valid lang is found, otherwise false
*/
function PMA_langCheck() {
function PMA_langCheck()
{
// check forced language
if (! empty($GLOBALS['cfg']['Lang'])) {
if (PMA_langSet($GLOBALS['cfg']['Lang'])) {
@@ -82,7 +83,8 @@ function PMA_langCheck() {
* @param string $lang language to set
* @return bool success
*/
function PMA_langSet( &$lang ) {
function PMA_langSet(&$lang)
{
if (empty($lang) || empty($GLOBALS['available_languages'][$lang])) {
return false;
}
@@ -103,9 +105,14 @@ function PMA_langSet( &$lang ) {
*
* @access private
*/
function PMA_langDetect( &$str, $envType ) {
if ( empty( $str ) ) return false;
if ( empty( $GLOBALS['available_languages'] ) ) return false;
function PMA_langDetect(&$str, $envType)
{
if (empty($str)) {
return false;
}
if (empty($GLOBALS['available_languages'])) {
return false;
}
foreach ($GLOBALS['available_languages'] as $lang => $value) {
// $envType = 1 for the 'HTTP_ACCEPT_LANGUAGE' environment variable,

View File

@@ -51,7 +51,7 @@ if ($is_superuser) {
}
$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 (PMA_DBI_num_rows($binlogs) > 0) {
$binary_logs = array();

View File

@@ -29,9 +29,7 @@ if (!@function_exists('session_name')) {
. '&char=' . urlencode($charset)
. '&dir=' . urlencode($text_dir)
. '&type=' . urlencode($strError)
. '&error=' . urlencode(
sprintf($strCantLoad, 'session'))
);
. '&error=' . urlencode(sprintf($strCantLoad, 'session')));
exit();
}
@@ -82,7 +80,8 @@ if ( version_compare( PHP_VERSION, '5.0.0', 'ge' )
* @uses strip_tags() to prevent XSS attacks in SID
* @uses function_exists() for session_regenerate_id()
*/
function PMA_secureSession() {
function PMA_secureSession()
{
// prevent session fixation and XSS
if (function_exists('session_regenerate_id')) {
session_regenerate_id(true);

View File

@@ -58,7 +58,8 @@ require_once('./libraries/bookmark.lib.php'); // used for file listing
* what part to display
* 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
if (! $display_tab) {
$display_tab = 'full';
@@ -177,7 +178,8 @@ function PMA_sqlQueryForm( $query = true, $display_tab = false ) {
* @param string $query query to display in the textarea
* @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
if ($GLOBALS['cfg']['TextareaAutoSelect']) {
@@ -382,7 +384,8 @@ function PMA_sqlQueryFormInsert( $query = '', $is_querywindow = false ) {
* @uses count()
* @uses htmlspecialchars()
*/
function PMA_sqlQueryFormBookmark() {
function PMA_sqlQueryFormBookmark()
{
$bookmark_list = PMA_listBookmarks(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', $GLOBALS['cfg']['Bookmark'] );
if (! $bookmark_list || count($bookmark_list) < 1) {
return;
@@ -525,7 +528,7 @@ function PMA_sqlQueryFormUpload() {
} elseif (PMA_MYSQL_INT_VERSION >= 40100) {
echo $GLOBALS['strCharsetOfFile'] . "\n";
echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET,
'charset_of_file', NULL, 'utf8', FALSE );
'charset_of_file', null, 'utf8', FALSE);
} // end if (recoding)
echo '<input type="submit" name="SQL" value="' . $GLOBALS['strGo']
.'" />' . "\n";

View File

@@ -77,7 +77,8 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
* @access public
*/
// Added, Robbat2 - 13 Janurary 2003, 2:59PM
function PMA_SQP_resetError() {
function PMA_SQP_resetError()
{
global $SQP_errorString;
$SQP_errorString = '';
unset($SQP_errorString);
@@ -91,7 +92,8 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
* @access public
*/
// Added, Robbat2 - 13 Janurary 2003, 2:59PM
function PMA_SQP_getErrorString() {
function PMA_SQP_getErrorString()
{
global $SQP_errorString;
return isset($SQP_errorString) ? $SQP_errorString : '';
}
@@ -104,7 +106,8 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
* @access public
*/
// Added, Robbat2 - 13 Janurary 2003, 2:59PM
function PMA_SQP_isError() {
function PMA_SQP_isError()
{
global $SQP_errorString;
return isset($SQP_errorString) && !empty($SQP_errorString);
}
@@ -394,11 +397,15 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
if ($is_hex_digit) {
$count2++;
$pos = strspn($sql, '0123456789abcdefABCDEF', $count2);
if ($pos > $count2) $count2 = $pos;
if ($pos > $count2) {
$count2 = $pos;
}
unset($pos);
} elseif ($is_digit) {
$pos = strspn($sql, '0123456789', $count2);
if ($pos > $count2) $count2 = $pos;
if ($pos > $count2) {
$count2 = $pos;
}
unset($pos);
}
}
@@ -456,8 +463,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
} else {
$type .= '_integer';
}
}
else {
} else {
if ($is_sql_variable != FALSE) {
$type = 'alpha_variable';
} else {
@@ -499,12 +505,10 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
break;
}
PMA_SQP_arrayAdd($sql_array, 'punct' . $t_suffix, $punct_data, $arraysize);
}
else if (PMA_STR_binarySearchInArr($punct_data, $allpunct_list_pair, $allpunct_list_pair_size)) {
} elseif (PMA_STR_binarySearchInArr($punct_data, $allpunct_list_pair, $allpunct_list_pair_size)) {
// Ok, we have one of the valid combined punct expressions
PMA_SQP_arrayAdd($sql_array, 'punct', $punct_data, $arraysize);
}
else {
} else {
// Bad luck, lets split it up more
$first = $punct_data[0];
$first2 = $punct_data[0] . $punct_data[1];
@@ -703,7 +707,9 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
*/
function PMA_SQP_analyze($arr)
{
if ($arr == array()) return array();
if ($arr == array()) {
return array();
}
$result = array();
$size = $arr['len'];
$subresult = array(
@@ -1978,7 +1984,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
// array_push($typearr, $arr[$i + 1]['type']);
$typearr[4] = $arr[$i + 1]['type'];
} else {
//array_push($typearr, NULL);
//array_push($typearr, null);
$typearr[4] = '';
}

View File

@@ -54,8 +54,8 @@ if (!function_exists('class_exists') || !class_exists('SOAP_Client')) {
var $connection_technology_version;
var $interactive;
var $service_link = NULL;
var $session_data = NULL;
var $service_link = null;
var $session_data = null;
/**
@@ -185,8 +185,8 @@ if (!function_exists('class_exists') || !class_exists('SOAP_Client')) {
$this->connection_technology_version = phpversion();
$this->interactive = 1;
$this->service_link = NULL;
$this->session_data = NULL;
$this->service_link = null;
$this->session_data = null;
} // 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->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)) {
// Reopens the service on the new URL that was provided
$url = $this->session_data->target;

View File

@@ -50,8 +50,7 @@ if ($action == 'tbl_create.php') {
?>
<input type="hidden" name="reload" value="1" />
<?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="after_field" value="<?php echo $after_field; ?>" />
@@ -244,8 +243,7 @@ for ( $i = 0 ; $i <= $num_fields; $i++ ) {
if (empty($row['Type'])) {
$row['Type'] = '';
$type = '';
}
else {
} else {
$type = $row['Type'];
}
// set or enum types: slashes single quotes inside options
@@ -323,7 +321,7 @@ for ( $i = 0 ; $i <= $num_fields; $i++ ) {
$ci++;
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);
unset($tmp_collation);
$ci++;
@@ -613,7 +611,7 @@ var odd_row = <?php echo $odd_row; ?>;
function addField() {
var new_fields = document.getElementById('added_fields').value;
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;
for ( i = 0; i < new_fields; i++ ) {
if ( odd_row ) {
@@ -653,13 +651,13 @@ if ($action == 'tbl_create.php') {
</td>
<td width="25">&nbsp;</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>
<?php
if ( PMA_MYSQL_INT_VERSION >= 40100 ) {
echo ' <td width="25">&nbsp;</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";
}
?>

View File

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

View File

@@ -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
if (isset($me_fields_type[$encoded_key])) $type = $me_fields_type[$encoded_key];
else $type = '';
if (isset($me_fields_type[$encoded_key])) {
$type = $me_fields_type[$encoded_key];
} else {
$type = '';
}
$f = 'field_' . md5($key);
$t_fval = (isset($$f) ? $$f : null);

View File

@@ -106,7 +106,8 @@
* @uses SimpleUnzip::ReadFile() Opens file on new if specified
* @since 1.0
*/
function SimpleUnzip($in_FileName = '') {
function SimpleUnzip($in_FileName = '')
{
if ($in_FileName !== '') {
SimpleUnzip::ReadFile($in_FileName);
}
@@ -120,7 +121,8 @@
* @uses $Entries
* @since 1.0
*/
function Count() {
function Count()
{
return count($this->Entries);
} // end of the 'Count()' method
@@ -133,7 +135,8 @@
* @access public
* @since 1.0
*/
function GetData($in_Index) {
function GetData($in_Index)
{
return $this->Entries[$in_Index]->Data;
} // end of the 'GetData()' method
@@ -146,7 +149,8 @@
* @access public
* @since 1.0
*/
function GetEntry($in_Index) {
function GetEntry($in_Index)
{
return $this->Entries[$in_Index];
} // end of the 'GetEntry()' method
@@ -159,7 +163,8 @@
* @access public
* @since 1.0
*/
function GetError($in_Index) {
function GetError($in_Index)
{
return $this->Entries[$in_Index]->Error;
} // end of the 'GetError()' method
@@ -172,7 +177,8 @@
* @access public
* @since 1.0
*/
function GetErrorMsg($in_Index) {
function GetErrorMsg($in_Index)
{
return $this->Entries[$in_Index]->ErrorMsg;
} // end of the 'GetErrorMsg()' method
@@ -185,7 +191,8 @@
* @access public
* @since 1.0
*/
function GetName($in_Index) {
function GetName($in_Index)
{
return $this->Entries[$in_Index]->Name;
} // end of the 'GetName()' method
@@ -198,7 +205,8 @@
* @access public
* @since 1.0
*/
function GetPath($in_Index) {
function GetPath($in_Index)
{
return $this->Entries[$in_Index]->Path;
} // end of the 'GetPath()' method
@@ -211,7 +219,8 @@
* @access public
* @since 1.0
*/
function GetTime($in_Index) {
function GetTime($in_Index)
{
return $this->Entries[$in_Index]->Time;
} // end of the 'GetTime()' method
@@ -224,7 +233,8 @@
* @access public
* @since 1.0
*/
function ReadFile($in_FileName) {
function ReadFile($in_FileName)
{
$this->Entries = array();
// Get file parameters
@@ -300,13 +310,11 @@
if (strlen($vZ) != $aP['CS']) {
$aI['E'] = 1;
$aI['EM'] = 'Compressed size is not equal with the value in header information.';
}
else {
} else {
if ($bE) {
$aI['E'] = 5;
$aI['EM'] = 'File is encrypted, which is not supported from this class.';
}
else {
} else {
switch($aP['CM']) {
case 0: // Stored
// Here is nothing to do, the file ist flat.
@@ -321,8 +329,7 @@
if (! extension_loaded('bz2')) {
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
@dl('php_bz2.dll');
}
else {
} else {
@dl('bz2.so');
}
}
@@ -331,8 +338,7 @@
// 2003-12-02 - HB <
$vZ = bzdecompress($vZ);
// 2003-12-02 - HB >
}
else {
} else {
$aI['E'] = 7;
$aI['EM'] = "PHP BZIP2 extension not available.";
}
@@ -351,13 +357,11 @@
if ($vZ === FALSE) {
$aI['E'] = 2;
$aI['EM'] = 'Decompression of data failed.';
}
else {
} else {
if (strlen($vZ) != $aP['UCS']) {
$aI['E'] = 3;
$aI['EM'] = 'Uncompressed size is not equal with the value in header information.';
}
else {
} else {
if (crc32($vZ) != $aP['CRC']) {
$aI['E'] = 4;
$aI['EM'] = 'CRC32 checksum is not equal with the value in header information.';
@@ -475,7 +479,8 @@
* @access public
* @since 1.0
*/
function SimpleUnzipEntry($in_Entry) {
function SimpleUnzipEntry($in_Entry)
{
$this->Data = $in_Entry['D'];
$this->Error = $in_Entry['E'];
$this->ErrorMsg = $in_Entry['EM'];

View File

@@ -65,10 +65,14 @@ function PMA_generate_common_hidden_inputs( $db = '', $table = '', $indent = 0,
}
if ( ! is_array($skip) ) {
if ( isset( $params[$skip] ) ) unset( $params[$skip] );
if ( isset( $params[$skip] ) ) {
unset( $params[$skip] );
}
} else {
foreach ( $skip as $skipping ) {
if ( isset( $params[$skipping] ) ) unset( $params[$skipping] );
if ( isset( $params[$skipping] ) ) {
unset( $params[$skipping] );
}
}
}

View File

@@ -90,8 +90,8 @@ if (!$cfg['LeftDisplayServers'] && (count($cfg['Servers']) > 1 || $server == 0 &
if ( $server > 0 ) {
echo '<ul>' . "\n";
PMA_printListItem( $strProtocolVersion . ': ' . PMA_DBI_get_proto_info()
, 'li_mysql_proto' );
PMA_printListItem( $strProtocolVersion . ': ' . PMA_DBI_get_proto_info(),
'li_mysql_proto' );
PMA_printListItem( $strServer . ': ' . $server_info, 'li_server_info' );
PMA_printListItem( $strUser . ': ' . htmlspecialchars( $mysql_cur_user_and_host ),
'li_user_info' );
@@ -131,7 +131,7 @@ if ( $server > 0 ) {
. ' </li>' . "\n"
. ' <li id="li_select_mysql_collation">';
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"
. ' ' . $strMySQLConnectionCollation . ': ' . "\n"
. ' </label>' . "\n"
@@ -172,7 +172,7 @@ if ( $server > 0 ) {
'./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 (PMA_DBI_num_rows($binlogs) > 0) {
PMA_printListItem( $strBinaryLog, 'li_mysql_binlogs',
@@ -371,18 +371,19 @@ if (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION < 32332) {
* @param string $id id, used for css styles
* @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 . '">';
if ( NULL !== $url ) {
if (null !== $url) {
echo '<a href="' . $url . '">';
}
echo $name;
if ( NULL !== $url ) {
if (null !== $url) {
echo '</a>' . "\n";
}
if ( NULL !== $mysql_help_page ) {
if (null !== $mysql_help_page) {
echo PMA_showMySQLDocu('', $mysql_help_page);
}
echo '</li>';

View File

@@ -223,7 +223,7 @@ if ($cfgRelation['pdfwork']) {
// We will need an array of all tables in this db
$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)) {
$selectboxall[] = $val[0];
}

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -510,12 +510,15 @@ function compress_servers(&$cfg) {
*
* @return array array with grabbed values
*/
function grab_values($list) {
function grab_values($list)
{
$a = split(';', $list);
$res = array();
foreach ($a as $val) {
$v = split(':', $val);
if (!isset($v[1])) $v[1] = '';
if (!isset($v[1])) {
$v[1] = '';
}
switch($v[1]) {
case 'bool':
$res[$v[0]] = isset($_POST[$v[0]]);
@@ -605,7 +608,9 @@ function show_overview($title, $list, $buttons = '') {
function show_config_form($list, $legend, $help, $defaults = array(), $save = '', $prefix = '') {
global $PMA_Config;
if (empty($save)) $save = 'Update';
if (empty($save)) {
$save = 'Update';
}
echo '<fieldset class="optbox">' . "\n";
echo '<legend>' . $legend . '</legend>' . "\n";
@@ -614,9 +619,13 @@ function show_config_form($list, $legend, $help, $defaults = array(), $save = ''
echo '<div class="opts">';
$type = 'text';
if (isset($val[3])) {
if (is_array($val[3])) $type = 'select';
elseif (is_bool($val[3])) $type = 'check';
elseif ($val[3] == 'password') $type = 'password';
if (is_array($val[3])) {
$type = 'select';
} elseif (is_bool($val[3])) {
$type = 'check';
} elseif ($val[3] == 'password') {
$type = 'password';
}
}
switch ($type) {
case 'text':
@@ -1078,7 +1087,9 @@ function show_window_form($defaults = array()) {
* @return string HTML for server selection
*/
function get_server_selection($cfg) {
if (count($cfg['Servers']) == 0) return '';
if (count($cfg['Servers']) == 0) {
return '';
}
$ret = '<select name="server">';
foreach ($cfg['Servers'] as $key => $val) {
$ret .= '<option value="' . $key . '">' . get_server_name($val, $key) . '</option>';
@@ -1300,11 +1311,15 @@ switch ($action) {
show_server_form($defaults);
break;
case 'editserver':
if (!isset($_POST['server'])) footer();
if (!isset($_POST['server'])) {
footer();
}
show_server_form($configuration['Servers'][$_POST['server']], $_POST['server']);
break;
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']));
unset($configuration['Servers'][$_POST['server']]);
compress_servers($configuration);

View File

@@ -24,7 +24,9 @@ echo '<h2>' . "\n"
. ' ' . $strBinaryLog . "\n"
. '</h2>' . "\n";
if (!isset($log)) $log = '';
if (!isset($log)) {
$log = '';
}
/**
* Display log selector.
@@ -48,7 +50,9 @@ if (count($binary_logs) > 1) {
$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

View File

@@ -111,7 +111,7 @@ echo '<h2>' . "\n"
* Gets the databases list
*/
if ($server > 0) {
$databases = PMA_DBI_get_databases_full( NULL, $dbstats );
$databases = PMA_DBI_get_databases_full(null, $dbstats);
} else {
$databases = array();
}

View File

@@ -567,11 +567,15 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0 ) {
if ($val['Field'] == 'User') {
strtok($val['Type'], '()');
$v = strtok('()');
if (is_int($v)) $username_length = $v;
if (is_int($v)) {
$username_length = $v;
}
} elseif ($val['Field'] == 'Host') {
strtok($val['Type'], '()');
$v = strtok('()');
if (is_int($v)) $hostname_length = $v;
if (is_int($v)) {
$hostname_length = $v;
}
}
}
unset($fields_info);
@@ -743,7 +747,7 @@ if (!empty($adduser_submit) || !empty($change_copy)) {
.' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted')
.' AND ' . PMA_convert_using('Host')
.' = ' . PMA_convert_using($hostname, 'quoted') . ';',
NULL, PMA_DBI_QUERY_STORE );
null, PMA_DBI_QUERY_STORE);
if (PMA_DBI_num_rows($res) == 1) {
PMA_DBI_free_result($res);
$message = sprintf($GLOBALS['strUserAlreadyExists'], '[i]\'' . $username . '\'@\'' . $hostname . '\'[/i]');
@@ -884,7 +888,7 @@ if (!empty($change_copy)) {
.' AND ' . PMA_convert_using('`Table_name`')
.' = ' . PMA_convert_using($row['Table_name'], 'quoted')
.';',
NULL, PMA_DBI_QUERY_STORE );
null, PMA_DBI_QUERY_STORE);
$tmp_privs1 = PMA_extractPrivInfo($row);
$tmp_privs2 = array(
@@ -1286,7 +1290,7 @@ if ( empty( $adduser ) && ( ! isset( $checkprivs ) || ! strlen($checkprivs) ) )
$sql_query .= (isset($initial) ? PMA_RangeOfUsers($initial) : '');
$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) {
// the query failed! This may have two reasons:
@@ -1295,7 +1299,7 @@ if ( empty( $adduser ) && ( ! isset( $checkprivs ) || ! strlen($checkprivs) ) )
// so let's try a more simple query
$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) {
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)) {
$array_initials[$tmp_initial] = TRUE;
}
@@ -1557,7 +1561,7 @@ if ( empty( $adduser ) && ( ! isset( $checkprivs ) || ! strlen($checkprivs) ) )
}
}
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);
PMA_DBI_free_result($res);
unset($res);
@@ -1842,7 +1846,7 @@ if ( empty( $adduser ) && ( ! isset( $checkprivs ) || ! strlen($checkprivs) ) )
} else {
echo ' <input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '"/>' . "\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();
while ($row = PMA_DBI_fetch_row($res)) {
if (!isset($found_rows) || !in_array($row[0], $found_rows)) {

View File

@@ -304,7 +304,7 @@ foreach ( $server_status as $name => $value ) {
unset( $server_status[$name] );
} else {
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] ) ) {
unset( $server_status[$name] );
$sections[$section]['vars'][$name] = $value;

13
sql.php
View File

@@ -372,13 +372,12 @@ else {
if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
unset($result);
$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
list($usec, $sec) = explode(' ', microtime());
$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());
$querytime_after = ((float)$usec + (float)$sec);
@@ -430,8 +429,7 @@ else {
// if we did not append a limit, set this to get a correct
// "Showing rows..." message
$GLOBALS['session_max_rows'] = 'all';
}
else if ($is_select) {
} elseif ($is_select) {
// c o u n t q u e r y
@@ -643,7 +641,7 @@ else {
if (!isset($table)) {
$goto = 'db_details.php';
} 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))) {
$goto = 'db_details.php';
unset($table);
@@ -675,8 +673,7 @@ else {
}
$active_page = $goto;
require('./' . $goto);
} // end if file_exist
else {
} else {
PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto) . '&message=' . urlencode($message));
} // end else
exit();

View File

@@ -136,7 +136,7 @@ unset($show_create_table);
* Get the list of the fields of the current table
*/
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 (is_array($primary_key)) {
$primary_key_array = $primary_key;
@@ -148,7 +148,7 @@ if (isset($primary_key)) {
$result = array();
foreach ($primary_key_array AS $rowcount => $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]);
$primary_keys[$rowcount] = $primary_key;
@@ -178,7 +178,7 @@ if (isset($primary_key)) {
} // end if (no record returned)
}
} 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);
}
@@ -212,7 +212,7 @@ document.onkeydown = onKeyDownArrowsHandler;
<?php } ?>
<!-- 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); ?>
<input type="hidden" name="goto" value="<?php echo urlencode($goto); ?>" />
<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['Null'])
&& $row_table_def['Null'] == 'YES') {
$row_table_def['Default'] = NULL;
$row_table_def['Default'] = null;
}
if ($row_table_def['Type'] == 'datetime'
@@ -636,8 +636,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
</td>
<?php
unset($disp_row);
}
else if ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) {
} elseif ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) {
?>
<td bgcolor="<?php echo $bgcolor; ?>">&nbsp;</td>
</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>
</td>
<?php
}
else if (strstr($type, 'text')) {
} elseif (strstr($type, 'text')) {
?>
<td bgcolor="<?php echo $bgcolor; ?>">
<?php echo $backup_field . "\n"; ?>
@@ -661,8 +659,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
if (strlen($special_chars) > 32000) {
echo ' <td bgcolor="' . $bgcolor . '">' . $strTextAreaLength . '</td>' . "\n";
}
}
else if ($type == 'enum') {
} elseif ($type == 'enum') {
$enum = PMA_getEnumSetOptions($row_table_def['Type']);
$enum_cnt = count($enum);
?>
@@ -698,8 +695,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
?>
</select>
<?php
} // end if
else {
} else {
echo "\n";
for ($j = 0; $j < $enum_cnt; $j++) {
// Removes automatic MySQL escape format
@@ -721,8 +717,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
</td>
<?php
echo "\n";
}
else if ($type == 'set') {
} elseif ($type == 'set') {
$set = PMA_getEnumSetOptions($row_table_def['Type']);
if (isset($vset)) {
@@ -855,8 +850,7 @@ foreach ($loop_array AS $vrowcount => $vrow) {
if ($is_char) {
$fieldsize = (($len > 40) ? 40 : $len);
$maxlength = $len;
}
else {
} else {
$fieldsize = 20;
$maxlength = 99;
} // end if... else...
@@ -948,8 +942,8 @@ if (!empty($disp_message)) {
<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>
<?php
if (isset($primary_key))
{?>
if (isset($primary_key)) {
?>
<option value="same_insert"><?php echo $strAfterInsertSame; ?></option>
<?php
// If we have just numeric primary key, we can also edit next

View File

@@ -36,7 +36,7 @@ if (!defined('PMA_IDX_INCLUDED')) {
// Not a valid table name -> back to the default db_details sub-page
if ( isset($table) && strlen($table) ) {
$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)
|| !( $is_table && PMA_DBI_num_rows($is_table) ) ) {
@@ -343,7 +343,7 @@ else if (!defined('PMA_IDX_INCLUDED')
<tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
<td><select name="column[]">
<option value="--ignore--"
<?php if ('--ignore--' == $selected) echo ' selected="selected"'; ?>>
<?php if ('--ignore--' == $selected) { echo ' selected="selected"'; } ?>>
-- <?php echo $strIgnore; ?> --</option>
<?php
foreach ($fields_names AS $key => $val) {

View File

@@ -44,7 +44,7 @@ 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/)
*/
if (isset($selected_tbl) && is_array($selected_tbl)) {
@@ -102,7 +102,7 @@ foreach ($the_tables AS $key => $table) {
/**
* 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);
// Check if we can use Relations (Mike Beck)
@@ -116,8 +116,7 @@ foreach ($the_tables AS $key => $table) {
} else {
$have_rel = FALSE;
}
}
else {
} else {
$have_rel = FALSE;
} // 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="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="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>-->
<?php
echo "\n";

View File

@@ -75,7 +75,7 @@ while ($row = PMA_DBI_fetch_assoc($result)) {
PMA_DBI_free_result($result);
// 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);
// 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" : '' ?>
<td nowrap="nowrap" style="font-size: 70%"><?php echo $attribute; ?></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 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'] . '`' ); ?>">
@@ -723,11 +723,9 @@ if ( $cfg['ShowStats'] ) {
<td class="value"><?php
if ($showtable['Row_format'] == 'Fixed') {
echo $strFixed;
}
else if ($showtable['Row_format'] == 'Dynamic') {
} elseif ($showtable['Row_format'] == 'Dynamic') {
echo $strDynamic;
}
else {
} else {
echo $showtable['Row_format'];
}
?></td>

View File

@@ -39,8 +39,8 @@ $options_array = array('CASCADE' => 'CASCADE', 'SET_NULL' => 'SET NULL', 'NO_ACT
*
* @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 '<select name="' . $radio_name . '">' . "\n";
@@ -281,7 +281,7 @@ if ($cfgRelation['relwork'] || $tbl_type=='INNODB') {
}
// [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_innodb['nix'] = '--';
@@ -290,7 +290,7 @@ if ($cfgRelation['relwork'] || $tbl_type=='INNODB') {
PMA_DBI_select_db($db);
// 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) {
$seen_a_primary = FALSE;
while ($curr_field = PMA_DBI_fetch_assoc($fi_rs)) {
@@ -337,7 +337,7 @@ if ($cfgRelation['relwork'] || $tbl_type=='INNODB') {
PMA_DBI_select_db($db);
// 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) {
while ($curr_field = PMA_DBI_fetch_assoc($fi_rs)) {
$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
// 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) {
while ($row = PMA_DBI_fetch_assoc($col_rs)) {

View File

@@ -122,7 +122,9 @@ $message = '';
foreach ($loop_array AS $primary_key_index => $enc_primary_key) {
// 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
$primary_key = urldecode($enc_primary_key);

View File

@@ -49,7 +49,7 @@ if (!isset($param) || $param[0] == '') {
$err_url = $goto . '?' . PMA_generate_common_url($db, $table);
// 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);
// rabue: we'd better ensure, that all arrays are empty.
$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
*/
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)) {
$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);
} 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);
}