use PMA_getenv()

This commit is contained in:
Sebastian Mendel
2006-04-11 14:33:17 +00:00
parent f813549799
commit 44a0f36096
13 changed files with 1173 additions and 732 deletions

View File

@@ -26,7 +26,7 @@
* @uses PMA_VERSION
* @uses session_write_close()
* @uses time()
* @uses getenv()
* @uses PMA_getenv()
* @uses header() to send charset
*/
@@ -46,8 +46,8 @@ session_write_close();
// Gets the host name
// loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
if (empty($HTTP_HOST)) {
if (getenv('HTTP_HOST')) {
$HTTP_HOST = getenv('HTTP_HOST');
if (PMA_getenv('HTTP_HOST')) {
$HTTP_HOST = PMA_getenv('HTTP_HOST');
} else {
$HTTP_HOST = '';
}

View File

@@ -1,6 +1,25 @@
<?php
/**
* @todo update with mysql manual, last: ???
*/
define('PMA_DBI_ENGINE_MYISAM', 'MyISAM');
define('PMA_DBI_ENGINE_ISAM', 'ISAM');
define('PMA_DBI_ENGINE_INNODB', 'InnoDB');
define('PMA_DBI_ENGINE_MERGE', 'MERGE');
define('PMA_DBI_ENGINE_MEMORY', 'MEMORY');
define('PMA_DBI_ENGINE_HEAP', 'HEAP');
define('PMA_DBI_ENGINE_BDB', 'BDB');
define('PMA_DBI_ENGINE_EXAMPLE', 'EXAMPLE');
define('PMA_DBI_ENGINE_FEDERATED', 'FEDERATED');
define('PMA_DBI_ENGINE_ARCHIVE', 'ARCHIVE');
define('PMA_DBI_ENGINE_CSV', 'CSV');
define('PMA_DBI_ENGINE_BLACKHOLE', 'BLACKHOLE');
/**
* @todo use classes for Database, Column, Index
*
*/
class PMA_Table {
/**
@@ -13,31 +32,31 @@ class PMA_Table {
*/
var $db_name = '';
/**
* @var string engine (innodb, myisam, bdb, ...)
*/
var $engine = '';
/**
* @var string type (view, base table, system view)
*/
var $type = '';
/**
* @var array settings
* @var array options
*/
var $settings = array();
var $options = array();
/**
* @var array errors occured
* @var array errors occured
*/
var $errors = array();
/**
* @var array messages
* @var array messages
*/
var $messages = array();
/**
* @var boolean whether options for this table has been altered or not
*/
var $alter_options = false;
/**
* Constructor
*
@@ -58,6 +77,139 @@ class PMA_Table {
return $this->getName();
}
function getOptions($engine = null)
{
if (null === $engine) {
$engine = $this->getEnginge();
}
$options = array();
$all_options = PMA_Table::getAlterOptions();
if (($engine === 'myisam' || $engine === 'isam')) {
$options['KEYS'] = $all_options['KEYS'];
}
if (($engine === 'myisam')) {
$options['checksum'] = $all_options['KEYS'];
$options['delay_key_write'] = $all_options['KEYS'];
}
if (($engine === 'myisam' || $engine === 'innodb')) {
$options['auto_increment'] = $all_options['KEYS'];
}
}
/**
* returns all available options for any table engine
*
* @todo update with mysql manual, last: ???
* @static
*/
function getAlterOptions()
{
static $options = null;
if (null === $options) {
$options = array(
// ENABLE/DISABLE KEY
// skipped, makes no sense here
'COMMENT' => array(
'type' => 'string',
'name' => 'strTableComment',
),
'TYPE' => array(
'type' => 'string',
'values' => array('PMA_Table', 'getEngines'),
'name' => 'strTableEngine',
),
'DEFAULT_CHARSET_COLLATION' => array(
'type' => 'string',
'desc' => 'strTableCharset',
),
'pack_keys' => array(
'type' => 'string',
'name' => 'pack_keys',
'desc' => '',
'engines' => array(
PMA_DBI_ENGINE_MYISAM,
PMA_DBI_ENGINE_ISAM,
),
),
'checksum' => array(
'type' => 'string',
'name' => 'checksum',
'engines' => array(
PMA_DBI_ENGINE_MYISAM,
),
),
'delay_key_write' => array(
'type' => 'string',
'name' => 'delay_key_write',
'engines' => array(
PMA_DBI_ENGINE_MYISAM,
),
),
'auto_increment' => array(
'type' => 'int',
'name' => 'auto_increment',
'engines' => array(
PMA_DBI_ENGINE_MYISAM,
PMA_DBI_ENGINE_INNODB,
),
),
);
}
return $options;
}
function setEngine($engine)
{
$this->set('ENGINE', $engine);
}
function getEngine()
{
return $this->get('ENGINE');
}
/**
* @todo update with mysql manual, last: ???
*/
function getEngineName($engine = null)
{
if (null === $engine) {
$engine = $this->getEngine();
}
switch ($engine) {
case PMA_DBI_ENGINE_MYISAM :
return 'MyISAM';
break;
case PMA_DBI_ENGINE_ISAM :
return 'ISAM';
break;
case PMA_DBI_ENGINE_INNODB :
return 'InnoDB';
break;
case PMA_DBI_ENGINE_MERGE :
return 'Merge';
break;
case PMA_DBI_ENGINE_MEMORY :
return 'MEMORY';
break;
case PMA_DBI_ENGINE_HEAP :
return 'HEAP';
break;
case PMA_DBI_ENGINE_BDB :
return 'BerkeleyDB';
break;
default :
return 'UNKNOWN';
}
}
function getLastError()
{
return end($this->errors);
@@ -144,33 +296,203 @@ class PMA_Table {
}
/**
* sets given $value for given $param
* sets given $value for given $option
*
* @uses $this->settings to add or change value
* @param string param name
* @param mixed param value
* @uses $this->options to add or change value
* @param string $option option name
* @param mixed $value option value
*/
function set($param, $value)
function set($option, $value)
{
$this->settings[$param] = $value;
$this->options[$option]->value = $value;
}
/**
* @static
* @param string $option
* @param mixed $value
* @return string
*/
function getAlterOption($option, $value) {
switch ($option) {
case 'KEYS' :
return ($value ? 'ENABLE' : 'DISABLE') . ' KEYS';
break;
case 'TABLESPACE' :
return ($value ? 'IMPORT' : 'DISCARD') . ' TABLESPACE';
break;
case 'RENAME TO' :
case 'RENAME' :
case 'CHECK' :
case 'ORDER BY' :
return $option . ' ' . $value;
break;
case 'PACK_KEYS' :
//{0 | 1 | DEFAULT}
case 'CHECKSUM' :
case 'DELAY_KEY_WRITE' :
return $option . ' = ' . (int) (bool) $value;
break;
case 'CONVERT CHARACTER SET' :
return 'CONVERT ' . PMA_generateCharsetQueryPart($value);
break;
case 'TABLE_COLLATION' :
case 'DEFAULT CHARACTER SET' :
return 'DEFAULT ' . PMA_generateCharsetQueryPart($value);
break;
case 'CHARACTER SET' :
return PMA_generateCharsetQueryPart($value);
break;
case 'INSERT_METHOD' :
//{ NO | FIRST | LAST }
case 'UNION' :
case 'ROW_FORMAT' :
//{DEFAULT|DYNAMIC|FIXED|COMPRESSED|REDUNDANT|COMPACT}
case 'MIN_ROWS' :
case 'MAX_ROWS' :
case 'AVG_ROW_LENGTH' :
case 'ENGINE' :
case 'TYPE' :
case 'AUTO_INCREMENT' :
return $option . ' = ' . $value;
break;
case 'CONNECTION' :
case 'INDEX DIRECTORY' :
case 'DATA DIRECTORY' :
case 'CONNECTION' :
return $option . ' = \'' . PMA_sqlAddslashes($value) . '\'';
break;
case 'TABLE_COMMENT' :
case 'COMMENT' :
return 'COMMENT = \'' . PMA_sqlAddslashes($value) . '\'';
break;
default :
return '-- UNKNOWN OPTION: ' . $option . ' = \'' . PMA_sqlAddslashes($value) . '\'';
}
}
/**
* set options from given array of options
*
* @param array $options
* @return boolean success
*/
function setOptions($options, $bc = false)
{
if ($bc) {
// backward compatibility
$new_engine = strtolower($this->get('ENGINE'));
$bc_options = $options;
$options = array();
if (null !== $this->get('TABLE_COMMENT')
&& isset($bc_options['comment'])) {
$options['TABLE_COMMENT'] = $bc_options['comment'];
}
if (isset($bc_options['new_tbl_type'])
&& ! $this->isEngineOneOf($bc_options['new_tbl_type'])) {
$options['ENGINE'] = $bc_options['new_tbl_type'];
$new_engine = strtolower($options['ENGINE']);
} elseif (null !== $this->get('TYPE')
&& isset($bc_options['new_tbl_type'])) {
$options['TYPE'] = $bc_options['new_tbl_type'];
}
if (null !== $this->get('TABLE_COLLATION')
&& isset($bc_options['tbl_collation'])) {
$options['TABLE_COLLATION'] = $bc_options['tbl_collation'];
}
//if (null !== $this->get('PACK_KEYS')) {
if ($new_engine === 'myisam' || $new_engine === 'isam') {
$options['PACK_KEYS'] = (int) !empty($bc_options['new_pack_keys']);
}
//if (null !== $this->get('CHECKSUM')) {
if ($new_engine === 'myisam') {
$options['CHECKSUM'] = (int) !empty($bc_options['new_checksum']);
}
//if (null !== $this->get('DELAY_KEY_WRITE')) {
if ($new_engine === 'myisam') {
$options['DELAY_KEY_WRITE'] = (int) !empty($bc_options['new_delay_key_write']);
}
//if (null !== $this->get('AUTO_INCREMENT')
// && isset($bc_options['new_auto_increment'])) {
if (isset($bc_options['new_auto_increment'])
&& ($new_engine === 'myisam'
// MEMORY in 4.1.0
|| ($new_engine === 'memory' && PMA_MYSQL_INT_VERSION >= 40100)
// InnoDB in 4.1.2 and 5.0.3
|| ($new_engine === 'innodb' && PMA_MYSQL_INT_VERSION >= 40102))) {
$options['AUTO_INCREMENT'] = (int) $bc_options['new_auto_increment'];
}
}
$table_alters = array();
foreach ($options as $option => $value) {
if ($this->get($option) != $value) {
$table_alters[] = PMA_Table::getAlterOption($option, $value);
}
}
if (count($table_alters)) {
$sql_query = '
ALTER TABLE ' . $this->getFullName(true) . '
' . implode("\r\n", $table_alters);
if (! PMA_DBI_try_query($sql_query)) {
$this->errors[] = $GLOBALS['strError'];
return false;
}
// display executed query in user interface
if (! isset($GLOBALS['sql_query'])) {
$GLOBALS['sql_query'] = '';
}
$GLOBALS['sql_query'] .= "\r\n" . $sql_query . ';';
$this->messages[] = $GLOBALS['strSuccess'];
}
return true;
}
/**
* returns value for given setting/param
*
* @uses $this->settings to return value
* @param string name for value to return
* @return mixed value for $param
* @uses $this->options to return value
* @param string $option name for value to return
* @return mixed value for $option
*/
function get($param)
function get($option)
{
if (isset($this->settings[$param])) {
return $this->settings[$param];
if (isset($this->options[$option])) {
return $this->options[$option]->value;
}
return null;
}
/**
* cleans 'InnoDB free'-string from table comment
*/
function cleanInnodbComment($comment = null)
{
$return = true;
if (null === $comment) {
if (! $this->isEngineOneOf('innodb')) {
return;
}
$comment = $this->get('TABLE_COMMENT');
$return = false;
}
$comment = preg_replace('/(; InnoDB free: .*$)/i', '', $comment);
if ($return) {
return $comment;
} else {
$this->set('TABLE_COMMENT', $comment);
}
}
/**
* loads structure data
*/
@@ -182,25 +504,96 @@ class PMA_Table {
return false;
}
$this->settings = $table_info;
foreach ($table_info[$this->getName()] as $key => $value) {
$this->options[$key]->value = $value;
}
$this->cleanInnodbComment();
/**
* init some values, check if they exists, if not create them with
* standard values
*/
if ($this->get('TABLE_ROWS') === null) {
$this->set('TABLE_ROWS', PMA_Table::countRecords($this->getDbName(),
$this->getName(), true, true));
}
$create_options = explode(' ', $this->get('TABLE_ROWS'));
/*
if (null === $this->get('AUTO_INCREMENT')
&& ($this->isEngineOneOf('myisam')
// MEMORY in 4.1.0
|| ($this->isEngineOneOf('memory') && PMA_MYSQL_INT_VERSION >= 40100)
// InnoDB in 4.1.2 and 5.0.3
|| ($this->isEngineOneOf('innodb') && PMA_MYSQL_INT_VERSION >= 40102))) {
$this->set('AUTO_INCREMENT', 0);
} else {
// do not support this option on others than MyISAM or ISAM
$this->removeOption('AUTO_INCREMENT');
}
if (null === $this->get('PACK_KEYS')
&& $this->isEngineOneOf('myisam', 'isam')) {
$this->set('PACK_KEYS', 'DEFAULT');
echo __LINE__;
} elseif (null !== $this->get('PACK_KEYS')) {
// do not support this option on others than MyISAM or ISAM
$this->removeOption('PACK_KEYS');
echo __LINE__;
}
if (null === $this->get('CHECKSUM')
&& $this->isEngineOneOf('myisam')) {
$this->set('CHECKSUM', 0);
} else {
// do not support this option on others than MyISAM
$this->removeOption('CHECKSUM');
}
if (null === $this->get('DELAY_KEY_WRITE')
&& $this->isEngineOneOf('myisam')) {
$this->set('DELAY_KEY_WRITE', 0);
} else {
// do not support this option on others than MyISAM
$this->removeOption('DELAY_KEY_WRITE');
}
*/
$create_options = explode(' ', $this->get('CREATE_OPTIONS'));
// export create options by its name as variables into gloabel namespace
// f.e. pack_keys=1 becomes available as $pack_keys with value of '1'
foreach ($create_options as $each_create_option) {
$each_create_option = explode('=', $each_create_option);
if (isset($each_create_option[1])) {
$this->set($$each_create_option[0], $each_create_option[1]);
$this->set(strtoupper($each_create_option[0]), $each_create_option[1]);
}
}
}
function removeOption($option)
{
if (isset($this->options[$option])) {
unset($this->options[$option]);
}
}
/**
*
* @param string $engine,... engine
* @return boolean whether one of the given engines is equal with current engine
*/
function isEngineOneOf()
{
foreach (func_get_args() as $engine) {
if (strtolower($this->getEngine()) === strtolower($engine)) {
return true;
}
}
return false;
}
/**
* old PHP 4style constructor
*
@@ -496,7 +889,6 @@ class PMA_Table {
return true;
} // end of 'PMA_Table::duplicateInfo()' function
/**
* Copies or renames table
* FIXME: use RENAME
@@ -868,15 +1260,21 @@ class PMA_Table {
return false;
}
$GLOBALS['sql_query'] = '
$sql_query = '
RENAME TABLE ' . $this->getFullName(true) . '
TO ' . $new_table->getFullName(true) . ';';
if (! PMA_DBI_query($GLOBALS['sql_query'])) {
if (! PMA_DBI_query($sql_query)) {
// TODO add $GLOBALS['strErrorRenamingTable'];
$this->errors[] = $GLOBALS['strError'] . ': ' . $new_table->getFullName();
return false;
}
// display executed query in user interface
if (! isset( $GLOBALS['sql_query'])) {
$GLOBALS['sql_query'] = '';
}
$GLOBALS['sql_query'] .= "\n\n" . $sql_query;
$old_name = $this->getName();
$old_db = $this->getDbName();
$this->setName($new_name);

View File

@@ -504,8 +504,8 @@ function PMA_auth_fails()
} elseif (isset($GLOBALS['no_activity']) && $GLOBALS['no_activity']) {
$conn_error = sprintf($GLOBALS['strNoActivity'], $GLOBALS['cfg']['LoginCookieValidity']);
// Remember where we got timeout to return on same place
if (getenv('SCRIPT_NAME')) {
$GLOBALS['target'] = basename(getenv('SCRIPT_NAME'));
if (PMA_getenv('SCRIPT_NAME')) {
$GLOBALS['target'] = basename(PMA_getenv('SCRIPT_NAME'));
}
} elseif (PMA_DBI_getError()) {
$conn_error = PMA_sanitize(PMA_DBI_getError());

View File

@@ -79,38 +79,34 @@ function PMA_auth_check()
// 'register_globals' and the 'variables_order' directives
// loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
if (empty($PHP_AUTH_USER)) {
if (isset($_SERVER['PHP_AUTH_USER'])) {
$PHP_AUTH_USER = $_SERVER['PHP_AUTH_USER'];
} elseif (getenv('PHP_AUTH_USER')) {
$PHP_AUTH_USER = getenv('PHP_AUTH_USER');
} elseif (getenv('REMOTE_USER')) {
if (PMA_getenv('PHP_AUTH_USER')) {
$PHP_AUTH_USER = PMA_getenv('PHP_AUTH_USER');
} elseif (PMA_getenv('REMOTE_USER')) {
// CGI, might be encoded, see bellow
$PHP_AUTH_USER = getenv('REMOTE_USER');
} elseif (getenv('AUTH_USER')) {
$PHP_AUTH_USER = PMA_getenv('REMOTE_USER');
} elseif (PMA_getenv('AUTH_USER')) {
// WebSite Professional
$PHP_AUTH_USER = getenv('AUTH_USER');
} elseif (getenv('HTTP_AUTHORIZATION')) {
$PHP_AUTH_USER = PMA_getenv('AUTH_USER');
} elseif (PMA_getenv('HTTP_AUTHORIZATION')) {
// IIS, might be encoded, see bellow
$PHP_AUTH_USER = getenv('HTTP_AUTHORIZATION');
} elseif (getenv('Authorization')) {
$PHP_AUTH_USER = PMA_getenv('HTTP_AUTHORIZATION');
} elseif (PMA_getenv('Authorization')) {
// FastCGI, might be encoded, see bellow
$PHP_AUTH_USER = getenv('Authorization');
$PHP_AUTH_USER = PMA_getenv('Authorization');
}
}
// Grabs the $PHP_AUTH_PW variable whatever are the values of the
// 'register_globals' and the 'variables_order' directives
// loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
if (empty($PHP_AUTH_PW)) {
if (isset($_SERVER['PHP_AUTH_PW'])) {
$PHP_AUTH_PW = $_SERVER['PHP_AUTH_PW'];
} elseif (getenv('PHP_AUTH_PW')) {
$PHP_AUTH_PW = getenv('PHP_AUTH_PW');
} elseif (getenv('REMOTE_PASSWORD')) {
if (PMA_getenv('PHP_AUTH_PW')) {
$PHP_AUTH_PW = PMA_getenv('PHP_AUTH_PW');
} elseif (PMA_getenv('REMOTE_PASSWORD')) {
// Apache/CGI
$PHP_AUTH_PW = getenv('REMOTE_PASSWORD');
} elseif (getenv('AUTH_PASSWORD')) {
$PHP_AUTH_PW = PMA_getenv('REMOTE_PASSWORD');
} elseif (PMA_getenv('AUTH_PASSWORD')) {
// WebSite Professional
$PHP_AUTH_PW = getenv('AUTH_PASSWORD');
$PHP_AUTH_PW = PMA_getenv('AUTH_PASSWORD');
}
}

View File

@@ -1911,7 +1911,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
} elseif (!empty($tab['active'])
|| (isset($GLOBALS['active_page'])
&& $GLOBALS['active_page'] == $tab['link'])
|| basename(getenv('PHP_SELF')) == $tab['link'])
|| basename(PMA_getenv('PHP_SELF')) == $tab['link'])
{
$tab['class'] = 'active';
}
@@ -2623,7 +2623,7 @@ if (isset($_POST['usesubform'])) {
$_POST = $subform;
$_REQUEST = $subform;
if (isset($_POST['redirect'])
&& $_POST['redirect'] != basename(getenv('PHP_SELF'))) {
&& $_POST['redirect'] != basename(PMA_getenv('PHP_SELF'))) {
$__redirect = $_POST['redirect'];
unset($_POST['redirect']);
} // end if (isset($_POST['redirect']))

View File

@@ -80,13 +80,13 @@ if (!isset($GLOBALS['checked_special'])) {
$GLOBALS['checked_special'] = FALSE;
}
if (getenv('SCRIPT_NAME') && empty($_POST) && !$GLOBALS['checked_special']) {
if (PMA_getenv('SCRIPT_NAME') && empty($_POST) && !$GLOBALS['checked_special']) {
echo '<div id="selflink" class="print_ignore">' . "\n";
$url_params['target'] = basename(getenv('SCRIPT_NAME'));
$url_params['target'] = basename(PMA_getenv('SCRIPT_NAME'));
echo '<a href="index.php' . PMA_generate_common_url($url_params) . '"'
. ' title="' . $GLOBALS['strOpenNewWindow'] . '" target="_blank">';
/*
echo '<a href="index.php?target=' . basename(getenv('SCRIPT_NAME'));
echo '<a href="index.php?target=' . basename(PMA_getenv('SCRIPT_NAME'));
$url = PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : '');
if (!empty($url)) {
echo '&amp;' . $url;

View File

@@ -1019,7 +1019,7 @@ function Output($name='',$dest='')
//Send to standard output
// lem9
//if(isset($HTTP_SERVER_VARS['SERVER_NAME']))
if(getenv('SERVER_NAME'))
if(PMA_getenv('SERVER_NAME'))
{
//We send to a browser
Header('Content-Type: application/pdf');
@@ -1034,7 +1034,7 @@ function Output($name='',$dest='')
//Download file
// lem9
//if(isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) and strpos($HTTP_SERVER_VARS['HTTP_USER_AGENT'],'MSIE'))
if(getenv('HTTP_USER_AGENT') and strpos(getenv('HTTP_USER_AGENT'), 'MSIE'))
if(PMA_getenv('HTTP_USER_AGENT') and strpos(PMA_getenv('HTTP_USER_AGENT'), 'MSIE'))
Header('Content-Type: application/force-download');
else
Header('Content-Type: application/octet-stream');
@@ -1619,7 +1619,7 @@ function _out($s)
//Handle special IE contype request
// lem9
//if(isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) and $HTTP_SERVER_VARS['HTTP_USER_AGENT']=='contype')
if(getenv('HTTP_USER_AGENT') == 'contype')
if(PMA_getenv('HTTP_USER_AGENT') == 'contype')
{
Header('Content-Type: application/pdf');
exit;

View File

@@ -107,8 +107,8 @@ foreach ($server_vars as $current) {
// its more important to prevent XSS
// so its not important if we result in an invalid string,
// its even better than a XSS capable string
if (getenv($current) && false === strpos(getenv($current), '<')) {
$$current = getenv($current);
if (PMA_getenv($current) && false === strpos(PMA_getenv($current), '<')) {
$$current = PMA_getenv($current);
// already importet by register_globals?
} elseif (! isset($$current) || false !== strpos($$current, '<')) {
$$current = '';

View File

@@ -37,7 +37,7 @@ if (empty($GLOBALS['is_header_sent'])) {
'@PHPMYADMIN@',
),
array(
getenv('HTTP_HOST') ? getenv('HTTP_HOST') : '',
PMA_getenv('HTTP_HOST') ? PMA_getenv('HTTP_HOST') : '',
isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : '',
isset($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : '',
!empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : (isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : ''),

View File

@@ -22,29 +22,29 @@ function PMA_getIp()
global $HTTP_VIA, $HTTP_X_COMING_FROM, $HTTP_COMING_FROM;
// Get some server/environment variables values
if (empty($REMOTE_ADDR) && getenv('REMOTE_ADDR')) {
$REMOTE_ADDR = getenv('REMOTE_ADDR');
if (empty($REMOTE_ADDR) && PMA_getenv('REMOTE_ADDR')) {
$REMOTE_ADDR = PMA_getenv('REMOTE_ADDR');
}
if (empty($HTTP_X_FORWARDED_FOR) && getenv('HTTP_X_FORWARDED_FOR')) {
$HTTP_X_FORWARDED_FOR = getenv('HTTP_X_FORWARDED_FOR');
if (empty($HTTP_X_FORWARDED_FOR) && PMA_getenv('HTTP_X_FORWARDED_FOR')) {
$HTTP_X_FORWARDED_FOR = PMA_getenv('HTTP_X_FORWARDED_FOR');
}
if (empty($HTTP_X_FORWARDED) && getenv('HTTP_X_FORWARDED')) {
$HTTP_X_FORWARDED = getenv('HTTP_X_FORWARDED');
if (empty($HTTP_X_FORWARDED) && PMA_getenv('HTTP_X_FORWARDED')) {
$HTTP_X_FORWARDED = PMA_getenv('HTTP_X_FORWARDED');
}
if (empty($HTTP_FORWARDED_FOR) && getenv('HTTP_FORWARDED_FOR')) {
$HTTP_FORWARDED_FOR = getenv('HTTP_FORWARDED_FOR');
if (empty($HTTP_FORWARDED_FOR) && PMA_getenv('HTTP_FORWARDED_FOR')) {
$HTTP_FORWARDED_FOR = PMA_getenv('HTTP_FORWARDED_FOR');
}
if (empty($HTTP_FORWARDED) && getenv('HTTP_FORWARDED')) {
$HTTP_FORWARDED = getenv('HTTP_FORWARDED');
if (empty($HTTP_FORWARDED) && PMA_getenv('HTTP_FORWARDED')) {
$HTTP_FORWARDED = PMA_getenv('HTTP_FORWARDED');
}
if (empty($HTTP_VIA) && getenv('HTTP_VIA')) {
$HTTP_VIA = getenv('HTTP_VIA');
if (empty($HTTP_VIA) && PMA_getenv('HTTP_VIA')) {
$HTTP_VIA = PMA_getenv('HTTP_VIA');
}
if (empty($HTTP_X_COMING_FROM) && getenv('HTTP_X_COMING_FROM')) {
$HTTP_X_COMING_FROM = getenv('HTTP_X_COMING_FROM');
if (empty($HTTP_X_COMING_FROM) && PMA_getenv('HTTP_X_COMING_FROM')) {
$HTTP_X_COMING_FROM = PMA_getenv('HTTP_X_COMING_FROM');
}
if (empty($HTTP_COMING_FROM) && getenv('HTTP_COMING_FROM')) {
$HTTP_COMING_FROM = getenv('HTTP_COMING_FROM');
if (empty($HTTP_COMING_FROM) && PMA_getenv('HTTP_COMING_FROM')) {
$HTTP_COMING_FROM = PMA_getenv('HTTP_COMING_FROM');
}
// Gets the default ip sent by the user
@@ -189,10 +189,10 @@ function PMA_allowDeny($type)
);
// Provide some useful shortcuts if server gives us address:
if (getenv('SERVER_ADDR')) {
$shortcuts['localnetA'] = getenv('SERVER_ADDR') . '/8';
$shortcuts['localnetB'] = getenv('SERVER_ADDR') . '/16';
$shortcuts['localnetC'] = getenv('SERVER_ADDR') . '/24';
if (PMA_getenv('SERVER_ADDR')) {
$shortcuts['localnetA'] = PMA_getenv('SERVER_ADDR') . '/8';
$shortcuts['localnetB'] = PMA_getenv('SERVER_ADDR') . '/16';
$shortcuts['localnetC'] = PMA_getenv('SERVER_ADDR') . '/24';
}
foreach ($rules as $rule) {

View File

@@ -53,8 +53,8 @@ function PMA_langCheck()
}
// try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE variable
if (getenv('HTTP_ACCEPT_LANGUAGE')) {
foreach (explode(',', getenv('HTTP_ACCEPT_LANGUAGE')) as $lang) {
if (PMA_getenv('HTTP_ACCEPT_LANGUAGE')) {
foreach (explode(',', PMA_getenv('HTTP_ACCEPT_LANGUAGE')) as $lang) {
if (PMA_langDetect($lang, 1)) {
return true;
}
@@ -62,7 +62,7 @@ function PMA_langCheck()
}
// try to findout user's language by checking its HTTP_USER_AGENT variable
if (PMA_langDetect(getenv('HTTP_USER_AGENT'), 2)) {
if (PMA_langDetect(PMA_getenv('HTTP_USER_AGENT'), 2)) {
return true;
}

File diff suppressed because it is too large Load Diff

View File

@@ -66,46 +66,13 @@ if (isset($_REQUEST['submitoptions'])) {
$tbl_type = $_REQUEST['new_tbl_type'];
}
if (! empty($_REQUEST['tbl_collation'])
&& $_REQUEST['tbl_collation'] !== $tbl_collation) {
$table_alters[] = 'DEFAULT ' . PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']);
}
$pma_table->loadStructure();
$l_tbl_type = strtolower($tbl_type);
$pack_keys = empty($pack_keys) ? '0' : '1';
$_REQUEST['new_pack_keys'] = empty($_REQUEST['new_pack_keys']) ? '0' : '1';
if (($l_tbl_type === 'myisam' || $l_tbl_type === 'isam')
&& $_REQUEST['new_pack_keys'] !== $pack_keys) {
$table_alters[] = 'pack_keys = ' . $_REQUEST['new_pack_keys'];
}
$checksum = empty($checksum) ? '0' : '1';
$_REQUEST['new_checksum'] = empty($_REQUEST['new_checksum']) ? '0' : '1';
if (($l_tbl_type === 'myisam')
&& $_REQUEST['new_checksum'] !== $checksum) {
$table_alters[] = 'checksum = ' . $_REQUEST['new_checksum'];
}
$delay_key_write = empty($delay_key_write) ? '0' : '1';
$_REQUEST['new_delay_key_write'] = empty($_REQUEST['new_delay_key_write']) ? '0' : '1';
if (($l_tbl_type === 'myisam')
&& $_REQUEST['new_delay_key_write'] !== $delay_key_write) {
$table_alters[] = 'delay_key_write = ' . $_REQUEST['new_delay_key_write'];
}
if (($l_tbl_type === 'myisam' || $l_tbl_type === 'innodb')
&& ! empty($_REQUEST['new_auto_increment'])
&& (! isset($auto_increment) || $_REQUEST['new_auto_increment'] !== $auto_increment)) {
$table_alters[] = 'auto_increment = ' . PMA_sqlAddslashes($_REQUEST['new_auto_increment']);
}
if (count($table_alters) > 0) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']);
$sql_query .= "\r\n" . implode("\r\n", $table_alters);
$message .= PMA_DBI_query($sql_query) ? $strSuccess : $strError;
$reread_info = true;
unset($table_alters);
if ($pma_table->setOptions($_REQUEST, true)) {
$message .= $pma_table->getLastMessage();
} else {
$errors[] = $pma_table->getLastError();
$message .= $pma_table->getLastError();
}
}
/**