HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/public/snappymail/snappymail/v/2.38.2/app/libraries/RainLoop/Plugins/Helper.php
<?php

namespace RainLoop\Plugins;

class Helper
{
	static public function ValidateWildcardValues(string $sString, string $sWildcardValues, string &$sFoundValue = null) : bool
	{
		$sFoundValue = '';

		$sString = \trim($sString);
		if ('' === $sString) {
			return false;
		}

		$sWildcardValues = \trim($sWildcardValues);
		if ('' === $sWildcardValues) {
			return true;
		}

		if ('*' === $sWildcardValues) {
			$sFoundValue = '*';
			return true;
		}

		$aWildcardValues = \preg_split('/[\\s,;]+/', \preg_replace('/\\*+/', '*', $sWildcardValues));

		foreach ($aWildcardValues as $sItem) {
			if (false === \strpos($sItem, '*')) {
				if ($sString === $sItem) {
					$sFoundValue = $sItem;
					return true;
				}
			} else {
				$aItem = \explode('*', $sItem);
				$aItem = \array_map(function ($sItem) {
					return \preg_quote($sItem, '/');
				}, $aItem);

				if (\preg_match('/'.\implode('.*', $aItem).'/', $sString)) {
					$sFoundValue = $sItem;
					return true;
				}
			}
		}

		return false;
	}
}