Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f087fa5d46
@ -114,6 +114,7 @@ abstract class PMA_List extends ArrayObject
|
||||
/**
|
||||
* builds up the list
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract public function build();
|
||||
}
|
||||
|
||||
@ -34,31 +34,31 @@ class PMA_List_Database extends PMA_List
|
||||
* @var mixed database link resource|object to be used
|
||||
* @access protected
|
||||
*/
|
||||
protected $_db_link = null;
|
||||
protected $db_link = null;
|
||||
|
||||
/**
|
||||
* @var mixed user database link resource|object
|
||||
* @access protected
|
||||
*/
|
||||
protected $_db_link_user = null;
|
||||
protected $db_link_user = null;
|
||||
|
||||
/**
|
||||
* @var mixed controluser database link resource|object
|
||||
* @access protected
|
||||
*/
|
||||
protected $_db_link_control = null;
|
||||
protected $db_link_control = null;
|
||||
|
||||
/**
|
||||
* @var boolean whether SHOW DATABASES is disabled or not
|
||||
* @access protected
|
||||
*/
|
||||
protected $_show_databases_disabled = false;
|
||||
protected $show_databases_disabled = false;
|
||||
|
||||
/**
|
||||
* @var string command to retrieve databases from server
|
||||
* @access protected
|
||||
*/
|
||||
protected $_command = null;
|
||||
protected $command = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -70,9 +70,9 @@ class PMA_List_Database extends PMA_List
|
||||
*/
|
||||
public function __construct($db_link_user = null, $db_link_control = null)
|
||||
{
|
||||
$this->_db_link = $db_link_user;
|
||||
$this->_db_link_user = $db_link_user;
|
||||
$this->_db_link_control = $db_link_control;
|
||||
$this->db_link = $db_link_user;
|
||||
$this->db_link_user = $db_link_user;
|
||||
$this->db_link_control = $db_link_control;
|
||||
|
||||
parent::__construct();
|
||||
$this->build();
|
||||
@ -83,7 +83,7 @@ class PMA_List_Database extends PMA_List
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _checkHideDatabase()
|
||||
protected function checkHideDatabase()
|
||||
{
|
||||
if (empty($GLOBALS['cfg']['Server']['hide_db'])) {
|
||||
return;
|
||||
@ -104,33 +104,33 @@ class PMA_List_Database extends PMA_List
|
||||
* @return array
|
||||
* @todo we could also search mysql tables if all fail?
|
||||
*/
|
||||
protected function _retrieve($like_db_name = null)
|
||||
protected function retrieve($like_db_name = null)
|
||||
{
|
||||
if ($this->_show_databases_disabled) {
|
||||
if ($this->show_databases_disabled) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (null !== $like_db_name) {
|
||||
$command = "SHOW DATABASES LIKE '" . $like_db_name . "'";
|
||||
} elseif (null === $this->_command) {
|
||||
} elseif (null === $this->command) {
|
||||
$command = str_replace(
|
||||
'#user#', $GLOBALS['cfg']['Server']['user'],
|
||||
$GLOBALS['cfg']['Server']['ShowDatabasesCommand']
|
||||
);
|
||||
$this->_command = $command;
|
||||
$this->command = $command;
|
||||
} else {
|
||||
$command = $this->_command;
|
||||
$command = $this->command;
|
||||
}
|
||||
|
||||
$database_list = PMA_DBI_fetch_result($command, null, null, $this->_db_link);
|
||||
$database_list = PMA_DBI_fetch_result($command, null, null, $this->db_link);
|
||||
PMA_DBI_getError();
|
||||
|
||||
if ($GLOBALS['errno'] !== 0) {
|
||||
// failed to get database list, try the control user
|
||||
// (hopefully there is one and he has SHOW DATABASES right)
|
||||
$this->_db_link = $this->_db_link_control;
|
||||
$this->db_link = $this->db_link_control;
|
||||
$database_list = PMA_DBI_fetch_result(
|
||||
$command, null, null, $this->_db_link
|
||||
$command, null, null, $this->db_link
|
||||
);
|
||||
|
||||
PMA_DBI_getError();
|
||||
@ -140,7 +140,7 @@ class PMA_List_Database extends PMA_List
|
||||
// retrieve database list, the admin has to setup a control user or
|
||||
// allow SHOW DATABASES
|
||||
$GLOBALS['error_showdatabases'] = true;
|
||||
$this->_show_databases_disabled = true;
|
||||
$this->show_databases_disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,12 +162,12 @@ class PMA_List_Database extends PMA_List
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
if (! $this->_checkOnlyDatabase()) {
|
||||
$items = $this->_retrieve();
|
||||
if (! $this->checkOnlyDatabase()) {
|
||||
$items = $this->retrieve();
|
||||
$this->exchangeArray($items);
|
||||
}
|
||||
|
||||
$this->_checkHideDatabase();
|
||||
$this->checkHideDatabase();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -175,7 +175,7 @@ class PMA_List_Database extends PMA_List
|
||||
*
|
||||
* @return boolean false if there is no only_db, otherwise true
|
||||
*/
|
||||
protected function _checkOnlyDatabase()
|
||||
protected function checkOnlyDatabase()
|
||||
{
|
||||
if (is_string($GLOBALS['cfg']['Server']['only_db'])
|
||||
&& strlen($GLOBALS['cfg']['Server']['only_db'])
|
||||
@ -192,10 +192,10 @@ class PMA_List_Database extends PMA_List
|
||||
$items = array();
|
||||
|
||||
foreach ($GLOBALS['cfg']['Server']['only_db'] as $each_only_db) {
|
||||
if ($each_only_db === '*' && ! $this->_show_databases_disabled) {
|
||||
if ($each_only_db === '*' && ! $this->show_databases_disabled) {
|
||||
// append all not already listed dbs to the list
|
||||
$items = array_merge(
|
||||
$items, array_diff($this->_retrieve(), $items)
|
||||
$items, array_diff($this->retrieve(), $items)
|
||||
);
|
||||
// there can only be one '*', and this can only be last
|
||||
break;
|
||||
@ -209,8 +209,8 @@ class PMA_List_Database extends PMA_List
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! $this->_show_databases_disabled) {
|
||||
$items = array_merge($items, $this->_retrieve($each_only_db));
|
||||
if (! $this->show_databases_disabled) {
|
||||
$items = array_merge($items, $this->retrieve($each_only_db));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -441,7 +441,7 @@ class PMA_List_Database extends PMA_List
|
||||
* @deprecated
|
||||
* @return void
|
||||
*/
|
||||
protected function _checkAgainstPrivTables()
|
||||
protected function checkAgainstPrivTables()
|
||||
{
|
||||
// 1. get allowed dbs from the "mysql.db" table
|
||||
// User can be blank (anonymous user)
|
||||
|
||||
@ -252,7 +252,8 @@ class PMA_StorageEngine
|
||||
if (isset($variables[$row['Variable_name']])) {
|
||||
$mysql_vars[$row['Variable_name']] = $variables[$row['Variable_name']];
|
||||
} elseif (! $like
|
||||
&& strpos(strtolower($row['Variable_name']), strtolower($this->engine)) !== 0) {
|
||||
&& strpos(strtolower($row['Variable_name']), strtolower($this->engine)) !== 0
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
$mysql_vars[$row['Variable_name']]['value'] = $row['Value'];
|
||||
|
||||
@ -293,13 +293,18 @@ class PMA_Theme_Manager
|
||||
// check for themes directory
|
||||
while (false !== ($PMA_Theme = readdir($handleThemes))) {
|
||||
// Skip non dirs, . and ..
|
||||
if ($PMA_Theme == '.' || $PMA_Theme == '..' || ! is_dir($this->getThemesPath() . '/' . $PMA_Theme)) {
|
||||
if ($PMA_Theme == '.'
|
||||
|| $PMA_Theme == '..'
|
||||
|| ! is_dir($this->getThemesPath() . '/' . $PMA_Theme)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists($PMA_Theme, $this->themes)) {
|
||||
continue;
|
||||
}
|
||||
$new_theme = PMA_Theme::load($this->getThemesPath() . '/' . $PMA_Theme);
|
||||
$new_theme = PMA_Theme::load(
|
||||
$this->getThemesPath() . '/' . $PMA_Theme
|
||||
);
|
||||
if ($new_theme) {
|
||||
$new_theme->setId($PMA_Theme);
|
||||
$this->themes[$PMA_Theme] = $new_theme;
|
||||
|
||||
@ -15,8 +15,10 @@ require_once 'libraries/Menu.class.php';
|
||||
/**
|
||||
* Add recently used table and reload the navigation.
|
||||
*
|
||||
* @param string $db Database name where the table is located.
|
||||
* @param string $db Database name where the table is located.
|
||||
* @param string $table The table name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_addRecentTable($db, $table)
|
||||
{
|
||||
|
||||
@ -69,20 +69,20 @@ function PMA_aix_iconv_wrapper($in_charset, $out_charset, $str)
|
||||
: $out_charset);
|
||||
|
||||
// Transform name of input character set (if found)
|
||||
if (array_key_exists(
|
||||
strtolower($in_charset),
|
||||
$gnu_iconv_to_aix_iconv_codepage_map
|
||||
)
|
||||
) {
|
||||
$in_charset_exisits = array_key_exists(
|
||||
strtolower($in_charset),
|
||||
$gnu_iconv_to_aix_iconv_codepage_map
|
||||
);
|
||||
if ($in_charset_exisits) {
|
||||
$in_charset = $gnu_iconv_to_aix_iconv_codepage_map[strtolower($in_charset)];
|
||||
}
|
||||
|
||||
// Transform name of "plain" output character set (if found)
|
||||
if (array_key_exists(
|
||||
strtolower($out_charset_plain),
|
||||
$gnu_iconv_to_aix_iconv_codepage_map
|
||||
)
|
||||
) {
|
||||
$out_charset_plain_exists = array_key_exists(
|
||||
strtolower($out_charset_plain),
|
||||
$gnu_iconv_to_aix_iconv_codepage_map
|
||||
);
|
||||
if ($out_charset_plain_exists) {
|
||||
$out_charset_plain = $gnu_iconv_to_aix_iconv_codepage_map[
|
||||
strtolower($out_charset_plain)];
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ require_once './libraries/check_user_privileges.lib.php';
|
||||
define('PMA_CHK_DROP', 1);
|
||||
|
||||
/**
|
||||
* Check whether timeout is getting close
|
||||
* Checks whether timeout is getting close
|
||||
*
|
||||
* @return boolean true if timeout is close
|
||||
* @access public
|
||||
@ -42,7 +42,7 @@ function PMA_checkTimeout()
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects what compression filse uses
|
||||
* Detects what compression filse uses
|
||||
*
|
||||
* @param string $filepath filename to check
|
||||
*
|
||||
@ -52,7 +52,7 @@ function PMA_checkTimeout()
|
||||
function PMA_detectCompression($filepath)
|
||||
{
|
||||
$file = @fopen($filepath, 'rb');
|
||||
if (!$file) {
|
||||
if (! $file) {
|
||||
return false;
|
||||
}
|
||||
$test = fread($file, 4);
|
||||
@ -78,6 +78,7 @@ function PMA_detectCompression($filepath)
|
||||
* @param string $full query to display, this might be commented
|
||||
* @param bool $controluser whether to use control user for queries
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
|
||||
@ -93,13 +94,15 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
|
||||
if ($skip_queries > 0) {
|
||||
$skip_queries--;
|
||||
} else {
|
||||
if (!empty($import_run_buffer['sql']) && trim($import_run_buffer['sql']) != '') {
|
||||
if (! empty($import_run_buffer['sql'])
|
||||
&& trim($import_run_buffer['sql']) != ''
|
||||
) {
|
||||
$max_sql_len = max($max_sql_len, strlen($import_run_buffer['sql']));
|
||||
if (!$sql_query_disabled) {
|
||||
if (! $sql_query_disabled) {
|
||||
$sql_query .= $import_run_buffer['full'];
|
||||
}
|
||||
if (!$cfg['AllowUserDropDatabase']
|
||||
&& !$is_superuser
|
||||
if (! $cfg['AllowUserDropDatabase']
|
||||
&& ! $is_superuser
|
||||
&& preg_match('@^[[:space:]]*DROP[[:space:]]+(IF EXISTS[[:space:]]+)?DATABASE @i', $import_run_buffer['sql'])
|
||||
) {
|
||||
$GLOBALS['message'] = PMA_Message::error(__('"DROP DATABASE" statements are disabled.'));
|
||||
@ -109,13 +112,13 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
|
||||
if ($run_query
|
||||
&& $GLOBALS['finished']
|
||||
&& empty($sql)
|
||||
&& !$error
|
||||
&& ((!empty($import_run_buffer['sql'])
|
||||
&& ! $error
|
||||
&& ((! empty($import_run_buffer['sql'])
|
||||
&& preg_match('/^[\s]*(SELECT|SHOW|HANDLER)/i', $import_run_buffer['sql']))
|
||||
|| ($executed_queries == 1))
|
||||
) {
|
||||
$go_sql = true;
|
||||
if (!$sql_query_disabled) {
|
||||
if (! $sql_query_disabled) {
|
||||
$complete_query = $sql_query;
|
||||
$display_query = $sql_query;
|
||||
} else {
|
||||
@ -123,11 +126,18 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
|
||||
$display_query = '';
|
||||
}
|
||||
$sql_query = $import_run_buffer['sql'];
|
||||
// If a 'USE <db>' SQL-clause was found, set our current $db to the new one
|
||||
list($db, $reload) = PMA_lookForUse($import_run_buffer['sql'], $db, $reload);
|
||||
// If a 'USE <db>' SQL-clause was found,
|
||||
// set our current $db to the new one
|
||||
list($db, $reload) = PMA_lookForUse(
|
||||
$import_run_buffer['sql'],
|
||||
$db,
|
||||
$reload
|
||||
);
|
||||
} elseif ($run_query) {
|
||||
if ($controluser) {
|
||||
$result = PMA_query_as_controluser($import_run_buffer['sql']);
|
||||
$result = PMA_query_as_controluser(
|
||||
$import_run_buffer['sql']
|
||||
);
|
||||
} else {
|
||||
$result = PMA_DBI_try_query($import_run_buffer['sql']);
|
||||
}
|
||||
@ -136,11 +146,14 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
|
||||
if (! isset($my_die)) {
|
||||
$my_die = array();
|
||||
}
|
||||
$my_die[] = array('sql' => $import_run_buffer['full'], 'error' => PMA_DBI_getError());
|
||||
$my_die[] = array(
|
||||
'sql' => $import_run_buffer['full'],
|
||||
'error' => PMA_DBI_getError()
|
||||
);
|
||||
|
||||
$msg .= __('Error');
|
||||
|
||||
if (!$cfg['IgnoreMultiSubmitErrors']) {
|
||||
if (! $cfg['IgnoreMultiSubmitErrors']) {
|
||||
$error = true;
|
||||
return;
|
||||
}
|
||||
@ -157,13 +170,18 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
|
||||
$msg .= __('MySQL returned an empty result set (i.e. zero rows).');
|
||||
}
|
||||
}
|
||||
if (!$sql_query_disabled) {
|
||||
if (! $sql_query_disabled) {
|
||||
$sql_query .= $msg . "\n";
|
||||
}
|
||||
|
||||
// If a 'USE <db>' SQL-clause was found and the query succeeded, set our current $db to the new one
|
||||
// If a 'USE <db>' SQL-clause was found and the query
|
||||
// succeeded, set our current $db to the new one
|
||||
if ($result != false) {
|
||||
list($db, $reload) = PMA_lookForUse($import_run_buffer['sql'], $db, $reload);
|
||||
list($db, $reload) = PMA_lookForUse(
|
||||
$import_run_buffer['sql'],
|
||||
$db,
|
||||
$reload
|
||||
);
|
||||
}
|
||||
|
||||
if ($result != false
|
||||
@ -174,12 +192,12 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
|
||||
} // end run query
|
||||
} // end if not DROP DATABASE
|
||||
// end non empty query
|
||||
} elseif (!empty($import_run_buffer['full'])) {
|
||||
} elseif (! empty($import_run_buffer['full'])) {
|
||||
if ($go_sql) {
|
||||
$complete_query .= $import_run_buffer['full'];
|
||||
$display_query .= $import_run_buffer['full'];
|
||||
} else {
|
||||
if (!$sql_query_disabled) {
|
||||
if (! $sql_query_disabled) {
|
||||
$sql_query .= $import_run_buffer['full'];
|
||||
}
|
||||
}
|
||||
@ -189,7 +207,10 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
|
||||
// the complete query in the textarea)
|
||||
if (! $go_sql && $run_query) {
|
||||
if (! empty($sql_query)) {
|
||||
if (strlen($sql_query) > 50000 || $executed_queries > 50 || $max_sql_len > 1000) {
|
||||
if (strlen($sql_query) > 50000
|
||||
|| $executed_queries > 50
|
||||
|| $max_sql_len > 1000
|
||||
) {
|
||||
$sql_query = '';
|
||||
$sql_query_disabled = true;
|
||||
}
|
||||
@ -199,7 +220,7 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
|
||||
} // end buffer exists
|
||||
|
||||
// Do we have something to push into buffer?
|
||||
if (!empty($sql) || !empty($full)) {
|
||||
if (! empty($sql) || ! empty($full)) {
|
||||
$import_run_buffer = array('sql' => $sql, 'full' => $full);
|
||||
} else {
|
||||
unset($GLOBALS['import_run_buffer']);
|
||||
@ -268,7 +289,8 @@ function PMA_importGetNextChunk($size = 32768)
|
||||
}
|
||||
|
||||
if ($GLOBALS['import_file'] == 'none') {
|
||||
// Well this is not yet supported and tested, but should return content of textarea
|
||||
// Well this is not yet supported and tested,
|
||||
// but should return content of textarea
|
||||
if (strlen($GLOBALS['import_text']) < $size) {
|
||||
$GLOBALS['finished'] = true;
|
||||
return $GLOBALS['import_text'];
|
||||
@ -316,7 +338,9 @@ function PMA_importGetNextChunk($size = 32768)
|
||||
if (strncmp($result, "\xEF\xBB\xBF", 3) == 0) {
|
||||
$result = substr($result, 3);
|
||||
// UTF-16 BE, LE
|
||||
} elseif (strncmp($result, "\xFE\xFF", 2) == 0 || strncmp($result, "\xFF\xFE", 2) == 0) {
|
||||
} elseif (strncmp($result, "\xFE\xFF", 2) == 0
|
||||
|| strncmp($result, "\xFF\xFE", 2) == 0
|
||||
) {
|
||||
$result = substr($result, 2);
|
||||
}
|
||||
}
|
||||
@ -329,22 +353,25 @@ function PMA_importGetNextChunk($size = 32768)
|
||||
*
|
||||
* This functions uses recursion to build the Excel column name.
|
||||
*
|
||||
* The column number (1-26) is converted to the responding ASCII character (A-Z) and returned.
|
||||
* The column number (1-26) is converted to the responding
|
||||
* ASCII character (A-Z) and returned.
|
||||
*
|
||||
* If the column number is bigger than 26 (= num of letters in alfabet),
|
||||
* an extra character needs to be added. To find this extra character, the number is divided by 26
|
||||
* and this value is passed to another instance of the same function (hence recursion).
|
||||
* In that new instance the number is evaluated again, and if it is still bigger than 26, it is divided again
|
||||
* and passed to another instance of the same function. This continues until the number is smaller than 26.
|
||||
* Then the last called function returns the corresponding ASCII character to the function that called it.
|
||||
* an extra character needs to be added. To find this extra character,
|
||||
* the number is divided by 26 and this value is passed to another instance
|
||||
* of the same function (hence recursion). In that new instance the number is
|
||||
* evaluated again, and if it is still bigger than 26, it is divided again
|
||||
* and passed to another instance of the same function. This continues until
|
||||
* the number is smaller than 26. Then the last called function returns
|
||||
* the corresponding ASCII character to the function that called it.
|
||||
* Each time a called function ends an extra character is added to the column name.
|
||||
* When the first function is reached, the last character is addded and the complete column name is returned.
|
||||
* When the first function is reached, the last character is addded and the complete
|
||||
* column name is returned.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param int $num
|
||||
* @param int $num the column number
|
||||
*
|
||||
* @return string The column's "Excel" name
|
||||
* @access public
|
||||
*/
|
||||
function PMA_getColumnAlphaName($num)
|
||||
{
|
||||
@ -395,7 +422,7 @@ function PMA_getColumnAlphaName($num)
|
||||
*/
|
||||
function PMA_getColumnNumberFromName($name)
|
||||
{
|
||||
if (!empty($name)) {
|
||||
if (! empty($name)) {
|
||||
$name = strtoupper($name);
|
||||
$num_chars = strlen($name);
|
||||
$column_number = 0;
|
||||
@ -514,8 +541,9 @@ function PMA_getDecimalSize(&$cell)
|
||||
*
|
||||
* @todo Handle the error cases more elegantly
|
||||
*/
|
||||
function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type, &$cell)
|
||||
{
|
||||
function PMA_detectSize($last_cumulative_size, $last_cumulative_type,
|
||||
$curr_type, &$cell
|
||||
) {
|
||||
$curr_size = strlen((string)$cell);
|
||||
|
||||
/**
|
||||
@ -792,7 +820,12 @@ function PMA_analyzeTable(&$table)
|
||||
/* Determine type of the current cell */
|
||||
$curr_type = PMA_detectType($types[$i], $table[ROWS][$j][$i]);
|
||||
/* Determine size of the current cell */
|
||||
$sizes[$i] = PMA_detectSize($sizes[$i], $types[$i], $curr_type, $table[ROWS][$j][$i]);
|
||||
$sizes[$i] = PMA_detectSize(
|
||||
$sizes[$i],
|
||||
$types[$i],
|
||||
$curr_type,
|
||||
$table[ROWS][$j][$i]
|
||||
);
|
||||
|
||||
/**
|
||||
* If a type for this column has already been declared,
|
||||
@ -810,7 +843,10 @@ function PMA_analyzeTable(&$table)
|
||||
$types[$i] = BIGINT;
|
||||
}
|
||||
} else if ($curr_type == INT) {
|
||||
if ($types[$i] != VARCHAR && $types[$i] != DECIMAL && $types[$i] != BIGINT) {
|
||||
if ($types[$i] != VARCHAR
|
||||
&& $types[$i] != DECIMAL
|
||||
&& $types[$i] != BIGINT
|
||||
) {
|
||||
$types[$i] = INT;
|
||||
}
|
||||
}
|
||||
@ -855,8 +891,9 @@ $import_notice = null;
|
||||
*
|
||||
* @link http://wiki.phpmyadmin.net/pma/Import
|
||||
*/
|
||||
function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql = null, $options = null)
|
||||
{
|
||||
function PMA_buildSQL($db_name, &$tables, &$analyses = null,
|
||||
&$additional_sql = null, $options = null
|
||||
) {
|
||||
/* Take care of the options */
|
||||
if (isset($options['db_collation'])&& ! is_null($options['db_collation'])) {
|
||||
$collation = $options['db_collation'];
|
||||
@ -881,9 +918,11 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
|
||||
|
||||
if ($create_db) {
|
||||
if (PMA_DRIZZLE) {
|
||||
$sql[] = "CREATE DATABASE IF NOT EXISTS " . PMA_backquote($db_name) . " COLLATE " . $collation;
|
||||
$sql[] = "CREATE DATABASE IF NOT EXISTS " . PMA_backquote($db_name)
|
||||
. " COLLATE " . $collation;
|
||||
} else {
|
||||
$sql[] = "CREATE DATABASE IF NOT EXISTS " . PMA_backquote($db_name) . " DEFAULT CHARACTER SET " . $charset . " COLLATE " . $collation;
|
||||
$sql[] = "CREATE DATABASE IF NOT EXISTS " . PMA_backquote($db_name)
|
||||
. " DEFAULT CHARACTER SET " . $charset . " COLLATE " . $collation;
|
||||
}
|
||||
}
|
||||
|
||||
@ -922,9 +961,15 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
|
||||
$pattern = '/CREATE [^`]*(TABLE)/';
|
||||
$replacement = 'CREATE \\1 IF NOT EXISTS';
|
||||
|
||||
/* Change CREATE statements to CREATE IF NOT EXISTS to support inserting into existing structures */
|
||||
/* Change CREATE statements to CREATE IF NOT EXISTS to support
|
||||
* inserting into existing structures
|
||||
*/
|
||||
for ($i = 0; $i < $additional_sql_len; ++$i) {
|
||||
$additional_sql[$i] = preg_replace($pattern, $replacement, $additional_sql[$i]);
|
||||
$additional_sql[$i] = preg_replace(
|
||||
$pattern,
|
||||
$replacement,
|
||||
$additional_sql[$i]
|
||||
);
|
||||
/* Execute the resulting statements */
|
||||
PMA_importRunQuery($additional_sql[$i], $additional_sql[$i]);
|
||||
}
|
||||
@ -993,7 +1038,8 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
|
||||
$num_cols = count($tables[$i][COL_NAMES]);
|
||||
$num_rows = count($tables[$i][ROWS]);
|
||||
|
||||
$tempSQLStr = "INSERT INTO " . PMA_backquote($db_name) . '.' . PMA_backquote($tables[$i][TBL_NAME]) . " (";
|
||||
$tempSQLStr = "INSERT INTO " . PMA_backquote($db_name) . '.'
|
||||
. PMA_backquote($tables[$i][TBL_NAME]) . " (";
|
||||
|
||||
for ($m = 0; $m < $num_cols; ++$m) {
|
||||
$tempSQLStr .= PMA_backquote($tables[$i][COL_NAMES][$m]);
|
||||
@ -1009,7 +1055,8 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
|
||||
$tempSQLStr .= "(";
|
||||
|
||||
for ($k = 0; $k < $num_cols; ++$k) {
|
||||
// If fully formatted SQL, no need to enclose with aphostrophes, add shalshes etc.
|
||||
// If fully formatted SQL, no need to enclose
|
||||
// with aphostrophes, add shalshes etc.
|
||||
if ($analyses != null
|
||||
&& isset($analyses[$i][FORMATTEDSQL][$col_count])
|
||||
&& $analyses[$i][FORMATTEDSQL][$col_count] == true
|
||||
@ -1019,7 +1066,7 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
|
||||
if ($analyses != null) {
|
||||
$is_varchar = ($analyses[$i][TYPES][$col_count] === VARCHAR);
|
||||
} else {
|
||||
$is_varchar = !is_numeric($tables[$i][ROWS][$j][$k]);
|
||||
$is_varchar = ! is_numeric($tables[$i][ROWS][$j][$k]);
|
||||
}
|
||||
|
||||
/* Don't put quotes around NULL fields */
|
||||
@ -1028,7 +1075,9 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
|
||||
}
|
||||
|
||||
$tempSQLStr .= (($is_varchar) ? "'" : "");
|
||||
$tempSQLStr .= PMA_sqlAddSlashes((string)$tables[$i][ROWS][$j][$k]);
|
||||
$tempSQLStr .= PMA_sqlAddSlashes(
|
||||
(string) $tables[$i][ROWS][$j][$k]
|
||||
);
|
||||
$tempSQLStr .= (($is_varchar) ? "'" : "");
|
||||
}
|
||||
|
||||
@ -1074,8 +1123,9 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
|
||||
* A work in progress
|
||||
*/
|
||||
|
||||
/* Add the viewable structures from $additional_sql to $tables so they are also displayed */
|
||||
|
||||
/* Add the viewable structures from $additional_sql
|
||||
* to $tables so they are also displayed
|
||||
*/
|
||||
$view_pattern = '@VIEW `[^`]+`\.`([^`]+)@';
|
||||
$table_pattern = '@CREATE TABLE IF NOT EXISTS `([^`]+)`@';
|
||||
/* Check a third pattern to make sure its not a "USE `db_name`;" statement */
|
||||
@ -1094,13 +1144,13 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
|
||||
|
||||
if (count($regs)) {
|
||||
for ($n = 0; $n < $num_tables; ++$n) {
|
||||
if (!strcmp($regs[1], $tables[$n][TBL_NAME])) {
|
||||
if (! strcmp($regs[1], $tables[$n][TBL_NAME])) {
|
||||
$inTables = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$inTables) {
|
||||
if (! $inTables) {
|
||||
$tables[] = array(TBL_NAME => $regs[1]);
|
||||
}
|
||||
}
|
||||
@ -1134,7 +1184,10 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
|
||||
|
||||
$num_tables = count($tables);
|
||||
for ($i = 0; $i < $num_tables; ++$i) {
|
||||
$params = array('db' => (string)$db_name, 'table' => (string)$tables[$i][TBL_NAME]);
|
||||
$params = array(
|
||||
'db' => (string) $db_name,
|
||||
'table' => (string) $tables[$i][TBL_NAME]
|
||||
);
|
||||
$tbl_url = 'sql.php' . PMA_generate_common_url($params);
|
||||
$tbl_struct_url = 'tbl_structure.php' . PMA_generate_common_url($params);
|
||||
$tbl_ops_url = 'tbl_operations.php' . PMA_generate_common_url($params);
|
||||
|
||||
@ -49,11 +49,11 @@ if ($cfg['SQLValidator']['use'] == true) {
|
||||
*
|
||||
* <http://developer.mimer.com/validator/index.htm>
|
||||
*
|
||||
* @param string SQL query to validate
|
||||
* @param string $sql SQL query to validate
|
||||
*
|
||||
* @return string Validator result string
|
||||
* @return string Validator result string
|
||||
*
|
||||
* @global array The PMA configuration array
|
||||
* @global array The PMA configuration array
|
||||
*/
|
||||
function PMA_validateSQL($sql)
|
||||
{
|
||||
@ -74,7 +74,10 @@ function PMA_validateSQL($sql)
|
||||
// The class defaults to anonymous with an empty password
|
||||
// automatically
|
||||
if ($cfg['SQLValidator']['username'] != '') {
|
||||
$srv->setCredentials($cfg['SQLValidator']['username'], $cfg['SQLValidator']['password']);
|
||||
$srv->setCredentials(
|
||||
$cfg['SQLValidator']['username'],
|
||||
$cfg['SQLValidator']['password']
|
||||
);
|
||||
}
|
||||
|
||||
// Identify ourselves to the server properly...
|
||||
|
||||
@ -51,7 +51,9 @@ if (false !== $possibly_uploaded_val) {
|
||||
// $key contains the md5() of the fieldname
|
||||
if ($type != 'protected' && $type != 'set' && 0 === strlen($val)) {
|
||||
// best way to avoid problems in strict mode (works also in non-strict mode)
|
||||
if (isset($multi_edit_auto_increment) && isset($multi_edit_auto_increment[$key])) {
|
||||
if (isset($multi_edit_auto_increment)
|
||||
&& isset($multi_edit_auto_increment[$key])
|
||||
) {
|
||||
$val = 'NULL';
|
||||
} else {
|
||||
$val = "''";
|
||||
|
||||
@ -414,18 +414,18 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations,
|
||||
/**
|
||||
* Builds the sql search query from the post parameters
|
||||
*
|
||||
* @param string $table Selected table
|
||||
* @param array $fields Entered values of the columns
|
||||
* @param array $criteriaColumnNames Names of all columns
|
||||
* @param array $criteriaColumnTypes Types of all columns
|
||||
* @param array $criteriaColumnCollations Collations of all columns
|
||||
* @param array $criteriaColumnOperators Operators for given column type
|
||||
* @param string $table Selected table
|
||||
* @param array $fields Entered values of the columns
|
||||
* @param array $criteriaColumnNames Names of all columns
|
||||
* @param array $criteriaColumnTypes Types of all columns
|
||||
* @param array $criteriaColumnCollations Collations of all columns
|
||||
* @param array $criteriaColumnOperators Operators for given column type
|
||||
*
|
||||
* @return string the generated SQL query
|
||||
*/
|
||||
function PMA_tblSearchBuildSqlQuery($table, $fields, $criteriaColumnNames,
|
||||
$criteriaColumnTypes, $criteriaColumnCollations, $criteriaColumnOperators)
|
||||
{
|
||||
$criteriaColumnTypes, $criteriaColumnCollations, $criteriaColumnOperators
|
||||
) {
|
||||
$sql_query = 'SELECT ';
|
||||
|
||||
// If only distinct values are needed
|
||||
@ -449,7 +449,7 @@ function PMA_tblSearchBuildSqlQuery($table, $fields, $criteriaColumnNames,
|
||||
$criteriaColumnCollations, $criteriaColumnOperators
|
||||
);
|
||||
$sql_query .= $whereClause;
|
||||
|
||||
|
||||
// if the search results are to be ordered
|
||||
if ($_POST['orderByColumn'] != '--nil--') {
|
||||
$sql_query .= ' ORDER BY ' . PMA_backquote($_POST['orderByColumn'])
|
||||
@ -461,17 +461,17 @@ function PMA_tblSearchBuildSqlQuery($table, $fields, $criteriaColumnNames,
|
||||
/**
|
||||
* Generates the where clause for the SQL search query to be executed
|
||||
*
|
||||
* @param array $fields Entered values of the columns
|
||||
* @param array $criteriaColumnNames Names of all columns
|
||||
* @param array $criteriaColumnTypes Types of all columns
|
||||
* @param array $criteriaColumnCollations Collations of all columns
|
||||
* @param array $criteriaColumnOperators Operators for given column type
|
||||
* @param array $fields Entered values of the columns
|
||||
* @param array $criteriaColumnNames Names of all columns
|
||||
* @param array $criteriaColumnTypes Types of all columns
|
||||
* @param array $criteriaColumnCollations Collations of all columns
|
||||
* @param array $criteriaColumnOperators Operators for given column type
|
||||
*
|
||||
* @return string the generated where clause
|
||||
*/
|
||||
function PMA_tblSearchGenerateWhereClause($fields, $criteriaColumnNames,
|
||||
$criteriaColumnTypes, $criteriaColumnCollations, $criteriaColumnOperators)
|
||||
{
|
||||
$criteriaColumnTypes, $criteriaColumnCollations, $criteriaColumnOperators
|
||||
) {
|
||||
$fullWhereClause = '';
|
||||
|
||||
if (trim($_POST['customWhereClause']) != '') {
|
||||
@ -520,8 +520,8 @@ function PMA_tblSearchGenerateWhereClause($fields, $criteriaColumnNames,
|
||||
* @return string the generated HTML
|
||||
*/
|
||||
function PMA_tblSearchGetGeomFuncHtml($geomColumnFlag, $columnTypes,
|
||||
$geom_types, $column_index)
|
||||
{
|
||||
$geom_types, $column_index
|
||||
) {
|
||||
$html_output = '';
|
||||
// return if geometrical column is not present
|
||||
if (! $geomColumnFlag) {
|
||||
@ -530,7 +530,7 @@ $geom_types, $column_index)
|
||||
|
||||
/**
|
||||
* Displays 'Function' column if it is present
|
||||
*/
|
||||
*/
|
||||
$html_output .= '<td>';
|
||||
// if a geometry column is present
|
||||
if (in_array($columnTypes[$column_index], $geom_types)) {
|
||||
@ -563,7 +563,7 @@ $geom_types, $column_index)
|
||||
* @return string the generated HTML
|
||||
*/
|
||||
function PMA_tblSearchGetOptions($columnNames, $columnCount)
|
||||
{
|
||||
{
|
||||
$html_output = '';
|
||||
$html_output .= PMA_getDivForSliderEffect('searchoptions', __('Options'));
|
||||
/**
|
||||
@ -619,7 +619,9 @@ function PMA_tblSearchGetOptions($columnNames, $columnCount)
|
||||
'ASC' => __('Ascending'),
|
||||
'DESC' => __('Descending')
|
||||
);
|
||||
$html_output .= PMA_getRadioFields('order', $choices, 'ASC', false, true, "formelement");
|
||||
$html_output .= PMA_getRadioFields(
|
||||
'order', $choices, 'ASC', false, true, "formelement"
|
||||
);
|
||||
unset($choices);
|
||||
|
||||
$html_output .= '</fieldset><br style="clear: both;"/></div></fieldset>';
|
||||
@ -642,9 +644,9 @@ function PMA_tblSearchGetOptions($columnNames, $columnCount)
|
||||
* @return string the generated HTML
|
||||
*/
|
||||
function PMA_tblSearchGetFieldsTableHtml($columnNames, $columnTypes,
|
||||
$columnCollations, $columnNullFlags, $geomColumnFlag, $columnCount,
|
||||
$foreigners, $db, $table)
|
||||
{
|
||||
$columnCollations, $columnNullFlags, $geomColumnFlag, $columnCount,
|
||||
$foreigners, $db, $table
|
||||
) {
|
||||
$html_output = '';
|
||||
$html_output .= '<table class="data">';
|
||||
$html_output .= PMA_tbl_setTableHeader($geomColumnFlag) . '<tbody>';
|
||||
@ -704,7 +706,7 @@ $foreigners, $db, $table)
|
||||
/**
|
||||
* Generates the table search form under table search tab
|
||||
*
|
||||
* @param string $goto Goto URL
|
||||
* @param string $goto Goto URL
|
||||
* @param array $columnNames Names of columns in the table
|
||||
* @param array $columnTypes Types of columns in the table
|
||||
* @param array $columnCollations Collation of all columns
|
||||
@ -718,9 +720,9 @@ $foreigners, $db, $table)
|
||||
* @return string the generated HTML for table search form
|
||||
*/
|
||||
function PMA_tblSearchGetSelectionForm($goto, $columnNames, $columnTypes,
|
||||
$columnCollations, $columnNullFlags, $geomColumnFlag, $columnCount,
|
||||
$foreigners, $db, $table)
|
||||
{
|
||||
$columnCollations, $columnNullFlags, $geomColumnFlag, $columnCount,
|
||||
$foreigners, $db, $table
|
||||
) {
|
||||
$html_output = '';
|
||||
$html_output .= '<fieldset id="fieldset_subtab">';
|
||||
$url_params = array();
|
||||
@ -742,7 +744,7 @@ $foreigners, $db, $table)
|
||||
*/
|
||||
$html_output .= PMA_tblSearchGetFieldsTableHtml(
|
||||
$columnNames, $columnTypes, $columnCollations, $columnNullFlags,
|
||||
$geomColumnFlag, $columnCount, $foreigners, $db, $table
|
||||
$geomColumnFlag, $columnCount, $foreigners, $db, $table
|
||||
);
|
||||
|
||||
$html_output .= '<div id="gis_editor"></div>'
|
||||
|
||||
@ -6,10 +6,12 @@
|
||||
* This file also provides basic functions to use in other plungins!
|
||||
* These are declared in the 'GLOBAL Plugin functions' section
|
||||
*
|
||||
* Please use short and expressive names. For now, special characters which aren't allowed in
|
||||
* Please use short and expressive names.
|
||||
* For now, special characters which aren't allowed in
|
||||
* filenames or functions should not be used.
|
||||
*
|
||||
* Please provide a comment for your function, what it does and what parameters are available.
|
||||
* Please provide a comment for your function,
|
||||
* what it does and what parameters are available.
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
@ -18,7 +20,8 @@ if (! defined('PHPMYADMIN')) {
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of options from string with options separated by comma, removes quotes
|
||||
* Returns array of options from string with options separated by comma,
|
||||
* removes quotes
|
||||
*
|
||||
* <code>
|
||||
* PMA_transformation_getOptions("'option ,, quoted',abd,'2,3',");
|
||||
@ -187,7 +190,9 @@ function PMA_getMIME($db, $table, $strict = false)
|
||||
AND ( `mimetype` != \'\'' . (!$strict ? '
|
||||
OR `transformation` != \'\'
|
||||
OR `transformation_options` != \'\'' : '') . ')';
|
||||
return PMA_DBI_fetch_result($com_qry, 'column_name', null, $GLOBALS['controllink']);
|
||||
return PMA_DBI_fetch_result(
|
||||
$com_qry, 'column_name', null, $GLOBALS['controllink']
|
||||
);
|
||||
} // end of the 'PMA_getMIME()' function
|
||||
|
||||
/**
|
||||
@ -275,14 +280,14 @@ function PMA_setMIME($db, $table, $key, $mimetype, $transformation,
|
||||
* in $buffer, after performing a regular expression search and replace on
|
||||
* $buffer using $options['regex'] and $options['regex_replace'].
|
||||
*
|
||||
* @param string $buffer text that will be replaced in $options['string'],
|
||||
* after being formatted
|
||||
* @param array $options the options required to format $buffer
|
||||
* = array (
|
||||
* 'string' => 'string', // text containing "[__BUFFER__]"
|
||||
* 'regex' => 'mixed', // the pattern to search for
|
||||
* 'regex_replace' => 'mixed', // string or array of strings to replace with
|
||||
* );
|
||||
* @param string $buffer text that will be replaced in $options['string'],
|
||||
* after being formatted
|
||||
* @param array $options the options required to format $buffer
|
||||
* = array (
|
||||
* 'string' => 'string', // text containing "[__BUFFER__]"
|
||||
* 'regex' => 'mixed', // the pattern to search for
|
||||
* 'regex_replace' => 'mixed', // string or array of strings to replace with
|
||||
* );
|
||||
*
|
||||
* @return string containing the text with all the replacements
|
||||
*/
|
||||
@ -293,7 +298,11 @@ function PMA_transformation_global_html_replace($buffer, $options = array())
|
||||
}
|
||||
|
||||
if (isset($options['regex']) && isset($options['regex_replace'])) {
|
||||
$buffer = preg_replace('@' . str_replace('@', '\@', $options['regex']) . '@si', $options['regex_replace'], $buffer);
|
||||
$buffer = preg_replace(
|
||||
'@' . str_replace('@', '\@', $options['regex']) . '@si',
|
||||
$options['regex_replace'],
|
||||
$buffer
|
||||
);
|
||||
}
|
||||
|
||||
// Replace occurences of [__BUFFER__] with actual text
|
||||
|
||||
@ -65,6 +65,8 @@ $msg->display();
|
||||
$cfgRelation = PMA_getRelationsParam();
|
||||
if (! $cfgRelation['userconfigwork']) {
|
||||
$msg = __('Your preferences will be saved for current session only. Storing them permanently requires %sphpMyAdmin configuration storage%s.');
|
||||
$msg = PMA_sanitize(sprintf($msg, '[a@./Documentation.html#linked-tables@_blank]', '[/a]'));
|
||||
$msg = PMA_sanitize(
|
||||
sprintf($msg, '[a@./Documentation.html#linked-tables@_blank]', '[/a]')
|
||||
);
|
||||
PMA_Message::notice($msg)->display();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user