diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-12-25 14:29:29 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-12-25 14:29:29 +0100 |
commit | 7e36f730ecfe452681f44771b28d1d3c4a5535df (patch) | |
tree | 578e604c170219151239e2da345d332b079ed920 /lib/public | |
parent | bf05ff351faa693337107ed4a316e36e9aacd296 (diff) | |
parent | 5d59ac07391841677e204958ea20be3fe05cd8ef (diff) | |
download | nextcloud-server-7e36f730ecfe452681f44771b28d1d3c4a5535df.tar.gz nextcloud-server-7e36f730ecfe452681f44771b28d1d3c4a5535df.zip |
merge master into filesystem
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/util.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/public/util.php b/lib/public/util.php index 7b5b1abbded..af782b01483 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -173,6 +173,42 @@ class Util { } /** + * @brief returns the server hostname + * @returns the server hostname + * + * Returns the server host name without an eventual port number + */ + public static function getServerHostName() { + $host_name = self::getServerHost(); + // strip away port number (if existing) + $colon_pos = strpos($host_name, ':'); + if ($colon_pos != FALSE) { + $host_name = substr($host_name, 0, $colon_pos); + } + return $host_name; + } + + /** + * @brief Returns the default email address + * @param $user_part the user part of the address + * @returns the default email address + * + * Assembles a default email address (using the server hostname + * and the given user part, and returns it + * Example: when given lostpassword-noreply as $user_part param, + * and is currently accessed via http(s)://example.com/, + * it would return 'lostpassword-noreply@example.com' + */ + public static function getDefaultEmailAddress($user_part) { + $host_name = self::getServerHostName(); + // handle localhost installations + if ($host_name === 'localhost') { + $host_name = "example.com"; + } + return $user_part.'@'.$host_name; + } + + /** * @brief Returns the server protocol * @returns the server protocol * |