fix PHP 8.0 Fatal error unknown function get_magic_quotes_gpc

This commit is contained in:
Ralf Becker 2021-03-21 18:27:09 +01:00
parent dac55616af
commit ffc048d472
14 changed files with 28 additions and 17 deletions

View File

@ -57,7 +57,7 @@ class uiconfig
Api\Translation::add_app($_appname);
}
if(get_magic_quotes_gpc() && is_array($_POST['newsettings']))
if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() && is_array($_POST['newsettings']))
{
$_POST['newsettings'] = array_stripslashes($_POST['newsettings']);
}

View File

@ -34,7 +34,7 @@ class Pam implements Backend
{
unset($passwd_type); // not used but required by interface
if (pam_auth($username, get_magic_quotes_gpc() ? stripslashes($passwd) : $passwd))
if (pam_auth($username, function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() ? stripslashes($passwd) : $passwd))
{
// for new accounts read full name from password file and pass it to EGroupware
if (!$GLOBALS['egw']->accounts->name2id($username) &&

View File

@ -470,7 +470,7 @@ class Etemplate extends Etemplate\Widget\Template
*/
static public function process_exec()
{
if (get_magic_quotes_gpc()) $_POST['value'] = stripslashes($_POST['value']);
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) $_POST['value'] = stripslashes($_POST['value']);
$content = json_decode($_POST['value'],true);
//error_log(__METHOD__."(".array2string($content).")");

View File

@ -38,7 +38,7 @@ if(!isset($_SESSION['token'])){
}
// slashes
if(get_magic_quotes_gpc()){
if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()){
foreach($_POST as $k => $v){
$_POST[$k] = stripslashes($v);
}

View File

@ -69,7 +69,7 @@ class Request
}
else
{
if (get_magic_quotes_gpc()) $input_data = stripslashes($input_data);
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) $input_data = stripslashes($input_data);
if (($json_data = json_decode($input_data,true)) === null && json_last_error() !== JSON_ERROR_NONE)
{

View File

@ -4421,7 +4421,7 @@ class Mail
//if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) Mail\Html::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); // Strip out stuff in ifs
//error_log(__METHOD__.' ('.__LINE__.') '.$_html);
if (get_magic_quotes_gpc() === 1) $_html = stripslashes($_html);
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() === 1) $_html = stripslashes($_html);
// Strip out doctype in head, as htmlLawed cannot handle it TODO: Consider extracting it and adding it afterwards
if (stripos($_html,'!doctype')!==false) Mail\Html::replaceTagsCompletley($_html,'!doctype');
if (stripos($_html,'?xml:namespace')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml:namespace','/>',false);

View File

@ -17,6 +17,17 @@ use EGroupware\Api;
require_once dirname(__DIR__).'/autoload.php';
/**
* To ease PHP 8.0 migration
*/
if (!function_exists('get_magic_quotes_gpc'))
{
function get_magic_quotes_gpc()
{
return false;
}
}
/**
* applies stripslashes recursivly on each element of an array
*

View File

@ -22,7 +22,7 @@ $GLOBALS['egw_info']['flags'] = array(
include ('../header.inc.php');
// strip slashes from _GET parameters, if someone still has magic_quotes_gpc on
if (get_magic_quotes_gpc() && $_GET)
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() && $_GET)
{
$_GET = array_stripslashes($_GET);
}

View File

@ -59,7 +59,7 @@ class filemanager_select
function __construct()
{
// strip slashes from _GET parameters, if someone still has magic_quotes_gpc on
if (get_magic_quotes_gpc() && $_GET)
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() && $_GET)
{
$_GET = array_stripslashes($_GET);
}

View File

@ -58,7 +58,7 @@ class filemanager_ui
function __construct()
{
// strip slashes from _GET parameters, if someone still has magic_quotes_gpc on
if (get_magic_quotes_gpc() && $_GET)
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() && $_GET)
{
$_GET = array_stripslashes($_GET);
}

View File

@ -113,7 +113,7 @@ else
{
$_SERVER['PHP_AUTH_USER'] = $_SERVER['REMOTE_USER'];
}
$passwd = get_magic_quotes_gpc() ? stripslashes($_POST['passwd']) : $_POST['passwd'];
$passwd = function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() ? stripslashes($_POST['passwd']) : $_POST['passwd'];
$passwd_type = $_POST['passwd_type'];
// forced password change

View File

@ -3493,7 +3493,7 @@ class mail_compose
function stripSlashes($_string)
{
if (get_magic_quotes_gpc()) {
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
return stripslashes($_string);
} else {
return $_string;

View File

@ -549,7 +549,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
$toCount = 0;
//error_log(__METHOD__.__LINE__.array2string($toMailAddr));
foreach((array)$toMailAddr as $address) {
foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
foreach(Mail::parseAddressList((function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' &&
calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST',
@ -564,7 +564,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
}
$ccCount = 0;
foreach((array)$ccMailAddr as $address) {
foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
foreach(Mail::parseAddressList((function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue;
$mailObject->AddCC($emailAddress, $addressObject->personal);
@ -573,7 +573,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
}
$bccCount = 0;
foreach((array)$bccMailAddr as $address) {
foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
foreach(Mail::parseAddressList((function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue;
$mailObject->AddBCC($emailAddress, $addressObject->personal);
@ -800,7 +800,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
}
if (count($folderArray) > 0) {
foreach((array)$bccMailAddr as $address) {
foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
foreach(Mail::parseAddressList((function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
$emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
$mailAddr[] = array($emailAddress, $addressObject->personal);
}

View File

@ -161,7 +161,7 @@ function check_header_form()
// setting the non-domain settings from the posted content
foreach($_POST['setting'] as $name => $value)
{
if (get_magic_quotes_gpc()) $value = stripslashes($value);
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) $value = stripslashes($value);
switch($name)
{
@ -191,7 +191,7 @@ function check_header_form()
foreach($_POST['setting_'.$key] as $name => $value)
{
if (get_magic_quotes_gpc()) $value = stripslashes($value);
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) $value = stripslashes($value);
if ($name == 'new_config_passwd')
{