Improve coding style
This commit is contained in:
parent
0c5b25bf9c
commit
4cb5bcd4b5
@ -86,7 +86,7 @@ class PMA_Index
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $params
|
||||
* @param array $params parameters
|
||||
*/
|
||||
public function __construct($params = array())
|
||||
{
|
||||
@ -111,9 +111,10 @@ class PMA_Index
|
||||
/**
|
||||
* returns an array with all indexes from the given table
|
||||
*
|
||||
* @param string $table
|
||||
* @param string $schema
|
||||
* @return array
|
||||
* @param string $table table
|
||||
* @param string $schema schema
|
||||
*
|
||||
* @return array array of indexes
|
||||
*/
|
||||
static public function getFromTable($table, $schema)
|
||||
{
|
||||
@ -129,8 +130,9 @@ class PMA_Index
|
||||
/**
|
||||
* return primary if set, false otherwise
|
||||
*
|
||||
* @param string $table
|
||||
* @param string $schema
|
||||
* @param string $table table
|
||||
* @param string $schema schema
|
||||
*
|
||||
* @return mixed primary index or false if no one exists
|
||||
*/
|
||||
static public function getPrimary($table, $schema)
|
||||
@ -147,9 +149,10 @@ class PMA_Index
|
||||
/**
|
||||
* Load index data for table
|
||||
*
|
||||
* @param string $table
|
||||
* @param string $schema
|
||||
* @return boolean
|
||||
* @param string $table table
|
||||
* @param string $schema schema
|
||||
*
|
||||
* @return boolean whether loading was successful
|
||||
*/
|
||||
static protected function _loadIndexes($table, $schema)
|
||||
{
|
||||
@ -177,6 +180,8 @@ class PMA_Index
|
||||
* Add column to index
|
||||
*
|
||||
* @param array $params column params
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addColumn($params)
|
||||
{
|
||||
@ -216,8 +221,9 @@ class PMA_Index
|
||||
/**
|
||||
* Returns true if $column indexed in this index
|
||||
*
|
||||
* @param string $column
|
||||
* @return boolean
|
||||
* @param string $column the column
|
||||
*
|
||||
* @return boolean true if $column indexed in this index
|
||||
*/
|
||||
public function hasColumn($column)
|
||||
{
|
||||
@ -324,8 +330,9 @@ class PMA_Index
|
||||
|
||||
foreach (PMA_Index::getIndexChoices() as $each_index_choice) {
|
||||
if ($each_index_choice === 'PRIMARY'
|
||||
&& $this->_choice !== 'PRIMARY'
|
||||
&& PMA_Index::getPrimary($this->_table, $this->_schema)) {
|
||||
&& $this->_choice !== 'PRIMARY'
|
||||
&& PMA_Index::getPrimary($this->_table, $this->_schema)
|
||||
) {
|
||||
// skip PRIMARY if there is already one in the table
|
||||
continue;
|
||||
}
|
||||
@ -403,12 +410,13 @@ class PMA_Index
|
||||
/**
|
||||
* Show index data
|
||||
*
|
||||
* @param string $table The tablename
|
||||
* @param array $indexes_info Referenced info array
|
||||
* @param array $indexes_data Referenced data array
|
||||
* @param boolean $print_mode
|
||||
* @param string $table The table name
|
||||
* @param string $schema The schema name
|
||||
* @param boolean $print_mode Whether the output is for the print mode
|
||||
*
|
||||
* @return array Index collection array
|
||||
*
|
||||
* @access public
|
||||
* @return array Index collection array
|
||||
*/
|
||||
static public function getView($table, $schema, $print_mode = false)
|
||||
{
|
||||
@ -543,9 +551,11 @@ class PMA_Index
|
||||
/**
|
||||
* Function to check over array of indexes and look for common problems
|
||||
*
|
||||
* @param string $table table name
|
||||
* @param string $schema schema name
|
||||
*
|
||||
* @return string Output HTML
|
||||
* @access public
|
||||
* @param string name of table
|
||||
* @return string Output HTML
|
||||
*/
|
||||
static public function findDuplicates($table, $schema)
|
||||
{
|
||||
|
||||
@ -56,8 +56,8 @@ require_once './libraries/List.class.php';
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed $db_link_user user database link resource|object
|
||||
* @param mixed $db_link_control control database link resource|object
|
||||
* @param mixed $db_link_user user database link resource|object
|
||||
* @param mixed $db_link_control control database link resource|object
|
||||
*/
|
||||
public function __construct($db_link_user = null, $db_link_control = null)
|
||||
{
|
||||
@ -88,9 +88,10 @@ require_once './libraries/List.class.php';
|
||||
/**
|
||||
* retrieves database list from server
|
||||
*
|
||||
* @todo we could also search mysql tables if all fail?
|
||||
* @param string $like_db_name usally a db_name containing wildcards
|
||||
* @param string $like_db_name usally a db_name containing wildcards
|
||||
*
|
||||
* @return array
|
||||
* @todo we could also search mysql tables if all fail?
|
||||
*/
|
||||
protected function _retrieve($like_db_name = null)
|
||||
{
|
||||
@ -101,8 +102,10 @@ require_once './libraries/List.class.php';
|
||||
if (null !== $like_db_name) {
|
||||
$command = "SHOW DATABASES LIKE '" . $like_db_name . "'";
|
||||
} elseif (null === $this->_command) {
|
||||
$command = str_replace('#user#', $GLOBALS['cfg']['Server']['user'],
|
||||
$GLOBALS['cfg']['Server']['ShowDatabasesCommand']);
|
||||
$command = str_replace(
|
||||
'#user#', $GLOBALS['cfg']['Server']['user'],
|
||||
$GLOBALS['cfg']['Server']['ShowDatabasesCommand']
|
||||
);
|
||||
$this->_command = $command;
|
||||
} else {
|
||||
$command = $this->_command;
|
||||
@ -161,7 +164,8 @@ require_once './libraries/List.class.php';
|
||||
protected function _checkOnlyDatabase()
|
||||
{
|
||||
if (is_string($GLOBALS['cfg']['Server']['only_db'])
|
||||
&& strlen($GLOBALS['cfg']['Server']['only_db'])) {
|
||||
&& strlen($GLOBALS['cfg']['Server']['only_db'])
|
||||
) {
|
||||
$GLOBALS['cfg']['Server']['only_db'] = array(
|
||||
$GLOBALS['cfg']['Server']['only_db']
|
||||
);
|
||||
@ -176,8 +180,9 @@ require_once './libraries/List.class.php';
|
||||
foreach ($GLOBALS['cfg']['Server']['only_db'] as $each_only_db) {
|
||||
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_merge(
|
||||
$items, array_diff($this->_retrieve(), $items)
|
||||
);
|
||||
// there can only be one '*', and this can only be last
|
||||
break;
|
||||
}
|
||||
@ -222,6 +227,7 @@ require_once './libraries/List.class.php';
|
||||
*
|
||||
* @param integer $offset
|
||||
* @param integer $count
|
||||
*
|
||||
* @return array db list
|
||||
*/
|
||||
public function getGroupedDetails($offset, $count)
|
||||
@ -229,7 +235,8 @@ require_once './libraries/List.class.php';
|
||||
$dbgroups = array();
|
||||
|
||||
if ($GLOBALS['cfg']['ShowTooltip']
|
||||
&& $GLOBALS['cfgRelation']['commwork']) {
|
||||
&& $GLOBALS['cfgRelation']['commwork']
|
||||
) {
|
||||
$db_tooltips = PMA_getDbComments();
|
||||
}
|
||||
|
||||
@ -299,6 +306,7 @@ require_once './libraries/List.class.php';
|
||||
*
|
||||
* @param integer $offset
|
||||
* @param integer $count
|
||||
*
|
||||
* @return array some items
|
||||
*/
|
||||
public function getLimitedItems($offset, $count)
|
||||
|
||||
@ -40,9 +40,9 @@ $gnu_iconv_to_aix_iconv_codepage_map = array (
|
||||
* Wrapper around IBM AIX iconv(), whose character set naming differs
|
||||
* from the GNU version of iconv().
|
||||
*
|
||||
* @param string input character set
|
||||
* @param string output character set
|
||||
* @param string the string to convert
|
||||
* @param string $in_charset input character set
|
||||
* @param string $out_charset output character set
|
||||
* @param string $str the string to convert
|
||||
*
|
||||
* @return mixed converted string or false on failure
|
||||
*
|
||||
|
||||
@ -44,7 +44,8 @@ function PMA_checkTimeout()
|
||||
/**
|
||||
* Detects what compression filse uses
|
||||
*
|
||||
* @param string $filepath filename to check
|
||||
* @param string $filepath filename to check
|
||||
*
|
||||
* @return string MIME type of compression, none for none
|
||||
* @access public
|
||||
*/
|
||||
@ -73,9 +74,10 @@ function PMA_detectCompression($filepath)
|
||||
* Runs query inside import buffer. This is needed to allow displaying
|
||||
* of last SELECT, SHOW or HANDLER results and similar nice stuff.
|
||||
*
|
||||
* @param string $sql query to run
|
||||
* @param string $full query to display, this might be commented
|
||||
* @param bool $controluser whether to use control user for queries
|
||||
* @param string $sql query to run
|
||||
* @param string $full query to display, this might be commented
|
||||
* @param bool $controluser whether to use control user for queries
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
|
||||
@ -214,9 +216,10 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
|
||||
/**
|
||||
* Looks for the presence of USE to possibly change current db
|
||||
*
|
||||
* @param string $buffer buffer to examine
|
||||
* @param string $db current db
|
||||
* @param bool $reload reload
|
||||
* @param string $buffer buffer to examine
|
||||
* @param string $db current db
|
||||
* @param bool $reload reload
|
||||
*
|
||||
* @return array (current or new db, whether to reload)
|
||||
* @access public
|
||||
*/
|
||||
@ -240,7 +243,9 @@ function PMA_lookForUse($buffer, $db, $reload)
|
||||
/**
|
||||
* Returns next part of imported file/buffer
|
||||
*
|
||||
* @param int $size size of buffer to read (this is maximal size function will return)
|
||||
* @param int $size size of buffer to read
|
||||
* (this is maximal size function will return)
|
||||
*
|
||||
* @return string part of file/buffer
|
||||
* @access public
|
||||
*/
|
||||
@ -283,23 +288,23 @@ function PMA_importGetNextChunk($size = 32768)
|
||||
}
|
||||
|
||||
switch ($compression) {
|
||||
case 'application/bzip2':
|
||||
$result = bzread($import_handle, $size);
|
||||
$GLOBALS['finished'] = feof($import_handle);
|
||||
break;
|
||||
case 'application/gzip':
|
||||
$result = gzread($import_handle, $size);
|
||||
$GLOBALS['finished'] = feof($import_handle);
|
||||
break;
|
||||
case 'application/zip':
|
||||
$result = substr($GLOBALS['import_text'], 0, $size);
|
||||
$GLOBALS['import_text'] = substr($GLOBALS['import_text'], $size);
|
||||
$GLOBALS['finished'] = empty($GLOBALS['import_text']);
|
||||
break;
|
||||
case 'none':
|
||||
$result = fread($import_handle, $size);
|
||||
$GLOBALS['finished'] = feof($import_handle);
|
||||
break;
|
||||
case 'application/bzip2':
|
||||
$result = bzread($import_handle, $size);
|
||||
$GLOBALS['finished'] = feof($import_handle);
|
||||
break;
|
||||
case 'application/gzip':
|
||||
$result = gzread($import_handle, $size);
|
||||
$GLOBALS['finished'] = feof($import_handle);
|
||||
break;
|
||||
case 'application/zip':
|
||||
$result = substr($GLOBALS['import_text'], 0, $size);
|
||||
$GLOBALS['import_text'] = substr($GLOBALS['import_text'], $size);
|
||||
$GLOBALS['finished'] = empty($GLOBALS['import_text']);
|
||||
break;
|
||||
case 'none':
|
||||
$result = fread($import_handle, $size);
|
||||
$GLOBALS['finished'] = feof($import_handle);
|
||||
break;
|
||||
}
|
||||
$GLOBALS['offset'] += $size;
|
||||
|
||||
@ -389,10 +394,10 @@ function PMA_getColumnAlphaName($num)
|
||||
* calculates the corresponding value, based on character value
|
||||
* (A = 1, ..., Z = 26) and position in the string.
|
||||
*
|
||||
* @access public
|
||||
* @param string $name column name(i.e. "A", or "BC", etc.)
|
||||
*
|
||||
* @param string $name (i.e. "A", or "BC", etc.)
|
||||
* @return int The column number
|
||||
* @access public
|
||||
*/
|
||||
function PMA_getColumnNumberFromName($name)
|
||||
{
|
||||
@ -401,19 +406,19 @@ function PMA_getColumnNumberFromName($name)
|
||||
$num_chars = strlen($name);
|
||||
$column_number = 0;
|
||||
for ($i = 0; $i < $num_chars; ++$i) {
|
||||
// read string from back to front
|
||||
$char_pos = ($num_chars - 1) - $i;
|
||||
// read string from back to front
|
||||
$char_pos = ($num_chars - 1) - $i;
|
||||
|
||||
// convert capital character to ASCII value
|
||||
// and subtract 64 to get corresponding decimal value
|
||||
// ASCII value of "A" is 65, "B" is 66, etc.
|
||||
// Decimal equivalent of "A" is 1, "B" is 2, etc.
|
||||
$number = (ord($name[$char_pos]) - 64);
|
||||
// convert capital character to ASCII value
|
||||
// and subtract 64 to get corresponding decimal value
|
||||
// ASCII value of "A" is 65, "B" is 66, etc.
|
||||
// Decimal equivalent of "A" is 1, "B" is 2, etc.
|
||||
$number = (ord($name[$char_pos]) - 64);
|
||||
|
||||
// base26 to base10 conversion : multiply each number
|
||||
// with corresponding value of the position, in this case
|
||||
// $i=0 : 1; $i=1 : 26; $i=2 : 676; ...
|
||||
$column_number += $number * pow(26, $i);
|
||||
// base26 to base10 conversion : multiply each number
|
||||
// with corresponding value of the position, in this case
|
||||
// $i=0 : 1; $i=1 : 26; $i=2 : 676; ...
|
||||
$column_number += $number * pow(26, $i);
|
||||
}
|
||||
return $column_number;
|
||||
} else {
|
||||
@ -451,10 +456,10 @@ define("FORMATTEDSQL", 2);
|
||||
/**
|
||||
* Obtains the precision (total # of digits) from a size of type decimal
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param string $last_cumulative_size
|
||||
*
|
||||
* @return int Precision of the given decimal size notation
|
||||
* @access public
|
||||
*/
|
||||
function PMA_getM($last_cumulative_size)
|
||||
{
|
||||
@ -462,25 +467,31 @@ function PMA_getM($last_cumulative_size)
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the scale (# of digits to the right of the decimal point) from a size of type decimal
|
||||
*
|
||||
* @access public
|
||||
* Obtains the scale (# of digits to the right of the decimal point)
|
||||
* from a size of type decimal
|
||||
*
|
||||
* @param string $last_cumulative_size
|
||||
*
|
||||
* @return int Scale of the given decimal size notation
|
||||
* @access public
|
||||
*/
|
||||
function PMA_getD($last_cumulative_size)
|
||||
{
|
||||
return (int)substr($last_cumulative_size, (strpos($last_cumulative_size, ",") + 1), (strlen($last_cumulative_size) - strpos($last_cumulative_size, ",")));
|
||||
return (int) substr(
|
||||
$last_cumulative_size,
|
||||
(strpos($last_cumulative_size, ",") + 1),
|
||||
(strlen($last_cumulative_size) - strpos($last_cumulative_size, ","))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the decimal size of a given cell
|
||||
*
|
||||
* @access public
|
||||
* @param string &$cell cell content
|
||||
*
|
||||
* @param string &$cell
|
||||
* @return array Contains the precision, scale, and full size representation of the given decimal cell
|
||||
* @return array Contains the precision, scale, and full size
|
||||
* representation of the given decimal cell
|
||||
* @access public
|
||||
*/
|
||||
function PMA_getDecimalSize(&$cell)
|
||||
{
|
||||
@ -497,15 +508,17 @@ function PMA_getDecimalSize(&$cell)
|
||||
/**
|
||||
* Obtains the size of the given cell
|
||||
*
|
||||
* @todo Handle the error cases more elegantly
|
||||
* @param string $last_cumulative_size Last cumulative column size
|
||||
* @param int $last_cumulative_type Last cumulative column type
|
||||
* (NONE or VARCHAR or DECIMAL or INT or BIGINT)
|
||||
* @param int $curr_type Type of the current cell
|
||||
* (NONE or VARCHAR or DECIMAL or INT or BIGINT)
|
||||
* @param string &$cell The current cell
|
||||
*
|
||||
* @return string Size of the given cell in the type-appropriate format
|
||||
* @access public
|
||||
*
|
||||
* @param string $last_cumulative_size Last cumulative column size
|
||||
* @param int $last_cumulative_type Last cumulative column type (NONE or VARCHAR or DECIMAL or INT or BIGINT)
|
||||
* @param int $curr_type Type of the current cell (NONE or VARCHAR or DECIMAL or INT or BIGINT)
|
||||
* @param string &$cell The current cell
|
||||
* @return string Size of the given cell in the type-appropriate format
|
||||
* @todo Handle the error cases more elegantly
|
||||
*/
|
||||
function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type, &$cell)
|
||||
{
|
||||
@ -711,11 +724,14 @@ function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type
|
||||
/**
|
||||
* Determines what MySQL type a cell is
|
||||
*
|
||||
* @access public
|
||||
* @param int $last_cumulative_type Last cumulative column type
|
||||
* (VARCHAR or INT or BIGINT or DECIMAL or NONE)
|
||||
* @param string &$cell String representation of the cell for which
|
||||
* a best-fit type is to be determined
|
||||
*
|
||||
* @param int $last_cumulative_type Last cumulative column type (VARCHAR or INT or BIGINT or DECIMAL or NONE)
|
||||
* @param string &$cell String representation of the cell for which a best-fit type is to be determined
|
||||
* @return int The MySQL type representation (VARCHAR or INT or BIGINT or DECIMAL or NONE)
|
||||
* @return int The MySQL type representation
|
||||
* (VARCHAR or INT or BIGINT or DECIMAL or NONE)
|
||||
* @access public
|
||||
*/
|
||||
function PMA_detectType($last_cumulative_type, &$cell)
|
||||
{
|
||||
@ -731,14 +747,17 @@ function PMA_detectType($last_cumulative_type, &$cell)
|
||||
return $last_cumulative_type;
|
||||
}
|
||||
} elseif (is_numeric($cell)) {
|
||||
if ($cell == (string)(float)$cell && strpos($cell, ".") !== false && substr_count($cell, ".") == 1) {
|
||||
if ($cell == (string)(float)$cell
|
||||
&& strpos($cell, ".") !== false
|
||||
&& substr_count($cell, ".") == 1
|
||||
) {
|
||||
return DECIMAL;
|
||||
} else {
|
||||
if (abs($cell) > 2147483647) {
|
||||
return BIGINT;
|
||||
} else {
|
||||
return INT;
|
||||
}
|
||||
if (abs($cell) > 2147483647) {
|
||||
return BIGINT;
|
||||
} else {
|
||||
return INT;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return VARCHAR;
|
||||
@ -748,14 +767,14 @@ function PMA_detectType($last_cumulative_type, &$cell)
|
||||
/**
|
||||
* Determines if the column types are int, decimal, or string
|
||||
*
|
||||
* @param array &$table array(string $table_name, array $col_names, array $rows)
|
||||
*
|
||||
* @return array array(array $types, array $sizes)
|
||||
* @access public
|
||||
*
|
||||
* @link http://wiki.phpmyadmin.net/pma/Import
|
||||
*
|
||||
* @todo Handle the error case more elegantly
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param &$table array(string $table_name, array $col_names, array $rows)
|
||||
* @return array array(array $types, array $sizes)
|
||||
*/
|
||||
function PMA_analyzeTable(&$table)
|
||||
{
|
||||
@ -782,7 +801,11 @@ function PMA_analyzeTable(&$table)
|
||||
$curr_size = 0;
|
||||
|
||||
/* If the passed array is not of the correct form, do not process it */
|
||||
if (is_array($table) && ! is_array($table[TBL_NAME]) && is_array($table[COL_NAMES]) && is_array($table[ROWS])) {
|
||||
if (is_array($table)
|
||||
&& ! is_array($table[TBL_NAME])
|
||||
&& is_array($table[COL_NAMES])
|
||||
&& is_array($table[ROWS])
|
||||
) {
|
||||
/* Analyze each column */
|
||||
for ($i = 0; $i < $numCols; ++$i) {
|
||||
/* Analyze the column in each row */
|
||||
@ -842,16 +865,16 @@ $import_notice = null;
|
||||
* Builds and executes SQL statements to create the database and tables
|
||||
* as necessary, as well as insert all the data.
|
||||
*
|
||||
* @link http://wiki.phpmyadmin.net/pma/Import
|
||||
* @param string $db_name Name of the database
|
||||
* @param array &$tables Array of tables for the specified database
|
||||
* @param array &$analyses Analyses of the tables
|
||||
* @param array &$additional_sql Additional SQL statements to be executed
|
||||
* @param array $options Associative array of options
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*
|
||||
* @param string $db_name Name of the database
|
||||
* @param array &$tables Array of tables for the specified database
|
||||
* @param array &$analyses Analyses of the tables
|
||||
* @param array &$additional_sql Additional SQL statements to be executed
|
||||
* @param array $options Associative array of options
|
||||
* @return void
|
||||
* @link http://wiki.phpmyadmin.net/pma/Import
|
||||
*/
|
||||
function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql = null, $options = null)
|
||||
{
|
||||
@ -886,7 +909,8 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
|
||||
}
|
||||
|
||||
/**
|
||||
* The calling plug-in should include this statement, if necessary, in the $additional_sql parameter
|
||||
* The calling plug-in should include this statement,
|
||||
* if necessary, in the $additional_sql parameter
|
||||
*
|
||||
* $sql[] = "USE " . PMA_backquote($db_name);
|
||||
*/
|
||||
@ -928,7 +952,14 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
|
||||
}
|
||||
|
||||
if ($analyses != null) {
|
||||
$type_array = array(NONE => "NULL", VARCHAR => "varchar", INT => "int", DECIMAL => "decimal", BIGINT => "bigint", GEOMETRY => 'geometry');
|
||||
$type_array = array(
|
||||
NONE => "NULL",
|
||||
VARCHAR => "varchar",
|
||||
INT => "int",
|
||||
DECIMAL => "decimal",
|
||||
BIGINT => "bigint",
|
||||
GEOMETRY => 'geometry'
|
||||
);
|
||||
|
||||
/* TODO: Do more checking here to make sure they really are matched */
|
||||
if (count($tables) != count($analyses)) {
|
||||
@ -940,14 +971,16 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
|
||||
$num_tables = count($tables);
|
||||
for ($i = 0; $i < $num_tables; ++$i) {
|
||||
$num_cols = count($tables[$i][COL_NAMES]);
|
||||
$tempSQLStr = "CREATE TABLE IF NOT EXISTS " . PMA_backquote($db_name) . '.' . PMA_backquote($tables[$i][TBL_NAME]) . " (";
|
||||
$tempSQLStr = "CREATE TABLE IF NOT EXISTS " . PMA_backquote($db_name)
|
||||
. '.' . PMA_backquote($tables[$i][TBL_NAME]) . " (";
|
||||
for ($j = 0; $j < $num_cols; ++$j) {
|
||||
$size = $analyses[$i][SIZES][$j];
|
||||
if ((int)$size == 0) {
|
||||
$size = 10;
|
||||
}
|
||||
|
||||
$tempSQLStr .= PMA_backquote($tables[$i][COL_NAMES][$j]) . " " . $type_array[$analyses[$i][TYPES][$j]];
|
||||
$tempSQLStr .= PMA_backquote($tables[$i][COL_NAMES][$j]) . " "
|
||||
. $type_array[$analyses[$i][TYPES][$j]];
|
||||
if ($analyses[$i][TYPES][$j] != GEOMETRY) {
|
||||
$tempSQLStr .= "(" . $size . ")";
|
||||
}
|
||||
@ -1141,10 +1174,12 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
|
||||
sprintf(__('Edit settings for %s'), htmlspecialchars(PMA_backquote($db_name)))
|
||||
);
|
||||
} else {
|
||||
$message .= sprintf('<li><a href="%s" title="%s">%s</a></li>',
|
||||
$tbl_url,
|
||||
sprintf(__('Go to view: %s'), htmlspecialchars(PMA_backquote($tables[$i][TBL_NAME]))),
|
||||
htmlspecialchars($tables[$i][TBL_NAME]));
|
||||
$message .= sprintf(
|
||||
'<li><a href="%s" title="%s">%s</a></li>',
|
||||
$tbl_url,
|
||||
sprintf(__('Go to view: %s'), htmlspecialchars(PMA_backquote($tables[$i][TBL_NAME]))),
|
||||
htmlspecialchars($tables[$i][TBL_NAME])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -58,8 +58,8 @@ function PMA_getIp()
|
||||
* Does not match:
|
||||
* xxx.xxx.xxx.xx[yyy-zzz] (range, partial octets not supported)
|
||||
*
|
||||
* @param string string of IP range to match
|
||||
* @param string string of IP to test against range
|
||||
* @param string $testRange string of IP range to match
|
||||
* @param string $ipToTest string of IP to test against range
|
||||
*
|
||||
* @return boolean always true
|
||||
*
|
||||
@ -67,36 +67,35 @@ function PMA_getIp()
|
||||
*/
|
||||
function PMA_ipMaskTest($testRange, $ipToTest)
|
||||
{
|
||||
$result = true;
|
||||
$result = true;
|
||||
|
||||
if (preg_match('|([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/([0-9]+)|', $testRange, $regs)) {
|
||||
// performs a mask match
|
||||
$ipl = ip2long($ipToTest);
|
||||
$rangel = ip2long($regs[1] . '.' . $regs[2] . '.' . $regs[3] . '.' . $regs[4]);
|
||||
if (preg_match('|([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/([0-9]+)|', $testRange, $regs)) {
|
||||
// performs a mask match
|
||||
$ipl = ip2long($ipToTest);
|
||||
$rangel = ip2long($regs[1] . '.' . $regs[2] . '.' . $regs[3] . '.' . $regs[4]);
|
||||
|
||||
$maskl = 0;
|
||||
$maskl = 0;
|
||||
|
||||
for ($i = 0; $i < 31; $i++) {
|
||||
if ($i < $regs[5] - 1) {
|
||||
$maskl = $maskl + PMA_pow(2, (30 - $i));
|
||||
} // end if
|
||||
} // end for
|
||||
for ($i = 0; $i < 31; $i++) {
|
||||
if ($i < $regs[5] - 1) {
|
||||
$maskl = $maskl + PMA_pow(2, (30 - $i));
|
||||
} // end if
|
||||
} // end for
|
||||
|
||||
if (($maskl & $rangel) == ($maskl & $ipl)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// range based
|
||||
$maskocts = explode('.', $testRange);
|
||||
$ipocts = explode('.', $ipToTest);
|
||||
if (($maskl & $rangel) == ($maskl & $ipl)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// range based
|
||||
$maskocts = explode('.', $testRange);
|
||||
$ipocts = explode('.', $ipToTest);
|
||||
|
||||
// perform a range match
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
// perform a range match
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
if (preg_match('|\[([0-9]+)\-([0-9]+)\]|', $maskocts[$i], $regs)) {
|
||||
if (($ipocts[$i] > $regs[2])
|
||||
|| ($ipocts[$i] < $regs[1])) {
|
||||
if (($ipocts[$i] > $regs[2]) || ($ipocts[$i] < $regs[1])) {
|
||||
$result = false;
|
||||
} // end if
|
||||
} else {
|
||||
@ -104,17 +103,17 @@ function PMA_ipMaskTest($testRange, $ipToTest)
|
||||
$result = false;
|
||||
} // end if
|
||||
} // end if/else
|
||||
} //end for
|
||||
} //end if/else
|
||||
} //end for
|
||||
} //end if/else
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
} // end of the "PMA_IPMaskTest()" function
|
||||
|
||||
|
||||
/**
|
||||
* Runs through IP Allow/Deny rules the use of it below for more information
|
||||
*
|
||||
* @param string 'allow' | 'deny' type of rule to match
|
||||
* @param string $type 'allow' | 'deny' type of rule to match
|
||||
*
|
||||
* @return bool Matched a rule ?
|
||||
*
|
||||
@ -162,7 +161,8 @@ function PMA_allowDeny($type)
|
||||
|
||||
// check for username
|
||||
if (($rule_data[1] != '%') //wildcarded first
|
||||
&& ($rule_data[1] != $username)) {
|
||||
&& ($rule_data[1] != $username)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
* This function is used to displays a javascript confirmation box for
|
||||
* "DROP/DELETE/ALTER" queries.
|
||||
*
|
||||
* @param string $a_string the string to format
|
||||
* @param boolean $add_backquotes whether to add backquotes to the string or not
|
||||
* @param string $a_string the string to format
|
||||
* @param boolean $add_backquotes whether to add backquotes to the string or not
|
||||
*
|
||||
* @return string the formatted string
|
||||
*
|
||||
@ -41,19 +41,26 @@ function PMA_jsFormat($a_string = '', $add_backquotes = true)
|
||||
* We also remove NUL byte as some browsers (namely MSIE) ignore it and
|
||||
* inserting it anywhere inside </script would allow to bypass this check.
|
||||
*
|
||||
* @param string $string the string to be escaped
|
||||
* @param string $string the string to be escaped
|
||||
*
|
||||
* @return string the escaped string
|
||||
*/
|
||||
function PMA_escapeJsString($string)
|
||||
{
|
||||
return preg_replace('@</script@i', '</\' + \'script',
|
||||
strtr($string, array(
|
||||
"\000" => '',
|
||||
'\\' => '\\\\',
|
||||
'\'' => '\\\'',
|
||||
'"' => '\"',
|
||||
"\n" => '\n',
|
||||
"\r" => '\r')));
|
||||
return preg_replace(
|
||||
'@</script@i', '</\' + \'script',
|
||||
strtr(
|
||||
$string,
|
||||
array(
|
||||
"\000" => '',
|
||||
'\\' => '\\\\',
|
||||
'\'' => '\\\'',
|
||||
'"' => '\"',
|
||||
"\n" => '\n',
|
||||
"\r" => '\r'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,7 +68,7 @@ function PMA_escapeJsString($string)
|
||||
*
|
||||
* @param string $value String to be formatted.
|
||||
*
|
||||
* @retrun string formatted value.
|
||||
* @return string formatted value.
|
||||
*/
|
||||
function PMA_formatJsVal($value)
|
||||
{
|
||||
@ -84,7 +91,8 @@ function PMA_formatJsVal($value)
|
||||
*
|
||||
* @param string $key Name of value to set
|
||||
* @param mixed $value Value to set, can be either string or array of strings
|
||||
* @param bool $escape Whether to escape value or keep it as it is (for inclusion of js code)
|
||||
* @param bool $escape Whether to escape value or keep it as it is
|
||||
* (for inclusion of js code)
|
||||
*
|
||||
* @return string Javascript code.
|
||||
*/
|
||||
@ -109,10 +117,10 @@ function PMA_getJsValue($key, $value, $escape = true)
|
||||
* Prints an javascript assignment with proper escaping of a value
|
||||
* and support for assigning array of strings.
|
||||
*
|
||||
* @param string $key Name of value to set
|
||||
* @param mixed $value Value to set, can be either string or array of strings
|
||||
* @param string $key Name of value to set
|
||||
* @param mixed $value Value to set, can be either string or array of strings
|
||||
*
|
||||
* @return nothing
|
||||
* @return void
|
||||
*/
|
||||
function PMA_printJsValue($key, $value)
|
||||
{
|
||||
|
||||
@ -67,9 +67,9 @@ function PMA_change_enc_order()
|
||||
* Kanji string encoding convert
|
||||
* 2002/1/4 by Y.Kawada
|
||||
*
|
||||
* @param string the string to convert
|
||||
* @param string the destination encoding code
|
||||
* @param string set 'kana' convert to JIS-X208-kana
|
||||
* @param string $str the string to convert
|
||||
* @param string $enc the destination encoding code
|
||||
* @param string $kana set 'kana' convert to JIS-X208-kana
|
||||
*
|
||||
* @global string the available encoding codes list
|
||||
*
|
||||
@ -101,9 +101,9 @@ function PMA_kanji_str_conv($str, $enc, $kana)
|
||||
* Kanji file encoding convert
|
||||
* 2002/1/4 by Y.Kawada
|
||||
*
|
||||
* @param string the name of the file to convert
|
||||
* @param string the destination encoding code
|
||||
* @param string set 'kana' convert to JIS-X208-kana
|
||||
* @param string $file the name of the file to convert
|
||||
* @param string $enc the destination encoding code
|
||||
* @param string $kana set 'kana' convert to JIS-X208-kana
|
||||
*
|
||||
* @return string the name of the converted file
|
||||
*/
|
||||
@ -135,7 +135,7 @@ function PMA_kanji_file_conv($file, $enc, $kana)
|
||||
* Defines radio form fields to switch between encoding modes
|
||||
* 2002/1/4 by Y.Kawada
|
||||
*
|
||||
* @param string spaces character to prepend the output with
|
||||
* @param string $spaces spaces character to prepend the output with
|
||||
*
|
||||
* @return string xhtml code for the radio controls
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user