public static function root($addAuth = false)
{
$url = '';
// Check to see if it's over https
$isHttps = self::isHttps();
// Was a username or password passed?
if ($addAuth) {
$url .= self::getAuth();
}
// We want the user to stay on the same host they are currently on,
// but beware of security issues
// see http://shiflett.org/blog/2006/mar/server-name-versus-http-host
$host = Arr::key('HTTP_HOST', $_SERVER, true);
$port = Arr::key('SERVER_PORT', $_SERVER, true);
$url .= str_replace(':' . $port, '', $host);
// Is it on a non standard port?
if ($isHttps && $port != self::PORT_HTTPS) {
$url .= Arr::key('SERVER_PORT', $_SERVER) ? ':' . $_SERVER['SERVER_PORT'] : '';
} elseif (!$isHttps && $port != self::PORT_HTTP) {
$url .= Arr::key('SERVER_PORT', $_SERVER) ? ':' . $_SERVER['SERVER_PORT'] : '';
}
if ($url) {
if ($isHttps) {
return 'https://' . $url;
} else {
return 'http://' . $url;
}
}
return null;
}
/** * Create img tag. * * @param string $src * @param string|array $class * @param string $id * @param array $attrs * @return string */ public function render($src, $class = '', $id = '', array $attrs = array()) { $attrs['class'] = false; $attrs = array_merge(array('fullUrl' => true), $attrs); $attrs['id'] = $id; $attrs = $this->_normalizeClassAttr($attrs, $this->_jbSrt('image')); if ($class !== '') { $attrs = $this->_normalizeClassAttr($attrs, $class); } $attrs['class'] = Str::clean($attrs['class']); $isFull = $attrs['fullUrl']; unset($attrs['fullUrl']); $src = FS::clean($src, '/'); $attrs['src'] = $isFull ? Url::root() . '/' . $src : $src; return '<img ' . $this->buildAttrs($attrs) . ' />'; }