Changeset View
Changeset View
Standalone View
Standalone View
src/app/Utils.php
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | public static function downloadFile($source, $target, $force = false) | ||||
unlink($target); | unlink($target); | ||||
return; | return; | ||||
} | } | ||||
curl_close($curl); | curl_close($curl); | ||||
fclose($fp); | fclose($fp); | ||||
} | } | ||||
/** | |||||
* Converts an email address to lower case. Keeps the LMTP shared folder | |||||
* addresses character case intact. | |||||
* | |||||
* @param string $email Email address | |||||
* | |||||
* @return string Email address | |||||
*/ | |||||
public static function emailToLower(string $email): string | |||||
{ | |||||
// For LMTP shared folder address lower case the domain part only | |||||
if (str_starts_with($email, 'shared+shared/')) { | |||||
$pos = strrpos($email, '@'); | |||||
$domain = substr($email, $pos + 1); | |||||
$local = substr($email, 0, strlen($email) - strlen($domain) - 1); | |||||
return $local . '@' . strtolower($domain); | |||||
} | |||||
return strtolower($email); | |||||
} | |||||
/** | /** | ||||
* Generate a passphrase. Not intended for use in production, so limited to environments that are not production. | * Generate a passphrase. Not intended for use in production, so limited to environments that are not production. | ||||
* | * | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
public static function generatePassphrase() | public static function generatePassphrase() | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | class Utils | ||||
* @return string|array Normalized email address as string or array | * @return string|array Normalized email address as string or array | ||||
*/ | */ | ||||
public static function normalizeAddress(?string $address, bool $asArray = false) | public static function normalizeAddress(?string $address, bool $asArray = false) | ||||
{ | { | ||||
if ($address === null || $address === '') { | if ($address === null || $address === '') { | ||||
return $asArray ? ['', ''] : ''; | return $asArray ? ['', ''] : ''; | ||||
} | } | ||||
$address = \strtolower($address); | $address = self::emailToLower($address); | ||||
if (strpos($address, '@') === false) { | if (strpos($address, '@') === false) { | ||||
return $asArray ? [$address, ''] : $address; | return $asArray ? [$address, ''] : $address; | ||||
} | } | ||||
list($local, $domain) = explode('@', $address); | list($local, $domain) = explode('@', $address); | ||||
if (strpos($local, '+') !== false) { | if (strpos($local, '+') !== false) { | ||||
▲ Show 20 Lines • Show All 238 Lines • Show Last 20 Lines |