Skip to content

Commit 8f9e5b0

Browse files
committed
Remove stuff only needed for PHP versions we don't support, fix some whitespace, and fix the unsupported PostgreSQL message output.
1 parent a9f887a commit 8f9e5b0

File tree

4 files changed

+40
-86
lines changed

4 files changed

+40
-86
lines changed

classes/Misc.php

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Misc {
1212
var $form;
1313

1414
/* Constructor */
15-
function __construct() {
15+
function __construct() {
1616
}
1717

1818
/**
@@ -417,30 +417,6 @@ function printVal($str, $type = null, $params = array()) {
417417
return $out;
418418
}
419419

420-
/**
421-
* A function to recursively strip slashes. Used to
422-
* enforce magic_quotes_gpc being off.
423-
* @param &var The variable to strip
424-
*/
425-
function stripVar(&$var) {
426-
if (is_array($var)) {
427-
foreach($var as $k => $v) {
428-
$this->stripVar($var[$k]);
429-
430-
/* magic_quotes_gpc escape keys as well ...*/
431-
if (is_string($k)) {
432-
$ek = stripslashes($k);
433-
if ($ek !== $k) {
434-
$var[$ek] = $var[$k];
435-
unset($var[$k]);
436-
}
437-
}
438-
}
439-
}
440-
else
441-
$var = stripslashes($var);
442-
}
443-
444420
/**
445421
* Print out the page heading and help link
446422
* @param $title Title, already escaped
@@ -466,7 +442,7 @@ function printMsg($msg) {
466442
* Creates a database accessor
467443
*/
468444
function getDatabaseAccessor($database, $server_id = null) {
469-
global $lang, $conf, $misc, $_connection;
445+
global $lang, $conf, $misc, $_connection, $postgresqlMinVer;
470446

471447
$server_info = $this->getServerInfo($server_id);
472448

classes/database/Connection.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ function __construct($host, $port, $sslmode, $user, $password, $database, $fetch
5151
* @return -3 Database-specific failure
5252
*/
5353
function getDriver(&$description) {
54-
5554
$v = pg_version($this->conn->_connectionID);
5655
if (isset($v['server'])) $version = $v['server'];
5756

libraries/lib.inc.php

Lines changed: 32 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
$appVersion = '7.14.1-mod';
2020

2121
// PostgreSQL and PHP minimum version
22+
global $postgresqlMinVer;
2223
$postgresqlMinVer = '7.4';
2324
$phpMinVer = '7.2';
2425

@@ -50,52 +51,43 @@
5051
require_once('./classes/Misc.php');
5152
$misc = new Misc();
5253

53-
// Session start: if extra_session_security is on, make sure cookie_samesite
54-
// is on (exit if we fail); otherwise, just start the session
55-
$our_session_name = 'PPA_ID';
56-
if ($conf['extra_session_security']) {
57-
if (version_compare(phpversion(), '7.3', '<')) {
58-
exit('PHPPgAdmin cannot be fully secured while running under PHP versions before 7.3. Please upgrade PHP if possible. If you cannot upgrade, and you\'re willing to assume the risk of CSRF attacks, you can change the value of "extra_session_security" to false in your config.inc.php file.');
59-
}
60-
if (ini_get('session.auto_start')) {
61-
// If session.auto_start is on, and the session doesn't have
62-
// session.cookie_samesite set, destroy and re-create the session
63-
if (session_name() !== $our_session_name) {
64-
$setting = strtolower(ini_get('session.cookie_samesite'));
65-
if ($setting !== 'lax' && $setting !== 'strict') {
66-
session_destroy();
67-
session_name($our_session_name);
68-
ini_set('session.cookie_samesite', 'Strict');
69-
session_start();
70-
}
71-
}
72-
} else {
73-
session_name($our_session_name);
74-
ini_set('session.cookie_samesite', 'Strict');
75-
session_start();
76-
}
77-
} else {
78-
if (!ini_get('session.auto_start')) {
79-
session_name($our_session_name);
80-
session_start();
81-
}
82-
}
83-
84-
// Do basic PHP configuration checks
85-
if (ini_get('magic_quotes_gpc')) {
86-
$misc->stripVar($_GET);
87-
$misc->stripVar($_POST);
88-
$misc->stripVar($_COOKIE);
89-
$misc->stripVar($_REQUEST);
54+
// Session start: if extra_session_security is on, make sure cookie_samesite
55+
// is on (exit if we fail); otherwise, just start the session
56+
$our_session_name = 'PPA_ID';
57+
if ($conf['extra_session_security']) {
58+
if (version_compare(phpversion(), '7.3', '<')) {
59+
exit('PHPPgAdmin cannot be fully secured while running under PHP versions before 7.3. Please upgrade PHP if possible. If you cannot upgrade, and you\'re willing to assume the risk of CSRF attacks, you can change the value of "extra_session_security" to false in your config.inc.php file.');
60+
}
61+
62+
if (ini_get('session.auto_start')) {
63+
// If session.auto_start is on, and the session doesn't have
64+
// session.cookie_samesite set, destroy and re-create the session
65+
if (session_name() !== $our_session_name) {
66+
$setting = strtolower(ini_get('session.cookie_samesite'));
67+
68+
if ($setting !== 'lax' && $setting !== 'strict') {
69+
session_destroy();
70+
session_name($our_session_name);
71+
ini_set('session.cookie_samesite', 'Strict');
72+
session_start();
73+
}
74+
}
75+
} else {
76+
session_name($our_session_name);
77+
ini_set('session.cookie_samesite', 'Strict');
78+
session_start();
79+
}
80+
} else {
81+
if (!ini_get('session.auto_start')) {
82+
session_name($our_session_name);
83+
session_start();
84+
}
9085
}
9186

92-
// This has to be deferred until after stripVar above
9387
$misc->setHREF();
9488
$misc->setForm();
9589

9690
// Enforce PHP environment
97-
ini_set('magic_quotes_runtime', 0);
98-
ini_set('magic_quotes_sybase', 0);
9991
ini_set('arg_separator.output', '&amp;');
10092

10193
// If login action is set, then set session variables
@@ -293,11 +285,4 @@
293285
}
294286
}
295287

296-
if (!function_exists("htmlspecialchars_decode")) {
297-
function htmlspecialchars_decode($string, $quote_style = ENT_COMPAT) {
298-
return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)));
299-
}
300-
}
301-
302288
$plugin_manager = new PluginManager($_language);
303-
?>

redirect.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
2-
$subject = isset($_REQUEST['subject']) ? $_REQUEST['subject'] : 'root';
3-
2+
$subject = isset($_REQUEST['subject']) ? $_REQUEST['subject'] : 'root';
3+
44
if ($subject == 'root')
55
$_no_db_connection = true;
6-
6+
77
include_once('./libraries/lib.inc.php');
8-
8+
99
$url = $misc->getLastTabURL($subject);
10-
10+
1111
// Load query vars into superglobal arrays
1212
if (isset($url['urlvars'])) {
1313
$urlvars = array();
@@ -16,14 +16,8 @@
1616
$urlvars[$k] = value($urlvar, $_REQUEST);
1717
}
1818

19-
/* parse_str function is affected by magic_quotes_gpc */
20-
if (ini_get('magic_quotes_gpc')) {
21-
$misc->stripVar($urlvars);
22-
}
23-
2419
$_REQUEST = array_merge($_REQUEST, $urlvars);
2520
$_GET = array_merge($_GET, $urlvars);
2621
}
27-
22+
2823
require $url['url'];
29-
?>

0 commit comments

Comments
 (0)