1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-06 22:56:46 +02:00

Ensure PHP 5.3 compatibility

This commit is contained in:
Jakub Vrana
2025-03-11 21:43:59 +01:00
parent dc2e945aef
commit 2fdebfda29
6 changed files with 19 additions and 10 deletions

View File

@@ -83,17 +83,18 @@ if ($_POST && !process_fields($row["fields"]) && !$error) {
$partitioning = ""; $partitioning = "";
if (support("partitioning")) { if (support("partitioning")) {
if (isset($partition_by[$row["partition_by"]])) { if (isset($partition_by[$row["partition_by"]])) {
$params = array_filter($row, function ($key) { $params = array();
return preg_match('~^partition~', $key); foreach ($row as $key => $val) {
}, ARRAY_FILTER_USE_KEY); if (preg_match('~^partition~', $key)) {
$params[$key] = $val;
}
}
foreach ($params["partition_names"] as $key => $name) { foreach ($params["partition_names"] as $key => $name) {
if ($name == "") { if ($name == "") {
unset($params["partition_names"][$key]); unset($params["partition_names"][$key]);
unset($params["partition_values"][$key]); unset($params["partition_values"][$key]);
} }
} }
if ($params != get_partitions_info($TABLE)) { if ($params != get_partitions_info($TABLE)) {
$partitions = array(); $partitions = array();
if ($params["partition_by"] == 'RANGE' || $params["partition_by"] == 'LIST') { if ($params["partition_by"] == 'RANGE' || $params["partition_by"] == 'LIST') {
@@ -102,7 +103,6 @@ if ($_POST && !process_fields($row["fields"]) && !$error) {
$partitions[] = "\n PARTITION " . idf_escape($name) . " VALUES " . ($params["partition_by"] == 'RANGE' ? "LESS THAN" : "IN") . ($value != "" ? " ($value)" : " MAXVALUE"); //! SQL injection $partitions[] = "\n PARTITION " . idf_escape($name) . " VALUES " . ($params["partition_by"] == 'RANGE' ? "LESS THAN" : "IN") . ($value != "" ? " ($value)" : " MAXVALUE"); //! SQL injection
} }
} }
// $params["partition"] can be expression, not only column // $params["partition"] can be expression, not only column
$partitioning .= "\nPARTITION BY $params[partition_by]($params[partition])"; $partitioning .= "\nPARTITION BY $params[partition_by]($params[partition])";
if ($partitions) { if ($partitions) {

View File

@@ -43,7 +43,10 @@ if (isset($_GET["pgsql"])) {
} }
function quote($string) { function quote($string) {
return pg_escape_literal($this->link, $string); return (function_exists('pg_escape_literal')
? pg_escape_literal($this->link, $string) // available since PHP 5.4.4
: "'" . pg_escape_string($this->link, $string) . "'"
);
} }
function value($val, $field) { function value($val, $field) {

View File

@@ -78,7 +78,7 @@ if (isset($_GET["sqlite"])) {
); );
} }
function __desctruct() { function __destruct() {
return $this->result->finalize(); return $this->result->finalize();
} }
} }

View File

@@ -62,7 +62,6 @@ if (function_exists("get_magic_quotes_runtime") && get_magic_quotes_runtime()) {
set_magic_quotes_runtime(false); set_magic_quotes_runtime(false);
} }
@set_time_limit(0); // @ - can be disabled @set_time_limit(0); // @ - can be disabled
@ini_set("zend.ze1_compatibility_mode", false); // @ - deprecated
@ini_set("precision", 15); // @ - can be disabled, 15 - internal PHP precision @ini_set("precision", 15); // @ - can be disabled, 15 - internal PHP precision
include "../adminer/include/lang.inc.php"; include "../adminer/include/lang.inc.php";

View File

@@ -108,4 +108,11 @@
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/> <rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/> <rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing"/> <rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing"/>
<!--
This is slow and has false positives but it's useful occasionally.
https://github.com/PHPCompatibility/PHPCompatibility
<rule ref="PHPCompatibility"/>
<config name="testVersion" value="5.3-"/>
-->
</ruleset> </ruleset>

View File

@@ -422,7 +422,7 @@ if (isset($_GET["simpledb"])) {
'max_redirects' => 0, 'max_redirects' => 0,
)))); ))));
if (!$file) { if (!$file) {
$this->error = lang('Invalid credentials.'); $connection->error = lang('Invalid credentials.');
return false; return false;
} }
libxml_use_internal_errors(true); libxml_use_internal_errors(true);