src/Utilities/Uri.php
public static function getSecuredUrl($url, $user = '', $password = '')
    {
        /*
         * Url is not provided?
         * Nothing to do
         */
        if (empty($url)) {
            return '';
        }

        $protocol = self::getProtocolName();
        $host = self::getServerNameOrIp();

        if (!Regex::startsWith($url, '/')) {
            $url = sprintf('/%s', $url);
        }

        $url = $host . $url;

        if (!empty($user) && !empty($password)) {
            $url = sprintf('%s:%s@%s', $user, $password, $url);
        }

        return sprintf('%s://%s', $protocol, $url);
    }
public static function getSecuredUrl($url, $user = '', $password = '')
    {
        /*
         * Url is not provided?
         * Nothing to do
         */
        if (empty($url)) {
            return '';
        }

        $protocol = self::getProtocolName();
        $host = self::getServerNameOrIp();

        if (!Regex::startsWith($url, '/')) {
            $url = sprintf('/%s', $url);
        }

        $url = $host . $url;

        if (!empty($user) && !empty($password)) {
            $url = sprintf('%s:%s@%s', $user, $password, $url);
        }

        return sprintf('%s://%s', $protocol, $url);
    }
public static function getSecuredUrl ( $ url , $ user = '' , $ password = '' ) { /*
         * Url is not provided?
         * Nothing to do
         */ if ( empty ( $ url ) ) { return '' ; } $ protocol = self :: getProtocolName ( ) ; $ host = self :: getServerNameOrIp ( ) ; if ( ! Regex :: startsWith ( $ url , '/' ) ) { $ url = sprintf ( '/%s' , $ url ) ; } $ url = $ host . $ url ; if ( ! empty ( $ user ) && ! empty ( $ password ) ) { $ url = sprintf ( '%s:%s@%s' , $ user , $ password , $ url ) ; } return sprintf ( '%s://%s' , $ protocol , $ url ) ; }
Returns url to resource secured by given htpasswd login and password

@param string $url      A path / url to some resource, e.g. page, image, css file
@param string $user     (optional) User name used to log in
@param string $password (optional) User password used to log in
@return string
Returns url to resource secured by given htpasswd login and password