Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.php2
-rw-r--r--db_datadict.php2
-rw-r--r--db_operations.php8
-rw-r--r--db_printview.php2
-rw-r--r--examples/openid.php2
-rw-r--r--export.php10
-rw-r--r--file_echo.php14
-rw-r--r--gis_data_editor.php15
-rw-r--r--import.php32
-rw-r--r--import_status.php10
-rw-r--r--index.php13
-rw-r--r--libraries/Advisor.class.php9
-rw-r--r--libraries/Config.class.php170
-rw-r--r--libraries/DBQbe.class.php65
-rw-r--r--libraries/DatabaseInterface.class.php76
-rw-r--r--libraries/DbSearch.class.php6
-rw-r--r--libraries/DisplayResults.class.php650
-rw-r--r--libraries/Error.class.php6
-rw-r--r--libraries/File.class.php2
-rw-r--r--libraries/Font.class.php11
-rw-r--r--libraries/Header.class.php8
-rw-r--r--libraries/Index.class.php8
-rw-r--r--libraries/List_Database.class.php4
-rw-r--r--libraries/Menu.class.php25
-rw-r--r--libraries/Message.class.php8
-rw-r--r--libraries/PDF.class.php6
-rw-r--r--libraries/RecentFavoriteTable.class.php7
-rw-r--r--libraries/Response.class.php8
-rw-r--r--libraries/Scripts.class.php21
-rw-r--r--libraries/ServerStatusData.class.php7
-rw-r--r--libraries/StorageEngine.class.php20
-rw-r--r--libraries/String.class.php125
-rw-r--r--libraries/StringByte.int.php94
-rw-r--r--libraries/StringMB.class.php196
-rw-r--r--libraries/StringNative.class.php124
-rw-r--r--libraries/StringType.int.php1
-rw-r--r--libraries/Table.class.php65
-rw-r--r--libraries/TableSearch.class.php13
-rw-r--r--libraries/Tracker.class.php74
-rw-r--r--libraries/Types.class.php8
-rw-r--r--libraries/Util.class.php293
-rw-r--r--libraries/bookmark.lib.php6
-rw-r--r--libraries/build_html_for_db.lib.php7
-rw-r--r--libraries/central_columns.lib.php7
-rw-r--r--libraries/check_user_privileges.lib.php22
-rw-r--r--libraries/common.inc.php28
-rw-r--r--libraries/config/Form.class.php21
-rw-r--r--libraries/config/FormDisplay.class.php12
-rw-r--r--libraries/config/FormDisplay.tpl.php4
-rw-r--r--libraries/config/ServerConfigChecks.class.php2
-rw-r--r--libraries/config/Validator.class.php11
-rw-r--r--libraries/core.lib.php49
-rw-r--r--libraries/db_common.inc.php6
-rw-r--r--libraries/db_designer.lib.php21
-rw-r--r--libraries/db_table_exists.lib.php12
-rw-r--r--libraries/display_change_password.lib.php11
-rw-r--r--libraries/display_export.lib.php17
-rw-r--r--libraries/display_git_revision.lib.php4
-rw-r--r--libraries/error_report.lib.php6
-rw-r--r--libraries/export.lib.php60
-rw-r--r--libraries/file_listing.lib.php2
-rw-r--r--libraries/gis/GIS_Factory.class.php8
-rw-r--r--libraries/gis/GIS_Geometry.class.php42
-rw-r--r--libraries/gis/GIS_Geometrycollection.class.php85
-rw-r--r--libraries/gis/GIS_Linestring.class.php70
-rw-r--r--libraries/gis/GIS_Multilinestring.class.php88
-rw-r--r--libraries/gis/GIS_Multipoint.class.php79
-rw-r--r--libraries/gis/GIS_Multipolygon.class.php106
-rw-r--r--libraries/gis/GIS_Point.class.php42
-rw-r--r--libraries/gis/GIS_Polygon.class.php88
-rw-r--r--libraries/gis/GIS_Visualization.class.php28
-rw-r--r--libraries/iconv_wrapper.lib.php25
-rw-r--r--libraries/import.lib.php99
-rw-r--r--libraries/insert_edit.lib.php121
-rw-r--r--libraries/ip_allow_deny.lib.php20
-rw-r--r--libraries/mime.lib.php8
-rw-r--r--libraries/mult_submits.inc.php6
-rw-r--r--libraries/mult_submits.lib.php21
-rw-r--r--libraries/navigation/NavigationHeader.class.php84
-rw-r--r--libraries/navigation/NavigationTree.class.php24
-rw-r--r--libraries/navigation/Nodes/Node_Database.class.php4
-rw-r--r--libraries/normalization.lib.php4
-rw-r--r--libraries/operations.lib.php25
-rw-r--r--libraries/parse_analyze.inc.php2
-rw-r--r--libraries/plugin_interface.lib.php42
-rw-r--r--libraries/plugins/auth/AuthenticationCookie.class.php7
-rw-r--r--libraries/plugins/export/ExportCsv.class.php8
-rw-r--r--libraries/plugins/export/ExportLatex.class.php18
-rw-r--r--libraries/plugins/export/ExportSql.class.php626
-rw-r--r--libraries/plugins/export/ExportXml.class.php5
-rw-r--r--libraries/plugins/export/TableProperty.class.php44
-rw-r--r--libraries/plugins/import/ImportCsv.class.php33
-rw-r--r--libraries/plugins/import/ImportMediawiki.class.php27
-rw-r--r--libraries/plugins/import/ImportShp.class.php18
-rw-r--r--libraries/plugins/import/ImportSql.class.php69
-rw-r--r--libraries/plugins/schema/dia/Dia_Relation_Schema.class.php4
-rw-r--r--libraries/plugins/schema/eps/Eps_Relation_Schema.class.php6
-rw-r--r--libraries/plugins/schema/pdf/Pdf_Relation_Schema.class.php7
-rw-r--r--libraries/plugins/schema/svg/Svg_Relation_Schema.class.php6
-rw-r--r--libraries/plugins/transformations/abstract/DateFormatTransformationsPlugin.class.php37
-rw-r--r--libraries/plugins/transformations/abstract/SubstringTransformationsPlugin.class.php10
-rw-r--r--libraries/pmd_common.php18
-rw-r--r--libraries/relation.lib.php26
-rw-r--r--libraries/replication.inc.php7
-rw-r--r--libraries/replication_gui.lib.php14
-rw-r--r--libraries/rte/rte_events.lib.php14
-rw-r--r--libraries/rte/rte_footer.lib.php9
-rw-r--r--libraries/rte/rte_main.inc.php2
-rw-r--r--libraries/rte/rte_routines.lib.php83
-rw-r--r--libraries/rte/rte_triggers.lib.php14
-rw-r--r--libraries/rte/rte_words.lib.php2
-rw-r--r--libraries/sanitizing.lib.php6
-rw-r--r--libraries/select_lang.lib.php13
-rw-r--r--libraries/server_databases.lib.php2
-rw-r--r--libraries/server_plugins.lib.php9
-rw-r--r--libraries/server_privileges.lib.php207
-rw-r--r--libraries/server_status_monitor.lib.php30
-rw-r--r--libraries/server_status_processes.lib.php8
-rw-r--r--libraries/server_status_variables.lib.php9
-rw-r--r--libraries/server_user_groups.lib.php17
-rw-r--r--libraries/server_variables.lib.php2
-rw-r--r--libraries/sql.lib.php31
-rw-r--r--libraries/sql_query_form.lib.php16
-rw-r--r--libraries/sqlparser.lib.php215
-rw-r--r--libraries/structure.lib.php81
-rw-r--r--libraries/sysinfo.lib.php8
-rw-r--r--libraries/tbl_columns_definition_form.inc.php6
-rw-r--r--libraries/tbl_columns_definition_form.lib.php28
-rw-r--r--libraries/tbl_indexes.lib.php5
-rw-r--r--libraries/tbl_info.inc.php7
-rw-r--r--libraries/tbl_relation.lib.php136
-rw-r--r--libraries/tbl_tracking.lib.php36
-rw-r--r--libraries/transformations.lib.php33
-rw-r--r--libraries/url_generating.lib.php14
-rw-r--r--prefs_manage.php10
-rw-r--r--scripts/decode_bug.php5
-rw-r--r--setup/frames/index.inc.php3
-rw-r--r--setup/lib/ConfigGenerator.class.php2
-rw-r--r--sql.php7
-rw-r--r--tbl_addfield.php4
-rw-r--r--tbl_change.php2
-rw-r--r--tbl_chart.php11
-rw-r--r--tbl_create.php7
-rw-r--r--tbl_get_field.php2
-rw-r--r--tbl_operations.php9
-rw-r--r--tbl_printview.php7
-rw-r--r--test/bootstrap-dist.php1
-rw-r--r--test/classes/PMA_Config_test.php18
-rw-r--r--test/classes/PMA_DisplayResults_test.php1
-rw-r--r--test/classes/plugin/auth/PMA_AuthenticationCookie_test.php2
-rw-r--r--test/classes/plugin/import/ImportShp_test.php1
-rw-r--r--test/libraries/PMA_StringMB_test.php48
-rw-r--r--test/libraries/PMA_StringNative_test.php48
-rw-r--r--test/libraries/PMA_String_Compare_test.php1161
-rw-r--r--test/libraries/PMA_browse_foreigners_test.php1
-rw-r--r--test/libraries/PMA_central_columns_test.php9
-rw-r--r--test/libraries/PMA_display_export_test.php2
-rw-r--r--test/libraries/PMA_relation_cleanup_test.php15
-rw-r--r--test/libraries/core/PMA_warnMissingExtension_test.php2
-rw-r--r--test/selenium/PmaSeleniumTableInsertTest.php2
-rw-r--r--test/selenium/PmaSeleniumXssTest.php2
-rw-r--r--test/selenium/TestBase.php12
-rw-r--r--themes/svg_gradient.php2
-rw-r--r--transformation_wrapper.php2
164 files changed, 5126 insertions, 1954 deletions
diff --git a/changelog.php b/changelog.php
index 5066ffe03e..7d42ea185a 100644
--- a/changelog.php
+++ b/changelog.php
@@ -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();
diff --git a/db_datadict.php b/db_datadict.php
index bb0f4eba0a..8fa41c8488 100644
--- a/db_datadict.php
+++ b/db_datadict.php
@@ -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);
diff --git a/db_operations.php b/db_operations.php
index 2e88b45d8c..9d48bb3009 100644
--- a/db_operations.php
+++ b/db_operations.php
@@ -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
diff --git a/db_printview.php b/db_printview.php
index edb25d82da..56edcbe9c4 100644
--- a/db_printview.php
+++ b/db_printview.php
@@ -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 {
diff --git a/examples/openid.php b/examples/openid.php
index bc0a6bf902..804fa4c0a8 100644
--- a/examples/openid.php
+++ b/examples/openid.php
@@ -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';
diff --git a/export.php b/export.php
index b8e46d4dcf..f861ac7be2 100644
--- a/export.php
+++ b/export.php
@@ -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!'));
diff --git a/file_echo.php b/file_echo.php
index d910b74e28..21b16796e3 100644
--- a/file_echo.php
+++ b/file_echo.php
@@ -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;
diff --git a/gis_data_editor.php b/gis_data_editor.php
index 546f700fb7..57add856c2 100644
--- a/gis_data_editor.php
+++ b/gis_data_editor.php
@@ -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']))
diff --git a/import.php b/import.php
index 046b08bc59..ae8d48d517 100644
--- a/import.php
+++ b/import.php
@@ -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';
}
diff --git a/import_status.php b/import_status.php
index 45e11fcd31..6b6e04b369 100644
--- a/import_status.php
+++ b/import_status.php
@@ -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]);
diff --git a/index.php b/index.php
index bdae1102f1..15be026dcd 100644
--- a/index.php
+++ b/index.php
@@ -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 . '-', '-')
)
)
),
diff --git a/libraries/Advisor.class.php b/libraries/Advisor.class.php
index 61ce36ec71..593d55a996 100644
--- a/libraries/Advisor.class.php
+++ b/libraries/Advisor.class.php
@@ -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;
}
diff --git a/libraries/Config.class.php b/libraries/Config.class.php
index a0a8707533..d3b33fc8f1 100644
--- a/libraries/Config.class.php
+++ b/libraries/Config.class.php
@@ -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);
}
diff --git a/libraries/DBQbe.class.php b/libraries/DBQbe.class.php
index dd14979ec5..a2c271a702 100644
--- a/libraries/DBQbe.class.php
+++ b/libraries/DBQbe.class.php
@@ -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,6 +454,10 @@ class PMA_DbQbe
$html_output = '<tr class="even noclick">';
$html_output .= '<th>' . __('Sort:') . '</th>';
$new_column_count = 0;
+
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
for (
$column_index = 0;
$column_index < $this->_criteria_column_count;
@@ -477,7 +481,7 @@ class PMA_DbQbe
// 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) == '.*'
+ && $pmaString->substr($_REQUEST['criteriaColumn'][$column_index], -2) == '.*'
) {
$_REQUEST['criteriaSort'][$column_index] = '';
} //end if
@@ -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;
diff --git a/libraries/DatabaseInterface.class.php b/libraries/DatabaseInterface.class.php
index 8eda8304ae..0f2bcc378c 100644
--- a/libraries/DatabaseInterface.class.php
+++ b/libraries/DatabaseInterface.class.php
@@ -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');
}
diff --git a/libraries/DbSearch.class.php b/libraries/DbSearch.class.php
index 9fcd2e75f4..8d029dc827 100644
--- a/libraries/DbSearch.class.php
+++ b/libraries/DbSearch.class.php
@@ -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
diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php
index 921fa09628..7553dbd3e5 100644
--- a/libraries/DisplayResults.class.php
+++ b/libraries/DisplayResults.class.php
@@ -387,6 +387,8 @@ class PMA_DisplayResults
// 2. Display mode is not "false for all elements" -> updates the
// display mode
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
if ($the_disp_mode != 'nnnn000000') {
if (isset($printview) && ($printview == '1')) {
@@ -433,7 +435,7 @@ class PMA_DisplayResults
$this->__get('sql_query'), $which
);
if (isset($which[1])
- && (strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0)
+ && ($pmaString->strpos(' ' . $pmaString->strtoupper($which[1]), 'PROCESSLIST') > 0)
) {
// no edit link
$do_display['edit_lnk'] = self::NO_EDIT_OR_DELETE;
@@ -500,7 +502,7 @@ class PMA_DisplayResults
$the_total = $unlim_num_rows;
} elseif ((($do_display['nav_bar'] == '1')
|| ($do_display['sort_lnk'] == '1'))
- && (strlen($db) && !empty($table))
+ && ($pmaString->strlen($db) && !empty($table))
) {
$the_total = PMA_Table::countRecords($db, $table);
}
@@ -1842,7 +1844,7 @@ class PMA_DisplayResults
// FROM `PMA_relation` AS `1` , `PMA_relation` AS `2`
$sort_tbl = (isset($fields_meta->table)
- && strlen($fields_meta->table))
+ && $GLOBALS['PMA_String']->strlen($fields_meta->table))
? PMA_Util::backquote(
$fields_meta->table
) . '.'
@@ -1945,6 +1947,9 @@ class PMA_DisplayResults
)) ? self::DESCENDING_SORT_DIR : self::ASCENDING_SORT_DIR;
}
+
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
$sort_expression_nodirection = array_filter($sort_expression_nodirection);
foreach ($sort_expression_nodirection as $index=>$expression) {
// check if this is the first clause,
@@ -1954,7 +1959,7 @@ class PMA_DisplayResults
$sort_tbl_new = $sort_tbl;
// Test to detect if the column name is a standard name
// Standard name has the table name prefixed to the column name
- if (strpos($name_to_use_in_sort, '.') !== false) {
+ if ($pmaString->strpos($name_to_use_in_sort, '.') !== false) {
$matches = explode('.', $name_to_use_in_sort);
// Matches[0] has the table name
// Matches[1] has the column name
@@ -1972,7 +1977,7 @@ class PMA_DisplayResults
// order by clause to the column name
$query_head = $is_first_clause ? "\nORDER BY " : "";
// Again a check to see if the given column is a aggregate column
- if (strpos($name_to_use_in_sort, '(') !== false) {
+ if ($pmaString->strpos($name_to_use_in_sort, '(') !== false) {
$sort_order .= $query_head . $name_to_use_in_sort . ' ' ;
} else {
$sort_order .= $query_head . $sort_tbl_new . "."
@@ -1986,7 +1991,7 @@ class PMA_DisplayResults
$sort_order = preg_replace("/\.\./", ".", $sort_order);
// Incase this is the current column save $single_sort_order
if ($current_name == $name_to_use_in_sort) {
- if (strpos($current_name, '(') !== false) {
+ if ($pmaString->strpos($current_name, '(') !== false) {
$single_sort_order = "\n" . 'ORDER BY ' . $current_name . ' ';
} else {
$single_sort_order = "\n" . 'ORDER BY ' . $sort_tbl
@@ -1999,7 +2004,8 @@ class PMA_DisplayResults
$sort_direction, $single_sort_order, $column_index, $index
);
} else {
- $single_sort_order .= strtoupper($sort_direction[$index]);
+ $single_sort_order .= $pmaString
+ ->strtoupper($sort_direction[$index]);
}
}
if ($current_name == $name_to_use_in_sort && $is_in_sort) {
@@ -2009,7 +2015,7 @@ class PMA_DisplayResults
);
$order_img .= " <small>" . ($index + 1) . "</small>";
} else {
- $sort_order .= strtoupper($sort_direction[$index]);
+ $sort_order .= $pmaString->strtoupper($sort_direction[$index]);
}
// Separate columns by a comma
$sort_order .= ", ";
@@ -2018,7 +2024,11 @@ class PMA_DisplayResults
}
// remove the comma from the last column name in the newly
// constructed clause
- $sort_order = substr($sort_order, 0, strlen($sort_order)-2);
+ $sort_order = $pmaString->substr(
+ $sort_order,
+ 0,
+ $pmaString->strlen($sort_order)-2
+ );
if (empty($order_img)) {
$order_img = '';
}
@@ -2046,8 +2056,10 @@ class PMA_DisplayResults
$index_in_expression = 0;
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
foreach ($sort_expression_nodirection as $index => $clause) {
- if (strpos($clause, '.') !== false) {
+ if ($pmaString->strpos($clause, '.') !== false) {
$fragments = explode('.', $clause);
$clause2 = $fragments[0] . "." . str_replace('`', '', $fragments[1]);
} else {
@@ -2071,8 +2083,8 @@ class PMA_DisplayResults
// SELECT p.*, FROM_UNIXTIME(p.temps) FROM mytable AS p
// (and try clicking on each column's header twice)
if (! empty($sort_tbl)
- && strpos($sort_expression_nodirection[$index_in_expression], $sort_tbl) === false
- && strpos($sort_expression_nodirection[$index_in_expression], '(') === false
+ && $pmaString->strpos($sort_expression_nodirection[$index_in_expression], $sort_tbl) === false
+ && $pmaString->strpos($sort_expression_nodirection[$index_in_expression], '(') === false
) {
$new_sort_expression_nodirection = $sort_tbl
. $sort_expression_nodirection[$index_in_expression];
@@ -2117,7 +2129,7 @@ class PMA_DisplayResults
private function _getSortingUrlParams(
$sort_direction, $sort_order, $column_index, $index
) {
- if (strtoupper(trim($sort_direction[$index])) == self::DESCENDING_SORT_DIR) {
+ if ($GLOBALS['PMA_String']->strtoupper(trim($sort_direction[$index])) == self::DESCENDING_SORT_DIR) {
$sort_order .= ' ASC';
$order_img = ' ' . PMA_Util::getImage(
's_desc.png', __('Descending'),
@@ -2161,13 +2173,15 @@ class PMA_DisplayResults
private function _getSortOrderLink(
$order_img, $col_index, $direction, $fields_meta, $order_url, $multi_order_url
) {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
$order_link_params = array();
if (isset($order_img) && ($order_img != '')) {
- if (strstr($order_img, 'asc')) {
+ if ($pmaString->strstr($order_img, 'asc')) {
$order_link_params['onmouseover'] = "$('.soimg$col_index').toggle()";
$order_link_params['onmouseout'] = "$('.soimg$col_index').toggle()";
- } elseif (strstr($order_img, 'desc')) {
+ } elseif ($pmaString->strstr($order_img, 'desc')) {
$order_link_params['onmouseover'] = "$('.soimg$col_index').toggle()";
$order_link_params['onmouseout'] = "$('.soimg$col_index').toggle()";
}
@@ -2537,13 +2551,15 @@ class PMA_DisplayResults
'binary' => 'hex',
);
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
foreach ($matches as $key => $value) {
- if (strpos($meta->flags, $key) !== false) {
+ if ($pmaString->strpos($meta->flags, $key) !== false) {
$classes[] = $value;
}
}
- if (strpos($meta->type, 'bit') !== false) {
+ if ($pmaString->strpos($meta->type, 'bit') !== false) {
$classes[] = 'bit';
}
@@ -2813,6 +2829,8 @@ class PMA_DisplayResults
$row_info = $this->_getRowInfoForSpecialLinks($row, $col_order);
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
for ($currentColumn = 0;
$currentColumn < $this->__get('fields_cnt');
++$currentColumn) {
@@ -2912,18 +2930,18 @@ class PMA_DisplayResults
// Check whether the field needs to display with syntax highlighting
- if (! empty($this->transformation_info[strtolower($this->__get('db'))][strtolower($this->__get('table'))][strtolower($meta->name)])
+ if (! empty($this->transformation_info[$pmaString->strtolower($this->__get('db'))][$pmaString->strtolower($this->__get('table'))][$pmaString->strtolower($meta->name)])
&& (trim($row[$i]) != '')
) {
$row[$i] = PMA_Util::formatSql($row[$i]);
include_once $this->transformation_info
- [strtolower($this->__get('db'))]
- [strtolower($this->__get('table'))]
- [strtolower($meta->name)][0];
+ [$pmaString->strtolower($this->__get('db'))]
+ [$pmaString->strtolower($this->__get('table'))]
+ [$pmaString->strtolower($meta->name)][0];
$transformation_plugin = new $this->transformation_info
- [strtolower($this->__get('db'))]
- [strtolower($this->__get('table'))]
- [strtolower($meta->name)][1](null);
+ [$pmaString->strtolower($this->__get('db'))]
+ [$pmaString->strtolower($this->__get('table'))]
+ [$pmaString->strtolower($meta->name)][1](null);
$transform_options = PMA_Transformation_getOptions(
isset($mime_map[$meta->name]['transformation_options'])
@@ -2931,11 +2949,12 @@ class PMA_DisplayResults
: ''
);
+ $dbLower = $pmaString->strtolower($this->__get('db'));
$meta->mimetype = str_replace(
'_', '/',
- $this->transformation_info[strtolower($this->__get('db'))]
- [strtolower($this->__get('table'))]
- [strtolower($meta->name)][2]
+ $this->transformation_info[$dbLower]
+ [$pmaString->strtolower($this->__get('table'))]
+ [$pmaString->strtolower($meta->name)][2]
);
}
@@ -2944,11 +2963,11 @@ class PMA_DisplayResults
include_once 'libraries/special_schema_links.lib.php';
if (isset($GLOBALS['special_schema_links'])
- && (! empty($GLOBALS['special_schema_links'][strtolower($this->__get('db'))][strtolower($this->__get('table'))][strtolower($meta->name)]))
+ && (! empty($GLOBALS['special_schema_links'][$pmaString->strtolower($this->__get('db'))][$pmaString->strtolower($this->__get('table'))][$pmaString->strtolower($meta->name)]))
) {
$linking_url = $this->_getSpecialLinkUrl(
- $row[$i], $row_info, strtolower($meta->name)
+ $row[$i], $row_info, $pmaString->strtolower($meta->name)
);
include_once
"libraries/plugins/transformations/Text_Plain_Link.class.php";
@@ -3151,10 +3170,12 @@ class PMA_DisplayResults
private function _getSpecialLinkUrl($column_value, $row_info, $field_name)
{
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
$linking_url_params = array();
$link_relations = $GLOBALS['special_schema_links']
- [strtolower($this->__get('db'))]
- [strtolower($this->__get('table'))]
+ [$pmaString->strtolower($this->__get('db'))]
+ [$pmaString->strtolower($this->__get('table'))]
[$field_name];
if (! is_array($link_relations['link_param'])) {
@@ -3168,39 +3189,41 @@ class PMA_DisplayResults
$linking_url_params[$link_relations['link_param'][0]] = $sql;
}
- if (! empty($link_relations['link_dependancy_params'])) {
+ if (empty($link_relations['link_dependancy_params'])) {
+ return $link_relations['default_page']
+ . PMA_URL_getCommon($linking_url_params);
+ }
- foreach ($link_relations['link_dependancy_params'] as $new_param) {
+ foreach ($link_relations['link_dependancy_params'] as $new_param) {
- // If param_info is an array, set the key and value
- // from that array
- if (is_array($new_param['param_info'])) {
- $linking_url_params[$new_param['param_info'][0]]
- = $new_param['param_info'][1];
- } else {
+ // If param_info is an array, set the key and value
+ // from that array
+ if (is_array($new_param['param_info'])) {
+ $linking_url_params[$new_param['param_info'][0]]
+ = $new_param['param_info'][1];
+ continue;
+ }
- $linking_url_params[$new_param['param_info']]
- = $row_info[strtolower($new_param['column_name'])];
-
- // Special case 1 - when executing routines, according
- // to the type of the routine, url param changes
- if (!empty($row_info['routine_type'])) {
- $lowerRoutineType = strtolower($row_info['routine_type']);
- if ($lowerRoutineType == self::ROUTINE_PROCEDURE
- || $lowerRoutineType == self::ROUTINE_FUNCTION
- ) {
- $linking_url_params['edit_item'] = 1;
- }
- }
- }
+ $linking_url_params[$new_param['param_info']]
+ = $row_info[$pmaString->strtolower($new_param['column_name'])];
+ // Special case 1 - when executing routines, according
+ // to the type of the routine, url param changes
+ if (empty($row_info['routine_type'])) {
+ continue;
+ }
+
+ $lowerRoutineType = $pmaString->strtolower($row_info['routine_type']);
+ if ($lowerRoutineType == self::ROUTINE_PROCEDURE
+ || $lowerRoutineType == self::ROUTINE_FUNCTION
+ ) {
+ $linking_url_params['edit_item'] = 1;
}
}
return $link_relations['default_page']
. PMA_URL_getCommon($linking_url_params);
-
}
@@ -3220,7 +3243,8 @@ class PMA_DisplayResults
for ($n = 0; $n < $this->__get('fields_cnt'); ++$n) {
$m = $col_order ? $col_order[$n] : $n;
- $row_info[strtolower($fields_meta[$m]->name)] = $row[$m];
+ $row_info[$GLOBALS['PMA_String']->strtolower($fields_meta[$m]->name)]
+ = $row[$m];
}
return $row_info;
@@ -3246,7 +3270,7 @@ class PMA_DisplayResults
&& isset($analyzed_sql[0])
&& isset($analyzed_sql[0]['querytype'])
&& ($analyzed_sql[0]['querytype'] == self::QUERY_TYPE_SELECT)
- && (strlen($this->__get('sql_query')) > 200)
+ && ($GLOBALS['PMA_String']->strlen($this->__get('sql_query')) > 200)
) {
$url_sql_query = 'SELECT ';
@@ -3647,7 +3671,7 @@ class PMA_DisplayResults
*/
private function _getClassForDateTimeRelatedFields($type)
{
- if ((substr($type, 0, 9) == self::TIMESTAMP_FIELD)
+ if (($GLOBALS['PMA_String']->substr($type, 0, 9) == self::TIMESTAMP_FIELD)
|| ($type == self::DATETIME_FIELD)
) {
$field_type_class = 'datetimefield';
@@ -3750,75 +3774,77 @@ class PMA_DisplayResults
$transformation_plugin, $default_function, $transform_options,
$is_field_truncated, $analyzed_sql
) {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
if (! isset($column) || is_null($column)) {
-
$cell = $this->_buildNullDisplay($class, $condition_field, $meta);
+ return $cell;
+ }
- } elseif ($column != '') {
-
- // Display as [GEOMETRY - (size)]
- if ($_SESSION['tmpval']['geoOption'] == self::GEOMETRY_DISP_GEOM) {
-
- $geometry_text = $this->_handleNonPrintableContents(
- strtoupper(self::GEOMETRY_FIELD),
- (isset($column) ? $column : ''), $transformation_plugin,
- $transform_options, $default_function, $meta
- );
-
- $cell = $this->_buildValueDisplay(
- $class, $condition_field, $geometry_text
- );
+ if ($column == '') {
+ $cell = $this->_buildEmptyDisplay($class, $condition_field, $meta);
+ return $cell;
+ }
- } elseif ($_SESSION['tmpval']['geoOption'] == self::GEOMETRY_DISP_WKT) {
- // Prepare in Well Known Text(WKT) format.
+ // Display as [GEOMETRY - (size)]
+ if ($_SESSION['tmpval']['geoOption'] == self::GEOMETRY_DISP_GEOM) {
+ $geometry_text = $this->_handleNonPrintableContents(
+ $pmaString->strtoupper(self::GEOMETRY_FIELD),
+ (isset($column) ? $column : ''), $transformation_plugin,
+ $transform_options, $default_function, $meta
+ );
- $where_comparison = ' = ' . $column;
+ $cell = $this->_buildValueDisplay(
+ $class, $condition_field, $geometry_text
+ );
+ return $cell;
+ }
- // Convert to WKT format
- $wktval = PMA_Util::asWKT($column);
- $is_field_truncated = $this->_getPartialText($wktval);
+ if ($_SESSION['tmpval']['geoOption'] == self::GEOMETRY_DISP_WKT) {
+ // Prepare in Well Known Text(WKT) format.
+ $where_comparison = ' = ' . $column;
- $cell = $this->_getRowData(
- $class, $condition_field, $analyzed_sql, $meta, $map,
- $wktval, $transformation_plugin, $default_function, '',
- $where_comparison, $transform_options,
- $is_field_truncated
- );
+ // Convert to WKT format
+ $wktval = PMA_Util::asWKT($column);
+ $is_field_truncated = $this->_getPartialText($wktval);
- } else {
- // Prepare in Well Known Binary (WKB) format.
+ $cell = $this->_getRowData(
+ $class, $condition_field, $analyzed_sql, $meta, $map,
+ $wktval, $transformation_plugin, $default_function, '',
+ $where_comparison, $transform_options,
+ $is_field_truncated
+ );
+ return $cell;
+ }
- if ($_SESSION['tmpval']['display_binary']) {
+ // Prepare in Well Known Binary (WKB) format.
- $where_comparison = ' = ' . $column;
+ if ($_SESSION['tmpval']['display_binary']) {
+ $where_comparison = ' = ' . $column;
- $wkbval = $GLOBALS['PMA_String']->substr(bin2hex($column), 8);
- $is_field_truncated = $this->_getPartialText($wkbval);
+ $wkbval = $pmaString->substr(bin2hex($column), 8);
+ $is_field_truncated = $this->_getPartialText($wkbval);
- $cell = $this->_getRowData(
- $class, $condition_field,
- $analyzed_sql, $meta, $map, $wkbval,
- $transformation_plugin, $default_function, '',
- $where_comparison, $transform_options,
- $is_field_truncated
- );
+ $cell = $this->_getRowData(
+ $class, $condition_field,
+ $analyzed_sql, $meta, $map, $wkbval,
+ $transformation_plugin, $default_function, '',
+ $where_comparison, $transform_options,
+ $is_field_truncated
+ );
+ return $cell;
+ }
- } else {
- $wkbval = $this->_handleNonPrintableContents(
- self::BINARY_FIELD, $column, $transformation_plugin,
- $transform_options, $default_function, $meta,
- $_url_params
- );
+ $wkbval = $this->_handleNonPrintableContents(
+ self::BINARY_FIELD, $column, $transformation_plugin,
+ $transform_options, $default_function, $meta,
+ $_url_params
+ );
- $cell = $this->_buildValueDisplay(
- $class, $condition_field, $wkbval
- );
- }
- }
- } else {
- $cell = $this->_buildEmptyDisplay($class, $condition_field, $meta);
- }
+ $cell = $this->_buildValueDisplay(
+ $class, $condition_field, $wkbval
+ );
return $cell;
@@ -3861,6 +3887,8 @@ class PMA_DisplayResults
$transformation_plugin, $default_function, $transform_options,
$is_field_truncated, $analyzed_sql, &$dt_result, $col_index
) {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
$is_analyse = $this->__get('is_analyse');
$field_flags = $GLOBALS['dbi']->fieldFlags($dt_result, $col_index);
@@ -3875,107 +3903,105 @@ class PMA_DisplayResults
|| ($GLOBALS['cfg']['ProtectBinary'] === 'blob'
&& stristr($meta->type, self::BLOB_FIELD))))
|| (gettype($transformation_plugin) === 'object'
- && strpos($transformation_plugin->getMIMEtype(), 'Text') === false)
+ && $pmaString->strpos($transformation_plugin->getMIMEtype(), 'Text') === false)
) {
$class = str_replace('grid_edit', '', $class);
}
if (! isset($column) || is_null($column)) {
-
$cell = $this->_buildNullDisplay($class, $condition_field, $meta);
+ return $cell;
+ }
- } elseif ($column != '') {
-
- // Cut all fields to $GLOBALS['cfg']['LimitChars']
- // (unless it's a link-type transformation or binary)
- if (!(gettype($transformation_plugin) === "object"
- && strpos($transformation_plugin->getName(), 'Link') !== false)
- && !stristr($field_flags, self::BINARY_FIELD)
- ) {
- $is_field_truncated = $this->_getPartialText($column);
- }
+ if ($column == '') {
+ $cell = $this->_buildEmptyDisplay($class, $condition_field, $meta);
+ return $cell;
+ }
- $formatted = false;
- if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) {
+ // Cut all fields to $GLOBALS['cfg']['LimitChars']
+ // (unless it's a link-type transformation or binary)
+ if (!(gettype($transformation_plugin) === "object"
+ && $pmaString->strpos($transformation_plugin->getName(), 'Link') !== false)
+ && !stristr($field_flags, self::BINARY_FIELD)
+ ) {
+ $is_field_truncated = $this->_getPartialText($column);
+ }
- $column = PMA_Util::printableBitValue(
- $column, $meta->length
- );
+ $formatted = false;
+ if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) {
- // some results of PROCEDURE ANALYSE() are reported as
- // being BINARY but they are quite readable,
- // so don't treat them as BINARY
- } elseif (stristr($field_flags, self::BINARY_FIELD)
- && !(isset($is_analyse) && $is_analyse)
- ) {
- // we show the BINARY or BLOB message and field's size
- // (or maybe use a transformation)
- $binary_or_blob = self::BLOB_FIELD;
- if ($meta->type === self::STRING_FIELD) {
- $binary_or_blob = self::BINARY_FIELD;
- }
- $column = $this->_handleNonPrintableContents(
- $binary_or_blob, $column, $transformation_plugin,
- $transform_options, $default_function,
- $meta, $_url_params, $is_field_truncated
- );
- $class = $this->_addClass(
- $class, $condition_field, $meta, '',
- $is_field_truncated, $transformation_plugin, $default_function
- );
- $result = strip_tags($column);
- // disable inline grid editing
- // if binary or blob data is not shown
- if (stristr($result, $binary_or_blob)) {
- $class = str_replace('grid_edit', '', $class);
- }
- $formatted = true;
+ $column = PMA_Util::printableBitValue(
+ $column, $meta->length
+ );
- } elseif (((substr($meta->type, 0, 9) == self::TIMESTAMP_FIELD)
- || ($meta->type == self::DATETIME_FIELD)
- || ($meta->type == self::TIME_FIELD)
- || ($meta->type == self::TIME_FIELD))
- && (strpos($column, ".") === true)
- ) {
- $column = PMA_Util::addMicroseconds($column);
+ // some results of PROCEDURE ANALYSE() are reported as
+ // being BINARY but they are quite readable,
+ // so don't treat them as BINARY
+ } elseif (stristr($field_flags, self::BINARY_FIELD)
+ && !(isset($is_analyse) && $is_analyse)
+ ) {
+ // we show the BINARY or BLOB message and field's size
+ // (or maybe use a transformation)
+ $binary_or_blob = self::BLOB_FIELD;
+ if ($meta->type === self::STRING_FIELD) {
+ $binary_or_blob = self::BINARY_FIELD;
}
+ $column = $this->_handleNonPrintableContents(
+ $binary_or_blob, $column, $transformation_plugin,
+ $transform_options, $default_function,
+ $meta, $_url_params, $is_field_truncated
+ );
+ $class = $this->_addClass(
+ $class, $condition_field, $meta, '',
+ $is_field_truncated, $transformation_plugin, $default_function
+ );
+ $result = strip_tags($column);
+ // disable inline grid editing
+ // if binary or blob data is not shown
+ if (stristr($result, $binary_or_blob)) {
+ $class = str_replace('grid_edit', '', $class);
+ }
+ $formatted = true;
- if ($formatted) {
-
- $cell = $this->_buildValueDisplay(
- $class, $condition_field, $column
- );
-
- } else {
+ } elseif ((($pmaString->substr($meta->type, 0, 9) == self::TIMESTAMP_FIELD)
+ || ($meta->type == self::DATETIME_FIELD)
+ || ($meta->type == self::TIME_FIELD)
+ || ($meta->type == self::TIME_FIELD))
+ && ($pmaString->strpos($column, ".") === true)
+ ) {
+ $column = PMA_Util::addMicroseconds($column);
+ }
- // transform functions may enable no-wrapping:
- $function_nowrap = 'applyTransformationNoWrap';
+ if ($formatted) {
+ $cell = $this->_buildValueDisplay(
+ $class, $condition_field, $column
+ );
+ return $cell;
+ }
- $bool_nowrap = (($default_function != $transformation_plugin)
- && function_exists($transformation_plugin->$function_nowrap()))
- ? $transformation_plugin->$function_nowrap($transform_options)
- : false;
+ // transform functions may enable no-wrapping:
+ $function_nowrap = 'applyTransformationNoWrap';
- // do not wrap if date field type
- $nowrap = (preg_match('@DATE|TIME@i', $meta->type)
- || $bool_nowrap) ? ' nowrap' : '';
+ $bool_nowrap = (($default_function != $transformation_plugin)
+ && function_exists($transformation_plugin->$function_nowrap()))
+ ? $transformation_plugin->$function_nowrap($transform_options)
+ : false;
- $where_comparison = ' = \''
- . PMA_Util::sqlAddSlashes($column)
- . '\'';
+ // do not wrap if date field type
+ $nowrap = (preg_match('@DATE|TIME@i', $meta->type)
+ || $bool_nowrap) ? ' nowrap' : '';
- $cell = $this->_getRowData(
- $class, $condition_field,
- $analyzed_sql, $meta, $map, $column,
- $transformation_plugin, $default_function, $nowrap,
- $where_comparison, $transform_options,
- $is_field_truncated
- );
- }
+ $where_comparison = ' = \''
+ . PMA_Util::sqlAddSlashes($column)
+ . '\'';
- } else {
- $cell = $this->_buildEmptyDisplay($class, $condition_field, $meta);
- }
+ $cell = $this->_getRowData(
+ $class, $condition_field,
+ $analyzed_sql, $meta, $map, $column,
+ $transformation_plugin, $default_function, $nowrap,
+ $where_comparison, $transform_options,
+ $is_field_truncated
+ );
return $cell;
@@ -4509,8 +4535,11 @@ class PMA_DisplayResults
);
}
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
// 2.3 Prepare the navigation bars
- if (! strlen($this->__get('table'))) {
+ if (!$pmaString->strlen($this->__get('table'))) {
if (isset($analyzed_sql[0]['query_type'])
&& ($analyzed_sql[0]['query_type'] == self::QUERY_TYPE_SELECT)
@@ -4558,7 +4587,7 @@ class PMA_DisplayResults
}
- if (strlen($this->__get('table'))) {
+ if ($pmaString->strlen($this->__get('table'))) {
// This method set the values for $map array
$this->_setParamForLinkForeignKeyRelatedTables($map);
} // end if
@@ -4730,97 +4759,102 @@ class PMA_DisplayResults
$fields_meta = $this->__get('fields_meta'); // To use array indexes
- if (! empty($sort_expression_nodirection)) {
+ if (empty($sort_expression_nodirection)) {
+ return null;
+ }
- if (strpos($sort_expression_nodirection, '.') === false) {
- $sort_table = $this->__get('table');
- $sort_column = $sort_expression_nodirection;
- } else {
- list($sort_table, $sort_column)
- = explode('.', $sort_expression_nodirection);
- }
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+ if ($pmaString->strpos($sort_expression_nodirection, '.') === false) {
+ $sort_table = $this->__get('table');
+ $sort_column = $sort_expression_nodirection;
+ } else {
+ list($sort_table, $sort_column)
+ = explode('.', $sort_expression_nodirection);
+ }
- $sort_table = PMA_Util::unQuote($sort_table);
- $sort_column = PMA_Util::unQuote($sort_column);
+ $sort_table = PMA_Util::unQuote($sort_table);
+ $sort_column = PMA_Util::unQuote($sort_column);
- // find the sorted column index in row result
- // (this might be a multi-table query)
- $sorted_column_index = false;
+ // find the sorted column index in row result
+ // (this might be a multi-table query)
+ $sorted_column_index = false;
- foreach ($fields_meta as $key => $meta) {
- if (($meta->table == $sort_table) && ($meta->name == $sort_column)) {
- $sorted_column_index = $key;
- break;
- }
+ foreach ($fields_meta as $key => $meta) {
+ if (($meta->table == $sort_table) && ($meta->name == $sort_column)) {
+ $sorted_column_index = $key;
+ break;
}
+ }
- if ($sorted_column_index !== false) {
-
- // fetch first row of the result set
- $row = $GLOBALS['dbi']->fetchRow($dt_result);
-
- // initializing default arguments
- $default_function = 'PMA_mimeDefaultFunction';
- $transformation_plugin = $default_function;
- $transform_options = array();
+ if ($sorted_column_index === false) {
+ return null;
+ }
- // check for non printable sorted row data
- $meta = $fields_meta[$sorted_column_index];
+ // fetch first row of the result set
+ $row = $GLOBALS['dbi']->fetchRow($dt_result);
- if (stristr($meta->type, self::BLOB_FIELD)
- || ($meta->type == self::GEOMETRY_FIELD)
- ) {
+ // initializing default arguments
+ $default_function = 'PMA_mimeDefaultFunction';
+ $transformation_plugin = $default_function;
+ $transform_options = array();
- $column_for_first_row = $this->_handleNonPrintableContents(
- $meta->type, $row[$sorted_column_index],
- $transformation_plugin, $transform_options,
- $default_function, $meta, null
- );
+ // check for non printable sorted row data
+ $meta = $fields_meta[$sorted_column_index];
- } else {
- $column_for_first_row = $row[$sorted_column_index];
- }
-
- $column_for_first_row = strtoupper(
- substr($column_for_first_row, 0, $GLOBALS['cfg']['LimitChars'])
- );
+ if (stristr($meta->type, self::BLOB_FIELD)
+ || ($meta->type == self::GEOMETRY_FIELD)
+ ) {
- // fetch last row of the result set
- $GLOBALS['dbi']->dataSeek($dt_result, $this->__get('num_rows') - 1);
- $row = $GLOBALS['dbi']->fetchRow($dt_result);
+ $column_for_first_row = $this->_handleNonPrintableContents(
+ $meta->type, $row[$sorted_column_index],
+ $transformation_plugin, $transform_options,
+ $default_function, $meta, null
+ );
- // check for non printable sorted row data
- $meta = $fields_meta[$sorted_column_index];
- if (stristr($meta->type, self::BLOB_FIELD)
- || ($meta->type == self::GEOMETRY_FIELD)
- ) {
+ } else {
+ $column_for_first_row = $row[$sorted_column_index];
+ }
- $column_for_last_row = $this->_handleNonPrintableContents(
- $meta->type, $row[$sorted_column_index],
- $transformation_plugin, $transform_options,
- $default_function, $meta, null
- );
+ $column_for_first_row = $pmaString->strtoupper(
+ $pmaString->substr(
+ $column_for_first_row, 0, $GLOBALS['cfg']['LimitChars']
+ )
+ );
- } else {
- $column_for_last_row = $row[$sorted_column_index];
- }
+ // fetch last row of the result set
+ $GLOBALS['dbi']->dataSeek($dt_result, $this->__get('num_rows') - 1);
+ $row = $GLOBALS['dbi']->fetchRow($dt_result);
- $column_for_last_row = strtoupper(
- substr($column_for_last_row, 0, $GLOBALS['cfg']['LimitChars'])
- );
+ // check for non printable sorted row data
+ $meta = $fields_meta[$sorted_column_index];
+ if (stristr($meta->type, self::BLOB_FIELD)
+ || ($meta->type == self::GEOMETRY_FIELD)
+ ) {
- // reset to first row for the loop in _getTableBody()
- $GLOBALS['dbi']->dataSeek($dt_result, 0);
+ $column_for_last_row = $this->_handleNonPrintableContents(
+ $meta->type, $row[$sorted_column_index],
+ $transformation_plugin, $transform_options,
+ $default_function, $meta, null
+ );
- // we could also use here $sort_expression_nodirection
- return ' [' . htmlspecialchars($sort_column)
- . ': <strong>' . htmlspecialchars($column_for_first_row) . ' - '
- . htmlspecialchars($column_for_last_row) . '</strong>]';
- }
+ } else {
+ $column_for_last_row = $row[$sorted_column_index];
}
- return null;
+ $column_for_last_row = $pmaString->strtoupper(
+ $pmaString->substr(
+ $column_for_last_row, 0, $GLOBALS['cfg']['LimitChars']
+ )
+ );
+ // reset to first row for the loop in _getTableBody()
+ $GLOBALS['dbi']->dataSeek($dt_result, 0);
+
+ // we could also use here $sort_expression_nodirection
+ return ' [' . htmlspecialchars($sort_column)
+ . ': <strong>' . htmlspecialchars($column_for_first_row) . ' - '
+ . htmlspecialchars($column_for_last_row) . '</strong>]';
} // end of the '_getSortedColumnMessage()' function
@@ -5431,9 +5465,11 @@ class PMA_DisplayResults
$is_truncated = false;
$result = '[' . $category;
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
if (isset($content)) {
- $size = strlen($content);
+ $size = $pmaString->strlen($content);
$display_size = PMA_Util::formatByteDown($size, 3, 1);
$result .= ' - ' . $display_size[0] . ' ' . $display_size[1];
@@ -5447,44 +5483,50 @@ class PMA_DisplayResults
$result .= ']';
// if we want to use a text transformation on a BLOB column
- if (gettype($transformation_plugin) === "object"
- && (strpos($transformation_plugin->getMIMESubtype(), 'Octetstream')
- || strpos($transformation_plugin->getMIMEtype(), 'Text') !== false)
- ) {
- // Applying Transformations on hex string of binary data
- // seems more appropriate
- $result = bin2hex($content);
+ if (gettype($transformation_plugin) === "object") {
+ $posMimeOctetstream = $pmaString
+ ->strpos($transformation_plugin->getMIMESubtype(), 'Octetstream');
+ $posMimeText = $pmaString
+ ->strpos($transformation_plugin->getMIMEtype(), 'Text');
+ if ($posMimeOctetstream
+ || $posMimeText !== false
+ ) {
+ // Applying Transformations on hex string of binary data
+ // seems more appropriate
+ $result = bin2hex($content);
+ }
}
- if ($size > 0) {
+ if ($size <= 0) {
+ return($result);
+ }
- if ($default_function != $transformation_plugin) {
- $result = $transformation_plugin->applyTransformation(
- $result,
- $transform_options,
- $meta
- );
- } else {
+ if ($default_function != $transformation_plugin) {
+ $result = $transformation_plugin->applyTransformation(
+ $result,
+ $transform_options,
+ $meta
+ );
+ return($result);
+ }
- $result = $default_function($result, array(), $meta);
- if (($_SESSION['tmpval']['display_binary']
- && $meta->type === self::STRING_FIELD)
- || ($_SESSION['tmpval']['display_blob']
- && stristr($meta->type, self::BLOB_FIELD))
- ) {
- // in this case, restart from the original $content
- $result = bin2hex($content);
- $is_truncated = $this->_getPartialText($result);
- }
+ $result = $default_function($result, array(), $meta);
+ if (($_SESSION['tmpval']['display_binary']
+ && $meta->type === self::STRING_FIELD)
+ || ($_SESSION['tmpval']['display_blob']
+ && stristr($meta->type, self::BLOB_FIELD))
+ ) {
+ // in this case, restart from the original $content
+ $result = bin2hex($content);
+ $is_truncated = $this->_getPartialText($result);
+ }
- /* Create link to download */
- if (count($url_params) > 0) {
- $result = '<a href="tbl_get_field.php'
- . PMA_URL_getCommon($url_params)
- . '" class="disableAjax">'
- . $result . '</a>';
- }
- }
+ /* Create link to download */
+ if (count($url_params) > 0) {
+ $result = '<a href="tbl_get_field.php'
+ . PMA_URL_getCommon($url_params)
+ . '" class="disableAjax">'
+ . $result . '</a>';
}
return($result);
@@ -5538,6 +5580,8 @@ class PMA_DisplayResults
)
. '">';
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
if (isset($analyzed_sql[0]['select_expr'])
&& is_array($analyzed_sql[0]['select_expr'])
) {
@@ -5549,7 +5593,7 @@ class PMA_DisplayResults
$alias = $analyzed_sql[0]['select_expr']
[$select_expr_position]['alias'];
- if (!isset($alias) || !strlen($alias)) {
+ if (!isset($alias) || !$pmaString->strlen($alias)) {
continue;
} // end if
@@ -5568,7 +5612,9 @@ class PMA_DisplayResults
if (isset($map[$meta->name])) {
// Field to display from the foreign table?
- if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) {
+ if (isset($map[$meta->name][2])
+ && $pmaString->strlen($map[$meta->name][2])
+ ) {
$dispsql = 'SELECT '
. PMA_Util::backquote($map[$meta->name][2])
diff --git a/libraries/Error.class.php b/libraries/Error.class.php
index 842af8c66e..4e5b22ca2b 100644
--- a/libraries/Error.class.php
+++ b/libraries/Error.class.php
@@ -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 = '/';
diff --git a/libraries/File.class.php b/libraries/File.class.php
index 600e2f8706..78596ff594 100644
--- a/libraries/File.class.php
+++ b/libraries/File.class.php
@@ -714,7 +714,7 @@ class PMA_File
*/
public function getContentLength()
{
- return strlen($this->_content);
+ return $GLOBALS['PMA_String']->strlen($this->_content);
}
/**
diff --git a/libraries/Font.class.php b/libraries/Font.class.php
index 3fdfda67cb..d32ce510be 100644
--- a/libraries/Font.class.php
+++ b/libraries/Font.class.php
@@ -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
diff --git a/libraries/Header.class.php b/libraries/Header.class.php
index 8438c55df2..552cf7f4f0 100644
--- a/libraries/Header.class.php
+++ b/libraries/Header.class.php
@@ -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);
diff --git a/libraries/Index.class.php b/libraries/Index.class.php
index a8bd0117bf..5128138c26 100644
--- a/libraries/Index.class.php
+++ b/libraries/Index.class.php
@@ -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();
diff --git a/libraries/List_Database.class.php b/libraries/List_Database.class.php
index fbf9315c70..efe1f87a17 100644
--- a/libraries/List_Database.class.php
+++ b/libraries/List_Database.class.php
@@ -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'];
}
diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php
index 824038ccb6..11ea715ea0 100644
--- a/libraries/Menu.class.php
+++ b/libraries/Menu.class.php
@@ -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:.*?$@',
'',
diff --git a/libraries/Message.class.php b/libraries/Message.class.php
index 60a0424ca1..fe3cdae875 100644
--- a/libraries/Message.class.php
+++ b/libraries/Message.class.php
@@ -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;
diff --git a/libraries/PDF.class.php b/libraries/PDF.class.php
index 2a939b8b16..4b3225922b 100644
--- a/libraries/PDF.class.php
+++ b/libraries/PDF.class.php
@@ -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;
}
}
diff --git a/libraries/RecentFavoriteTable.class.php b/libraries/RecentFavoriteTable.class.php
index d5ef859fd8..ec753cadce 100644
--- a/libraries/RecentFavoriteTable.class.php
+++ b/libraries/RecentFavoriteTable.class.php
@@ -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']) . "."
diff --git a/libraries/Response.class.php b/libraries/Response.class.php
index 7f60173e6f..09d51cff13 100644
--- a/libraries/Response.class.php
+++ b/libraries/Response.class.php
@@ -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'];
}
diff --git a/libraries/Scripts.class.php b/libraries/Scripts.class.php
index e6ba610fd6..c1ea5fc17e 100644
--- a/libraries/Scripts.class.php
+++ b/libraries/Scripts.class.php
@@ -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;
}
diff --git a/libraries/ServerStatusData.class.php b/libraries/ServerStatusData.class.php
index a07e671f15..fd7368a667 100644
--- a/libraries/ServerStatusData.class.php
+++ b/libraries/ServerStatusData.class.php
@@ -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'
) {
diff --git a/libraries/StorageEngine.class.php b/libraries/StorageEngine.class.php
index f2c01501ac..dead6f1dd0 100644
--- a/libraries/StorageEngine.class.php
+++ b/libraries/StorageEngine.class.php
@@ -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;
}
diff --git a/libraries/String.class.php b/libraries/String.class.php
index a5fbe8a0ff..0b5fd7b00d 100644
--- a/libraries/String.class.php
+++ b/libraries/String.class.php
@@ -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,7 @@ class PMA_String
}
/**
- * Returns postion of $needle in $haystack or false if not found
+ * 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
@@ -137,6 +142,98 @@ class PMA_String
}
/**
+ * 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
*
* @param string $string the string being lowercased
@@ -149,6 +246,18 @@ class PMA_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
*
* @param string $string the string for which ord is required
@@ -161,6 +270,18 @@ class PMA_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
*
* @param string $c character to check for
diff --git a/libraries/StringByte.int.php b/libraries/StringByte.int.php
index 99e15a37f7..db52eae409 100644
--- a/libraries/StringByte.int.php
+++ b/libraries/StringByte.int.php
@@ -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
{
@@ -40,6 +39,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
*
* @param string $string the string being lowercased
@@ -49,6 +123,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
*
* @param string $string the string for which ord is required
@@ -56,5 +139,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);
}
?> \ No newline at end of file
diff --git a/libraries/StringMB.class.php b/libraries/StringMB.class.php
index fb4cdc99db..5c75f67610 100644
--- a/libraries/StringMB.class.php
+++ b/libraries/StringMB.class.php
@@ -44,11 +44,19 @@ 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 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,10 +66,161 @@ 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
*
* @param string $string the string being lowercased
@@ -74,6 +233,18 @@ class PMA_StringMB implements PMA_StringByte
}
/**
+ * 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 +254,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'
+ );
+ }
}
?>
diff --git a/libraries/StringNative.class.php b/libraries/StringNative.class.php
index cfbdcabfac..3085490f0d 100644
--- a/libraries/StringNative.class.php
+++ b/libraries/StringNative.class.php
@@ -61,6 +61,106 @@ class PMA_StringNative implements PMA_StringByte
}
/**
+ * 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
*
* @param string $string the string being lowercased
@@ -73,6 +173,18 @@ class PMA_StringNative implements PMA_StringByte
}
/**
+ * 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
*
* @param string $string the string for which ord is required
@@ -83,5 +195,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);
+ }
};
?>
diff --git a/libraries/StringType.int.php b/libraries/StringType.int.php
index dfcb7de8ec..38c17342da 100644
--- a/libraries/StringType.int.php
+++ b/libraries/StringType.int.php
@@ -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
{
diff --git a/libraries/Table.class.php b/libraries/Table.class.php
index c057c8256f..a8b12d7963 100644
--- a/libraries/Table.class.php
+++ b/libraries/Table.class.php
@@ -262,7 +262,11 @@ class PMA_Table
);
foreach ($results as $result) {
$analyzed_sql[0]['create_table_fields'][$result['COLUMN_NAME']]
- = array('type' => strtoupper($result['DATA_TYPE']));
+ = array(
+ 'type' => $GLOBALS['PMA_String']->strtoupper(
+ $result['DATA_TYPE']
+ )
+ );
}
} else {
$show_create_table = $GLOBALS['dbi']->fetchValue(
@@ -333,7 +337,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 +429,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;
@@ -810,9 +823,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 +890,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 +980,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 +1017,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 +1300,7 @@ class PMA_Table
return false;
}
- if (! strlen($table_name)) {
+ if (! $GLOBALS['PMA_String']->strlen($table_name)) {
// zero length
return false;
}
@@ -1593,13 +1611,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 +1660,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 +1754,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 +1781,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();
}
diff --git a/libraries/TableSearch.class.php b/libraries/TableSearch.class.php
index ba9e54a9f1..1ea8c35fa5 100644
--- a/libraries/TableSearch.class.php
+++ b/libraries/TableSearch.class.php
@@ -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 {
diff --git a/libraries/Tracker.class.php b/libraries/Tracker.class.php
index 6ee52e55ae..a4f89cfa72 100644
--- a/libraries/Tracker.class.php
+++ b/libraries/Tracker.class.php
@@ -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
diff --git a/libraries/Types.class.php b/libraries/Types.class.php
index eb89319be7..02ee2d3de9 100644
--- a/libraries/Types.class.php
+++ b/libraries/Types.class.php
@@ -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':
diff --git a/libraries/Util.class.php b/libraries/Util.class.php
index 45f534c4f5..3fe0c64b2e 100644
--- a/libraries/Util.class.php
+++ b/libraries/Util.class.php
@@ -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 (!$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';
}
- 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;
+ $_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 {
- return $error_msg;
+ $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) {
+ return $server_type;
+ }
+
+ if ($pmaString->stripos(PMA_MYSQL_STR_VERSION, 'mariadb') !== false) {
$server_type = 'MariaDB';
- } else if (stripos(PMA_MYSQL_VERSION_COMMENT, 'percona') !== false) {
+ 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") {
diff --git a/libraries/bookmark.lib.php b/libraries/bookmark.lib.php
index aa2cbf2efd..2943b60727 100644
--- a/libraries/bookmark.lib.php
+++ b/libraries/bookmark.lib.php
@@ -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;
}
diff --git a/libraries/build_html_for_db.lib.php b/libraries/build_html_for_db.lib.php
index 694e916b55..0ee9f136f2 100644
--- a/libraries/build_html_for_db.lib.php
+++ b/libraries/build_html_for_db.lib.php
@@ -133,6 +133,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;">';
@@ -141,14 +144,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)
) {
diff --git a/libraries/central_columns.lib.php b/libraries/central_columns.lib.php
index 5f492a5854..0c64254fe7 100644
--- a/libraries/central_columns.lib.php
+++ b/libraries/central_columns.lib.php
@@ -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>';
diff --git a/libraries/check_user_privileges.lib.php b/libraries/check_user_privileges.lib.php
index ee9896a681..827c43990b 100644
--- a/libraries/check_user_privileges.lib.php
+++ b/libraries/check_user_privileges.lib.php
@@ -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
diff --git a/libraries/common.inc.php b/libraries/common.inc.php
index c86667b3b0..0ddd2f2b16 100644
--- a/libraries/common.inc.php
+++ b/libraries/common.inc.php
@@ -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) {
@@ -738,11 +743,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'] = '';
}
diff --git a/libraries/config/Form.class.php b/libraries/config/Form.class.php
index 23413bf0a8..ff76a2d71e 100644
--- a/libraries/config/Form.class.php
+++ b/libraries/config/Form.class.php
@@ -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;
}
diff --git a/libraries/config/FormDisplay.class.php b/libraries/config/FormDisplay.class.php
index 1f804a72c6..93d9d2ffb4 100644
--- a/libraries/config/FormDisplay.class.php
+++ b/libraries/config/FormDisplay.class.php
@@ -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 '';
}
diff --git a/libraries/config/FormDisplay.tpl.php b/libraries/config/FormDisplay.tpl.php
index b355511f1c..930dab753b 100644
--- a/libraries/config/FormDisplay.tpl.php
+++ b/libraries/config/FormDisplay.tpl.php
@@ -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) {
diff --git a/libraries/config/ServerConfigChecks.class.php b/libraries/config/ServerConfigChecks.class.php
index 8872bf6ad5..627f73072d 100644
--- a/libraries/config/ServerConfigChecks.class.php
+++ b/libraries/config/ServerConfigChecks.class.php
@@ -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.');
}
diff --git a/libraries/config/Validator.class.php b/libraries/config/Validator.class.php
index df204748ee..c87f4b3610 100644
--- a/libraries/config/Validator.class.php
+++ b/libraries/config/Validator.class.php
@@ -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;
}
diff --git a/libraries/core.lib.php b/libraries/core.lib.php
index 103dff72cd..bcbc5b604d 100644
--- a/libraries/core.lib.php
+++ b/libraries/core.lib.php
@@ -12,6 +12,11 @@ if (! defined('PHPMYADMIN')) {
}
/**
+ * 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
* or against any other type if $type is provided
@@ -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;
}
diff --git a/libraries/db_common.inc.php b/libraries/db_common.inc.php
index ab6f693615..4f54062b4f 100644
--- a/libraries/db_common.inc.php
+++ b/libraries/db_common.inc.php
@@ -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);
diff --git a/libraries/db_designer.lib.php b/libraries/db_designer.lib.php
index fdecc2e17e..f5ca0bf979 100644
--- a/libraries/db_designer.lib.php
+++ b/libraries/db_designer.lib.php
@@ -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';
}
diff --git a/libraries/db_table_exists.lib.php b/libraries/db_table_exists.lib.php
index 706629e488..ffc9275fef 100644
--- a/libraries/db_table_exists.lib.php
+++ b/libraries/db_table_exists.lib.php
@@ -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):
diff --git a/libraries/display_change_password.lib.php b/libraries/display_change_password.lib.php
index 51a4762add..21fde3b81d 100644
--- a/libraries/display_change_password.lib.php
+++ b/libraries/display_change_password.lib.php
@@ -40,7 +40,11 @@ function PMA_getHtmlForChangePassword($username, $hostname)
$html .= PMA_URL_getHiddenInputs();
- if (strpos($GLOBALS['PMA_PHP_SELF'], 'server_privileges') !== false) {
+ if ($GLOBALS['PMA_String']->strpos(
+ $GLOBALS['PMA_PHP_SELF'],
+ 'server_privileges'
+ ) !== false
+ ) {
$html .= '<input type="hidden" name="username" '
. 'value="' . htmlspecialchars($username) . '" />'
. '<input type="hidden" name="hostname" '
@@ -48,7 +52,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">'
diff --git a/libraries/display_export.lib.php b/libraries/display_export.lib.php
index 9c1734ee1c..91e1f13cfd 100644
--- a/libraries/display_export.lib.php
+++ b/libraries/display_export.lib.php
@@ -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>';
diff --git a/libraries/display_git_revision.lib.php b/libraries/display_git_revision.lib.php
index d794832eeb..f192451b64 100644
--- a/libraries/display_git_revision.lib.php
+++ b/libraries/display_git_revision.lib.php
@@ -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
diff --git a/libraries/error_report.lib.php b/libraries/error_report.lib.php
index 02fc4389c9..199025bf6a 100644
--- a/libraries/error_report.lib.php
+++ b/libraries/error_report.lib.php
@@ -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)) {
diff --git a/libraries/export.lib.php b/libraries/export.lib.php
index 3ed20a4fb1..573718d861 100644
--- a/libraries/export.lib.php
+++ b/libraries/export.lib.php
@@ -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
@@ -475,7 +497,8 @@ function PMA_exportServer(
// Walk over databases
foreach ($GLOBALS['pma']->databases as $current_db) {
if (isset($tmp_select)
- && strpos(' ' . $tmp_select, '|' . $current_db . '|')
+ && $GLOBALS['PMA_String']
+ ->strpos(' ' . $tmp_select, '|' . $current_db . '|')
) {
$tables = $GLOBALS['dbi']->getTables($current_db);
PMA_exportDatabase(
@@ -520,7 +543,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);
diff --git a/libraries/file_listing.lib.php b/libraries/file_listing.lib.php
index 929dfaaea4..cf63e1dd26 100644
--- a/libraries/file_listing.lib.php
+++ b/libraries/file_listing.lib.php
@@ -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)) {
diff --git a/libraries/gis/GIS_Factory.class.php b/libraries/gis/GIS_Factory.class.php
index 0b9a11bc12..c9f1d92794 100644
--- a/libraries/gis/GIS_Factory.class.php
+++ b/libraries/gis/GIS_Factory.class.php
@@ -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' :
diff --git a/libraries/gis/GIS_Geometry.class.php b/libraries/gis/GIS_Geometry.class.php
index f27640e37b..b2be72e4da 100644
--- a/libraries/gis/GIS_Geometry.class.php
+++ b/libraries/gis/GIS_Geometry.class.php
@@ -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;
diff --git a/libraries/gis/GIS_Geometrycollection.class.php b/libraries/gis/GIS_Geometrycollection.class.php
index 80cc225102..5ef0f97817 100644
--- a/libraries/gis/GIS_Geometrycollection.class.php
+++ b/libraries/gis/GIS_Geometrycollection.class.php
@@ -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;
diff --git a/libraries/gis/GIS_Linestring.class.php b/libraries/gis/GIS_Linestring.class.php
index 3baac59067..edb6193b0c 100644
--- a/libraries/gis/GIS_Linestring.class.php
+++ b/libraries/gis/GIS_Linestring.class.php
@@ -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);
diff --git a/libraries/gis/GIS_Multilinestring.class.php b/libraries/gis/GIS_Multilinestring.class.php
index 6b4785d7b5..54d716c82e 100644
--- a/libraries/gis/GIS_Multilinestring.class.php
+++ b/libraries/gis/GIS_Multilinestring.class.php
@@ -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);
diff --git a/libraries/gis/GIS_Multipoint.class.php b/libraries/gis/GIS_Multipoint.class.php
index 515780deb5..c96ace4e76 100644
--- a/libraries/gis/GIS_Multipoint.class.php
+++ b/libraries/gis/GIS_Multipoint.class.php
@@ -55,8 +55,11 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
*/
public function scaleRow($spatial)
{
+ /** @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));
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 .= ')';
diff --git a/libraries/gis/GIS_Multipolygon.class.php b/libraries/gis/GIS_Multipolygon.class.php
index 275ca3e463..c3fa35cbae 100644
--- a/libraries/gis/GIS_Multipolygon.class.php
+++ b/libraries/gis/GIS_Multipolygon.class.php
@@ -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,21 +169,24 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
*/
public function prepareRowAsPdf($spatial, $label, $fill_color, $scale_data, $pdf)
{
+ /** @var PMA_String $pmaString */
+ $pmaString = $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($pmaString->substr($fill_color, 1, 2));
+ $green = hexdec($pmaString->substr($fill_color, 3, 2));
+ $blue = hexdec($pmaString->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 = $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 ($pmaString->strpos($polygon, "),(") === false) {
$points_arr = $this->extractPoints($polygon, $scale_data, true);
} else {
// Seperate outer and inner polygons
@@ -229,16 +246,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 +315,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 +377,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 +403,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 +464,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 +480,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 +490,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 +525,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 +539,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 +549,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;
diff --git a/libraries/gis/GIS_Point.class.php b/libraries/gis/GIS_Point.class.php
index 35fff43621..6c1ccfc327 100644
--- a/libraries/gis/GIS_Point.class.php
+++ b/libraries/gis/GIS_Point.class.php
@@ -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];
diff --git a/libraries/gis/GIS_Polygon.class.php b/libraries/gis/GIS_Polygon.class.php
index ed944f4a0d..d7d096ae5a 100644
--- a/libraries/gis/GIS_Polygon.class.php
+++ b/libraries/gis/GIS_Polygon.class.php
@@ -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 $pmaString */
+ $pmaString = $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($pmaString->substr($fill_color, 1, 2));
+ $green = hexdec($pmaString->substr($fill_color, 3, 2));
+ $blue = hexdec($pmaString->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 = $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);
@@ -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);
+ /** @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
+ );
- // Seperate outer and inner polygons
+ // 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);
diff --git a/libraries/gis/GIS_Visualization.class.php b/libraries/gis/GIS_Visualization.class.php
index 20fd75f881..4f5d8f7bf2 100644
--- a/libraries/gis/GIS_Visualization.class.php
+++ b/libraries/gis/GIS_Visualization.class.php
@@ -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) {
diff --git a/libraries/iconv_wrapper.lib.php b/libraries/iconv_wrapper.lib.php
index bc822e6fee..67ee0a14af 100644
--- a/libraries/iconv_wrapper.lib.php
+++ b/libraries/iconv_wrapper.lib.php
@@ -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
diff --git a/libraries/import.lib.php b/libraries/import.lib.php
index 07be7759b5..2ee6a76190 100644
--- a/libraries/import.lib.php
+++ b/libraries/import.lib.php
@@ -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;
- }
+ if (!is_numeric($cell)) {
+ return VARCHAR;
+ }
+
+ if ($cell == (string)(float)$cell
+ && $pmaString->strpos($cell, ".") !== false
+ && substr_count($cell, ".") == 1
+ ) {
+ return DECIMAL;
+ }
- return INT;
+ if (abs($cell) > 2147483647) {
+ return BIGINT;
}
- return VARCHAR;
+ return INT;
}
/**
diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php
index d628f5ca5d..c53e79694d 100644
--- a/libraries/insert_edit.lib.php
+++ b/libraries/insert_edit.lib.php
@@ -342,12 +342,15 @@ 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');
+ return $pmaString->stristr($column['Type'], 'binary');
} else {
return false;
}
@@ -365,12 +368,15 @@ 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');
+ return $pmaString->stristr($column['Type'], 'blob');
} else {
return false;
}
@@ -386,10 +392,13 @@ 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');
+ return $pmaString->stristr($column['Type'], 'char');
} else {
return false;
}
@@ -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"'
: ''
)
diff --git a/libraries/ip_allow_deny.lib.php b/libraries/ip_allow_deny.lib.php
index df46013ed2..b4209fc75c 100644
--- a/libraries/ip_allow_deny.lib.php
+++ b/libraries/ip_allow_deny.lib.php
@@ -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;
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
// convert to lowercase for easier comparison
- $test_range = strtolower($test_range);
- $ip_to_test = strtolower($ip_to_test);
+ $test_range = $pmaString->strtolower($test_range);
+ $ip_to_test = $pmaString->strtolower($ip_to_test);
- $is_cidr = strpos($test_range, '/') > -1;
- $is_range = strpos($test_range, '[') > -1;
+ $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);
diff --git a/libraries/mime.lib.php b/libraries/mime.lib.php
index 399b36d859..529a2d1d27 100644
--- a/libraries/mime.lib.php
+++ b/libraries/mime.lib.php
@@ -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';
diff --git a/libraries/mult_submits.inc.php b/libraries/mult_submits.inc.php
index 531967dd09..e0065c1ba5 100644
--- a/libraries/mult_submits.inc.php
+++ b/libraries/mult_submits.inc.php
@@ -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 {
diff --git a/libraries/mult_submits.lib.php b/libraries/mult_submits.lib.php
index 25bbda6965..c6f55e3205 100644
--- a/libraries/mult_submits.lib.php
+++ b/libraries/mult_submits.lib.php
@@ -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)
diff --git a/libraries/navigation/NavigationHeader.class.php b/libraries/navigation/NavigationHeader.class.php
index 732e9bd32b..97f06e60d4 100644
--- a/libraries/navigation/NavigationHeader.class.php
+++ b/libraries/navigation/NavigationHeader.class.php
@@ -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" />';
+ 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 .= '<div id="pmalogo">';
- if ($GLOBALS['cfg']['NavigationLogoLink']) {
- $logo_link = trim(
- htmlspecialchars($GLOBALS['cfg']['NavigationLogoLink'])
+ $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']
);
- // 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':
+ if ($pmaString->substr($navLogoLinkLower , 0, 4) !== '://') {
+ $retval .= '?' . $GLOBALS['url_query'] . '"';
+ } else {
$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>';
+ $retval .= '>';
+ $retval .= $logo;
+ $retval .= '</a>';
+ } else {
+ $retval .= $logo;
}
+ $retval .= '</div>';
+
$retval .= '<!-- LOGO END -->';
return $retval;
}
diff --git a/libraries/navigation/NavigationTree.class.php b/libraries/navigation/NavigationTree.class.php
index 84bcb4bf57..d7303e7118 100644
--- a/libraries/navigation/NavigationTree.class.php
+++ b/libraries/navigation/NavigationTree.class.php
@@ -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>";
}
diff --git a/libraries/navigation/Nodes/Node_Database.class.php b/libraries/navigation/Nodes/Node_Database.class.php
index 7be8750fca..e1e62cf0d0 100644
--- a/libraries/navigation/Nodes/Node_Database.class.php
+++ b/libraries/navigation/Nodes/Node_Database.class.php
@@ -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();
diff --git a/libraries/normalization.lib.php b/libraries/normalization.lib.php
index 79e9f68771..c085ef0550 100644
--- a/libraries/normalization.lib.php
+++ b/libraries/normalization.lib.php
@@ -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) . '"/>'
diff --git a/libraries/operations.lib.php b/libraries/operations.lib.php
index 9db2b35272..f7dbd7a464 100644
--- a/libraries/operations.lib.php
+++ b/libraries/operations.lib.php
@@ -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'
diff --git a/libraries/parse_analyze.inc.php b/libraries/parse_analyze.inc.php
index eb7704efcb..b01162d51e 100644
--- a/libraries/parse_analyze.inc.php
+++ b/libraries/parse_analyze.inc.php
@@ -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 {
diff --git a/libraries/plugin_interface.lib.php b/libraries/plugin_interface.lib.php
index 25698e2174..e8c7a4a637 100644
--- a/libraries/plugin_interface.lib.php
+++ b/libraries/plugin_interface.lib.php
@@ -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>';
diff --git a/libraries/plugins/auth/AuthenticationCookie.class.php b/libraries/plugins/auth/AuthenticationCookie.class.php
index 95f9efdecc..625d67344f 100644
--- a/libraries/plugins/auth/AuthenticationCookie.class.php
+++ b/libraries/plugins/auth/AuthenticationCookie.class.php
@@ -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?
diff --git a/libraries/plugins/export/ExportCsv.class.php b/libraries/plugins/export/ExportCsv.class.php
index 70acb1c672..21d0c1121b 100644
--- a/libraries/plugins/export/ExportCsv.class.php
+++ b/libraries/plugins/export/ExportCsv.class.php
@@ -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;
}
diff --git a/libraries/plugins/export/ExportLatex.class.php b/libraries/plugins/export/ExportLatex.class.php
index 5519c58b58..a2b126bd3f 100644
--- a/libraries/plugins/export/ExportLatex.class.php
+++ b/libraries/plugins/export/ExportLatex.class.php
@@ -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;
diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php
index a15279a835..bc98579aca 100644
--- a/libraries/plugins/export/ExportSql.class.php
+++ b/libraries/plugins/export/ExportSql.class.php
@@ -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
- );
+ 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 {
- $result = PMA_exportOutputHandler('USE ' . $db_alias . ';' . $crlf);
+ $create_query .= ' DEFAULT CHARACTER SET ' . $collation;
}
- return $result;
+ }
+ $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 {
- return true;
+ $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,7 @@ class ExportSql extends ExportPlugin
if (! $first) {
$sql_constraints .= $crlf;
}
- if (strpos($sql_lines[$j], 'CONSTRAINT') === false) {
+ if ($pmaString->strpos($sql_lines[$j], 'CONSTRAINT') === false) {
$tmp_str = preg_replace(
'/(FOREIGN[\s]+KEY)/',
'ADD \1',
@@ -1937,304 +1947,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);
- $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
- );
+ // 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
+ );
+ }
+ 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 = '';
- }
+ $sql_command = 'INSERT';
+ }
- // 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);
- }
+ // delayed inserts?
+ if (isset($GLOBALS['sql_delayed'])) {
+ $insert_delayed = ' DELAYED';
+ } else {
+ $insert_delayed = '';
+ }
- // 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';
- }
+ // 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);
}
- //\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')
+ // scheme for inserting fields
+ if ($GLOBALS['sql_insert_syntax'] == 'complete'
+ || $GLOBALS['sql_insert_syntax'] == 'both'
) {
- $separator = ',';
- $schema_insert .= $crlf;
+ $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 {
- $separator = ';';
+ $schema_insert = $sql_command . $insert_delayed . ' INTO '
+ . PMA_Util::backquoteCompat(
+ $table_alias,
+ $compat,
+ $sql_backquotes
+ )
+ . ' VALUES';
}
+ }
- 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;
- }
+ //\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;
}
- // We need to SET IDENTITY_INSERT ON for MSSQL
- if (isset($GLOBALS['sql_compatibility'])
- && $GLOBALS['sql_compatibility'] == 'MSSQL'
- && $current_row == 0
+ }
+ $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
) {
- if (! PMA_exportOutputHandler(
- 'SET IDENTITY_INSERT '
- . PMA_Util::backquoteCompat(
- $table_alias,
- $compat
- )
- . ' ON ;' . $crlf
- )) {
- return false;
+ // 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]);
}
- }
- $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
- )
+ } 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
+ )
+ . "'";
+ } 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'
- ) {
+ // 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];
+ $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);
+ 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 {
+ } 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;
+ // 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 += strlen($insert_line);
- // Other inserts case
- } else {
- $insert_line = $schema_insert
- . '('
- . implode(', ', $values)
- . ')';
}
+ $query_size += $pmaString->strlen($insert_line);
+ // Other inserts case
+ } else {
+ $insert_line = $schema_insert
+ . '(' . implode(', ', $values) . ')';
}
- unset($values);
+ }
+ unset($values);
- if (! PMA_exportOutputHandler(
- ($current_row == 1 ? '' : $separator . $crlf)
- . $insert_line
- )) {
- return false;
- }
+ if (! PMA_exportOutputHandler(
+ ($current_row == 1 ? '' : $separator . $crlf)
+ . $insert_line
+ )) {
+ return false;
+ }
- } // end while
+ } // end while
- if ($current_row > 0) {
- if (! PMA_exportOutputHandler(';' . $crlf)) {
- return false;
- }
+ 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;
- }
+ // 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;
}
- } // end if ($result != false)
- $GLOBALS['dbi']->freeResult($result);
+ }
+ $GLOBALS['dbi']->freeResult($result);
return true;
} // end of the 'exportData()' function
@@ -2395,6 +2409,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 +2422,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 === ''
diff --git a/libraries/plugins/export/ExportXml.class.php b/libraries/plugins/export/ExportXml.class.php
index da7ced9ad2..527fd0627a 100644
--- a/libraries/plugins/export/ExportXml.class.php
+++ b/libraries/plugins/export/ExportXml.class.php
@@ -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);
diff --git a/libraries/plugins/export/TableProperty.class.php b/libraries/plugins/export/TableProperty.class.php
index 4affb7c0d5..3ff5780058 100644
--- a/libraries/plugins/export/TableProperty.class.php
+++ b/libraries/plugins/export/TableProperty.class.php
@@ -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')
. "\"";
diff --git a/libraries/plugins/import/ImportCsv.class.php b/libraries/plugins/import/ImportCsv.class.php
index 05f53420ce..4e65d42943 100644
--- a/libraries/plugins/import/ImportCsv.class.php
+++ b/libraries/plugins/import/ImportCsv.class.php
@@ -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]) {
@@ -548,8 +553,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];
@@ -584,7 +589,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 {
@@ -612,7 +617,7 @@ class ImportCsv extends AbstractImportCsv
*/
/* 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 {
diff --git a/libraries/plugins/import/ImportMediawiki.class.php b/libraries/plugins/import/ImportMediawiki.class.php
index 20d274859e..bd15d161c9 100644
--- a/libraries/plugins/import/ImportMediawiki.class.php
+++ b/libraries/plugins/import/ImportMediawiki.class.php
@@ -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));
}
}
diff --git a/libraries/plugins/import/ImportShp.class.php b/libraries/plugins/import/ImportShp.class.php
index 89dba9d2d7..c4601decdd 100644
--- a/libraries/plugins/import/ImportShp.class.php
+++ b/libraries/plugins/import/ImportShp.class.php
@@ -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 {
diff --git a/libraries/plugins/import/ImportSql.class.php b/libraries/plugins/import/ImportSql.class.php
index 79423e7482..351cb9f9f6 100644
--- a/libraries/plugins/import/ImportSql.class.php
+++ b/libraries/plugins/import/ImportSql.class.php
@@ -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);
}
diff --git a/libraries/plugins/schema/dia/Dia_Relation_Schema.class.php b/libraries/plugins/schema/dia/Dia_Relation_Schema.class.php
index 3e078061f8..29358e6845 100644
--- a/libraries/plugins/schema/dia/Dia_Relation_Schema.class.php
+++ b/libraries/plugins/schema/dia/Dia_Relation_Schema.class.php
@@ -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;
}
diff --git a/libraries/plugins/schema/eps/Eps_Relation_Schema.class.php b/libraries/plugins/schema/eps/Eps_Relation_Schema.class.php
index 30b7f17c6e..0f42eb8310 100644
--- a/libraries/plugins/schema/eps/Eps_Relation_Schema.class.php
+++ b/libraries/plugins/schema/eps/Eps_Relation_Schema.class.php
@@ -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;
}
}
diff --git a/libraries/plugins/schema/pdf/Pdf_Relation_Schema.class.php b/libraries/plugins/schema/pdf/Pdf_Relation_Schema.class.php
index ae2418fc20..dfba41beee 100644
--- a/libraries/plugins/schema/pdf/Pdf_Relation_Schema.class.php
+++ b/libraries/plugins/schema/pdf/Pdf_Relation_Schema.class.php
@@ -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) {
diff --git a/libraries/plugins/schema/svg/Svg_Relation_Schema.class.php b/libraries/plugins/schema/svg/Svg_Relation_Schema.class.php
index 725fbda794..1b8865bfa2 100644
--- a/libraries/plugins/schema/svg/Svg_Relation_Schema.class.php
+++ b/libraries/plugins/schema/svg/Svg_Relation_Schema.class.php
@@ -187,7 +187,11 @@ class PMA_SVG extends XMLWriter
//ob_get_clean();
$output = $this->flush();
PMA_Response::getInstance()->disable();
- PMA_downloadHeader($fileName . '.svg', 'image/svg+xml', strlen($output));
+ PMA_downloadHeader(
+ $fileName . '.svg',
+ 'image/svg+xml',
+ $GLOBALS['PMA_String']->strlen($output)
+ );
print $output;
}
diff --git a/libraries/plugins/transformations/abstract/DateFormatTransformationsPlugin.class.php b/libraries/plugins/transformations/abstract/DateFormatTransformationsPlugin.class.php
index bc4c822ed7..719c6ff761 100644
--- a/libraries/plugins/transformations/abstract/DateFormatTransformationsPlugin.class.php
+++ b/libraries/plugins/transformations/abstract/DateFormatTransformationsPlugin.class.php
@@ -58,10 +58,13 @@ abstract class DateFormatTransformationsPlugin extends TransformationsPlugin
$options[0] = 0;
}
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
if (empty($options[2])) {
$options[2] = 'local';
} else {
- $options[2] = strtolower($options[2]);
+ $options[2] = $pmaString->strtolower($options[2]);
}
if (empty($options[1])) {
@@ -86,28 +89,30 @@ abstract class DateFormatTransformationsPlugin extends TransformationsPlugin
// for example TIMESTAMP(8) means YYYYMMDD)
} else if (preg_match('/^(\d{2}){3,7}$/', $buffer)) {
- if (strlen($buffer) == 14 || strlen($buffer) == 8) {
+ if ($pmaString->strlen($buffer) == 14
+ || $pmaString->strlen($buffer) == 8
+ ) {
$offset = 4;
} else {
$offset = 2;
}
- $d = array();
- $d['year'] = substr($buffer, 0, $offset);
- $d['month'] = substr($buffer, $offset, 2);
- $d['day'] = substr($buffer, $offset + 2, 2);
- $d['hour'] = substr($buffer, $offset + 4, 2);
- $d['minute'] = substr($buffer, $offset + 6, 2);
- $d['second'] = substr($buffer, $offset + 8, 2);
+ $aDate = array();
+ $aDate['year'] = $pmaString->substr($buffer, 0, $offset);
+ $aDate['month'] = $pmaString->substr($buffer, $offset, 2);
+ $aDate['day'] = $pmaString->substr($buffer, $offset + 2, 2);
+ $aDate['hour'] = $pmaString->substr($buffer, $offset + 4, 2);
+ $aDate['minute'] = $pmaString->substr($buffer, $offset + 6, 2);
+ $aDate['second'] = $pmaString->substr($buffer, $offset + 8, 2);
- if (checkdate($d['month'], $d['day'], $d['year'])) {
+ if (checkdate($aDate['month'], $aDate['day'], $aDate['year'])) {
$timestamp = mktime(
- $d['hour'],
- $d['minute'],
- $d['second'],
- $d['month'],
- $d['day'],
- $d['year']
+ $aDate['hour'],
+ $aDate['minute'],
+ $aDate['second'],
+ $aDate['month'],
+ $aDate['day'],
+ $aDate['year']
);
}
// If all fails, assume one of the dozens of valid strtime() syntaxes
diff --git a/libraries/plugins/transformations/abstract/SubstringTransformationsPlugin.class.php b/libraries/plugins/transformations/abstract/SubstringTransformationsPlugin.class.php
index 32af2649fd..33a4f4ee17 100644
--- a/libraries/plugins/transformations/abstract/SubstringTransformationsPlugin.class.php
+++ b/libraries/plugins/transformations/abstract/SubstringTransformationsPlugin.class.php
@@ -52,16 +52,18 @@ abstract class SubstringTransformationsPlugin extends TransformationsPlugin
// further operations on $buffer using the $options[] array.
$options = $this->getOptions($options, array(0, 'all', '…'));
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
if ($options[1] != 'all') {
- $newtext = $GLOBALS['PMA_String']->substr(
+ $newtext = $pmaString->substr(
$buffer, $options[0], $options[1]
);
} else {
- $newtext = $GLOBALS['PMA_String']->substr($buffer, $options[0]);
+ $newtext = $pmaString->substr($buffer, $options[0]);
}
- $length = strlen($newtext);
- $baselength = strlen($buffer);
+ $length = $pmaString->strlen($newtext);
+ $baselength = $pmaString->strlen($buffer);
if ($length != $baselength) {
if ($options[0] != 0) {
$newtext = $options[2] . $newtext;
diff --git a/libraries/pmd_common.php b/libraries/pmd_common.php
index 5552ab8d80..cb094c2edc 100644
--- a/libraries/pmd_common.php
+++ b/libraries/pmd_common.php
@@ -55,7 +55,9 @@ function PMA_getTablesInfo()
$one_table['TABLE_NAME'], ENT_QUOTES
);
- $GLOBALS['PMD']['TABLE_TYPE'][$i] = strtoupper($one_table['ENGINE']);
+ $GLOBALS['PMD']['TABLE_TYPE'][$i] = $GLOBALS['PMA_String']->strtoupper(
+ $one_table['ENGINE']
+ );
$DF = PMA_getDisplayField($GLOBALS['db'], $one_table['TABLE_NAME']);
if ($DF != '') {
@@ -469,10 +471,13 @@ function PMA_saveDisplayField($db, $table, $field)
*/
function PMA_addNewRelation($db, $T1, $F1, $T2, $F2, $on_delete, $on_update)
{
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$tables = $GLOBALS['dbi']->getTablesFull($db, $T1);
- $type_T1 = strtoupper($tables[$T1]['ENGINE']);
+ $type_T1 = $pmaString->strtoupper($tables[$T1]['ENGINE']);
$tables = $GLOBALS['dbi']->getTablesFull($db, $T2);
- $type_T2 = strtoupper($tables[$T2]['ENGINE']);
+ $type_T2 = $pmaString->strtoupper($tables[$T2]['ENGINE']);
// native foreign key
if (PMA_Util::isForeignKeySupported($type_T1)
@@ -576,13 +581,16 @@ function PMA_addNewRelation($db, $T1, $F1, $T2, $F2, $on_delete, $on_update)
*/
function PMA_removeRelation($T1, $F1, $T2, $F2)
{
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
list($DB1, $T1) = explode(".", $T1);
list($DB2, $T2) = explode(".", $T2);
$tables = $GLOBALS['dbi']->getTablesFull($DB1, $T1);
- $type_T1 = strtoupper($tables[$T1]['ENGINE']);
+ $type_T1 = $pmaString->strtoupper($tables[$T1]['ENGINE']);
$tables = $GLOBALS['dbi']->getTablesFull($DB2, $T2);
- $type_T2 = strtoupper($tables[$T2]['ENGINE']);
+ $type_T2 = $pmaString->strtoupper($tables[$T2]['ENGINE']);
$try_to_delete_internal_relation = false;
diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php
index 78d76a230d..f96e167fde 100644
--- a/libraries/relation.lib.php
+++ b/libraries/relation.lib.php
@@ -646,6 +646,9 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both')
$cfgRelation = PMA_getRelationsParam();
$foreign = array();
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
if ($cfgRelation['relwork'] && ($source == 'both' || $source == 'internal')) {
$rel_query = '
SELECT `master_field`,
@@ -656,7 +659,7 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both')
. '.' . PMA_Util::backquote($cfgRelation['relation']) . '
WHERE `master_db` = \'' . PMA_Util::sqlAddSlashes($db) . '\'
AND `master_table` = \'' . PMA_Util::sqlAddSlashes($table) . '\' ';
- if (strlen($column)) {
+ if ($pmaString->strlen($column)) {
$rel_query .= ' AND `master_field` = '
. '\'' . PMA_Util::sqlAddSlashes($column) . '\'';
}
@@ -665,7 +668,7 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both')
);
}
- if (($source == 'both' || $source == 'foreign') && strlen($table)) {
+ if (($source == 'both' || $source == 'foreign') && $pmaString->strlen($table)) {
$showCreateTableQuery = 'SHOW CREATE TABLE '
. PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table);
@@ -680,8 +683,9 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both')
/**
* Emulating relations for some information_schema and data_dictionary tables
*/
- $isInformationSchema = strtolower($db) == 'information_schema';
- $is_data_dictionary = PMA_DRIZZLE && strtolower($db) == 'data_dictionary';
+ $isInformationSchema = $pmaString->strtolower($db) == 'information_schema';
+ $is_data_dictionary = PMA_DRIZZLE
+ && $pmaString->strtolower($db) == 'data_dictionary';
if (($isInformationSchema || $is_data_dictionary)
&& ($source == 'internal' || $source == 'both')
) {
@@ -694,8 +698,9 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both')
}
if (isset($GLOBALS[$relations_key][$table])) {
foreach ($GLOBALS[$relations_key][$table] as $field => $relations) {
- if ((! strlen($column) || $column == $field)
- && (! isset($foreign[$field]) || ! strlen($foreign[$field]))
+ if ((! $pmaString->strlen($column) || $column == $field)
+ && (! isset($foreign[$field])
+ || ! $pmaString->strlen($foreign[$field]))
) {
$foreign[$field] = $relations;
}
@@ -878,7 +883,7 @@ function PMA_setDbComment($db, $comment = '')
return false;
}
- if (strlen($comment)) {
+ if ($GLOBALS['PMA_String']->strlen($comment)) {
$upd_query = 'INSERT INTO '
. PMA_Util::backquote($cfgRelation['db']) . '.'
. PMA_Util::backquote($cfgRelation['column_info'])
@@ -920,9 +925,10 @@ function PMA_setDbComment($db, $comment = '')
*/
function PMA_setHistory($db, $table, $username, $sqlquery)
{
+ $maxCharactersInDisplayedSQL = $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'];
// Prevent to run this automatically on Footer class destroying in testsuite
if (defined('TESTSUITE')
- || strlen($sqlquery) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']
+ || $GLOBALS['PMA_String']->strlen($sqlquery) > $maxCharactersInDisplayedSQL
) {
return;
}
@@ -1094,7 +1100,9 @@ function PMA_buildForeignDropdown($foreign, $data, $mode)
} else {
$vtitle = htmlspecialchars($value);
$value = htmlspecialchars(
- substr($value, 0, $GLOBALS['cfg']['LimitChars']) . '...'
+ $GLOBALS['PMA_String']->substr(
+ $value, 0, $GLOBALS['cfg']['LimitChars']
+ ) . '...'
);
}
diff --git a/libraries/replication.inc.php b/libraries/replication.inc.php
index d1b14e6179..593ec12d5b 100644
--- a/libraries/replication.inc.php
+++ b/libraries/replication.inc.php
@@ -191,8 +191,11 @@ function PMA_extractDbOrTable($string, $what = 'db')
*/
function PMA_Replication_Slave_control($action, $control = null, $link = null)
{
- $action = strtoupper($action);
- $control = strtoupper($control);
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
+ $action = $pmaString->strtoupper($action);
+ $control = $pmaString->strtoupper($control);
if ($action != "START" && $action != "STOP") {
return -1;
diff --git a/libraries/replication_gui.lib.php b/libraries/replication_gui.lib.php
index 684521c550..e260a58230 100644
--- a/libraries/replication_gui.lib.php
+++ b/libraries/replication_gui.lib.php
@@ -659,7 +659,12 @@ function PMA_getHtmlForReplicationMasterAddSlaveuser()
list($username_length, $hostname_length)
= PMA_replicationGetUsernameHostnameLength();
- if (isset($_REQUEST['username']) && strlen($_REQUEST['username']) === 0) {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
+ if (isset($_REQUEST['username'])
+ && $pmaString->strlen($_REQUEST['username']) === 0
+ ) {
$GLOBALS['pred_username'] = 'any';
}
$html .= '<div id="master_addslaveuser_gui">';
@@ -683,7 +688,10 @@ function PMA_getHtmlForReplicationMasterAddSlaveuser()
$thishost = str_replace(
"'",
'',
- substr($_current_user, (strrpos($_current_user, '@') + 1))
+ $pmaString->substr(
+ $_current_user,
+ ($pmaString->strrpos($_current_user, '@') + 1)
+ )
);
if ($thishost == 'localhost' || $thishost == '127.0.0.1') {
unset($thishost);
@@ -704,7 +712,7 @@ function PMA_getHtmlForReplicationMasterAddSlaveuser()
// when we start editing a user, $GLOBALS['pred_hostname'] is not defined
if (! isset($GLOBALS['pred_hostname']) && isset($_REQUEST['hostname'])) {
- switch (strtolower($_REQUEST['hostname'])) {
+ switch ($pmaString->strtolower($_REQUEST['hostname'])) {
case 'localhost':
case '127.0.0.1':
$GLOBALS['pred_hostname'] = 'localhost';
diff --git a/libraries/rte/rte_events.lib.php b/libraries/rte/rte_events.lib.php
index 0a17686639..9c3f1694c0 100644
--- a/libraries/rte/rte_events.lib.php
+++ b/libraries/rte/rte_events.lib.php
@@ -199,7 +199,9 @@ function PMA_EVN_handleEditor()
$event = $GLOBALS['dbi']->fetchSingleRow($query);
$response->addJSON(
'name',
- htmlspecialchars(strtoupper($_REQUEST['item_name']))
+ htmlspecialchars(
+ $GLOBALS['PMA_String']->strtoupper($_REQUEST['item_name'])
+ )
);
$response->addJSON('new_row', PMA_EVN_getRowForList($event));
$response->addJSON('insert', ! empty($event));
@@ -374,6 +376,9 @@ function PMA_EVN_getEditorForm($mode, $operation, $item)
{
global $db, $table, $event_status, $event_type, $event_interval;
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
// Escape special characters
$need_escape = array(
'item_original_name',
@@ -414,7 +419,7 @@ function PMA_EVN_getEditorForm($mode, $operation, $item)
}
// Create the output
$retval = "";
- $retval .= "<!-- START " . strtoupper($mode) . " EVENT FORM -->\n\n";
+ $retval .= "<!-- START " . $pmaString->strtoupper($mode) . " EVENT FORM -->\n\n";
$retval .= "<form class='rte_form' action='db_events.php' method='post'>\n";
$retval .= "<input name='{$mode}_item' type='hidden' value='1' />\n";
$retval .= $original_data;
@@ -549,7 +554,7 @@ function PMA_EVN_getEditorForm($mode, $operation, $item)
$retval .= "</fieldset>\n";
}
$retval .= "</form>\n\n";
- $retval .= "<!-- END " . strtoupper($mode) . " EVENT FORM -->\n\n";
+ $retval .= "<!-- END " . $pmaString->strtoupper($mode) . " EVENT FORM -->\n\n";
return $retval;
} // end PMA_EVN_getEditorForm()
@@ -565,7 +570,8 @@ function PMA_EVN_getQueryFromRequest()
$query = 'CREATE ';
if (! empty($_REQUEST['item_definer'])) {
- if (strpos($_REQUEST['item_definer'], '@') !== false) {
+ if ($GLOBALS['PMA_String']->strpos($_REQUEST['item_definer'], '@') !== false
+ ) {
$arr = explode('@', $_REQUEST['item_definer']);
$query .= 'DEFINER=' . PMA_Util::backquote($arr[0]);
$query .= '@' . PMA_Util::backquote($arr[1]) . ' ';
diff --git a/libraries/rte/rte_footer.lib.php b/libraries/rte/rte_footer.lib.php
index 9fe85f49a5..415f0164a5 100644
--- a/libraries/rte/rte_footer.lib.php
+++ b/libraries/rte/rte_footer.lib.php
@@ -22,14 +22,17 @@ function PMA_RTE_getFooterLinks($docu, $priv, $name)
{
global $db, $url_query, $ajax_class;
- $icon = 'b_' . strtolower($name) . '_add.png';
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
+ $icon = 'b_' . $pmaString->strtolower($name) . '_add.png';
$retval = "";
$retval .= "<!-- ADD " . $name . " FORM START -->\n";
$retval .= "<fieldset class='left'>\n";
$retval .= "<legend>" . _pgettext('Create new procedure', 'New') . "</legend>\n";
$retval .= " <div class='wrap'>\n";
$retval .= " <a {$ajax_class['add']} ";
- $retval .= "href='db_" . strtolower($name) . "s.php";
+ $retval .= "href='db_" . $pmaString->strtolower($name) . "s.php";
$retval .= "?$url_query&amp;add_item=1' onclick='$.datepicker.initialized = false;'>";
$retval .= PMA_Util::getIcon($icon);
$retval .= PMA_RTE_getWord('add') . "</a>\n";
@@ -80,7 +83,7 @@ function PMA_EVN_getFooterLinks()
0,
1
);
- $es_state = strtolower($es_state);
+ $es_state = $GLOBALS['PMA_String']->strtolower($es_state);
$options = array(
0 => array(
'label' => __('OFF'),
diff --git a/libraries/rte/rte_main.inc.php b/libraries/rte/rte_main.inc.php
index 9abb9a3080..845c2978d4 100644
--- a/libraries/rte/rte_main.inc.php
+++ b/libraries/rte/rte_main.inc.php
@@ -35,7 +35,7 @@ if ($GLOBALS['is_ajax_request'] != true) {
* to manually select the required database and
* create the missing $url_query variable
*/
- if (strlen($db)) {
+ if ($GLOBALS['PMA_String']->strlen($db)) {
$GLOBALS['dbi']->selectDb($db);
if (! isset($url_query)) {
$url_query = PMA_URL_getCommon($db, $table);
diff --git a/libraries/rte/rte_routines.lib.php b/libraries/rte/rte_routines.lib.php
index 2055f4a9ac..8a63709a52 100644
--- a/libraries/rte/rte_routines.lib.php
+++ b/libraries/rte/rte_routines.lib.php
@@ -97,6 +97,9 @@ function PMA_RTN_parseOneParameter($value)
{
global $param_directions;
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$retval = array(0 => '',
1 => '',
2 => '',
@@ -104,8 +107,11 @@ function PMA_RTN_parseOneParameter($value)
4 => '');
$parsed_param = PMA_SQP_parse($value);
$pos = 0;
- if (in_array(strtoupper($parsed_param[$pos]['data']), $param_directions)) {
- $retval[0] = strtoupper($parsed_param[0]['data']);
+ if (in_array(
+ $pmaString->strtoupper($parsed_param[$pos]['data']),
+ $param_directions
+ )) {
+ $retval[0] = $pmaString->strtoupper($parsed_param[0]['data']);
$pos++;
}
if ($parsed_param[$pos]['type'] == 'alpha_identifier'
@@ -123,7 +129,7 @@ function PMA_RTN_parseOneParameter($value)
if (($parsed_param[$i]['type'] == 'alpha_columnType'
|| $parsed_param[$i]['type'] == 'alpha_functionName') && $depth == 0
) {
- $retval[2] = strtoupper($parsed_param[$i]['data']);
+ $retval[2] = $pmaString->strtoupper($parsed_param[$i]['data']);
} else if ($parsed_param[$i]['type'] == 'punct_bracket_open_round'
&& $depth == 0
) {
@@ -135,17 +141,18 @@ function PMA_RTN_parseOneParameter($value)
} else if ($depth == 1) {
$param_length .= $parsed_param[$i]['data'];
} else if ($parsed_param[$i]['type'] == 'alpha_reservedWord'
- && strtoupper($parsed_param[$i]['data']) == 'CHARSET' && $depth == 0
+ && $pmaString->strtoupper($parsed_param[$i]['data']) == 'CHARSET'
+ && $depth == 0
) {
if ($parsed_param[$i+1]['type'] == 'alpha_charset'
|| $parsed_param[$i+1]['type'] == 'alpha_identifier'
) {
- $param_opts[] = strtolower($parsed_param[$i+1]['data']);
+ $param_opts[] = $pmaString->strtolower($parsed_param[$i+1]['data']);
}
} else if ($parsed_param[$i]['type'] == 'alpha_columnAttrib'
&& $depth == 0
) {
- $param_opts[] = strtoupper($parsed_param[$i]['data']);
+ $param_opts[] = $pmaString->strtoupper($parsed_param[$i]['data']);
}
}
$retval[3] = $param_length;
@@ -238,6 +245,9 @@ function PMA_RTN_parseAllParameters($parsed_query, $routine_type)
*/
function PMA_RTN_parseRoutineDefiner($parsed_query)
{
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$retval = '';
$fetching = false;
for ($i=0; $i<$parsed_query['len']; $i++) {
@@ -247,7 +257,7 @@ function PMA_RTN_parseRoutineDefiner($parsed_query)
$fetching = true;
} else if ($fetching == true
&& $parsed_query[$i]['type'] != 'quote_backtick'
- && substr($parsed_query[$i]['type'], 0, 5) != 'punct'
+ && $pmaString->substr($parsed_query[$i]['type'], 0, 5) != 'punct'
) {
break;
} else if ($fetching == true
@@ -402,7 +412,10 @@ function PMA_RTN_handleEditor()
. " WHERE $where;"
);
$response->addJSON(
- 'name', htmlspecialchars(strtoupper($_REQUEST['item_name']))
+ 'name',
+ htmlspecialchars(
+ $GLOBALS['PMA_String']->strtoupper($_REQUEST['item_name'])
+ )
);
$response->addJSON('new_row', PMA_RTN_getRowForList($routine));
$response->addJSON('insert', ! empty($routine));
@@ -512,7 +525,7 @@ function PMA_RTN_getDataFromRequest()
'item_definition',
'item_comment',
'item_definer');
- foreach ($indices as $key => $index) {
+ foreach ($indices as $index) {
$retval[$index] = isset($_REQUEST[$index]) ? $_REQUEST[$index] : '';
}
@@ -579,9 +592,12 @@ function PMA_RTN_getDataFromRequest()
$retval['item_returntype'] = $_REQUEST['item_returntype'];
}
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$retval['item_isdeterministic'] = '';
if (isset($_REQUEST['item_isdeterministic'])
- && strtolower($_REQUEST['item_isdeterministic']) == 'on'
+ && $pmaString->strtolower($_REQUEST['item_isdeterministic']) == 'on'
) {
$retval['item_isdeterministic'] = " checked='checked'";
}
@@ -670,7 +686,9 @@ function PMA_RTN_getDataFromName($name, $type, $all = true)
$retval['item_returnopts_num'] = '';
$retval['item_returnopts_text'] = '';
if (! empty($routine['DTD_IDENTIFIER'])) {
- if (strlen($routine['DTD_IDENTIFIER']) > 63) {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+ if ($pmaString->strlen($routine['DTD_IDENTIFIER']) > 63) {
// If the DTD_IDENTIFIER string from INFORMATION_SCHEMA is
// at least 64 characters, then it may actually have been
// chopped because that column is a varchar(64), so we will
@@ -680,7 +698,7 @@ function PMA_RTN_getDataFromName($name, $type, $all = true)
$fetching = false;
for ($i=0; $i<$parsed_query['len']; $i++) {
if ($parsed_query[$i]['type'] == 'alpha_reservedWord'
- && strtoupper($parsed_query[$i]['data']) == 'RETURNS'
+ && $pmaString->strtoupper($parsed_query[$i]['data']) == 'RETURNS'
) {
$fetching = true;
} else if ($fetching == true
@@ -692,7 +710,7 @@ function PMA_RTN_getDataFromName($name, $type, $all = true)
// characters. We can safely assume that the return
// datatype is either ENUM or SET, so we only look
// for CHARSET.
- $word = strtoupper($parsed_query[$i]['data']);
+ $word = $pmaString->strtoupper($parsed_query[$i]['data']);
if ($word == 'CHARSET'
&& ($parsed_query[$i+1]['type'] == 'alpha_charset'
|| $parsed_query[$i+1]['type'] == 'alpha_identifier')
@@ -935,9 +953,13 @@ function PMA_RTN_getEditorForm($mode, $operation, $routine)
$isfunction_select = " selected='selected'";
}
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
// Create the output
$retval = "";
- $retval .= "<!-- START " . strtoupper($mode) . " ROUTINE FORM -->\n\n";
+ $retval .= "<!-- START " . $pmaString->strtoupper($mode)
+ . " ROUTINE FORM -->\n\n";
$retval .= "<form class='rte_form' action='db_routines.php' method='post'>\n";
$retval .= "<input name='{$mode}_item' type='hidden' value='1' />\n";
$retval .= $original_routine;
@@ -1096,7 +1118,7 @@ function PMA_RTN_getEditorForm($mode, $operation, $routine)
$retval .= "</fieldset>";
}
$retval .= "</form>";
- $retval .= "<!-- END " . strtoupper($mode) . " ROUTINE FORM -->";
+ $retval .= "<!-- END " . $pmaString->strtoupper($mode) . " ROUTINE FORM -->";
return $retval;
} // end PMA_RTN_getEditorForm()
@@ -1113,9 +1135,12 @@ function PMA_RTN_getQueryFromRequest()
$_REQUEST['item_type'] = isset($_REQUEST['item_type'])
? $_REQUEST['item_type'] : '';
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$query = 'CREATE ';
if (! empty($_REQUEST['item_definer'])) {
- if (strpos($_REQUEST['item_definer'], '@') !== false) {
+ if ($pmaString->strpos($_REQUEST['item_definer'], '@') !== false) {
$arr = explode('@', $_REQUEST['item_definer']);
$query .= 'DEFINER=' . PMA_Util::backquote($arr[0]);
$query .= '@' . PMA_Util::backquote($arr[1]) . ' ';
@@ -1201,13 +1226,17 @@ function PMA_RTN_getQueryFromRequest()
if (! empty($_REQUEST['item_param_opts_text'][$i])) {
if ($PMA_Types->getTypeClass($item_param_type[$i]) == 'CHAR') {
$params .= ' CHARSET '
- . strtolower($_REQUEST['item_param_opts_text'][$i]);
+ . $pmaString->strtolower(
+ $_REQUEST['item_param_opts_text'][$i]
+ );
}
}
if (! empty($_REQUEST['item_param_opts_num'][$i])) {
if ($PMA_Types->getTypeClass($item_param_type[$i]) == 'NUMBER') {
$params .= ' '
- . strtoupper($_REQUEST['item_param_opts_num'][$i]);
+ . $pmaString->strtoupper(
+ $_REQUEST['item_param_opts_num'][$i]
+ );
}
}
if ($i != (count($item_param_name) - 1)) {
@@ -1261,12 +1290,13 @@ function PMA_RTN_getQueryFromRequest()
if (! empty($_REQUEST['item_returnopts_text'])) {
if ($PMA_Types->getTypeClass($item_returntype) == 'CHAR') {
$query .= ' CHARSET '
- . strtolower($_REQUEST['item_returnopts_text']);
+ . $pmaString->strtolower($_REQUEST['item_returnopts_text']);
}
}
if (! empty($_REQUEST['item_returnopts_num'])) {
if ($PMA_Types->getTypeClass($item_returntype) == 'NUMBER') {
- $query .= ' ' . strtoupper($_REQUEST['item_returnopts_num']);
+ $query .= ' '
+ . $pmaString->strtoupper($_REQUEST['item_returnopts_num']);
}
}
$query .= ' ';
@@ -1570,6 +1600,9 @@ function PMA_RTN_getExecuteForm($routine)
{
global $db, $cfg;
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
// Escape special characters
$routine['item_name'] = htmlentities($routine['item_name'], ENT_QUOTES);
for ($i=0; $i<$routine['item_num_params']; $i++) {
@@ -1624,13 +1657,16 @@ function PMA_RTN_getExecuteForm($routine)
if (stristr($routine['item_param_type'][$i], 'enum')
|| stristr($routine['item_param_type'][$i], 'set')
|| in_array(
- strtolower($routine['item_param_type'][$i]), $no_support_types
+ $pmaString->strtolower($routine['item_param_type'][$i]),
+ $no_support_types
)
) {
$retval .= "--\n";
} else {
$field = array(
- 'True_Type' => strtolower($routine['item_param_type'][$i]),
+ 'True_Type' => $pmaString->strtolower(
+ $routine['item_param_type'][$i]
+ ),
'Type' => '',
'Key' => '',
'Field' => '',
@@ -1676,7 +1712,8 @@ function PMA_RTN_getExecuteForm($routine)
}
}
} else if (in_array(
- strtolower($routine['item_param_type'][$i]), $no_support_types
+ $pmaString->strtolower($routine['item_param_type'][$i]),
+ $no_support_types
)) {
$retval .= "\n";
} else {
diff --git a/libraries/rte/rte_triggers.lib.php b/libraries/rte/rte_triggers.lib.php
index 1650ae7a51..46718d29b9 100644
--- a/libraries/rte/rte_triggers.lib.php
+++ b/libraries/rte/rte_triggers.lib.php
@@ -178,7 +178,9 @@ function PMA_TRI_handleEditor()
$response->addJSON(
'name',
htmlspecialchars(
- strtoupper($_REQUEST['item_name'])
+ $GLOBALS['PMA_String']->strtoupper(
+ $_REQUEST['item_name']
+ )
)
);
}
@@ -322,6 +324,9 @@ function PMA_TRI_getEditorForm($mode, $item)
{
global $db, $table, $event_manipulations, $action_timings;
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
// Escape special characters
$need_escape = array(
'item_original_name',
@@ -344,7 +349,7 @@ function PMA_TRI_getEditorForm($mode, $item)
// Create the output
$retval = "";
- $retval .= "<!-- START " . strtoupper($mode) . " TRIGGER FORM -->\n\n";
+ $retval .= "<!-- START " . $pmaString->strtoupper($mode) . " TRIGGER FORM -->\n\n";
$retval .= "<form class='rte_form' action='db_triggers.php' method='post'>\n";
$retval .= "<input name='{$mode}_item' type='hidden' value='1' />\n";
$retval .= $original_data;
@@ -427,7 +432,7 @@ function PMA_TRI_getEditorForm($mode, $item)
$retval .= "</fieldset>\n";
}
$retval .= "</form>\n\n";
- $retval .= "<!-- END " . strtoupper($mode) . " TRIGGER FORM -->\n\n";
+ $retval .= "<!-- END " . $pmaString->strtoupper($mode) . " TRIGGER FORM -->\n\n";
return $retval;
} // end PMA_TRI_getEditorForm()
@@ -443,7 +448,8 @@ function PMA_TRI_getQueryFromRequest()
$query = 'CREATE ';
if (! empty($_REQUEST['item_definer'])) {
- if (strpos($_REQUEST['item_definer'], '@') !== false) {
+ if ($GLOBALS['PMA_String']->strpos($_REQUEST['item_definer'], '@') !== false
+ ) {
$arr = explode('@', $_REQUEST['item_definer']);
$query .= 'DEFINER=' . PMA_Util::backquote($arr[0]);
$query .= '@' . PMA_Util::backquote($arr[1]) . ' ';
diff --git a/libraries/rte/rte_words.lib.php b/libraries/rte/rte_words.lib.php
index a9f5f5c4f0..db40ca73a7 100644
--- a/libraries/rte/rte_words.lib.php
+++ b/libraries/rte/rte_words.lib.php
@@ -10,7 +10,7 @@ if (! defined('PHPMYADMIN')) {
}
/**
- * This function is used to retreive some language strings that are used
+ * This function is used to retrieve some language strings that are used
* in functionalities that are common to routines, triggers and events.
*
* @param string $index The index of the string to get
diff --git a/libraries/sanitizing.lib.php b/libraries/sanitizing.lib.php
index 7e6e84db5b..0b14de8ab4 100644
--- a/libraries/sanitizing.lib.php
+++ b/libraries/sanitizing.lib.php
@@ -29,8 +29,10 @@ function PMA_checkLink($url)
$valid_starts[] = '?page=form&';
$valid_starts[] = '?page=servers&';
}
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
foreach ($valid_starts as $val) {
- if (substr($url, 0, strlen($val)) == $val) {
+ if ($pmaString->substr($url, 0, $pmaString->strlen($val)) == $val) {
return true;
}
}
@@ -62,7 +64,7 @@ function PMA_replaceBBLink($found)
}
/* Construct url */
- if (substr($found[1], 0, 4) == 'http') {
+ if ($GLOBALS['PMA_String']->substr($found[1], 0, 4) == 'http') {
$url = PMA_linkURL($found[1]);
} else {
$url = $found[1];
diff --git a/libraries/select_lang.lib.php b/libraries/select_lang.lib.php
index 625f7cf229..23d6e0ff19 100644
--- a/libraries/select_lang.lib.php
+++ b/libraries/select_lang.lib.php
@@ -18,7 +18,12 @@ if (! defined('PHPMYADMIN')) {
*/
function PMA_languageName($tmplang)
{
- $lang_name = ucfirst(substr(strrchr($tmplang[0], '|'), 1));
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
+ $lang_name = ucfirst(
+ $pmaString->substr($pmaString->strrchr($tmplang[0], '|'), 1)
+ );
// Include native name if non empty
if (!empty($tmplang[2])) {
@@ -84,7 +89,9 @@ function PMA_langCheck()
// try to find out user's language by checking its HTTP_ACCEPT_LANGUAGE variable;
// prevent XSS
$accepted_languages = PMA_getenv('HTTP_ACCEPT_LANGUAGE');
- if ($accepted_languages && false === strpos($accepted_languages, '<')) {
+ if ($accepted_languages
+ && false === $GLOBALS['PMA_String']->strpos($accepted_languages, '<')
+ ) {
foreach (explode(',', $accepted_languages) as $lang) {
if (PMA_langDetect($lang, 1)) {
return true;
@@ -153,7 +160,7 @@ function PMA_langDetect($str, $envType)
// $envType = 1 for the 'HTTP_ACCEPT_LANGUAGE' environment variable,
// 2 for the 'HTTP_USER_AGENT' one
$expr = $value[0];
- if (strpos($expr, '[-_]') === false) {
+ if ($GLOBALS['PMA_String']->strpos($expr, '[-_]') === false) {
$expr = str_replace('|', '([-_][[:alpha:]]{2,3})?|', $expr);
}
$pattern1 = '/^(' . addcslashes($expr, '/') . ')(;q=[0-9]\\.[0-9])?$/i';
diff --git a/libraries/server_databases.lib.php b/libraries/server_databases.lib.php
index 83ac53ae6d..b3d42e11ce 100644
--- a/libraries/server_databases.lib.php
+++ b/libraries/server_databases.lib.php
@@ -439,7 +439,7 @@ function PMA_getListForSortDatabase()
}
if (isset($_REQUEST['sort_order'])
- && strtolower($_REQUEST['sort_order']) == 'desc'
+ && $GLOBALS['PMA_String']->strtolower($_REQUEST['sort_order']) == 'desc'
) {
$sort_order = 'desc';
} else {
diff --git a/libraries/server_plugins.lib.php b/libraries/server_plugins.lib.php
index a85aaead20..7661b9ee27 100644
--- a/libraries/server_plugins.lib.php
+++ b/libraries/server_plugins.lib.php
@@ -49,8 +49,12 @@ function PMA_getPluginTab($plugins)
$html = '<div id="plugins_plugins">';
$html .= '<div id="sectionlinks">';
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
foreach ($plugins as $plugin_type => $plugin_list) {
- $key = 'plugins-' . preg_replace('/[^a-z]/', '', strtolower($plugin_type));
+ $key = 'plugins-'
+ . preg_replace('/[^a-z]/', '', $pmaString->strtolower($plugin_type));
$html .= '<a href="#' . $key . '">'
. htmlspecialchars($plugin_type) . '</a>' . "\n";
}
@@ -59,7 +63,8 @@ function PMA_getPluginTab($plugins)
$html .= '<br />';
foreach ($plugins as $plugin_type => $plugin_list) {
- $key = 'plugins-' . preg_replace('/[^a-z]/', '', strtolower($plugin_type));
+ $key = 'plugins-'
+ . preg_replace('/[^a-z]/', '', $pmaString->strtolower($plugin_type));
sort($plugin_list);
$html .= '<table class="data_full_width" id="' . $key . '">';
diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php
index 4bd0c9f374..d2c0d8e4d4 100644
--- a/libraries/server_privileges.lib.php
+++ b/libraries/server_privileges.lib.php
@@ -52,10 +52,12 @@ function PMA_getHtmlForUserGroupDialog($username, $is_menuswork)
*/
function PMA_wildcardEscapeForGrant($dbname, $tablename)
{
- if (! strlen($dbname)) {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+ if (!$pmaString->strlen($dbname)) {
$db_and_table = '*.*';
} else {
- if (strlen($tablename)) {
+ if ($pmaString->strlen($tablename)) {
$db_and_table = PMA_Util::backquote(
PMA_Util::unescapeMysqlWildcards($dbname)
)
@@ -78,14 +80,16 @@ function PMA_rangeOfUsers($initial = '')
{
// strtolower() is used because the User field
// might be BINARY, so LIKE would be case sensitive
- if (! empty($initial)) {
- $ret = " WHERE `User` LIKE '"
- . PMA_Util::sqlAddSlashes($initial, true) . "%'"
- . " OR `User` LIKE '"
- . PMA_Util::sqlAddSlashes(strtolower($initial), true) . "%'";
- } else {
+ if (empty($initial)) {
$ret = '';
+ return $ret;
}
+
+ $ret = " WHERE `User` LIKE '"
+ . PMA_Util::sqlAddSlashes($initial, true) . "%'"
+ . " OR `User` LIKE '"
+ . PMA_Util::sqlAddSlashes($GLOBALS['PMA_String']->strtolower($initial), true)
+ . "%'";
return $ret;
} // end function
@@ -125,12 +129,16 @@ function PMA_fillInTablePrivileges(&$row)
// the view for Show is spelled with lowercase v
// and there is a space between the words
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$av_grants = explode(
'\',\'',
- substr(
+ $pmaString->substr(
$row1['Type'],
- strpos($row1['Type'], '(') + 2,
- strpos($row1['Type'], ')') - strpos($row1['Type'], '(') - 3
+ $pmaString->strpos($row1['Type'], '(') + 2,
+ $pmaString->strpos($row1['Type'], ')')
+ - $pmaString->strpos($row1['Type'], '(') - 3
)
);
@@ -641,7 +649,7 @@ function PMA_getHtmlToDisplayPrivilegesTable($db = '*',
}
$res = $GLOBALS['dbi']->query($sql_query);
while ($row1 = $GLOBALS['dbi']->fetchRow($res)) {
- if (substr($row1[0], 0, 4) == 'max_') {
+ if ($GLOBALS['PMA_String']->substr($row1[0], 0, 4) == 'max_') {
$row[$row1[0]] = 0;
} else {
$row[$row1[0]] = 'N';
@@ -903,8 +911,12 @@ function PMA_getHtmlForAttachedPrivilegesToTableSpecificColumn($columns, $row)
function PMA_getHtmlForNotAttachedPrivilegesToTableSpecificColumn($row)
{
$html_output = '';
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
foreach ($row as $current_grant => $current_grant_value) {
- $grant_type = substr($current_grant, 0, (strlen($current_grant) - 5));
+ $grant_type = $pmaString
+ ->substr($current_grant, 0, ($pmaString->strlen($current_grant) - 5));
if (in_array($grant_type, array('Select', 'Insert', 'Update', 'References'))
) {
continue;
@@ -931,18 +943,24 @@ function PMA_getHtmlForNotAttachedPrivilegesToTableSpecificColumn($row)
. 'title="';
$html_output .= (isset($GLOBALS[
- 'strPrivDesc' . substr(
- $tmp_current_grant, 0, (strlen($tmp_current_grant) - 5)
+ 'strPrivDesc' . $pmaString->substr(
+ $tmp_current_grant,
+ 0,
+ ($pmaString->strlen($tmp_current_grant) - 5)
)
] )
? $GLOBALS[
- 'strPrivDesc' . substr(
- $tmp_current_grant, 0, (strlen($tmp_current_grant) - 5)
+ 'strPrivDesc' . $pmaString->substr(
+ $tmp_current_grant,
+ 0,
+ ($pmaString->strlen($tmp_current_grant) - 5)
)
]
: $GLOBALS[
- 'strPrivDesc' . substr(
- $tmp_current_grant, 0, (strlen($tmp_current_grant) - 5)
+ 'strPrivDesc' . $pmaString->substr(
+ $tmp_current_grant,
+ 0,
+ ($pmaString->strlen($tmp_current_grant) - 5)
) . 'Tbl'
]
)
@@ -951,24 +969,34 @@ function PMA_getHtmlForNotAttachedPrivilegesToTableSpecificColumn($row)
$html_output .= '<label for="checkbox_' . $current_grant
. '"><code><dfn title="'
. (isset($GLOBALS[
- 'strPrivDesc' . substr(
- $tmp_current_grant, 0, (strlen($tmp_current_grant) - 5)
+ 'strPrivDesc' . $pmaString->substr(
+ $tmp_current_grant,
+ 0,
+ ($pmaString->strlen($tmp_current_grant) - 5)
)
])
? $GLOBALS[
- 'strPrivDesc' . substr(
- $tmp_current_grant, 0, (strlen($tmp_current_grant) - 5)
+ 'strPrivDesc' . $pmaString->substr(
+ $tmp_current_grant,
+ 0,
+ ($pmaString->strlen($tmp_current_grant) - 5)
)
]
: $GLOBALS[
- 'strPrivDesc' . substr(
- $tmp_current_grant, 0, (strlen($tmp_current_grant) - 5)
+ 'strPrivDesc' . $pmaString->substr(
+ $tmp_current_grant,
+ 0,
+ ($pmaString->strlen($tmp_current_grant) - 5)
) . 'Tbl'
]
)
. '">'
- . strtoupper(
- substr($current_grant, 0, strlen($current_grant) - 5)
+ . $pmaString->strtoupper(
+ $pmaString->substr(
+ $current_grant,
+ 0,
+ $pmaString->strlen($current_grant) - 5
+ )
)
. '</dfn></code></label>' . "\n"
. '</div>' . "\n";
@@ -1270,7 +1298,11 @@ function PMA_getHtmlForLoginInformationFields($mode = 'new')
{
list($username_length, $hostname_length) = PMA_getUsernameAndHostnameLength();
- if (isset($GLOBALS['username']) && strlen($GLOBALS['username']) === 0) {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+ if (isset($GLOBALS['username'])
+ && $pmaString->strlen($GLOBALS['username']) === 0
+ ) {
$GLOBALS['pred_username'] = 'any';
}
$html_output = '<fieldset id="fieldset_add_user_login">' . "\n"
@@ -1354,7 +1386,10 @@ function PMA_getHtmlForLoginInformationFields($mode = 'new')
$thishost = str_replace(
"'",
'',
- substr($_current_user, (strrpos($_current_user, '@') + 1))
+ $pmaString->substr(
+ $_current_user,
+ ($pmaString->strrpos($_current_user, '@') + 1)
+ )
);
if ($thishost == 'localhost' || $thishost == '127.0.0.1') {
unset($thishost);
@@ -1384,7 +1419,7 @@ function PMA_getHtmlForLoginInformationFields($mode = 'new')
// when we start editing a user, $GLOBALS['pred_hostname'] is not defined
if (! isset($GLOBALS['pred_hostname']) && isset($GLOBALS['hostname'])) {
- switch (strtolower($GLOBALS['hostname'])) {
+ switch ($pmaString->strtolower($GLOBALS['hostname'])) {
case 'localhost':
case '127.0.0.1':
$GLOBALS['pred_hostname'] = 'localhost';
@@ -2334,10 +2369,12 @@ function PMA_getExtraDataForAjaxBehavior(
$user_group_count = PMA_getUserGroupCount();
}
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$extra_data = array();
- if (strlen($sql_query)) {
- $extra_data['sql_query']
- = PMA_Util::getMessage(null, $sql_query);
+ if ($pmaString->strlen($sql_query)) {
+ $extra_data['sql_query'] = PMA_Util::getMessage(null, $sql_query);
}
if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) {
@@ -2415,7 +2452,8 @@ function PMA_getExtraDataForAjaxBehavior(
* Generate the string for this alphabet's initial, to update the user
* pagination
*/
- $new_user_initial = strtoupper(substr($username, 0, 1));
+ $new_user_initial = $pmaString
+ ->strtoupper($pmaString->substr($username, 0, 1));
$newUserInitialString = '<a href="server_privileges.php'
. PMA_URL_getCommon(array('initial' => $new_user_initial)) . '">'
. $new_user_initial . '</a>';
@@ -2532,7 +2570,7 @@ function PMA_getLinkToDbAndTable($url_dbname, $dbname, $tablename)
)
. "</a> ]\n";
- if (strlen($tablename)) {
+ if ($GLOBALS['PMA_String']->strlen($tablename)) {
$html_output .= ' [ ' . __('Table') . ' <a href="'
. $GLOBALS['cfg']['DefaultTabTable']
. PMA_URL_getCommon(
@@ -2565,7 +2603,9 @@ function PMA_getLinkToDbAndTable($url_dbname, $dbname, $tablename)
*/
function PMA_getUserSpecificRights($tables, $user_host_condition, $dbname)
{
- if (! strlen($dbname)) {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+ if (!$pmaString->strlen($dbname)) {
$tables_to_search_for_users = array(
'tables_priv', 'columns_priv',
);
@@ -2606,7 +2646,7 @@ function PMA_getUserSpecificRights($tables, $user_host_condition, $dbname)
while ($db_rights_row = $GLOBALS['dbi']->fetchAssoc($db_rights_result)) {
$db_rights_row = array_merge($user_defaults, $db_rights_row);
- if (! strlen($dbname)) {
+ if (!$pmaString->strlen($dbname)) {
// only Db names in the table `mysql`.`db` uses wildcards
// as we are in the db specific rights display we want
// all db names escaped, also from other sources
@@ -2619,7 +2659,7 @@ function PMA_getUserSpecificRights($tables, $user_host_condition, $dbname)
$GLOBALS['dbi']->freeResult($db_rights_result);
- if (! strlen($dbname)) {
+ if (!$pmaString->strlen($dbname)) {
$sql_query = 'SELECT * FROM `mysql`.`db`'
. $user_host_condition . ' ORDER BY `Db` ASC';
} else {
@@ -2642,7 +2682,7 @@ function PMA_getUserSpecificRights($tables, $user_host_condition, $dbname)
} else {
$db_rights[$row[$dbOrTableName]] = $row;
}
- if (! strlen($dbname)) {
+ if (!$pmaString->strlen($dbname)) {
// there are db specific rights for this user
// so we can drop this db rights
$db_rights[$row['Db']]['can_delete'] = true;
@@ -2673,15 +2713,20 @@ function PMA_getHtmlForUserRights($db_rights, $dbname,
. '<td colspan="6"><center><i>' . __('None') . '</i></center></td>' . "\n"
. '</tr>' . "\n";
} else {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$odd_row = true;
//while ($row = $GLOBALS['dbi']->fetchAssoc($res)) {
foreach ($db_rights as $row) {
- $found_rows[] = (! strlen($dbname)) ? $row['Db'] : $row['Table_name'];
+ $found_rows[] = (!$pmaString->strlen($dbname))
+ ? $row['Db']
+ : $row['Table_name'];
$html_output .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">' . "\n"
. '<td>'
. htmlspecialchars(
- (! strlen($dbname)) ? $row['Db'] : $row['Table_name']
+ (!$pmaString->strlen($dbname)) ? $row['Db'] : $row['Table_name']
)
. '</td>' . "\n"
. '<td><code>' . "\n"
@@ -2692,8 +2737,8 @@ function PMA_getHtmlForUserRights($db_rights, $dbname,
) . "\n"
. '</code></td>' . "\n"
. '<td>'
- . ((((! strlen($dbname)) && $row['Grant_priv'] == 'Y')
- || (strlen($dbname)
+ . ((((!$pmaString->strlen($dbname)) && $row['Grant_priv'] == 'Y')
+ || ($pmaString->strlen($dbname)
&& in_array('Grant', explode(',', $row['Table_priv']))))
? __('Yes')
: __('No'))
@@ -2709,20 +2754,20 @@ function PMA_getHtmlForUserRights($db_rights, $dbname,
$html_output .= PMA_getUserEditLink(
$username,
$hostname,
- (! strlen($dbname)) ? $row['Db'] : $dbname,
- (! strlen($dbname)) ? '' : $row['Table_name']
+ (!$pmaString->strlen($dbname)) ? $row['Db'] : $dbname,
+ (!$pmaString->strlen($dbname)) ? '' : $row['Table_name']
);
$html_output .= '</td>' . "\n"
. ' <td>';
if (! empty($row['can_delete'])
|| isset($row['Table_name'])
- && strlen($row['Table_name'])
+ && $pmaString->strlen($row['Table_name'])
) {
$html_output .= PMA_getUserRevokeLink(
$username,
$hostname,
- (! strlen($dbname)) ? $row['Db'] : $dbname,
- (! strlen($dbname)) ? '' : $row['Table_name']
+ (! $pmaString->strlen($dbname)) ? $row['Db'] : $dbname,
+ (! $pmaString->strlen($dbname)) ? '' : $row['Table_name']
);
}
$html_output .= '</td>' . "\n"
@@ -2745,6 +2790,8 @@ function PMA_getHtmlForUserRights($db_rights, $dbname,
function PMA_getHtmlForAllTableSpecificRights(
$username, $hostname, $dbname
) {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
// table header
$html_output = PMA_URL_getHiddenInputs('', '')
. '<input type="hidden" name="username" '
@@ -2753,12 +2800,12 @@ function PMA_getHtmlForAllTableSpecificRights(
. 'value="' . htmlspecialchars($hostname) . '" />' . "\n"
. '<fieldset>' . "\n"
. '<legend data-submenu-label="'
- . (! strlen($dbname)
+ . (!$pmaString->strlen($dbname)
? __('Database')
: __('Table')
)
. '">'
- . (! strlen($dbname)
+ . (!$pmaString->strlen($dbname)
? __('Database-specific privileges')
: __('Table-specific privileges')
)
@@ -2766,12 +2813,12 @@ function PMA_getHtmlForAllTableSpecificRights(
. '<table class="data">' . "\n"
. '<thead>' . "\n"
. '<tr><th>'
- . (! strlen($dbname) ? __('Database') : __('Table'))
+ . (!$pmaString->strlen($dbname) ? __('Database') : __('Table'))
. '</th>' . "\n"
. '<th>' . __('Privileges') . '</th>' . "\n"
. '<th>' . __('Grant') . '</th>' . "\n"
. '<th>'
- . (! strlen($dbname)
+ . (!$pmaString->strlen($dbname)
? __('Table-specific privileges')
: __('Column-specific privileges')
)
@@ -3155,10 +3202,13 @@ function PMA_getFieldsetForAddDeleteUser()
*/
function PMA_getHtmlForInitials($array_initials)
{
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
// initialize to false the letters A-Z
for ($letter_counter = 1; $letter_counter < 27; $letter_counter++) {
- if (! isset($array_initials[chr($letter_counter + 64)])) {
- $array_initials[chr($letter_counter + 64)] = false;
+ if (! isset($array_initials[$pmaString->chr($letter_counter + 64)])) {
+ $array_initials[$pmaString->chr($letter_counter + 64)] = false;
}
}
@@ -3323,16 +3373,20 @@ function PMA_updatePrivileges($username, $hostname, $tablename, $dbname)
$sql_query1 = '';
}
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
// Should not do a GRANT USAGE for a table-specific privilege, it
// causes problems later (cannot revoke it)
- if (! (strlen($tablename) && 'USAGE' == implode('', PMA_extractPrivInfo()))) {
+ if (! ($pmaString->strlen($tablename)
+ && 'USAGE' == implode('', PMA_extractPrivInfo()))
+ ) {
$sql_query2 = 'GRANT ' . join(', ', PMA_extractPrivInfo())
. ' ON ' . $db_and_table
. ' TO \'' . PMA_Util::sqlAddSlashes($username) . '\'@\''
. PMA_Util::sqlAddSlashes($hostname) . '\'';
if ((isset($_POST['Grant_priv']) && $_POST['Grant_priv'] == 'Y')
- || (! strlen($dbname)
+ || (! $pmaString->strlen($dbname)
&& (isset($_POST['max_questions']) || isset($_POST['max_connections'])
|| isset($_POST['max_updates'])
|| isset($_POST['max_user_connections'])))
@@ -3512,6 +3566,10 @@ function PMA_addUser(
$queries = null;
$queries_for_display = null;
$sql_query = null;
+
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) {
$sql_query = '';
if ($_POST['pred_username'] == 'any') {
@@ -3529,7 +3587,10 @@ function PMA_addUser(
break;
case 'thishost':
$_user_name = $GLOBALS['dbi']->fetchValue('SELECT USER()');
- $hostname = substr($_user_name, (strrpos($_user_name, '@') + 1));
+ $hostname = $pmaString->substr(
+ $_user_name,
+ ($pmaString->strrpos($_user_name, '@') + 1)
+ );
unset($_user_name);
break;
}
@@ -3718,9 +3779,17 @@ function PMA_getListForExportUserDefinition($username, $hostname)
if (isset($_REQUEST['selected_usr'])) {
// export privileges for selected users
$title = __('Privileges');
+
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
foreach ($_REQUEST['selected_usr'] as $export_user) {
- $export_username = substr($export_user, 0, strpos($export_user, '&'));
- $export_hostname = substr($export_user, strrpos($export_user, ';') + 1);
+ $export_username = $pmaString->substr(
+ $export_user, 0, $pmaString->strpos($export_user, '&')
+ );
+ $export_hostname = $pmaString->substr(
+ $export_user, $pmaString->strrpos($export_user, ';') + 1
+ );
$export .= '# '
. sprintf(
__('Privileges for %s'),
@@ -4027,9 +4096,11 @@ function PMA_getHtmlForUserProperties($dbname_is_wildcard,$url_dbname,
'username' => $username,
'hostname' => $hostname,
);
- if (! is_array($dbname) && strlen($dbname)) {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+ if (! is_array($dbname) && $pmaString->strlen($dbname)) {
$_params['dbname'] = $dbname;
- if (strlen($tablename)) {
+ if ($pmaString->strlen($tablename)) {
$_params['tablename'] = $tablename;
}
} else {
@@ -4047,7 +4118,9 @@ function PMA_getHtmlForUserProperties($dbname_is_wildcard,$url_dbname,
$html_output .= '</form>' . "\n";
- if (! is_array($dbname) && ! strlen($tablename) && empty($dbname_is_wildcard)) {
+ if (! is_array($dbname) && ! $pmaString->strlen($tablename)
+ && empty($dbname_is_wildcard)
+ ) {
// no table name was given, display all table specific rights
// but only if $dbname contains no wildcards
@@ -4063,7 +4136,7 @@ function PMA_getHtmlForUserProperties($dbname_is_wildcard,$url_dbname,
);
$html_output .= $html_rightsTable;
- if (! strlen($dbname)) {
+ if (! $pmaString->strlen($dbname)) {
// no database name was given, display select db
$html_output .= PMA_getHtmlForSelectDbInEditPrivs($found_rows);
@@ -4079,12 +4152,16 @@ function PMA_getHtmlForUserProperties($dbname_is_wildcard,$url_dbname,
}
// Provide a line with links to the relevant database and table
- if (! is_array($dbname) && strlen($dbname) && empty($dbname_is_wildcard)) {
+ if (! is_array($dbname) && $pmaString->strlen($dbname)
+ && empty($dbname_is_wildcard)
+ ) {
$html_output .= PMA_getLinkToDbAndTable($url_dbname, $dbname, $tablename);
}
- if (! is_array($dbname) && ! strlen($dbname) && ! $user_does_not_exists) {
+ if (! is_array($dbname) && ! $pmaString->strlen($dbname)
+ && ! $user_does_not_exists
+ ) {
//change login information
$html_output .= PMA_getHtmlForChangePassword($username, $hostname);
$html_output .= PMA_getChangeLoginInformationHtmlForm($username, $hostname);
diff --git a/libraries/server_status_monitor.lib.php b/libraries/server_status_monitor.lib.php
index e2dd65f51d..c19b5a7d48 100644
--- a/libraries/server_status_monitor.lib.php
+++ b/libraries/server_status_monitor.lib.php
@@ -576,23 +576,29 @@ function PMA_getJsonForLogDataTypeSlow($start, $end)
$return = array('rows' => array(), 'sum' => array());
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
- $type = strtolower(
- substr($row['sql_text'], 0, strpos($row['sql_text'], ' '))
+ $type = $pmaString->strtolower(
+ $pmaString->substr(
+ $row['sql_text'],
+ 0,
+ $pmaString->strpos($row['sql_text'], ' ')
+ )
);
switch($type) {
case 'insert':
case 'update':
//Cut off big inserts and updates, but append byte count instead
- if (strlen($row['sql_text']) > 220) {
+ if ($pmaString->strlen($row['sql_text']) > 220) {
$implode_sql_text = implode(
' ',
PMA_Util::formatByteDown(
- strlen($row['sql_text']), 2, 2
+ $pmaString->strlen($row['sql_text']), 2, 2
)
);
- $row['sql_text'] = substr($row['sql_text'], 0, 200)
+ $row['sql_text'] = $pmaString->substr($row['sql_text'], 0, 200)
. '... [' . $implode_sql_text . ']';
}
break;
@@ -647,9 +653,11 @@ function PMA_getJsonForLogDataTypeGeneral($start, $end)
$removeVars = isset($_REQUEST['removeVariables'])
&& $_REQUEST['removeVariables'];
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
preg_match('/^(\w+)\s/', $row['argument'], $match);
- $type = strtolower($match[1]);
+ $type = $pmaString->strtolower($match[1]);
if (! isset($return['sum'][$type])) {
$return['sum'][$type] = 0;
@@ -676,7 +684,7 @@ function PMA_getJsonForLogDataTypeGeneral($start, $end)
$temp = $return['rows'][$insertTablesFirst]['argument'];
$return['rows'][$insertTablesFirst]['argument']
.= PMA_getJsonForLogDataTypeGeneral_getSuspensionPoints(
- $temp[strlen($temp) - 1]
+ $temp[$pmaString->strlen($temp) - 1]
);
// Group this value, thus do not add to the result list
@@ -691,13 +699,13 @@ function PMA_getJsonForLogDataTypeGeneral($start, $end)
case 'update':
// Cut off big inserts and updates,
// but append byte count therefor
- if (strlen($row['argument']) > 220) {
- $row['argument'] = substr($row['argument'], 0, 200)
+ if ($pmaString->strlen($row['argument']) > 220) {
+ $row['argument'] = $pmaString->substr($row['argument'], 0, 200)
. '... ['
. implode(
' ',
PMA_Util::formatByteDown(
- strlen($row['argument']),
+ $pmaString->strlen($row['argument']),
2,
2
)
@@ -776,7 +784,7 @@ function PMA_getJsonForQueryAnalyzer()
{
$return = array();
- if (strlen($_REQUEST['database'])) {
+ if ($GLOBALS['PMA_String']->strlen($_REQUEST['database'])) {
$GLOBALS['dbi']->selectDb($_REQUEST['database']);
}
diff --git a/libraries/server_status_processes.lib.php b/libraries/server_status_processes.lib.php
index e7cd41e41a..61140991fc 100644
--- a/libraries/server_status_processes.lib.php
+++ b/libraries/server_status_processes.lib.php
@@ -233,11 +233,14 @@ function PMA_getHtmlForServerProcesslist()
*/
function PMA_getHtmlForServerProcessItem($process, $odd_row, $show_full_sql)
{
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
// Array keys need to modify due to the way it has used
// to display column values
if (! empty($_REQUEST['order_by_field']) && ! empty($_REQUEST['sort_order']) ) {
foreach (array_keys($process) as $key) {
- $new_key = ucfirst(strtolower($key));
+ $new_key = ucfirst($pmaString->strtolower($key));
if ($new_key !== $key) {
$process[$new_key] = $process[$key];
unset($process[$key]);
@@ -257,7 +260,8 @@ function PMA_getHtmlForServerProcessItem($process, $odd_row, $show_full_sql)
$retval .= '<td class="value">' . $process['Id'] . '</td>';
$retval .= '<td>' . htmlspecialchars($process['User']) . '</td>';
$retval .= '<td>' . htmlspecialchars($process['Host']) . '</td>';
- $retval .= '<td>' . ((! isset($process['db']) || ! strlen($process['db']))
+ $retval .= '<td>' . ((! isset($process['db'])
+ || !$pmaString->strlen($process['db']))
? '<i>' . __('None') . '</i>'
: htmlspecialchars($process['db'])) . '</td>';
$retval .= '<td>' . htmlspecialchars($process['Command']) . '</td>';
diff --git a/libraries/server_status_variables.lib.php b/libraries/server_status_variables.lib.php
index 16fc8502a4..aec779a8c1 100644
--- a/libraries/server_status_variables.lib.php
+++ b/libraries/server_status_variables.lib.php
@@ -223,6 +223,9 @@ function PMA_getHtmlForRenderVariables($ServerStatusData, $alerts, $strShowStatu
$retval .= '</thead>';
$retval .= '<tbody>';
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$odd_row = false;
foreach ($ServerStatusData->status as $name => $value) {
$odd_row = !$odd_row;
@@ -236,7 +239,7 @@ function PMA_getHtmlForRenderVariables($ServerStatusData, $alerts, $strShowStatu
$retval .= htmlspecialchars(str_replace('_', ' ', $name));
// Fields containing % are calculated,
// they can not be described in MySQL documentation
- if (strpos($name, '%') === false) {
+ if ($pmaString->strpos($name, '%') === false) {
$retval .= PMA_Util::showMySQLDocu(
'server-status-variables',
false,
@@ -253,9 +256,9 @@ function PMA_getHtmlForRenderVariables($ServerStatusData, $alerts, $strShowStatu
$retval .= '<span class="allfine">';
}
}
- if ('%' === substr($name, -1, 1)) {
+ if ('%' === $pmaString->substr($name, -1, 1)) {
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 0, 2)) . ' %';
- } elseif (strpos($name, 'Uptime') !== false) {
+ } elseif ($pmaString->strpos($name, 'Uptime') !== false) {
$retval .= htmlspecialchars(
PMA_Util::timespanFormat($value)
);
diff --git a/libraries/server_user_groups.lib.php b/libraries/server_user_groups.lib.php
index 2e3f9fc8bc..ede1708c67 100644
--- a/libraries/server_user_groups.lib.php
+++ b/libraries/server_user_groups.lib.php
@@ -249,15 +249,20 @@ function PMA_getHtmlToEditUserGroup($userGroup = null)
. " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "'";
$result = PMA_queryAsControlUser($sql_query, false);
if ($result) {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
$key = $row['tab'];
$value = $row['allowed'];
- if (substr($key, 0, 7) == 'server_' && $value == 'Y') {
- $allowedTabs['server'][] = substr($key, 7);
- } elseif (substr($key, 0, 3) == 'db_' && $value == 'Y') {
- $allowedTabs['db'][] = substr($key, 3);
- } elseif (substr($key, 0, 6) == 'table_' && $value == 'Y') {
- $allowedTabs['table'][] = substr($key, 6);
+ if ($pmaString->substr($key, 0, 7) == 'server_' && $value == 'Y') {
+ $allowedTabs['server'][] = $pmaString->substr($key, 7);
+ } elseif ($pmaString->substr($key, 0, 3) == 'db_' && $value == 'Y') {
+ $allowedTabs['db'][] = $pmaString->substr($key, 3);
+ } elseif ($pmaString->substr($key, 0, 6) == 'table_'
+ && $value == 'Y'
+ ) {
+ $allowedTabs['table'][] = $pmaString->substr($key, 6);
}
}
}
diff --git a/libraries/server_variables.lib.php b/libraries/server_variables.lib.php
index f2de458513..e516942d03 100644
--- a/libraries/server_variables.lib.php
+++ b/libraries/server_variables.lib.php
@@ -78,7 +78,7 @@ function PMA_getAjaxReturnForSetVal($variable_doc_links)
);
$value = floatval($matches[1]) * PMA_Util::pow(
1024,
- $exp[strtolower($matches[3])]
+ $exp[$GLOBALS['PMA_String']->strtolower($matches[3])]
);
} else {
$value = PMA_Util::sqlAddSlashes($value);
diff --git a/libraries/sql.lib.php b/libraries/sql.lib.php
index 044b656837..15631af50e 100644
--- a/libraries/sql.lib.php
+++ b/libraries/sql.lib.php
@@ -22,7 +22,8 @@ function PMA_getNewDatabase($sql, $databases)
$db = '';
// loop through all the databases
foreach ($databases as $database) {
- if (strpos($sql, $database['SCHEMA_NAME']) !== false) {
+ if ($GLOBALS['PMA_String']->strpos($sql, $database['SCHEMA_NAME']) !== false
+ ) {
$db = $database['SCHEMA_NAME'];
break;
}
@@ -46,7 +47,7 @@ function PMA_getTableNameBySQL($sql, $tables)
// loop through all the tables in the database
foreach ($tables as $tbl) {
- if (strpos($sql, $tbl)) {
+ if ($GLOBALS['PMA_String']->strpos($sql, $tbl)) {
$table .= ' ' . $tbl;
}
}
@@ -111,7 +112,10 @@ function PMA_getTableHtmlForMultipleQueries(
// Initialize needed params related to each query in multiquery statement
if (isset($sql_data['valid_sql'][$sql_no])) {
// 'Use' query can change the database
- if (stripos($sql_data['valid_sql'][$sql_no], "use ")) {
+ if ($GLOBALS['PMA_String']->stripos(
+ $sql_data['valid_sql'][$sql_no],
+ "use "
+ )) {
$db = PMA_getNewDatabase(
$sql_data['valid_sql'][$sql_no],
$databases_array
@@ -290,7 +294,7 @@ function PMA_getColumnNameInColumnDropSql($sql)
$tmpArray1 = explode('DROP', $sql);
$str_to_check = trim($tmpArray1[1]);
- if (stripos($str_to_check, 'COLUMN') !== false) {
+ if ($GLOBALS['PMA_String']->stripos($str_to_check, 'COLUMN') !== false) {
$tmpArray2 = explode('COLUMN', $str_to_check);
$str_to_check = trim($tmpArray2[1]);
}
@@ -1374,7 +1378,7 @@ function PMA_hasCurrentDbChanged($db)
// Checks if the current database has changed
// This could happen if the user sends a query like "USE `database`;"
$reload = 0;
- if (strlen($db)) {
+ if ($GLOBALS['PMA_String']->strlen($db)) {
$current_db = $GLOBALS['dbi']->fetchValue('SELECT DATABASE()');
// $current_db is false, except when a USE statement was sent
if ($current_db != false && $db !== $current_db) {
@@ -1400,18 +1404,21 @@ function PMA_cleanupRelations($db, $table, $dropped_column, $purge, $extra_data)
{
include_once 'libraries/relation_cleanup.lib.php';
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
if (isset($purge) && $purge == 1) {
- if (strlen($table) && strlen($db)) {
+ if ($pmaString->strlen($table) && $pmaString->strlen($db)) {
PMA_relationsCleanupTable($db, $table);
- } elseif (strlen($db)) {
+ } elseif ($pmaString->strlen($db)) {
PMA_relationsCleanupDatabase($db);
}
}
if (isset($dropped_column)
&& !empty($dropped_column)
- && strlen($db)
- && strlen($table)
+ && $pmaString->strlen($db)
+ && $pmaString->strlen($table)
) {
PMA_relationsCleanupColumn($db, $table, $dropped_column);
// to refresh the list of indexes (Ajax mode)
@@ -1646,7 +1653,11 @@ function PMA_deleteTransformationInfo($db, $table, $analyzed_sql)
{
include_once 'libraries/transformations.lib.php';
if ($analyzed_sql[0]['querytype'] == 'ALTER') {
- if (stripos($analyzed_sql[0]['unsorted_query'], 'DROP') !== false) {
+ if ($GLOBALS['PMA_String']->stripos(
+ $analyzed_sql[0]['unsorted_query'],
+ 'DROP'
+ ) !== false
+ ) {
$drop_column = PMA_getColumnNameInColumnDropSql(
$analyzed_sql[0]['unsorted_query']
);
diff --git a/libraries/sql_query_form.lib.php b/libraries/sql_query_form.lib.php
index c88cd496e7..2deae3113b 100644
--- a/libraries/sql_query_form.lib.php
+++ b/libraries/sql_query_form.lib.php
@@ -57,13 +57,16 @@ function PMA_getHtmlForSqlQueryForm(
$enctype = '';
}
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$table = '';
$db = '';
- if (! strlen($GLOBALS['db'])) {
+ if (! $pmaString->strlen($GLOBALS['db'])) {
// prepare for server related
$goto = empty($GLOBALS['goto']) ?
'server_sql.php' : $GLOBALS['goto'];
- } elseif (! strlen($GLOBALS['table'])) {
+ } elseif (! $pmaString->strlen($GLOBALS['table'])) {
// prepare for db related
$db = $GLOBALS['db'];
$goto = empty($GLOBALS['goto']) ?
@@ -146,10 +149,13 @@ function PMA_getHtmlForSqlQueryFormInsert(
$locking = '';
$height = $GLOBALS['cfg']['TextareaRows'] * 2;
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$table = '';
$db = '';
$fields_list = array();
- if (! strlen($GLOBALS['db'])) {
+ if (! $pmaString->strlen($GLOBALS['db'])) {
// prepare for server related
$legend = sprintf(
__('Run SQL query/queries on server %s'),
@@ -159,7 +165,7 @@ function PMA_getHtmlForSqlQueryFormInsert(
: $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host']
) . '&quot;'
);
- } elseif (! strlen($GLOBALS['table'])) {
+ } elseif (! $pmaString->strlen($GLOBALS['table'])) {
// prepare for db related
$db = $GLOBALS['db'];
// if you want navigation:
@@ -247,7 +253,7 @@ function PMA_getHtmlForSqlQueryFormInsert(
$html .= '<option value="'
. PMA_Util::backquote(htmlspecialchars($field['Field'])) . '"';
if (isset($field['Field'])
- && strlen($field['Field'])
+ && $pmaString->strlen($field['Field'])
&& isset($field['Comment'])
) {
$html .= ' title="' . htmlspecialchars($field['Comment']) . '"';
diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php
index a4ec7ef091..9ad283ed1c 100644
--- a/libraries/sqlparser.lib.php
+++ b/libraries/sqlparser.lib.php
@@ -220,11 +220,14 @@ function PMA_SQP_parse($sql)
static $PMA_SQPdata_function_name, $PMA_SQPdata_forbidden_word;
global $mysql_charsets, $mysql_collations_flat;
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
// Convert all line feeds to Unix style
$sql = str_replace("\r\n", "\n", $sql);
$sql = str_replace("\r", "\n", $sql);
- $len = $GLOBALS['PMA_String']->strlen($sql);
+ $len = $pmaString->strlen($sql);
if ($len == 0) {
return array();
}
@@ -285,7 +288,7 @@ function PMA_SQP_parse($sql)
$this_was_quote = false;
while ($count2 < $len) {
- $c = $GLOBALS['PMA_String']->substr($sql, $count2, 1);
+ $c = $pmaString->substr($sql, $count2, 1);
$count1 = $count2;
$previous_was_space = $this_was_space;
@@ -307,7 +310,7 @@ function PMA_SQP_parse($sql)
}
// Checks for white space
- if ($GLOBALS['PMA_String']->isSpace($c)) {
+ if ($pmaString->isSpace($c)) {
$this_was_space = true;
$count2++;
continue;
@@ -317,12 +320,12 @@ function PMA_SQP_parse($sql)
// MySQL style #
// C style /* */
// ANSI style --
- $next_c = $GLOBALS['PMA_String']->substr($sql, $count2 + 1, 1);
+ $next_c = $pmaString->substr($sql, $count2 + 1, 1);
if (($c == '#')
|| (($count2 + 1 < $len) && ($c == '/') && ($next_c == '*'))
|| (($count2 + 2 == $len) && ($c == '-') && ($next_c == '-'))
|| (($count2 + 2 < $len) && ($c == '-') && ($next_c == '-')
- && (($GLOBALS['PMA_String']->substr($sql, $count2 + 2, 1) <= ' ')))
+ && (($pmaString->substr($sql, $count2 + 2, 1) <= ' ')))
) {
$count2++;
$pos = 0;
@@ -330,22 +333,22 @@ function PMA_SQP_parse($sql)
switch ($c) {
case '#':
$type = 'mysql';
- $pos = $GLOBALS['PMA_String']->strpos($sql, "\n", $count2);
+ $pos = $pmaString->strpos($sql, "\n", $count2);
break;
case '-':
$type = 'ansi';
- $pos = $GLOBALS['PMA_String']->strpos($sql, "\n", $count2);
+ $pos = $pmaString->strpos($sql, "\n", $count2);
break;
case '/':
$type = 'c';
- $pos = $GLOBALS['PMA_String']->strpos($sql, '*/', $count2);
+ $pos = $pmaString->strpos($sql, '*/', $count2);
$pos += 2;
break;
default:
break;
} // end switch
$count2 = ($pos < $count2) ? $len : $pos;
- $str = $GLOBALS['PMA_String']->substr(
+ $str = $pmaString->substr(
$sql, $count1, $count2 - $count1
);
PMA_SQP_arrayAdd(
@@ -355,14 +358,14 @@ function PMA_SQP_parse($sql)
} // end if
// Checks for something inside quotation marks
- if ($GLOBALS['PMA_String']->strpos($quote_list, $c) !== false) {
+ if ($pmaString->strpos($quote_list, $c) !== false) {
$startquotepos = $count2;
$quotetype = $c;
$count2++;
$pos = $count2;
do {
$oldpos = $pos;
- $pos = $GLOBALS['PMA_String']->strpos(
+ $pos = $pmaString->strpos(
' ' . $sql, $quotetype, $oldpos + 1
) - 1;
// ($pos === false)
@@ -379,7 +382,7 @@ function PMA_SQP_parse($sql)
*
* SELECT * FROM `table`
*/
- $pos_quote_separator = $GLOBALS['PMA_String']->strpos(
+ $pos_quote_separator = $pmaString->strpos(
' ' . $sql, $GLOBALS['sql_delimiter'], $oldpos + 1
) - 1;
if ($pos_quote_separator < 0) {
@@ -389,9 +392,9 @@ function PMA_SQP_parse($sql)
$pos = $len;
} else {
$len += 1;
- $sql = $GLOBALS['PMA_String']->substr(
+ $sql = $pmaString->substr(
$sql, 0, $pos_quote_separator
- ) . '`' . $GLOBALS['PMA_String']->substr(
+ ) . '`' . $pmaString->substr(
$sql, $pos_quote_separator
);
$sql_array['raw'] = $sql;
@@ -422,16 +425,14 @@ function PMA_SQP_parse($sql)
// Checks for MySQL escaping using a \
// And checks for ANSI escaping using the $quotetype character
if (($pos < $len)
- && $GLOBALS['PMA_String']->charIsEscaped($sql, $pos)
+ && $pmaString->charIsEscaped($sql, $pos)
&& $c != '`'
) {
$pos ++;
continue;
} elseif (($pos + 1 < $len)
- && ($GLOBALS['PMA_String']->substr($sql, $pos, 1) == $quotetype)
- && ($GLOBALS['PMA_String']->substr(
- $sql, $pos + 1, 1
- ) == $quotetype)
+ && ($pmaString->substr($sql, $pos, 1) == $quotetype)
+ && ($pmaString->substr($sql, $pos + 1, 1) == $quotetype)
) {
$pos = $pos + 2;
continue;
@@ -459,25 +460,25 @@ function PMA_SQP_parse($sql)
default:
break;
} // end switch
- $data = $GLOBALS['PMA_String']->substr($sql, $count1, $count2 - $count1);
+ $data = $pmaString->substr($sql, $count1, $count2 - $count1);
PMA_SQP_arrayAdd($sql_array, $type, $data, $arraysize, $count2);
continue;
}
// Checks for brackets
- if ($GLOBALS['PMA_String']->strpos($bracket_list, $c) !== false) {
+ if ($pmaString->strpos($bracket_list, $c) !== false) {
// All bracket tokens are only one item long
$this_was_bracket = true;
$count2++;
- if ($GLOBALS['PMA_String']->strpos('([{', $c) !== false) {
+ if ($pmaString->strpos('([{', $c) !== false) {
$type_type = 'open';
} else {
$type_type = 'close';
}
- if ($GLOBALS['PMA_String']->strpos('()', $c) !== false) {
+ if ($pmaString->strpos('()', $c) !== false) {
$type_style = 'round';
- } elseif ($GLOBALS['PMA_String']->strpos('[]', $c) !== false) {
+ } elseif ($pmaString->strpos('[]', $c) !== false) {
$type_style = 'square';
} else {
$type_style = 'curly';
@@ -490,12 +491,12 @@ function PMA_SQP_parse($sql)
/* DEBUG
echo '<pre>1';
- var_dump($GLOBALS['PMA_String']->isSqlIdentifier($c, false));
+ var_dump($pmaString->isSqlIdentifier($c, false));
var_dump($c == '@');
var_dump($c == '.');
var_dump(
- $GLOBALS['PMA_String']->isDigit(
- $GLOBALS['PMA_String']->substr($sql, $count2 + 1, 1)
+ $pmaString->isDigit(
+ $pmaString->substr($sql, $count2 + 1, 1)
)
);
var_dump($previous_was_space);
@@ -505,16 +506,15 @@ function PMA_SQP_parse($sql)
*/
// Checks for identifier (alpha or numeric)
- if ($GLOBALS['PMA_String']->isSqlIdentifier($c, false)
+ if ($pmaString->isSqlIdentifier($c, false)
|| $c == '@'
|| ($c == '.'
- && $GLOBALS['PMA_String']->isDigit(
- $GLOBALS['PMA_String']->substr($sql, $count2 + 1, 1)
- ) && ($previous_was_space || $previous_was_bracket
+ && $pmaString->isDigit($pmaString->substr($sql, $count2 + 1, 1))
+ && ($previous_was_space || $previous_was_bracket
|| $previous_was_listsep))
) {
/* DEBUG
- echo $GLOBALS['PMA_String']->substr($sql, $count2);
+ echo $pmaString->substr($sql, $count2);
echo '<hr />';
*/
@@ -531,13 +531,13 @@ function PMA_SQP_parse($sql)
$is_digit = (
!$is_identifier
&& !$is_sql_variable
- && $GLOBALS['PMA_String']->isDigit($c)
+ && $pmaString->isDigit($c)
);
$is_hex_digit = (
$is_digit
&& $c == '0'
&& $count2 < $len
- && $GLOBALS['PMA_String']->substr($sql, $count2, 1) == 'x'
+ && $pmaString->substr($sql, $count2, 1) == 'x'
);
$is_float_digit = $c == '.';
$is_float_digit_exponent = false;
@@ -568,12 +568,12 @@ function PMA_SQP_parse($sql)
}
while (($count2 < $len)
- && $GLOBALS['PMA_String']->isSqlIdentifier(
- $GLOBALS['PMA_String']->substr($sql, $count2, 1),
+ && $pmaString->isSqlIdentifier(
+ $pmaString->substr($sql, $count2, 1),
($is_sql_variable || $is_digit)
)
) {
- $c2 = $GLOBALS['PMA_String']->substr($sql, $count2, 1);
+ $c2 = $pmaString->substr($sql, $count2, 1);
if ($is_sql_variable && ($c2 == '.')) {
$count2++;
continue;
@@ -587,7 +587,7 @@ function PMA_SQP_parse($sql)
$debugstr = __('Invalid Identifer')
. ' @ ' . ($count1+1) . "\n"
. 'STR: ' . htmlspecialchars(
- $GLOBALS['PMA_String']->substr(
+ $pmaString->substr(
$sql, $count1, $count2 - $count1
)
);
@@ -609,8 +609,8 @@ function PMA_SQP_parse($sql)
$is_float_digit = false;
}
}
- if (($is_hex_digit && $GLOBALS['PMA_String']->isHexDigit($c2))
- || ($is_digit && $GLOBALS['PMA_String']->isDigit($c2))
+ if (($is_hex_digit && $pmaString->isHexDigit($c2))
+ || ($is_digit && $pmaString->isDigit($c2))
) {
$count2++;
continue;
@@ -623,7 +623,7 @@ function PMA_SQP_parse($sql)
} // end while
$l = $count2 - $count1;
- $str = $GLOBALS['PMA_String']->substr($sql, $count1, $l);
+ $str = $pmaString->substr($sql, $count1, $l);
if ($is_digit || $is_float_digit || $is_hex_digit) {
$type = 'digit';
@@ -647,10 +647,10 @@ function PMA_SQP_parse($sql)
}
// Checks for punct
- if ($GLOBALS['PMA_String']->strpos($allpunct_list, $c) !== false) {
+ if ($pmaString->strpos($allpunct_list, $c) !== false) {
while (($count2 < $len)
- && $GLOBALS['PMA_String']->strpos(
- $allpunct_list, $GLOBALS['PMA_String']->substr(
+ && $pmaString->strpos(
+ $allpunct_list, $pmaString->substr(
$sql, $count2, 1
)
) !== false
@@ -661,7 +661,7 @@ function PMA_SQP_parse($sql)
if ($l == 1) {
$punct_data = $c;
} else {
- $punct_data = $GLOBALS['PMA_String']->substr($sql, $count1, $l);
+ $punct_data = $pmaString->substr($sql, $count1, $l);
}
// Special case, sometimes, although two characters are
@@ -713,15 +713,15 @@ function PMA_SQP_parse($sql)
} elseif (($last2 == '/*')
|| (($last2 == '--')
&& ($count2 == $len
- || $GLOBALS['PMA_String']->substr($sql, $count2, 1) <= ' '))
+ || $pmaString->substr($sql, $count2, 1) <= ' '))
) {
$count2 -= 2;
- $punct_data = $GLOBALS['PMA_String']->substr(
+ $punct_data = $pmaString->substr(
$sql, $count1, $count2 - $count1
);
} elseif (($last == '-') || ($last == '+') || ($last == '!')) {
$count2--;
- $punct_data = $GLOBALS['PMA_String']->substr(
+ $punct_data = $pmaString->substr(
$sql, $count1, $count2 - $count1
);
} elseif ($last != '~') {
@@ -748,7 +748,7 @@ function PMA_SQP_parse($sql)
$count2++;
$debugstr = 'C1 C2 LEN: ' . $count1 . ' ' . $count2 . ' ' . $len . "\n"
- . 'STR: ' . $GLOBALS['PMA_String']->substr(
+ . 'STR: ' . $pmaString->substr(
$sql, $count1, $count2 - $count1
) . "\n";
PMA_SQP_bug($debugstr, $sql);
@@ -771,7 +771,9 @@ function PMA_SQP_parse($sql)
$d_prev = '';
$d_bef_prev = '';
$d_cur = '';
- $d_next_upper = $t_next == 'alpha' ? strtoupper($d_next) : $d_next;
+ $d_next_upper = $t_next == 'alpha'
+ ? $pmaString->strtoupper($d_next)
+ : $d_next;
$d_prev_upper = '';
$d_bef_prev_upper = '';
$d_cur_upper = '';
@@ -790,7 +792,8 @@ function PMA_SQP_parse($sql)
if (($i + 1) < $arraysize) {
$t_next = $sql_array[$i + 1]['type'];
$d_next = $sql_array[$i + 1]['data'];
- $d_next_upper = $t_next == 'alpha' ? strtoupper($d_next) : $d_next;
+ $d_next_upper =
+ $t_next == 'alpha' ? $pmaString->strtoupper($d_next) : $d_next;
} else {
$t_next = '';
$d_next = '';
@@ -886,7 +889,8 @@ function PMA_SQP_parse($sql)
}
} elseif (in_array($d_cur, $mysql_charsets)
|| in_array($d_cur, $mysql_collations_flat)
- || ($d_cur{0} == '_' && in_array(substr($d_cur, 1), $mysql_charsets))
+ || ($d_cur{0} == '_'
+ && in_array($pmaString->substr($d_cur, 1), $mysql_charsets))
) {
$t_suffix = '_charset';
} else {
@@ -928,16 +932,19 @@ function PMA_SQP_typeCheck($toCheck, $whatWeWant)
$typeSeparator = '_';
if (strcmp($whatWeWant, $toCheck) == 0) {
return true;
- } else {
- if (strpos($whatWeWant, $typeSeparator) === false) {
- return strncmp(
- $whatWeWant, $toCheck,
- strpos($toCheck, $typeSeparator)
- ) == 0;
- } else {
- return false;
- }
}
+
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
+ if ($pmaString->strpos($whatWeWant, $typeSeparator) !== false) {
+ return false;
+ }
+
+ return strncmp(
+ $whatWeWant, $toCheck,
+ $pmaString->strpos($toCheck, $typeSeparator)
+ ) == 0;
}
@@ -1170,6 +1177,9 @@ function PMA_SQP_analyze($arr)
*/
);
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
// loop #1 for each token: select_expr, table_ref for SELECT
for ($i = 0; $i < $size; $i++) {
@@ -1239,7 +1249,7 @@ function PMA_SQP_analyze($arr)
}
// ==============================================================
if ($arr[$i]['type'] == 'alpha_functionName') {
- $upper_data = strtoupper($arr[$i]['data']);
+ $upper_data = $pmaString->strtoupper($arr[$i]['data']);
if ($upper_data =='EXTRACT') {
$in_extract = true;
$number_of_brackets_in_extract = 0;
@@ -1254,7 +1264,7 @@ function PMA_SQP_analyze($arr)
if ($arr[$i]['type'] == 'alpha_reservedWord') {
// We don't know what type of query yet, so run this
if ($subresult['querytype'] == '') {
- $subresult['querytype'] = strtoupper($arr[$i]['data']);
+ $subresult['querytype'] = $pmaString->strtoupper($arr[$i]['data']);
} // end if (querytype was empty)
// Check if we support this type of query
@@ -1265,7 +1275,7 @@ function PMA_SQP_analyze($arr)
} // end if (query not supported)
// upper once
- $upper_data = strtoupper($arr[$i]['data']);
+ $upper_data = $pmaString->strtoupper($arr[$i]['data']);
/**
* @todo reset for each query?
*/
@@ -1399,7 +1409,9 @@ function PMA_SQP_analyze($arr)
'column' => ''
);
- if (isset($alias_for_select_expr) && strlen($alias_for_select_expr)) {
+ if (isset($alias_for_select_expr)
+ && $pmaString->strlen($alias_for_select_expr)
+ ) {
// we had found an alias for this select expression
$subresult['select_expr'][$current_select_expr]['alias']
= $alias_for_select_expr;
@@ -1472,7 +1484,9 @@ function PMA_SQP_analyze($arr)
'table_alias' => '',
'table_true_name' => ''
);
- if (isset($alias_for_table_ref) && strlen($alias_for_table_ref)) {
+ if (isset($alias_for_table_ref)
+ && $pmaString->strlen($alias_for_table_ref)
+ ) {
$subresult['table_ref'][$current_table_ref]['table_alias']
= $alias_for_table_ref;
unset($alias_for_table_ref);
@@ -1516,7 +1530,7 @@ function PMA_SQP_analyze($arr)
$truename = $subresult['table_ref'][$tr]['table_true_name'];
for ($se=0; $se <= $current_select_expr; $se++) {
if (isset($alias)
- && strlen($alias)
+ && $pmaString->strlen($alias)
&& $subresult['select_expr'][$se]['table_true_name'] == $alias
) {
$subresult['select_expr'][$se]['table_true_name']
@@ -1671,7 +1685,7 @@ function PMA_SQP_analyze($arr)
}
if ($arr[$i]['type'] == 'alpha_reservedWord') {
- $upper_data = strtoupper($arr[$i]['data']);
+ $upper_data = $pmaString->strtoupper($arr[$i]['data']);
if ($upper_data == 'SELECT' && $number_of_brackets > 0) {
$in_subquery = true;
@@ -1727,7 +1741,9 @@ function PMA_SQP_analyze($arr)
}
if ($upper_data == 'LIMIT' && ! $in_subquery) {
- $section_before_limit = substr($arr['raw'], 0, $arr[$i]['pos'] - 5);
+ $section_before_limit = $pmaString->substr(
+ $arr['raw'], 0, $arr[$i]['pos'] - 5
+ );
$in_limit = true;
$seen_limit = true;
$limit_clause = '';
@@ -1744,7 +1760,7 @@ function PMA_SQP_analyze($arr)
&& $subresult['queryflags']['select_from'] == 1
&& ($i + 1) < $size
&& $arr[$i + 1]['type'] == 'alpha_reservedWord'
- && strtoupper($arr[$i + 1]['data']) == 'ANALYSE'
+ && $pmaString->strtoupper($arr[$i + 1]['data']) == 'ANALYSE'
) {
$subresult['queryflags']['is_analyse'] = 1;
}
@@ -1756,7 +1772,7 @@ function PMA_SQP_analyze($arr)
&& $subresult['queryflags']['select_from'] == 1
&& ($i + 1) < $size
&& $arr[$i + 1]['type'] == 'alpha_reservedWord'
- && strtoupper($arr[$i + 1]['data']) == 'OUTFILE'
+ && $pmaString->strtoupper($arr[$i + 1]['data']) == 'OUTFILE'
) {
$subresult['queryflags']['is_export'] = 1;
}
@@ -1773,7 +1789,7 @@ function PMA_SQP_analyze($arr)
&& !isset($subresult['queryflags']['is_group'])
&& ($i + 1) < $size
&& $arr[$i + 1]['type'] == 'alpha_functionName'
- && strtoupper($arr[$i + 1]['data']) == 'COUNT'
+ && $pmaString->strtoupper($arr[$i + 1]['data']) == 'COUNT'
) {
$subresult['queryflags']['is_count'] = 1;
}
@@ -1830,10 +1846,13 @@ function PMA_SQP_analyze($arr)
&& $subresult['queryflags']['select_from'] == 1
&& ($i + 1) < $size
&& $arr[$i + 1]['type'] == 'alpha_reservedWord'
- && in_array(strtoupper($arr[$i + 1]['data']), $arrayKeyWords)
+ && in_array(
+ $pmaString->strtoupper($arr[$i + 1]['data']),
+ $arrayKeyWords
+ )
&& ($i + 2) < $size
&& $arr[$i + 2]['type'] == 'alpha_reservedWord'
- && strtoupper($arr[$i + 2]['data']) == 'DISTINCT'
+ && $pmaString->strtoupper($arr[$i + 2]['data']) == 'DISTINCT'
) {
$subresult['queryflags']['is_group'] = 1;
}
@@ -1913,7 +1932,7 @@ function PMA_SQP_analyze($arr)
$sep = ' ';
if ($arr[$i]['type'] == 'alpha_functionName') {
$sep='';
- $upper_data = strtoupper($arr[$i]['data']);
+ $upper_data = $pmaString->strtoupper($arr[$i]['data']);
if ($upper_data =='GROUP_CONCAT') {
$in_group_concat = true;
$number_of_brackets_in_group_concat = 0;
@@ -1950,10 +1969,13 @@ function PMA_SQP_analyze($arr)
// for the presence of INSERT|LOAD DATA
if ($arr[$i]['type'] == 'alpha_identifier'
- && strtoupper($arr[$i]['data']) == 'DATA'
+ && $pmaString->strtoupper($arr[$i]['data']) == 'DATA'
&& ($i - 1) >= 0
&& $arr[$i - 1]['type'] == 'alpha_reservedWord'
- && in_array(strtoupper($arr[$i - 1]['data']), array("INSERT", "LOAD"))
+ && in_array(
+ $pmaString->strtoupper($arr[$i - 1]['data']),
+ array("INSERT", "LOAD")
+ )
) {
$subresult['queryflags']['is_insert'] = 1;
$subresult['queryflags']['is_affected'] = 1;
@@ -1961,7 +1983,7 @@ function PMA_SQP_analyze($arr)
// for the presence of SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND
if ($arr[$i]['type'] == 'alpha_functionName'
- && in_array(strtoupper($arr[$i]['data']), $arrayFunctions)
+ && in_array($pmaString->strtoupper($arr[$i]['data']), $arrayFunctions)
&& isset($subresult['queryflags']['select_from'])
&& $subresult['queryflags']['select_from'] == 1
&& !isset($subresult['queryflags']['is_group'])
@@ -2064,7 +2086,7 @@ function PMA_SQP_analyze($arr)
for ($i = 0; $i < $size; $i++) {
if ($arr[$i]['type'] == 'alpha_reservedWord') {
- $upper_data = strtoupper($arr[$i]['data']);
+ $upper_data = $pmaString->strtoupper($arr[$i]['data']);
if ($upper_data == 'NOT' && $in_timestamp_options) {
if (! isset($create_table_fields)) {
@@ -2127,7 +2149,7 @@ function PMA_SQP_analyze($arr)
if (isset($arr[$i+1])
&& $arr[$i+1]['type'] == 'alpha_reservedWord'
) {
- $second_upper_data = strtoupper($arr[$i+1]['data']);
+ $second_upper_data = $pmaString->strtoupper($arr[$i+1]['data']);
if ($second_upper_data == 'DELETE') {
$clause = 'on_delete';
}
@@ -2141,9 +2163,10 @@ function PMA_SQP_analyze($arr)
if (isset($clause)
&& ($arr[$i+2]['type'] == 'alpha_reservedWord'
|| ($arr[$i+2]['type'] == 'alpha_identifier'
- && strtoupper($arr[$i+2]['data'])=='NO'))
+ && $pmaString->strtoupper($arr[$i+2]['data'])=='NO'))
) {
- $third_upper_data = strtoupper($arr[$i+2]['data']);
+ $third_upper_data = $pmaString
+ ->strtoupper($arr[$i+2]['data']);
if ($third_upper_data == 'CASCADE'
|| $third_upper_data == 'RESTRICT'
) {
@@ -2153,7 +2176,7 @@ function PMA_SQP_analyze($arr)
) {
if ($arr[$i+3]['type'] == 'alpha_reservedWord') {
$value = $third_upper_data . '_'
- . strtoupper($arr[$i+3]['data']);
+ . $pmaString->strtoupper($arr[$i+3]['data']);
}
} elseif ($third_upper_data == 'CURRENT_TIMESTAMP') {
if ($clause == 'on_update'
@@ -2197,7 +2220,7 @@ function PMA_SQP_analyze($arr)
}
if (($arr[$i]['type'] == 'alpha_columnAttrib')) {
- $upper_data = strtoupper($arr[$i]['data']);
+ $upper_data = $pmaString->strtoupper($arr[$i]['data']);
if ($seen_create_table && $in_create_table_fields) {
if ($upper_data == 'DEFAULT') {
$seen_default = true;
@@ -2213,7 +2236,7 @@ function PMA_SQP_analyze($arr)
if (($arr[$i]['type'] == 'alpha_columnType')
|| ($arr[$i]['type'] == 'alpha_functionName' && $seen_create_table)
) {
- $upper_data = strtoupper($arr[$i]['data']);
+ $upper_data = $pmaString->strtoupper($arr[$i]['data']);
if ($seen_create_table && $in_create_table_fields
&& isset($current_identifier)
) {
@@ -2429,6 +2452,9 @@ function PMA_SQP_format(
$typearr[3] = $arr[$start_token]['type'];
}
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$in_priv_list = false;
for ($i = $start_token; $i < $number_of_tokens; $i++) {
// DEBUG echo "Loop format <strong>" . $arr[$i]['data']
@@ -2464,10 +2490,14 @@ function PMA_SQP_format(
$bracketlevel++;
$infunction = false;
$keyword_brackets_2before = isset(
- $keywords_with_brackets_2before[strtoupper($arr[$i - 2]['data'])]
+ $keywords_with_brackets_2before[
+ $pmaString->strtoupper($arr[$i - 2]['data'])
+ ]
);
$keyword_brackets_1before = isset(
- $keywords_with_brackets_1before[strtoupper($arr[$i - 1]['data'])]
+ $keywords_with_brackets_1before[
+ $pmaString->strtoupper($arr[$i - 1]['data'])
+ ]
);
// Make sure this array is sorted!
if (($typearr[1] == 'alpha_functionName')
@@ -2599,7 +2629,7 @@ function PMA_SQP_format(
// select * from mysql.user where binary user="root"
// binary is marked as alpha_columnAttrib
// but should be marked as a reserved word
- if (strtoupper($arr[$i]['data']) == 'BINARY'
+ if ($pmaString->strtoupper($arr[$i]['data']) == 'BINARY'
&& $typearr[3] == 'alpha_identifier'
) {
$after .= ' ';
@@ -2615,7 +2645,7 @@ function PMA_SQP_format(
// as an identifier name)
if ($mode != 'query_only') {
- $arr[$i]['data'] = strtoupper($arr[$i]['data']);
+ $arr[$i]['data'] = $pmaString->strtoupper($arr[$i]['data']);
}
list($before, $in_priv_list) = PMA_SQP_format_getBeforeAndInPrivList(
@@ -2731,7 +2761,7 @@ function PMA_SQP_format_getBeforeAndInPrivList(
) {
if (!((($typearr[1] != 'alpha_reservedWord')
|| (($typearr[1] == 'alpha_reservedWord')
- && isset($keywords_no_newline[strtoupper($arr[$index - 1]['data'])])))
+ && isset($keywords_no_newline[$GLOBALS['PMA_String']->strtoupper($arr[$index - 1]['data'])])))
&& ($typearr[1] != 'punct_level_plus')
&& (!isset($keywords_no_newline[$arr[$index]['data']])))
) {
@@ -2893,7 +2923,10 @@ function PMA_SQP_formatNone($arr)
function PMA_SQP_isKeyWord($column)
{
global $PMA_SQPdata_forbidden_word;
- return in_array(strtoupper($column), $PMA_SQPdata_forbidden_word);
+ return in_array(
+ $GLOBALS['PMA_String']->strtoupper($column),
+ $PMA_SQPdata_forbidden_word
+ );
}
/**
diff --git a/libraries/structure.lib.php b/libraries/structure.lib.php
index 7d9268f554..6aa89dd24d 100644
--- a/libraries/structure.lib.php
+++ b/libraries/structure.lib.php
@@ -730,7 +730,7 @@ function PMA_getHtmlForNotNullEngineViewTable($table_is_view, $current_table,
$html_output .= '<td class="nowrap">'
. ($table_is_view ? __('View') : $current_table['ENGINE'])
. '</td>';
- if (strlen($collation)) {
+ if ($GLOBALS['PMA_String']->strlen($collation)) {
$html_output .= '<td class="nowrap">' . $collation . '</td>';
}
}
@@ -1016,40 +1016,52 @@ function PMA_getServerSlaveStatus($server_slave_status, $truename)
$ignored = false;
$do = false;
include_once 'libraries/replication.inc.php';
- if ($server_slave_status) {
- $nbServerSlaveDoDb = count($server_slave_Do_DB);
- $nbServerSlaveIgnoreDb = count($server_slave_Ignore_DB);
- if ((strlen(array_search($truename, $server_slave_Do_Table)) > 0)
- || (strlen(array_search($GLOBALS['db'], $server_slave_Do_DB)) > 0)
- || ($nbServerSlaveDoDb == 1 && $nbServerSlaveIgnoreDb == 1)
+
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
+ if (!$server_slave_status) {
+ return array($do, $ignored);
+ }
+
+ $nbServerSlaveDoDb = count($server_slave_Do_DB);
+ $nbServerSlaveIgnoreDb = count($server_slave_Ignore_DB);
+ if (($pmaString->strlen(array_search($truename, $server_slave_Do_Table)) > 0)
+ || $pmaString->strlen(array_search($GLOBALS['db'], $server_slave_Do_DB)) > 0
+ || ($nbServerSlaveDoDb == 1 && $nbServerSlaveIgnoreDb == 1)
+ ) {
+ $do = true;
+ }
+ foreach ($server_slave_Wild_Do_Table as $db_table) {
+ $table_part = PMA_extractDbOrTable($db_table, 'table');
+ $pattern = "@^"
+ . $pmaString->substr($table_part, 0, $pmaString->strlen($table_part) - 1)
+ . "@";
+ if (($GLOBALS['db'] == PMA_extractDbOrTable($db_table, 'db'))
+ && (preg_match($pattern, $truename))
) {
$do = true;
}
- foreach ($server_slave_Wild_Do_Table as $db_table) {
- $table_part = PMA_extractDbOrTable($db_table, 'table');
- $pattern = "@^" . substr($table_part, 0, strlen($table_part) - 1) . "@";
- if (($GLOBALS['db'] == PMA_extractDbOrTable($db_table, 'db'))
- && (preg_match($pattern, $truename))
- ) {
- $do = true;
- }
- }
+ }
- if ((strlen(array_search($truename, $server_slave_Ignore_Table)) > 0)
- || (strlen(array_search($GLOBALS['db'], $server_slave_Ignore_DB)) > 0)
+ $search = array_search($GLOBALS['db'], $server_slave_Ignore_DB);
+ if (($pmaString->strlen(array_search($truename, $server_slave_Ignore_Table)) > 0)
+ || $pmaString->strlen($search) > 0
+ ) {
+ $ignored = true;
+ }
+ foreach ($server_slave_Wild_Ignore_Table as $db_table) {
+ $table_part = PMA_extractDbOrTable($db_table, 'table');
+ $pattern = "@^"
+ . $pmaString->substr($table_part, 0, $pmaString->strlen($table_part) - 1)
+ . "@";
+ if (($db == PMA_extractDbOrTable($db_table))
+ && (preg_match($pattern, $truename))
) {
$ignored = true;
}
- foreach ($server_slave_Wild_Ignore_Table as $db_table) {
- $table_part = PMA_extractDbOrTable($db_table, 'table');
- $pattern = "@^" . substr($table_part, 0, strlen($table_part) - 1) . "@";
- if (($db == PMA_extractDbOrTable($db_table))
- && (preg_match($pattern, $truename))
- ) {
- $ignored = true;
- }
- }
}
+
return array($do, $ignored);
}
@@ -1353,7 +1365,8 @@ function PMA_getHtmlTableStructureRow($row, $rownum,
}
$html_output .= '</td>';
- $html_output .= '<td class="nowrap">' . strtoupper($row['Extra']) . '</td>';
+ $html_output .= '<td class="nowrap">'
+ . $GLOBALS['PMA_String']->strtoupper($row['Extra']) . '</td>';
$html_output .= PMA_getHtmlForDropColumn(
$tbl_is_view, $db_is_system_schema,
@@ -1954,13 +1967,17 @@ function PMA_getHtmlForActionRowInStructureTable($type, $tbl_storage_engine,
function PMA_getHtmlForFullTextAction($tbl_storage_engine, $type, $url_query,
$row, $titles
) {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$html_output = '<li class="fulltext nowrap">';
if (! empty($tbl_storage_engine)
&& ($tbl_storage_engine == 'MYISAM'
|| $tbl_storage_engine == 'ARIA'
|| $tbl_storage_engine == 'MARIA'
|| ($tbl_storage_engine == 'INNODB' && PMA_MYSQL_INT_VERSION >= 50604))
- && (strpos($type, 'text') !== false || strpos($type, 'char') !== false)
+ && ($pmaString->strpos($type, 'text') !== false
+ || $pmaString->strpos($type, 'char') !== false)
) {
$html_output .= '<a rel="samepage" href="sql.php?' . $url_query
. '&amp;sql_query='
@@ -2562,7 +2579,9 @@ function PMA_updateColumns($db, $table)
) {
foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
if (isset($_REQUEST['field_name'][$fieldindex])
- && strlen($_REQUEST['field_name'][$fieldindex])
+ && $GLOBALS['PMA_String']->strlen(
+ $_REQUEST['field_name'][$fieldindex]
+ )
) {
PMA_setMIME(
$db, $table, $_REQUEST['field_name'][$fieldindex],
@@ -2633,7 +2652,7 @@ function PMA_moveColumns($db, $table)
$changes[] = 'CHANGE ' . PMA_Table::generateAlter(
$column,
$column,
- strtoupper($extracted_columnspec['type']),
+ $GLOBALS['PMA_String']->strtoupper($extracted_columnspec['type']),
$extracted_columnspec['spec_in_brackets'],
$extracted_columnspec['attribute'],
isset($data['Collation']) ? $data['Collation'] : '',
diff --git a/libraries/sysinfo.lib.php b/libraries/sysinfo.lib.php
index ec7a35df47..2ff9caeead 100644
--- a/libraries/sysinfo.lib.php
+++ b/libraries/sysinfo.lib.php
@@ -235,8 +235,14 @@ class PMA_SysInfoLinux extends PMA_SysInfo
*/
function loadavg()
{
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$buf = file_get_contents('/proc/stat');
- $nums = preg_split("/\s+/", substr($buf, 0, strpos($buf, "\n")));
+ $nums = preg_split(
+ "/\s+/",
+ $pmaString->substr($buf, 0, $pmaString->strpos($buf, "\n"))
+ );
return Array(
'busy' => $nums[1] + $nums[2] + $nums[3],
'idle' => intval($nums[4])
diff --git a/libraries/tbl_columns_definition_form.inc.php b/libraries/tbl_columns_definition_form.inc.php
index 8a9d660bb6..c83215a156 100644
--- a/libraries/tbl_columns_definition_form.inc.php
+++ b/libraries/tbl_columns_definition_form.inc.php
@@ -124,9 +124,9 @@ for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
// some types, for example longtext, are reported as
// "longtext character set latin7" when their charset and / or collation
// differs from the ones of the corresponding database.
- $tmp = strpos($type, 'character set');
+ $tmp = $pmaString->strpos($type, 'character set');
if ($tmp) {
- $type = substr($type, 0, $tmp - 1);
+ $type = $pmaString->substr($type, 0, $tmp - 1);
}
// rtrim the type, for cases like "float unsigned"
$type = rtrim($type);
@@ -154,7 +154,7 @@ for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
$content_cells[$columnNumber] = PMA_getHtmlForColumnAttributes(
$columnNumber, isset($columnMeta) ? $columnMeta : array(),
- strtoupper($type), $length_values_input_size, $length,
+ $pmaString->strtoupper($type), $length_values_input_size, $length,
isset($default_current_timestamp) ? $default_current_timestamp : null,
isset($extracted_columnspec) ? $extracted_columnspec : null,
isset($submit_attribute) ? $submit_attribute : null,
diff --git a/libraries/tbl_columns_definition_form.lib.php b/libraries/tbl_columns_definition_form.lib.php
index 78b5c9a33c..5b4c796283 100644
--- a/libraries/tbl_columns_definition_form.lib.php
+++ b/libraries/tbl_columns_definition_form.lib.php
@@ -868,7 +868,7 @@ function PMA_getHtmlForColumnAutoIncrement($columnNumber, $ci, $ci_offset,
$html = '<input name="field_extra[' . $columnNumber . ']"'
. ' id="field_' . $columnNumber . '_' . ($ci - $ci_offset) . '"';
if (isset($columnMeta['Extra'])
- && strtolower($columnMeta['Extra']) == 'auto_increment'
+ && $GLOBALS['PMA_String']->strtolower($columnMeta['Extra']) == 'auto_increment'
) {
$html .= ' checked="checked"';
}
@@ -928,13 +928,15 @@ function PMA_getHtmlForColumnIndexes($columnNumber, $ci, $ci_offset, $columnMeta
function PMA_getHtmlForIndexTypeOption($columnNumber, $columnMeta, $type, $key)
{
- $html = '<option value="' . strtolower($type) . '_' . $columnNumber
- . '" title="'
- . __($type) . '"';
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
+ $html = '<option value="' . $pmaString->strtolower($type) . '_' . $columnNumber
+ . '" title="' . __($type) . '"';
if (isset($columnMeta['Key']) && $columnMeta['Key'] == $key) {
$html .= ' selected="selected"';
}
- $html .= '>' . strtoupper($type) . '</option>';
+ $html .= '>' . $pmaString->strtoupper($type) . '</option>';
return $html;
}
@@ -1037,12 +1039,14 @@ function PMA_getHtmlForColumnAttribute($columnNumber, $ci, $ci_offset,
$default_current_timestamp = false;
}
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$attribute_types = $GLOBALS['PMA_Types']->getAttributes();
$cnt_attribute_types = count($attribute_types);
for ($j = 0; $j < $cnt_attribute_types; $j++) {
- $html
- .= ' <option value="' . $attribute_types[$j] . '"';
- if (strtoupper($attribute) == strtoupper($attribute_types[$j])) {
+ $html .= ' <option value="' . $attribute_types[$j] . '"';
+ if ($pmaString->strtoupper($attribute) == $pmaString->strtoupper($attribute_types[$j])) {
$html .= ' selected="selected"';
}
$html .= '>' . $attribute_types[$j] . '</option>';
@@ -1369,16 +1373,20 @@ function PMA_getFormParamsForOldColumn(
} else {
$form_params['field_orig[' . $columnNumber . ']'] = '';
}
+
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
// old column type
if (isset($columnMeta['Type'])) {
// keep in uppercase because the new type will be in uppercase
$form_params['field_type_orig[' . $columnNumber . ']']
- = strtoupper($type);
+ = $pmaString->strtoupper($type);
if (isset($columnMeta['column_status'])
&& !$columnMeta['column_status']['isEditable']
) {
$form_params['field_type[' . $columnNumber . ']']
- = strtoupper($type);
+ = $pmaString->strtoupper($type);
}
} else {
$form_params['field_type_orig[' . $columnNumber . ']'] = '';
diff --git a/libraries/tbl_indexes.lib.php b/libraries/tbl_indexes.lib.php
index 1b6c0f2aee..b5c2a74d9b 100644
--- a/libraries/tbl_indexes.lib.php
+++ b/libraries/tbl_indexes.lib.php
@@ -19,10 +19,13 @@ if (! defined('PHPMYADMIN')) {
*/
function PMA_getNameAndTypeOfTheColumns($db, $table)
{
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$columns = array();
foreach ($GLOBALS['dbi']->getColumnsFull($db, $table) as $row) {
if (preg_match('@^(set|enum)\((.+)\)$@i', $row['Type'], $tmp)) {
- $tmp[2] = substr(
+ $tmp[2] = $pmaString->substr(
preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1
);
$columns[$row['Field']] = $tmp[1] . '('
diff --git a/libraries/tbl_info.inc.php b/libraries/tbl_info.inc.php
index c1ed2cd75e..58eb69c633 100644
--- a/libraries/tbl_info.inc.php
+++ b/libraries/tbl_info.inc.php
@@ -54,6 +54,9 @@ $GLOBALS['showtable'] = PMA_Table::sGetStatusInfo(
// and we don't want to mess up the $tbl_storage_engine coming from the form
if ($showtable) {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
if (PMA_Table::isView($GLOBALS['db'], $GLOBALS['table'])) {
$tbl_is_view = true;
$tbl_storage_engine = __('View');
@@ -61,7 +64,7 @@ if ($showtable) {
} else {
$tbl_is_view = false;
$tbl_storage_engine = isset($showtable['Engine'])
- ? strtoupper($showtable['Engine'])
+ ? $pmaString->strtoupper($showtable['Engine'])
: '';
$show_comment = '';
if (isset($showtable['Comment'])) {
@@ -97,7 +100,7 @@ if ($showtable) {
}
}
// we need explicit DEFAULT value here (different from '0')
- $pack_keys = (! isset($pack_keys) || strlen($pack_keys) == 0)
+ $pack_keys = (! isset($pack_keys) || $pmaString->strlen($pack_keys) == 0)
? 'DEFAULT'
: $pack_keys;
unset($create_options, $each_create_option);
diff --git a/libraries/tbl_relation.lib.php b/libraries/tbl_relation.lib.php
index ca7b6e3882..7c3bea0a42 100644
--- a/libraries/tbl_relation.lib.php
+++ b/libraries/tbl_relation.lib.php
@@ -48,21 +48,25 @@ function PMA_generateDropdown(
*/
function PMA_backquoteSplit($text)
{
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$elements = array();
- $final_pos = strlen($text) - 1;
+ $final_pos = $pmaString->strlen($text) - 1;
$pos = 0;
while ($pos <= $final_pos) {
- $first_backquote = strpos($text, '`', $pos);
- $second_backquote = strpos($text, '`', $first_backquote + 1);
+ $first_backquote = $pmaString->strpos($text, '`', $pos);
+ $second_backquote = $pmaString->strpos($text, '`', $first_backquote + 1);
// after the second one, there might be another one which means
// this is an escaped backquote
if ($second_backquote < $final_pos && '`' == $text[$second_backquote + 1]) {
- $second_backquote = strpos($text, '`', $second_backquote + 2);
+ $second_backquote
+ = $pmaString->strpos($text, '`', $second_backquote + 2);
}
if (false === $first_backquote || false === $second_backquote) {
break;
}
- $elements[] = substr(
+ $elements[] = $pmaString->substr(
$text, $first_backquote, $second_backquote - $first_backquote + 1
);
$pos = $second_backquote + 1;
@@ -551,6 +555,9 @@ function PMA_getHtmlForForeignKeyRow($one_key, $odd_row, $columns, $i,
$foreign_table = isset($one_key['ref_table_name'])
? $one_key['ref_table_name'] : '';
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
// In Drizzle, 'SHOW TABLE STATUS' will show status only for the tables
// which are currently in the table cache. Hence we have to use
// 'SHOW TABLES' and manully retrieve table engine values.
@@ -567,7 +574,7 @@ function PMA_getHtmlForForeignKeyRow($one_key, $odd_row, $columns, $i,
'Engine'
);
if (isset($engine)
- && strtoupper($engine) == $tbl_storage_engine
+ && $pmaString->strtoupper($engine) == $tbl_storage_engine
) {
$tables[] = $row[0];
}
@@ -580,7 +587,7 @@ function PMA_getHtmlForForeignKeyRow($one_key, $odd_row, $columns, $i,
);
while ($row = $GLOBALS['dbi']->fetchRow($tables_rs)) {
if (isset($row[1])
- && strtoupper($row[1]) == $tbl_storage_engine
+ && $pmaString->strtoupper($row[1]) == $tbl_storage_engine
) {
$tables[] = $row[0];
}
@@ -731,12 +738,15 @@ function PMA_sendHtmlForColumnDropdownList()
*/
function PMA_sendHtmlForTableDropdownList()
{
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$response = PMA_Response::getInstance();
$tables = array();
$foreign = isset($_REQUEST['foreign']) && $_REQUEST['foreign'] === 'true';
if ($foreign) {
- $tbl_storage_engine = strtoupper(
+ $tbl_storage_engine = $pmaString->strtoupper(
PMA_Table::sGetStatusInfo(
$_REQUEST['db'],
$_REQUEST['table'],
@@ -759,7 +769,7 @@ function PMA_sendHtmlForTableDropdownList()
while ($row = $GLOBALS['dbi']->fetchArray($tables_rs)) {
if (isset($row['Engine'])
- && strtoupper($row['Engine']) == $tbl_storage_engine
+ && $pmaString->strtoupper($row['Engine']) == $tbl_storage_engine
) {
$tables[] = htmlspecialchars($row['Name']);
}
@@ -774,7 +784,7 @@ function PMA_sendHtmlForTableDropdownList()
);
while ($row = $GLOBALS['dbi']->fetchArray($tables_rs)) {
if ($foreign && PMA_DRIZZLE) {
- $engine = strtoupper(
+ $engine = $pmaString->strtoupper(
PMA_Table::sGetStatusInfo(
$_REQUEST['foreignDb'],
$row[0],
@@ -1126,63 +1136,65 @@ function PMA_handleUpdateForForeignKey($multi_edit_columns_name, $master_field_m
}
}
$tmp_error_create = false;
- if ($create) {
- $create_query = PMA_getSQLToCreateForeignKey(
- $table, $master_field, $foreign_db, $foreign_table, $foreign_field,
- $_REQUEST['constraint_name'][$master_field_md5],
- $options_array[$_REQUEST['on_delete'][$master_field_md5]],
- $options_array[$_REQUEST['on_update'][$master_field_md5]]
- );
+ if (!$create) {
+ return array($html_output, $preview_sql_data);
+ }
- if (! $preview_sql) {
- $display_query .= $create_query . "\n";
- $GLOBALS['dbi']->tryQuery($create_query);
- $tmp_error_create = $GLOBALS['dbi']->getError();
- if (! empty($tmp_error_create)) {
- $seen_error = true;
+ $create_query = PMA_getSQLToCreateForeignKey(
+ $table, $master_field, $foreign_db, $foreign_table, $foreign_field,
+ $_REQUEST['constraint_name'][$master_field_md5],
+ $options_array[$_REQUEST['on_delete'][$master_field_md5]],
+ $options_array[$_REQUEST['on_update'][$master_field_md5]]
+ );
- if (substr($tmp_error_create, 1, 4) == '1005') {
- $message = PMA_Message::error(
- __('Error creating foreign key on %1$s (check data types)')
- );
- $message->addParam(implode(', ', $master_field));
- $html_output .= $message->getDisplay();
- } else {
- $html_output .= PMA_Util::mysqlDie(
- $tmp_error_create, $create_query, false, '', false
- );
- }
- $html_output .= PMA_Util::showMySQLDocu(
- 'InnoDB_foreign_key_constraints'
- ) . "\n";
- }
- } else {
- $preview_sql_data .= $create_query . "\n";
- }
+ if (! $preview_sql) {
+ $display_query .= $create_query . "\n";
+ $GLOBALS['dbi']->tryQuery($create_query);
+ $tmp_error_create = $GLOBALS['dbi']->getError();
+ if (! empty($tmp_error_create)) {
+ $seen_error = true;
- // this is an alteration and the old constraint has been dropped
- // without creation of a new one
- if ($drop && $create && empty($tmp_error_drop)
- && ! empty($tmp_error_create)
- ) {
- // a rollback may be better here
- $sql_query_recreate = '# Restoring the dropped constraint...' . "\n";
- $sql_query_recreate .= PMA_getSQLToCreateForeignKey(
- $table,
- $master_field,
- $existrel_foreign[$master_field_md5]['ref_db_name'],
- $existrel_foreign[$master_field_md5]['ref_table_name'],
- $existrel_foreign[$master_field_md5]['ref_index_list'],
- $existrel_foreign[$master_field_md5]['constraint'],
- $options_array[$existrel_foreign[$master_field_md5]['on_delete']],
- $options_array[$existrel_foreign[$master_field_md5]['on_update']]
- );
- if (! $preview_sql) {
- $display_query .= $sql_query_recreate . "\n";
- $GLOBALS['dbi']->tryQuery($sql_query_recreate);
+ if ($GLOBALS['PMA_String']->substr($tmp_error_create, 1, 4) == '1005') {
+ $message = PMA_Message::error(
+ __('Error creating foreign key on %1$s (check data types)')
+ );
+ $message->addParam(implode(', ', $master_field));
+ $html_output .= $message->getDisplay();
} else {
- $preview_sql_data .= $sql_query_recreate;
+ $html_output .= PMA_Util::mysqlDie(
+ $tmp_error_create, $create_query, false, '', false
+ );
}
+ $html_output .= PMA_Util::showMySQLDocu(
+ 'InnoDB_foreign_key_constraints'
+ ) . "\n";
+ }
+ } else {
+ $preview_sql_data .= $create_query . "\n";
+ }
+
+ // this is an alteration and the old constraint has been dropped
+ // without creation of a new one
+ if ($drop && $create && empty($tmp_error_drop)
+ && ! empty($tmp_error_create)
+ ) {
+ // a rollback may be better here
+ $sql_query_recreate = '# Restoring the dropped constraint...' . "\n";
+ $sql_query_recreate .= PMA_getSQLToCreateForeignKey(
+ $table,
+ $master_field,
+ $existrel_foreign[$master_field_md5]['ref_db_name'],
+ $existrel_foreign[$master_field_md5]['ref_table_name'],
+ $existrel_foreign[$master_field_md5]['ref_index_list'],
+ $existrel_foreign[$master_field_md5]['constraint'],
+ $options_array[$existrel_foreign[$master_field_md5]['on_delete']],
+ $options_array[$existrel_foreign[$master_field_md5]['on_update']]
+ );
+ if (! $preview_sql) {
+ $display_query .= $sql_query_recreate . "\n";
+ $GLOBALS['dbi']->tryQuery($sql_query_recreate);
+ } else {
+ $preview_sql_data .= $sql_query_recreate;
}
}
diff --git a/libraries/tbl_tracking.lib.php b/libraries/tbl_tracking.lib.php
index da41907b01..2eb0b71dbc 100644
--- a/libraries/tbl_tracking.lib.php
+++ b/libraries/tbl_tracking.lib.php
@@ -51,6 +51,9 @@ function PMA_filterTracking(
function PMA_getHtmlForDataDefinitionAndManipulationStatements($url_query,
$last_version
) {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$html = '<div id="div_create_version">';
$html .= '<form method="post" action="tbl_tracking.php?' . $url_query . '">';
$html .= PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table']);
@@ -67,63 +70,63 @@ function PMA_getHtmlForDataDefinitionAndManipulationStatements($url_query,
$html .= '<p>' . __('Track these data definition statements:')
. '</p>';
$html .= '<input type="checkbox" name="alter_table" value="true"'
- . (stripos(
+ . ($pmaString->stripos(
$GLOBALS['cfg']['Server']['tracking_default_statements'],
'ALTER TABLE'
) !== false ? ' checked="checked"' : '')
. ' /> ALTER TABLE<br/>';
$html .= '<input type="checkbox" name="rename_table" value="true"'
- . (stripos(
+ . ($pmaString->stripos(
$GLOBALS['cfg']['Server']['tracking_default_statements'],
'RENAME TABLE'
) !== false ? ' checked="checked"' : '')
. ' /> RENAME TABLE<br/>';
$html .= '<input type="checkbox" name="create_table" value="true"'
- . (stripos(
+ . ($pmaString->stripos(
$GLOBALS['cfg']['Server']['tracking_default_statements'],
'CREATE TABLE'
) !== false ? ' checked="checked"' : '')
. ' /> CREATE TABLE<br/>';
$html .= '<input type="checkbox" name="drop_table" value="true"'
- . (stripos(
+ . ($pmaString->stripos(
$GLOBALS['cfg']['Server']['tracking_default_statements'],
'DROP TABLE'
) !== false ? ' checked="checked"' : '')
. ' /> DROP TABLE<br/>';
$html .= '<br/>';
$html .= '<input type="checkbox" name="create_index" value="true"'
- . (stripos(
+ . ($pmaString->stripos(
$GLOBALS['cfg']['Server']['tracking_default_statements'],
'CREATE INDEX'
) !== false ? ' checked="checked"' : '')
. ' /> CREATE INDEX<br/>';
$html .= '<input type="checkbox" name="drop_index" value="true"'
- . (stripos(
+ . ($pmaString->stripos(
$GLOBALS['cfg']['Server']['tracking_default_statements'],
'DROP INDEX'
) !== false ? ' checked="checked"' : '')
. ' /> DROP INDEX<br/>';
$html .= '<p>' . __('Track these data manipulation statements:') . '</p>';
$html .= '<input type="checkbox" name="insert" value="true"'
- . (stripos(
+ . ($pmaString->stripos(
$GLOBALS['cfg']['Server']['tracking_default_statements'],
'INSERT'
) !== false ? ' checked="checked"' : '')
. ' /> INSERT<br/>';
$html .= '<input type="checkbox" name="update" value="true"'
- . (stripos(
+ . ($pmaString->stripos(
$GLOBALS['cfg']['Server']['tracking_default_statements'],
'UPDATE'
) !== false ? ' checked="checked"' : '')
. ' /> UPDATE<br/>';
$html .= '<input type="checkbox" name="delete" value="true"'
- . (stripos(
+ . ($pmaString->stripos(
$GLOBALS['cfg']['Server']['tracking_default_statements'],
'DELETE'
) !== false ? ' checked="checked"' : '')
. ' /> DELETE<br/>';
$html .= '<input type="checkbox" name="truncate" value="true"'
- . (stripos(
+ . ($pmaString->stripos(
$GLOBALS['cfg']['Server']['tracking_default_statements'],
'TRUNCATE'
) !== false ? ' checked="checked"' : '')
@@ -809,8 +812,11 @@ function PMA_getHtmlForSchemaSnapshot($url_query)
// Get first DROP TABLE/VIEW and CREATE TABLE/VIEW statements
$drop_create_statements = $data['ddlog'][0]['statement'];
- if (strstr($data['ddlog'][0]['statement'], 'DROP TABLE')
- || strstr($data['ddlog'][0]['statement'], 'DROP VIEW')
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
+ if ($pmaString->strstr($data['ddlog'][0]['statement'], 'DROP TABLE')
+ || $pmaString->strstr($data['ddlog'][0]['statement'], 'DROP VIEW')
) {
$drop_create_statements .= $data['ddlog'][1]['statement'];
}
@@ -1156,7 +1162,11 @@ function PMA_exportAsFileDownload($entries)
$dump .= $entry['statement'];
}
$filename = 'log_' . htmlspecialchars($_REQUEST['table']) . '.sql';
- PMA_downloadHeader($filename, 'text/x-sql', strlen($dump));
+ PMA_downloadHeader(
+ $filename,
+ 'text/x-sql',
+ $GLOBALS['PMA_String']->strlen($dump)
+ );
$response = PMA_Response::getInstance();
$response->addHTML($dump);
diff --git a/libraries/transformations.lib.php b/libraries/transformations.lib.php
index 9c83fef649..8fdcea41ac 100644
--- a/libraries/transformations.lib.php
+++ b/libraries/transformations.lib.php
@@ -41,7 +41,10 @@ function PMA_Transformation_getOptions($option_string)
{
$result = array();
- if (! strlen($option_string)
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
+ if (! $pmaString->strlen($option_string)
|| ! $transform_options = preg_split('/,/', $option_string)
) {
return $result;
@@ -49,12 +52,12 @@ function PMA_Transformation_getOptions($option_string)
while (($option = array_shift($transform_options)) !== null) {
$trimmed = trim($option);
- if (strlen($trimmed) > 1
+ if ($pmaString->strlen($trimmed) > 1
&& $trimmed[0] == "'"
- && $trimmed[strlen($trimmed) - 1] == "'"
+ && $trimmed[$pmaString->strlen($trimmed) - 1] == "'"
) {
// '...'
- $option = substr($trimmed, 1, -1);
+ $option = $pmaString->substr($trimmed, 1, -1);
} elseif (isset($trimmed[0]) && $trimmed[0] == "'") {
// '...,
$trimmed = ltrim($option);
@@ -62,12 +65,12 @@ function PMA_Transformation_getOptions($option_string)
// ...,
$trimmed .= ',' . $option;
$rtrimmed = rtrim($trimmed);
- if ($rtrimmed[strlen($rtrimmed) - 1] == "'") {
+ if ($rtrimmed[$pmaString->strlen($rtrimmed) - 1] == "'") {
// ,...'
break;
}
}
- $option = substr($rtrimmed, 1, -1);
+ $option = $pmaString->substr($rtrimmed, 1, -1);
}
$result[] = stripslashes($option);
}
@@ -290,9 +293,12 @@ function PMA_setMIME($db, $table, $key, $mimetype, $transformation,
return false;
}
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
// lowercase mimetype & transformation
- $mimetype = strtolower($mimetype);
- $transformation = strtolower($transformation);
+ $mimetype = $pmaString->strtolower($mimetype);
+ $transformation = $pmaString->strtolower($transformation);
$test_qry = '
SELECT `mimetype`,
@@ -312,8 +318,9 @@ function PMA_setMIME($db, $table, $key, $mimetype, $transformation,
$GLOBALS['dbi']->freeResult($test_rs);
if (! $forcedelete
- && (strlen($mimetype) || strlen($transformation)
- || strlen($transformationOpts) || strlen($row['comment']))
+ && ($pmaString->strlen($mimetype) || $pmaString->strlen($transformation)
+ || $pmaString->strlen($transformationOpts)
+ || $pmaString->strlen($row['comment']))
) {
$upd_query = 'UPDATE ' . PMA_Util::backquote($cfgRelation['db']) . '.'
. PMA_Util::backquote($cfgRelation['column_info'])
@@ -336,9 +343,9 @@ function PMA_setMIME($db, $table, $key, $mimetype, $transformation,
WHERE `db_name` = \'' . PMA_Util::sqlAddSlashes($db) . '\'
AND `table_name` = \'' . PMA_Util::sqlAddSlashes($table) . '\'
AND `column_name` = \'' . PMA_Util::sqlAddSlashes($key) . '\'';
- } elseif (strlen($mimetype)
- || strlen($transformation)
- || strlen($transformationOpts)
+ } elseif ($pmaString->strlen($mimetype)
+ || $pmaString->strlen($transformation)
+ || $pmaString->strlen($transformationOpts)
) {
$upd_query = 'INSERT INTO ' . PMA_Util::backquote($cfgRelation['db'])
diff --git a/libraries/url_generating.lib.php b/libraries/url_generating.lib.php
index 475e673970..a18fdf46a3 100644
--- a/libraries/url_generating.lib.php
+++ b/libraries/url_generating.lib.php
@@ -42,11 +42,14 @@ function PMA_URL_getHiddenInputs($db = '', $table = '',
$indent =& $_indent;
$skip =& $_skip;
} else {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$params = array();
- if (strlen($db)) {
+ if ($pmaString->strlen($db)) {
$params['db'] = $db;
}
- if (strlen($table)) {
+ if ($pmaString->strlen($table)) {
$params['table'] = $table;
}
}
@@ -284,15 +287,18 @@ function PMA_URL_getArgSeparator($encode = 'none')
static $separator = null;
static $html_separator = null;
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
if (null === $separator) {
// use separators defined by php, but prefer ';'
// as recommended by W3C
// (see http://www.w3.org/TR/1999/REC-html401-19991224/appendix
// /notes.html#h-B.2.2)
$arg_separator = ini_get('arg_separator.input');
- if (strpos($arg_separator, ';') !== false) {
+ if ($pmaString->strpos($arg_separator, ';') !== false) {
$separator = ';';
- } elseif (strlen($arg_separator) > 0) {
+ } elseif ($pmaString->strlen($arg_separator) > 0) {
$separator = $arg_separator{0};
} else {
$separator = '&';
diff --git a/prefs_manage.php b/prefs_manage.php
index b79e2d6d6d..7291ad3f58 100644
--- a/prefs_manage.php
+++ b/prefs_manage.php
@@ -171,13 +171,17 @@ if (isset($_POST['submit_export'])
if ($return_url) {
$query = explode('&', parse_url($return_url, PHP_URL_QUERY));
$return_url = parse_url($return_url, PHP_URL_PATH);
+
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
foreach ($query as $q) {
- $pos = strpos($q, '=');
- $k = substr($q, 0, $pos);
+ $pos = $pmaString->strpos($q, '=');
+ $k = $pmaString->substr($q, 0, $pos);
if ($k == 'token') {
continue;
}
- $params[$k] = substr($q, $pos+1);
+ $params[$k] = $pmaString->substr($q, $pos+1);
}
} else {
$return_url = 'prefs_manage.php';
diff --git a/scripts/decode_bug.php b/scripts/decode_bug.php
index a310e643c6..6334f2377a 100644
--- a/scripts/decode_bug.php
+++ b/scripts/decode_bug.php
@@ -82,9 +82,12 @@ if (!empty($bug_encoded) && is_string($bug_encoded)) {
$bug_encoded = stripslashes($bug_encoded);
}
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$bug_encoded = preg_replace('/[[:space:]]/', '', $bug_encoded);
$bug_decoded = base64_decode($bug_encoded);
- if (substr($bug_encoded, 0, 2) == 'eN') {
+ if ($pmaString->substr($bug_encoded, 0, 2) == 'eN') {
if (function_exists('gzuncompress')) {
$result = PMA_printDecodedBug(gzuncompress($bug_decoded));
} else {
diff --git a/setup/frames/index.inc.php b/setup/frames/index.inc.php
index a24d058ef9..16823da658 100644
--- a/setup/frames/index.inc.php
+++ b/setup/frames/index.inc.php
@@ -64,7 +64,8 @@ if (!$config_writable || !$config_readable) {
//
// Check https connection
//
-$is_https = !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
+$is_https = !empty($_SERVER['HTTPS'])
+ && $GLOBALS['PMA_String']->strtolower($_SERVER['HTTPS']) == 'on';
if (!$is_https) {
$text = __(
'You are not using a secure connection; all data (including potentially '
diff --git a/setup/lib/ConfigGenerator.class.php b/setup/lib/ConfigGenerator.class.php
index 5497eff4ab..07a6a65fc0 100644
--- a/setup/lib/ConfigGenerator.class.php
+++ b/setup/lib/ConfigGenerator.class.php
@@ -71,7 +71,7 @@ class ConfigGenerator
}
// keep 1d array keys which are present in $persist_keys (config.values.php)
foreach (array_keys($persistKeys) as $k) {
- if (strpos($k, '/') === false) {
+ if ($GLOBALS['PMA_String']->strpos($k, '/') === false) {
$k = preg_replace('/[^A-Za-z0-9_]/', '_', $k);
$ret .= self::_getVarExport($k, $cf->getDefault($k), $crlf);
}
diff --git a/sql.php b/sql.php
index 0630122f06..291bf43f8d 100644
--- a/sql.php
+++ b/sql.php
@@ -57,10 +57,13 @@ if (! empty($goto)) {
$is_gotofile = true;
} // end if
+/** @var PMA_String $pmaString */
+$pmaString = $GLOBALS['PMA_String'];
if (! isset($err_url)) {
$err_url = (! empty($back) ? $back : $goto)
. '?' . PMA_URL_getCommon($GLOBALS['db'])
- . ((strpos(' ' . $goto, 'db_') != 1 && strlen($table))
+ . (($pmaString->strpos(' ' . $goto, 'db_') != 1
+ && $pmaString->strlen($table))
? '&amp;table=' . urlencode($table)
: ''
);
@@ -110,7 +113,7 @@ if (isset($_REQUEST['set_col_prefs']) && $_REQUEST['set_col_prefs'] == true) {
// Default to browse if no query set and we have table
// (needed for browsing from DefaultTabTable)
-if (empty($sql_query) && strlen($table) && strlen($db)) {
+if (empty($sql_query) && $pmaString->strlen($table) && $pmaString->strlen($db)) {
$sql_query = PMA_getDefaultSqlQueryForBrowse($db, $table);
// set $goto to what will be displayed if query returns 0 rows
diff --git a/tbl_addfield.php b/tbl_addfield.php
index 305765ce18..3946efeacc 100644
--- a/tbl_addfield.php
+++ b/tbl_addfield.php
@@ -64,9 +64,11 @@ if (isset($_REQUEST['do_save_data'])) {
&& is_array($_REQUEST['field_mimetype'])
&& $cfg['BrowseMIME']
) {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
if (isset($_REQUEST['field_name'][$fieldindex])
- && strlen($_REQUEST['field_name'][$fieldindex])
+ && $pmaString->strlen($_REQUEST['field_name'][$fieldindex])
) {
PMA_setMIME(
$db, $table,
diff --git a/tbl_change.php b/tbl_change.php
index 2288cb64f2..c0f468d355 100644
--- a/tbl_change.php
+++ b/tbl_change.php
@@ -47,7 +47,7 @@ require_once 'libraries/file_listing.lib.php';
* (at this point, $GLOBALS['goto'] will be set but could be empty)
*/
if (empty($GLOBALS['goto'])) {
- if (strlen($table)) {
+ if ($GLOBALS['PMA_String']->strlen($table)) {
// avoid a problem (see bug #2202709)
$GLOBALS['goto'] = 'tbl_sql.php';
} else {
diff --git a/tbl_chart.php b/tbl_chart.php
index f5a6264d33..6d5f316c30 100644
--- a/tbl_chart.php
+++ b/tbl_chart.php
@@ -8,6 +8,10 @@
require_once 'libraries/common.inc.php';
require_once 'libraries/tbl_chart.lib.php';
+
+/** @var PMA_String $pmaString */
+$pmaString = $GLOBALS['PMA_String'];
+
/*
* Execute the query and return the result
*/
@@ -17,7 +21,8 @@ if (isset($_REQUEST['ajax_request'])
) {
$response = PMA_Response::getInstance();
- if (strlen($GLOBALS['table']) && strlen($GLOBALS['db'])) {
+ if ($pmaString->strlen($GLOBALS['table']) && $pmaString->strlen($GLOBALS['db'])
+ ) {
include './libraries/tbl_common.inc.php';
}
@@ -76,12 +81,12 @@ $scripts->addFile('jqplot/plugins/jqplot.highlighter.js');
/**
* Runs common work
*/
-if (strlen($GLOBALS['table'])) {
+if ($pmaString->strlen($GLOBALS['table'])) {
$url_params['goto'] = $cfg['DefaultTabTable'];
$url_params['back'] = 'tbl_sql.php';
include 'libraries/tbl_common.inc.php';
include 'libraries/tbl_info.inc.php';
-} elseif (strlen($GLOBALS['db'])) {
+} elseif ($pmaString->strlen($GLOBALS['db'])) {
$url_params['goto'] = $cfg['DefaultTabDatabase'];
$url_params['back'] = 'sql.php';
include 'libraries/db_common.inc.php';
diff --git a/tbl_create.php b/tbl_create.php
index a6209d6c4b..b685ea5692 100644
--- a/tbl_create.php
+++ b/tbl_create.php
@@ -15,8 +15,11 @@ require_once 'libraries/create_addfield.lib.php';
// Check parameters
PMA_Util::checkParameters(array('db'));
+/** @var PMA_String $pmaString */
+$pmaString = $GLOBALS['PMA_String'];
+
/* Check if database name is empty */
-if (strlen($db) == 0) {
+if ($pmaString->strlen($db) == 0) {
PMA_Util::mysqlDie(
__('The database name is empty!'), '', false, 'index.php'
);
@@ -73,7 +76,7 @@ if (isset($_REQUEST['do_save_data'])) {
) {
foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
if (isset($_REQUEST['field_name'][$fieldindex])
- && strlen($_REQUEST['field_name'][$fieldindex])
+ && $pmaString->strlen($_REQUEST['field_name'][$fieldindex])
) {
PMA_setMIME(
$db, $table,
diff --git a/tbl_get_field.php b/tbl_get_field.php
index 3c9a867117..be42d20cbe 100644
--- a/tbl_get_field.php
+++ b/tbl_get_field.php
@@ -49,7 +49,7 @@ if ($result === false) {
PMA_downloadHeader(
$table . '-' . $_GET['transform_key'] . '.bin',
PMA_detectMIME($result),
- strlen($result)
+ $GLOBALS['PMA_String']->strlen($result)
);
echo $result;
?>
diff --git a/tbl_operations.php b/tbl_operations.php
index c27b5e9c00..c4c0a47094 100644
--- a/tbl_operations.php
+++ b/tbl_operations.php
@@ -73,6 +73,9 @@ if ($is_aria) {
$reread_info = false;
$table_alters = array();
+/** @var PMA_String $pmaString */
+$pmaString = $GLOBALS['PMA_String'];
+
/**
* If the table has to be moved to some other database
*/
@@ -108,7 +111,7 @@ if (isset($_REQUEST['submitoptions'])) {
}
if (! empty($_REQUEST['new_tbl_storage_engine'])
- && strtolower($_REQUEST['new_tbl_storage_engine']) !== strtolower($tbl_storage_engine)
+ && $pmaString->strtolower($_REQUEST['new_tbl_storage_engine']) !== $pmaString->strtolower($tbl_storage_engine)
) {
$new_tbl_storage_engine = $_REQUEST['new_tbl_storage_engine'];
// reset the globals for the new engine
@@ -270,8 +273,8 @@ if (! $hideOrderTable) {
*/
$response->addHTML(PMA_getHtmlForMoveTable());
-if (strstr($show_comment, '; InnoDB free') === false) {
- if (strstr($show_comment, 'InnoDB free') === false) {
+if ($pmaString->strstr($show_comment, '; InnoDB free') === false) {
+ if ($pmaString->strstr($show_comment, 'InnoDB free') === false) {
// only user entered comment
$comment = $show_comment;
} else {
diff --git a/tbl_printview.php b/tbl_printview.php
index fd500eaf46..d8c3a1956f 100644
--- a/tbl_printview.php
+++ b/tbl_printview.php
@@ -31,10 +31,13 @@ require_once 'libraries/tbl_printview.lib.php';
$cfgRelation = PMA_getRelationsParam();
+/** @var PMA_String $pmaString */
+$pmaString = $GLOBALS['PMA_String'];
+
/**
* Defines the url to return to in case of error in a sql statement
*/
-if (strlen($table)) {
+if ($pmaString->strlen($table)) {
$err_url = 'tbl_sql.php?' . PMA_URL_getCommon($db, $table);
} else {
$err_url = 'db_sql.php?' . PMA_URL_getCommon($db);
@@ -51,7 +54,7 @@ $GLOBALS['dbi']->selectDb($db);
*/
if (isset($_POST['selected_tbl']) && is_array($_POST['selected_tbl'])) {
$the_tables = $_POST['selected_tbl'];
-} elseif (strlen($table)) {
+} elseif ($pmaString->strlen($table)) {
$the_tables[] = $table;
}
diff --git a/test/bootstrap-dist.php b/test/bootstrap-dist.php
index dde8f7f9e9..4e74a52351 100644
--- a/test/bootstrap-dist.php
+++ b/test/bootstrap-dist.php
@@ -45,6 +45,7 @@ foreach ($test_defaults as $varname => $defvalue) {
// Initialize PMA_VERSION variable
require_once 'libraries/core.lib.php';
+$GLOBALS['PMA_String'] = $PMA_String;
require_once 'libraries/Config.class.php';
$CFG = new PMA_Config();
define('PMA_VERSION', $CFG->get('PMA_VERSION'));
diff --git a/test/classes/PMA_Config_test.php b/test/classes/PMA_Config_test.php
index c3c3763414..9ae5c91e19 100644
--- a/test/classes/PMA_Config_test.php
+++ b/test/classes/PMA_Config_test.php
@@ -40,8 +40,6 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase
*/
protected $permTestObj;
-
-
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
@@ -343,10 +341,13 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase
);
}
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
if (@function_exists('gd_info')) {
$this->object->checkGd2();
$gd_nfo = gd_info();
- if (strstr($gd_nfo["GD Version"], '2.')) {
+ if ($pmaString->strstr($gd_nfo["GD Version"], '2.')) {
$this->assertEquals(
1,
$this->object->get('PMA_IS_GD2'),
@@ -368,7 +369,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase
ob_end_clean();
if (preg_match('@GD Version[[:space:]]*\(.*\)@', $a, $v)) {
- if (strstr($v, '2.')) {
+ if ($pmaString->strstr($v, '2.')) {
$this->assertEquals(
1,
$this->object->get('PMA_IS_GD2'),
@@ -387,7 +388,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase
/**
* Web server detection test
*
- * @param string $server Server indentification
+ * @param string $server Server identification
* @param boolean $iis Whether server should be detected as IIS
*
* @return void
@@ -439,7 +440,6 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase
$this->assertEquals(1, $this->object->get('PMA_IS_WINDOWS'));
} elseif (stristr(PHP_OS, 'OS/2')) {
$this->assertEquals(1, $this->object->get('PMA_IS_WINDOWS'));
- break;
} elseif (stristr(PHP_OS, 'Linux')) {
$this->assertEquals(0, $this->object->get('PMA_IS_WINDOWS'));
} else {
@@ -883,7 +883,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase
* Test for loading user preferences
*
* @return void
- * @todo Test actualy preferences loading
+ * @todo Test actually preferences loading
*/
public function testLoadUserPreferences()
{
@@ -919,7 +919,6 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase
* Should test getting unique value for theme
*
* @return void
- * @todo Implement testGetThemeUniqueValue().
*/
public function testGetThemeUniqueValue()
{
@@ -953,13 +952,12 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase
* Should test checking of config permissions
*
* @return void
- * @todo Implement testCheckPermissions().
*/
public function testCheckPermissions()
{
//load file permissions for the current permissions file
$perms = @fileperms($this->object->getSource());
- //testing for permissions for no configration file
+ //testing for permissions for no configuration file
$this->assertFalse(!($perms === false) && ($perms & 2));
//load file permissions for the current permissions file
diff --git a/test/classes/PMA_DisplayResults_test.php b/test/classes/PMA_DisplayResults_test.php
index c04fc4d328..db3d71ce4c 100644
--- a/test/classes/PMA_DisplayResults_test.php
+++ b/test/classes/PMA_DisplayResults_test.php
@@ -46,7 +46,6 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase
$GLOBALS['PMA_Config'] = new PMA_Config();
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['text_dir'] = 'ltr';
- $GLOBALS['PMA_String'] = new PMA_String();
include_once 'libraries/Response.class.php';
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
diff --git a/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php b/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php
index 42d42a1352..dc6ea29c50 100644
--- a/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php
+++ b/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php
@@ -1042,7 +1042,7 @@ class PMA_AuthenticationCookie_Test extends PHPUnit_Framework_TestCase
$this->assertEquals(
256,
- strlen($result)
+ $GLOBALS['PMA_String']->strlen($result)
);
// case 2
diff --git a/test/classes/plugin/import/ImportShp_test.php b/test/classes/plugin/import/ImportShp_test.php
index 780c5dce78..98e4cd6ea6 100644
--- a/test/classes/plugin/import/ImportShp_test.php
+++ b/test/classes/plugin/import/ImportShp_test.php
@@ -28,6 +28,7 @@ require_once 'libraries/Message.class.php';
class ImportShp_Test extends PHPUnit_Framework_TestCase
{
/**
+ * @var ImportShp
* @access protected
*/
protected $object;
diff --git a/test/libraries/PMA_StringMB_test.php b/test/libraries/PMA_StringMB_test.php
index 89fe57d11b..5b5e1aa0c4 100644
--- a/test/libraries/PMA_StringMB_test.php
+++ b/test/libraries/PMA_StringMB_test.php
@@ -40,6 +40,54 @@ class PMA_String_Mb_Test extends PMA_StringNative_Test
}
/**
+ * Test for PMA_StringNative::strrchr
+ *
+ * @param string $expected Expected substring
+ * @param string $haystack String to cut
+ * @param string $needle Searched string
+ *
+ * @return void
+ * @test
+ * @dataProvider providerStrrchr
+ */
+ public function testStrrchr($expected, $haystack, $needle)
+ {
+ $this->assertEquals(
+ $expected,
+ $this->testObject->strrchr($haystack, $needle)
+ );
+ }
+
+ /**
+ * Data provider for testStrrchr
+ *
+ * @return array Test data
+ */
+ public function providerStrrchr()
+ {
+ return array(
+ array('abcdef', 'abcdefabcdef', 'a'),
+ array(false, 'abcdefabcdef', 'A'),
+ array('f', 'abcdefabcdef', 'f'),
+ array(false, 'abcdefabcdef', 'z'),
+ array(false, 'abcdefabcdef', ''),
+ array(false, 'abcdefabcdef', false),
+ array(false, 'abcdefabcdef', true),
+ array(false, '789456123', true),
+ array(false, 'abcdefabcdef', null),
+ array(false, null, null),
+ array(false, null, 'a'),
+ array(false, null, '0'),
+ array(false, false, null),
+ array(false, false, 'a'),
+ array(false, false, '0'),
+ array(false, true, null),
+ array(false, true, 'a'),
+ array(false, true, '0'),
+ );
+ }
+
+ /**
* TearDown function for tests, restores internal encoding
*
* @access protected
diff --git a/test/libraries/PMA_StringNative_test.php b/test/libraries/PMA_StringNative_test.php
index 170eb81474..c3543248d1 100644
--- a/test/libraries/PMA_StringNative_test.php
+++ b/test/libraries/PMA_StringNative_test.php
@@ -159,5 +159,53 @@ class PMA_StringNative_Test extends PHPUnit_Framework_TestCase
array("test string", "TEST STRING")
);
}
+
+ /**
+ * Test for PMA_StringNative::strrchr
+ *
+ * @param string $expected Expected substring
+ * @param string $haystack String to cut
+ * @param string $needle Searched string
+ *
+ * @return void
+ * @test
+ * @dataProvider providerStrrchr
+ */
+ public function testStrrchr($expected, $haystack, $needle)
+ {
+ $this->assertEquals(
+ $expected,
+ $this->testObject->strrchr($haystack, $needle)
+ );
+ }
+
+ /**
+ * Data provider for testStrrchr
+ *
+ * @return array Test data
+ */
+ public function providerStrrchr()
+ {
+ return array(
+ array('abcdef', 'abcdefabcdef', 'a'),
+ array(false, 'abcdefabcdef', 'A'),
+ array('f', 'abcdefabcdef', 'f'),
+ array(false, 'abcdefabcdef', 'z'),
+ array(false, 'abcdefabcdef', ''),
+ array(false, 'abcdefabcdef', false),
+ array(false, 'abcdefabcdef', true),
+ array(false, '789456123', true),
+ array(false, 'abcdefabcdef', null),
+ array(false, null, null),
+ array(false, null, 'a'),
+ array(false, null, '0'),
+ array(false, false, null),
+ array(false, false, 'a'),
+ array(false, false, '0'),
+ array(false, true, null),
+ array(false, true, 'a'),
+ array(false, true, '0'),
+ );
+ }
}
?>
diff --git a/test/libraries/PMA_String_Compare_test.php b/test/libraries/PMA_String_Compare_test.php
new file mode 100644
index 0000000000..75d15104c8
--- /dev/null
+++ b/test/libraries/PMA_String_Compare_test.php
@@ -0,0 +1,1161 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Tests to compare String Functions for phpMyAdmin
+ *
+ * @package PhpMyAdmin-test
+ */
+
+/*
+ * Include to test.
+ */
+require_once 'libraries/StringNative.class.php';
+require_once 'libraries/StringMB.class.php';
+
+/**
+ * Tests to compare String Functions for phpMyAdmin
+ *
+ * @package PhpMyAdmin-test
+ */
+class PMA_String_Compare_Test extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @var PMA_StringNative
+ */
+ private $_native;
+
+ /**
+ * @var PMA_StringMB
+ */
+ private $_mb;
+
+ /**
+ * Setup function for test cases
+ *
+ * @access protected
+ * @return void
+ */
+ protected function setUp()
+ {
+ if (!@function_exists('mb_strlen')) {
+ $this->markTestSkipped('Multibyte String Functions are not available.');
+ }
+ $this->_native = new PMA_StringNative();
+ $this->_mb = new PMA_StringMB();
+ }
+
+ /**
+ * Tests for strlen
+ *
+ * @param mixed $value Value to test
+ *
+ * @return void
+ * @test
+ * @dataProvider providerStrlen
+ */
+ public function testStrlen($value)
+ {
+ $native = $this->_native->strlen($value);
+ $multibytes = $this->_mb->strlen($value);
+ $this->assertTrue(
+ $native === $multibytes,
+ 'native length: ' . var_export($native, true)
+ . ' - mb length: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testStrlen
+ *
+ * @return array Test data
+ */
+ public function providerStrlen()
+ {
+ return array(
+ array('test'),
+ array('3'),
+ array(''),
+ array(""),
+ array(false),
+ array(true),
+ array(null),
+ array(3),
+ array(10),
+ );
+ }
+
+ /**
+ * Tests for substr
+ *
+ * @param mixed $value Value to test
+ * @param int $start Position to start cutting
+ * @param int $length Number of characters to cut
+ *
+ * @return void
+ * @test
+ * @dataProvider providerSubstr
+ */
+ public function testSubstr($value, $start, $length = 2147483647)
+ {
+ $native = $this->_native->substr($value, $start, $length);
+ $multibytes = $this->_mb->substr($value, $start, $length);
+ $this->assertTrue(
+ $native === $multibytes,
+ 'native substr: ' . var_export($native, true)
+ . ' - mb substr: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testSubstr
+ *
+ * @return array Test data
+ */
+ public function providerSubstr()
+ {
+ return array(
+ array('abcdefabcdef', 0),
+ array('abcdefabcdef', 0, 3),
+ array('abcdefabcdef', 0, 10),
+ array('abcdefabcdef', 0, -2),
+ array('abcdefabcdef', 2),
+ array('abcdefabcdef', 2, 3),
+ array('abcdefabcdef', 2, 10),
+ array('abcdefabcdef', 2, -1),
+ array('abcdefabcdef', 2, -4),
+ array('abcdefabcdef', 2, -5),
+ array('abcdefabcdef', 6),
+ array('abcdefabcdef', 6, 2),
+ array('abcdefabcdef', 6, 10),
+ array('abcdefabcdef', 6, -4),
+ array('abcdefabcdef', -3),
+ array('abcdefabcdef', -3, 1),
+ array('abcdefabcdef', -3, 10),
+ array('abcdefabcdef', -3, -1),
+ array('abcdefabcdef', -3, -3),
+ array('abcdefabcdef', -3, -5),
+ array(false, 0),
+ array(false, 0, 2),
+ array(false, 10),
+ array(false, 10, 2),
+ array(true, 0),
+ array(true, 0, 1),
+ array(true, 0, 10),
+ array(true, 0, -1),
+ array(true, 0, -10),
+ array(true, 10),
+ array(true, 10, 1),
+ array(true, 10, 10),
+ array(true, 10, -3),
+ array(3, 0),
+ array(3, 0, 1),
+ array(3, 0, 2),
+ array(3, 0, -1),
+ array(3, 10),
+ array(3, 10, 1),
+ array(3, 10, 10),
+ array(3, 10, -1),
+ array('3', 0),
+ array('3', 0, 1),
+ array('3', 0, 2),
+ array('3', 0, -1),
+ array('3', 10),
+ array('3', 10, 1),
+ array('3', 10, 10),
+ array('3', 10, -1),
+ array('', 0),
+ array('', 0, 1),
+ array('', 0, 10),
+ array('', 0, -1),
+ array('', 10),
+ array('', 10, 1),
+ array('', 10, 10),
+ array('', 10, -1),
+ array(null, 10),
+ array(null, 10, 1),
+ array(null, 10, 10),
+ array(null, 10, -1),
+ );
+ }
+
+ /**
+ * Tests for strpos
+ *
+ * @param string $haystack String to search in
+ * @param mixed $needle Characters to search
+ * @param int $offset Start position
+ *
+ * @return void
+ * @test
+ * @dataProvider providerStrpos
+ */
+ public function testStrpos($haystack, $needle, $offset = 0)
+ {
+ $native = $this->_native->strpos($haystack, $needle, $offset);
+ $multibytes = $this->_mb->strpos($haystack, $needle, $offset);
+ $this->assertTrue(
+ $native === $multibytes,
+ 'native strpos: ' . var_export($native, true)
+ . ' - mb strpos: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testStrpos
+ *
+ * @return array Test data
+ */
+ public function providerStrpos()
+ {
+ return array(
+ array('abcdefabcdef', 'a'),
+ array('abcdefabcdef', 'a', 2),
+ array('abcdefabcdef', 'a', 10),
+ array('abcdefabcdef', 'A'),
+ array('abcdefabcdef', 'A', 2),
+ array('abcdefabcdef', 'A', 10),
+ array('abcdefabcdef', 'e'),
+ array('abcdefabcdef', 'e', 2),
+ array('abcdefabcdef', 'e', 10),
+ array('abcdefabcdef', 'e'),
+ array('abcdefabcdef', 'z'),
+ array('abcdefabcdef', 'z', 2),
+ array('abcdefabcdef', ord('a')),
+ array('abcdefabcdef', ord('a'), 2),
+ array('abcdefabcdef', ord('A')),
+ array('abcdefabcdef', ord('A'), 2),
+ array('abcdefabcdef', ord('e')),
+ array('abcdefabcdef', ord('e'), 2),
+ array('abcdefabcdef', ord('z')),
+ array('abcdefabcdef', ord('z'), 2),
+ array('abcdefabcdef', false),
+ array(false, 'a'),
+ array(false, 0),
+ array(false, false),
+ array(true, 0),
+ array(true, 0, 1),
+ array(true, 1),
+ array(true, 1, 1),
+ array(3, 0),
+ array(3, 3),
+ array(3, '3'),
+ array('3', '3'),
+ array(null, 0),
+ array(null, false),
+ array('', 0),
+ array('', false),
+ );
+ }
+
+ /**
+ * Tests for strpos
+ *
+ * @param string $haystack String to search in
+ * @param mixed $needle Characters to search
+ * @param int $offset Start position
+ *
+ * @return void
+ * @test
+ * @dataProvider providerStrposException
+ */
+ public function testStrposException($haystack, $needle, $offset = 0)
+ {
+ $native = null;
+ $multibytes = null;
+ $nativeException = false;
+ $multibytesException = false;
+ try {
+ $native = $this->_native->strpos($haystack, $needle, $offset);
+ } catch (PHPUnit_Framework_Error $e) {
+ $nativeException = true;
+ }
+ try {
+ $multibytes = $this->_mb->strpos($haystack, $needle, $offset);
+ } catch (PHPUnit_Framework_Error $e) {
+ $multibytesException = true;
+ }
+
+ $this->assertTrue(
+ true === $nativeException && true === $multibytesException,
+ 'native strpos: ' . var_export($native, true)
+ . ' - mb strpos: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testStrposException
+ *
+ * @return array Test data
+ */
+ public function providerStrposException()
+ {
+ return array(
+ array('abcdefabcdef', 'a', 20),
+ array('abcdefabcdef', 'e', 20),
+ array('abcdefabcdef', 'z', 20),
+ array('abcdefabcdef', ord('a'), 20),
+ array('abcdefabcdef', ord('e'), 20),
+ array('abcdefabcdef', ord('z'), 20),
+ array(false, 0, 1),
+ array(3, 0, 2),
+ array(3, 3, 2),
+ array(3, '3', 2),
+ array('3', '3', 2),
+ array('', 0, 2),
+ );
+ }
+
+ /**
+ * Tests for stripos
+ *
+ * @param string $haystack String to search in
+ * @param mixed $needle Characters to search
+ * @param int $offset Start position
+ *
+ * @return void
+ * @test
+ * @dataProvider providerStripos
+ */
+ public function testStripos($haystack, $needle, $offset = 0)
+ {
+ $native = $this->_native->stripos($haystack, $needle, $offset);
+ $multibytes = $this->_mb->stripos($haystack, $needle, $offset);
+ $this->assertTrue(
+ $native === $multibytes,
+ 'native stripos: ' . var_export($native, true)
+ . ' - mb stripos: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testStripos
+ *
+ * @return array Test data
+ */
+ public function providerStripos()
+ {
+ return array(
+ array('abcdefabcdef', 'a'),
+ array('abcdefabcdef', 'a', 2),
+ array('abcdefabcdef', 'a', 10),
+ array('abcdefabcdef', 'A'),
+ array('abcdefabcdef', 'A', 2),
+ array('abcdefabcdef', 'A', 10),
+ array('abcdefabcdef', 'e'),
+ array('abcdefabcdef', 'e', 2),
+ array('abcdefabcdef', 'e', 10),
+ array('abcdefabcdef', 'e'),
+ array('abcdefabcdef', 'z'),
+ array('abcdefabcdef', 'z', 2),
+ array('abcdefabcdef', ord('a')),
+ array('abcdefabcdef', ord('a'), 2),
+ array('abcdefabcdef', ord('A')),
+ array('abcdefabcdef', ord('A'), 2),
+ array('abcdefabcdef', ord('e')),
+ array('abcdefabcdef', ord('e'), 2),
+ array('abcdefabcdef', ord('z')),
+ array('abcdefabcdef', ord('z'), 2),
+ array('abcdefabcdef', false),
+ array(false, 'a'),
+ array(false, 0),
+ array(false, 0, 1),
+ array(false, false),
+ array(true, 0),
+ array(true, 0, 1),
+ array(true, 1),
+ array(true, 1, 1),
+ array(3, 0),
+ array(3, 3),
+ array(3, '3'),
+ array('3', '3'),
+ array(null, 0),
+ array(null, false),
+ array('', 0),
+ array('', 0, 2),
+ array('', false),
+ );
+ }
+
+ /**
+ * Tests for stripos
+ *
+ * @param string $haystack String to search in
+ * @param mixed $needle Characters to search
+ * @param int $offset Start position
+ *
+ * @return void
+ * @test
+ * @dataProvider providerStriposException
+ */
+ public function testStriposException($haystack, $needle, $offset = 0)
+ {
+ $native = null;
+ $multibytes = null;
+ $nativeException = false;
+ $multibytesException = false;
+ try {
+ $native = $this->_native->stripos($haystack, $needle, $offset);
+ } catch (PHPUnit_Framework_Error $e) {
+ $nativeException = true;
+ }
+ try {
+ $multibytes = $this->_mb->stripos($haystack, $needle, $offset);
+ } catch (PHPUnit_Framework_Error $e) {
+ $multibytesException = true;
+ }
+
+ $this->assertTrue(
+ true === $nativeException && true === $multibytesException,
+ 'native stripos: ' . var_export($native, true)
+ . ' - mb stripos: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testStriposException
+ *
+ * @return array Test data
+ */
+ public function providerStriposException()
+ {
+ return array(
+ array('abcdefabcdef', 'a', 20),
+ array('abcdefabcdef', 'e', 20),
+ array('abcdefabcdef', 'z', 20),
+ array('abcdefabcdef', ord('a'), 20),
+ array('abcdefabcdef', ord('e'), 20),
+ array('abcdefabcdef', ord('z'), 20),
+ array(3, 0, 2),
+ array(3, 3, 2),
+ array(3, '3', 2),
+ array('3', '3', 2),
+ );
+ }
+
+ /**
+ * Tests for strrpos
+ *
+ * @param string $haystack String to search in
+ * @param mixed $needle Characters to search
+ * @param int $offset Start position
+ *
+ * @return void
+ * @test
+ * @dataProvider providerStrrpos
+ */
+ public function testStrrpos($haystack, $needle, $offset = 0)
+ {
+ $native = $this->_native->strrpos($haystack, $needle, $offset);
+ $multibytes = $this->_mb->strrpos($haystack, $needle, $offset);
+ $this->assertTrue(
+ $native === $multibytes,
+ 'native strrpos: ' . var_export($native, true)
+ . ' - mb strrpos: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testStrrpos
+ *
+ * @return array Test data
+ */
+ public function providerStrrpos()
+ {
+ return array(
+ array('abcdefabcdef', 'a'),
+ array('abcdefabcdef', 'a', 2),
+ array('abcdefabcdef', 'a', 10),
+ array('abcdefabcdef', 'a', -10),
+ array('abcdefabcdef', 'A'),
+ array('abcdefabcdef', 'A', 2),
+ array('abcdefabcdef', 'A', 10),
+ array('abcdefabcdef', 'A', -10),
+ array('abcdefabcdef', 'e'),
+ array('abcdefabcdef', 'e', 2),
+ array('abcdefabcdef', 'e', 10),
+ array('abcdefabcdef', 'e', -2),
+ array('abcdefabcdef', 'e'),
+ array('abcdefabcdef', 'z'),
+ array('abcdefabcdef', 'z', 2),
+ array('abcdefabcdef', 'z', -2),
+ array('abcdefabcdef', ord('a')),
+ array('abcdefabcdef', ord('a'), 2),
+ array('abcdefabcdef', ord('a'), -2),
+ array('abcdefabcdef', ord('A')),
+ array('abcdefabcdef', ord('A'), 2),
+ array('abcdefabcdef', ord('A'), -2),
+ array('abcdefabcdef', ord('e')),
+ array('abcdefabcdef', ord('e'), 2),
+ array('abcdefabcdef', ord('e'), -2),
+ array('abcdefabcdef', ord('z')),
+ array('abcdefabcdef', ord('z'), 2),
+ array('abcdefabcdef', ord('z'), -2),
+ array('abcdefabcdef', false),
+ array(false, 'a'),
+ array(false, 0),
+ array(false, 0, 1),
+ array(false, false),
+ array(true, 0),
+ array(true, 0, 1),
+ array(true, 1),
+ array(true, 1, 1),
+ array(3, 0),
+ array(3, 3),
+ array(3, '3'),
+ array('3', '3'),
+ array(null, 0),
+ array(null, false),
+ array('', 0),
+ array('', 0, 2),
+ array('', false),
+ );
+ }
+
+ /**
+ * Tests for strrpos
+ *
+ * @param string $haystack String to search in
+ * @param mixed $needle Characters to search
+ * @param int $offset Start position
+ *
+ * @return void
+ * @test
+ * @dataProvider providerStrrposException
+ */
+ public function testStrrposException($haystack, $needle, $offset = 0)
+ {
+ $native = null;
+ $multibytes = null;
+ $nativeException = false;
+ $multibytesException = false;
+ try {
+ $native = $this->_native->strrpos($haystack, $needle, $offset);
+ } catch (PHPUnit_Framework_Error $e) {
+ $nativeException = true;
+ }
+ try {
+ $multibytes = $this->_mb->strrpos($haystack, $needle, $offset);
+ } catch (PHPUnit_Framework_Error $e) {
+ $multibytesException = true;
+ }
+
+ $this->assertTrue(
+ true === $nativeException && true === $multibytesException,
+ 'native strrpos: ' . var_export($native, true)
+ . ' - mb strrpos: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testStrrposException
+ *
+ * @return array Test data
+ */
+ public function providerStrrposException()
+ {
+ return array(
+ array('abcdefabcdef', 'a', 20),
+ array('abcdefabcdef', 'a', -20),
+ array('abcdefabcdef', 'e', 20),
+ array('abcdefabcdef', 'e', -20),
+ array('abcdefabcdef', 'z', 20),
+ array('abcdefabcdef', 'z', -20),
+ array('abcdefabcdef', ord('a'), 20),
+ array('abcdefabcdef', ord('e'), 20),
+ array('abcdefabcdef', ord('z'), 20),
+ array(3, 0, 2),
+ array(3, 3, 2),
+ array(3, '3', 2),
+ array('3', '3', 2),
+ );
+ }
+
+ /**
+ * Tests for strripos
+ *
+ * @param string $haystack String to search in
+ * @param mixed $needle Characters to search
+ * @param int $offset Start position
+ *
+ * @return void
+ * @test
+ * @dataProvider providerStrripos
+ */
+ public function testStrripos($haystack, $needle, $offset = 0)
+ {
+ $native = $this->_native->strripos($haystack, $needle, $offset);
+ $multibytes = $this->_mb->strripos($haystack, $needle, $offset);
+ $this->assertTrue(
+ $native === $multibytes,
+ 'native strripos: ' . var_export($native, true)
+ . ' - mb strripos: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testStrripos
+ *
+ * @return array Test data
+ */
+ public function providerStrripos()
+ {
+ return array(
+ array('abcdefabcdef', 'a'),
+ array('abcdefabcdef', 'a', 2),
+ array('abcdefabcdef', 'a', 10),
+ array('abcdefabcdef', 'a', -10),
+ array('abcdefabcdef', 'A'),
+ array('abcdefabcdef', 'A', 2),
+ array('abcdefabcdef', 'A', 10),
+ array('abcdefabcdef', 'A', -10),
+ array('abcdefabcdef', 'e'),
+ array('abcdefabcdef', 'e', 2),
+ array('abcdefabcdef', 'e', 10),
+ array('abcdefabcdef', 'e', -2),
+ array('abcdefabcdef', 'e'),
+ array('abcdefabcdef', 'z'),
+ array('abcdefabcdef', 'z', 2),
+ array('abcdefabcdef', 'z', -2),
+ array('abcdefabcdef', ord('a')),
+ array('abcdefabcdef', ord('a'), 2),
+ array('abcdefabcdef', ord('a'), -2),
+ array('abcdefabcdef', ord('A')),
+ array('abcdefabcdef', ord('A'), 2),
+ array('abcdefabcdef', ord('A'), -2),
+ array('abcdefabcdef', ord('e')),
+ array('abcdefabcdef', ord('e'), 2),
+ array('abcdefabcdef', ord('e'), -2),
+ array('abcdefabcdef', ord('z')),
+ array('abcdefabcdef', ord('z'), 2),
+ array('abcdefabcdef', ord('z'), -2),
+ array('abcdefabcdef', false),
+ array(false, 'a'),
+ array(false, 0),
+ array(false, 0, 1),
+ array(false, false),
+ array(true, 0),
+ array(true, 0, 1),
+ array(true, 1),
+ array(true, 1, 1),
+ array(3, 0),
+ array(3, 3),
+ array(3, '3'),
+ array('3', '3'),
+ array(null, 0),
+ array(null, false),
+ array('', 0),
+ array('', 0, 2),
+ array('', false),
+ );
+ }
+
+ /**
+ * Tests for strripos
+ *
+ * @param string $haystack String to search in
+ * @param mixed $needle Characters to search
+ * @param int $offset Start position
+ *
+ * @return void
+ * @test
+ * @dataProvider providerStrriposException
+ */
+ public function testStrriposException($haystack, $needle, $offset = 0)
+ {
+ $native = null;
+ $multibytes = null;
+ $nativeException = false;
+ $multibytesException = false;
+ try {
+ $native = $this->_native->strripos($haystack, $needle, $offset);
+ } catch (PHPUnit_Framework_Error $e) {
+ $nativeException = true;
+ }
+ try {
+ $multibytes = $this->_mb->strripos($haystack, $needle, $offset);
+ } catch (PHPUnit_Framework_Error $e) {
+ $multibytesException = true;
+ }
+
+ $this->assertTrue(
+ true === $nativeException && true === $multibytesException,
+ 'native strripos: ' . var_export($native, true)
+ . ' - mb strripos: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testStrriposException
+ *
+ * @return array Test data
+ */
+ public function providerStrriposException()
+ {
+ return array(
+ array('abcdefabcdef', 'a', 20),
+ array('abcdefabcdef', 'a', -20),
+ array('abcdefabcdef', 'e', 20),
+ array('abcdefabcdef', 'e', -20),
+ array('abcdefabcdef', 'z', 20),
+ array('abcdefabcdef', 'z', -20),
+ array('abcdefabcdef', ord('a'), 20),
+ array('abcdefabcdef', ord('e'), 20),
+ array('abcdefabcdef', ord('z'), 20),
+ array(3, 0, 2),
+ array(3, 3, 2),
+ array(3, '3', 2),
+ array('3', '3', 2),
+ );
+ }
+
+ /**
+ * Tests for strstr
+ *
+ * @param string $haystack String to search in
+ * @param mixed $needle Characters to search
+ * @param bool $before_needle Start position
+ *
+ * @return void
+ * @test
+ * @dataProvider providerStrstr
+ */
+ public function testStrstr($haystack, $needle, $before_needle = false)
+ {
+ $native = $this->_native->strstr($haystack, $needle, $before_needle);
+ $multibytes = $this->_mb->strstr($haystack, $needle, $before_needle);
+ $this->assertTrue(
+ $native === $multibytes,
+ 'native strstr: ' . var_export($native, true)
+ . ' - mb strstr: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testStrstr
+ *
+ * @return array Test data
+ */
+ public function providerStrstr()
+ {
+ return array(
+ array('abcdefabcdef', 'a'),
+ array('abcdefabcdef', 'a', true),
+ array('abcdefabcdef', 'A'),
+ array('abcdefabcdef', 'A', true),
+ array('abcdefabcdef', 97),
+ array('abcdefabcdef', 97, true),
+ array('abcdefabcdef', 65),
+ array('abcdefabcdef', 65, true),
+ array('abcdefabcdef', 'e'),
+ array('abcdefabcdef', 'e', true),
+ array('abcdefabcdef', 'z'),
+ array('abcdefabcdef', 'z', true),
+ array('abcdefabcdef', null),
+ array('abcdefabcdef', null, true),
+ array('abcdefabcdef', false),
+ array('abcdefabcdef', false, true),
+ array(false, 'a'),
+ array(false, false),
+ array(true, 0),
+ array(true, 1),
+ array(true, true),
+ array(true, true, true),
+ array(3, 0),
+ array(3, 3),
+ array(3, 3, true),
+ array(123456789, 0),
+ array(123456789, 3),
+ array(123456789, 3, true),
+ array('3', '3'),
+ array('3', '3', true),
+ array('123456789', 3),
+ array('123456789', 3, true),
+ array('123456789', 49), //ASCII 49 = 1
+ array('123456789', 49, true),
+ array(null, 0),
+ array(null, null),
+ array('', 0),
+ array('', false),
+ array('', null),
+ );
+ }
+
+ /**
+ * Tests for strstr
+ *
+ * @param string $haystack String to search in
+ * @param mixed $needle Characters to search
+ * @param bool $before_needle Start position
+ *
+ * @return void
+ * @test
+ * @dataProvider providerStrstrException
+ */
+ public function testStrstrException($haystack, $needle, $before_needle = false)
+ {
+ $native = null;
+ $multibytes = null;
+ $nativeException = false;
+ $multibytesException = false;
+ try {
+ $native = $this->_native->strstr($haystack, $needle, $before_needle);
+ } catch (PHPUnit_Framework_Error $e) {
+ $nativeException = true;
+ }
+ try {
+ $multibytes = $this->_mb->strstr($haystack, $needle, $before_needle);
+ } catch (PHPUnit_Framework_Error $e) {
+ $multibytesException = true;
+ }
+
+ $this->assertTrue(
+ true === $nativeException && true === $multibytesException,
+ 'native strstr: ' . var_export($native, true)
+ . ' - mb strstr: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testStrstrException
+ *
+ * @return array Test data
+ */
+ public function providerStrstrException()
+ {
+ return array(
+ array('abcdefabcdef', ''),
+ array('abcdefabcdef', '', true),
+ );
+ }
+
+ /**
+ * Tests for stristr
+ *
+ * @param string $haystack String to search in
+ * @param mixed $needle Characters to search
+ * @param bool $before_needle Start position
+ *
+ * @return void
+ * @test
+ * @dataProvider providerStristr
+ */
+ public function testStristr($haystack, $needle, $before_needle = false)
+ {
+ $this->markTestSkipped('Skip until hhvm implements third parameter.');
+ $native = $this->_native->stristr($haystack, $needle, $before_needle);
+ $multibytes = $this->_mb->stristr($haystack, $needle, $before_needle);
+ $this->assertTrue(
+ $native === $multibytes,
+ 'native stristr: ' . var_export($native, true)
+ . ' - mb stristr: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testStristr
+ *
+ * @return array Test data
+ */
+ public function providerStristr()
+ {
+ return array(
+ array('abcdefabcdef', 'a'),
+ array('abcdefabcdef', 'a', true),
+ array('abcdefabcdef', 'A'),
+ array('abcdefabcdef', 'A', true),
+ array('abcdefabcdef', 97),
+ array('abcdefabcdef', 97, true),
+ array('abcdefabcdef', 65),
+ array('abcdefabcdef', 65, true),
+ array('abcdefabcdef', 'e'),
+ array('abcdefabcdef', 'e', true),
+ array('abcdefabcdef', 'z'),
+ array('abcdefabcdef', 'z', true),
+ array('abcdefabcdef', null),
+ array('abcdefabcdef', null, true),
+ array('abcdefabcdef', false),
+ array('abcdefabcdef', false, true),
+ array(false, 'a'),
+ array(false, false),
+ array(true, 0),
+ array(true, 1),
+ array(true, true),
+ array(true, true, true),
+ array(3, 0),
+ array(3, 3),
+ array(3, 3, true),
+ array(123456789, 0),
+ array(123456789, 3),
+ array(123456789, 3, true),
+ array('3', '3'),
+ array('3', '3', true),
+ array('123456789', 3),
+ array('123456789', 3, true),
+ array('123456789', 49), //ASCII 49 = 1
+ array('123456789', 49, true),
+ array(null, 0),
+ array(null, null),
+ array('', 0),
+ array('', false),
+ array('', null),
+ );
+ }
+
+ /**
+ * Tests for stristr
+ *
+ * @param string $haystack String to search in
+ * @param mixed $needle Characters to search
+ * @param bool $before_needle Start position
+ *
+ * @return void
+ * @test
+ * @dataProvider providerStristrException
+ */
+ public function testStristrException($haystack, $needle, $before_needle = false)
+ {
+ $this->markTestSkipped('Skip until hhvm implements third parameter.');
+ $native = null;
+ $multibytes = null;
+ $nativeException = false;
+ $multibytesException = false;
+ try {
+ $native = $this->_native->stristr($haystack, $needle, $before_needle);
+ } catch (PHPUnit_Framework_Error $e) {
+ $nativeException = true;
+ }
+ try {
+ $multibytes = $this->_mb->stristr($haystack, $needle, $before_needle);
+ } catch (PHPUnit_Framework_Error $e) {
+ $multibytesException = true;
+ }
+
+ $this->assertTrue(
+ true === $nativeException && true === $multibytesException,
+ 'native stristr: ' . var_export($native, true)
+ . ' - mb stristr: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testStristrException
+ *
+ * @return array Test data
+ */
+ public function providerStristrException()
+ {
+ return array(
+ array('abcdefabcdef', ''),
+ array('abcdefabcdef', '', true),
+ );
+ }
+
+ /**
+ * Tests for strrchr
+ *
+ * @param string $haystack String to search in
+ * @param mixed $needle Characters to search
+ *
+ * @return void
+ * @test
+ * @dataProvider providerStrstr
+ */
+ public function testStrrchr($haystack, $needle)
+ {
+ $native = $this->_native->strrchr($haystack, $needle);
+ $multibytes = $this->_mb->strrchr($haystack, $needle);
+ $this->assertTrue(
+ $native === $multibytes,
+ 'native strrchr: ' . var_export($native, true)
+ . ' - mb strrchr: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testStrrchr
+ *
+ * @return array Test data
+ */
+ public function providerStrrchr()
+ {
+ return array(
+ array('abcdefabcdef', 'a'),
+ array('abcdefabcdef', 'A'),
+ array('abcdefabcdef', 97),
+ array('abcdefabcdef', 65),
+ array('abcdefabcdef', 'e'),
+ array('abcdefabcdef', 'z'),
+ array('abcdefabcdef', ''),
+ array('abcdefabcdef', null),
+ array('abcdefabcdef', false),
+ array(false, 'a'),
+ array(false, false),
+ array(true, 0),
+ array(true, 1),
+ array(true, true),
+ array(3, 0),
+ array(3, 3),
+ array(123456789, 0),
+ array(123456789, 3),
+ array('3', '3'),
+ array('123456789', 3),
+ array('123456789', 49), //ASCII 49 = 1
+ array(null, 0),
+ array(null, null),
+ array('', 0),
+ array('', false),
+ array('', null),
+ );
+ }
+
+ /**
+ * Tests for strtolower
+ *
+ * @param string $str Input string
+ *
+ * @return void
+ * @test
+ * @dataProvider providerCase
+ */
+ public function testStrtolower($str)
+ {
+ $native = $this->_native->strtolower($str);
+ $multibytes = $this->_mb->strtolower($str);
+ $this->assertTrue(
+ $native === $multibytes,
+ 'native strtolower: ' . var_export($native, true)
+ . ' - mb strtolower: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Tests for strtoupper
+ *
+ * @param string $str Input string
+ *
+ * @return void
+ * @test
+ * @dataProvider providerCase
+ */
+ public function testStrtoupper($str)
+ {
+ $native = $this->_native->strtoupper($str);
+ $multibytes = $this->_mb->strtoupper($str);
+ $this->assertTrue(
+ $native === $multibytes,
+ 'native strtoupper: ' . var_export($native, true)
+ . ' - mb strtoupper: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testStrtolower and testStrtoupper
+ *
+ * @return array Test data
+ */
+ public function providerCase()
+ {
+ return array(
+ array('abcdefabcdef'),
+ array('abcdefABCDEF'),
+ //array('abcdefABCDEFàéÀÉ'), //Error with those characters.
+ array('abcdefABCDEF@+12345'),
+ array(false),
+ array(true),
+ array(3),
+ array(123456789),
+ array('3'),
+ array('4k'),
+ array('4kb'),
+ array('4K'),
+ array('4KB'),
+ array('123456789'),
+ array(null),
+ array(''),
+ );
+ }
+
+ /**
+ * Tests for ord
+ *
+ * @param string $chr Input char
+ *
+ * @return void
+ * @test
+ * @dataProvider providerOrd
+ */
+ public function testOrd($chr)
+ {
+ $native = $this->_native->ord($chr);
+ $multibytes = $this->_mb->ord($chr);
+ $this->assertTrue(
+ $native === $multibytes,
+ 'native ord: ' . var_export($native, true)
+ . ' - mb ord: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testOrd
+ *
+ * @return array Test data
+ */
+ public function providerOrd()
+ {
+ return array(
+ array('a'),
+ array('A'),
+ array('az'),
+ array('AZ'),
+ array('3a'),
+ array(3),
+ array(3.1),
+ array(true),
+ array(false),
+ array(null),
+ array(''),
+ );
+ }
+
+ /**
+ * Tests for chr
+ *
+ * @param string $ascii Ascii code
+ *
+ * @return void
+ * @test
+ * @dataProvider providerChr
+ */
+ public function testChr($ascii)
+ {
+ $native = $this->_native->chr($ascii);
+ $multibytes = $this->_mb->chr($ascii);
+ $this->assertTrue(
+ $native === $multibytes,
+ 'native chr: ' . var_export($native, true)
+ . ' - mb chr: ' . var_export($multibytes, true)
+ );
+ }
+
+ /**
+ * Data provider for testChr
+ *
+ * @return array Test data
+ */
+ public function providerChr()
+ {
+ return array(
+ array('a'),
+ array('A'),
+ array('az'),
+ array('AZ'),
+ array('a3'),
+ array(3),
+ array(3.1),
+ array(false),
+ array(true),
+ array(null),
+ array(''),
+ );
+ }
+}
diff --git a/test/libraries/PMA_browse_foreigners_test.php b/test/libraries/PMA_browse_foreigners_test.php
index 574fe0612c..97a6be88ee 100644
--- a/test/libraries/PMA_browse_foreigners_test.php
+++ b/test/libraries/PMA_browse_foreigners_test.php
@@ -232,7 +232,6 @@ class PMA_BrowseForeignersTest extends PHPUnit_Framework_TestCase
*/
function testGetDescriptionAndTitle()
{
- $GLOBALS['PMA_String'] = new PMA_String();
$GLOBALS['cfg']['LimitChars'] = 30;
$desc = 'foobar<baz';
diff --git a/test/libraries/PMA_central_columns_test.php b/test/libraries/PMA_central_columns_test.php
index 49d1a56d4c..a9abff3683 100644
--- a/test/libraries/PMA_central_columns_test.php
+++ b/test/libraries/PMA_central_columns_test.php
@@ -344,6 +344,9 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase
*/
public function testPMAGetHTMLforCentralColumnsTableRow()
{
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
$row = array(
'col_name'=>'col_test',
'col_type'=>'int',
@@ -369,7 +372,7 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase
);
$this->assertContains(
PMA_getHtmlForColumnDefault(
- 1, 5, 0, strtoupper($row['col_type']), '',
+ 1, 5, 0, $pmaString->strtoupper($row['col_type']), '',
array('DefaultType'=>'NONE')
),
$result
@@ -380,7 +383,7 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase
);
$this->assertContains(
PMA_getHtmlForColumnDefault(
- 1, 5, 0, strtoupper($row['col_type']), '',
+ 1, 5, 0, $pmaString->strtoupper($row['col_type']), '',
array('DefaultType'=>'USER_DEFINED', 'DefaultValue'=>100)
),
$result_1
@@ -391,7 +394,7 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase
);
$this->assertContains(
PMA_getHtmlForColumnDefault(
- 1, 5, 0, strtoupper($row['col_type']), '',
+ 1, 5, 0, $pmaString->strtoupper($row['col_type']), '',
array('DefaultType'=>'CURRENT_TIMESTAMP')
),
$result_2
diff --git a/test/libraries/PMA_display_export_test.php b/test/libraries/PMA_display_export_test.php
index 332ca869d7..166da0d329 100644
--- a/test/libraries/PMA_display_export_test.php
+++ b/test/libraries/PMA_display_export_test.php
@@ -340,7 +340,7 @@ class PMA_DisplayExport_Test extends PHPUnit_Framework_TestCase
);
$name_attr = 'aliases[test\'_db][tables][test_&lt;b&gt;table][alias]';
- $id_attr = substr(md5($name_attr), 0, 12);
+ $id_attr = $GLOBALS['PMA_String']->substr(md5($name_attr), 0, 12);
$this->assertContains(
'<input type="text" value="" name="' . $name_attr . '" '
diff --git a/test/libraries/PMA_relation_cleanup_test.php b/test/libraries/PMA_relation_cleanup_test.php
index 6601cd743d..b2a74351c5 100644
--- a/test/libraries/PMA_relation_cleanup_test.php
+++ b/test/libraries/PMA_relation_cleanup_test.php
@@ -379,27 +379,30 @@ class DBI_PMA_Relation_Cleanup extends PMA_DatabaseInterface
*/
function query($sql, $link = null, $options = 0, $cache_affected_rows = true)
{
- if (stripos($sql, "column_info") !== false) {
+ /** @var PMA_String $pmaString */
+ $pmaString = $GLOBALS['PMA_String'];
+
+ if ($pmaString->stripos($sql, "column_info") !== false) {
unset($this->values[$this->indexs['column_info']]);
}
- if (stripos($sql, "table_info") !== false) {
+ if ($pmaString->stripos($sql, "table_info") !== false) {
unset ($this->values[$this->indexs['table_info']]);
}
- if (stripos($sql, "table_coords") !== false) {
+ if ($pmaString->stripos($sql, "table_coords") !== false) {
unset($this->values[$this->indexs['table_coords']]);
}
- if (stripos($sql, "relation") !== false) {
+ if ($pmaString->stripos($sql, "relation") !== false) {
unset($this->values[$this->indexs['relation']]);
}
- if (stripos($sql, "pdf_pages") !== false) {
+ if ($pmaString->stripos($sql, "pdf_pages") !== false) {
unset($GLOBALS [$this->indexs['pdf_pages']]);
}
- if (stripos($sql, "bookmark") !== false) {
+ if ($pmaString->stripos($sql, "bookmark") !== false) {
unset($GLOBALS [$this->indexs['bookmark']]);
}
return true;
diff --git a/test/libraries/core/PMA_warnMissingExtension_test.php b/test/libraries/core/PMA_warnMissingExtension_test.php
index 9eff0f11d7..1cf4f28307 100644
--- a/test/libraries/core/PMA_warnMissingExtension_test.php
+++ b/test/libraries/core/PMA_warnMissingExtension_test.php
@@ -89,6 +89,6 @@ class PMA_WarnMissingExtension_Test extends PHPUnit_Framework_TestCase
$printed = ob_get_contents();
ob_end_clean();
- $this->assertGreaterThan(0, strpos($printed, $warn));
+ $this->assertGreaterThan(0, $GLOBALS['PMA_String']->strpos($printed, $warn));
}
}
diff --git a/test/selenium/PmaSeleniumTableInsertTest.php b/test/selenium/PmaSeleniumTableInsertTest.php
index 48e1882134..965ba1bff1 100644
--- a/test/selenium/PmaSeleniumTableInsertTest.php
+++ b/test/selenium/PmaSeleniumTableInsertTest.php
@@ -58,7 +58,7 @@ class PMA_SeleniumTableInsertTest extends PMA_SeleniumBase
*/
public function testAddData()
{
- if (strtolower($this->getBrowser()) == 'safari') {
+ if ($GLOBALS['PMA_String']->strtolower($this->getBrowser()) == 'safari') {
/* TODO: this should be fixed, but the cause is unclear to me */
$this->markTestIncomplete('Fails with Safari');
}
diff --git a/test/selenium/PmaSeleniumXssTest.php b/test/selenium/PmaSeleniumXssTest.php
index 5579b981fc..a1150dbe6a 100644
--- a/test/selenium/PmaSeleniumXssTest.php
+++ b/test/selenium/PmaSeleniumXssTest.php
@@ -27,7 +27,7 @@ class PMA_SeleniumXSSTest extends PMA_SeleniumBase
*/
public function testQueryTabWithNullValue()
{
- if (strtolower($this->getBrowser()) == 'safari') {
+ if ($GLOBALS['PMA_String']->strtolower($this->getBrowser()) == 'safari') {
$this->markTestSkipped('Alerts not supported on Safari browser.');
}
$this->login();
diff --git a/test/selenium/TestBase.php b/test/selenium/TestBase.php
index 30d3436442..e1bb2687f2 100644
--- a/test/selenium/TestBase.php
+++ b/test/selenium/TestBase.php
@@ -156,6 +156,8 @@ abstract class PMA_SeleniumBase extends PHPUnit_Extensions_Selenium2TestCase
* Configures the selenium and database link.
*
* @return void
+ *
+ * @throws Exception
*/
protected function setUp()
{
@@ -184,7 +186,7 @@ abstract class PMA_SeleniumBase extends PHPUnit_Extensions_Selenium2TestCase
);
}
$this->database_name = $GLOBALS['TESTSUITE_DATABASE']
- . substr(md5(rand()), 0, 7);
+ . $GLOBALS['PMA_String']->substr(md5(rand()), 0, 7);
$this->dbQuery(
'CREATE DATABASE IF NOT EXISTS ' . $this->database_name
);
@@ -461,7 +463,7 @@ abstract class PMA_SeleniumBase extends PHPUnit_Extensions_Selenium2TestCase
* Not supported in Safari Webdriver, see
* http://code.google.com/p/selenium/issues/detail?id=4136
*/
- if (strtolower($this->getBrowser()) == 'safari') {
+ if ($GLOBALS['PMA_String']->strtolower($this->getBrowser()) == 'safari') {
$this->markTestSkipped('Can not send keys to Safari browser.');
}
parent::keys($text);
@@ -481,7 +483,7 @@ abstract class PMA_SeleniumBase extends PHPUnit_Extensions_Selenium2TestCase
* Not supported in Safari Webdriver, see
* http://code.google.com/p/selenium/issues/detail?id=4136
*/
- if (strtolower($this->getBrowser()) == 'safari') {
+ if ($GLOBALS['PMA_String']->strtolower($this->getBrowser()) == 'safari') {
$this->markTestSkipped('MoveTo not supported on Safari browser.');
}
parent::moveto($element);
@@ -499,7 +501,7 @@ abstract class PMA_SeleniumBase extends PHPUnit_Extensions_Selenium2TestCase
* Not supported in Safari Webdriver, see
* http://code.google.com/p/selenium/issues/detail?id=4136
*/
- if (strtolower($this->getBrowser()) == 'safari') {
+ if ($GLOBALS['PMA_String']->strtolower($this->getBrowser()) == 'safari') {
$this->markTestSkipped('Alerts not supported on Safari browser.');
}
return parent::alertText();
@@ -518,7 +520,7 @@ abstract class PMA_SeleniumBase extends PHPUnit_Extensions_Selenium2TestCase
* Firefox needs some escaping of a text, see
* http://code.google.com/p/selenium/issues/detail?id=1723
*/
- if (strtolower($this->getBrowser()) == 'firefox') {
+ if ($GLOBALS['PMA_String']->strtolower($this->getBrowser()) == 'firefox') {
$text = str_replace(
"(",
PHPUnit_Extensions_Selenium2TestCase_Keys::SHIFT
diff --git a/themes/svg_gradient.php b/themes/svg_gradient.php
index 7e49037293..bebb691f8d 100644
--- a/themes/svg_gradient.php
+++ b/themes/svg_gradient.php
@@ -17,7 +17,7 @@ header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 3600) . ' GMT');
*/
function PMA_gradientGetColor($get_name, $default)
{
- // get color from GET args, only alphanumeric chcracters
+ // get color from GET args, only alphanumeric characters
$opts = array('options' => array('regexp' => '/^[a-z0-9]+$/i'));
$color = filter_input(INPUT_GET, $get_name, FILTER_VALIDATE_REGEXP, $opts);
if (preg_match('/^[a-f0-9]{6}$/', $color)) {
diff --git a/transformation_wrapper.php b/transformation_wrapper.php
index ac0b04973d..f1462143bc 100644
--- a/transformation_wrapper.php
+++ b/transformation_wrapper.php
@@ -77,7 +77,7 @@ if ($cfgRelation['commwork'] && $cfgRelation['mimework']) {
);
foreach ($mime_options as $key => $option) {
- if (substr($option, 0, 10) == '; charset=') {
+ if ($GLOBALS['PMA_String']->substr($option, 0, 10) == '; charset=') {
$mime_options['charset'] = $option;
}
}