snappymail/rainloop/v/0.0.0/app/libraries/RainLoop/Plugins/Helper.php
djmaze 2cada68f41 Privacy/GDPR friendly version (removed: Social, Gravatar, Facebook, Google, Twitter, DropBox, OwnCloud)
Also removed: POP3, OAuth2 and update feature
Added: admin password_hash/password_verify
Requires: PHP 7.3+
Replaced: CRLF with LF
Replaced: pclZip with ZipArchive
2020-03-09 17:04:17 +01:00

66 lines
1.1 KiB
PHP

<?php
namespace RainLoop\Plugins;
class Helper
{
/**
* @return void
*/
private function __construct()
{
}
static public function ValidateWildcardValues(string $sString, string $sWildcardValues, string &$sFoundedValue) : bool
{
$sFoundedValue = '';
$sString = \trim($sString);
if ('' === $sString)
{
return false;
}
$sWildcardValues = \trim($sWildcardValues);
if ('' === $sWildcardValues)
{
return true;
}
if ('*' === $sWildcardValues)
{
$sFoundedValue = '*';
return true;
}
$sWildcardValues = \preg_replace('/[*]+/', '*', \preg_replace('/[\s,;]+/', ' ', $sWildcardValues));
$aWildcardValues = \explode(' ', $sWildcardValues);
foreach ($aWildcardValues as $sItem)
{
if (false === \strpos($sItem, '*'))
{
if ($sString === $sItem)
{
$sFoundedValue = $sItem;
return true;
}
}
else
{
$aItem = \explode('*', $sItem);
$aItem = \array_map(function ($sItem) {
return \preg_quote($sItem, '/');
}, $aItem);
if (\preg_match('/'.\implode('.*', $aItem).'/', $sString))
{
$sFoundedValue = $sItem;
return true;
}
}
}
return false;
}
}