roundcubemail/program/lib/Roundcube/rcube_utils.php
public static function parse_host($name, $host = '')
    {
        if (!is_string($name)) {
            return $name;
        }

        // %n - host
        $n = preg_replace('/:\d+$/', '', $_SERVER['SERVER_NAME']);
        // %t - host name without first part, e.g. %n=mail.domain.tld, %t=domain.tld
        $t = preg_replace('/^[^\.]+\./', '', $n);
        // %d - domain name without first part
        $d = preg_replace('/^[^\.]+\./', '', $_SERVER['HTTP_HOST']);
        // %h - IMAP host
        $h = $_SESSION['storage_host'] ?: $host;
        // %z - IMAP domain without first part, e.g. %h=imap.domain.tld, %z=domain.tld
        $z = preg_replace('/^[^\.]+\./', '', $h);
        // %s - domain name after the '@' from e-mail address provided at login screen.
        //      Returns FALSE if an invalid email is provided
        if (strpos($name, '%s') !== false) {
            $user_email = self::get_input_value('_user', self::INPUT_POST);
            $user_email = self::idn_convert($user_email, true);
            $matches    = preg_match('/(.*)@([a-z0-9\.\-\[\]\:]+)/i', $user_email, $s);
            if ($matches < 1 || filter_var($s[1]."@".$s[2], FILTER_VALIDATE_EMAIL) === false) {
                return false;
            }
        }

        return str_replace(array('%n', '%t', '%d', '%h', '%z', '%s'), array($n, $t, $d, $h, $z, $s[2]), $name);
    }
public static function parse_host($name, $host = '')
    {
        if (!is_string($name)) {
            return $name;
        }

        // %n - host
        $n = preg_replace('/:\d+$/', '', $_SERVER['SERVER_NAME']);
        // %t - host name without first part, e.g. %n=mail.domain.tld, %t=domain.tld
        $t = preg_replace('/^[^\.]+\./', '', $n);
        // %d - domain name without first part
        $d = preg_replace('/^[^\.]+\./', '', $_SERVER['HTTP_HOST']);
        // %h - IMAP host
        $h = $_SESSION['storage_host'] ?: $host;
        // %z - IMAP domain without first part, e.g. %h=imap.domain.tld, %z=domain.tld
        $z = preg_replace('/^[^\.]+\./', '', $h);
        // %s - domain name after the '@' from e-mail address provided at login screen.
        //      Returns FALSE if an invalid email is provided
        if (strpos($name, '%s') !== false) {
            $user_email = self::get_input_value('_user', self::INPUT_POST);
            $user_email = self::idn_convert($user_email, true);
            $matches    = preg_match('/(.*)@([a-z0-9\.\-\[\]\:]+)/i', $user_email, $s);
            if ($matches < 1 || filter_var($s[1]."@".$s[2], FILTER_VALIDATE_EMAIL) === false) {
                return false;
            }
        }

        return str_replace(array('%n', '%t', '%d', '%h', '%z', '%s'), array($n, $t, $d, $h, $z, $s[2]), $name);
    }
public static function parse_host ( $ name , $ host = '' ) { if ( ! is_string ( $ name ) ) { return $ name ; } // %n - host $ n = preg_replace ( '/:\d+$/' , '' , $ _SERVER [ 'SERVER_NAME' ] ) ; // %t - host name without first part, e.g. %n=mail.domain.tld, %t=domain.tld $ t = preg_replace ( '/^[^\.]+\./' , '' , $ n ) ; // %d - domain name without first part $ d = preg_replace ( '/^[^\.]+\./' , '' , $ _SERVER [ 'HTTP_HOST' ] ) ; // %h - IMAP host $ h = $ _SESSION [ 'storage_host' ] ? : $ host ; // %z - IMAP domain without first part, e.g. %h=imap.domain.tld, %z=domain.tld $ z = preg_replace ( '/^[^\.]+\./' , '' , $ h ) ; // %s - domain name after the '@' from e-mail address provided at login screen. //      Returns FALSE if an invalid email is provided if ( strpos ( $ name , '%s' ) !== false ) { $ user_email = self :: get_input_value ( '_user' , self :: INPUT_POST ) ; $ user_email = self :: idn_convert ( $ user_email , true ) ; $ matches = preg_match ( '/(.*)@([a-z0-9\.\-\[\]\:]+)/i' , $ user_email , $ s ) ; if ( $ matches < 1 || filter_var ( $ s [ 1 ] . "@" . $ s [ 2 ] , FILTER_VALIDATE_EMAIL ) === false ) { return false ; } } return str_replace ( array ( '%n' , '%t' , '%d' , '%h' , '%z' , '%s' ) , array ( $ n , $ t , $ d , $ h , $ z , $ s [ 2 ] ) , $ name ) ; }
Replaces hostname variables.

@param string $name Hostname
@param string $host Optional IMAP hostname

@return string Hostname
Replaces hostname variables .