protected function getBaseUrl()
{
$protocol = $this->isHttps() ? 'https' : 'http';
if (isset($_SERVER["SERVER_PORT"])) {
$port = ':' . $_SERVER["SERVER_PORT"];
} else {
$port = '';
}
if ($port == ':80' || $port == ':443') {
$port = '';
}
$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
$cutoff = strpos($uri, 'install.php');
$uri = substr($uri, 0, $cutoff);
$serverName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '';
return "{$protocol}://{$serverName}{$port}{$uri}";
}