Don't suppress functions

This commit is contained in:
djmaze 2020-03-20 15:29:52 +01:00
parent 1009398d0c
commit 559ebe0f28
28 changed files with 244 additions and 265 deletions

View file

@ -64,7 +64,7 @@ abstract class HtmlUtils
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('libxml_clear_errors'))
{
@\libxml_clear_errors();
\libxml_clear_errors();
}
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('libxml_use_internal_errors'))

View file

@ -17,19 +17,6 @@ namespace MailSo\Base;
*/
class Http
{
/**
* @var bool
*/
private $bIsMagicQuotesOn;
/**
* @access private
*/
private function __construct()
{
$this->bIsMagicQuotesOn = (bool) @\ini_get('magic_quotes_gpc');
}
public static function NewInstance() : self
{
return new self();
@ -181,7 +168,7 @@ class Http
static $sRawBody = null;
if (null === $sRawBody)
{
$sBody = @\file_get_contents('php://input');
$sBody = \file_get_contents('php://input');
$sRawBody = (false !== $sBody) ? $sBody : '';
}
return $sRawBody;
@ -338,7 +325,7 @@ class Http
static public function DetectAndHackFollowLocationUrl(string $sUrl, array &$aOptions, ?\MailSo\Log\Logger $oLogger = null) : string
{
$sSafeMode = \strtolower(\trim(@\ini_get('safe_mode')));
$sSafeMode = \strtolower(\trim(\ini_get('safe_mode')));
$bSafeMode = 'on' === $sSafeMode || '1' === $sSafeMode;
$sNewUrl = null;
@ -537,10 +524,10 @@ class Http
{
if ($bSetCacheHeader)
{
@\header('Cache-Control: public', true);
@\header('Pragma: public', true);
@\header('Last-Modified: '.\gmdate('D, d M Y H:i:s', $iUtcTimeStamp - $iExpireTime).' UTC', true);
@\header('Expires: '.\gmdate('D, j M Y H:i:s', $iUtcTimeStamp + $iExpireTime).' UTC', true);
\header('Cache-Control: public', true);
\header('Pragma: public', true);
\header('Last-Modified: '.\gmdate('D, d M Y H:i:s', $iUtcTimeStamp - $iExpireTime).' UTC', true);
\header('Expires: '.\gmdate('D, j M Y H:i:s', $iUtcTimeStamp + $iExpireTime).' UTC', true);
if (0 < strlen($sEtag))
{
@ -567,11 +554,11 @@ class Http
if (false === $bCache)
{
$bCache = true;
@\header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
@\header('Last-Modified: '.\gmdate('D, d M Y H:i:s').' GMT');
@\header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
@\header('Cache-Control: post-check=0, pre-check=0', false);
@\header('Pragma: no-cache');
\header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
\header('Last-Modified: '.\gmdate('D, d M Y H:i:s').' GMT');
\header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
\header('Cache-Control: post-check=0, pre-check=0', false);
\header('Pragma: no-cache');
}
}
@ -584,10 +571,10 @@ class Http
if (false === $bCache)
{
$bCache = true;
@\header('Cache-Control: private', true);
@\header('ETag: '.$sEtag, true);
@\header('Last-Modified: '.\gmdate('D, d M Y H:i:s', $iLastModified).' UTC', true);
@\header('Expires: '.\gmdate('D, j M Y H:i:s', $iExpires).' UTC', true);
\header('Cache-Control: private', true);
\header('ETag: '.$sEtag, true);
\header('Last-Modified: '.\gmdate('D, d M Y H:i:s', $iLastModified).' UTC', true);
\header('Expires: '.\gmdate('D, j M Y H:i:s', $iExpires).' UTC', true);
}
}

View file

@ -149,7 +149,7 @@ class LinkFinder
$sResult = '';
if ($bUseHtmlSpecialChars)
{
$sResult = @\htmlentities($sText.$sSubText, $this->iHtmlSpecialCharsFlags, 'UTF-8');
$sResult = \htmlentities($sText.$sSubText, $this->iHtmlSpecialCharsFlags, 'UTF-8');
}
else
{

View file

@ -57,7 +57,7 @@ abstract class ResourceRegistry
{
self::regResourcesShutdownFunc();
$oResult = @\fopen('php://temp/maxmemory:'.($iMemoryMaxInMb * 1024 * 1024), 'r+b');
$oResult = \fopen('php://temp/maxmemory:'.($iMemoryMaxInMb * 1024 * 1024), 'r+b');
if (\is_resource($oResult))
{
\MailSo\Base\Loader::IncStatistic('CreateMemoryResource');

View file

@ -106,7 +106,7 @@ class Literal
$iRead = $iCount;
while (0 < $iRead)
{
$sAddRead = @fread($this->rStream, $iRead);
$sAddRead = fread($this->rStream, $iRead);
if (false === $sAddRead)
{
$sReadResult = false;

View file

@ -147,7 +147,7 @@ class SubStreams
{
if (!\feof($mCurrentPart))
{
$sReadResult = @\fread($mCurrentPart, 8192);
$sReadResult = \fread($mCurrentPart, 8192);
if (false === $sReadResult)
{
return false;

View file

@ -117,7 +117,7 @@ END;
public static function DetectSystemCharset() : string
{
$sResult = '';
$sLocale = @\setlocale(LC_ALL, '');
$sLocale = \setlocale(LC_ALL, '');
$sLocaleLower = \strtolower(\trim($sLocale));
foreach (static::$aLocaleMapping as $sKey => $sValue)
@ -464,7 +464,7 @@ END;
{
if (isset($aMatch[0][$iIndex]))
{
$iPos = @\strpos($aMatch[0][$iIndex], '*');
$iPos = \strpos($aMatch[0][$iIndex], '*');
if (false !== $iPos)
{
$aMatch[0][$iIndex][0] = \substr($aMatch[0][$iIndex][0], 0, $iPos);
@ -985,7 +985,7 @@ END;
{
$iResetTimer = 0;
$sSafeMode = \strtolower(\trim(@\ini_get('safe_mode')));
$sSafeMode = \strtolower(\trim(\ini_get('safe_mode')));
$bSafeMode = 'on' === $sSafeMode || '1' === $sSafeMode || 'true' === $sSafeMode;
$bValidateAction = !$bSafeMode && static::FunctionExistsAndEnabled('set_time_limit');
@ -994,7 +994,7 @@ END;
if ($bValidateAction && $iTimeToReset < $iTime - $iResetTimer)
{
$iResetTimer = $iTime;
if (!@\set_time_limit($iTimeToAdd))
if (!\set_time_limit($iTimeToAdd))
{
$bValidateAction = false;
return false;
@ -1041,13 +1041,7 @@ END;
*/
public static function Php2js($mInput, ?\MailSo\Log\Logger $oLogger = null) : string
{
static $iOpt = null;
if (null === $iOpt)
{
$iOpt = \defined('JSON_UNESCAPED_UNICODE') ? JSON_UNESCAPED_UNICODE : 0;
}
$sResult = @\json_encode($mInput, $iOpt);
$sResult = \json_encode($mInput, JSON_UNESCAPED_UNICODE);
if (!\is_string($sResult) || '' === $sResult)
{
if (!$oLogger && \MailSo\Log\Logger::IsSystemEnabled())
@ -1078,7 +1072,7 @@ END;
}
static::ClearArrayUtf8Values($mInput);
$sResult = @\json_encode($mInput, $iOpt);
$sResult = \json_encode($mInput, JSON_UNESCAPED_UNICODE);
}
}
@ -1106,7 +1100,7 @@ END;
public static function RecRmDir(string $sDir) : bool
{
if (@\is_dir($sDir))
if (\is_dir($sDir))
{
$aObjects = \scandir($sDir);
foreach ($aObjects as $sObject)
@ -1120,12 +1114,12 @@ END;
}
else
{
@\unlink($sDir.'/'.$sObject);
\unlink($sDir.'/'.$sObject);
}
}
}
return @\rmdir($sDir);
return \rmdir($sDir);
}
return false;
@ -1170,17 +1164,17 @@ END;
$iFileCount = 0;
$sTempPath = rtrim($sTempPath, '\\/');
if (@\is_dir($sTempPath))
if (\is_dir($sTempPath))
{
$rDirH = @\opendir($sTempPath);
$rDirH = \opendir($sTempPath);
if ($rDirH)
{
$bRemoveAllDirs = true;
while (($sFile = @\readdir($rDirH)) !== false)
while (($sFile = \readdir($rDirH)) !== false)
{
if ('.' !== $sFile && '..' !== $sFile)
{
if (@\is_dir($sTempPath.'/'.$sFile))
if (\is_dir($sTempPath.'/'.$sFile))
{
if (!static::RecTimeDirRemove($sTempPath.'/'.$sFile, $iTime2Kill, $iNow))
{
@ -1194,19 +1188,19 @@ END;
}
}
@\closedir($rDirH);
\closedir($rDirH);
}
if ($iFileCount > 0)
{
if (static::TimeFilesRemove($sTempPath, $iTime2Kill, $iNow))
{
return @\rmdir($sTempPath);
return \rmdir($sTempPath);
}
}
else
{
return $bRemoveAllDirs ? @\rmdir($sTempPath) : false;
return $bRemoveAllDirs ? \rmdir($sTempPath) : false;
}
return false;
@ -1220,18 +1214,18 @@ END;
$bResult = true;
$sTempPath = rtrim($sTempPath, '\\/');
if (@\is_dir($sTempPath))
if (\is_dir($sTempPath))
{
$rDirH = @\opendir($sTempPath);
$rDirH = \opendir($sTempPath);
if ($rDirH)
{
while (($sFile = @\readdir($rDirH)) !== false)
while (($sFile = \readdir($rDirH)) !== false)
{
if ($sFile !== '.' && $sFile !== '..')
{
if ($iNow - \filemtime($sTempPath.'/'.$sFile) > $iTime2Kill)
{
@\unlink($sTempPath.'/'.$sFile);
\unlink($sTempPath.'/'.$sFile);
}
else
{
@ -1240,7 +1234,7 @@ END;
}
}
@\closedir($rDirH);
\closedir($rDirH);
}
}
@ -1417,7 +1411,7 @@ END;
{
while (!\feof($fResource))
{
$sBuffer = @\fread($fResource, $iBufferLen);
$sBuffer = \fread($fResource, $iBufferLen);
if (false !== $sBuffer)
{
echo $sBuffer;
@ -1487,7 +1481,7 @@ END;
{
if (\is_resource($rWriteStream))
{
@\rewind($rWriteStream);
\rewind($rWriteStream);
}
}
}
@ -1800,7 +1794,7 @@ END;
if (null === $aCache)
{
$sDisableFunctions = @\ini_get('disable_functions');
$sDisableFunctions = \ini_get('disable_functions');
$sDisableFunctions = \is_string($sDisableFunctions) && 0 < \strlen($sDisableFunctions) ? $sDisableFunctions : '';
$aCache = \explode(',', $sDisableFunctions);
@ -1808,7 +1802,7 @@ END;
if (\extension_loaded('suhosin'))
{
$sSuhosin = @\ini_get('suhosin.executor.func.blacklist');
$sSuhosin = \ini_get('suhosin.executor.func.blacklist');
$sSuhosin = \is_string($sSuhosin) && 0 < \strlen($sSuhosin) ? $sSuhosin : '';
$aSuhosinCache = \explode(',', $sSuhosin);
@ -1869,7 +1863,7 @@ END;
public static function ValidateIP(string $sIp) : bool
{
return !empty($sIp) && $sIp === @\filter_var($sIp, FILTER_VALIDATE_IP);
return !empty($sIp) && $sIp === \filter_var($sIp, FILTER_VALIDATE_IP);
}
private static function idn() : \Net

View file

@ -99,9 +99,9 @@ class File implements \MailSo\Cache\DriverInterface
$sFilePath = $this->sCacheFolder.$this->sKeyPrefix.$sKeyPath;
if ($bMkDir && !\is_dir(\dirname($sFilePath)))
{
if (!@\mkdir(\dirname($sFilePath), 0755, true))
if (!\mkdir(\dirname($sFilePath), 0755, true))
{
if (!@\mkdir(\dirname($sFilePath), 0755, true))
if (!\mkdir(\dirname($sFilePath), 0755, true))
{
$sFilePath = '';
}

View file

@ -109,7 +109,7 @@ class ImapClient extends \MailSo\Net\NetClient
$this->__FORCE_SELECT_ON_EXAMINE__ = false;
@\ini_set('xdebug.max_nesting_level', 500);
\ini_set('xdebug.max_nesting_level', 500);
}
public static function NewInstance() : self
@ -2187,9 +2187,9 @@ class ImapClient extends \MailSo\Net\NetClient
if (!$bFeof)
{
while (!@\feof($rImapLiteralStream))
while (!\feof($rImapLiteralStream))
{
$sBuf = @\fread($rImapLiteralStream, 1024 * 1024);
$sBuf = \fread($rImapLiteralStream, 1024 * 1024);
if (false === $sBuf || 0 === \strlen($sBuf) || null === $sBuf)
{
break;
@ -2199,15 +2199,15 @@ class ImapClient extends \MailSo\Net\NetClient
$iNotReadLiteralLen += \strlen($sBuf);
}
if (\is_resource($rImapLiteralStream) && !@\feof($rImapLiteralStream))
if (\is_resource($rImapLiteralStream) && !\feof($rImapLiteralStream))
{
@\stream_get_contents($rImapLiteralStream);
\stream_get_contents($rImapLiteralStream);
}
}
if (\is_resource($rImapLiteralStream))
{
@\fclose($rImapLiteralStream);
\fclose($rImapLiteralStream);
}
if ($iNotReadLiteralLen > 0)

View file

@ -31,7 +31,7 @@ class Syslog extends \MailSo\Log\Driver
\openlog('rainloop', LOG_ODELAY, LOG_USER);
\register_shutdown_function(function () {
@\closelog();
\closelog();
});
}
else

View file

@ -558,7 +558,7 @@ class MailClient
public function MessageAppendFile(string $sMessageFileName, string $sFolderToSave, array $aAppendFlags = null, int &$iUid = null) : self
{
if (!@\is_file($sMessageFileName) || !@\is_readable($sMessageFileName))
if (!\is_file($sMessageFileName) || !\is_readable($sMessageFileName))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}
@ -570,7 +570,7 @@ class MailClient
if (\is_resource($rMessageStream))
{
@fclose($rMessageStream);
fclose($rMessageStream);
}
return $this;
@ -1324,7 +1324,7 @@ class MailClient
$sSerializedUids = $oCacher->Get($sSerializedHashKey);
if (!empty($sSerializedUids))
{
$aSerializedUids = @\json_decode($sSerializedUids, true);
$aSerializedUids = \json_decode($sSerializedUids, true);
if (isset($aSerializedUids['ThreadsUids']) && \is_array($aSerializedUids['ThreadsUids']))
{
if ($this->oLogger)
@ -1465,7 +1465,7 @@ class MailClient
if ($oCacher && $oCacher->IsInited() && !empty($sSerializedHashKey))
{
$oCacher->Set($sSerializedHashKey, @\json_encode(array(
$oCacher->Set($sSerializedHashKey, \json_encode(array(
'ThreadsUids' => $aResult
)));
@ -1568,7 +1568,7 @@ class MailClient
$sSerialized = $oCacher->Get($sSerializedHash);
if (!empty($sSerialized))
{
$aSerialized = @\json_decode($sSerialized, true);
$aSerialized = \json_decode($sSerialized, true);
if (\is_array($aSerialized) && isset($aSerialized['FolderHash'], $aSerialized['Uids']) &&
$sFolderHash === $aSerialized['FolderHash'] &&
\is_array($aSerialized['Uids'])
@ -1594,7 +1594,7 @@ class MailClient
if (!$bUidsFromCacher && $bUseCacheAfterSearch && \is_array($aResultUids) && $oCacher && $oCacher->IsInited() && 0 < \strlen($sSerializedHash))
{
$oCacher->Set($sSerializedHash, @\json_encode(array(
$oCacher->Set($sSerializedHash, \json_encode(array(
'FolderHash' => $sFolderHash,
'Uids' => $aResultUids
)));

View file

@ -377,7 +377,7 @@ class Message
return '<'.
\MailSo\Base\Utils::Md5Rand($sHostName.
(\MailSo\Base\Utils::FunctionExistsAndEnabled('getmypid') ? @\getmypid() : '')).'@'.$sHostName.'>';
(\MailSo\Base\Utils::FunctionExistsAndEnabled('getmypid') ? \getmypid() : '')).'@'.$sHostName.'>';
}
private function createNewMessageAttachmentBody(\MailSo\Mime\Attachment $oAttachment) : \MailSo\Mime\Part

View file

@ -205,7 +205,7 @@ class Part
public function ParseFromFile(string $sFileName) : self
{
$rStreamHandle = (@file_exists($sFileName)) ? @fopen($sFileName, 'rb') : false;
$rStreamHandle = (file_exists($sFileName)) ? fopen($sFileName, 'rb') : false;
if (is_resource($rStreamHandle))
{
$this->ParseFromStream($rStreamHandle);
@ -324,7 +324,7 @@ class Part
{
if (!$bNotFirstRead)
{
$sBuffer = @fread($rStreamHandle, $this->iParseBuffer);
$sBuffer = fread($rStreamHandle, $this->iParseBuffer);
if (false === $sBuffer)
{
break;

View file

@ -213,7 +213,7 @@ abstract class NetClient
$this->writeLog('Start connection to "'.$this->sConnectedHost.':'.$this->iConnectedPort.'"',
\MailSo\Log\Enumerations\Type::NOTE);
// $this->rConnect = @\fsockopen($this->sConnectedHost, $this->iConnectedPort,
// $this->rConnect = \fsockopen($this->sConnectedHost, $this->iConnectedPort,
// $iErrorNo, $sErrorStr, $this->iConnectTimeOut);
$bVerifySsl = !!$bVerifySsl;
@ -270,7 +270,7 @@ abstract class NetClient
{
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('stream_set_timeout'))
{
@\stream_set_timeout($this->rConnect, $this->iSocketTimeOut);
\stream_set_timeout($this->rConnect, $this->iSocketTimeOut);
}
}
}
@ -284,11 +284,11 @@ abstract class NetClient
switch (true)
{
case defined('STREAM_CRYPTO_METHOD_ANY_CLIENT') &&
@\stream_socket_enable_crypto($this->rConnect, true, STREAM_CRYPTO_METHOD_ANY_CLIENT):
\stream_socket_enable_crypto($this->rConnect, true, STREAM_CRYPTO_METHOD_ANY_CLIENT):
case defined('STREAM_CRYPTO_METHOD_TLS_CLIENT') &&
@\stream_socket_enable_crypto($this->rConnect, true, STREAM_CRYPTO_METHOD_TLS_CLIENT):
\stream_socket_enable_crypto($this->rConnect, true, STREAM_CRYPTO_METHOD_TLS_CLIENT):
case defined('STREAM_CRYPTO_METHOD_SSLv23_CLIENT') &&
@\stream_socket_enable_crypto($this->rConnect, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT):
\stream_socket_enable_crypto($this->rConnect, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT):
$bError = false;
break;
}
@ -389,7 +389,7 @@ abstract class NetClient
$sFakeRaw .= "\r\n";
}
$mResult = @\fwrite($this->rConnect, $sRaw);
$mResult = \fwrite($this->rConnect, $sRaw);
if (false === $mResult)
{
$this->IsConnected(true);
@ -420,7 +420,7 @@ abstract class NetClient
{
if (null === $mReadLen)
{
$this->sResponseBuffer = @\fgets($this->rConnect);
$this->sResponseBuffer = \fgets($this->rConnect);
}
else
{
@ -428,7 +428,7 @@ abstract class NetClient
$iRead = $mReadLen;
while (0 < $iRead)
{
$sAddRead = @\fread($this->rConnect, $iRead);
$sAddRead = \fread($this->rConnect, $iRead);
if (false === $sAddRead)
{
$this->sResponseBuffer = false;
@ -445,7 +445,7 @@ abstract class NetClient
$this->IsConnected(true);
$this->bUnreadBuffer = true;
$aSocketStatus = @\stream_get_meta_data($this->rConnect);
$aSocketStatus = \stream_get_meta_data($this->rConnect);
if (isset($aSocketStatus['timed_out']) && $aSocketStatus['timed_out'])
{
$this->writeLogException(