Merge pull request #1353 from Tithugues/securityStringSquash

Mass modifications to use PMA_String.
This commit is contained in:
Hugues Peccatte 2014-09-06 19:15:06 +02:00
commit ff0011ac3f
166 changed files with 5409 additions and 2061 deletions

View File

@ -23,7 +23,7 @@ $filename = CHANGELOG_FILE;
if (is_readable($filename)) {
// Test if the if is in a compressed format
if (substr($filename, -3) == '.gz') {
if ($GLOBALS['PMA_String']->substr($filename, -3) == '.gz') {
ob_start();
readgzfile($filename);
$changelog = ob_get_contents();

View File

@ -36,7 +36,7 @@ PMA_Util::checkParameters(array('db'));
/**
* Defines the url to return to in case of error in a sql statement
*/
if (strlen($table)) {
if ($GLOBALS['PMA_String']->strlen($table)) {
$err_url = 'tbl_sql.php?' . PMA_URL_getCommon($db, $table);
} else {
$err_url = 'db_sql.php?' . PMA_URL_getCommon($db);

View File

@ -32,7 +32,9 @@ $scripts->addFile('db_operations.js');
/**
* Rename/move or copy database
*/
if (strlen($GLOBALS['db'])
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strlen($GLOBALS['db'])
&& (! empty($_REQUEST['db_rename']) || ! empty($_REQUEST['db_copy']))
) {
if (! empty($_REQUEST['db_rename'])) {
@ -41,7 +43,9 @@ if (strlen($GLOBALS['db'])
$move = false;
}
if (! isset($_REQUEST['newname']) || ! strlen($_REQUEST['newname'])) {
if (! isset($_REQUEST['newname'])
|| ! $pmaString->strlen($_REQUEST['newname'])
) {
$message = PMA_Message::error(__('The database name is empty!'));
} else {
$sql_query = ''; // in case target db exists

View File

@ -59,7 +59,7 @@ if ($num_tables == 0) {
$odd_row = true;
foreach ($tables as $sts_data) {
if (PMA_Table::isMerge($db, $sts_data['TABLE_NAME'])
|| strtoupper($sts_data['ENGINE']) == 'FEDERATED'
|| $GLOBALS['PMA_String']->strtoupper($sts_data['ENGINE']) == 'FEDERATED'
) {
$merged_size = true;
} else {

View File

@ -79,7 +79,7 @@ $base .= '://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'];
$realm = $base . '/';
$returnTo = $base . dirname($_SERVER['PHP_SELF']);
if ($returnTo[strlen($returnTo) - 1] != '/') {
if ($returnTo[$GLOBALS['PMA_String']->strlen($returnTo) - 1] != '/') {
$returnTo .= '/';
}
$returnTo .= 'openid.php';

View File

@ -238,9 +238,13 @@ if (!defined('TESTSUITE')) {
}
// Generate error url and check for needed variables
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($export_type == 'server') {
$err_url = 'server_export.php?' . PMA_URL_getCommon();
} elseif ($export_type == 'database' && strlen($db)) {
} elseif ($export_type == 'database'
&& $pmaString->strlen($db)
) {
$err_url = 'db_export.php?' . PMA_URL_getCommon($db);
// Check if we have something to export
if (isset($table_select)) {
@ -248,7 +252,9 @@ if (!defined('TESTSUITE')) {
} else {
$tables = array();
}
} elseif ($export_type == 'table' && strlen($db) && strlen($table)) {
} elseif ($export_type == 'table' && $pmaString->strlen($db)
&& $pmaString->strlen($table)
) {
$err_url = 'tbl_export.php?' . PMA_URL_getCommon($db, $table);
} else {
PMA_fatalError(__('Bad parameters!'));

View File

@ -41,16 +41,26 @@ if (isset($_REQUEST['filename']) && isset($_REQUEST['image'])) {
$filename = $_REQUEST['filename'];
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
/* Decode data */
if ($extension != 'svg') {
$data = substr($_REQUEST['image'], strpos($_REQUEST['image'], ',') + 1);
$data = $pmaString->substr(
$_REQUEST['image'],
$pmaString->strpos($_REQUEST['image'], ',') + 1
);
$data = base64_decode($data);
} else {
$data = $_REQUEST['image'];
}
/* Send download header */
PMA_downloadHeader($filename, $_REQUEST['type'], strlen($data));
PMA_downloadHeader(
$filename,
$_REQUEST['type'],
$pmaString->strlen($data)
);
/* Send data */
echo $data;

View File

@ -40,16 +40,21 @@ $gis_types = array(
'GEOMETRYCOLLECTION'
);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Extract type from the initial call and make sure that it's a valid one.
// Extract from field's values if availbale, if not use the column type passed.
// Extract from field's values if available, if not use the column type passed.
if (! isset($gis_data['gis_type'])) {
if (isset($_REQUEST['type']) && $_REQUEST['type'] != '') {
$gis_data['gis_type'] = strtoupper($_REQUEST['type']);
$gis_data['gis_type'] = $pmaString->strtoupper($_REQUEST['type']);
}
if (isset($_REQUEST['value']) && trim($_REQUEST['value']) != '') {
$start = (substr($_REQUEST['value'], 0, 1) == "'") ? 1 : 0;
$gis_data['gis_type'] = substr(
$_REQUEST['value'], $start, strpos($_REQUEST['value'], "(") - $start
$start = ($pmaString->substr($_REQUEST['value'], 0, 1) == "'") ? 1 : 0;
$gis_data['gis_type'] = $pmaString->substr(
$_REQUEST['value'],
$start,
$pmaString->strpos($_REQUEST['value'], "(") - $start
);
}
if ((! isset($gis_data['gis_type']))

View File

@ -97,7 +97,7 @@ $_SESSION['Import_message']['go_back_url'] = null;
// default values
$GLOBALS['reload'] = false;
// Use to identify curren cycle is executing
// Use to identify current cycle is executing
// a multiquery statement or stored routine
if (!isset($_SESSION['is_multi_query'])) {
$_SESSION['is_multi_query'] = false;
@ -222,6 +222,8 @@ PMA_Util::checkParameters(array('import_type', 'format'));
// We don't want anything special in format
$format = PMA_securePath($format);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Create error and goto url
if ($import_type == 'table') {
@ -238,17 +240,17 @@ if ($import_type == 'table') {
$goto = 'server_import.php';
} else {
if (empty($goto) || !preg_match('@^(server|db|tbl)(_[a-z]*)*\.php$@i', $goto)) {
if (strlen($table) && strlen($db)) {
if ($pmaString->strlen($table) && $pmaString->strlen($db)) {
$goto = 'tbl_structure.php';
} elseif (strlen($db)) {
} elseif ($pmaString->strlen($db)) {
$goto = 'db_structure.php';
} else {
$goto = 'server_sql.php';
}
}
if (strlen($table) && strlen($db)) {
if ($pmaString->strlen($table) && $pmaString->strlen($db)) {
$common = PMA_URL_getCommon($db, $table);
} elseif (strlen($db)) {
} elseif ($pmaString->strlen($db)) {
$common = PMA_URL_getCommon($db);
} else {
$common = PMA_URL_getCommon();
@ -266,7 +268,7 @@ if (basename($_SERVER['SCRIPT_NAME']) === 'import.php') {
}
if (strlen($db)) {
if ($pmaString->strlen($db)) {
$GLOBALS['dbi']->selectDb($db);
}
@ -390,12 +392,13 @@ if ($memory_limit == -1) {
}
// Calculate value of the limit
if (strtolower(substr($memory_limit, -1)) == 'm') {
$memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
} elseif (strtolower(substr($memory_limit, -1)) == 'k') {
$memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
} elseif (strtolower(substr($memory_limit, -1)) == 'g') {
$memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
if ($pmaString->strtolower($pmaString->substr($memory_limit, -1)) == 'm') {
$memory_limit = (int)$pmaString->substr($memory_limit, 0, -1) * 1024 * 1024;
} elseif ($pmaString->strtolower($pmaString->substr($memory_limit, -1)) == 'k') {
$memory_limit = (int)$pmaString->substr($memory_limit, 0, -1) * 1024;
} elseif ($pmaString->strtolower($pmaString->substr($memory_limit, -1)) == 'g') {
$memory_limit
= (int)$pmaString->substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
} else {
$memory_limit = (int)$memory_limit;
}
@ -584,7 +587,7 @@ if (! $error && isset($skip)) {
$sql_data = array('valid_sql' => array(), 'valid_queries' => 0);
if (! $error) {
// Check for file existance
// Check for file existence
include_once "libraries/plugin_interface.lib.php";
$import_plugin = PMA_getPlugin(
"import",
@ -677,7 +680,8 @@ if (isset($message)) {
// in case of a query typed in the query window
// (but if the query is too large, in case of an imported file, the parser
// can choke on it so avoid parsing)
if (strlen($sql_query) <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
if ($pmaString->strlen($sql_query) <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']
) {
include_once 'libraries/parse_analyze.inc.php';
}

View File

@ -32,9 +32,12 @@ if (version_compare(PHP_VERSION, '5.4.0', '>=')
define('UPLOAD_PREFIX', ini_get('session.upload_progress.prefix'));
session_start();
/** @var PMA_String $pmaString /
$pmaString = $GLOBALS['PMA_String'];
foreach ($_SESSION as $key => $value) {
// only copy session-prefixed data
if (substr($key, 0, strlen(UPLOAD_PREFIX)) == UPLOAD_PREFIX) {
if ($pmaString->substr($key, 0, $pmaString->strlen(UPLOAD_PREFIX))
== UPLOAD_PREFIX) {
$sessionupload[$key] = $value;
}
}
@ -61,9 +64,12 @@ if (defined('SESSIONUPLOAD')) {
$_SESSION[$key] = $value;
}
/** @var PMA_String $pmaString /
$pmaString = $GLOBALS['PMA_String'];
// remove session upload data that are not set anymore
foreach ($_SESSION as $key => $value) {
if (substr($key, 0, strlen(UPLOAD_PREFIX)) == UPLOAD_PREFIX
if ($pmaString->substr($key, 0, $pmaString->strlen(UPLOAD_PREFIX))
== UPLOAD_PREFIX
&& ! isset($sessionupload[$key])
) {
unset($_SESSION[$key]);

View File

@ -553,20 +553,25 @@ if (isset($GLOBALS['dbi'])
&& !PMA_DRIZZLE
&& $cfg['ServerLibraryDifference_DisableWarning'] == false
) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$_client_info = $GLOBALS['dbi']->getClientInfo();
if ($server > 0
&& strpos($_client_info, 'mysqlnd') === false
&& substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(PMA_MYSQL_INT_VERSION, 0, 3)
&& $pmaString->strpos($_client_info, 'mysqlnd') === false
&& $pmaString->substr(PMA_MYSQL_CLIENT_API, 0, 3) != $pmaString->substr(
PMA_MYSQL_INT_VERSION, 0, 3
)
) {
trigger_error(
PMA_sanitize(
sprintf(
__('Your PHP MySQL library version %s differs from your MySQL server version %s. This may cause unpredictable behavior.'),
$_client_info,
substr(
$pmaString->substr(
PMA_MYSQL_STR_VERSION,
0,
strpos(PMA_MYSQL_STR_VERSION . '-', '-')
$pmaString->strpos(PMA_MYSQL_STR_VERSION . '-', '-')
)
)
),

View File

@ -382,6 +382,9 @@ class Advisor
$ruleNo = -1;
$ruleLine = -1;
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
for ($i = 0; $i < $numLines; $i++) {
$line = $file[$i];
if ($line == "" || $line[0] == '#') {
@ -389,7 +392,7 @@ class Advisor
}
// Reading new rule
if (substr($line, 0, 4) == 'rule') {
if ($pmaString->substr($line, 0, 4) == 'rule') {
if ($ruleLine > 0) {
$errors[] = sprintf(
__(
@ -443,7 +446,9 @@ class Advisor
);
continue;
}
$rules[$ruleNo][$ruleSyntax[$ruleLine]] = chop(substr($line, 1));
$rules[$ruleNo][$ruleSyntax[$ruleLine]] = chop(
$pmaString->substr($line, 1)
);
$lines[$ruleNo][$ruleSyntax[$ruleLine]] = $i + 1;
$ruleLine += 1;
}

View File

@ -148,7 +148,7 @@ class PMA_Config
}
// disable output-buffering (if set to 'auto') for IE6, else enable it.
if (strtolower($this->get('OBGzip')) == 'auto') {
if ($GLOBALS['PMA_String']->strtolower($this->get('OBGzip')) == 'auto') {
if ($this->get('PMA_USR_BROWSER_AGENT') == 'IE'
&& $this->get('PMA_USR_BROWSER_VER') >= 6
&& $this->get('PMA_USR_BROWSER_VER') < 7
@ -176,16 +176,19 @@ class PMA_Config
$HTTP_USER_AGENT = '';
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// 1. Platform
if (strstr($HTTP_USER_AGENT, 'Win')) {
if ($pmaString->strstr($HTTP_USER_AGENT, 'Win')) {
$this->set('PMA_USR_OS', 'Win');
} elseif (strstr($HTTP_USER_AGENT, 'Mac')) {
} elseif ($pmaString->strstr($HTTP_USER_AGENT, 'Mac')) {
$this->set('PMA_USR_OS', 'Mac');
} elseif (strstr($HTTP_USER_AGENT, 'Linux')) {
} elseif ($pmaString->strstr($HTTP_USER_AGENT, 'Linux')) {
$this->set('PMA_USR_OS', 'Linux');
} elseif (strstr($HTTP_USER_AGENT, 'Unix')) {
} elseif ($pmaString->strstr($HTTP_USER_AGENT, 'Unix')) {
$this->set('PMA_USR_OS', 'Unix');
} elseif (strstr($HTTP_USER_AGENT, 'OS/2')) {
} elseif ($pmaString->strstr($HTTP_USER_AGENT, 'OS/2')) {
$this->set('PMA_USR_OS', 'OS/2');
} else {
$this->set('PMA_USR_OS', 'Other');
@ -260,7 +263,7 @@ class PMA_Config
);
$this->set('PMA_USR_BROWSER_AGENT', 'SAFARI');
// Firefox
} elseif (! strstr($HTTP_USER_AGENT, 'compatible')
} elseif (! $pmaString->strstr($HTTP_USER_AGENT, 'compatible')
&& preg_match('@Firefox/([\w.]+)@', $HTTP_USER_AGENT, $log_version)
) {
$this->set(
@ -288,23 +291,28 @@ class PMA_Config
{
if ($this->get('GD2Available') == 'yes') {
$this->set('PMA_IS_GD2', 1);
} elseif ($this->get('GD2Available') == 'no') {
return;
}
if ($this->get('GD2Available') == 'no') {
$this->set('PMA_IS_GD2', 0);
} else {
if (!@function_exists('imagecreatetruecolor')) {
$this->set('PMA_IS_GD2', 0);
return;
}
if (!@function_exists('imagecreatetruecolor')) {
$this->set('PMA_IS_GD2', 0);
return;
}
if (@function_exists('gd_info')) {
$gd_nfo = gd_info();
if ($GLOBALS['PMA_String']->strstr($gd_nfo["GD Version"], '2.')) {
$this->set('PMA_IS_GD2', 1);
} else {
if (@function_exists('gd_info')) {
$gd_nfo = gd_info();
if (strstr($gd_nfo["GD Version"], '2.')) {
$this->set('PMA_IS_GD2', 1);
} else {
$this->set('PMA_IS_GD2', 0);
}
} else {
$this->set('PMA_IS_GD2', 0);
}
$this->set('PMA_IS_GD2', 0);
}
} else {
$this->set('PMA_IS_GD2', 0);
}
}
@ -426,12 +434,16 @@ class PMA_Config
if (! $ref_head = @file_get_contents($git_folder . '/HEAD')) {
return;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$branch = false;
// are we on any branch?
if (strstr($ref_head, '/')) {
$ref_head = substr(trim($ref_head), 5);
if (substr($ref_head, 0, 11) === 'refs/heads/') {
$branch = substr($ref_head, 11);
//@TODO Implement strstr in PMA_String
if ($pmaString->strstr($ref_head, '/')) {
$ref_head = $pmaString->substr(trim($ref_head), 5);
if ($pmaString->substr($ref_head, 0, 11) === 'refs/heads/') {
$branch = $pmaString->substr($ref_head, 11);
} else {
$branch = basename($ref_head);
}
@ -479,8 +491,9 @@ class PMA_Config
$commit = false;
if (! isset($_SESSION['PMA_VERSION_COMMITDATA_' . $hash])) {
$git_file_name = $git_folder . '/objects/' . substr($hash, 0, 2)
. '/' . substr($hash, 2);
$git_file_name = $git_folder . '/objects/'
. $pmaString->substr($hash, 0, 2)
. '/' . $pmaString->substr($hash, 2);
if (file_exists($git_file_name) ) {
if (! $commit = @file_get_contents($git_file_name)) {
return;
@ -499,7 +512,7 @@ class PMA_Config
// packs. (to look for them in .git/object/pack directory later)
foreach (explode("\n", $packs) as $line) {
// skip blank lines
if (strlen(trim($line)) == 0) {
if ($pmaString->strlen(trim($line)) == 0) {
continue;
}
// skip non pack lines
@ -507,7 +520,7 @@ class PMA_Config
continue;
}
// parse names
$pack_names[] = substr($line, 2);
$pack_names[] = $pmaString->substr($line, 2);
}
} else {
// '.git/objects/info/packs' file can be missing
@ -522,13 +535,13 @@ class PMA_Config
$file_name = $file_info->getFilename();
// if this is a .pack file
if ($file_info->isFile()
&& substr($file_name, -5) == '.pack'
&& $pmaString->substr($file_name, -5) == '.pack'
) {
$pack_names[] = $file_name;
}
}
}
$hash = strtolower($hash);
$hash = $pmaString->strtolower($hash);
foreach ($pack_names as $pack_name) {
$index_name = str_replace('.pack', '.idx', $pack_name);
@ -540,19 +553,22 @@ class PMA_Config
continue;
}
// check format
if (substr($index_data, 0, 4) != "\377tOc") {
if ($pmaString->substr($index_data, 0, 4) != "\377tOc") {
continue;
}
// check version
$version = unpack('N', substr($index_data, 4, 4));
$version = unpack('N', $pmaString->substr($index_data, 4, 4));
if ($version[1] != 2) {
continue;
}
// parse fanout table
$fanout = unpack("N*", substr($index_data, 8, 256 * 4));
$fanout = unpack(
"N*",
$pmaString->substr($index_data, 8, 256 * 4)
);
// find where we should search
$firstbyte = intval(substr($hash, 0, 2), 16);
$firstbyte = intval($pmaString->substr($hash, 0, 2), 16);
// array is indexed from 1 and we need to get
// previous entry for start
if ($firstbyte == 0) {
@ -566,9 +582,9 @@ class PMA_Config
$found = false;
$offset = 8 + (256 * 4);
for ($position = $start; $position < $end; $position++) {
$sha = strtolower(
$sha = $pmaString->strtolower(
bin2hex(
substr(
$pmaString->substr(
$index_data, $offset + ($position * 20), 20
)
)
@ -584,7 +600,8 @@ class PMA_Config
// read pack offset
$offset = 8 + (256 * 4) + (24 * $fanout[256]);
$pack_offset = unpack(
'N', substr($index_data, $offset + ($position * 4), 4)
'N',
$pmaString->substr($index_data, $offset + ($position * 4), 4)
);
$pack_offset = $pack_offset[1];
@ -599,14 +616,14 @@ class PMA_Config
fseek($pack_file, $pack_offset);
// parse header
$header = ord(fread($pack_file, 1));
$header = $pmaString->ord(fread($pack_file, 1));
$type = ($header >> 4) & 7;
$hasnext = ($header & 128) >> 7;
$size = $header & 0xf;
$offset = 4;
while ($hasnext) {
$byte = ord(fread($pack_file, 1));
$byte = $pmaString->ord(fread($pack_file, 1));
$size |= ($byte & 0x7f) << $offset;
$hasnext = ($byte & 128) >> 7;
$offset += 7;
@ -769,9 +786,24 @@ class PMA_Config
}
$httpOk = 'HTTP/1.1 200 OK';
$httpNotFound = 'HTTP/1.1 404 Not Found';
if (substr($data, 0, strlen($httpOk)) === $httpOk) {
return $get_body ? substr($data, strpos($data, "\r\n\r\n") + 4) : true;
} elseif (substr($data, 0, strlen($httpNotFound)) === $httpNotFound) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->substr($data, 0, $pmaString->strlen($httpOk)) === $httpOk) {
return $get_body
? $pmaString->substr(
$data,
$pmaString->strpos($data, "\r\n\r\n") + 4
)
: true;
}
$httpNOK = $pmaString->substr(
$data,
0,
$pmaString->strlen($httpNotFound)
);
if ($httpNOK === $httpNotFound) {
return false;
}
return null;
@ -1259,7 +1291,9 @@ class PMA_Config
$pma_absolute_uri = $this->get('PmaAbsoluteUri');
$is_https = $this->detectHttps();
if (strlen($pma_absolute_uri) < 5) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strlen($pma_absolute_uri) < 5) {
$url = array();
// If we don't have scheme, we didn't have full URL so we need to
@ -1355,7 +1389,7 @@ class PMA_Config
$path = '';
}
// in vhost situations, there could be already an ending slash
if (substr($path, -1) != '/') {
if ($pmaString->substr($path, -1) != '/') {
$path .= '/';
}
$pma_absolute_uri .= $path;
@ -1377,18 +1411,21 @@ class PMA_Config
// Adds a trailing slash et the end of the phpMyAdmin uri if it
// does not exist.
if (substr($pma_absolute_uri, -1) != '/') {
if ($pmaString->substr($pma_absolute_uri, -1) != '/') {
$pma_absolute_uri .= '/';
}
// If URI doesn't start with http:// or https://, we will add
// this.
if (substr($pma_absolute_uri, 0, 7) != 'http://'
&& substr($pma_absolute_uri, 0, 8) != 'https://'
if ($pmaString->substr($pma_absolute_uri, 0, 7) != 'http://'
&& $pmaString->substr($pma_absolute_uri, 0, 8) != 'https://'
) {
$pma_absolute_uri
= ($is_https ? 'https' : 'http')
. ':' . (substr($pma_absolute_uri, 0, 2) == '//' ? '' : '//')
. ':'
. (
$pmaString->substr($pma_absolute_uri, 0, 2) == '//' ? '' : '//'
)
. $pma_absolute_uri;
}
}
@ -1474,14 +1511,15 @@ class PMA_Config
*/
function checkUpload()
{
if (ini_get('file_uploads')) {
$this->set('enable_upload', true);
// if set "php_admin_value file_uploads Off" in httpd.conf
// ini_get() also returns the string "Off" in this case:
if ('off' == strtolower(ini_get('file_uploads'))) {
$this->set('enable_upload', false);
}
} else {
if (!ini_get('file_uploads')) {
$this->set('enable_upload', false);
return;
}
$this->set('enable_upload', true);
// if set "php_admin_value file_uploads Off" in httpd.conf
// ini_get() also returns the string "Off" in this case:
if ('off' == $GLOBALS['PMA_String']->strtolower(ini_get('file_uploads'))) {
$this->set('enable_upload', false);
}
}
@ -1558,6 +1596,9 @@ class PMA_Config
}
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// If we don't have scheme, we didn't have full URL so we need to
// dig deeper
if (empty($url['scheme'])) {
@ -1565,18 +1606,19 @@ class PMA_Config
if (PMA_getenv('HTTP_SCHEME')) {
$url['scheme'] = PMA_getenv('HTTP_SCHEME');
} elseif (PMA_getenv('HTTPS')
&& strtolower(PMA_getenv('HTTPS')) == 'on'
&& $pmaString->strtolower(PMA_getenv('HTTPS')) == 'on'
) {
$url['scheme'] = 'https';
// A10 Networks load balancer:
} elseif (PMA_getenv('HTTP_HTTPS_FROM_LB')
&& strtolower(PMA_getenv('HTTP_HTTPS_FROM_LB')) == 'on'
&& $pmaString->strtolower(PMA_getenv('HTTP_HTTPS_FROM_LB')) == 'on'
) {
$url['scheme'] = 'https';
} elseif (PMA_getenv('HTTP_X_FORWARDED_PROTO')) {
$url['scheme'] = strtolower(PMA_getenv('HTTP_X_FORWARDED_PROTO'));
$url['scheme']
= $pmaString->strtolower(PMA_getenv('HTTP_X_FORWARDED_PROTO'));
} elseif (PMA_getenv('HTTP_FRONT_END_HTTPS')
&& strtolower(PMA_getenv('HTTP_FRONT_END_HTTPS')) == 'on'
&& $pmaString->strtolower(PMA_getenv('HTTP_FRONT_END_HTTPS')) == 'on'
) {
$url['scheme'] = 'https';
} else {
@ -1815,7 +1857,9 @@ class PMA_Config
function setCookie($cookie, $value, $default = null, $validity = null,
$httponly = true
) {
if (strlen($value) && null !== $default && $value === $default) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strlen($value) && null !== $default && $value === $default) {
// default value is used
if (isset($_COOKIE[$cookie])) {
// remove cookie
@ -1824,7 +1868,7 @@ class PMA_Config
return false;
}
if (! strlen($value) && isset($_COOKIE[$cookie])) {
if (!$pmaString->strlen($value) && isset($_COOKIE[$cookie])) {
// remove cookie, value is empty
return $this->removeCookie($cookie);
}

View File

@ -334,7 +334,7 @@ class PMA_DbQbe
$this->_columnNames[] = $each_column;
// increase the width if necessary
$this->_form_column_width = max(
strlen($each_column),
$GLOBALS['PMA_String']->strlen($each_column),
$this->_form_column_width
);
} // end foreach
@ -454,49 +454,53 @@ class PMA_DbQbe
$html_output = '<tr class="even noclick">';
$html_output .= '<th>' . __('Sort:') . '</th>';
$new_column_count = 0;
/** @var PMA_String $pmaStr */
$pmaStr = $GLOBALS['PMA_String'];
for (
$column_index = 0;
$column_index < $this->_criteria_column_count;
$column_index++
$colInd = 0;
$colInd < $this->_criteria_column_count;
$colInd++
) {
if (! empty($this->_criteriaColumnInsert)
&& isset($this->_criteriaColumnInsert[$column_index])
&& $this->_criteriaColumnInsert[$column_index] == 'on'
&& isset($this->_criteriaColumnInsert[$colInd])
&& $this->_criteriaColumnInsert[$colInd] == 'on'
) {
$html_output .= $this->_getSortSelectCell($new_column_count);
$new_column_count++;
} // end if
if (! empty($this->_criteriaColumnDelete)
&& isset($this->_criteriaColumnDelete[$column_index])
&& $this->_criteriaColumnDelete[$column_index] == 'on'
&& isset($this->_criteriaColumnDelete[$colInd])
&& $this->_criteriaColumnDelete[$colInd] == 'on'
) {
continue;
}
// If they have chosen all fields using the * selector,
// then sorting is not available, Fix for Bug #570698
if (isset($_REQUEST['criteriaSort'][$column_index])
&& isset($_REQUEST['criteriaColumn'][$column_index])
&& substr($_REQUEST['criteriaColumn'][$column_index], -2) == '.*'
if (isset($_REQUEST['criteriaSort'][$colInd])
&& isset($_REQUEST['criteriaColumn'][$colInd])
&& $pmaStr->substr($_REQUEST['criteriaColumn'][$colInd], -2) == '.*'
) {
$_REQUEST['criteriaSort'][$column_index] = '';
$_REQUEST['criteriaSort'][$colInd] = '';
} //end if
// Set asc_selected
if (isset($_REQUEST['criteriaSort'][$column_index])
&& $_REQUEST['criteriaSort'][$column_index] == 'ASC'
if (isset($_REQUEST['criteriaSort'][$colInd])
&& $_REQUEST['criteriaSort'][$colInd] == 'ASC'
) {
$this->_curSort[$new_column_count]
= $_REQUEST['criteriaSort'][$column_index];
= $_REQUEST['criteriaSort'][$colInd];
$asc_selected = ' selected="selected"';
} else {
$asc_selected = '';
} // end if
// Set desc selected
if (isset($_REQUEST['criteriaSort'][$column_index])
&& $_REQUEST['criteriaSort'][$column_index] == 'DESC'
if (isset($_REQUEST['criteriaSort'][$colInd])
&& $_REQUEST['criteriaSort'][$colInd] == 'DESC'
) {
$this->_curSort[$new_column_count]
= $_REQUEST['criteriaSort'][$column_index];
= $_REQUEST['criteriaSort'][$colInd];
$desc_selected = ' selected="selected"';
} else {
$desc_selected = '';
@ -995,6 +999,9 @@ class PMA_DbQbe
*/
private function _getWhereClause()
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$where_clause = '';
$criteria_cnt = 0;
for (
@ -1009,7 +1016,7 @@ class PMA_DbQbe
&& isset($this->_curAndOrCol)
) {
$where_clause .= ' '
. strtoupper($this->_curAndOrCol[$last_where]) . ' ';
. $pmaString->strtoupper($this->_curAndOrCol[$last_where]) . ' ';
}
if (! empty($this->_curField[$column_index])
&& ! empty($this->_curCriteria[$column_index])
@ -1045,7 +1052,8 @@ class PMA_DbQbe
&& $column_index
) {
$qry_orwhere .= ' '
. strtoupper($this->_curAndOrCol[$last_orwhere]) . ' ';
. $pmaString->strtoupper($this->_curAndOrCol[$last_orwhere])
. ' ';
}
if (! empty($this->_curField[$column_index])
&& ! empty($_REQUEST['Or' . $row_index][$column_index])
@ -1063,7 +1071,7 @@ class PMA_DbQbe
}
if (! empty($qry_orwhere)) {
$where_clause .= "\n"
. strtoupper(
. $pmaString->strtoupper(
isset($this->_curAndOrRow[$row_index])
? $this->_curAndOrRow[$row_index] . ' '
: ''
@ -1087,6 +1095,10 @@ class PMA_DbQbe
{
$orderby_clause = '';
$orderby_clauses = array();
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
for (
$column_index = 0;
$column_index < $this->_criteria_column_count;
@ -1095,15 +1107,18 @@ class PMA_DbQbe
// if all columns are chosen with * selector,
// then sorting isn't available
// Fix for Bug #570698
if (! empty($this->_curField[$column_index])
&& ! empty($this->_curSort[$column_index])
if (empty($this->_curField[$column_index])
&& empty($this->_curSort[$column_index])
) {
if (substr($this->_curField[$column_index], -2) == '.*') {
continue;
}
$orderby_clauses[] = $this->_curField[$column_index] . ' '
. $this->_curSort[$column_index];
continue;
}
if ($pmaString->substr($this->_curField[$column_index], -2) == '.*') {
continue;
}
$orderby_clauses[] = $this->_curField[$column_index] . ' '
. $this->_curSort[$column_index];
} // end for
if ($orderby_clauses) {
$orderby_clause = 'ORDER BY '
@ -1243,7 +1258,7 @@ class PMA_DbQbe
// table, whether they have any matching row in child table or not.
// So we select candidate tables which are foreign tables.
$foreign_tables = array();
foreach ($candidate_columns as $key => $one_table) {
foreach ($candidate_columns as $one_table) {
$foreigners = PMA_getForeigners($this->_db, $one_table);
foreach ($foreigners as $key => $foreigner) {
if ($key != 'foreign_keys_data') {
@ -1251,16 +1266,12 @@ class PMA_DbQbe
$foreign_tables[$foreigner['foreign_table']]
= $foreigner['foreign_table'];
}
} else {
foreach ($foreigner as $one_key) {
if (in_array(
$one_key['ref_table_name'],
$candidate_columns
)
) {
$foreign_tables[$one_key['ref_table_name']]
= $one_key['ref_table_name'];
}
continue;
}
foreach ($foreigner as $one_key) {
if (in_array($one_key['ref_table_name'], $candidate_columns)) {
$foreign_tables[$one_key['ref_table_name']]
= $one_key['ref_table_name'];
}
}
}
@ -1311,6 +1322,10 @@ class PMA_DbQbe
{
$where_clause_columns = array();
$where_clause_tables = array();
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Now we need all tables that we have in the where clause
for (
$column_index = 0, $nb = count($this->_criteria);
@ -1327,8 +1342,8 @@ class PMA_DbQbe
// Now we know that our array has the same numbers as $criteria
// we can check which of our columns has a where clause
if (! empty($this->_criteria[$column_index])) {
if (substr($this->_criteria[$column_index], 0, 1) == '='
|| stristr($this->_criteria[$column_index], 'is')
if ($pmaString->substr($this->_criteria[$column_index], 0, 1) == '='
|| /*$pmaString->*/stristr($this->_criteria[$column_index], 'is')
) {
$where_clause_columns[$column] = $column;
$where_clause_tables[$table] = $table;

View File

@ -497,12 +497,15 @@ class PMA_DatabaseInterface
$sql, array('TABLE_SCHEMA', 'TABLE_NAME'), null, $link
);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if (PMA_DRIZZLE) {
// correct I_S and D_D names returned by D_D.TABLES -
// Drizzle generally uses lower case for them,
// but TABLES returns uppercase
foreach ((array)$database as $db) {
$db_upper = strtoupper($db);
$db_upper = $pmaString->strtoupper($db);
if (!isset($tables[$db]) && isset($tables[$db_upper])) {
$tables[$db] = $tables[$db_upper];
unset($tables[$db_upper]);
@ -543,32 +546,36 @@ class PMA_DatabaseInterface
$this->_cacheTableData($tables, $table);
if (! is_array($database)) {
if (isset($tables[$database])) {
return $tables[$database];
} elseif (isset($tables[strtolower($database)])) {
// on windows with lower_case_table_names = 1
// MySQL returns
// with SHOW DATABASES or information_schema.SCHEMATA: `Test`
// but information_schema.TABLES gives `test`
// bug #2036
// https://sourceforge.net/p/phpmyadmin/bugs/2036/
return $tables[strtolower($database)];
} else {
// one database but inexact letter case match
// as Drizzle is always case insensitive,
// we can safely return the only result
if (PMA_DRIZZLE && count($tables) == 1) {
$keys = array_keys($tables);
if (strlen(array_pop($keys)) == strlen($database)) {
return array_pop($tables);
}
}
return $tables;
}
} else {
if (is_array($database)) {
return $tables;
}
if (isset($tables[$database])) {
return $tables[$database];
}
if (isset($tables[$pmaString->strtolower($database)])) {
// on windows with lower_case_table_names = 1
// MySQL returns
// with SHOW DATABASES or information_schema.SCHEMATA: `Test`
// but information_schema.TABLES gives `test`
// bug #2036
// https://sourceforge.net/p/phpmyadmin/bugs/2036/
return $tables[$pmaString->strtolower($database)];
}
// one database but inexact letter case match
// as Drizzle is always case insensitive,
// we can safely return the only result
if (!PMA_DRIZZLE || !count($tables) == 1) {
return $tables;
}
$keys = array_keys($tables);
if ($pmaString->strlen(array_pop($keys)) == $pmaString->strlen($database)) {
return array_pop($tables);
}
return $tables;
}
/**
@ -640,7 +647,9 @@ class PMA_DatabaseInterface
$tables[$table_name]['TABLE_COMMENT']
=& $tables[$table_name]['Comment'];
if (strtoupper($tables[$table_name]['Comment']) === 'VIEW'
$commentUpper = $GLOBALS['PMA_String']
->strtoupper($tables[$table_name]['Comment']);
if ($commentUpper === 'VIEW'
&& $tables[$table_name]['Engine'] == null
) {
$tables[$table_name]['TABLE_TYPE'] = 'VIEW';
@ -701,7 +710,7 @@ class PMA_DatabaseInterface
$link = null, $sort_by = 'SCHEMA_NAME', $sort_order = 'ASC',
$limit_offset = 0, $limit_count = false
) {
$sort_order = strtoupper($sort_order);
$sort_order = $GLOBALS['PMA_String']->strtoupper($sort_order);
if (true === $limit_count) {
$limit_count = $GLOBALS['cfg']['MaxDbList'];
@ -1830,7 +1839,8 @@ class PMA_DatabaseInterface
$error .= ' - ' . $error_message;
$error .= '<br />' . __('The server is not responding.');
} elseif ($error_number == 1005) {
if (strpos($error_message, 'errno: 13') !== false) {
if ($GLOBALS['PMA_String']->strpos($error_message, 'errno: 13') !== false
) {
$error .= ' - ' . $error_message;
$error .= '<br />'
. __('Please check privileges of directory containing database.');
@ -1951,9 +1961,13 @@ class PMA_DatabaseInterface
*/
public function isSystemSchema($schema_name, $testForMysqlSchema = false)
{
return strtolower($schema_name) == 'information_schema'
|| (!PMA_DRIZZLE && strtolower($schema_name) == 'performance_schema')
|| (PMA_DRIZZLE && strtolower($schema_name) == 'data_dictionary')
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
return $pmaString->strtolower($schema_name) == 'information_schema'
|| (!PMA_DRIZZLE
&& $pmaString->strtolower($schema_name) == 'performance_schema')
|| (PMA_DRIZZLE
&& $pmaString->strtolower($schema_name) == 'data_dictionary')
|| ($testForMysqlSchema && !PMA_DRIZZLE && $schema_name == 'mysql');
}

View File

@ -214,16 +214,18 @@ class PMA_DbSearch
? array($this->_criteriaSearchString)
: explode(' ', $this->_criteriaSearchString));
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
foreach ($search_words as $search_word) {
// Eliminates empty values
if (strlen($search_word) === 0) {
if ($pmaString->strlen($search_word) === 0) {
continue;
}
$likeClausesPerColumn = array();
// for each column in the table
foreach ($allColumns as $column) {
if (! isset($this->_criteriaColumnName)
|| strlen($this->_criteriaColumnName) == 0
|| $pmaString->strlen($this->_criteriaColumnName) == 0
|| $column['Field'] == $this->_criteriaColumnName
) {
// Drizzle has no CONVERT and all text columns are UTF-8

File diff suppressed because it is too large Load Diff

View File

@ -251,7 +251,9 @@ class PMA_Error extends PMA_Message
*/
public function getHtmlTitle()
{
return htmlspecialchars(substr($this->getTitle(), 0, 100));
return htmlspecialchars(
$GLOBALS['PMA_String']->substr($this->getTitle(), 0, 100)
);
}
/**
@ -435,7 +437,7 @@ class PMA_Error extends PMA_Message
{
$dest = realpath($dest);
if (substr(PHP_OS, 0, 3) == 'WIN') {
if ($GLOBALS['PMA_String']->substr(PHP_OS, 0, 3) == 'WIN') {
$separator = '\\';
} else {
$separator = '/';

View File

@ -714,7 +714,7 @@ class PMA_File
*/
public function getContentLength()
{
return strlen($this->_content);
return $GLOBALS['PMA_String']->strlen($this->_content);
}
/**

View File

@ -104,18 +104,21 @@ class PMA_Font
*/
$count = 0;
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
foreach ($charLists as $charList) {
$count += ((strlen($text)
- strlen(str_replace($charList["chars"], "", $text))
$count += (($pmaString->strlen($text)
- $pmaString->strlen(str_replace($charList["chars"], "", $text))
) * $charList["modifier"]);
}
$text = str_replace(" ", "", $text);//remove the " "'s
//all other chars
$count = $count + (strlen(preg_replace("/[a-z0-9]/i", "", $text)) * 0.3);
$count = $count
+ ($pmaString->strlen(preg_replace("/[a-z0-9]/i", "", $text)) * 0.3);
$modifier = 1;
$font = strtolower($font);
$font = $pmaString->strtolower($font);
switch ($font) {
/*
* no modifier for arial and sans-serif

View File

@ -557,10 +557,12 @@ class PMA_Header
$lang = $GLOBALS['available_languages'][$GLOBALS['lang']][1];
$dir = $GLOBALS['text_dir'];
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$retval = "<!DOCTYPE HTML>";
$retval .= "<html lang='$lang' dir='$dir' class='";
$retval .= strtolower(PMA_USR_BROWSER_AGENT) . " ";
$retval .= strtolower(PMA_USR_BROWSER_AGENT)
$retval .= $pmaString->strtolower(PMA_USR_BROWSER_AGENT) . " ";
$retval .= $pmaString->strtolower(PMA_USR_BROWSER_AGENT)
. intval(PMA_USR_BROWSER_VER) . "'>";
return $retval;
@ -704,7 +706,7 @@ class PMA_Header
{
$retval = '';
if ($this->_menuEnabled
&& strlen($table)
&& $GLOBALS['PMA_String']->strlen($table)
&& $GLOBALS['cfg']['NumRecentTables'] > 0
) {
$tmp_result = PMA_RecentFavoriteTable::getInstance('recent')->add($db, $table);

View File

@ -111,7 +111,7 @@ class PMA_Index
PMA_Index::_loadIndexes($table, $schema);
if (! isset(PMA_Index::$_registry[$schema][$table][$index_name])) {
$index = new PMA_Index;
if (strlen($index_name)) {
if ($GLOBALS['PMA_String']->strlen($index_name)) {
$index->setName($index_name);
PMA_Index::$_registry[$schema][$table][$index->getName()] = $index;
}
@ -199,7 +199,9 @@ class PMA_Index
*/
public function addColumn($params)
{
if (isset($params['Column_name']) && strlen($params['Column_name'])) {
if (isset($params['Column_name'])
&& $GLOBALS['PMA_String']->strlen($params['Column_name'])
) {
$this->_columns[$params['Column_name']] = new PMA_Index_Column($params);
}
}
@ -339,7 +341,7 @@ class PMA_Index
public function getComments()
{
$comments = $this->getRemarks();
if (strlen($comments)) {
if ($GLOBALS['PMA_String']->strlen($comments)) {
$comments .= "\n";
}
$comments .= $this->getComment();

View File

@ -142,7 +142,7 @@ class PMA_List_Database extends PMA_List
protected function checkOnlyDatabase()
{
if (is_string($GLOBALS['cfg']['Server']['only_db'])
&& strlen($GLOBALS['cfg']['Server']['only_db'])
&& $GLOBALS['PMA_String']->strlen($GLOBALS['cfg']['Server']['only_db'])
) {
$GLOBALS['cfg']['Server']['only_db'] = array(
$GLOBALS['cfg']['Server']['only_db']
@ -183,7 +183,7 @@ class PMA_List_Database extends PMA_List
*/
public function getDefault()
{
if (strlen($GLOBALS['db'])) {
if ($GLOBALS['PMA_String']->strlen($GLOBALS['db'])) {
return $GLOBALS['db'];
}

View File

@ -81,7 +81,7 @@ class PMA_Menu
*/
public function getHash()
{
return substr(
return $GLOBALS['PMA_String']->substr(
md5($this->_getMenu() . $this->_getBreadcrumbs()),
0,
8
@ -98,11 +98,13 @@ class PMA_Menu
$url_params = array('db' => $this->_db);
$level = '';
if (strlen($this->_table)) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strlen($this->_table)) {
$tabs = $this->_getTableTabs();
$url_params['table'] = $this->_table;
$level = 'table';
} else if (strlen($this->_db)) {
} else if ($pmaString->strlen($this->_db)) {
$tabs = $this->_getDbTabs();
$level = 'db';
} else {
@ -146,8 +148,14 @@ class PMA_Menu
$result = PMA_queryAsControlUser($sql_query, false);
if ($result) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
$tabName = substr($row['tab'], strpos($row['tab'], '_') + 1);
$tabName = $pmaString->substr(
$row['tab'],
$pmaString->strpos($row['tab'], '_') + 1
);
unset($allowedTabs[$tabName]);
}
}
@ -195,7 +203,10 @@ class PMA_Menu
__('Server')
);
if (strlen($this->_db)) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strlen($this->_db)) {
$retval .= $separator;
if (PMA_Util::showIcons('TabsMode')) {
$retval .= PMA_Util::getImage(
@ -213,7 +224,7 @@ class PMA_Menu
);
// if the table is being dropped, $_REQUEST['purge'] is set to '1'
// so do not display the table name in upper div
if (strlen($this->_table)
if ($pmaString->strlen($this->_table)
&& ! (isset($_REQUEST['purge']) && $_REQUEST['purge'] == '1')
) {
include './libraries/tbl_info.inc.php';
@ -241,7 +252,7 @@ class PMA_Menu
if (! empty($show_comment)
&& ! isset($GLOBALS['avoid_show_comment'])
) {
if (strstr($show_comment, '; InnoDB free')) {
if ($pmaString->strstr($show_comment, '; InnoDB free')) {
$show_comment = preg_replace(
'@; InnoDB free:.*?$@',
'',

View File

@ -501,7 +501,7 @@ class PMA_Message
*/
public function addMessage($message, $separator = ' ')
{
if (strlen($separator)) {
if ($GLOBALS['PMA_String']->strlen($separator)) {
$this->addedMessages[] = $separator;
}
@ -628,11 +628,13 @@ class PMA_Message
{
$message = $this->message;
if (0 === strlen($message)) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if (0 === $pmaString->strlen($message)) {
$string = $this->getString();
if (isset($GLOBALS[$string])) {
$message = $GLOBALS[$string];
} elseif (0 === strlen($string)) {
} elseif (0 === $pmaString->strlen($string)) {
$message = '';
} else {
$message = $string;

View File

@ -139,7 +139,11 @@ class PMA_PDF extends TCPDF
{
$pdfData = $this->getPDFData();
PMA_Response::getInstance()->disable();
PMA_downloadHeader($filename, 'application/pdf', strlen($pdfData));
PMA_downloadHeader(
$filename,
'application/pdf',
$GLOBALS['PMA_String']->strlen($pdfData)
);
echo $pdfData;
}
}

View File

@ -63,9 +63,12 @@ class PMA_RecentFavoriteTable
*/
private function __construct($type)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$this->_tableType = $type;
if (strlen($GLOBALS['cfg']['Server']['pmadb'])
&& strlen($GLOBALS['cfg']['Server'][$this->_tableType])
if ($pmaString->strlen($GLOBALS['cfg']['Server']['pmadb'])
&& $pmaString->strlen($GLOBALS['cfg']['Server'][$this->_tableType])
) {
$this->_pmaTable
= PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) . "."

View File

@ -317,7 +317,11 @@ class PMA_Response
$this->addJSON('_selflink', $this->getFooter()->getSelfUrl('unencoded'));
$this->addJSON('_displayMessage', $this->getHeader()->getMessage());
$errors = $this->_footer->getErrorMessages();
if (strlen($errors)) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strlen($errors)) {
$this->addJSON('_errors', $errors);
}
$promptPhpErrors = $GLOBALS['error_handler']->hasErrorsForPrompt();
@ -328,7 +332,7 @@ class PMA_Response
$query = '';
$maxChars = $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'];
if (isset($GLOBALS['sql_query'])
&& strlen($GLOBALS['sql_query']) < $maxChars
&& $pmaString->strlen($GLOBALS['sql_query']) < $maxChars
) {
$query = $GLOBALS['sql_query'];
}

View File

@ -53,7 +53,7 @@ class PMA_Scripts
$dynamic_scripts = "";
$scripts = array();
foreach ($files as $value) {
if (strpos($value['filename'], "?") !== false) {
if ($GLOBALS['PMA_String']->strpos($value['filename'], "?") !== false) {
$dynamic_scripts .= "<script type='text/javascript' src='js/"
. $value['filename'] . "'></script>";
continue;
@ -149,13 +149,16 @@ class PMA_Scripts
*/
private function _eventBlacklist($filename)
{
if ( strpos($filename, 'jquery') !== false
|| strpos($filename, 'codemirror') !== false
|| strpos($filename, 'messages.php') !== false
|| strpos($filename, 'ajax.js') !== false
|| strpos($filename, 'navigation.js') !== false
|| strpos($filename, 'get_image.js.php') !== false
|| strpos($filename, 'cross_framing_protection.js') !== false
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ( $pmaString->strpos($filename, 'jquery') !== false
|| $pmaString->strpos($filename, 'codemirror') !== false
|| $pmaString->strpos($filename, 'messages.php') !== false
|| $pmaString->strpos($filename, 'ajax.js') !== false
|| $pmaString->strpos($filename, 'navigation.js') !== false
|| $pmaString->strpos($filename, 'get_image.js.php') !== false
|| $pmaString->strpos($filename, 'cross_framing_protection.js') !== false
) {
return 0;
}
@ -204,7 +207,7 @@ class PMA_Scripts
$retval = array();
foreach ($this->_files as $file) {
//If filename contains a "?", continue.
if (strpos($file['filename'], "?") !== false) {
if ($GLOBALS['PMA_String']->strpos($file['filename'], "?") !== false) {
continue;
}

View File

@ -280,11 +280,14 @@ class PMA_ServerStatusData
// Variable to mark used sections
$categoryUsed = array();
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// sort vars into arrays
foreach ($server_status as $name => $value) {
$section_found = false;
foreach ($allocations as $filter => $section) {
if (strpos($name, $filter) !== false) {
if ($pmaString->strpos($name, $filter) !== false) {
$allocationMap[$name] = $section;
$categoryUsed[$section] = true;
$section_found = true;
@ -315,7 +318,7 @@ class PMA_ServerStatusData
// Set all class properties
$this->db_isLocal = false;
if (strtolower($GLOBALS['cfg']['Server']['host']) === 'localhost'
if ($pmaString->strtolower($GLOBALS['cfg']['Server']['host']) === 'localhost'
|| $GLOBALS['cfg']['Server']['host'] === '127.0.0.1'
|| $GLOBALS['cfg']['Server']['host'] === '::1'
) {

View File

@ -132,7 +132,10 @@ class PMA_StorageEngine
$name = 'engine', $id = null,
$selected = null, $offerUnavailableEngines = false
) {
$selected = strtolower($selected);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$selected = $pmaString->strtolower($selected);
$output = '<select name="' . $name . '"'
. (empty($id) ? '' : ' id="' . $id . '"') . '>' . "\n";
@ -151,7 +154,7 @@ class PMA_StorageEngine
$output .= ' <option value="' . htmlspecialchars($key) . '"'
. (empty($details['Comment'])
? '' : ' title="' . htmlspecialchars($details['Comment']) . '"')
. (strtolower($key) == $selected
. ($pmaString->strtolower($key) == $selected
|| (empty($selected) && $details['Support'] == 'DEFAULT')
? ' selected="selected"' : '')
. '>' . "\n"
@ -172,10 +175,14 @@ class PMA_StorageEngine
*/
static public function getEngine($engine)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$engine = str_replace('/', '', str_replace('.', '', $engine));
$filename = './libraries/engines/' . strtolower($engine) . '.lib.php';
$filename = './libraries/engines/'
. $pmaString->strtolower($engine) . '.lib.php';
if (file_exists($filename) && include_once $filename) {
switch(strtolower($engine)) {
switch($pmaString->strtolower($engine)) {
case 'bdb':
return new PMA_StorageEngine_Bdb($engine);
case 'berkeleydb':
@ -311,6 +318,9 @@ class PMA_StorageEngine
$mysql_vars = array();
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$sql_query = 'SHOW GLOBAL VARIABLES ' . $like . ';';
$res = $GLOBALS['dbi']->query($sql_query);
while ($row = $GLOBALS['dbi']->fetchAssoc($res)) {
@ -318,7 +328,7 @@ class PMA_StorageEngine
$mysql_vars[$row['Variable_name']]
= $variables[$row['Variable_name']];
} elseif (! $like
&& strpos(strtolower($row['Variable_name']), strtolower($this->engine)) !== 0
&& $pmaString->strpos($pmaString->strtolower($row['Variable_name']), $pmaString->strtolower($this->engine)) !== 0
) {
continue;
}

View File

@ -5,14 +5,19 @@
*
* @package PhpMyAdmin-String
*/
if (! defined('PHPMYADMIN')) {
exit;
}
require_once 'libraries/StringType.int.php';
require_once 'libraries/StringByte.int.php';
/**
* Specialized string class for phpMyAdmin.
* The SQL Parser code relies heavily on these functions.
*
* @package PhpMyAdmin-String
*/
class PMA_String
class PMA_String implements PMA_StringByte, PMA_StringType
{
/**
* @var PMA_StringType
@ -123,7 +128,20 @@ class PMA_String
}
/**
* Returns postion of $needle in $haystack or false if not found
* Returns number of substrings from string.
*
* @param string $string string to count
* @param int $start start of substring
*
* @return int number of substrings from the string
*/
public function substrCount($string, $start)
{
return $this->_byte->substrCount($string, $start);
}
/**
* Returns position of $needle in $haystack or false if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
@ -136,6 +154,98 @@ class PMA_String
return $this->_byte->strpos($haystack, $needle, $offset);
}
/**
* Returns position of $needle in $haystack - case insensitive - or false if
* not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param int $offset the search offset
*
* @return integer position of $needle in $haystack or false
*/
public function stripos($haystack, $needle, $offset = 0)
{
return $this->_byte->stripos($haystack, $needle, $offset);
}
/**
* Returns position of last $needle in $haystack or false if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param int $offset the search offset
*
* @return integer position of last $needle in $haystack or false
*/
public function strrpos($haystack, $needle, $offset = 0)
{
return $this->_byte->strrpos($haystack, $needle, $offset);
}
/**
* Returns position of last $needle in $haystack - case insensitive - or false
* if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param int $offset the search offset
*
* @return integer position of last $needle in $haystack or false
*/
public function strripos($haystack, $needle, $offset = 0)
{
return $this->_byte->strripos($haystack, $needle, $offset);
}
/**
* Returns part of $haystack string starting from and including the first
* occurrence of $needle to the end of $haystack or false if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param bool $before_needle the part before the needle
*
* @return string part of $haystack or false
*/
public function strstr($haystack, $needle, $before_needle = false)
{
return $this->_byte->strstr($haystack, $needle, $before_needle);
}
/**
* Returns part of $haystack string starting from and including the first
* occurrence of $needle to the end of $haystack - case insensitive - or false
* if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param bool $before_needle the part before the needle
*
* @return string part of $haystack or false
*
* @deprecated
* @see DON'T USE UNTIL HHVM IMPLEMENTS THIRD PARAMETER!
*/
public function stristr($haystack, $needle, $before_needle = false)
{
return $this->_byte->stristr($haystack, $needle, $before_needle);
}
/**
* Returns the portion of haystack which starts at the last occurrence or false
* if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
*
* @return integer position of $needle in $haystack or false
*/
public function strrchr($haystack, $needle)
{
return $this->_byte->strrchr($haystack, $needle);
}
/**
* Make a string lowercase
*
@ -148,6 +258,18 @@ class PMA_String
return $this->_byte->strtolower($string);
}
/**
* Make a string uppercase
*
* @param string $string the string being uppercased
*
* @return string the lower case string
*/
public function strtoupper($string)
{
return $this->_byte->strtoupper($string);
}
/**
* Get the ordinal value of a string
*
@ -160,6 +282,18 @@ class PMA_String
return $this->_byte->ord($string);
}
/**
* Get the character of an ASCII
*
* @param int $ascii the ASCII code for which character is required
*
* @return string the character
*/
public function chr($ascii)
{
return $this->_byte->chr($ascii);
}
/**
* Checks if a character is an alphanumeric one
*

View File

@ -3,7 +3,6 @@
* Defines a set of specialized string functions.
*
* @package PhpMyAdmin-String
* @todo May be move this into file of its own
*/
interface PMA_StringByte
{
@ -29,7 +28,17 @@ interface PMA_StringByte
public function substr($string, $start, $length = 2147483647);
/**
* Returns postion of $needle in $haystack or false if not found
* Returns number of substrings from string, works depending on current charset.
*
* @param string $string string to count
* @param int $start start of substring
*
* @return int number of substrings from the string
*/
public function substrCount($string, $start);
/**
* Returns position of $needle in $haystack or false if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
@ -39,6 +48,81 @@ interface PMA_StringByte
*/
public function strpos($haystack, $needle, $offset = 0);
/**
* Returns position of $needle in $haystack - case insensitive - or false if
* not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param int $offset the search offset
*
* @return integer position of $needle in $haystack or false
*/
public function stripos($haystack, $needle, $offset = 0);
/**
* Returns position of last $needle in $haystack or false if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param int $offset the search offset
*
* @return integer position of last $needle in $haystack or false
*/
public function strrpos($haystack, $needle, $offset = 0);
/**
* Returns position of last $needle in $haystack - case insensitive - or false
* if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param int $offset the search offset
*
* @return integer position of last $needle in $haystack or false
*/
public function strripos($haystack, $needle, $offset = 0);
/**
* Returns part of $haystack string starting from and including the first
* occurrence of $needle to the end of $haystack or false if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param bool $before_needle the part before the needle
*
* @return string part of $haystack or false
*/
public function strstr($haystack, $needle, $before_needle = false);
/**
* Returns part of $haystack string starting from and including the first
* occurrence of $needle to the end of $haystack - case insensitive - or false
* if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param bool $before_needle the part before the needle
*
* @return string part of $haystack or false
*
* @deprecated
* @see DON'T USE UNTIL HHVM IMPLEMENTS THIRD PARAMETER!
*/
public function stristr($haystack, $needle, $before_needle = false);
/**
* Returns the portion of haystack which starts at the last occurrence or false
* if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
*
* @return string portion of haystack which starts at the last occurrence or
* false
*/
public function strrchr($haystack, $needle);
/**
* Make a string lowercase
*
@ -48,6 +132,15 @@ interface PMA_StringByte
*/
public function strtolower($string);
/**
* Make a string uppercase
*
* @param string $string the string being uppercased
*
* @return string the lower case string
*/
public function strtoupper($string);
/**
* Get the ordinal value of a string
*
@ -56,5 +149,14 @@ interface PMA_StringByte
* @return string the ord value
*/
public function ord($string);
/**
* Get the character of an ASCII
*
* @param int $ascii the ASCII code for which character is required
*
* @return string the character
*/
public function chr($ascii);
}
?>

View File

@ -44,11 +44,32 @@ class PMA_StringMB implements PMA_StringByte
*/
public function substr($string, $start, $length = 2147483647)
{
return mb_substr($string, $start, $length);
$stringLength = $this->strlen($string);
if ($stringLength <= $start) {
return false;
}
if ($stringLength + $length < $start) {
return false;
}
return mb_substr($string, $start, $length, 'utf-8');
}
/**
* Returns postion of $needle in $haystack or false if not found
* Returns number of substrings from string.
*
* @param string $string string to count
* @param int $start start of substring
*
* @return int number of substrings from the string
*/
public function substrCount($string, $start)
{
return mb_substr_count($string, $start, 'utf-8');
}
/**
* Returns position of $needle in $haystack or false if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
@ -58,9 +79,160 @@ class PMA_StringMB implements PMA_StringByte
*/
public function strpos($haystack, $needle, $offset = 0)
{
if (null === $haystack) {
return false;
}
if (false === $needle) {
return false;
}
if (!is_string($needle) && is_numeric($needle)) {
$needle = (int)$needle;
$needle = $this->chr($needle);
}
return mb_strpos($haystack, $needle, $offset);
}
/**
* Returns position of $needle in $haystack - case insensitive - or false if
* not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param int $offset the search offset
*
* @return integer position of $needle in $haystack or false
*/
public function stripos($haystack, $needle, $offset = 0)
{
if (null === $haystack) {
return false;
}
if (false === $needle) {
return false;
}
if (!is_string($needle) && is_numeric($needle)) {
$needle = (int)$needle;
$needle = $this->chr($needle);
}
return mb_stripos($haystack, $needle, $offset);
}
/**
* Returns position of last $needle in $haystack or false if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param int $offset the search offset
*
* @return integer position of last $needle in $haystack or false
*/
public function strrpos($haystack, $needle, $offset = 0)
{
if (null === $haystack) {
return false;
}
if (false === $needle) {
return false;
}
if (!is_string($needle) && is_numeric($needle)) {
$needle = (int)$needle;
$needle = $this->chr($needle);
}
return mb_strrpos($haystack, $needle, $offset);
}
/**
* Returns position of last $needle in $haystack - case insensitive - or false
* if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param int $offset the search offset
*
* @return integer position of last $needle in $haystack or false
*/
public function strripos($haystack, $needle, $offset = 0)
{
if (null === $haystack) {
return false;
}
if (false === $needle) {
return false;
}
if (!is_string($needle) && is_numeric($needle)) {
$needle = (int)$needle;
$needle = $this->chr($needle);
}
return mb_strripos($haystack, $needle, $offset);
}
/**
* Returns part of $haystack string starting from and including the first
* occurrence of $needle to the end of $haystack or false if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param bool $before_needle the part before the needle
*
* @return string part of $haystack or false
*/
public function strstr($haystack, $needle, $before_needle = false)
{
if (!is_string($needle) && is_numeric($needle)) {
$needle = (int)$needle;
$needle = $this->chr($needle);
}
if (!is_string($haystack) || !is_string($needle) || null === $needle) {
return false;
}
return mb_strstr($haystack, $needle, $before_needle);
}
/**
* Returns part of $haystack string starting from and including the first
* occurrence of $needle to the end of $haystack - case insensitive - or false
* if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param bool $before_needle the part before the needle
*
* @return string part of $haystack or false
*/
public function stristr($haystack, $needle, $before_needle = false)
{
if (!is_string($needle) && is_numeric($needle)) {
$needle = (int)$needle;
$needle = $this->chr($needle);
}
if (!is_string($haystack) || !is_string($needle) || null === $needle) {
return false;
}
return mb_stristr($haystack, $needle, $before_needle);
}
/**
* Returns the portion of haystack which starts at the last occurrence or false
* if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
*
* @return string portion of haystack which starts at the last occurrence or
* false
*/
public function strrchr($haystack, $needle)
{
if (!is_string($needle) && is_numeric($needle)) {
$needle = (int)$needle;
$needle = $this->chr($needle);
}
if (!is_string($haystack) || !is_string($needle) || null === $needle) {
return false;
}
return mb_strrchr($haystack, $needle);
}
/**
* Make a string lowercase
*
@ -73,6 +245,18 @@ class PMA_StringMB implements PMA_StringByte
return mb_strtolower($string);
}
/**
* Make a string uppercase
*
* @param string $string the string being uppercased
*
* @return string the upper case string
*/
public function strtoupper($string)
{
return mb_strtoupper($string);
}
/**
* Get the ordinal value of a multibyte string
* (Adapted from http://www.php.net/manual/en/function.ord.php#72463)
@ -83,10 +267,31 @@ class PMA_StringMB implements PMA_StringByte
*/
public function ord($string)
{
if (false === $string || null === $string || '' === $string) {
return 0;
}
$str = mb_convert_encoding($string, "UCS-4BE", "UTF-8");
$substr = mb_substr($str, 0, 1, "UCS-4BE");
$val = unpack("N", $substr);
return $val[1];
}
/**
* Get the multibyte character of an ASCII
* (from http://fr2.php.net/manual/en/function.chr.php#69082)
*
* @param int $ascii the ASCII code for which character is required
*
* @return string the multibyte character
*/
public function chr($ascii)
{
return mb_convert_encoding(
pack("N", $ascii),
mb_internal_encoding(),
'UCS-4BE'
);
}
}
?>

View File

@ -46,6 +46,19 @@ class PMA_StringNative implements PMA_StringByte
return substr($string, $start, $length);
}
/**
* Returns number of substrings from string.
*
* @param string $string string to count
* @param int $start start of substring
*
* @return int number of substrings from the string
*/
public function substrCount($string, $start)
{
return substr_count($string, $start);
}
/**
* Returns postion of $needle in $haystack or false if not found
*
@ -60,6 +73,106 @@ class PMA_StringNative implements PMA_StringByte
return strpos($haystack, $needle, $offset);
}
/**
* Returns position of $needle in $haystack - case insensitive - or false if
* not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param int $offset the search offset
*
* @return integer position of $needle in $haystack or false
*/
public function stripos($haystack, $needle, $offset = 0)
{
if (('' === $haystack || false === $haystack)
&& $offset >= $this->strlen($haystack)
) {
return false;
}
return stripos($haystack, $needle, $offset);
}
/**
* Returns position of last $needle in $haystack or false if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param int $offset the search offset
*
* @return integer position of last $needle in $haystack or false
*/
public function strrpos($haystack, $needle, $offset = 0)
{
return strrpos($haystack, $needle, $offset);
}
/**
* Returns position of last $needle in $haystack - case insensitive - or false
* if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param int $offset the search offset
*
* @return integer position of last $needle in $haystack or false
*/
public function strripos($haystack, $needle, $offset = 0)
{
if (('' === $haystack || false === $haystack)
&& $offset >= $this->strlen($haystack)
) {
return false;
}
return strripos($haystack, $needle, $offset);
}
/**
* Returns part of $haystack string starting from and including the first
* occurrence of $needle to the end of $haystack or false if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param bool $before_needle the part before the needle
*
* @return string part of $haystack or false
*/
public function strstr($haystack, $needle, $before_needle = false)
{
return strstr($haystack, $needle, $before_needle);
}
/**
* Returns part of $haystack string starting from and including the first
* occurrence of $needle to the end of $haystack - case insensitive - or false
* if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param bool $before_needle the part before the needle
*
* @return string part of $haystack or false
*/
public function stristr($haystack, $needle, $before_needle = false)
{
return stristr($haystack, $needle, $before_needle);
}
/**
* Returns the portion of haystack which starts at the last occurrence or false
* if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
*
* @return string portion of haystack which starts at the last occurrence or
* false
*/
public function strrchr($haystack, $needle)
{
return strrchr($haystack, $needle);
}
/**
* Make a string lowercase
*
@ -72,6 +185,18 @@ class PMA_StringNative implements PMA_StringByte
return strtolower($string);
}
/**
* Make a string uppercase
*
* @param string $string the string being uppercased
*
* @return string the upper case string
*/
public function strtoupper($string)
{
return strtoupper($string);
}
/**
* Get the ordinal value of a string
*
@ -83,5 +208,17 @@ class PMA_StringNative implements PMA_StringByte
{
return ord($string);
}
/**
* Get the character of an ASCII
*
* @param int $ascii the ASCII code for which character is required
*
* @return string the character
*/
public function chr($ascii)
{
return chr($ascii);
}
};
?>

View File

@ -3,7 +3,6 @@
* Defines a set of specialized string functions.
*
* @package PhpMyAdmin-String
* @todo May be move this into file of its own
*/
interface PMA_StringType
{

View File

@ -260,9 +260,15 @@ class PMA_Table
WHERE TABLE_SCHEMA = '" . PMA_Util::sqlAddSlashes($db) . "'
AND TABLE_NAME = '" . PMA_Util::sqlAddSlashes($table) . "'"
);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
foreach ($results as $result) {
$analyzed_sql[0]['create_table_fields'][$result['COLUMN_NAME']]
= array('type' => strtoupper($result['DATA_TYPE']));
= array(
'type' => $pmaString->strtoupper($result['DATA_TYPE'])
);
}
} else {
$show_create_table = $GLOBALS['dbi']->fetchValue(
@ -333,7 +339,10 @@ class PMA_Table
}
// any of known merge engines?
return in_array(strtoupper($engine), array('MERGE', 'MRG_MYISAM'));
return in_array(
$GLOBALS['PMA_String']->strtoupper($engine),
array('MERGE', 'MRG_MYISAM')
);
}
/**
@ -422,7 +431,13 @@ class PMA_Table
$default_type = 'USER_DEFINED', $default_value = '', $extra = '',
$comment = '', &$field_primary = null, $move_to = ''
) {
$is_timestamp = strpos(strtoupper($type), 'TIMESTAMP') !== false;
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$is_timestamp = $pmaString->strpos(
$pmaString->strtoupper($type),
'TIMESTAMP'
) !== false;
$query = PMA_Util::backquote($name) . ' ' . $type;
@ -432,13 +447,9 @@ class PMA_Table
// MySQL permits a non-standard syntax for FLOAT and DOUBLE,
// see http://dev.mysql.com/doc/refman/5.5/en/floating-point-types.html
//
if ($length != ''
&& ! preg_match(
'@^(DATE|TINYBLOB|TINYTEXT|BLOB|TEXT|'
. 'MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT|SERIAL|BOOLEAN|UUID)$@i',
$type
)
) {
$pattern = '@^(DATE|TINYBLOB|TINYTEXT|BLOB|TEXT|'
. 'MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT|SERIAL|BOOLEAN|UUID)$@i';
if ($length != '' && ! preg_match($pattern, $type)) {
$query .= '(' . $length . ')';
}
@ -810,9 +821,12 @@ class PMA_Table
return false;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$source = PMA_Util::backquote($source_db)
. '.' . PMA_Util::backquote($source_table);
if (! isset($target_db) || ! strlen($target_db)) {
if (! isset($target_db) || ! $pmaString->strlen($target_db)) {
$target_db = $source_db;
}
@ -874,7 +888,7 @@ class PMA_Table
);
// ANSI_QUOTES might be a subset of sql_mode, for example
// REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI
if (false !== strpos($server_sql_mode, 'ANSI_QUOTES')) {
if (false !== $pmaString->strpos($server_sql_mode, 'ANSI_QUOTES')) {
$table_delimiter = 'quote_double';
} else {
$table_delimiter = 'quote_backtick';
@ -964,8 +978,9 @@ class PMA_Table
$cnt = $parsed_sql['len'] - 1;
for ($j = $i; $j < $cnt; $j++) {
$dataUpper = $pmaString->strtoupper($parsed_sql[$j]['data']);
if ($parsed_sql[$j]['type'] == 'alpha_reservedWord'
&& strtoupper($parsed_sql[$j]['data']) == 'CONSTRAINT'
&& $dataUpper == 'CONSTRAINT'
) {
if ($parsed_sql[$j+1]['type'] == $table_delimiter) {
$parsed_sql[$j+1]['data'] = '';
@ -1000,8 +1015,9 @@ class PMA_Table
$cnt = $parsed_sql['len'] - 1;
for ($j = $i; $j < $cnt; $j++) {
$dataUpper = $pmaString->strtoupper($parsed_sql[$j]['data']);
if ($parsed_sql[$j]['type'] == 'alpha_reservedWord'
&& strtoupper($parsed_sql[$j]['data']) == 'CONSTRAINT'
&& $dataUpper == 'CONSTRAINT'
) {
if ($parsed_sql[$j+1]['type'] == $table_delimiter) {
$parsed_sql[$j+1]['data'] = '';
@ -1282,7 +1298,7 @@ class PMA_Table
return false;
}
if (! strlen($table_name)) {
if (! $GLOBALS['PMA_String']->strlen($table_name)) {
// zero length
return false;
}
@ -1593,13 +1609,18 @@ class PMA_Table
protected function loadUiPrefs()
{
$server_id = $GLOBALS['server'];
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// set session variable if it's still undefined
if (! isset($_SESSION['tmpval']['table_uiprefs'][$server_id][$this->db_name][$this->name])) {
// check whether we can get from pmadb
$_SESSION['tmpval']['table_uiprefs'][$server_id][$this->db_name]
[$this->name]
= (strlen($GLOBALS['cfg']['Server']['pmadb'])
&& strlen($GLOBALS['cfg']['Server']['table_uiprefs']))
= ($pmaString->strlen($GLOBALS['cfg']['Server']['pmadb'])
&& $pmaString->strlen($GLOBALS['cfg']['Server']['table_uiprefs'])
)
? $this->getUiPrefsFromDb()
: array();
}
@ -1637,12 +1658,16 @@ class PMA_Table
$colname = str_replace('`', '', $colname);
//get the available column name without backquoting
$avail_columns = $this->getColumns(false);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
foreach ($avail_columns as $each_col) {
// check if $each_col ends with $colname
if (substr_compare(
$each_col,
$colname,
strlen($each_col) - strlen($colname)
$pmaString->strlen($each_col) - $pmaString->strlen($colname)
) === 0) {
return $this->uiprefs[$property];
}
@ -1727,9 +1752,13 @@ class PMA_Table
}
// save the value
$this->uiprefs[$property] = $value;
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// check if pmadb is set
if (strlen($GLOBALS['cfg']['Server']['pmadb'])
&& strlen($GLOBALS['cfg']['Server']['table_uiprefs'])
if ($pmaString->strlen($GLOBALS['cfg']['Server']['pmadb'])
&& $pmaString->strlen($GLOBALS['cfg']['Server']['table_uiprefs'])
) {
return $this->saveUiprefsToDb();
}
@ -1750,9 +1779,13 @@ class PMA_Table
}
if (isset($this->uiprefs[$property])) {
unset($this->uiprefs[$property]);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// check if pmadb is set
if (strlen($GLOBALS['cfg']['Server']['pmadb'])
&& strlen($GLOBALS['cfg']['Server']['table_uiprefs'])
if ($pmaString->strlen($GLOBALS['cfg']['Server']['pmadb'])
&& $pmaString->strlen($GLOBALS['cfg']['Server']['table_uiprefs'])
) {
return $this->saveUiprefsToDb();
}

View File

@ -151,7 +151,7 @@ class PMA_TableSearch
}
$type = preg_replace('@ZEROFILL@i', '', $type);
$type = preg_replace('@UNSIGNED@i', '', $type);
$type = strtolower($type);
$type = $GLOBALS['PMA_String']->strtolower($type);
}
if (empty($type)) {
$type = '&nbsp;';
@ -316,7 +316,7 @@ EOT;
$html_output = '';
$value = explode(
', ',
str_replace("'", '', substr($column_type, 5, -1))
str_replace("'", '', $GLOBALS['PMA_String']->substr($column_type, 5, -1))
);
$cnt_value = count($value);
@ -406,13 +406,16 @@ EOT;
// other cases
$the_class = 'textfield';
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($column_type == 'date') {
$the_class .= ' datefield';
} elseif ($column_type == 'datetime'
|| substr($column_type, 0, 9) == 'timestamp'
|| $pmaString->substr($column_type, 0, 9) == 'timestamp'
) {
$the_class .= ' datetimefield';
} elseif (substr($column_type, 0, 3) == 'bit') {
} elseif ($pmaString->substr($column_type, 0, 3) == 'bit') {
$the_class .= ' bit';
}
@ -560,7 +563,7 @@ EOT;
// strings to numbers and numbers to strings as necessary
// during the comparison
if (preg_match('@char|binary|blob|text|set|date|time|year@i', $types)
|| strpos(' ' . $func_type, 'LIKE')
|| $GLOBALS['PMA_String']->strpos(' ' . $func_type, 'LIKE')
) {
$quot = '\'';
} else {

View File

@ -166,7 +166,7 @@ class PMA_Tracker
*/
static protected function getTableName($string)
{
if (strstr($string, '.')) {
if ($GLOBALS['PMA_String']->strstr($string, '.')) {
$temp = explode('.', $string);
$tablename = $temp[1];
} else {
@ -610,16 +610,21 @@ class PMA_Tracker
$ddlog = array();
$i = 0;
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Iterate tracked data definition statements
// For each log entry we want to get date, username and statement
foreach ($log_schema_entries as $log_entry) {
if (trim($log_entry) != '') {
$date = substr($log_entry, 0, 19);
$username = substr($log_entry, 20, strpos($log_entry, "\n") - 20);
$date = $pmaString->substr($log_entry, 0, 19);
$username = $pmaString->substr(
$log_entry, 20, $pmaString->strpos($log_entry, "\n") - 20
);
if ($i == 0) {
$ddl_date_from = $date;
}
$statement = rtrim(strstr($log_entry, "\n"));
$statement = rtrim($pmaString->strstr($log_entry, "\n"));
$ddlog[] = array( 'date' => $date,
'username'=> $username,
@ -640,12 +645,14 @@ class PMA_Tracker
// For each log entry we want to get date, username and statement
foreach ($log_data_entries as $log_entry) {
if (trim($log_entry) != '') {
$date = substr($log_entry, 0, 19);
$username = substr($log_entry, 20, strpos($log_entry, "\n") - 20);
$date = $pmaString->substr($log_entry, 0, 19);
$username = $pmaString->substr(
$log_entry, 20, $pmaString->strpos($log_entry, "\n") - 20
);
if ($i == 0) {
$dml_date_from = $date;
}
$statement = rtrim(strstr($log_entry, "\n"));
$statement = rtrim($pmaString->strstr($log_entry, "\n"));
$dmlog[] = array( 'date' => $date,
'username' => $username,
@ -694,6 +701,8 @@ class PMA_Tracker
*/
static public function parseQuery($query)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Usage of PMA_SQP does not work here
//
@ -709,11 +718,11 @@ class PMA_Tracker
$tokens = explode(" ", $query);
foreach ($tokens as $key => $value) {
$tokens[$key] = strtoupper($value);
$tokens[$key] = $pmaString->strtoupper($value);
}
// Parse USE statement, need it for SQL dump imports
if (substr($query, 0, 4) == 'USE ') {
if ($pmaString->substr($query, 0, 4) == 'USE ') {
$prefix = explode('USE ', $query);
$GLOBALS['db'] = self::getTableName($prefix[1]);
}
@ -734,7 +743,7 @@ class PMA_Tracker
$index = array_search('VIEW', $tokens);
$result['tablename'] = strtolower(
$result['tablename'] = $pmaString->strtolower(
self::getTableName($tokens[$index + 1])
);
}
@ -749,19 +758,19 @@ class PMA_Tracker
$index = array_search('VIEW', $tokens);
$result['tablename'] = strtolower(
$result['tablename'] = $pmaString->strtolower(
self::getTableName($tokens[$index + 1])
);
}
// Parse DROP VIEW statement
if (! isset($result['identifier'])
&& substr($query, 0, 10) == 'DROP VIEW '
&& $pmaString->substr($query, 0, 10) == 'DROP VIEW '
) {
$result['identifier'] = 'DROP VIEW';
$prefix = explode('DROP VIEW ', $query);
$str = strstr($prefix[1], 'IF EXISTS');
$str = $pmaString->strstr($prefix[1], 'IF EXISTS');
if ($str == false ) {
$str = $prefix[1];
@ -771,7 +780,7 @@ class PMA_Tracker
// Parse CREATE DATABASE statement
if (! isset($result['identifier'])
&& substr($query, 0, 15) == 'CREATE DATABASE'
&& $pmaString->substr($query, 0, 15) == 'CREATE DATABASE'
) {
$result['identifier'] = 'CREATE DATABASE';
$str = str_replace('CREATE DATABASE', '', $query);
@ -785,7 +794,7 @@ class PMA_Tracker
// Parse ALTER DATABASE statement
if (! isset($result['identifier'])
&& substr($query, 0, 14) == 'ALTER DATABASE'
&& $pmaString->substr($query, 0, 14) == 'ALTER DATABASE'
) {
$result['identifier'] = 'ALTER DATABASE';
$result['tablename'] = '';
@ -793,7 +802,7 @@ class PMA_Tracker
// Parse DROP DATABASE statement
if (! isset($result['identifier'])
&& substr($query, 0, 13) == 'DROP DATABASE'
&& $pmaString->substr($query, 0, 13) == 'DROP DATABASE'
) {
$result['identifier'] = 'DROP DATABASE';
$str = str_replace('DROP DATABASE', '', $query);
@ -804,7 +813,7 @@ class PMA_Tracker
// Parse CREATE TABLE statement
if (! isset($result['identifier'])
&& substr($query, 0, 12) == 'CREATE TABLE'
&& $pmaString->substr($query, 0, 12) == 'CREATE TABLE'
) {
$result['identifier'] = 'CREATE TABLE';
$query = str_replace('IF NOT EXISTS', '', $query);
@ -815,7 +824,7 @@ class PMA_Tracker
// Parse ALTER TABLE statement
if (! isset($result['identifier'])
&& substr($query, 0, 12) == 'ALTER TABLE '
&& $pmaString->substr($query, 0, 12) == 'ALTER TABLE '
) {
$result['identifier'] = 'ALTER TABLE';
@ -826,12 +835,12 @@ class PMA_Tracker
// Parse DROP TABLE statement
if (! isset($result['identifier'])
&& substr($query, 0, 11) == 'DROP TABLE '
&& $pmaString->substr($query, 0, 11) == 'DROP TABLE '
) {
$result['identifier'] = 'DROP TABLE';
$prefix = explode('DROP TABLE ', $query);
$str = strstr($prefix[1], 'IF EXISTS');
$str = $pmaString->strstr($prefix[1], 'IF EXISTS');
if ($str == false ) {
$str = $prefix[1];
@ -841,9 +850,9 @@ class PMA_Tracker
// Parse CREATE INDEX statement
if (! isset($result['identifier'])
&& (substr($query, 0, 12) == 'CREATE INDEX'
|| substr($query, 0, 19) == 'CREATE UNIQUE INDEX'
|| substr($query, 0, 20) == 'CREATE SPATIAL INDEX')
&& ($pmaString->substr($query, 0, 12) == 'CREATE INDEX'
|| $pmaString->substr($query, 0, 19) == 'CREATE UNIQUE INDEX'
|| $pmaString->substr($query, 0, 20) == 'CREATE SPATIAL INDEX')
) {
$result['identifier'] = 'CREATE INDEX';
$prefix = explode('ON ', $query);
@ -853,7 +862,7 @@ class PMA_Tracker
// Parse DROP INDEX statement
if (! isset($result['identifier'])
&& substr($query, 0, 10) == 'DROP INDEX'
&& $pmaString->substr($query, 0, 10) == 'DROP INDEX'
) {
$result['identifier'] = 'DROP INDEX';
$prefix = explode('ON ', $query);
@ -862,7 +871,7 @@ class PMA_Tracker
// Parse RENAME TABLE statement
if (! isset($result['identifier'])
&& substr($query, 0, 13) == 'RENAME TABLE '
&& $pmaString->substr($query, 0, 13) == 'RENAME TABLE '
) {
$result['identifier'] = 'RENAME TABLE';
$prefix = explode('RENAME TABLE ', $query);
@ -880,7 +889,7 @@ class PMA_Tracker
}
// Parse UPDATE statement
if (! isset($result['identifier'])
&& substr($query, 0, 6) == 'UPDATE'
&& $pmaString->substr($query, 0, 6) == 'UPDATE'
) {
$result['identifier'] = 'UPDATE';
$prefix = explode('UPDATE ', $query);
@ -890,7 +899,7 @@ class PMA_Tracker
// Parse INSERT INTO statement
if (! isset($result['identifier'])
&& substr($query, 0, 11) == 'INSERT INTO'
&& $pmaString->substr($query, 0, 11) == 'INSERT INTO'
) {
$result['identifier'] = 'INSERT';
$prefix = explode('INSERT INTO', $query);
@ -900,7 +909,7 @@ class PMA_Tracker
// Parse DELETE statement
if (! isset($result['identifier'])
&& substr($query, 0, 6) == 'DELETE'
&& $pmaString->substr($query, 0, 6) == 'DELETE'
) {
$result['identifier'] = 'DELETE';
$prefix = explode('FROM ', $query);
@ -910,7 +919,7 @@ class PMA_Tracker
// Parse TRUNCATE statement
if (! isset($result['identifier'])
&& substr($query, 0, 8) == 'TRUNCATE'
&& $pmaString->substr($query, 0, 8) == 'TRUNCATE'
) {
$result['identifier'] = 'TRUNCATE';
$prefix = explode('TRUNCATE', $query);
@ -932,12 +941,15 @@ class PMA_Tracker
*/
static public function handleQuery($query)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// If query is marked as untouchable, leave
if (strstr($query, "/*NOTRACK*/")) {
if ($pmaString->strstr($query, "/*NOTRACK*/")) {
return;
}
if (! (substr($query, -1) == ';')) {
if (! ($pmaString->substr($query, -1) == ';')) {
$query = $query . ";\n";
}
// Get some information about query

View File

@ -314,7 +314,7 @@ class PMA_Types_MySQL extends PMA_Types
*/
public function getTypeDescription($type)
{
$type = strtoupper($type);
$type = $GLOBALS['PMA_String']->strtoupper($type);
switch ($type) {
case 'TINYINT':
return __('A 1-byte integer, signed range is -128 to 127, unsigned range is 0 to 255');
@ -409,7 +409,7 @@ class PMA_Types_MySQL extends PMA_Types
*/
public function getTypeClass($type)
{
$type = strtoupper($type);
$type = $GLOBALS['PMA_String']->strtoupper($type);
switch ($type) {
case 'TINYINT':
case 'SMALLINT':
@ -769,7 +769,7 @@ class PMA_Types_Drizzle extends PMA_Types
*/
public function getTypeDescription($type)
{
$type = strtoupper($type);
$type = $GLOBALS['PMA_String']->strtoupper($type);
switch ($type) {
case 'INTEGER':
return __('A 4-byte integer, range is -2,147,483,648 to 2,147,483,647');
@ -818,7 +818,7 @@ class PMA_Types_Drizzle extends PMA_Types
*/
public function getTypeClass($type)
{
$type = strtoupper($type);
$type = $GLOBALS['PMA_String']->strtoupper($type);
switch ($type) {
case 'INTEGER':
case 'BIGINT':

View File

@ -364,11 +364,14 @@ class PMA_Util
$quotes[] = $quote;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
foreach ($quotes as $quote) {
if (substr($quoted_string, 0, 1) === $quote
&& substr($quoted_string, -1, 1) === $quote
if ($pmaString->substr($quoted_string, 0, 1) === $quote
&& $pmaString->substr($quoted_string, -1, 1) === $quote
) {
$unquoted_string = substr($quoted_string, 1, -1);
$unquoted_string = $pmaString->substr($quoted_string, 1, -1);
// replace escaped quotes
$unquoted_string = str_replace(
$quote . $quote,
@ -398,10 +401,14 @@ class PMA_Util
public static function formatSql($sql_query, $truncate = false)
{
global $cfg;
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($truncate
&& strlen($sql_query) > $cfg['MaxCharactersInDisplayedSQL']
&& $pmaString->strlen($sql_query) > $cfg['MaxCharactersInDisplayedSQL']
) {
$sql_query = $GLOBALS['PMA_String']->substr(
$sql_query = $pmaString->substr(
$sql_query,
0,
$cfg['MaxCharactersInDisplayedSQL']
@ -442,7 +449,7 @@ class PMA_Util
public static function getMySQLDocuURL($link, $anchor = '')
{
// Fixup for newly used names:
$link = str_replace('_', '-', strtolower($link));
$link = str_replace('_', '-', $GLOBALS['PMA_String']->strtolower($link));
if (empty($link)) {
$link = 'index';
@ -626,10 +633,14 @@ class PMA_Util
$error_msg .= "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
$error_msg .= ' <div class="error"><h1>' . __('Error')
. '</h1>' . "\n";
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// if the config password is wrong, or the MySQL server does not
// respond, do not show the query that would reveal the
// username/password
if (! empty($the_query) && ! strstr($the_query, 'connect')) {
if (! empty($the_query) && ! $pmaString->strstr($the_query, 'connect')) {
// --- Added to solve bug #641765
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
$error_msg .= PMA_SQP_getErrorString() . "\n";
@ -638,7 +649,8 @@ class PMA_Util
// ---
// modified to show the help on sql errors
$error_msg .= '<p><strong>' . __('SQL query:') . '</strong>' . "\n";
if (strstr(strtolower($formatted_sql), 'select')) {
if ($pmaString->strstr($pmaString->strtolower($formatted_sql), 'select')
) {
// please show me help to the error on select
$error_msg .= self::showMySQLDocu('SELECT');
}
@ -647,12 +659,12 @@ class PMA_Util
'sql_query' => $the_query,
'show_query' => 1,
);
if (strlen($table)) {
if ($pmaString->strlen($table)) {
$_url_params['db'] = $db;
$_url_params['table'] = $table;
$doedit_goto = '<a href="tbl_sql.php'
. PMA_URL_getCommon($_url_params) . '">';
} elseif (strlen($db)) {
} elseif ($pmaString->strlen($db)) {
$_url_params['db'] = $db;
$doedit_goto = '<a href="db_sql.php'
. PMA_URL_getCommon($_url_params) . '">';
@ -706,38 +718,38 @@ class PMA_Util
$_SESSION['Import_message']['message'] = $error_msg;
if ($exit) {
/**
* If in an Ajax request
* - avoid displaying a Back link
* - use PMA_Response() to transmit the message and exit
*/
if (isset($GLOBALS['is_ajax_request'])
&& $GLOBALS['is_ajax_request'] == true
) {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', $error_msg);
exit;
}
if (! empty($back_url)) {
if (strstr($back_url, '?')) {
$back_url .= '&amp;no_history=true';
} else {
$back_url .= '?no_history=true';
}
$_SESSION['Import_message']['go_back_url'] = $back_url;
$error_msg .= '<fieldset class="tblFooters">'
. '[ <a href="' . $back_url . '">' . __('Back') . '</a> ]'
. '</fieldset>' . "\n\n";
}
echo $error_msg;
exit;
} else {
if (!$exit) {
return $error_msg;
}
/**
* If in an Ajax request
* - avoid displaying a Back link
* - use PMA_Response() to transmit the message and exit
*/
if (isset($GLOBALS['is_ajax_request'])
&& $GLOBALS['is_ajax_request'] == true
) {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', $error_msg);
exit;
}
if (! empty($back_url)) {
if ($pmaString->strstr($back_url, '?')) {
$back_url .= '&amp;no_history=true';
} else {
$back_url .= '?no_history=true';
}
$_SESSION['Import_message']['go_back_url'] = $back_url;
$error_msg .= '<fieldset class="tblFooters">'
. '[ <a href="' . $back_url . '">' . __('Back') . '</a> ]'
. '</fieldset>' . "\n\n";
}
echo $error_msg;
exit;
} // end of the 'mysqlDie()' function
/**
@ -804,7 +816,7 @@ class PMA_Util
// in $group we save the reference to the place in $table_groups
// where to store the table info
if ($GLOBALS['cfg']['NavigationTreeEnableGrouping']
&& $sep && strstr($table_name, $sep)
&& $sep && $GLOBALS['PMA_String']->strstr($table_name, $sep)
) {
$parts = explode($sep, $table_name);
@ -888,15 +900,19 @@ class PMA_Util
return $a_name;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if (! $do_it) {
global $PMA_SQPdata_forbidden_word;
if (! in_array(strtoupper($a_name), $PMA_SQPdata_forbidden_word)) {
$eltNameUpper = $pmaString->strtoupper($a_name);
if (!in_array($eltNameUpper, $PMA_SQPdata_forbidden_word)) {
return $a_name;
}
}
// '0' is also empty for php :-(
if (strlen($a_name) && $a_name !== '*') {
if ($pmaString->strlen($a_name) && $a_name !== '*') {
return '`' . str_replace('`', '``', $a_name) . '`';
} else {
return $a_name;
@ -934,9 +950,13 @@ class PMA_Util
return $a_name;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if (! $do_it) {
global $PMA_SQPdata_forbidden_word;
if (! in_array(strtoupper($a_name), $PMA_SQPdata_forbidden_word)) {
$eltNameUpper = $pmaString->strtoupper($a_name);
if (!in_array($eltNameUpper, $PMA_SQPdata_forbidden_word)) {
return $a_name;
}
}
@ -952,7 +972,7 @@ class PMA_Util
}
// '0' is also empty for php :-(
if (strlen($a_name) && $a_name !== '*') {
if ($pmaString->strlen($a_name) && $a_name !== '*') {
return $quote . $a_name . $quote;
} else {
return $a_name;
@ -1057,14 +1077,21 @@ class PMA_Util
$query_too_big = false;
if (strlen($query_base) > $cfg['MaxCharactersInDisplayedSQL']) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strlen($query_base) > $cfg['MaxCharactersInDisplayedSQL']
) {
// when the query is large (for example an INSERT of binary
// data), the parser chokes; so avoid parsing the query
$query_too_big = true;
$shortened_query_base = nl2br(
htmlspecialchars(
substr($sql_query, 0, $cfg['MaxCharactersInDisplayedSQL'])
. '[...]'
$pmaString->substr(
$sql_query,
0,
$cfg['MaxCharactersInDisplayedSQL']
) . '[...]'
)
);
} elseif (! empty($GLOBALS['parsed_sql'])
@ -1134,9 +1161,9 @@ class PMA_Util
if (! isset($GLOBALS['db'])) {
$GLOBALS['db'] = '';
}
if (strlen($GLOBALS['db'])) {
if ($pmaString->strlen($GLOBALS['db'])) {
$url_params['db'] = $GLOBALS['db'];
if (strlen($GLOBALS['table'])) {
if ($pmaString->strlen($GLOBALS['table'])) {
$url_params['table'] = $GLOBALS['table'];
$edit_link = 'tbl_sql.php';
} else {
@ -1159,7 +1186,7 @@ class PMA_Util
} elseif (preg_match(
'@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $sql_query
)) {
$explain_params['sql_query'] = substr($sql_query, 8);
$explain_params['sql_query'] = $pmaString->substr($sql_query, 8);
$_message = __('Skip Explain SQL');
}
if (isset($explain_params['sql_query']) && isset($_message)) {
@ -1522,12 +1549,18 @@ class PMA_Util
{
$return_value = -1;
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if (preg_match('/^[0-9]+GB$/', $formatted_size)) {
$return_value = substr($formatted_size, 0, -2) * self::pow(1024, 3);
$return_value = $pmaString->substr($formatted_size, 0, -2)
* self::pow(1024, 3);
} elseif (preg_match('/^[0-9]+MB$/', $formatted_size)) {
$return_value = substr($formatted_size, 0, -2) * self::pow(1024, 2);
$return_value = $pmaString->substr($formatted_size, 0, -2)
* self::pow(1024, 2);
} elseif (preg_match('/^[0-9]+K$/', $formatted_size)) {
$return_value = substr($formatted_size, 0, -1) * self::pow(1024, 1);
$return_value = $pmaString->substr($formatted_size, 0, -1)
* self::pow(1024, 1);
}
return $return_value;
}// end of the 'extractValueFromFormattedSize' function
@ -1765,7 +1798,10 @@ class PMA_Util
$url, $message, $tag_params = array(),
$new_form = true, $strip_img = false, $target = ''
) {
$url_length = strlen($url);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$url_length = $pmaString->strlen($url);
// with this we should be able to catch case of image upload
// into a (MEDIUM) BLOB; not worth generating even a form for these
if ($url_length > $GLOBALS['cfg']['LinkLengthLimit'] * 100) {
@ -1788,7 +1824,7 @@ class PMA_Util
$tag_params_strings = array();
foreach ($tag_params as $par_name => $par_value) {
// htmlspecialchars() only on non javascript
$par_value = substr($par_name, 0, 2) == 'on'
$par_value = $pmaString->substr($par_name, 0, 2) == 'on'
? $par_value
: htmlspecialchars($par_value);
$tag_params_strings[] = $par_name . '="' . $par_value . '"';
@ -1815,7 +1851,7 @@ class PMA_Util
$query_parts = self::splitURLQuery($url);
foreach ($query_parts as $query_pair) {
list($eachvar, $eachval) = explode('=', $query_pair);
if (strlen($eachval) > $suhosin_get_MaxValueLength) {
if ($pmaString->strlen($eachval) > $suhosin_get_MaxValueLength) {
$in_suhosin_limits = false;
break;
}
@ -1958,7 +1994,10 @@ class PMA_Util
$format_string = '';
$charbuff = false;
for ($i = 0, $str_len = strlen($string); $i < $str_len; $i++) {
for ($i = 0, $str_len = $GLOBALS['PMA_String']->strlen($string);
$i < $str_len;
$i++
) {
$char = $string{$i};
$append = false;
@ -2061,6 +2100,9 @@ class PMA_Util
$nonprimary_condition_array = array();
$condition_array = array();
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
for ($i = 0; $i < $fields_cnt; ++$i) {
$con_val = '';
@ -2068,7 +2110,7 @@ class PMA_Util
$meta = $fields_meta[$i];
// do not use a column alias in a condition
if (! isset($meta->orgname) || ! strlen($meta->orgname)) {
if (! isset($meta->orgname) || ! $pmaString->strlen($meta->orgname)) {
$meta->orgname = $meta->name;
if (isset($GLOBALS['analyzed_sql'][0]['select_expr'])
@ -2136,7 +2178,7 @@ class PMA_Util
// hexify only if this is a true not empty BLOB or a BINARY
// do not waste memory building a too big condition
if (strlen($row[$i]) < 1000) {
if ($pmaString->strlen($row[$i]) < 1000) {
// use a CAST if possible, to avoid problems
// if the field contains wildcard characters % or _
$con_val = '= CAST(0x' . bin2hex($row[$i]) . ' AS BINARY)';
@ -2144,7 +2186,7 @@ class PMA_Util
// when this blob is the only field present
// try settling with length comparison
$condition = ' CHAR_LENGTH(' . $con_key . ') ';
$con_val = ' = ' . strlen($row[$i]);
$con_val = ' = ' . $pmaString->strlen($row[$i]);
} else {
// this blob won't be part of the final condition
$con_val = null;
@ -2153,7 +2195,7 @@ class PMA_Util
&& ! empty($row[$i])
) {
// do not build a too big condition
if (strlen($row[$i]) < 5000) {
if ($pmaString->strlen($row[$i]) < 5000) {
$condition .= '=0x' . bin2hex($row[$i]) . ' AND';
} else {
$condition = '';
@ -2515,7 +2557,7 @@ class PMA_Util
public static function userDir($dir)
{
// add trailing slash
if (substr($dir, -1) != '/') {
if ($GLOBALS['PMA_String']->substr($dir, -1) != '/') {
$dir .= '/';
}
@ -2531,8 +2573,11 @@ class PMA_Util
*/
public static function getDbLink($database = null)
{
if (! strlen($database)) {
if (! strlen($GLOBALS['db'])) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if (! $pmaString->strlen($database)) {
if (! $pmaString->strlen($GLOBALS['db'])) {
return '';
}
$database = $GLOBALS['db'];
@ -2926,22 +2971,27 @@ class PMA_Util
*/
public static function extractColumnSpec($columnspec)
{
$first_bracket_pos = strpos($columnspec, '(');
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$first_bracket_pos = $pmaString->strpos($columnspec, '(');
if ($first_bracket_pos) {
$spec_in_brackets = chop(
substr(
$pmaString->substr(
$columnspec,
$first_bracket_pos + 1,
(strrpos($columnspec, ')') - $first_bracket_pos - 1)
($pmaString->strrpos($columnspec, ')') - $first_bracket_pos - 1)
)
);
// convert to lowercase just to be sure
$type = strtolower(chop(substr($columnspec, 0, $first_bracket_pos)));
$type = $pmaString->strtolower(
chop($pmaString->substr($columnspec, 0, $first_bracket_pos))
);
} else {
// Split trailing attributes such as unsigned,
// binary, zerofill and get data type name
$type_parts = explode(' ', $columnspec);
$type = strtolower($type_parts[0]);
$type = $pmaString->strtolower($type_parts[0]);
$spec_in_brackets = '';
}
@ -2957,7 +3007,7 @@ class PMA_Util
$enum_set_values = array();
/* Create printable type name */
$printtype = strtolower($columnspec);
$printtype = $pmaString->strtolower($columnspec);
// Strip the "BINARY" attribute, except if we find "BINARY(" because
// this would be a BINARY or VARBINARY column type;
@ -3005,7 +3055,7 @@ class PMA_Util
// for the case ENUM('&#8211;','&ldquo;')
$displayed_type = htmlspecialchars($printtype);
if (strlen($printtype) > $GLOBALS['cfg']['LimitChars']) {
if ($pmaString->strlen($printtype) > $GLOBALS['cfg']['LimitChars']) {
$displayed_type = '<abbr title="' . $printtype . '">';
$displayed_type .= $GLOBALS['PMA_String']->substr(
$printtype, 0, $GLOBALS['cfg']['LimitChars']
@ -3036,7 +3086,7 @@ class PMA_Util
*/
public static function isForeignKeySupported($engine)
{
$engine = strtoupper($engine);
$engine = $GLOBALS['PMA_String']->strtoupper($engine);
if (($engine == 'INNODB') || ($engine == 'PBXT')) {
return true;
} elseif ($engine == 'NDBCLUSTER' || $engine == 'NDB') {
@ -3107,7 +3157,7 @@ class PMA_Util
*/
public static function duplicateFirstNewline($string)
{
$first_occurence = strpos($string, "\r\n");
$first_occurence = $GLOBALS['PMA_String']->strpos($string, "\r\n");
if ($first_occurence === 0) {
$string = "\n" . $string;
}
@ -3218,13 +3268,16 @@ class PMA_Util
}
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
/* Backward compatibility in 3.5.x */
if (strpos($string, '@FIELDS@') !== false) {
if ($pmaString->strpos($string, '@FIELDS@') !== false) {
$string = strtr($string, array('@FIELDS@' => '@COLUMNS@'));
}
/* Fetch columns list if required */
if (strpos($string, '@COLUMNS@') !== false) {
if ($pmaString->strpos($string, '@COLUMNS@') !== false) {
$columns_list = $GLOBALS['dbi']->getColumns(
$GLOBALS['db'], $GLOBALS['table']
);
@ -3483,7 +3536,8 @@ class PMA_Util
);
if ($upper_case) {
for ($i = 0, $nb = count($gis_data_types); $i < $nb; $i++) {
$gis_data_types[$i] = strtoupper($gis_data_types[$i]);
$gis_data_types[$i]
= $GLOBALS['PMA_String']->strtoupper($gis_data_types[$i]);
}
}
return $gis_data_types;
@ -3532,7 +3586,7 @@ class PMA_Util
$funcs[] = array('display' => ' ');
}
// Unary functions common to all geomety types
// Unary functions common to all geometry types
$funcs['Dimension'] = array('params' => 1, 'type' => 'int');
$funcs['Envelope'] = array('params' => 1, 'type' => 'Polygon');
$funcs['GeometryType'] = array('params' => 1, 'type' => 'text');
@ -3540,18 +3594,18 @@ class PMA_Util
$funcs['IsEmpty'] = array('params' => 1, 'type' => 'int');
$funcs['IsSimple'] = array('params' => 1, 'type' => 'int');
$geom_type = trim(strtolower($geom_type));
$geom_type = trim($GLOBALS['PMA_String']->strtolower($geom_type));
if ($display && $geom_type != 'geometry' && $geom_type != 'multipoint') {
$funcs[] = array('display' => '--------');
}
// Unary functions that are specific to each geomety type
// Unary functions that are specific to each geometry type
if ($geom_type == 'point') {
$funcs['X'] = array('params' => 1, 'type' => 'float');
$funcs['Y'] = array('params' => 1, 'type' => 'float');
} elseif ($geom_type == 'multipoint') {
// no fucntions here
// no functions here
} elseif ($geom_type == 'linestring') {
$funcs['EndPoint'] = array('params' => 1, 'type' => 'point');
$funcs['GLength'] = array('params' => 1, 'type' => 'float');
@ -3866,14 +3920,25 @@ class PMA_Util
*/
public static function getServerType()
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$server_type = 'MySQL';
if (PMA_DRIZZLE) {
$server_type = 'Drizzle';
} else if (stripos(PMA_MYSQL_STR_VERSION, 'mariadb') !== false) {
$server_type = 'MariaDB';
} else if (stripos(PMA_MYSQL_VERSION_COMMENT, 'percona') !== false) {
$server_type = 'Percona Server';
return $server_type;
}
if ($pmaString->stripos(PMA_MYSQL_STR_VERSION, 'mariadb') !== false) {
$server_type = 'MariaDB';
return $server_type;
}
if ($pmaString->stripos(PMA_MYSQL_VERSION_COMMENT, 'percona') !== false) {
$server_type = 'Percona Server';
return $server_type;
}
return $server_type;
}
@ -3933,10 +3998,17 @@ class PMA_Util
$in_string = false;
$buffer = '';
for ($i=0, $length = strlen($values_string); $i < $length; $i++) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
for ($i=0, $length = $pmaString->strlen($values_string);
$i < $length;
$i++
) {
$curr = $values_string[$i];
$next = ($i == strlen($values_string)-1) ? '' : $values_string[$i+1];
$next = ($i == $pmaString->strlen($values_string)-1)
? ''
: $values_string[$i+1];
if (! $in_string && $curr == "'") {
$in_string = true;
@ -3958,7 +4030,7 @@ class PMA_Util
}
if (strlen($buffer) > 0) {
if ($pmaString->strlen($buffer) > 0) {
// The leftovers in the buffer are the last value (if any)
$values[] = $buffer;
}
@ -3984,8 +4056,11 @@ class PMA_Util
public static function fillTooltip(
&$tooltip_truename, &$tooltip_aliasname, $table
) {
if (strstr($table['Comment'], '; InnoDB free') === false) {
if (!strstr($table['Comment'], 'InnoDB free') === false) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strstr($table['Comment'], '; InnoDB free') === false) {
if (!$pmaString->strstr($table['Comment'], 'InnoDB free') === false) {
// here we have just InnoDB generated part
$table['Comment'] = '';
}
@ -4130,12 +4205,15 @@ class PMA_Util
*/
public static function handleContext(array $context)
{
if (strlen($GLOBALS['cfg']['ProxyUrl'])) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strlen($GLOBALS['cfg']['ProxyUrl'])) {
$context['http'] = array(
'proxy' => $GLOBALS['cfg']['ProxyUrl'],
'request_fulluri' => true
);
if (strlen($GLOBALS['cfg']['ProxyUser'])) {
if ($pmaString->strlen($GLOBALS['cfg']['ProxyUser'])) {
$auth = base64_encode(
$GLOBALS['cfg']['ProxyUser'] . ':' . $GLOBALS['cfg']['ProxyPass']
);
@ -4156,9 +4234,12 @@ class PMA_Util
*/
public static function configureCurl(resource $curl_handle)
{
if (strlen($GLOBALS['cfg']['ProxyUrl'])) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strlen($GLOBALS['cfg']['ProxyUrl'])) {
curl_setopt($curl_handle, CURLOPT_PROXY, $GLOBALS['cfg']['ProxyUrl']);
if (strlen($GLOBALS['cfg']['ProxyUser'])) {
if ($pmaString->strlen($GLOBALS['cfg']['ProxyUser'])) {
curl_setopt(
$curl_handle,
CURLOPT_PROXYUSERPWD,
@ -4231,10 +4312,13 @@ class PMA_Util
}
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$data = json_decode($response);
if (is_object($data)
&& strlen($data->version)
&& strlen($data->date)
&& $pmaString->strlen($data->version)
&& $pmaString->strlen($data->date)
&& $save
) {
if (! isset($_SESSION) && ! defined('TESTSUITE')) {
@ -4328,14 +4412,19 @@ class PMA_Util
*/
public static function addMicroseconds($value)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if (empty($value) || $value == 'CURRENT_TIMESTAMP') {
return $value;
} elseif (strpos($value, '.')) {
$value .= '000000';
return substr($value, 0, strpos($value, '.') + 7);
} else {
}
if (!$pmaString->strpos($value, '.')) {
return $value . '.000000';
}
$value .= '000000';
return $pmaString->substr($value, 0, $pmaString->strpos($value, '.') + 7);
}
/**
@ -4348,13 +4437,19 @@ class PMA_Util
*/
public static function getCompressionMimeType($file)
{
//Can't use PMA_StringMB here, so force use of PMA_StringNative.
include_once 'libraries/StringNative.class.php';
$pmaString = new PMA_StringNative();
$test = fread($file, 4);
$len = strlen($test);
$len = $pmaString->strlen($test);
fclose($file);
if ($len >= 2 && $test[0] == chr(31) && $test[1] == chr(139)) {
if ($len >= 2 && $test[0] == $pmaString->chr(31)
&& $test[1] == $pmaString->chr(139)
) {
return 'application/gzip';
}
if ($len >= 3 && substr($test, 0, 3) == 'BZh') {
if ($len >= 3 && $pmaString->substr($test, 0, 3) == 'BZh') {
return 'application/bzip2';
}
if ($len >= 4 && $test == "PK\003\004") {

View File

@ -218,9 +218,11 @@ function PMA_Bookmark_save($bkm_fields, $all_users = false)
$cfgBookmark = PMA_Bookmark_getParams();
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if (!(isset($bkm_fields['bkm_sql_query']) && isset($bkm_fields['bkm_label'])
&& strlen($bkm_fields['bkm_sql_query']) > 0
&& strlen($bkm_fields['bkm_label']) > 0)
&& $pmaString->strlen($bkm_fields['bkm_sql_query']) > 0
&& $pmaString->strlen($bkm_fields['bkm_label']) > 0)
) {
return false;
}

View File

@ -131,6 +131,9 @@ function PMA_buildHtmlForDb(
}
}
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
foreach ($replication_types as $type) {
if ($replication_info[$type]['status']) {
$out .= '<td class="tool" style="text-align: center;">';
@ -139,14 +142,14 @@ function PMA_buildHtmlForDb(
$current["SCHEMA_NAME"],
$replication_info[$type]['Ignore_DB']
);
if (strlen($key) > 0) {
if ($pmaString->strlen($key) > 0) {
$out .= PMA_Util::getIcon('s_cancel.png', __('Not replicated'));
} else {
$key = array_search(
$current["SCHEMA_NAME"], $replication_info[$type]['Do_DB']
);
if (strlen($key) > 0
if ($pmaString->strlen($key) > 0
|| ($replication_info[$type]['Do_DB'][0] == ""
&& count($replication_info[$type]['Do_DB']) == 1)
) {

View File

@ -746,6 +746,9 @@ function PMA_getHTMLforAddCentralColumn($total_rows, $pos, $db)
*/
function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$tableHtml = '<tr data-rownum="' . $row_num . '" id="f_' . $row_num . '" '
. 'class="' . ($odd_row ? 'odd' : 'even') . '">'
. PMA_URL_getHiddenInputs(
@ -776,7 +779,7 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
'<td name = "col_type" class="nowrap"><span>'
. htmlspecialchars($row['col_type']) . '</span>'
. PMA_getHtmlForColumnType(
$row_num, 1, 0, strtoupper($row['col_type']), array()
$row_num, 1, 0, $pmaString->strtoupper($row['col_type']), array()
)
. '</td>';
$tableHtml .=
@ -826,7 +829,7 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
? htmlspecialchars($row['col_default']) : 'None')
. '</span>'
. PMA_getHtmlForColumnDefault(
$row_num, 5, 0, strtoupper($row['col_type']), '', $meta
$row_num, 5, 0, $pmaString->strtoupper($row['col_type']), '', $meta
)
. '</td>';
$tableHtml .= '</tr>';

View File

@ -69,17 +69,23 @@ function PMA_analyseShowGrant()
$re0 = '(^|(\\\\\\\\)+|[^\\\\])'; // non-escaped wildcards
$re1 = '(^|[^\\\\])(\\\)+'; // escaped wildcards
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
while ($row = $GLOBALS['dbi']->fetchRow($rs_usr)) {
// extract db from GRANT ... ON *.* or GRANT ... ON db.*
$db_name_offset = strpos($row[0], ' ON ') + 4;
$show_grants_dbname = substr(
$db_name_offset = $pmaString->strpos($row[0], ' ON ') + 4;
$show_grants_dbname = $pmaString->substr(
$row[0], $db_name_offset,
strpos($row[0], '.', $db_name_offset) - $db_name_offset
$pmaString->strpos($row[0], '.', $db_name_offset) - $db_name_offset
);
$show_grants_dbname
= PMA_Util::unQuote($show_grants_dbname, '`');
$show_grants_dbname = PMA_Util::unQuote($show_grants_dbname, '`');
$show_grants_str = substr($row[0], 6, (strpos($row[0], ' ON ') - 6));
$show_grants_str = $pmaString->substr(
$row[0],
6,
($pmaString->strpos($row[0], ' ON ') - 6)
);
if ($show_grants_str == 'RELOAD') {
$GLOBALS['is_reload_priv'] = true;
}
@ -91,7 +97,7 @@ function PMA_analyseShowGrant()
if ($show_grants_str == 'ALL'
|| $show_grants_str == 'ALL PRIVILEGES'
|| $show_grants_str == 'CREATE'
|| strpos($show_grants_str, 'CREATE,') !== false
|| $pmaString->strpos($show_grants_str, 'CREATE,') !== false
) {
if ($show_grants_dbname == '*') {
// a global CREATE privilege
@ -121,7 +127,7 @@ function PMA_analyseShowGrant()
'/' . $re1 . '(%|_)/', '\\1\\3', $dbname_to_test
)
)
&& substr($GLOBALS['dbi']->getError(), 1, 4) != 1044)
&& $pmaString->substr($GLOBALS['dbi']->getError(), 1, 4) != 1044)
) {
/**
* Do not handle the underscore wildcard

View File

@ -157,9 +157,13 @@ if (! defined('PMA_MINIMUM_COMMON')) {
$PMA_PHP_SELF = PMA_getenv('PHP_SELF');
$_PATH_INFO = PMA_getenv('PATH_INFO');
if (! empty($_PATH_INFO) && ! empty($PMA_PHP_SELF)) {
$path_info_pos = strrpos($PMA_PHP_SELF, $_PATH_INFO);
if ($path_info_pos + strlen($_PATH_INFO) === strlen($PMA_PHP_SELF)) {
$PMA_PHP_SELF = substr($PMA_PHP_SELF, 0, $path_info_pos);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$path_info_pos = $pmaString->strrpos($PMA_PHP_SELF, $_PATH_INFO);
$pathLength = $path_info_pos + $pmaString->strlen($_PATH_INFO);
if ($pathLength === $pmaString->strlen($PMA_PHP_SELF)) {
$PMA_PHP_SELF = $pmaString->substr($PMA_PHP_SELF, 0, $path_info_pos);
}
}
$PMA_PHP_SELF = htmlspecialchars($PMA_PHP_SELF);
@ -183,7 +187,8 @@ $variables_whitelist = array (
'error_handler',
'PMA_PHP_SELF',
'variables_whitelist',
'key'
'key',
'PMA_String'
);
foreach (get_defined_vars() as $key => $value) {
@ -737,11 +742,6 @@ if (! defined('PMA_MINIMUM_COMMON')) {
*/
include_once './libraries/charset_conversion.lib.php';
/**
* String handling
*/
include_once './libraries/string.inc.php';
/**
* Lookup server by name
* (see FAQ 4.8)
@ -751,10 +751,11 @@ if (! defined('PMA_MINIMUM_COMMON')) {
&& ! is_numeric($_REQUEST['server'])
) {
foreach ($cfg['Servers'] as $i => $server) {
$verboseLower = $PMA_String->strtolower($server['verbose']);
if ($server['host'] == $_REQUEST['server']
|| $server['verbose'] == $_REQUEST['server']
|| $PMA_String->strtolower($server['verbose']) == $PMA_String->strtolower($_REQUEST['server'])
|| md5($PMA_String->strtolower($server['verbose'])) == $PMA_String->strtolower($_REQUEST['server'])
|| $verboseLower == $PMA_String->strtolower($_REQUEST['server'])
|| md5($verboseLower) == $PMA_String->strtolower($_REQUEST['server'])
) {
$_REQUEST['server'] = $i;
break;
@ -843,7 +844,8 @@ if (! defined('PMA_MINIMUM_COMMON')) {
// and run authentication
// to allow HTTP or http
$cfg['Server']['auth_type'] = strtolower($cfg['Server']['auth_type']);
$cfg['Server']['auth_type']
= $PMA_String->strtolower($cfg['Server']['auth_type']);
/**
* the required auth type plugin
@ -933,7 +935,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
}
// if using TCP socket is not needed
if (strtolower($cfg['Server']['connect_type']) == 'tcp') {
if ($PMA_String->strtolower($cfg['Server']['connect_type']) == 'tcp') {
$cfg['Server']['socket'] = '';
}

View File

@ -75,7 +75,13 @@ class Form
*/
public function getOptionType($option_name)
{
$key = ltrim(substr($option_name, strrpos($option_name, '/')), '/');
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$key = ltrim(
$pmaString->substr($option_name, $pmaString->strrpos($option_name, '/')),
'/'
);
return isset($this->_fieldsTypes[$key])
? $this->_fieldsTypes[$key]
: null;
@ -169,12 +175,18 @@ class Form
$this->fields = array();
array_walk($form, array($this, '_readFormPathsCallback'), '');
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// $this->fields is an array of the form: [0..n] => 'field path'
// change numeric indexes to contain field names (last part of the path)
$paths = $this->fields;
$this->fields = array();
foreach ($paths as $path) {
$key = ltrim(substr($path, strrpos($path, '/')), '/');
$key = ltrim(
$pmaString->substr($path, $pmaString->strrpos($path, '/')),
'/'
);
$this->fields[$key] = $path;
}
// now $this->fields is an array of the form: 'field name' => 'field path'
@ -187,9 +199,12 @@ class Form
*/
protected function readTypes()
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$cf = $this->_configFile;
foreach ($this->fields as $name => $path) {
if (strpos($name, ':group:') === 0) {
if ($pmaString->strpos($name, ':group:') === 0) {
$this->_fieldsTypes[$name] = 'group';
continue;
}

View File

@ -357,6 +357,10 @@ class FormDisplay
if (isset($this->_errors[$work_path])) {
$opts['errors'] = $this->_errors[$work_path];
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
switch ($form->getOptionType($field)) {
case 'string':
$type = 'text';
@ -382,8 +386,8 @@ class FormDisplay
break;
case 'group':
// :group:end is changed to :group:end:{unique id} in Form class
if (substr($field, 7, 4) != 'end:') {
PMA_displayGroupHeader(substr($field, 7));
if ($pmaString->substr($field, 7, 4) != 'end:') {
PMA_displayGroupHeader($pmaString->substr($field, 7));
} else {
PMA_displayGroupFooter();
}
@ -395,7 +399,7 @@ class FormDisplay
// detect password fields
if ($type === 'text'
&& substr($translated_path, -9) === '-password'
&& $pmaString->substr($translated_path, -9) === '-password'
) {
$type = 'password';
}
@ -700,7 +704,7 @@ class FormDisplay
*/
public function getDocLink($path)
{
$test = substr($path, 0, 6);
$test = $GLOBALS['PMA_String']->substr($path, 0, 6);
if ($test == 'Import' || $test == 'Export') {
return '';
}

View File

@ -254,7 +254,9 @@ function PMA_displayInput($path, $name, $type, $value, $description = '',
foreach ($opts['values'] as $opt_value_key => $opt_value) {
// set names for boolean values
if (is_bool($opt_value)) {
$opt_value = strtolower($opt_value ? __('Yes') : __('No'));
$opt_value = $GLOBALS['PMA_String']->strtolower(
$opt_value ? __('Yes') : __('No')
);
}
// escape if necessary
if ($escape) {

View File

@ -338,7 +338,7 @@ class ServerConfigChecks
} else {
$blowfishWarnings = array();
// check length
if (strlen($blowfishSecret) < 8) {
if ($GLOBALS['PMA_String']->strlen($blowfishSecret) < 8) {
// too short key
$blowfishWarnings[] = __('Key is too short, it should have at least 8 characters.');
}

View File

@ -47,6 +47,9 @@ class PMA_Validator
return $validators;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// not in setup script: load additional validators for user
// preferences we need original config values not overwritten
// by user preferences, creating a new PMA_Config instance is a
@ -59,9 +62,9 @@ class PMA_Validator
continue;
}
for ($i = 1, $nb = count($uv); $i < $nb; $i++) {
if (substr($uv[$i], 0, 6) == 'value:') {
if ($pmaString->substr($uv[$i], 0, 6) == 'value:') {
$uv[$i] = PMA_arrayRead(
substr($uv[$i], 6),
$pmaString->substr($uv[$i], 6),
$GLOBALS['PMA_Config']->base_settings
);
}
@ -113,7 +116,9 @@ class PMA_Validator
$key_map = array();
foreach ($values as $k => $v) {
$k2 = $isPostSource ? str_replace('-', '/', $k) : $k;
$k2 = strpos($k2, '/') ? $cf->getCanonicalPath($k2) : $k2;
$k2 = $GLOBALS['PMA_String']->strpos($k2, '/')
? $cf->getCanonicalPath($k2)
: $k2;
$key_map[$k2] = $k;
$arguments[$k2] = $v;
}

View File

@ -11,6 +11,11 @@ if (! defined('PHPMYADMIN')) {
exit;
}
/**
* String handling (security)
*/
require_once './libraries/string.inc.php';
/**
* checks given $var and returns it if valid, or $default of not valid
* given $var is also checked for type being 'similar' as $default
@ -107,8 +112,11 @@ function PMA_isValid(&$var, $type = 'length', $compare = null)
return in_array($var, $type);
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// allow some aliaes of var types
$type = strtolower($type);
$type = $pmaString->strtolower($type);
switch ($type) {
case 'identic' :
$type = 'identical';
@ -156,7 +164,7 @@ function PMA_isValid(&$var, $type = 'length', $compare = null)
if ($type === 'length' || $type === 'scalar') {
$is_scalar = is_scalar($var);
if ($is_scalar && $type === 'length') {
return (bool) strlen($var);
return (bool) $pmaString->strlen($var);
}
return $is_scalar;
}
@ -361,11 +369,24 @@ function PMA_getRealSize($size = 0)
'b' => 1,
);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
foreach ($scan as $unit => $factor) {
if (strlen($size) > strlen($unit)
&& strtolower(substr($size, strlen($size) - strlen($unit))) == $unit
$sizeLength = $pmaString->strlen($size);
$unitLength = $pmaString->strlen($unit);
if ($sizeLength > $unitLength
&& $pmaString->strtolower(
$pmaString->substr(
$size,
$sizeLength - $unitLength
)
) == $unit
) {
return substr($size, 0, strlen($size) - strlen($unit)) * $factor;
return $pmaString->substr(
$size,
0,
$sizeLength - $unitLength
) * $factor;
}
}
@ -491,12 +512,16 @@ function PMA_checkPageValidity(&$page, $whitelist)
return true;
}
if (in_array(substr($page, 0, strpos($page . '?', '?')), $whitelist)) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$_page = $pmaString->substr($page, 0, $pmaString->strpos($page . '?', '?'));
if (in_array($_page, $whitelist)) {
return true;
}
$_page = urldecode($page);
if (in_array(substr($_page, 0, strpos($_page . '?', '?')), $whitelist)) {
$_page = $pmaString->substr($_page, 0, $pmaString->strpos($_page . '?', '?'));
if (in_array($_page, $whitelist)) {
return true;
}
@ -546,7 +571,9 @@ function PMA_getenv($var_name)
*/
function PMA_sendHeaderLocation($uri, $use_refresh = false)
{
if (PMA_IS_IIS && strlen($uri) > 600) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if (PMA_IS_IIS && $pmaString->strlen($uri) > 600) {
include_once './libraries/js_escape.lib.php';
PMA_Response::getInstance()->disable();
@ -575,7 +602,7 @@ function PMA_sendHeaderLocation($uri, $use_refresh = false)
}
if (SID) {
if (strpos($uri, '?') === false) {
if ($pmaString->strpos($uri, '?') === false) {
header('Location: ' . $uri . '?' . SID);
} else {
$separator = PMA_URL_getArgSeparator();
@ -669,7 +696,7 @@ function PMA_downloadHeader($filename, $mimetype, $length = 0, $no_cache = true)
header('Content-Type: ' . $mimetype);
// inform the server that compression has been done,
// to avoid a double compression (for example with Apache + mod_deflate)
if (strpos($mimetype, 'gzip') !== false) {
if ($GLOBALS['PMA_String']->strpos($mimetype, 'gzip') !== false) {
header('Content-Encoding: gzip');
}
header('Content-Transfer-Encoding: binary');
@ -846,7 +873,7 @@ function PMA_isAllowedDomain($url)
/* Following are doubtful ones. */
'www.primebase.com','pbxt.blogspot.com'
);
if (in_array(strtolower($domain), $domainWhiteList)) {
if (in_array($GLOBALS['PMA_String']->strtolower($domain), $domainWhiteList)) {
return true;
}

View File

@ -29,13 +29,15 @@ if ($db_is_system_schema) {
$err_url_0 = 'index.php?' . PMA_URL_getCommon();
$err_url = $cfg['DefaultTabDatabase'] . '?' . PMA_URL_getCommon($db);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
/**
* Ensures the database exists (else move to the "parent" script) and displays
* headers
*/
if (! isset($is_db) || ! $is_db) {
if (strlen($db)) {
if ($pmaString->strlen($db)) {
$is_db = $GLOBALS['dbi']->selectDb($db);
// This "Command out of sync" 2014 error may happen, for example
// after calling a MySQL procedure; at this point we can't select
@ -51,7 +53,7 @@ if (! isset($is_db) || ! $is_db) {
$uri = $cfg['PmaAbsoluteUri'] . 'index.php?'
. PMA_URL_getCommon('', '', '&')
. (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1';
if (! strlen($db) || ! $is_db) {
if (!$pmaString->strlen($db) || ! $is_db) {
$response = PMA_Response::getInstance();
if ($response->isAjax()) {
$response->isSuccess(false);

View File

@ -705,19 +705,22 @@ function PMA_getDatabaseTables(
$html .= '<img src="' . $_SESSION['PMA_Theme']->getImgPath()
. 'pmd/Field_small';
if (strstr($tab_column[$t_n]["TYPE"][$j], 'char')
|| strstr($tab_column[$t_n]["TYPE"][$j], 'text')
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strstr($tab_column[$t_n]["TYPE"][$j], 'char')
|| $pmaString->strstr($tab_column[$t_n]["TYPE"][$j], 'text')
) {
$html .= '_char';
} elseif (strstr($tab_column[$t_n]["TYPE"][$j], 'int')
|| strstr($tab_column[$t_n]["TYPE"][$j], 'float')
|| strstr($tab_column[$t_n]["TYPE"][$j], 'double')
|| strstr($tab_column[$t_n]["TYPE"][$j], 'decimal')
} elseif ($pmaString->strstr($tab_column[$t_n]["TYPE"][$j], 'int')
|| $pmaString->strstr($tab_column[$t_n]["TYPE"][$j], 'float')
|| $pmaString->strstr($tab_column[$t_n]["TYPE"][$j], 'double')
|| $pmaString->strstr($tab_column[$t_n]["TYPE"][$j], 'decimal')
) {
$html .= '_int';
} elseif (strstr($tab_column[$t_n]["TYPE"][$j], 'date')
|| strstr($tab_column[$t_n]["TYPE"][$j], 'time')
|| strstr($tab_column[$t_n]["TYPE"][$j], 'year')
} elseif ($pmaString->strstr($tab_column[$t_n]["TYPE"][$j], 'date')
|| $pmaString->strstr($tab_column[$t_n]["TYPE"][$j], 'time')
|| $pmaString->strstr($tab_column[$t_n]["TYPE"][$j], 'year')
) {
$html .= '_date';
}

View File

@ -10,8 +10,10 @@ if (! defined('PHPMYADMIN')) {
exit;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if (empty($is_db)) {
if (strlen($db)) {
if ($pmaString->strlen($db)) {
$is_db = @$GLOBALS['dbi']->selectDb($db);
} else {
$is_db = false;
@ -50,11 +52,11 @@ if (empty($is_db)) {
if (empty($is_table)
&& !defined('PMA_SUBMIT_MULT')
&& ! defined('TABLE_MAY_BE_ABSENT')
&& !defined('TABLE_MAY_BE_ABSENT')
) {
// Not a valid table name -> back to the db_sql.php
if (strlen($table)) {
if ($pmaString->strlen($table)) {
$is_table = isset(PMA_Table::$cache[$db][$table]);
if (! $is_table) {
@ -71,8 +73,8 @@ if (empty($is_table)
}
if (! $is_table) {
if (! defined('IS_TRANSFORMATION_WRAPPER')) {
if (strlen($table)) {
if (!defined('IS_TRANSFORMATION_WRAPPER')) {
if ($pmaString->strlen($table)) {
// SHOW TABLES doesn't show temporary tables, so try select
// (as it can happen just in case temporary table, it should be
// fast):

View File

@ -40,7 +40,9 @@ function PMA_getHtmlForChangePassword($username, $hostname)
$html .= PMA_URL_getHiddenInputs();
if (strpos($GLOBALS['PMA_PHP_SELF'], 'server_privileges') !== false) {
/** @var PMA_String $pmaStr */
$pmaStr = $GLOBALS['PMA_String'];
if ($pmaStr->strpos($GLOBALS['PMA_PHP_SELF'], 'server_privileges') !== false) {
$html .= '<input type="hidden" name="username" '
. 'value="' . htmlspecialchars($username) . '" />'
. '<input type="hidden" name="hostname" '
@ -48,7 +50,10 @@ function PMA_getHtmlForChangePassword($username, $hostname)
}
$html .= '<fieldset id="fieldset_change_password">'
. '<legend'
. ($is_privileges ? ' data-submenu-label="' . __('Change password') . '"' : '')
. ($is_privileges
? ' data-submenu-label="' . __('Change password') . '"'
: ''
)
. '>' . __('Change password') . '</legend>'
. '<table class="data noclick">'
. '<tr class="odd">'

View File

@ -74,7 +74,10 @@ function PMA_getHtmlForExportSelectOptions($tmp_select = '')
$is_selected = '';
}
} elseif (!empty($tmp_select)) {
if (strpos(' ' . $tmp_select, '|' . $current_db . '|')) {
if ($GLOBALS['PMA_String']->strpos(
' ' . $tmp_select,
'|' . $current_db . '|'
)) {
$is_selected = ' selected="selected"';
} else {
$is_selected = '';
@ -710,7 +713,8 @@ function PMA_getHtmlForExportOptions(
$html .= PMA_getHtmlForExportOptionsMethod();
$html .= PMA_getHtmlForExportOptionsSelection($export_type, $multi_values);
if (strlen($table) && empty($num_tables) && ! PMA_Table::isMerge($db, $table)) {
$tableLength = $GLOBALS['PMA_String']->strlen($table);
if ($tableLength && empty($num_tables) && ! PMA_Table::isMerge($db, $table)) {
$html .= PMA_getHtmlForExportOptionsRows($db, $table, $unlim_num_rows);
}
@ -772,6 +776,9 @@ function PMA_getHtmlForAliasModalDialog($db = '', $table = '')
);
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$html = '<div id="alias_modal" class="hide" title="' . $title . '">';
$db_html = '<label class="col-2">' . __('Select database') . ': '
. '</label><select id="db_alias_select">';
@ -785,7 +792,7 @@ function PMA_getHtmlForAliasModalDialog($db = '', $table = '')
}
$db = htmlspecialchars($db);
$name_attr = 'aliases[' . $db . '][alias]';
$id_attr = substr(md5($name_attr), 0, 12);
$id_attr = $pmaString->substr(md5($name_attr), 0, 12);
$class = 'hide';
if ($first_db) {
$first_db = false;
@ -809,7 +816,7 @@ function PMA_getHtmlForAliasModalDialog($db = '', $table = '')
}
$table = htmlspecialchars($table);
$name_attr = 'aliases[' . $db . '][tables][' . $table . '][alias]';
$id_attr = substr(md5($name_attr), 0, 12);
$id_attr = $pmaString->substr(md5($name_attr), 0, 12);
$class = 'hide';
if ($first_tbl) {
$first_tbl = false;
@ -837,7 +844,7 @@ function PMA_getHtmlForAliasModalDialog($db = '', $table = '')
$column = htmlspecialchars($column);
$name_attr = 'aliases[' . $db . '][tables][' . $table
. '][columns][' . $column . ']';
$id_attr = substr(md5($name_attr), 0, 12);
$id_attr = $pmaString->substr(md5($name_attr), 0, 12);
$col_html .= '<tr class="' . $class . '">';
$col_html .= '<th><label for="' . $id_attr . '">' . $column
. '</label></th>';

View File

@ -25,8 +25,8 @@ function PMA_printGitRevision()
// load revision data from repo
$GLOBALS['PMA_Config']->checkGitRevision();
// if using a remote commit fast-forwarded, link to Github
$commit_hash = substr(
// if using a remote commit fast-forwarded, link to GitHub
$commit_hash = $GLOBALS['PMA_String']->substr(
$GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'),
0,
7

View File

@ -293,10 +293,12 @@ function PMA_getLineNumber($filenames, $cumulative_number)
*/
function PMA_translateStacktrace($stack)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
foreach ($stack as &$level) {
foreach ($level["context"] as &$line) {
if (strlen($line) > 80) {
$line = substr($line, 0, 75) . "//...";
if ($pmaString->strlen($line) > 80) {
$line = $pmaString->substr($line, 0, 75) . "//...";
}
}
if (preg_match("<js/get_scripts.js.php\?(.*)>", $level["url"], $matches)) {

View File

@ -19,7 +19,9 @@ if (! defined('PHPMYADMIN')) {
function PMA_shutdownDuringExport()
{
$a = error_get_last();
if ($a != null && strpos($a['message'], "execution time")) {
if ($a != null
&& $GLOBALS['PMA_String']->strpos($a['message'], "execution time")
) {
//write in partially downloaded file for future reference of user
print_r($a);
//set session variable to check if there was error while exporting
@ -83,13 +85,17 @@ function PMA_exportOutputHandler($line)
isset($GLOBALS['xkana']) ? $GLOBALS['xkana'] : ''
);
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// If we have to buffer data, we will perform everything at once at the end
if ($GLOBALS['buffer_needed']) {
$dump_buffer .= $line;
if ($GLOBALS['onfly_compression']) {
$dump_buffer_len += strlen($line);
$dump_buffer_len += $pmaString->strlen($line);
if ($dump_buffer_len > $GLOBALS['memory_limit']) {
if ($GLOBALS['output_charset_conversion']) {
@ -108,7 +114,7 @@ function PMA_exportOutputHandler($line)
}
if ($GLOBALS['save_on_server']) {
$write_result = @fwrite($GLOBALS['file_handle'], $dump_buffer);
if ($write_result != strlen($dump_buffer)) {
if ($write_result != $pmaString->strlen($dump_buffer)) {
$GLOBALS['message'] = PMA_Message::error(
__('Insufficient space to save the file %s.')
);
@ -137,9 +143,11 @@ function PMA_exportOutputHandler($line)
$line
);
}
if ($GLOBALS['save_on_server'] && strlen($line) > 0) {
if ($GLOBALS['save_on_server'] && $pmaString->strlen($line) > 0) {
$write_result = @fwrite($GLOBALS['file_handle'], $line);
if (! $write_result || ($write_result != strlen($line))) {
if (! $write_result
|| $write_result != $pmaString->strlen($line)
) {
$GLOBALS['message'] = PMA_Message::error(
__('Insufficient space to save the file %s.')
);
@ -198,16 +206,20 @@ function PMA_getHtmlForDisplayedExportFooter($back_button)
*/
function PMA_getMemoryLimitForExport()
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$memory_limit = trim(@ini_get('memory_limit'));
$memory_limit_num = (int)substr($memory_limit, 0, -1);
$memory_limit_num = (int)$pmaString->substr($memory_limit, 0, -1);
$lowerLastChar = $pmaString->strtolower($pmaString->substr($memory_limit, -1));
// 2 MB as default
if (empty($memory_limit) || '-1' == $memory_limit) {
$memory_limit = 2 * 1024 * 1024;
} elseif (strtolower(substr($memory_limit, -1)) == 'm') {
} elseif ($lowerLastChar == 'm') {
$memory_limit = $memory_limit_num * 1024 * 1024;
} elseif (strtolower(substr($memory_limit, -1)) == 'k') {
} elseif ($lowerLastChar == 'k') {
$memory_limit = $memory_limit_num * 1024;
} elseif (strtolower(substr($memory_limit, -1)) == 'g') {
} elseif ($lowerLastChar == 'g') {
$memory_limit = $memory_limit_num * 1024 * 1024 * 1024;
} else {
$memory_limit = (int)$memory_limit;
@ -270,15 +282,19 @@ function PMA_getExportFilenameAndMimetype(
// part of the filename) to avoid a remote code execution vulnerability
$filename = PMA_sanitizeFilename($filename, $replaceDots = true);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Grab basic dump extension and mime type
// Check if the user already added extension;
// get the substring where the extension would be if it was included
$extension_start_pos = strlen($filename) - strlen(
$extension_start_pos = $pmaString->strlen($filename) - $pmaString->strlen(
$export_plugin->getProperties()->getExtension()
) - 1;
$user_extension = substr($filename, $extension_start_pos, strlen($filename));
$user_extension = $pmaString->substr(
$filename, $extension_start_pos, $pmaString->strlen($filename)
);
$required_extension = "." . $export_plugin->getProperties()->getExtension();
if (strtolower($user_extension) != $required_extension) {
if ($pmaString->strtolower($user_extension) != $required_extension) {
$filename .= $required_extension;
}
$mime_type = $export_plugin->getProperties()->getMimeType();
@ -354,10 +370,13 @@ function PMA_openExportFile($filename, $quick_export)
*/
function PMA_closeExportFile($file_handle, $dump_buffer, $save_filename)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$write_result = @fwrite($file_handle, $dump_buffer);
fclose($file_handle);
if (strlen($dump_buffer) > 0
&& (! $write_result || ($write_result != strlen($dump_buffer)))
if ($pmaString->strlen($dump_buffer) > 0
&& (! $write_result || ($write_result != $pmaString->strlen($dump_buffer)))
) {
$message = new PMA_Message(
__('Insufficient space to save the file %s.'),
@ -387,7 +406,10 @@ function PMA_compressExport($dump_buffer, $compression, $filename)
{
if ($compression == 'zip' && @function_exists('gzcompress')) {
$zipfile = new ZipFile();
$zipfile->addFile($dump_buffer, substr($filename, 0, -4));
$zipfile->addFile(
$dump_buffer,
$GLOBALS['PMA_String']->substr($filename, 0, -4)
);
$dump_buffer = $zipfile->file();
} elseif ($compression == 'gzip' && PMA_gzencodeNeeded()) {
// without the optional parameter level because it bugs
@ -468,6 +490,9 @@ function PMA_exportServer(
$export_type, $do_relation, $do_comments, $do_mime, $do_dates,
$aliases
) {
/** @var PMA_String $pmaStr */
$pmaStr = $GLOBALS['PMA_String'];
if (! empty($db_select)) {
$tmp_select = implode($db_select, '|');
$tmp_select = '|' . $tmp_select . '|';
@ -475,7 +500,7 @@ function PMA_exportServer(
// Walk over databases
foreach ($GLOBALS['pma']->databases as $current_db) {
if (isset($tmp_select)
&& strpos(' ' . $tmp_select, '|' . $current_db . '|')
&& $pmaStr->strpos(' ' . $tmp_select, '|' . $current_db . '|')
) {
$tables = $GLOBALS['dbi']->getTables($current_db);
PMA_exportDatabase(
@ -520,7 +545,10 @@ function PMA_exportDatabase(
}
if (method_exists($export_plugin, 'exportRoutines')
&& strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
&& $GLOBALS['PMA_String']->strpos(
$GLOBALS['sql_structure_or_data'],
'structure'
) !== false
&& isset($GLOBALS['sql_procedure_function'])
) {
$export_plugin->exportRoutines($db, $aliases);

View File

@ -24,7 +24,7 @@ function PMA_getDirContent($dir, $expression = '')
}
$result = array();
if (substr($dir, -1) != '/') {
if ($GLOBALS['PMA_String']->substr($dir, -1) != '/') {
$dir .= '/';
}
while ($file = @readdir($handle)) {

View File

@ -32,12 +32,16 @@ class PMA_GIS_Factory
{
include_once './libraries/gis/GIS_Geometry.class.php';
$file = './libraries/gis/GIS_' . ucfirst(strtolower($type)) . '.class.php';
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$file = './libraries/gis/GIS_'
. ucfirst($pmaString->strtolower($type)) . '.class.php';
if (! file_exists($file)) {
return false;
}
if (include_once $file) {
switch(strtoupper($type)) {
switch($pmaString->strtoupper($type)) {
case 'MULTIPOLYGON' :
return PMA_GIS_Multipolygon::singleton();
case 'POLYGON' :

View File

@ -84,7 +84,7 @@ abstract class PMA_GIS_Geometry
*
* @param string $spatial spatial data of a row
*
* @return array array containing the min, max values for x and y cordinates
* @return array array containing the min, max values for x and y coordinates
* @access public
*/
public abstract function scaleRow($spatial);
@ -176,10 +176,14 @@ abstract class PMA_GIS_Geometry
. '|POLYGON|MULTIPOLYGON|GEOMETRYCOLLECTION)';
$srid = 0;
$wkt = '';
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if (preg_match("/^'" . $geom_types . "\(.*\)',[0-9]*$/i", $value)) {
$last_comma = strripos($value, ",");
$srid = trim(substr($value, $last_comma + 1));
$wkt = trim(substr($value, 1, $last_comma - 2));
$last_comma = $pmaString->strripos($value, ",");
$srid = trim($pmaString->substr($value, $last_comma + 1));
$wkt = trim($pmaString->substr($value, 1, $last_comma - 2));
} elseif (preg_match("/^" . $geom_types . "\(.*\)$/i", $value)) {
$wkt = $value;
}
@ -250,7 +254,15 @@ abstract class PMA_GIS_Geometry
$rings = explode("),(", $polygon);
$ol_array .= $this->getPolygonForOpenLayers($rings, $srid) . ', ';
}
$ol_array = substr($ol_array, 0, strlen($ol_array) - 2);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$ol_array = $pmaString->substr(
$ol_array,
0,
$pmaString->strlen($ol_array) - 2
);
$ol_array .= ')';
return $ol_array;
@ -295,7 +307,15 @@ abstract class PMA_GIS_Geometry
);
$ol_array .= ', ';
}
$ol_array = substr($ol_array, 0, strlen($ol_array) - 2);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$ol_array = $pmaString->substr(
$ol_array,
0,
$pmaString->strlen($ol_array) - 2
);
$ol_array .= ')';
return $ol_array;
@ -335,7 +355,15 @@ abstract class PMA_GIS_Geometry
foreach ($points_arr as $point) {
$ol_array .= $this->getPointForOpenLayers($point, $srid) . ', ';
}
$ol_array = substr($ol_array, 0, strlen($ol_array) - 2);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$ol_array = $pmaString->substr(
$ol_array,
0,
$pmaString->strlen($ol_array) - 2
);
$ol_array .= ')';
return $ol_array;

View File

@ -57,15 +57,22 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
{
$min_max = array();
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')'
$goem_col = substr($spatial, 19, (strlen($spatial) - 20));
$goem_col = $pmaString->substr(
$spatial,
19,
$pmaString->strlen($spatial) - 20
);
// Split the geometry collection object to get its constituents.
$sub_parts = $this->_explodeGeomCol($goem_col);
foreach ($sub_parts as $sub_part) {
$type_pos = stripos($sub_part, '(');
$type = substr($sub_part, 0, $type_pos);
$type_pos = $pmaString->stripos($sub_part, '(');
$type = $pmaString->substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
@ -111,14 +118,21 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
*/
public function prepareRowAsPng($spatial, $label, $color, $scale_data, $image)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')'
$goem_col = substr($spatial, 19, (strlen($spatial) - 20));
$goem_col = $pmaString->substr(
$spatial,
19,
$pmaString->strlen($spatial) - 20
);
// Split the geometry collection object to get its constituents.
$sub_parts = $this->_explodeGeomCol($goem_col);
foreach ($sub_parts as $sub_part) {
$type_pos = stripos($sub_part, '(');
$type = substr($sub_part, 0, $type_pos);
$type_pos = $pmaString->stripos($sub_part, '(');
$type = $pmaString->substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
@ -145,14 +159,21 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
*/
public function prepareRowAsPdf($spatial, $label, $color, $scale_data, $pdf)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')'
$goem_col = substr($spatial, 19, (strlen($spatial) - 20));
$goem_col = $pmaString->substr(
$spatial,
19,
$pmaString->strlen($spatial) - 20
);
// Split the geometry collection object to get its constituents.
$sub_parts = $this->_explodeGeomCol($goem_col);
foreach ($sub_parts as $sub_part) {
$type_pos = stripos($sub_part, '(');
$type = substr($sub_part, 0, $type_pos);
$type_pos = $pmaString->stripos($sub_part, '(');
$type = $pmaString->substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
@ -180,14 +201,21 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
{
$row = '';
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')'
$goem_col = substr($spatial, 19, (strlen($spatial) - 20));
$goem_col = $pmaString->substr(
$spatial,
19,
$pmaString->strlen($spatial) - 20
);
// Split the geometry collection object to get its constituents.
$sub_parts = $this->_explodeGeomCol($goem_col);
foreach ($sub_parts as $sub_part) {
$type_pos = stripos($sub_part, '(');
$type = substr($sub_part, 0, $type_pos);
$type_pos = $pmaString->stripos($sub_part, '(');
$type = $pmaString->substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
@ -217,14 +245,21 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
{
$row = '';
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')'
$goem_col = substr($spatial, 19, (strlen($spatial) - 20));
$goem_col = $pmaString->substr(
$spatial,
19,
$pmaString->strlen($spatial) - 20
);
// Split the geometry collection object to get its constituents.
$sub_parts = $this->_explodeGeomCol($goem_col);
foreach ($sub_parts as $sub_part) {
$type_pos = stripos($sub_part, '(');
$type = substr($sub_part, 0, $type_pos);
$type_pos = $pmaString->stripos($sub_part, '(');
$type = $pmaString->substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
@ -257,7 +292,11 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
} elseif ($char == ')') {
$br_count--;
if ($br_count == 0) {
$sub_parts[] = substr($goem_col, $start, ($count + 1 - $start));
$sub_parts[] = $GLOBALS['PMA_String']->substr(
$goem_col,
$start,
($count + 1 - $start)
);
$start = $count + 2;
}
}
@ -292,7 +331,10 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
}
}
if (isset($gis_data[0]['gis_type'])) {
$wkt = substr($wkt, 0, strlen($wkt) - 1);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$wkt = $pmaString->substr($wkt, 0, $pmaString->strlen($wkt) - 1);
}
$wkt .= ')';
return $wkt;
@ -313,16 +355,19 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
$params['srid'] = $data['srid'];
$wkt = $data['wkt'];
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')'
$goem_col = substr($wkt, 19, (strlen($wkt) - 20));
$goem_col = $pmaString->substr($wkt, 19, ($pmaString->strlen($wkt) - 20));
// Split the geometry collection object to get its constituents.
$sub_parts = $this->_explodeGeomCol($goem_col);
$params['GEOMETRYCOLLECTION']['geom_count'] = count($sub_parts);
$i = 0;
foreach ($sub_parts as $sub_part) {
$type_pos = stripos($sub_part, '(');
$type = substr($sub_part, 0, $type_pos);
$type_pos = $pmaString->stripos($sub_part, '(');
$type = $pmaString->substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
continue;

View File

@ -55,8 +55,15 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
*/
public function scaleRow($spatial)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'LINESTRING(' and trailing ')'
$linesrting = substr($spatial, 11, (strlen($spatial) - 12));
$linesrting = $pmaString->substr(
$spatial,
11,
$pmaString->strlen($spatial) - 12
);
return $this->setMinMax($linesrting, array());
}
@ -75,15 +82,25 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
public function prepareRowAsPng($spatial, $label, $line_color,
$scale_data, $image
) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// allocate colors
$black = imagecolorallocate($image, 0, 0, 0);
$red = hexdec(substr($line_color, 1, 2));
$green = hexdec(substr($line_color, 3, 2));
$blue = hexdec(substr($line_color, 4, 2));
$red = hexdec($pmaString->substr($line_color, 1, 2));
$green = hexdec($pmaString->substr($line_color, 3, 2));
$blue = hexdec($pmaString->substr($line_color, 4, 2));
$color = imagecolorallocate($image, $red, $green, $blue);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'LINESTRING(' and trailing ')'
$linesrting = substr($spatial, 11, (strlen($spatial) - 12));
$linesrting = $pmaString->substr(
$spatial,
11,
$pmaString->strlen($spatial) - 12
);
$points_arr = $this->extractPoints($linesrting, $scale_data);
foreach ($points_arr as $point) {
@ -122,14 +139,21 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
*/
public function prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// allocate colors
$red = hexdec(substr($line_color, 1, 2));
$green = hexdec(substr($line_color, 3, 2));
$blue = hexdec(substr($line_color, 4, 2));
$red = hexdec($pmaString->substr($line_color, 1, 2));
$green = hexdec($pmaString->substr($line_color, 3, 2));
$blue = hexdec($pmaString->substr($line_color, 4, 2));
$line = array('width' => 1.5, 'color' => array($red, $green, $blue));
// Trim to remove leading 'LINESTRING(' and trailing ')'
$linesrting = substr($spatial, 11, (strlen($spatial) - 12));
$linesrting = $pmaString->substr(
$spatial,
11,
$pmaString->strlen($spatial) - 12
);
$points_arr = $this->extractPoints($linesrting, $scale_data);
foreach ($points_arr as $point) {
@ -175,8 +199,15 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
'stroke-width'=> 2,
);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'LINESTRING(' and trailing ')'
$linesrting = substr($spatial, 11, (strlen($spatial) - 12));
$linesrting = $pmaString->substr(
$spatial,
11,
$pmaString->strlen($spatial) - 12
);
$points_arr = $this->extractPoints($linesrting, $scale_data);
$row = '<polyline points="';
@ -218,8 +249,15 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
}
$result = $this->getBoundsForOl($srid, $scale_data);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'LINESTRING(' and trailing ')'
$linesrting = substr($spatial, 11, (strlen($spatial) - 12));
$linesrting = $pmaString->substr(
$spatial,
11,
$pmaString->strlen($spatial) - 12
);
$points_arr = $this->extractPoints($linesrting, null);
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
@ -254,7 +292,10 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
&& trim($gis_data[$index]['LINESTRING'][$i]['y']) != '')
? $gis_data[$index]['LINESTRING'][$i]['y'] : $empty) . ',';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$wkt = $pmaString->substr($wkt, 0, $pmaString->strlen($wkt) - 1);
$wkt .= ')';
return $wkt;
}
@ -281,8 +322,11 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
$wkt = $value;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'LINESTRING(' and trailing ')'
$linestring = substr($wkt, 11, (strlen($wkt) - 12));
$linestring = $pmaString->substr($wkt, 11, ($pmaString->strlen($wkt) - 12));
$points_arr = $this->extractPoints($linestring, null);
$no_of_points = count($points_arr);

View File

@ -57,8 +57,15 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
{
$min_max = array();
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
$multilinestirng = substr($spatial, 17, (strlen($spatial) - 19));
$multilinestirng = $pmaString->substr(
$spatial,
17,
$pmaString->strlen($spatial) - 19
);
// Separate each linestring
$linestirngs = explode("),(", $multilinestirng);
@ -84,16 +91,23 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
public function prepareRowAsPng($spatial, $label, $line_color,
$scale_data, $image
) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// allocate colors
$black = imagecolorallocate($image, 0, 0, 0);
$red = hexdec(substr($line_color, 1, 2));
$green = hexdec(substr($line_color, 3, 2));
$blue = hexdec(substr($line_color, 4, 2));
$red = hexdec($pmaString->substr($line_color, 1, 2));
$green = hexdec($pmaString->substr($line_color, 3, 2));
$blue = hexdec($pmaString->substr($line_color, 4, 2));
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
$multilinestirng = substr($spatial, 17, (strlen($spatial) - 19));
// Seperate each linestring
$multilinestirng = $pmaString->substr(
$spatial,
17,
$pmaString->strlen($spatial) - 19
);
// Separate each linestring
$linestirngs = explode("),(", $multilinestirng);
$first_line = true;
@ -138,15 +152,21 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
*/
public function prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// allocate colors
$red = hexdec(substr($line_color, 1, 2));
$green = hexdec(substr($line_color, 3, 2));
$blue = hexdec(substr($line_color, 4, 2));
$red = hexdec($pmaString->substr($line_color, 1, 2));
$green = hexdec($pmaString->substr($line_color, 3, 2));
$blue = hexdec($pmaString->substr($line_color, 4, 2));
$line = array('width' => 1.5, 'color' => array($red, $green, $blue));
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
$multilinestirng = substr($spatial, 17, (strlen($spatial) - 19));
// Seperate each linestring
$multilinestirng = $pmaString->substr(
$spatial,
17, $pmaString->strlen($spatial) - 19
);
// Separate each linestring
$linestirngs = explode("),(", $multilinestirng);
$first_line = true;
@ -196,9 +216,16 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
'stroke-width'=> 2,
);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
$multilinestirng = substr($spatial, 17, (strlen($spatial) - 19));
// Seperate each linestring
$multilinestirng = $pmaString->substr(
$spatial,
17,
$pmaString->strlen($spatial) - 19
);
// Separate each linestring
$linestirngs = explode("),(", $multilinestirng);
$row = '';
@ -246,9 +273,16 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
}
$row = $this->getBoundsForOl($srid, $scale_data);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
$multilinestirng = substr($spatial, 17, (strlen($spatial) - 19));
// Seperate each linestring
$multilinestirng = $pmaString->substr(
$spatial,
17,
$pmaString->strlen($spatial) - 19
);
// Separate each linestring
$linestirngs = explode("),(", $multilinestirng);
$row .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
@ -277,6 +311,10 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
if ($no_of_lines < 1) {
$no_of_lines = 1;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$wkt = 'MULTILINESTRING(';
for ($i = 0; $i < $no_of_lines; $i++) {
$no_of_points = isset($data_row[$i]['no_of_points'])
@ -293,10 +331,10 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
&& trim($data_row[$i][$j]['y']) != '')
? $data_row[$i][$j]['y'] : $empty) . ',';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt = $pmaString->substr($wkt, 0, $pmaString->strlen($wkt) - 1);
$wkt .= '),';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt = $pmaString->substr($wkt, 0, $pmaString->strlen($wkt) - 1);
$wkt .= ')';
return $wkt;
}
@ -311,16 +349,19 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
*/
public function getShape($row_data)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$wkt = 'MULTILINESTRING(';
for ($i = 0; $i < $row_data['numparts']; $i++) {
$wkt .= '(';
foreach ($row_data['parts'][$i]['points'] as $point) {
$wkt .= $point['x'] . ' ' . $point['y'] . ',';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt = $pmaString->substr($wkt, 0, $pmaString->strlen($wkt) - 1);
$wkt .= '),';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt = $pmaString->substr($wkt, 0, $pmaString->strlen($wkt) - 1);
$wkt .= ')';
return $wkt;
}
@ -347,8 +388,15 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
$wkt = $value;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
$multilinestirng = substr($wkt, 17, (strlen($wkt) - 19));
$multilinestirng = $pmaString->substr(
$wkt,
17,
$pmaString->strlen($wkt) - 19
);
// Seperate each linestring
$linestirngs = explode("),(", $multilinestirng);
$params[$index]['MULTILINESTRING']['no_of_lines'] = count($linestirngs);

View File

@ -55,8 +55,11 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
*/
public function scaleRow($spatial)
{
/** @var PMA_String $pmaStr */
$pmaStr = $GLOBALS['PMA_String'];
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
$multipoint = substr($spatial, 11, (strlen($spatial) - 12));
$multipoint = $pmaStr->substr($spatial, 11, $pmaStr->strlen($spatial) - 12);
return $this->setMinMax($multipoint, array());
}
@ -75,15 +78,22 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
public function prepareRowAsPng($spatial, $label, $point_color,
$scale_data, $image
) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// allocate colors
$black = imagecolorallocate($image, 0, 0, 0);
$red = hexdec(substr($point_color, 1, 2));
$green = hexdec(substr($point_color, 3, 2));
$blue = hexdec(substr($point_color, 4, 2));
$red = hexdec($pmaString->substr($point_color, 1, 2));
$green = hexdec($pmaString->substr($point_color, 3, 2));
$blue = hexdec($pmaString->substr($point_color, 4, 2));
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
$multipoint = substr($spatial, 11, (strlen($spatial) - 12));
$multipoint = $pmaString->substr(
$spatial,
11,
$pmaString->strlen($spatial) - 12
);
$points_arr = $this->extractPoints($multipoint, $scale_data);
foreach ($points_arr as $point) {
@ -118,14 +128,21 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
public function prepareRowAsPdf($spatial, $label, $point_color,
$scale_data, $pdf
) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// allocate colors
$red = hexdec(substr($point_color, 1, 2));
$green = hexdec(substr($point_color, 3, 2));
$blue = hexdec(substr($point_color, 4, 2));
$red = hexdec($pmaString->substr($point_color, 1, 2));
$green = hexdec($pmaString->substr($point_color, 3, 2));
$blue = hexdec($pmaString->substr($point_color, 4, 2));
$line = array('width' => 1.25, 'color' => array($red, $green, $blue));
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
$multipoint = substr($spatial, 11, (strlen($spatial) - 12));
$multipoint = $pmaString->substr(
$spatial,
11,
$pmaString->strlen($spatial) - 12
);
$points_arr = $this->extractPoints($multipoint, $scale_data);
foreach ($points_arr as $point) {
@ -166,8 +183,15 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
'stroke-width'=> 2,
);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
$multipoint = substr($spatial, 11, (strlen($spatial) - 12));
$multipoint = $pmaString->substr(
$spatial,
11,
$pmaString->strlen($spatial) - 12
);
$points_arr = $this->extractPoints($multipoint, $scale_data);
$row = '';
@ -216,8 +240,15 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
}
$result = $this->getBoundsForOl($srid, $scale_data);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
$multipoint = substr($spatial, 11, (strlen($spatial) - 12));
$multipoint = $pmaString->substr(
$spatial,
11,
$pmaString->strlen($spatial) - 12
);
$points_arr = $this->extractPoints($multipoint, null);
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
@ -253,7 +284,11 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
&& trim($gis_data[$index]['MULTIPOINT'][$i]['y']) != '')
? $gis_data[$index]['MULTIPOINT'][$i]['y'] : '') . ',';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$wkt = $pmaString->substr($wkt, 0, $pmaString->strlen($wkt) - 1);
$wkt .= ')';
return $wkt;
}
@ -273,7 +308,11 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
$wkt .= $row_data['points'][$i]['x'] . ' '
. $row_data['points'][$i]['y'] . ',';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$wkt = $pmaString->substr($wkt, 0, $pmaString->strlen($wkt) - 1);
$wkt .= ')';
return $wkt;
}
@ -300,8 +339,11 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
$wkt = $value;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
$points = substr($wkt, 11, (strlen($wkt) - 12));
$points = $pmaString->substr($wkt, 11, $pmaString->strlen($wkt) - 12);
$points_arr = $this->extractPoints($points, null);
$no_of_points = count($points_arr);
@ -332,8 +374,13 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
$ol_array .= $this->getPointForOpenLayers($point, $srid) . ', ';
}
}
if (substr($ol_array, strlen($ol_array) - 2) == ', ') {
$ol_array = substr($ol_array, 0, strlen($ol_array) - 2);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$olArrayLength = $pmaString->strlen($ol_array);
if ($pmaString->substr($ol_array, $olArrayLength - 2) == ', ') {
$ol_array = $pmaString->substr($ol_array, 0, $olArrayLength - 2);
}
$ol_array .= ')';

View File

@ -55,19 +55,26 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
*/
public function scaleRow($spatial)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$min_max = array();
// Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
$multipolygon = substr($spatial, 15, (strlen($spatial) - 18));
// Seperate each polygon
$multipolygon = $pmaString->substr(
$spatial,
15,
$pmaString->strlen($spatial) - 18
);
// Separate each polygon
$polygons = explode(")),((", $multipolygon);
foreach ($polygons as $polygon) {
// If the polygon doesn't have an inner ring, use polygon itself
if (strpos($polygon, "),(") === false) {
if ($pmaString->strpos($polygon, "),(") === false) {
$ring = $polygon;
} else {
// Seperate outer ring and use it to determin min-max
// Separate outer ring and use it to determine min-max
$parts = explode("),(", $polygon);
$ring = $parts[0];
}
@ -92,25 +99,32 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
public function prepareRowAsPng($spatial, $label, $fill_color,
$scale_data, $image
) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// allocate colors
$black = imagecolorallocate($image, 0, 0, 0);
$red = hexdec(substr($fill_color, 1, 2));
$green = hexdec(substr($fill_color, 3, 2));
$blue = hexdec(substr($fill_color, 4, 2));
$red = hexdec($pmaString->substr($fill_color, 1, 2));
$green = hexdec($pmaString->substr($fill_color, 3, 2));
$blue = hexdec($pmaString->substr($fill_color, 4, 2));
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
$multipolygon = substr($spatial, 15, (strlen($spatial) - 18));
// Seperate each polygon
$multipolygon = $pmaString->substr(
$spatial,
15,
$pmaString->strlen($spatial) - 18
);
// Separate each polygon
$polygons = explode(")),((", $multipolygon);
$first_poly = true;
foreach ($polygons as $polygon) {
// If the polygon doesnt have an inner polygon
if (strpos($polygon, "),(") === false) {
// If the polygon doesn't have an inner polygon
if ($pmaString->strpos($polygon, "),(") === false) {
$points_arr = $this->extractPoints($polygon, $scale_data, true);
} else {
// Seperate outer and inner polygons
// Separate outer and inner polygons
$parts = explode("),(", $polygon);
$outer = $parts[0];
$inner = array_slice($parts, 1);
@ -155,24 +169,31 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
*/
public function prepareRowAsPdf($spatial, $label, $fill_color, $scale_data, $pdf)
{
/** @var PMA_String $pmaStr */
$pmaStr = $GLOBALS['PMA_String'];
// allocate colors
$red = hexdec(substr($fill_color, 1, 2));
$green = hexdec(substr($fill_color, 3, 2));
$blue = hexdec(substr($fill_color, 4, 2));
$red = hexdec($pmaStr->substr($fill_color, 1, 2));
$green = hexdec($pmaStr->substr($fill_color, 3, 2));
$blue = hexdec($pmaStr->substr($fill_color, 4, 2));
$color = array($red, $green, $blue);
// Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
$multipolygon = substr($spatial, 15, (strlen($spatial) - 18));
// Seperate each polygon
$multipolygon = $pmaStr->substr(
$spatial,
15,
$pmaStr->strlen($spatial) - 18
);
// Separate each polygon
$polygons = explode(")),((", $multipolygon);
$first_poly = true;
foreach ($polygons as $polygon) {
// If the polygon doesnt have an inner polygon
if (strpos($polygon, "),(") === false) {
// If the polygon doesn't have an inner polygon
if ($pmaStr->strpos($polygon, "),(") === false) {
$points_arr = $this->extractPoints($polygon, $scale_data, true);
} else {
// Seperate outer and inner polygons
// Separate outer and inner polygons
$parts = explode("),(", $polygon);
$outer = $parts[0];
$inner = array_slice($parts, 1);
@ -229,16 +250,23 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
$row = '';
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
$multipolygon = substr($spatial, 15, (strlen($spatial) - 18));
// Seperate each polygon
$multipolygon = $pmaString->substr(
$spatial,
15,
$pmaString->strlen($spatial) - 18
);
// Separate each polygon
$polygons = explode(")),((", $multipolygon);
foreach ($polygons as $polygon) {
$row .= '<path d="';
// If the polygon doesnt have an inner polygon
if (strpos($polygon, "),(") === false) {
if ($pmaString->strpos($polygon, "),(") === false) {
$row .= $this->_drawPath($polygon, $scale_data);
} else {
// Seperate outer and inner polygons
@ -291,9 +319,16 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
}
$row = $this->getBoundsForOl($srid, $scale_data);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
$multipolygon = substr($spatial, 15, (strlen($spatial) - 18));
// Seperate each polygon
$multipolygon = $pmaString->substr(
$spatial,
15,
$pmaString->strlen($spatial) - 18
);
// Separate each polygon
$polygons = explode(")),((", $multipolygon);
$row .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
@ -346,6 +381,9 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
$no_of_polygons = 1;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$wkt = 'MULTIPOLYGON(';
for ($k = 0; $k < $no_of_polygons; $k++) {
$no_of_lines = isset($data_row[$k]['no_of_lines'])
@ -369,13 +407,13 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
&& trim($data_row[$k][$i][$j]['y']) != '')
? $data_row[$k][$i][$j]['y'] : $empty) . ',';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt = $pmaString->substr($wkt, 0, $pmaString->strlen($wkt) - 1);
$wkt .= '),';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt = $pmaString->substr($wkt, 0, $pmaString->strlen($wkt) - 1);
$wkt .= '),';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt = $pmaString->substr($wkt, 0, $pmaString->strlen($wkt) - 1);
$wkt .= ')';
return $wkt;
}
@ -430,6 +468,9 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
}
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$wkt = 'MULTIPOLYGON(';
// for each polygon
foreach ($row_data['parts'] as $ring) {
@ -443,7 +484,7 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
foreach ($ring['points'] as $point) {
$wkt .= $point['x'] . ' ' . $point['y'] . ',';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt = $pmaString->substr($wkt, 0, $pmaString->strlen($wkt) - 1);
$wkt .= ')'; // end of outer ring
// inner rings if any
@ -453,14 +494,14 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
foreach ($row_data['parts'][$j]['points'] as $innerPoint) {
$wkt .= $innerPoint['x'] . ' ' . $innerPoint['y'] . ',';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt = $pmaString->substr($wkt, 0, $pmaString->strlen($wkt) - 1);
$wkt .= ')'; // end of inner ring
}
}
$wkt .= '),'; // end of polygon
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt = $pmaString->substr($wkt, 0, $pmaString->strlen($wkt) - 1);
$wkt .= ')'; // end of multipolygon
return $wkt;
@ -488,9 +529,12 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
$wkt = $value;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
$multipolygon = substr($wkt, 15, (strlen($wkt) - 18));
// Seperate each polygon
$multipolygon = $pmaString->substr($wkt, 15, $pmaString->strlen($wkt) - 18);
// Separate each polygon
$polygons = explode(")),((", $multipolygon);
$param_row =& $params[$index]['MULTIPOLYGON'];
@ -499,7 +543,7 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
$k = 0;
foreach ($polygons as $polygon) {
// If the polygon doesnt have an inner polygon
if (strpos($polygon, "),(") === false) {
if ($pmaString->strpos($polygon, "),(") === false) {
$param_row[$k]['no_of_lines'] = 1;
$points_arr = $this->extractPoints($polygon, null);
$no_of_points = count($points_arr);
@ -509,7 +553,7 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
$param_row[$k][0][$i]['y'] = $points_arr[$i][1];
}
} else {
// Seperate outer and inner polygons
// Separate outer and inner polygons
$parts = explode("),(", $polygon);
$param_row[$k]['no_of_lines'] = count($parts);
$j = 0;

View File

@ -55,8 +55,11 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
*/
public function scaleRow($spatial)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'POINT(' and trailing ')'
$point = substr($spatial, 6, (strlen($spatial) - 7));
$point = $pmaString->substr($spatial, 6, $pmaString->strlen($spatial) - 7);
return $this->setMinMax($point, array());
}
@ -75,15 +78,18 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
public function prepareRowAsPng($spatial, $label, $point_color,
$scale_data, $image
) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// allocate colors
$black = imagecolorallocate($image, 0, 0, 0);
$red = hexdec(substr($point_color, 1, 2));
$green = hexdec(substr($point_color, 3, 2));
$blue = hexdec(substr($point_color, 4, 2));
$red = hexdec($pmaString->substr($point_color, 1, 2));
$green = hexdec($pmaString->substr($point_color, 3, 2));
$blue = hexdec($pmaString->substr($point_color, 4, 2));
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'POINT(' and trailing ')'
$point = substr($spatial, 6, (strlen($spatial) - 7));
$point = $pmaString->substr($spatial, 6, $pmaString->strlen($spatial) - 7);
$points_arr = $this->extractPoints($point, $scale_data);
// draw a small circle to mark the point
@ -117,14 +123,17 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
public function prepareRowAsPdf($spatial, $label, $point_color,
$scale_data, $pdf
) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// allocate colors
$red = hexdec(substr($point_color, 1, 2));
$green = hexdec(substr($point_color, 3, 2));
$blue = hexdec(substr($point_color, 4, 2));
$red = hexdec($pmaString->substr($point_color, 1, 2));
$green = hexdec($pmaString->substr($point_color, 3, 2));
$blue = hexdec($pmaString->substr($point_color, 4, 2));
$line = array('width' => 1.25, 'color' => array($red, $green, $blue));
// Trim to remove leading 'POINT(' and trailing ')'
$point = substr($spatial, 6, (strlen($spatial) - 7));
$point = $pmaString->substr($spatial, 6, $pmaString->strlen($spatial) - 7);
$points_arr = $this->extractPoints($point, $scale_data);
// draw a small circle to mark the point
@ -164,8 +173,11 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
'stroke-width'=> 2,
);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'POINT(' and trailing ')'
$point = substr($spatial, 6, (strlen($spatial) - 7));
$point = $pmaString->substr($spatial, 6, $pmaString->strlen($spatial) - 7);
$points_arr = $this->extractPoints($point, $scale_data);
$row = '';
@ -211,8 +223,11 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
}
$result = $this->getBoundsForOl($srid, $scale_data);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'POINT(' and trailing ')'
$point = substr($spatial, 6, (strlen($spatial) - 7));
$point = $pmaString->substr($spatial, 6, $pmaString->strlen($spatial) - 7);
$points_arr = $this->extractPoints($point, null);
if ($points_arr[0][0] != '' && $points_arr[0][1] != '') {
@ -281,8 +296,11 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
$wkt = $value;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'POINT(' and trailing ')'
$point = substr($wkt, 6, (strlen($wkt) - 7));
$point = $pmaString->substr($wkt, 6, $pmaString->strlen($wkt) - 7);
$points_arr = $this->extractPoints($point, null);
$params[$index]['POINT']['x'] = $points_arr[0][0];

View File

@ -55,14 +55,21 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
*/
public function scaleRow($spatial)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = substr($spatial, 9, (strlen($spatial) - 11));
$polygon = $pmaString->substr(
$spatial,
9,
$pmaString->strlen($spatial) - 11
);
// If the polygon doesn't have an inner ring, use polygon itself
if (strpos($polygon, "),(") === false) {
if ($pmaString->strpos($polygon, "),(") === false) {
$ring = $polygon;
} else {
// Seperate outer ring and use it to determin min-max
// Separate outer ring and use it to determine min-max
$parts = explode("),(", $polygon);
$ring = $parts[0];
}
@ -84,21 +91,28 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
public function prepareRowAsPng($spatial, $label, $fill_color,
$scale_data, $image
) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// allocate colors
$black = imagecolorallocate($image, 0, 0, 0);
$red = hexdec(substr($fill_color, 1, 2));
$green = hexdec(substr($fill_color, 3, 2));
$blue = hexdec(substr($fill_color, 4, 2));
$red = hexdec($pmaString->substr($fill_color, 1, 2));
$green = hexdec($pmaString->substr($fill_color, 3, 2));
$blue = hexdec($pmaString->substr($fill_color, 4, 2));
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = substr($spatial, 9, (strlen($spatial) - 11));
$polygon = $pmaString->substr(
$spatial,
9,
$pmaString->strlen($spatial) - 11
);
// If the polygon doesnt have an inner polygon
if (strpos($polygon, "),(") === false) {
// If the polygon doesn't have an inner polygon
if ($pmaString->strpos($polygon, "),(") === false) {
$points_arr = $this->extractPoints($polygon, $scale_data, true);
} else {
// Seperate outer and inner polygons
// Separate outer and inner polygons
$parts = explode("),(", $polygon);
$outer = $parts[0];
$inner = array_slice($parts, 1);
@ -137,20 +151,23 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
*/
public function prepareRowAsPdf($spatial, $label, $fill_color, $scale_data, $pdf)
{
/** @var PMA_String $pmaStr */
$pmaStr = $GLOBALS['PMA_String'];
// allocate colors
$red = hexdec(substr($fill_color, 1, 2));
$green = hexdec(substr($fill_color, 3, 2));
$blue = hexdec(substr($fill_color, 4, 2));
$red = hexdec($pmaStr->substr($fill_color, 1, 2));
$green = hexdec($pmaStr->substr($fill_color, 3, 2));
$blue = hexdec($pmaStr->substr($fill_color, 4, 2));
$color = array($red, $green, $blue);
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = substr($spatial, 9, (strlen($spatial) - 11));
$polygon = $pmaStr->substr($spatial, 9, $pmaStr->strlen($spatial) - 11);
// If the polygon doesnt have an inner polygon
if (strpos($polygon, "),(") === false) {
// If the polygon doesn't have an inner polygon
if ($pmaStr->strpos($polygon, "),(") === false) {
$points_arr = $this->extractPoints($polygon, $scale_data, true);
} else {
// Seperate outer and inner polygons
// Separate outer and inner polygons
$parts = explode("),(", $polygon);
$outer = $parts[0];
$inner = array_slice($parts, 1);
@ -199,16 +216,23 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
'fill-opacity'=> 0.8,
);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = substr($spatial, 9, (strlen($spatial) - 11));
$polygon = $pmaString->substr(
$spatial,
9,
$pmaString->strlen($spatial) - 11
);
$row = '<path d="';
// If the polygon doesnt have an inner polygon
if (strpos($polygon, "),(") === false) {
if ($pmaString->strpos($polygon, "),(") === false) {
$row .= $this->_drawPath($polygon, $scale_data);
} else {
// Seperate outer and inner polygons
// Separate outer and inner polygons
$parts = explode("),(", $polygon);
$outer = $parts[0];
$inner = array_slice($parts, 1);
@ -256,10 +280,17 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
}
$row = $this->getBoundsForOl($srid, $scale_data);
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = substr($spatial, 9, (strlen($spatial) - 11));
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Seperate outer and inner polygons
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = $pmaString->substr(
$spatial,
9,
$pmaString->strlen($spatial) - 11
);
// Separate outer and inner polygons
$parts = explode("),(", $polygon);
$row .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
. $this->getPolygonForOpenLayers($parts, $srid)
@ -307,6 +338,10 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
if ($no_of_lines < 1) {
$no_of_lines = 1;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$wkt = 'POLYGON(';
for ($i = 0; $i < $no_of_lines; $i++) {
$no_of_points = isset($gis_data[$index]['POLYGON'][$i]['no_of_points'])
@ -323,10 +358,10 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
&& trim($gis_data[$index]['POLYGON'][$i][$j]['y']) != '')
? $gis_data[$index]['POLYGON'][$i][$j]['y'] : $empty) . ',';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt = $pmaString->substr($wkt, 0, $pmaString->strlen($wkt) - 1);
$wkt .= '),';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt = $pmaString->substr($wkt, 0, $pmaString->strlen($wkt) - 1);
$wkt .= ')';
return $wkt;
}
@ -536,8 +571,11 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
$wkt = $value;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = substr($wkt, 9, (strlen($wkt) - 11));
$polygon = $pmaString->substr($wkt, 9, ($pmaString->strlen($wkt) - 11));
// Seperate each linestring
$linerings = explode("),(", $polygon);
$params[$index]['POLYGON']['no_of_lines'] = count($linerings);

View File

@ -126,14 +126,18 @@ class PMA_GIS_Visualization
{
$file_name = PMA_sanitizeFilename($file_name);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Check if the user already added extension;
// get the substring where the extension would be if it was included
$extension_start_pos = strlen($file_name) - strlen($ext) - 1;
$user_extension = substr(
$file_name, $extension_start_pos, strlen($file_name)
$extension_start_pos = $pmaString->strlen($file_name)
- $pmaString->strlen($ext) - 1;
$user_extension = $pmaString->substr(
$file_name, $extension_start_pos, $pmaString->strlen($file_name)
);
$required_extension = "." . $ext;
if (strtolower($user_extension) != $required_extension) {
if ($pmaString->strtolower($user_extension) != $required_extension) {
$file_name .= $required_extension;
}
return $file_name;
@ -370,12 +374,15 @@ class PMA_GIS_Visualization
$plot_width = $this->_settings['width'] - 2 * $border;
$plot_height = $this->_settings['height'] - 2 * $border;
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
foreach ($data as $row) {
// Figure out the data type
$ref_data = $row[$this->_settings['spatialColumn']];
$type_pos = stripos($ref_data, '(');
$type = substr($ref_data, 0, $type_pos);
$type_pos = $pmaString->stripos($ref_data, '(');
$type = $pmaString->substr($ref_data, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
@ -385,7 +392,7 @@ class PMA_GIS_Visualization
$row[$this->_settings['spatialColumn']]
);
// Upadate minimum/maximum values for x and y cordinates.
// Update minimum/maximum values for x and y cordinates.
$c_maxX = (float) $scale_data['maxX'];
if (! isset($min_max['maxX']) || $c_maxX > $min_max['maxX']) {
$min_max['maxX'] = $c_maxX;
@ -454,14 +461,17 @@ class PMA_GIS_Visualization
{
$color_number = 0;
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// loop through the rows
foreach ($data as $row) {
$index = $color_number % sizeof($this->_settings['colors']);
// Figure out the data type
$ref_data = $row[$this->_settings['spatialColumn']];
$type_pos = stripos($ref_data, '(');
$type = substr($ref_data, 0, $type_pos);
$type_pos = $pmaString->stripos($ref_data, '(');
$type = $pmaString->substr($ref_data, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {

View File

@ -75,40 +75,51 @@ function PMA_convertAIXMapCharsets($in_charset, $out_charset)
{
global $gnu_iconv_to_aix_iconv_codepage_map;
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// Check for transliteration argument at the end of output character set name
$translit_search = strpos(strtolower($out_charset), '//translit');
$translit_search = $pmaString->strpos(
$pmaString->strtolower($out_charset),
'//translit'
);
$using_translit = (!($translit_search === false));
// Extract "plain" output character set name
// (without any transliteration argument)
$out_charset_plain = ($using_translit
? substr($out_charset, 0, $translit_search)
? $pmaString->substr($out_charset, 0, $translit_search)
: $out_charset);
// Transform name of input character set (if found)
$in_charset_exisits = array_key_exists(
strtolower($in_charset),
$pmaString->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)];
$in_charset = $gnu_iconv_to_aix_iconv_codepage_map[
$pmaString->strtolower($in_charset)
];
}
// Transform name of "plain" output character set (if found)
$out_charset_plain_exists = array_key_exists(
strtolower($out_charset_plain),
$pmaString->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)];
$pmaString->strtolower($out_charset_plain)
];
}
// Add transliteration argument again (exactly as specified by user) if used
// Build the output character set name that we will use
/* Not needed because always overwritten
$out_charset = ($using_translit
? $out_charset_plain . substr($out_charset, $translit_search)
? $out_charset_plain . $pmaString->substr($out_charset, $translit_search)
: $out_charset_plain);
*/
// NOTE: Transliteration not supported; we will use the "plain"
// output character set name

View File

@ -97,6 +97,8 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false,
return;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if (! empty($import_run_buffer['sql'])
&& trim($import_run_buffer['sql']) != ''
) {
@ -104,11 +106,14 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false,
// USE query changes the database, son need to track
// while running multiple queries
$is_use_query
= (stripos($import_run_buffer['sql'], "use ") !== false)
= ($pmaString->stripos($import_run_buffer['sql'], "use ") !== false)
? true
: false;
$max_sql_len = max($max_sql_len, strlen($import_run_buffer['sql']));
$max_sql_len = max(
$max_sql_len,
$pmaString->strlen($import_run_buffer['sql'])
);
if (! $sql_query_disabled) {
$sql_query .= $import_run_buffer['full'];
}
@ -250,7 +255,7 @@ 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
if ($pmaString->strlen($sql_query) > 50000
|| $executed_queries > 50
|| $max_sql_len > 1000
) {
@ -350,16 +355,19 @@ function PMA_importGetNextChunk($size = 32768)
return true;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($GLOBALS['import_file'] == 'none') {
// Well this is not yet supported and tested,
// but should return content of textarea
if (strlen($GLOBALS['import_text']) < $size) {
if ($pmaString->strlen($GLOBALS['import_text']) < $size) {
$GLOBALS['finished'] = true;
return $GLOBALS['import_text'];
} else {
$r = substr($GLOBALS['import_text'], 0, $size);
$r = $pmaString->substr($GLOBALS['import_text'], 0, $size);
$GLOBALS['offset'] += $size;
$GLOBALS['import_text'] = substr($GLOBALS['import_text'], $size);
$GLOBALS['import_text'] = $pmaString
->substr($GLOBALS['import_text'], $size);
return $r;
}
}
@ -374,8 +382,8 @@ function PMA_importGetNextChunk($size = 32768)
$GLOBALS['finished'] = feof($import_handle);
break;
case 'application/zip':
$result = substr($GLOBALS['import_text'], 0, $size);
$GLOBALS['import_text'] = substr($GLOBALS['import_text'], $size);
$result = $pmaString->substr($GLOBALS['import_text'], 0, $size);
$GLOBALS['import_text'] = $pmaString->substr($GLOBALS['import_text'], $size);
$GLOBALS['finished'] = empty($GLOBALS['import_text']);
break;
case 'none':
@ -399,12 +407,12 @@ function PMA_importGetNextChunk($size = 32768)
if ($GLOBALS['offset'] == $size) {
// UTF-8
if (strncmp($result, "\xEF\xBB\xBF", 3) == 0) {
$result = substr($result, 3);
$result = $pmaString->substr($result, 3);
// UTF-16 BE, LE
} elseif (strncmp($result, "\xFE\xFF", 2) == 0
|| strncmp($result, "\xFF\xFE", 2) == 0
) {
$result = substr($result, 2);
$result = $pmaString->substr($result, 2);
}
}
return $result;
@ -456,13 +464,16 @@ function PMA_getColumnAlphaName($num)
$num = $remain;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($num == 0) {
// use 'Z' if column number is 0,
// this is necessary because A-Z has no 'zero'
$col_name .= chr(($A + 26) - 1);
$col_name .= $pmaString->chr(($A + 26) - 1);
} else {
// convert column number to ASCII character
$col_name .= chr(($A + $num) - 1);
$col_name .= $pmaString->chr(($A + $num) - 1);
}
return $col_name;
@ -488,8 +499,10 @@ function PMA_getColumnNumberFromName($name)
return 0;
}
$name = strtoupper($name);
$num_chars = strlen($name);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$name = $pmaString->strtoupper($name);
$num_chars = $pmaString->strlen($name);
$column_number = 0;
for ($i = 0; $i < $num_chars; ++$i) {
// read string from back to front
@ -499,7 +512,7 @@ function PMA_getColumnNumberFromName($name)
// 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);
$number = (int)($pmaString->ord($name[$char_pos]) - 64);
// base26 to base10 conversion : multiply each number
// with corresponding value of the position, in this case
@ -546,7 +559,13 @@ define("FORMATTEDSQL", 2);
*/
function PMA_getDecimalPrecision($last_cumulative_size)
{
return (int)substr($last_cumulative_size, 0, strpos($last_cumulative_size, ","));
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
return (int)$pmaString->substr(
$last_cumulative_size,
0,
$pmaString->strpos($last_cumulative_size, ",")
);
}
/**
@ -560,10 +579,13 @@ function PMA_getDecimalPrecision($last_cumulative_size)
*/
function PMA_getDecimalScale($last_cumulative_size)
{
return (int) substr(
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
return (int) $pmaString->substr(
$last_cumulative_size,
(strpos($last_cumulative_size, ",") + 1),
(strlen($last_cumulative_size) - strpos($last_cumulative_size, ","))
($pmaString->strpos($last_cumulative_size, ",") + 1),
($pmaString->strlen($last_cumulative_size)
- $pmaString->strpos($last_cumulative_size, ","))
);
}
@ -578,8 +600,10 @@ function PMA_getDecimalScale($last_cumulative_size)
*/
function PMA_getDecimalSize($cell)
{
$curr_size = strlen((string)$cell);
$decPos = strpos($cell, ".");
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$curr_size = $pmaString->strlen((string)$cell);
$decPos = $pmaString->strpos($cell, ".");
$decPrecision = ($curr_size - 1) - $decPos;
$m = $curr_size - 1;
@ -606,7 +630,9 @@ function PMA_getDecimalSize($cell)
function PMA_detectSize($last_cumulative_size, $last_cumulative_type,
$curr_type, $cell
) {
$curr_size = strlen((string)$cell);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$curr_size = $pmaString->strlen((string)$cell);
/**
* If the cell is NULL, don't treat it as a varchar
@ -744,7 +770,7 @@ function PMA_detectSize($last_cumulative_size, $last_cumulative_type,
$oldM = PMA_getDecimalPrecision($last_cumulative_size);
$oldD = PMA_getDecimalScale($last_cumulative_size);
$oldInt = $oldM - $oldD;
$newInt = strlen((string)$cell);
$newInt = $pmaString->strlen((string)$cell);
/* See which has the larger integer length */
if ($oldInt >= $newInt) {
@ -817,22 +843,25 @@ function PMA_detectType($last_cumulative_type, $cell)
return $last_cumulative_type;
}
if (is_numeric($cell)) {
if ($cell == (string)(float)$cell
&& strpos($cell, ".") !== false
&& substr_count($cell, ".") == 1
) {
return DECIMAL;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if (abs($cell) > 2147483647) {
return BIGINT;
}
return INT;
if (!is_numeric($cell)) {
return VARCHAR;
}
return VARCHAR;
if ($cell == (string)(float)$cell
&& $pmaString->strpos($cell, ".") !== false
&& $pmaString->substrCount($cell, ".") == 1
) {
return DECIMAL;
}
if (abs($cell) > 2147483647) {
return BIGINT;
}
return INT;
}
/**

View File

@ -342,10 +342,13 @@ function PMA_getColumnTitle($column, $comments_map)
*/
function PMA_isColumnBinary($column)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// The type column.
// Fix for bug #3152931 'ENUM and SET cannot have "Binary" option'
if (stripos($column['Type'], 'binary') === 0
|| stripos($column['Type'], 'varbinary') === 0
if ($pmaString->stripos($column['Type'], 'binary') === 0
|| $pmaString->stripos($column['Type'], 'varbinary') === 0
) {
return stristr($column['Type'], 'binary');
} else {
@ -365,10 +368,13 @@ function PMA_isColumnBinary($column)
*/
function PMA_isColumnBlob($column)
{
if (stripos($column['Type'], 'blob') === 0
|| stripos($column['Type'], 'tinyblob') === 0
|| stripos($column['Type'], 'mediumblob') === 0
|| stripos($column['Type'], 'longblob') === 0
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->stripos($column['Type'], 'blob') === 0
|| $pmaString->stripos($column['Type'], 'tinyblob') === 0
|| $pmaString->stripos($column['Type'], 'mediumblob') === 0
|| $pmaString->stripos($column['Type'], 'longblob') === 0
) {
return stristr($column['Type'], 'blob');
} else {
@ -386,8 +392,11 @@ function PMA_isColumnBlob($column)
*/
function PMA_isColumnChar($column)
{
if (stripos($column['Type'], 'char') === 0
|| stripos($column['Type'], 'varchar') === 0
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->stripos($column['Type'], 'char') === 0
|| $pmaString->stripos($column['Type'], 'varchar') === 0
) {
return stristr($column['Type'], 'char');
} else {
@ -453,6 +462,9 @@ function PMA_getFunctionColumn($column, $is_upload, $column_name_appendix,
$unnullify_trigger, $no_support_types, $tabindex_for_function,
$tabindex, $idindex, $insert_mode
) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$html_output = '';
if (($GLOBALS['cfg']['ProtectBinary'] === 'blob'
&& $column['is_blob'] && !$is_upload)
@ -462,8 +474,8 @@ function PMA_getFunctionColumn($column, $is_upload, $column_name_appendix,
&& $column['is_binary'])
) {
$html_output .= '<td class="center">' . __('Binary') . '</td>' . "\n";
} elseif (strstr($column['True_Type'], 'enum')
|| strstr($column['True_Type'], 'set')
} elseif ($pmaString->strstr($column['True_Type'], 'enum')
|| $pmaString->strstr($column['True_Type'], 'set')
|| in_array($column['pma_type'], $no_support_types)
) {
$html_output .= '<td class="center">--</td>' . "\n";
@ -547,14 +559,16 @@ function PMA_getNullColumn($column, $column_name_appendix, $real_null_value,
*/
function PMA_getNullifyCodeForNullColumn($column, $foreigners, $foreignData)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$foreigner = PMA_searchColumnInForeigners($foreigners, $column['Field']);
if (strstr($column['True_Type'], 'enum')) {
if (strlen($column['Type']) > 20) {
if ($pmaString->strstr($column['True_Type'], 'enum')) {
if ($pmaString->strlen($column['Type']) > 20) {
$nullify_code = '1';
} else {
$nullify_code = '2';
}
} elseif (strstr($column['True_Type'], 'set')) {
} elseif ($pmaString->strstr($column['True_Type'], 'set')) {
$nullify_code = '3';
} elseif ($foreigners
&& $foreigner
@ -622,6 +636,8 @@ function PMA_getValueColumn($column, $backup_field, $column_name_appendix,
$data_type = $GLOBALS['PMA_Types']->getTypeClass($column['True_Type']);
$html_output = '';
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($foreignData['foreign_link'] == true) {
$html_output .= PMA_getForeignLink(
$column, $backup_field, $column_name_appendix,
@ -637,7 +653,7 @@ function PMA_getValueColumn($column, $backup_field, $column_name_appendix,
);
} elseif ($GLOBALS['cfg']['LongtextDoubleTextarea']
&& strstr($column['pma_type'], 'longtext')
&& $pmaString->strstr($column['pma_type'], 'longtext')
) {
$html_output = '&nbsp;</td>';
$html_output .= '</tr>';
@ -649,7 +665,7 @@ function PMA_getValueColumn($column, $backup_field, $column_name_appendix,
$special_chars_encoded, $data_type
);
} elseif (strstr($column['pma_type'], 'text')) {
} elseif ($pmaString->strstr($column['pma_type'], 'text')) {
$html_output .= PMA_getTextarea(
$column, $backup_field, $column_name_appendix, $unnullify_trigger,
@ -657,7 +673,7 @@ function PMA_getValueColumn($column, $backup_field, $column_name_appendix,
$special_chars_encoded, $data_type
);
$html_output .= "\n";
if (strlen($special_chars) > 32000) {
if ($pmaString->strlen($special_chars) > 32000) {
$html_output .= "</td>\n";
$html_output .= '<td>' . __(
'Because of its length,<br /> this column might not be editable.'
@ -827,7 +843,7 @@ function PMA_getTextarea($column, $backup_field, $column_name_appendix,
$extracted_columnspec = PMA_Util::extractColumnSpec($column['Type']);
$maxlength = $extracted_columnspec['spec_in_brackets'];
} elseif ($GLOBALS['cfg']['LongtextDoubleTextarea']
&& strstr($column['pma_type'], 'longtext')
&& $GLOBALS['PMA_String']->strstr($column['pma_type'], 'longtext')
) {
$textAreaRows = $GLOBALS['cfg']['TextareaRows'] * 2;
$textareaCols = $GLOBALS['cfg']['TextareaCols'] * 2;
@ -882,7 +898,7 @@ function PMA_getPmaTypeEnum($column, $backup_field, $column_name_appendix,
$html_output .= '<input type="hidden" name="fields'
. $column_name_appendix . '" value="" />';
$html_output .= "\n" . ' ' . $backup_field . "\n";
if (strlen($column['Type']) > 20) {
if ($GLOBALS['PMA_String']->strlen($column['Type']) > 20) {
$html_output .= PMA_getDropDownDependingOnLength(
$column, $column_name_appendix, $unnullify_trigger,
$tabindex, $tabindex_for_value, $idindex, $data, $column_enum_values
@ -1115,7 +1131,7 @@ function PMA_getBinaryAndBlobColumn(
$html_output .= __('Binary - do not edit');
if (isset($data)) {
$data_size = PMA_Util::formatByteDown(
strlen(stripslashes($data)), 3, 1
$GLOBALS['PMA_String']->strlen(stripslashes($data)), 3, 1
);
$html_output .= ' (' . $data_size[0] . ' ' . $data_size[1] . ')';
unset($data_size);
@ -1319,13 +1335,16 @@ function PMA_getValueColumnForOtherDatatypes($column, $default_char_editing,
$tabindex_for_value, $idindex, $text_dir, $special_chars_encoded, $data,
$extracted_columnspec
) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// HTML5 data-* attribute data-type
$data_type = $GLOBALS['PMA_Types']->getTypeClass($column['True_Type']);
$fieldsize = PMA_getColumnSize($column, $extracted_columnspec);
$html_output = $backup_field . "\n";
if ($column['is_char']
&& ($GLOBALS['cfg']['CharEditing'] == 'textarea'
|| strpos($data, "\n") !== false)
|| $pmaString->strpos($data, "\n") !== false)
) {
$html_output .= "\n";
$GLOBALS['cfg']['CharEditing'] = $default_char_editing;
@ -1344,11 +1363,11 @@ function PMA_getValueColumnForOtherDatatypes($column, $default_char_editing,
$html_output .= '<input type="hidden" name="auto_increment'
. $column_name_appendix . '" value="1" />';
}
if (substr($column['pma_type'], 0, 9) == 'timestamp') {
if ($pmaString->substr($column['pma_type'], 0, 9) == 'timestamp') {
$html_output .= '<input type="hidden" name="fields_type'
. $column_name_appendix . '" value="timestamp" />';
}
if (substr($column['pma_type'], 0, 8) == 'datetime') {
if ($pmaString->substr($column['pma_type'], 0, 8) == 'datetime') {
$html_output .= '<input type="hidden" name="fields_type'
. $column_name_appendix . '" value="datetime" />';
}
@ -1358,7 +1377,7 @@ function PMA_getValueColumnForOtherDatatypes($column, $default_char_editing,
}
if ($column['pma_type'] == 'date'
|| $column['pma_type'] == 'datetime'
|| substr($column['pma_type'], 0, 9) == 'timestamp'
|| $pmaString->substr($column['pma_type'], 0, 9) == 'timestamp'
) {
// the _3 suffix points to the date field
// the _2 suffix points to the corresponding NULL checkbox
@ -1671,6 +1690,9 @@ function PMA_getSpecialCharsAndBackupFieldForExistingRow(
$current_row, $column, $extracted_columnspec,
$real_null_value, $gis_data_types, $column_name_appendix, $as_is
) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$special_chars_encoded = '';
$data = null;
// (we are editing)
@ -1686,10 +1708,10 @@ function PMA_getSpecialCharsAndBackupFieldForExistingRow(
$current_row[$column['Field']],
$extracted_columnspec['spec_in_brackets']
);
} elseif ((substr($column['True_Type'], 0, 9) == 'timestamp'
} elseif (($pmaString->substr($column['True_Type'], 0, 9) == 'timestamp'
|| $column['True_Type'] == 'datetime'
|| $column['True_Type'] == 'time')
&& (strpos($current_row[$column['Field']], ".") === true)
&& ($pmaString->strpos($current_row[$column['Field']], ".") === true)
) {
$current_row[$column['Field']] = $as_is
? $current_row[$column['Field']]
@ -1732,7 +1754,7 @@ function PMA_getSpecialCharsAndBackupFieldForExistingRow(
&& $_REQUEST['default_action'] === 'insert'
) {
if ($column['Key'] === 'PRI'
&& strpos($column['Extra'], 'auto_increment') !== false
&& $pmaString->strpos($column['Extra'], 'auto_increment') !== false
) {
$data = $special_chars_encoded = $special_chars = null;
}
@ -1774,11 +1796,13 @@ function PMA_getSpecialCharsAndBackupFieldForInsertingMode(
$data = $column['Default'];
}
if ($column['True_Type'] == 'bit') {
$trueType = $column['True_Type'];
if ($trueType == 'bit') {
$special_chars = PMA_Util::convertBitDefaultValue($column['Default']);
} elseif (substr($column['True_Type'], 0, 9) == 'timestamp'
|| $column['True_Type'] == 'datetime'
|| $column['True_Type'] == 'time'
} elseif ($GLOBALS['PMA_String']->substr($trueType, 0, 9) == 'timestamp'
|| $trueType == 'datetime'
|| $trueType == 'time'
) {
$special_chars = PMA_Util::addMicroseconds($column['Default']);
} else {
@ -1885,6 +1909,9 @@ function PMA_setSessionForEditNext($one_where_clause)
*/
function PMA_getGotoInclude($goto_include)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$valid_options = array('new_insert', 'same_insert', 'edit_next');
if (isset($_REQUEST['after_insert'])
&& in_array($_REQUEST['after_insert'], $valid_options)
@ -1898,12 +1925,14 @@ function PMA_getGotoInclude($goto_include)
} else {
$goto_include = $GLOBALS['goto'];
}
if ($GLOBALS['goto'] == 'db_sql.php' && strlen($GLOBALS['table'])) {
if ($GLOBALS['goto'] == 'db_sql.php'
&& $pmaString->strlen($GLOBALS['table'])
) {
$GLOBALS['table'] = '';
}
}
if (! $goto_include) {
if (! strlen($GLOBALS['table'])) {
if (! $pmaString->strlen($GLOBALS['table'])) {
$goto_include = 'db_sql.php';
} else {
$goto_include = 'tbl_sql.php';
@ -2062,7 +2091,7 @@ function PMA_getDisplayValueForForeignTableColumn($where_comparison,
$foreigner['foreign_table']
);
// Field to display from the foreign table?
if (isset($display_field) && strlen($display_field)) {
if (isset($display_field) && $GLOBALS['PMA_String']->strlen($display_field)) {
$dispsql = 'SELECT ' . PMA_Util::backquote($display_field)
. ' FROM ' . PMA_Util::backquote($foreigner['foreign_db'])
. '.' . PMA_Util::backquote($foreigner['foreign_table'])
@ -2201,6 +2230,9 @@ function PMA_getCurrentValueAsAnArrayForMultipleEdit( $multi_edit_funcs,
$gis_from_text_functions, $current_value, $gis_from_wkb_functions,
$func_optional_param, $func_no_param, $key
) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if (empty($multi_edit_funcs[$key])) {
return $current_value;
} elseif ('UUID' === $multi_edit_funcs[$key]) {
@ -2208,11 +2240,13 @@ function PMA_getCurrentValueAsAnArrayForMultipleEdit( $multi_edit_funcs,
$uuid = $GLOBALS['dbi']->fetchValue('SELECT UUID()');
return "'" . $uuid . "'";
} elseif ((in_array($multi_edit_funcs[$key], $gis_from_text_functions)
&& substr($current_value, 0, 3) == "'''")
&& $pmaString->substr($current_value, 0, 3) == "'''")
|| in_array($multi_edit_funcs[$key], $gis_from_wkb_functions)
) {
// Remove enclosing apostrophes
$current_value = substr($current_value, 1, strlen($current_value) - 2);
$current_value = $pmaString->substr(
$current_value, 1, $pmaString->strlen($current_value) - 2
);
// Remove escaping apostrophes
$current_value = str_replace("''", "'", $current_value);
return $multi_edit_funcs[$key] . '(' . $current_value . ')';
@ -2261,7 +2295,7 @@ function PMA_getQueryValuesForInsertAndUpdateInMultipleEdit($multi_edit_columns_
// i n s e r t
if ($is_insert) {
// no need to add column into the valuelist
if (strlen($current_value_as_an_array)) {
if ($GLOBALS['PMA_String']->strlen($current_value_as_an_array)) {
$query_values[] = $current_value_as_an_array;
// first inserted row so prepare the list of fields
if (empty($value_sets)) {
@ -2347,7 +2381,9 @@ function PMA_getCurrentValueForDifferentTypes($possibly_uploaded_val, $key,
$type = '';
}
if ($type != 'protected' && $type != 'set' && 0 === strlen($current_value)) {
if ($type != 'protected' && $type != 'set'
&& 0 === $GLOBALS['PMA_String']->strlen($current_value)
) {
// best way to avoid problems in strict mode
// (works also in non-strict mode)
if (isset($multi_edit_auto_increment)
@ -2441,7 +2477,7 @@ function PMA_verifyWhetherValueCanBeTruncatedAndAppendExtraData(
$meta = $fields_meta[0];
$new_value = $GLOBALS['dbi']->fetchValue($result);
if ($new_value !== false) {
if ((substr($meta->type, 0, 9) == 'timestamp')
if (($GLOBALS['PMA_String']->substr($meta->type, 0, 9) == 'timestamp')
|| ($meta->type == 'datetime')
|| ($meta->type == 'time')
) {
@ -2630,7 +2666,8 @@ function PMA_getHtmlForFunctionOption($odd_row, $column, $column_name_appendix)
$longDoubleTextArea = $GLOBALS['cfg']['LongtextDoubleTextarea'];
return '<tr class="noclick ' . ($odd_row ? 'odd' : 'even' ) . '">'
. '<td '
. ($longDoubleTextArea && strstr($column['True_Type'], 'longtext')
. ($longDoubleTextArea
&& $GLOBALS['PMA_String']->strstr($column['True_Type'], 'longtext')
? 'rowspan="2"'
: ''
)

View File

@ -67,7 +67,12 @@ function PMA_ipMaskTest($testRange, $ipToTest)
{
$result = true;
if (strpos($testRange, ':') > -1 || strpos($ipToTest, ':') > -1) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strpos($testRange, ':') > -1
|| $pmaString->strpos($ipToTest, ':') > -1
) {
// assume IPv6
$result = PMA_ipv6MaskTest($testRange, $ipToTest);
} else {
@ -178,12 +183,15 @@ function PMA_ipv6MaskTest($test_range, $ip_to_test)
{
$result = true;
// convert to lowercase for easier comparison
$test_range = strtolower($test_range);
$ip_to_test = strtolower($ip_to_test);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$is_cidr = strpos($test_range, '/') > -1;
$is_range = strpos($test_range, '[') > -1;
// convert to lowercase for easier comparison
$test_range = $pmaString->strtolower($test_range);
$ip_to_test = $pmaString->strtolower($ip_to_test);
$is_cidr = $pmaString->strpos($test_range, '/') > -1;
$is_range = $pmaString->strpos($test_range, '[') > -1;
$is_single = ! $is_cidr && ! $is_range;
$ip_hex = bin2hex(inet_pton($ip_to_test));
@ -235,7 +243,7 @@ function PMA_ipv6MaskTest($test_range, $ip_to_test)
$pos = 31;
while ($flexbits > 0) {
// Get the character at this position
$orig = substr($last_hex, $pos, 1);
$orig = $pmaString->substr($last_hex, $pos, 1);
// Convert it to an integer
$origval = hexdec($orig);

View File

@ -19,14 +19,16 @@ if (! defined('PHPMYADMIN')) {
*/
function PMA_detectMIME(&$test)
{
$len = strlen($test);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$len = $pmaString->strlen($test);
if ($len >= 2 && $test[0] == chr(0xff) && $test[1] == chr(0xd8)) {
return 'image/jpeg';
}
if ($len >= 3 && substr($test, 0, 3) == 'GIF') {
if ($len >= 3 && $pmaString->substr($test, 0, 3) == 'GIF') {
return 'image/gif';
}
if ($len >= 4 && substr($test, 0, 4) == "\x89PNG") {
if ($len >= 4 && $pmaString->substr($test, 0, 4) == "\x89PNG") {
return 'image/png';
}
return 'application/octet-stream';

View File

@ -152,11 +152,13 @@ $views = $GLOBALS['dbi']->getVirtualTables($db);
if (!empty($submit_mult) && !empty($what)) {
unset($message);
if (strlen($table)) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strlen($table)) {
include './libraries/tbl_common.inc.php';
$url_query .= '&amp;goto=tbl_sql.php&amp;back=tbl_sql.php';
include './libraries/tbl_info.inc.php';
} elseif (strlen($db)) {
} elseif ($pmaString->strlen($db)) {
include './libraries/db_common.inc.php';
include './libraries/db_info.inc.php';
} else {

View File

@ -34,9 +34,13 @@ function PMA_getUrlParams(
'query_type' => $what,
'reload' => (! empty($reload) ? 1 : 0),
);
if (strpos(' ' . $action, 'db_') == 1) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strpos(' ' . $action, 'db_') == 1) {
$_url_params['db']= $db;
} elseif (strpos(' ' . $action, 'tbl_') == 1 || $what == 'row_delete') {
} elseif ($pmaString->strpos(' ' . $action, 'tbl_') == 1
|| $what == 'row_delete'
) {
$_url_params['db']= $db;
$_url_params['table']= $table;
}
@ -100,6 +104,9 @@ function PMA_getQueryStrFromSelected(
$selected_cnt = count($selected);
$deletes = false;
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
for ($i = 0; $i < $selected_cnt; $i++) {
switch ($query_type) {
case 'row_delete':
@ -224,8 +231,11 @@ function PMA_getQueryStrFromSelected(
case 'replace_prefix_tbl':
$current = $selected[$i];
if (substr($current, 0, strlen($from_prefix)) == $from_prefix) {
$newtablename = $to_prefix . substr($current, strlen($from_prefix));
$subFromPrefix = $pmaString
->substr($current, 0, $pmaString->strlen($from_prefix));
if ($subFromPrefix == $from_prefix) {
$newtablename = $to_prefix
. $pmaString->substr($current, $pmaString->strlen($from_prefix));
} else {
$newtablename = $current;
}
@ -239,7 +249,8 @@ function PMA_getQueryStrFromSelected(
case 'copy_tbl_change_prefix':
$current = $selected[$i];
$newtablename = $to_prefix . substr($current, strlen($from_prefix));
$newtablename = $to_prefix .
$pmaString->substr($current, $pmaString->strlen($from_prefix));
// COPY TABLE AND CHANGE PREFIX PATTERN
$a_query = 'CREATE TABLE '
. PMA_Util::backquote($newtablename)

View File

@ -75,50 +75,58 @@ class PMA_NavigationHeader
{
$retval = '<!-- LOGO START -->';
// display Logo, depending on $GLOBALS['cfg']['NavigationDisplayLogo']
if ($GLOBALS['cfg']['NavigationDisplayLogo']) {
$logo = 'phpMyAdmin';
if (@file_exists($GLOBALS['pmaThemeImage'] . 'logo_left.png')) {
$logo = '<img src="' . $GLOBALS['pmaThemeImage'] . 'logo_left.png" '
. 'alt="' . $logo . '" id="imgpmalogo" />';
} elseif (@file_exists($GLOBALS['pmaThemeImage'] . 'pma_logo2.png')) {
$logo = '<img src="' . $GLOBALS['pmaThemeImage'] . 'pma_logo2.png" '
. 'alt="' . $logo . '" id="imgpmalogo" />';
}
$retval .= '<div id="pmalogo">';
if ($GLOBALS['cfg']['NavigationLogoLink']) {
$logo_link = trim(
htmlspecialchars($GLOBALS['cfg']['NavigationLogoLink'])
);
// prevent XSS, see PMASA-2013-9
// if link has protocol, allow only http and https
if (preg_match('/^[a-z]+:/i', $logo_link)
&& ! preg_match('/^https?:/i', $logo_link)
) {
$logo_link = 'index.php';
}
$retval .= ' <a href="' . $logo_link;
switch ($GLOBALS['cfg']['NavigationLogoLinkWindow']) {
case 'new':
$retval .= '" target="_blank"';
break;
case 'main':
// do not add our parameters for an external link
if (substr(
strtolower($GLOBALS['cfg']['NavigationLogoLink']), 0, 4
) !== '://') {
$retval .= '?' . $GLOBALS['url_query'] . '"';
} else {
$retval .= '" target="_blank"';
}
}
$retval .= '>';
$retval .= $logo;
$retval .= '</a>';
} else {
$retval .= $logo;
}
$retval .= '</div>';
if (!$GLOBALS['cfg']['NavigationDisplayLogo']) {
$retval .= '<!-- LOGO END -->';
return $retval;
}
$logo = 'phpMyAdmin';
if (@file_exists($GLOBALS['pmaThemeImage'] . 'logo_left.png')) {
$logo = '<img src="' . $GLOBALS['pmaThemeImage'] . 'logo_left.png" '
. 'alt="' . $logo . '" id="imgpmalogo" />';
} elseif (@file_exists($GLOBALS['pmaThemeImage'] . 'pma_logo2.png')) {
$logo = '<img src="' . $GLOBALS['pmaThemeImage'] . 'pma_logo2.png" '
. 'alt="' . $logo . '" id="imgpmalogo" />';
}
$retval .= '<div id="pmalogo">';
if ($GLOBALS['cfg']['NavigationLogoLink']) {
$logo_link = trim(
htmlspecialchars($GLOBALS['cfg']['NavigationLogoLink'])
);
// prevent XSS, see PMASA-2013-9
// if link has protocol, allow only http and https
if (preg_match('/^[a-z]+:/i', $logo_link)
&& ! preg_match('/^https?:/i', $logo_link)
) {
$logo_link = 'index.php';
}
$retval .= ' <a href="' . $logo_link;
switch ($GLOBALS['cfg']['NavigationLogoLinkWindow']) {
case 'new':
$retval .= '" target="_blank"';
break;
case 'main':
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// do not add our parameters for an external link
$navLogoLinkLower = $pmaString->strtolower(
$GLOBALS['cfg']['NavigationLogoLink']
);
if ($pmaString->substr($navLogoLinkLower, 0, 4) !== '://') {
$retval .= '?' . $GLOBALS['url_query'] . '"';
} else {
$retval .= '" target="_blank"';
}
}
$retval .= '>';
$retval .= $logo;
$retval .= '</a>';
} else {
$retval .= $logo;
}
$retval .= '</div>';
$retval .= '<!-- LOGO END -->';
return $retval;
}

View File

@ -563,10 +563,13 @@ class PMA_NavigationTree
return;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$separators = array();
if (is_array($node->separator)) {
$separators = $node->separator;
} else if (strlen($node->separator)) {
} else if ($pmaString->strlen($node->separator)) {
$separators[] = $node->separator;
}
$prefixes = array();
@ -574,9 +577,9 @@ class PMA_NavigationTree
foreach ($node->children as $child) {
$prefix_pos = false;
foreach ($separators as $separator) {
$sep_pos = strpos($child->name, $separator);
$sep_pos = $pmaString->strpos($child->name, $separator);
if ($sep_pos != false
&& $sep_pos != strlen($child->name)
&& $sep_pos != $pmaString->strlen($child->name)
&& $sep_pos != 0
&& ($prefix_pos == false || $sep_pos < $prefix_pos)
) {
@ -584,7 +587,7 @@ class PMA_NavigationTree
}
}
if ($prefix_pos !== false) {
$prefix = substr($child->name, 0, $prefix_pos);
$prefix = $pmaString->substr($child->name, 0, $prefix_pos);
if (! isset($prefixes[$prefix])) {
$prefixes[$prefix] = 1;
} else {
@ -641,8 +644,10 @@ class PMA_NavigationTree
foreach ($separators as $separator) {
// FIXME: this could be more efficient
foreach ($node->children as $child) {
$name_substring = substr(
$child->name, 0, strlen($key) + strlen($separator)
$name_substring = $pmaString->substr(
$child->name,
0,
$pmaString->strlen($key) + $pmaString->strlen($separator)
);
if (($name_substring != $key . $separator
&& $child->name != $key)
@ -653,9 +658,10 @@ class PMA_NavigationTree
$class = get_class($child);
$new_child = PMA_NodeFactory::getInstance(
$class,
substr(
$pmaString->substr(
$child->name,
strlen($key) + strlen($separator)
$pmaString->strlen($key)
+ $pmaString->strlen($separator)
)
);
$new_child->real_name = $child->real_name;
@ -891,7 +897,7 @@ class PMA_NavigationTree
$iClass = " class='first'";
}
$retval .= "<i$iClass></i>";
if (strpos($class, 'last') === false) {
if ($GLOBALS['PMA_String']->strpos($class, 'last') === false) {
$retval .= "<b></b>";
}

View File

@ -307,8 +307,8 @@ class Node_Database extends Node
. "." . PMA_Util::backquote($cfgRelation['navigationhiding']);
$sqlQuery = "SELECT `item_name` FROM " . $navTable
. " WHERE `username`='" . $cfgRelation['user'] . "'"
. " AND `item_type`='" . substr($type, 0, -1) . "'"
. " AND `db_name`='" . PMA_Util::sqlAddSlashes($db) . "'";
. " AND `item_type`='" . $GLOBALS['PMA_String']->substr($type, 0, -1)
. "'" . " AND `db_name`='" . PMA_Util::sqlAddSlashes($db) . "'";
$result = PMA_queryAsControlUser($sqlQuery, false);
if ($result) {
$hiddenItems = array();

View File

@ -42,7 +42,9 @@ function PMA_getHtmlForColumnsList(
$extracted_columnspec = PMA_Util::extractColumnSpec($def['Type']);
$type = $extracted_columnspec['type'];
}
if (empty($columnTypeList) || in_array(strtoupper($type), $columnTypeList)) {
if (empty($columnTypeList)
|| in_array($GLOBALS['PMA_String']->strtoupper($type), $columnTypeList)
) {
if ($listType == 'checkbox') {
$selectColHtml .= '<input type="checkbox" value="'
. htmlspecialchars($column) . '"/>'

View File

@ -855,7 +855,9 @@ function PMA_getTableOptionFieldset($comment, $tbl_collation,
);
} // end if (ARIA)
if (strlen($auto_increment) > 0
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strlen($auto_increment) > 0
&& ($is_myisam_or_aria || $is_innodb || $is_pbxt)
) {
$html_output .= '<tr><td>'
@ -875,7 +877,8 @@ function PMA_getTableOptionFieldset($comment, $tbl_collation,
// (if the table was compressed, it can be seen on the Structure page)
if (isset($possible_row_formats[$tbl_storage_engine])) {
$current_row_format = strtoupper($GLOBALS['showtable']['Row_format']);
$current_row_format
= $pmaString->strtoupper($GLOBALS['showtable']['Row_format']);
$html_output .= '<tr><td>'
. '<label for="new_row_format">ROW_FORMAT</label></td>'
. '<td>';
@ -1447,8 +1450,11 @@ function PMA_getTableAltersArray($is_myisam_or_aria, $is_isam, $pack_keys,
$table_alters[] = 'COMMENT = \''
. PMA_Util::sqlAddSlashes($_REQUEST['comment']) . '\'';
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if (! empty($newTblStorageEngine)
&& strtolower($newTblStorageEngine) !== strtolower($GLOBALS['tbl_storage_engine'])
&& $pmaString->strtolower($newTblStorageEngine) !== $pmaString->strtolower($GLOBALS['tbl_storage_engine'])
) {
$table_alters[] = 'ENGINE = ' . $newTblStorageEngine;
}
@ -1506,13 +1512,14 @@ function PMA_getTableAltersArray($is_myisam_or_aria, $is_isam, $pack_keys,
. PMA_Util::sqlAddSlashes($_REQUEST['new_auto_increment']);
}
$newRowFormat = $_REQUEST['new_row_format'];
$newRowFormatLower = $pmaString->strtolower($newRowFormat);
if (($is_myisam_or_aria || $is_innodb || $is_pbxt)
&& ! empty($_REQUEST['new_row_format'])
&& (!strlen($row_format)
|| strtolower($_REQUEST['new_row_format']) !== strtolower($row_format))
&& ! empty($newRowFormat)
&& (!$pmaString->strlen($row_format)
|| $newRowFormatLower !== $pmaString->strtolower($row_format))
) {
$table_alters[] = 'ROW_FORMAT = '
. PMA_Util::sqlAddSlashes($_REQUEST['new_row_format']);
$table_alters[] = 'ROW_FORMAT = ' . PMA_Util::sqlAddSlashes($newRowFormat);
}
return $table_alters;
@ -1528,7 +1535,7 @@ function PMA_getTableAltersArray($is_myisam_or_aria, $is_isam, $pack_keys,
*/
function PMA_setGlobalVariablesForEngine($tbl_storage_engine)
{
$upperTblStorEngine = strtoupper($tbl_storage_engine);
$upperTblStorEngine = $GLOBALS['PMA_String']->strtoupper($tbl_storage_engine);
//Options that apply to MYISAM usually apply to ARIA
$is_myisam_or_aria = ($upperTblStorEngine == 'MYISAM'

View File

@ -130,7 +130,7 @@ if ($is_select) {
$table = $analyzed_sql[0]['table_ref'][0]['table_true_name'];
}
if (isset($analyzed_sql[0]['table_ref'][0]['db'])
&& strlen($analyzed_sql[0]['table_ref'][0]['db'])
&& $GLOBALS['PMA_String']->strlen($analyzed_sql[0]['table_ref'][0]['db'])
) {
$db = $analyzed_sql[0]['table_ref'][0]['db'];
} else {

View File

@ -23,11 +23,14 @@ function PMA_getPlugin(
$plugins_dir,
$plugin_param = false
) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$GLOBALS['plugin_param'] = $plugin_param;
$class_name = strtoupper($plugin_type[0])
. strtolower(substr($plugin_type, 1))
. strtoupper($plugin_format[0])
. strtolower(substr($plugin_format, 1));
$class_name = $pmaString->strtoupper($plugin_type[0])
. $pmaString->strtolower($pmaString->substr($plugin_type, 1))
. $pmaString->strtoupper($plugin_format[0])
. $pmaString->strtolower($pmaString->substr($plugin_format, 1));
$file = $class_name . ".class.php";
if (is_file($plugins_dir . $file)) {
include_once $plugins_dir . $file;
@ -41,7 +44,7 @@ function PMA_getPlugin(
* Reads all plugin information from directory $plugins_dir
*
* @param string $plugin_type the type of the plugin (import, export, etc)
* @param string $plugins_dir directrory with plugins
* @param string $plugins_dir directory with plugins
* @param mixed $plugin_param parameter to plugin by which they can
* decide whether they can work
*
@ -57,13 +60,16 @@ function PMA_getPlugins($plugin_type, $plugins_dir, $plugin_param)
return $plugin_list;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
//@todo Find a way to use PMA_StringMB with UTF-8 instead of mb_*.
while ($file = @readdir($handle)) {
// In some situations, Mac OS creates a new file for each file
// (for example ._csv.php) so the following regexp
// matches a file which does not start with a dot but ends
// with ".php"
$class_type = mb_strtoupper($plugin_type[0], 'UTF-8')
. mb_strtolower(substr($plugin_type, 1), 'UTF-8');
. mb_strtolower($pmaString->substr($plugin_type, 1), 'UTF-8');
if (is_file($plugins_dir . $file)
&& preg_match(
'@^' . $class_type . '(.+)\.class\.php$@i',
@ -190,8 +196,12 @@ function PMA_pluginGetChoice($section, $name, &$list, $cfgname = null)
}
$ret = '<select id="plugins" name="' . $name . '">';
$default = PMA_pluginGetDefault($section, $cfgname);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
foreach ($list as $plugin) {
$plugin_name = strtolower(substr(get_class($plugin), strlen($section)));
$plugin_name = $pmaString->strtolower(
$pmaString->substr(get_class($plugin), $pmaString->strlen($section))
);
$ret .= '<option';
// If the form is being repopulated using $_GET data, that is priority
if (isset($_GET[$name])
@ -215,7 +225,9 @@ function PMA_pluginGetChoice($section, $name, &$list, $cfgname = null)
// Whether each plugin has to be saved as a file
foreach ($list as $plugin) {
$plugin_name = strtolower(substr(get_class($plugin), strlen($section)));
$plugin_name = $pmaString->strtolower(
$pmaString->substr(get_class($plugin), $pmaString->strlen($section))
);
$ret .= '<input type="hidden" id="force_file_' . $plugin_name
. '" value="';
$properties = $plugin->getProperties();
@ -249,11 +261,14 @@ function PMA_pluginGetOneOption(
&$propertyGroup,
$is_subgroup = false
) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$ret = "\n";
if (! $is_subgroup) {
// for subgroup headers
if (strpos(get_class($propertyGroup), "PropertyItem")) {
if ($pmaString->strpos(get_class($propertyGroup), "PropertyItem")) {
$properties = array($propertyGroup);
} else {
// for main groups
@ -282,7 +297,7 @@ function PMA_pluginGetOneOption(
foreach ($properties as $propertyItem) {
$property_class = get_class($propertyItem);
// if the property is a subgroup, we deal with it recursively
if (strpos($property_class, "Subgroup")) {
if ($pmaString->strpos($property_class, "Subgroup")) {
// for subgroups
// each subgroup can have a header, which may also be a form element
$subgroup_header = $propertyItem->getSubgroupHeader();
@ -475,6 +490,9 @@ function PMA_pluginGetOneOption(
*/
function PMA_pluginGetOptions($section, &$list)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$ret = '';
// Options for plugins that support them
foreach ($list as $plugin) {
@ -484,7 +502,9 @@ function PMA_pluginGetOptions($section, &$list)
$options = $properties->getOptions();
}
$plugin_name = strtolower(substr(get_class($plugin), strlen($section)));
$plugin_name = $pmaString->strtolower(
$pmaString->substr(get_class($plugin), $pmaString->strlen($section))
);
$ret .= '<div id="' . $plugin_name
. '_options" class="format_specific_options">';
$ret .= '<h3>' . PMA_getString($text) . '</h3>';

View File

@ -52,5 +52,29 @@ abstract class ImportPlugin
* @return void
*/
abstract protected function setProperties();
/**
* Define DB name and options
*
* @param string $currentDb DB
* @param string $defaultDb Default DB name
*
* @return array DB name and options (an associative array of options)
*/
protected function getDbnameAndOptions($currentDb, $defaultDb)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strlen($currentDb)) {
$db_name = $currentDb;
$options = array('create_db' => false);
} else {
$db_name = $defaultDb;
$options = null;
}
return array($db_name, $options);
}
}
?>

View File

@ -587,12 +587,15 @@ class AuthenticationCookie extends AuthenticationPlugin
// URL where to go:
$redirect_url = $cfg['PmaAbsoluteUri'] . 'index.php';
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
// any parameters to pass?
$url_params = array();
if (strlen($GLOBALS['db'])) {
if ($pmaString->strlen($GLOBALS['db'])) {
$url_params['db'] = $GLOBALS['db'];
}
if (strlen($GLOBALS['table'])) {
if ($pmaString->strlen($GLOBALS['table'])) {
$url_params['table'] = $GLOBALS['table'];
}
// any target to pass?

View File

@ -131,7 +131,9 @@ class ExportCsv extends ExportPlugin
$GLOBALS['csv_columns'] = 'yes';
}
} else {
if (empty($csv_terminated) || strtolower($csv_terminated) == 'auto') {
if (empty($csv_terminated)
|| $GLOBALS['PMA_String']->strtolower($csv_terminated) == 'auto'
) {
$csv_terminated = $GLOBALS['crlf'];
} else {
$csv_terminated = str_replace('\\r', "\015", $csv_terminated);
@ -241,7 +243,9 @@ class ExportCsv extends ExportPlugin
}
$schema_insert .= $csv_separator;
} // end for
$schema_insert = trim(substr($schema_insert, 0, -1));
$schema_insert = trim(
$GLOBALS['PMA_String']->substr($schema_insert, 0, -1)
);
if (! PMA_exportOutputHandler($schema_insert . $csv_terminated)) {
return false;
}

View File

@ -343,7 +343,8 @@ class ExportLatex extends ExportPlugin
. self::texEscape(stripslashes($columns_alias[$i])) . '}} & ';
}
$buffer = substr($buffer, 0, -2) . '\\\\ \\hline \hline ';
$buffer = $GLOBALS['PMA_String']->substr($buffer, 0, -2)
. '\\\\ \\hline \hline ';
if (! PMA_exportOutputHandler($buffer . ' \\endfirsthead ' . $crlf)) {
return false;
}
@ -574,6 +575,9 @@ class ExportLatex extends ExportPlugin
return false;
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$fields = $GLOBALS['dbi']->getColumns($db, $table);
foreach ($fields as $row) {
$extracted_columnspec
@ -625,16 +629,16 @@ class ExportLatex extends ExportPlugin
}
$local_buffer = self::texEscape($local_buffer);
if ($row['Key']=='PRI') {
$pos=strpos($local_buffer, "\000");
$pos = $pmaString->strpos($local_buffer, "\000");
$local_buffer = '\\textit{'
. substr($local_buffer, 0, $pos)
. '}' . substr($local_buffer, $pos);
. $pmaString->substr($local_buffer, 0, $pos)
. '}' . $pmaString->substr($local_buffer, $pos);
}
if (in_array($field_name, $unique_keys)) {
$pos=strpos($local_buffer, "\000");
$pos = $pmaString->strpos($local_buffer, "\000");
$local_buffer = '\\textbf{'
. substr($local_buffer, 0, $pos)
. '}' . substr($local_buffer, $pos);
. $pmaString->substr($local_buffer, 0, $pos)
. '}' . $pmaString->substr($local_buffer, $pos);
}
$buffer = str_replace("\000", ' & ', $local_buffer);
$buffer .= ' \\\\ \\hline ' . $crlf;

View File

@ -785,42 +785,49 @@ class ExportSql extends ExportPlugin
return false;
}
}
if (isset($GLOBALS['sql_create_database'])) {
$create_query = 'CREATE DATABASE IF NOT EXISTS '
. (isset($GLOBALS['sql_backquotes'])
? PMA_Util::backquoteCompat($db_alias, $compat) : $db_alias);
$collation = PMA_getDbCollation($db);
if (PMA_DRIZZLE) {
$create_query .= ' COLLATE ' . $collation;
} else {
if (strpos($collation, '_')) {
$create_query .= ' DEFAULT CHARACTER SET '
. substr($collation, 0, strpos($collation, '_'))
. ' COLLATE ' . $collation;
} else {
$create_query .= ' DEFAULT CHARACTER SET ' . $collation;
}
}
$create_query .= ';' . $crlf;
if (! PMA_exportOutputHandler($create_query)) {
return false;
}
if (isset($GLOBALS['sql_backquotes'])
&& ((isset($GLOBALS['sql_compatibility'])
&& $GLOBALS['sql_compatibility'] == 'NONE')
|| PMA_DRIZZLE)
) {
$result = PMA_exportOutputHandler(
'USE ' . PMA_Util::backquoteCompat($db_alias, $compat)
. ';' . $crlf
);
} else {
$result = PMA_exportOutputHandler('USE ' . $db_alias . ';' . $crlf);
}
return $result;
} else {
if (!isset($GLOBALS['sql_create_database'])) {
return true;
}
$create_query = 'CREATE DATABASE IF NOT EXISTS '
. (isset($GLOBALS['sql_backquotes'])
? PMA_Util::backquoteCompat($db_alias, $compat) : $db_alias);
$collation = PMA_getDbCollation($db);
if (PMA_DRIZZLE) {
$create_query .= ' COLLATE ' . $collation;
} else {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strpos($collation, '_')) {
$create_query .= ' DEFAULT CHARACTER SET '
. $pmaString->substr(
$collation,
0,
$pmaString->strpos($collation, '_')
)
. ' COLLATE ' . $collation;
} else {
$create_query .= ' DEFAULT CHARACTER SET ' . $collation;
}
}
$create_query .= ';' . $crlf;
if (! PMA_exportOutputHandler($create_query)) {
return false;
}
if (isset($GLOBALS['sql_backquotes'])
&& ((isset($GLOBALS['sql_compatibility'])
&& $GLOBALS['sql_compatibility'] == 'NONE')
|| PMA_DRIZZLE)
) {
$result = PMA_exportOutputHandler(
'USE ' . PMA_Util::backquoteCompat($db_alias, $compat)
. ';' . $crlf
);
} else {
$result = PMA_exportOutputHandler('USE ' . $db_alias . ';' . $crlf);
}
return $result;
}
/**
@ -1219,17 +1226,20 @@ class ExportSql extends ExportPlugin
return $this->_exportComment(__('in use') . '(' . $tmp_error . ')');
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$warning = '';
if ($result != false && ($row = $GLOBALS['dbi']->fetchRow($result))) {
$create_query = $row[1];
unset($row);
// Convert end of line chars to one that we want (note that MySQL
// doesn't return query it will accept in all cases)
if (strpos($create_query, "(\r\n ")) {
if ($pmaString->strpos($create_query, "(\r\n ")) {
$create_query = str_replace("\r\n", $crlf, $create_query);
} elseif (strpos($create_query, "(\n ")) {
} elseif ($pmaString->strpos($create_query, "(\n ")) {
$create_query = str_replace("\n", $crlf, $create_query);
} elseif (strpos($create_query, "(\r ")) {
} elseif ($pmaString->strpos($create_query, "(\r ")) {
$create_query = str_replace("\r", $crlf, $create_query);
}
@ -1443,9 +1453,9 @@ class ExportSql extends ExportPlugin
$sql_lines[$k]
)) {
//adds auto increment value
$increment_value = substr(
$increment_value = $pmaString->substr(
$sql_lines[$k],
strpos($sql_lines[$k], "AUTO_INCREMENT")
$pmaString->strpos($sql_lines[$k], "AUTO_INCREMENT")
);
$increment_value_array = explode(' ', $increment_value);
$sql_auto_increments .= $increment_value_array[0] . ";";
@ -1454,7 +1464,7 @@ class ExportSql extends ExportPlugin
}
if ($sql_auto_increments != '') {
$sql_auto_increments = substr(
$sql_auto_increments = $pmaString->substr(
$sql_auto_increments, 0, -1
) . ';';
}
@ -1480,7 +1490,11 @@ class ExportSql extends ExportPlugin
if (! $first) {
$sql_constraints .= $crlf;
}
if (strpos($sql_lines[$j], 'CONSTRAINT') === false) {
$posConstraint = $pmaString->strpos(
$sql_lines[$j],
'CONSTRAINT'
);
if ($posConstraint === false) {
$tmp_str = preg_replace(
'/(FOREIGN[\s]+KEY)/',
'ADD \1',
@ -1937,304 +1951,308 @@ class ExportSql extends ExportPlugin
);
}
if ($result != false) {
$fields_cnt = $GLOBALS['dbi']->numFields($result);
if ($result == false) {
$GLOBALS['dbi']->freeResult($result);
return true;
}
// Get field information
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
$field_flags = array();
for ($j = 0; $j < $fields_cnt; $j++) {
$field_flags[$j] = $GLOBALS['dbi']->fieldFlags($result, $j);
$fields_cnt = $GLOBALS['dbi']->numFields($result);
// Get field information
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
$field_flags = array();
for ($j = 0; $j < $fields_cnt; $j++) {
$field_flags[$j] = $GLOBALS['dbi']->fieldFlags($result, $j);
}
$field_set = array();
for ($j = 0; $j < $fields_cnt; $j++) {
$col_as = $fields_meta[$j]->name;
if (!empty($aliases[$db]['tables'][$table]['columns'][$col_as])) {
$col_as = $aliases[$db]['tables'][$table]['columns'][$col_as];
}
$field_set[$j] = PMA_Util::backquoteCompat(
$col_as,
$compat,
$sql_backquotes
);
}
$field_set = array();
for ($j = 0; $j < $fields_cnt; $j++) {
$col_as = $fields_meta[$j]->name;
if (!empty($aliases[$db]['tables'][$table]['columns'][$col_as])) {
$col_as = $aliases[$db]['tables'][$table]['columns'][$col_as];
}
$field_set[$j] = PMA_Util::backquoteCompat(
$col_as,
$compat,
$sql_backquotes
);
if (isset($GLOBALS['sql_type'])
&& $GLOBALS['sql_type'] == 'UPDATE'
) {
// update
$schema_insert = 'UPDATE ';
if (isset($GLOBALS['sql_ignore'])) {
$schema_insert .= 'IGNORE ';
}
// avoid EOL blank
$schema_insert .= PMA_Util::backquoteCompat(
$table_alias,
$compat,
$sql_backquotes
) . ' SET';
} else {
// insert or replace
if (isset($GLOBALS['sql_type'])
&& $GLOBALS['sql_type'] == 'UPDATE'
&& $GLOBALS['sql_type'] == 'REPLACE'
) {
// update
$schema_insert = 'UPDATE ';
if (isset($GLOBALS['sql_ignore'])) {
$schema_insert .= 'IGNORE ';
}
// avoid EOL blank
$schema_insert .= PMA_Util::backquoteCompat(
$table_alias,
$compat,
$sql_backquotes
) . ' SET';
$sql_command = 'REPLACE';
} else {
// insert or replace
if (isset($GLOBALS['sql_type'])
&& $GLOBALS['sql_type'] == 'REPLACE'
) {
$sql_command = 'REPLACE';
} else {
$sql_command = 'INSERT';
}
// delayed inserts?
if (isset($GLOBALS['sql_delayed'])) {
$insert_delayed = ' DELAYED';
} else {
$insert_delayed = '';
}
// insert ignore?
if (isset($GLOBALS['sql_type'])
&& $GLOBALS['sql_type'] == 'INSERT'
&& isset($GLOBALS['sql_ignore'])
) {
$insert_delayed .= ' IGNORE';
}
//truncate table before insert
if (isset($GLOBALS['sql_truncate'])
&& $GLOBALS['sql_truncate']
&& $sql_command == 'INSERT'
) {
$truncate = 'TRUNCATE TABLE '
. PMA_Util::backquoteCompat(
$table_alias,
$compat,
$sql_backquotes
) . ";";
$truncatehead = $this->_possibleCRLF()
. $this->_exportComment()
. $this->_exportComment(
__('Truncate table before insert') . ' '
. $formatted_table_name
)
. $this->_exportComment()
. $crlf;
PMA_exportOutputHandler($truncatehead);
PMA_exportOutputHandler($truncate);
}
// scheme for inserting fields
if ($GLOBALS['sql_insert_syntax'] == 'complete'
|| $GLOBALS['sql_insert_syntax'] == 'both'
) {
$fields = implode(', ', $field_set);
$schema_insert = $sql_command . $insert_delayed . ' INTO '
. PMA_Util::backquoteCompat(
$table_alias,
$compat,
$sql_backquotes
)
// avoid EOL blank
. ' (' . $fields . ') VALUES';
} else {
$schema_insert = $sql_command . $insert_delayed . ' INTO '
. PMA_Util::backquoteCompat(
$table_alias,
$compat,
$sql_backquotes
)
. ' VALUES';
}
$sql_command = 'INSERT';
}
//\x08\\x09, not required
$search = array("\x00", "\x0a", "\x0d", "\x1a");
$replace = array('\0', '\n', '\r', '\Z');
$current_row = 0;
$query_size = 0;
if (($GLOBALS['sql_insert_syntax'] == 'extended'
|| $GLOBALS['sql_insert_syntax'] == 'both')
&& (! isset($GLOBALS['sql_type'])
|| $GLOBALS['sql_type'] != 'UPDATE')
) {
$separator = ',';
$schema_insert .= $crlf;
// delayed inserts?
if (isset($GLOBALS['sql_delayed'])) {
$insert_delayed = ' DELAYED';
} else {
$separator = ';';
$insert_delayed = '';
}
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
if ($current_row == 0) {
$head = $this->_possibleCRLF()
. $this->_exportComment()
. $this->_exportComment(
__('Dumping data for table') . ' '
. $formatted_table_name
)
. $this->_exportComment()
. $crlf;
if (! PMA_exportOutputHandler($head)) {
return false;
}
// insert ignore?
if (isset($GLOBALS['sql_type'])
&& $GLOBALS['sql_type'] == 'INSERT'
&& isset($GLOBALS['sql_ignore'])
) {
$insert_delayed .= ' IGNORE';
}
//truncate table before insert
if (isset($GLOBALS['sql_truncate'])
&& $GLOBALS['sql_truncate']
&& $sql_command == 'INSERT'
) {
$truncate = 'TRUNCATE TABLE '
. PMA_Util::backquoteCompat(
$table_alias,
$compat,
$sql_backquotes
) . ";";
$truncatehead = $this->_possibleCRLF()
. $this->_exportComment()
. $this->_exportComment(
__('Truncate table before insert') . ' '
. $formatted_table_name
)
. $this->_exportComment()
. $crlf;
PMA_exportOutputHandler($truncatehead);
PMA_exportOutputHandler($truncate);
}
// scheme for inserting fields
if ($GLOBALS['sql_insert_syntax'] == 'complete'
|| $GLOBALS['sql_insert_syntax'] == 'both'
) {
$fields = implode(', ', $field_set);
$schema_insert = $sql_command . $insert_delayed . ' INTO '
. PMA_Util::backquoteCompat(
$table_alias,
$compat,
$sql_backquotes
)
// avoid EOL blank
. ' (' . $fields . ') VALUES';
} else {
$schema_insert = $sql_command . $insert_delayed . ' INTO '
. PMA_Util::backquoteCompat(
$table_alias,
$compat,
$sql_backquotes
)
. ' VALUES';
}
}
//\x08\\x09, not required
$search = array("\x00", "\x0a", "\x0d", "\x1a");
$replace = array('\0', '\n', '\r', '\Z');
$current_row = 0;
$query_size = 0;
if (($GLOBALS['sql_insert_syntax'] == 'extended'
|| $GLOBALS['sql_insert_syntax'] == 'both')
&& (! isset($GLOBALS['sql_type'])
|| $GLOBALS['sql_type'] != 'UPDATE')
) {
$separator = ',';
$schema_insert .= $crlf;
} else {
$separator = ';';
}
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
if ($current_row == 0) {
$head = $this->_possibleCRLF()
. $this->_exportComment()
. $this->_exportComment(
__('Dumping data for table') . ' '
. $formatted_table_name
)
. $this->_exportComment()
. $crlf;
if (! PMA_exportOutputHandler($head)) {
return false;
}
// We need to SET IDENTITY_INSERT ON for MSSQL
if (isset($GLOBALS['sql_compatibility'])
&& $GLOBALS['sql_compatibility'] == 'MSSQL'
&& $current_row == 0
) {
if (! PMA_exportOutputHandler(
'SET IDENTITY_INSERT '
. PMA_Util::backquoteCompat(
$table_alias,
$compat
)
. ' ON ;' . $crlf
)) {
return false;
}
}
$current_row++;
$values = array();
for ($j = 0; $j < $fields_cnt; $j++) {
// NULL
if (! isset($row[$j]) || is_null($row[$j])) {
$values[] = 'NULL';
} elseif ($fields_meta[$j]->numeric
&& $fields_meta[$j]->type != 'timestamp'
&& ! $fields_meta[$j]->blob
) {
// a number
// timestamp is numeric on some MySQL 4.1, BLOBs are
// sometimes numeric
$values[] = $row[$j];
} elseif (stristr($field_flags[$j], 'BINARY') !== false
&& isset($GLOBALS['sql_hex_for_binary'])
) {
// a true BLOB
// - mysqldump only generates hex data when the --hex-blob
// option is used, for fields having the binary attribute
// no hex is generated
// - a TEXT field returns type blob but a real blob
// returns also the 'binary' flag
// empty blobs need to be different, but '0' is also empty
// :-(
if (empty($row[$j]) && $row[$j] != '0') {
$values[] = '\'\'';
} else {
$values[] = '0x' . bin2hex($row[$j]);
}
} elseif ($fields_meta[$j]->type == 'bit') {
// detection of 'bit' works only on mysqli extension
$values[] = "b'" . PMA_Util::sqlAddSlashes(
PMA_Util::printableBitValue(
$row[$j], $fields_meta[$j]->length
)
)
. "'";
} else {
// something else -> treat as a string
$values[] = '\''
. str_replace(
$search, $replace,
PMA_Util::sqlAddSlashes($row[$j])
)
. '\'';
} // end if
} // end for
// should we make update?
if (isset($GLOBALS['sql_type'])
&& $GLOBALS['sql_type'] == 'UPDATE'
) {
$insert_line = $schema_insert;
for ($i = 0; $i < $fields_cnt; $i++) {
if (0 == $i) {
$insert_line .= ' ';
}
if ($i > 0) {
// avoid EOL blank
$insert_line .= ',';
}
$insert_line .= $field_set[$i] . ' = ' . $values[$i];
}
list($tmp_unique_condition, $tmp_clause_is_unique)
= PMA_Util::getUniqueCondition(
$result,
$fields_cnt,
$fields_meta,
$row
);
$insert_line .= ' WHERE ' . $tmp_unique_condition;
unset($tmp_unique_condition, $tmp_clause_is_unique);
} else {
// Extended inserts case
if ($GLOBALS['sql_insert_syntax'] == 'extended'
|| $GLOBALS['sql_insert_syntax'] == 'both'
) {
if ($current_row == 1) {
$insert_line = $schema_insert . '('
. implode(', ', $values) . ')';
} else {
$insert_line = '(' . implode(', ', $values) . ')';
$sql_max_size = $GLOBALS['sql_max_query_size'];
if (isset($sql_max_size)
&& $sql_max_size > 0
&& $query_size + strlen($insert_line) > $sql_max_size
) {
if (! PMA_exportOutputHandler(';' . $crlf)) {
return false;
}
$query_size = 0;
$current_row = 1;
$insert_line = $schema_insert . $insert_line;
}
}
$query_size += strlen($insert_line);
// Other inserts case
} else {
$insert_line = $schema_insert
. '('
. implode(', ', $values)
. ')';
}
}
unset($values);
}
// We need to SET IDENTITY_INSERT ON for MSSQL
if (isset($GLOBALS['sql_compatibility'])
&& $GLOBALS['sql_compatibility'] == 'MSSQL'
&& $current_row == 0
) {
if (! PMA_exportOutputHandler(
($current_row == 1 ? '' : $separator . $crlf)
. $insert_line
'SET IDENTITY_INSERT '
. PMA_Util::backquoteCompat(
$table_alias,
$compat
)
. ' ON ;' . $crlf
)) {
return false;
}
} // end while
if ($current_row > 0) {
if (! PMA_exportOutputHandler(';' . $crlf)) {
return false;
}
}
$current_row++;
$values = array();
for ($j = 0; $j < $fields_cnt; $j++) {
// NULL
if (! isset($row[$j]) || is_null($row[$j])) {
$values[] = 'NULL';
} elseif ($fields_meta[$j]->numeric
&& $fields_meta[$j]->type != 'timestamp'
&& ! $fields_meta[$j]->blob
) {
// a number
// timestamp is numeric on some MySQL 4.1, BLOBs are
// sometimes numeric
$values[] = $row[$j];
} elseif (stristr($field_flags[$j], 'BINARY') !== false
&& isset($GLOBALS['sql_hex_for_binary'])
) {
// a true BLOB
// - mysqldump only generates hex data when the --hex-blob
// option is used, for fields having the binary attribute
// no hex is generated
// - a TEXT field returns type blob but a real blob
// returns also the 'binary' flag
// We need to SET IDENTITY_INSERT OFF for MSSQL
if (isset($GLOBALS['sql_compatibility'])
&& $GLOBALS['sql_compatibility'] == 'MSSQL'
&& $current_row > 0
// empty blobs need to be different, but '0' is also empty
// :-(
if (empty($row[$j]) && $row[$j] != '0') {
$values[] = '\'\'';
} else {
$values[] = '0x' . bin2hex($row[$j]);
}
} elseif ($fields_meta[$j]->type == 'bit') {
// detection of 'bit' works only on mysqli extension
$values[] = "b'" . PMA_Util::sqlAddSlashes(
PMA_Util::printableBitValue(
$row[$j], $fields_meta[$j]->length
)
)
. "'";
} else {
// something else -> treat as a string
$values[] = '\''
. str_replace(
$search, $replace,
PMA_Util::sqlAddSlashes($row[$j])
)
. '\'';
} // end if
} // end for
// should we make update?
if (isset($GLOBALS['sql_type'])
&& $GLOBALS['sql_type'] == 'UPDATE'
) {
$outputSucceeded = PMA_exportOutputHandler(
$crlf . 'SET IDENTITY_INSERT '
. PMA_Util::backquoteCompat($table_alias, $compat)
. ' OFF;' . $crlf
);
if (! $outputSucceeded) {
return false;
$insert_line = $schema_insert;
for ($i = 0; $i < $fields_cnt; $i++) {
if (0 == $i) {
$insert_line .= ' ';
}
if ($i > 0) {
// avoid EOL blank
$insert_line .= ',';
}
$insert_line .= $field_set[$i] . ' = ' . $values[$i];
}
list($tmp_unique_condition, $tmp_clause_is_unique)
= PMA_Util::getUniqueCondition(
$result,
$fields_cnt,
$fields_meta,
$row
);
$insert_line .= ' WHERE ' . $tmp_unique_condition;
unset($tmp_unique_condition, $tmp_clause_is_unique);
} else {
// Extended inserts case
if ($GLOBALS['sql_insert_syntax'] == 'extended'
|| $GLOBALS['sql_insert_syntax'] == 'both'
) {
if ($current_row == 1) {
$insert_line = $schema_insert . '('
. implode(', ', $values) . ')';
} else {
$insert_line = '(' . implode(', ', $values) . ')';
$insertLineSize = $pmaString->strlen($insert_line);
$sql_max_size = $GLOBALS['sql_max_query_size'];
if (isset($sql_max_size)
&& $sql_max_size > 0
&& $query_size + $insertLineSize > $sql_max_size
) {
if (! PMA_exportOutputHandler(';' . $crlf)) {
return false;
}
$query_size = 0;
$current_row = 1;
$insert_line = $schema_insert . $insert_line;
}
}
$query_size += $pmaString->strlen($insert_line);
// Other inserts case
} else {
$insert_line = $schema_insert
. '(' . implode(', ', $values) . ')';
}
}
} // end if ($result != false)
$GLOBALS['dbi']->freeResult($result);
unset($values);
if (! PMA_exportOutputHandler(
($current_row == 1 ? '' : $separator . $crlf)
. $insert_line
)) {
return false;
}
} // end while
if ($current_row > 0) {
if (! PMA_exportOutputHandler(';' . $crlf)) {
return false;
}
}
// We need to SET IDENTITY_INSERT OFF for MSSQL
if (isset($GLOBALS['sql_compatibility'])
&& $GLOBALS['sql_compatibility'] == 'MSSQL'
&& $current_row > 0
) {
$outputSucceeded = PMA_exportOutputHandler(
$crlf . 'SET IDENTITY_INSERT '
. PMA_Util::backquoteCompat($table_alias, $compat)
. ' OFF;' . $crlf
);
if (! $outputSucceeded) {
return false;
}
}
$GLOBALS['dbi']->freeResult($result);
return true;
} // end of the 'exportData()' function
@ -2395,6 +2413,10 @@ class ExportSql extends ExportPlugin
$old_table = $table;
$on_seen = false;
$size = $tokens['len'];
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
for ($i = 0; $i < $size && !$query_end; $i++) {
$type = $tokens[$i]['type'];
$data = $tokens[$i]['data'];
@ -2404,9 +2426,9 @@ class ExportSql extends ExportPlugin
$d_unq = PMA_Util::unQuote($data);
$d_unq_next = PMA_Util::unQuote($data_next);
$d_unq_prev = PMA_Util::unQuote($data_prev);
$d_upper = strtoupper($d_unq);
$d_upper_next = strtoupper($d_unq_next);
$d_upper_prev = strtoupper($d_unq_prev);
$d_upper = $pmaString->strtoupper($d_unq);
$d_upper_next = $pmaString->strtoupper($d_unq_next);
$d_upper_prev = $pmaString->strtoupper($d_unq_prev);
$pos = $tokens[$i]['pos'] + $offset;
if ($type === 'alpha_reservedWord') {
if ($query_type === ''

View File

@ -9,7 +9,7 @@
if (! defined('PHPMYADMIN')) {
exit;
}
if (! strlen($GLOBALS['db'])) { /* Can't do server export */
if (!$GLOBALS['PMA_String']->strlen($GLOBALS['db'])) { /* Can't do server export */
$GLOBALS['skip_import'] = true;
return;
}
@ -270,7 +270,8 @@ class ExportXml extends ExportPlugin
. $trigger['name'] . '">' . $crlf;
// Do some formatting
$code = substr(rtrim($code), 0, -3);
$code = $GLOBALS['PMA_String']
->substr(rtrim($code), 0, -3);
$code = " " . htmlspecialchars($code);
$code = str_replace("\n", "\n ", $code);

View File

@ -82,9 +82,11 @@ class TableProperty
*/
function getPureType()
{
$pos = strpos($this->type, "(");
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$pos = $pmaString->strpos($this->type, "(");
if ($pos > 0) {
return substr($this->type, 0, $pos);
return $pmaString->substr($this->type, 0, $pos);
}
return $this->type;
}
@ -116,28 +118,30 @@ class TableProperty
*/
function getDotNetPrimitiveType()
{
if (strpos($this->type, "int") === 0) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strpos($this->type, "int") === 0) {
return "int";
}
if (strpos($this->type, "longtext") === 0) {
if ($pmaString->strpos($this->type, "longtext") === 0) {
return "string";
}
if (strpos($this->type, "long") === 0) {
if ($pmaString->strpos($this->type, "long") === 0) {
return "long";
}
if (strpos($this->type, "char") === 0) {
if ($pmaString->strpos($this->type, "char") === 0) {
return "string";
}
if (strpos($this->type, "varchar") === 0) {
if ($pmaString->strpos($this->type, "varchar") === 0) {
return "string";
}
if (strpos($this->type, "text") === 0) {
if ($pmaString->strpos($this->type, "text") === 0) {
return "string";
}
if (strpos($this->type, "tinyint") === 0) {
if ($pmaString->strpos($this->type, "tinyint") === 0) {
return "bool";
}
if (strpos($this->type, "datetime") === 0) {
if ($pmaString->strpos($this->type, "datetime") === 0) {
return "DateTime";
}
return "unknown";
@ -150,28 +154,30 @@ class TableProperty
*/
function getDotNetObjectType()
{
if (strpos($this->type, "int") === 0) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strpos($this->type, "int") === 0) {
return "Int32";
}
if (strpos($this->type, "longtext") === 0) {
if ($pmaString->strpos($this->type, "longtext") === 0) {
return "String";
}
if (strpos($this->type, "long") === 0) {
if ($pmaString->strpos($this->type, "long") === 0) {
return "Long";
}
if (strpos($this->type, "char") === 0) {
if ($pmaString->strpos($this->type, "char") === 0) {
return "String";
}
if (strpos($this->type, "varchar") === 0) {
if ($pmaString->strpos($this->type, "varchar") === 0) {
return "String";
}
if (strpos($this->type, "text") === 0) {
if ($pmaString->strpos($this->type, "text") === 0) {
return "String";
}
if (strpos($this->type, "tinyint") === 0) {
if ($pmaString->strpos($this->type, "tinyint") === 0) {
return "Boolean";
}
if (strpos($this->type, "datetime") === 0) {
if ($pmaString->strpos($this->type, "datetime") === 0) {
return "DateTime";
}
return "Unknown";
@ -184,7 +190,7 @@ class TableProperty
*/
function getIndexName()
{
if (strlen($this->key) > 0) {
if ($GLOBALS['PMA_String']->strlen($this->key) > 0) {
return "index=\""
. htmlspecialchars($this->name, ENT_COMPAT, 'UTF-8')
. "\"";

View File

@ -104,6 +104,9 @@ class ImportCsv extends AbstractImportCsv
// but we use directly from $_POST
global $error, $timeout_passed, $finished, $message;
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$replacements = array(
'\\n' => "\n",
'\\t' => "\t",
@ -115,7 +118,7 @@ class ImportCsv extends AbstractImportCsv
$csv_new_line = strtr($csv_new_line, $replacements);
$param_error = false;
if (strlen($csv_terminated) < 1) {
if ($pmaString->strlen($csv_terminated) < 1) {
$message = PMA_Message::error(
__('Invalid parameter for CSV import: %s')
);
@ -130,21 +133,23 @@ class ImportCsv extends AbstractImportCsv
// confuses this script.
// But the parser won't work correctly with strings so we allow just
// one character.
} elseif (strlen($csv_enclosed) > 1) {
} elseif ($pmaString->strlen($csv_enclosed) > 1) {
$message = PMA_Message::error(
__('Invalid parameter for CSV import: %s')
);
$message->addParam(__('Columns enclosed with'), false);
$error = true;
$param_error = true;
} elseif (strlen($csv_escaped) != 1) {
} elseif ($pmaString->strlen($csv_escaped) != 1) {
$message = PMA_Message::error(
__('Invalid parameter for CSV import: %s')
);
$message->addParam(__('Columns escaped with'), false);
$error = true;
$param_error = true;
} elseif (strlen($csv_new_line) != 1 && $csv_new_line != 'auto') {
} elseif ($pmaString->strlen($csv_new_line) != 1
&& $csv_new_line != 'auto'
) {
$message = PMA_Message::error(
__('Invalid parameter for CSV import: %s')
);
@ -233,7 +238,7 @@ class ImportCsv extends AbstractImportCsv
$col_count = 0;
$max_cols = 0;
$csv_terminated_len = strlen($csv_terminated);
$csv_terminated_len = $pmaString->strlen($csv_terminated);
while (! ($finished && $i >= $len) && ! $error && ! $timeout_passed) {
$data = PMA_importGetNextChunk();
if ($data === false) {
@ -249,7 +254,7 @@ class ImportCsv extends AbstractImportCsv
// Force a trailing new line at EOF to prevent parsing problems
if ($finished && $buffer) {
$finalch = substr($buffer, -1);
$finalch = $pmaString->substr($buffer, -1);
if ($csv_new_line == 'auto'
&& $finalch != "\r"
&& $finalch != "\n"
@ -265,17 +270,17 @@ class ImportCsv extends AbstractImportCsv
// Do not parse string when we're not at the end
// and don't have new line inside
if (($csv_new_line == 'auto'
&& strpos($buffer, "\r") === false
&& strpos($buffer, "\n") === false)
&& $pmaString->strpos($buffer, "\r") === false
&& $pmaString->strpos($buffer, "\n") === false)
|| ($csv_new_line != 'auto'
&& strpos($buffer, $csv_new_line) === false)
&& $pmaString->strpos($buffer, $csv_new_line) === false)
) {
continue;
}
}
// Current length of our buffer
$len = strlen($buffer);
$len = $pmaString->strlen($buffer);
// Currently parsed char
$ch = $buffer[$i];
if ($csv_terminated_len > 1 && $ch == $csv_terminated[0]) {
@ -539,8 +544,8 @@ class ImportCsv extends AbstractImportCsv
$line++;
$csv_finish = false;
$values = array();
$buffer = substr($buffer, $i + 1);
$len = strlen($buffer);
$buffer = $pmaString->substr($buffer, $i + 1);
$len = $pmaString->strlen($buffer);
$i = 0;
$lasti = -1;
$ch = $buffer[0];
@ -575,7 +580,7 @@ class ImportCsv extends AbstractImportCsv
}
}
if (strlen($db)) {
if ($pmaString->strlen($db)) {
$result = $GLOBALS['dbi']->fetchResult('SHOW TABLES');
$tbl_name = 'TABLE ' . (count($result) + 1);
} else {
@ -603,13 +608,7 @@ class ImportCsv extends AbstractImportCsv
*/
/* Set database name to the currently selected one, if applicable */
if (strlen($db)) {
$db_name = $db;
$options = array('create_db' => false);
} else {
$db_name = 'CSV_DB';
$options = null;
}
list($db_name, $options) = $this->getDbnameAndOptions($db, 'CSV_DB');
/* Non-applicable parameters */
$create = null;

View File

@ -93,12 +93,15 @@ class ImportMediawiki extends ImportPlugin
// Initialize the name of the current table
$cur_table_name = "";
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
while (! $finished && ! $error && ! $timeout_passed ) {
$data = PMA_importGetNextChunk();
if ($data === false) {
// Subtract data we didn't handle yet and stop processing
$GLOBALS['offset'] -= strlen($buffer);
$GLOBALS['offset'] -= $pmaString->strlen($buffer);
break;
} elseif ($data === true) {
// Handle rest of buffer
@ -108,7 +111,7 @@ class ImportMediawiki extends ImportPlugin
unset($data);
// Don't parse string if we're not at the end
// and don't have a new line inside
if ( strpos($buffer, $mediawiki_new_line) === false ) {
if ($pmaString->strpos($buffer, $mediawiki_new_line) === false ) {
continue;
}
}
@ -141,13 +144,13 @@ class ImportMediawiki extends ImportPlugin
$first_character = $cur_buffer_line[0];
$matches = array();
// Check beginnning of comment
if (! strcmp(substr($cur_buffer_line, 0, 4), "<!--")) {
// Check beginning of comment
if (! strcmp($pmaString->substr($cur_buffer_line, 0, 4), "<!--")) {
$inside_comment = true;
continue;
} elseif ($inside_comment) {
// Check end of comment
if (! strcmp(substr($cur_buffer_line, 0, 4), "-->")) {
if (!strcmp($pmaString->substr($cur_buffer_line, 0, 4), "-->")) {
// Only data comments are closed. The structure comments
// will be closed when a data comment begins (in order to
// skip structure tables)
@ -203,9 +206,9 @@ class ImportMediawiki extends ImportPlugin
$in_table_header = false;
// End processing because the current line does not
// contain any column information
} elseif (substr($cur_buffer_line, 0, 2) === '|-'
|| substr($cur_buffer_line, 0, 2) === '|+'
|| substr($cur_buffer_line, 0, 2) === '|}'
} elseif ($pmaString->substr($cur_buffer_line, 0, 2) === '|-'
|| $pmaString->substr($cur_buffer_line, 0, 2) === '|+'
|| $pmaString->substr($cur_buffer_line, 0, 2) === '|}'
) {
// Check begin row or end table
@ -227,7 +230,7 @@ class ImportMediawiki extends ImportPlugin
$cur_temp_line = array();
// No more processing required at the end of the table
if (substr($cur_buffer_line, 0, 2) === '|}') {
if ($pmaString->substr($cur_buffer_line, 0, 2) === '|}') {
$current_table = array(
$cur_table_name,
$cur_temp_table_headers,
@ -263,7 +266,7 @@ class ImportMediawiki extends ImportPlugin
// A '|' inside an invalid link should not
// be mistaken as delimiting cell parameters
if (strpos($cell_data[0], '[[') === true ) {
if ($pmaString->strpos($cell_data[0], '[[') === true ) {
if (count($cell_data) == 1) {
$cell = $cell_data[0];
} else {
@ -275,8 +278,8 @@ class ImportMediawiki extends ImportPlugin
$cell = trim($cell);
$col_start_chars = array( "|", "!");
foreach ($col_start_chars as $col_start_char) {
if (strpos($cell, $col_start_char) === 0) {
$cell = trim(substr($cell, 1));
if ($pmaString->strpos($cell, $col_start_char) === 0) {
$cell = trim($pmaString->substr($cell, 1));
}
}
@ -396,13 +399,7 @@ class ImportMediawiki extends ImportPlugin
// $db_name : The currently selected database name, if applicable
// No backquotes
// $options : An associative array of options
if (strlen($db)) {
$db_name = $db;
$options = array('create_db' => false);
} else {
$db_name = 'mediawiki_DB';
$options = null;
}
list($db_name, $options) = $this->getDbnameAndOptions($db, 'mediawiki_DB');
// Array of SQL strings
// Non-applicable parameters

View File

@ -368,13 +368,7 @@ class ImportOds extends ImportPlugin
*/
/* Set database name to the currently selected one, if applicable */
if (strlen($db)) {
$db_name = $db;
$options = array('create_db' => false);
} else {
$db_name = 'ODS_DB';
$options = null;
}
list($db_name, $options) = $this->getDbnameAndOptions($db, 'ODS_DB');
/* Non-applicable parameters */
$create = null;

View File

@ -69,6 +69,9 @@ class ImportShp extends ImportPlugin
global $db, $error, $finished, $compression,
$import_file, $local_import_file, $message;
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$GLOBALS['finished'] = false;
$shp = new PMA_ShapeFile(1);
@ -107,8 +110,8 @@ class ImportShp extends ImportPlugin
$temp_dbf_file = true;
// Replace the .dbf with .*, as required
// by the bsShapeFiles library.
$file_name = substr(
$dbf_file_path, 0, strlen($dbf_file_path) - 4
$file_name = $pmaString->substr(
$dbf_file_path, 0, $pmaString->strlen($dbf_file_path) - 4
) . '.*';
$shp->FileName = $file_name;
}
@ -121,8 +124,11 @@ class ImportShp extends ImportPlugin
// to load extra data.
// Replace the .shp with .*,
// so the bsShapeFiles library correctly locates .dbf file.
$file_name = substr($import_file, 0, strlen($import_file) - 4)
. '.*';
$file_name = $pmaString->substr(
$import_file,
0,
$pmaString->strlen($import_file) - 4
) . '.*';
$shp->FileName = $file_name;
}
}
@ -255,7 +261,7 @@ class ImportShp extends ImportPlugin
}
// Set table name based on the number of tables
if (strlen($db)) {
if ($pmaString->strlen($db)) {
$result = $GLOBALS['dbi']->fetchResult('SHOW TABLES');
$table_name = 'TABLE ' . (count($result) + 1);
} else {
@ -272,7 +278,7 @@ class ImportShp extends ImportPlugin
$analyses[$table_no][FORMATTEDSQL][$spatial_col] = true;
// Set database name to the currently selected one, if applicable
if (strlen($db)) {
if ($pmaString->strlen($db)) {
$db_name = $db;
$options = array('create_db' => false);
} else {

View File

@ -111,6 +111,9 @@ class ImportSql extends ImportPlugin
{
global $error, $timeout_passed;
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$buffer = '';
// Defaults for parser
$sql = '';
@ -120,7 +123,7 @@ class ImportSql extends ImportPlugin
$big_value = 2147483647;
// include the space because it's mandatory
$delimiter_keyword = 'DELIMITER ';
$length_of_delimiter_keyword = strlen($delimiter_keyword);
$length_of_delimiter_keyword = $pmaString->strlen($delimiter_keyword);
if (isset($_POST['sql_delimiter'])) {
$sql_delimiter = $_POST['sql_delimiter'];
@ -159,7 +162,7 @@ class ImportSql extends ImportPlugin
$data = PMA_importGetNextChunk();
if ($data === false) {
// subtract data we didn't handle yet and stop processing
$GLOBALS['offset'] -= strlen($buffer);
$GLOBALS['offset'] -= $pmaString->strlen($buffer);
break;
} elseif ($data === true) {
// Handle rest of buffer
@ -170,7 +173,7 @@ class ImportSql extends ImportPlugin
unset($data);
// Do not parse string when we're not at the end
// and don't have ; inside
if ((strpos($buffer, $sql_delimiter, $i) === false)
if (($pmaString->strpos($buffer, $sql_delimiter, $i) === false)
&& ! $GLOBALS['finished']
) {
continue;
@ -182,7 +185,7 @@ class ImportSql extends ImportPlugin
$buffer = preg_replace("/\r($|[^\n])/", "\n$1", $buffer);
// Current length of our buffer
$len = strlen($buffer);
$len = $pmaString->strlen($buffer);
// Grab some SQL queries out of it
while ($i < $len) {
@ -211,7 +214,11 @@ class ImportSql extends ImportPlugin
* inside quotes (or even double-quotes)
*/
// the cost of doing this one with preg_match() would be too high
$first_sql_delimiter = strpos($buffer, $sql_delimiter, $i);
$first_sql_delimiter = $pmaString->strpos(
$buffer,
$sql_delimiter,
$i
);
if ($first_sql_delimiter === false) {
$first_sql_delimiter = $big_value;
} else {
@ -236,19 +243,19 @@ class ImportSql extends ImportPlugin
break;
}
// We hit end of query, go there!
$i = strlen($buffer) - 1;
$i = $pmaString->strlen($buffer) - 1;
}
// Grab current character
$ch = $buffer[$i];
// Quotes
if (strpos('\'"`', $ch) !== false) {
if ($pmaString->strpos('\'"`', $ch) !== false) {
$quote = $ch;
$endq = false;
while (! $endq) {
// Find next quote
$pos = strpos($buffer, $quote, $i + 1);
$pos = $pmaString->strpos($buffer, $quote, $i + 1);
/*
* Behave same as MySQL and accept end of query as end
* of backtick.
@ -314,13 +321,17 @@ class ImportSql extends ImportPlugin
) {
// Copy current string to SQL
if ($start_pos != $i) {
$sql .= substr($buffer, $start_pos, $i - $start_pos);
$sql .= $pmaString->substr(
$buffer,
$start_pos,
$i - $start_pos
);
}
// Skip the rest
$start_of_comment = $i;
// do not use PHP_EOL here instead of "\n", because the export
// file might have been produced on a different system
$i = strpos($buffer, $ch == '/' ? '*/' : "\n", $i);
$i = $pmaString->strpos($buffer, $ch == '/' ? '*/' : "\n", $i);
// didn't we hit end of string?
if ($i === false) {
if ($GLOBALS['finished']) {
@ -337,7 +348,7 @@ class ImportSql extends ImportPlugin
$i++;
// We need to send the comment part in case we are defining
// a procedure or function and comments in it are valuable
$sql .= substr(
$sql .= $pmaString->substr(
$buffer,
$start_of_comment,
$i - $start_of_comment
@ -354,13 +365,13 @@ class ImportSql extends ImportPlugin
// Change delimiter, if redefined, and skip it
// (don't send to server!)
if (($i + $length_of_delimiter_keyword < $len)
&& strtoupper(
substr($buffer, $i, $length_of_delimiter_keyword)
&& $pmaString->strtoupper(
$pmaString->substr($buffer, $i, $length_of_delimiter_keyword)
) == $delimiter_keyword
) {
// look for EOL on the character immediately after 'DELIMITER '
// (see previous comment about PHP_EOL)
$new_line_pos = strpos(
$new_line_pos = $pmaString->strpos(
$buffer,
"\n",
$i + $length_of_delimiter_keyword
@ -369,7 +380,7 @@ class ImportSql extends ImportPlugin
if (false === $new_line_pos) {
$new_line_pos = $len;
}
$sql_delimiter = substr(
$sql_delimiter = $pmaString->substr(
$buffer,
$i + $length_of_delimiter_keyword,
$new_line_pos - $i - $length_of_delimiter_keyword
@ -392,7 +403,11 @@ class ImportSql extends ImportPlugin
if (! $found_delimiter) {
$length_to_grab++;
}
$tmp_sql .= substr($buffer, $start_pos, $length_to_grab);
$tmp_sql .= $pmaString->substr(
$buffer,
$start_pos,
$length_to_grab
);
unset($length_to_grab);
}
// Do not try to execute empty SQL
@ -400,20 +415,27 @@ class ImportSql extends ImportPlugin
$sql = $tmp_sql;
PMA_importRunQuery(
$sql,
substr($buffer, 0, $i + strlen($sql_delimiter)),
$pmaString->substr(
$buffer,
0,
$i + $pmaString->strlen($sql_delimiter)
),
false,
$sql_data
);
$buffer = substr($buffer, $i + strlen($sql_delimiter));
$buffer = $pmaString->substr(
$buffer,
$i + $pmaString->strlen($sql_delimiter)
);
// Reset parser:
$len = strlen($buffer);
$len = $pmaString->strlen($buffer);
$sql = '';
$i = 0;
$start_pos = 0;
// Any chance we will get a complete query?
//if ((strpos($buffer, ';') === false)
//&& ! $GLOBALS['finished']) {
if (strpos($buffer, $sql_delimiter) === false
if ($pmaString->strpos($buffer, $sql_delimiter) === false
&& ! $GLOBALS['finished']
) {
break;
@ -426,7 +448,12 @@ class ImportSql extends ImportPlugin
} // End of parser loop
} // End of import loop
// Commit any possible data in buffers
PMA_importRunQuery('', substr($buffer, 0, $len), false, $sql_data);
PMA_importRunQuery(
'',
$pmaString->substr($buffer, 0, $len),
false,
$sql_data
);
PMA_importRunQuery('', '', false, $sql_data);
}

View File

@ -176,7 +176,9 @@ class PMA_DIA extends XMLWriter
$output = $this->flush();
PMA_Response::getInstance()->disable();
PMA_downloadHeader(
$fileName . '.dia', 'application/x-dia-diagram', strlen($output)
$fileName . '.dia',
'application/x-dia-diagram',
$GLOBALS['PMA_String']->strlen($output)
);
print $output;
}

View File

@ -294,7 +294,11 @@ class PMA_EPS
//}
$output = $this->stringCommands;
PMA_Response::getInstance()->disable();
PMA_downloadHeader($fileName . '.eps', 'image/x-eps', strlen($output));
PMA_downloadHeader(
$fileName . '.eps',
'image/x-eps',
$GLOBALS['PMA_String']->strlen($output)
);
print $output;
}
}

View File

@ -345,13 +345,16 @@ class PMA_Schema_PDF extends PMA_PDF
*/
function NbLines($w, $txt)
{
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
$cw = &$this->CurrentFont['cw'];
if ($w == 0) {
$w = $this->w - $this->rMargin - $this->x;
}
$wmax = ($w-2 * $this->cMargin) * 1000 / $this->FontSize;
$s = str_replace("\r", '', $txt);
$nb = strlen($s);
$nb = $pmaString->strlen($s);
if ($nb > 0 and $s[$nb-1] == "\n") {
$nb--;
}
@ -373,7 +376,7 @@ class PMA_Schema_PDF extends PMA_PDF
if ($c == ' ') {
$sep = $i;
}
$l += isset($cw[ord($c)])?$cw[ord($c)]:0 ;
$l += isset($cw[$pmaString->ord($c)])?$cw[$pmaString->ord($c)]:0 ;
if ($l > $wmax) {
if ($sep == -1) {
if ($i == $j) {

Some files were not shown because too many files have changed in this diff Show More