• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.4 Detecting HTTPS - http.php file changed

LogOn

Active member
#1
Hi guys, i've tried to make Cloudflare work, but i think i did something wrong with http.php content, because my website does not work att all. I changed my http.php file (located in
/library/Zend/Controller/Request) like is mentioned here , but i think that i changed something else in this file

My website is http://recomandare.net/

The last content of the http.php file look's like this (i've bolded the text changed by me):
public function getHeader($header)
{
if (empty($header)) {
require_once 'Zend/Controller/Request/Exception.php';
throw new Zend_Controller_Request_Exception('An HTTP header name is required');
}

// Try to get it from the $_SERVER array first
$temp = 'HTTP_' . strtoupper(str_replace('-', '_', $header));
if (isset($_SERVER[$temp])) {
return $_SERVER[$temp];
}

// This seems to be the only way to get the Authorization header on
// Apache
if (function_exists('apache_request_headers')) {
$headers = apache_request_headers();
if (isset($headers[$header])) {
return $headers[$header];
}
$header = strtolower($header);
foreach ($headers as $key => $value) {
if (strtolower($key) == $header) {
return $value;
}
}
}

return false;
}

/**
* Get the request URI scheme
*
* @return string
*/
public function getScheme()
{
if ($this->getServer('HTTPS') == 'on') {
return self::SCHEME_HTTPS;
}
if ($this->getServer('SERVER_PORT') == '443') {
return self::SCHEME_HTTPS;
}
if (strtolower($this->getServer('HTTP_X_FORWARDED_PROTO')) == 'https') {
return self::SCHEME_HTTPS;
}
return self::SCHEME_HTTP;
}


/**
* Get the HTTP host.
*
* "Host" ":" host [ ":" port ] ; Section 3.2.2
* Note the HTTP Host header is not the same as the URI host.
* It includes the port while the URI host doesn't.
*
* @return string
*/
public function getHttpHost()
{
$host = $this->getServer('HTTP_HOST');
if (!empty($host)) {
return $host;
}

$scheme = $this->getScheme();
$name = $this->getServer('SERVER_NAME');
$port = $this->getServer('SERVER_PORT');

if(null === $name) {
return '';
}
elseif (($scheme == self::SCHEME_HTTP && $port == 80) || ($scheme == self::SCHEME_HTTPS && $port == 443)) {
return $name;
} else {
return $name . ':' . $port;
}
}

/**
* Get the client's IP addres
*
* @param boolean $checkProxy
* @return string
*/
public function getClientIp($checkProxy = true)
{
if ($checkProxy && $this->getServer('HTTP_CLIENT_IP') != null) {
$ip = $this->getServer('HTTP_CLIENT_IP');
} else if ($checkProxy && $this->getServer('HTTP_X_FORWARDED_FOR') != null) {
$ip = $this->getServer('HTTP_X_FORWARDED_FOR');
} else {
$ip = $this->getServer('REMOTE_ADDR');
}

return $ip;
}
}

/**
* Get the request URI scheme
*
* @return string
*/
public function getScheme()
{
return ($this->getServer('HTTPS') == 'on') ? self::SCHEME_HTTPS : self::SCHEME_HTTP;
}
Please help!
Thank you!