ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilHTTPS Class Reference

HTTPS. More...

+ Collaboration diagram for ilHTTPS:

Public Member Functions

 ilHTTPS ()
 use ilHTTPS::getInstance()
 checkPort ()
 check if current port usage is right: if https should be used than redirection is done, to http otherwise.
 __readProtectedScripts ()
 isDetected ()
 check if https is detected
 __readProtectedClasses ()
 _checkHTTPS ()
 static method to check if https connections are possible for this server public
 _checkHTTP ()
 static method to check if http connections are possible for this server
 enableSecureCookies ()
 enable secure cookies

Static Public Member Functions

static getInstance ()
 Get https instance.

Data Fields

const PROTOCOL_HTTP = 1
const PROTOCOL_HTTPS = 2
 $enabled = false
 $protected_scripts = array()
 $automaticHTTPSDetectionEnabled = false
 $headerName = false
 $headerValue = false

Protected Member Functions

 shouldSwitchProtocol ($to_protocol)

Static Private Attributes

static $instance = null

Detailed Description

HTTPS.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id:
class.ilHTTPS.php 55334 2014-11-19 15:07:17Z mjansen

Definition at line 13 of file class.ilHTTPS.php.

Member Function Documentation

ilHTTPS::__readProtectedClasses ( )

Definition at line 160 of file class.ilHTTPS.php.

Referenced by ilHTTPS().

{
$this->protected_classes[] = 'ilstartupgui';
$this->protected_classes[] = 'ilaccountregistrationgui';
$this->protected_classes[] = 'ilpurchasebmfgui';
$this->protected_classes[] = 'ilpurchasepaypal';
$this->protected_classes[] = 'ilshopshoppingcartgui';
$this->protected_classes[] = 'ilpurchasebillgui';
$this->protected_classes[] = 'ilpersonalsettingsgui';
}

+ Here is the caller graph for this function:

ilHTTPS::__readProtectedScripts ( )

Definition at line 114 of file class.ilHTTPS.php.

Referenced by ilHTTPS().

{
$this->protected_scripts[] = 'login.php';
$this->protected_scripts[] = 'index.php';
$this->protected_scripts[] = 'payment.php';
$this->protected_scripts[] = 'register.php';
// BEGIN WebDAV Use SSL for WebDAV.
$this->protected_scripts[] = 'webdav.php';
// END WebDAV Use SSL for WebDAV.
$this->protected_scripts[] = 'shib_login.php';
return true;
}

+ Here is the caller graph for this function:

ilHTTPS::_checkHTTP ( )

static method to check if http connections are possible for this server

public

Returns
boolean

Definition at line 194 of file class.ilHTTPS.php.

{
$port = 80;
if(($sp = fsockopen($_SERVER["SERVER_NAME"],$port,$errno,$error)) === false)
{
return false;
}
fclose($sp);
return true;
}
ilHTTPS::_checkHTTPS ( )

static method to check if https connections are possible for this server public

Returns
boolean

Definition at line 176 of file class.ilHTTPS.php.

Referenced by ilSecuritySettings\validate().

{
// only check standard port in the moment
$port = 443;
if(($sp = fsockopen($_SERVER["SERVER_NAME"],$port,$errno,$error)) === false)
{
return false;
}
fclose($sp);
return true;
}

+ Here is the caller graph for this function:

ilHTTPS::checkPort ( )

check if current port usage is right: if https should be used than redirection is done, to http otherwise.

Returns
unknown

Definition at line 95 of file class.ilHTTPS.php.

References exit, and shouldSwitchProtocol().

{
// if https is enabled for scripts or classes, check for redirection
if ($this->enabled)
{
if($this->shouldSwitchProtocol(self::PROTOCOL_HTTPS))
{
header("location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
}
if($this->shouldSwitchProtocol(self::PROTOCOL_HTTP))
{
header("location: http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
}
}
return true;
}

+ Here is the call graph for this function:

ilHTTPS::enableSecureCookies ( )

enable secure cookies

public

Parameters
@return

Definition at line 213 of file class.ilHTTPS.php.

References $ilLog, IL_COOKIE_PATH, and isDetected().

{
global $ilLog,$ilClientIniFile;
$secure_disabled = $ilClientIniFile->readVariable('session','disable_secure_cookies');
if(!$secure_disabled and !$this->enabled and $this->isDetected() and !session_id())
{
#$ilLog->write(__CLASS__.': Enabled secure cookies');
// session_set_cookie_params() supports 5th parameter
// only for php version 5.2.0 and above
if( version_compare(PHP_VERSION, '5.2.0', '>=') )
{
// PHP version >= 5.2.0
session_set_cookie_params(
IL_COOKIE_EXPIRE, IL_COOKIE_PATH, IL_COOKIE_DOMAIN, true, IL_COOKIE_HTTPONLY
);
}
else
{
// PHP version < 5.2.0
session_set_cookie_params(
IL_COOKIE_EXPIRE, IL_COOKIE_PATH, IL_COOKIE_DOMAIN, true
);
}
}
return true;
}

+ Here is the call graph for this function:

static ilHTTPS::getInstance ( )
static

Get https instance.

Returns

Definition at line 51 of file class.ilHTTPS.php.

References $instance, and ilHTTPS().

Referenced by ilUtil\deliverData(), and ilUtil\deliverFile().

{
if(self::$instance)
{
}
return self::$instance = new ilHTTPS();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilHTTPS::ilHTTPS ( )

use ilHTTPS::getInstance()

Returns

Definition at line 31 of file class.ilHTTPS.php.

References $ilSetting, __readProtectedClasses(), and __readProtectedScripts().

Referenced by getInstance().

{
global $ilSetting;
if($this->enabled = (bool) $ilSetting->get('https'))
{
}
if ($this->automaticHTTPSDetectionEnabled = (bool) $ilSetting->get("ps_auto_https_enabled"))
{
$this->headerName = $ilSetting->get("ps_auto_https_headername");
$this->headerValue = $ilSetting->get("ps_auto_https_headervalue");
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilHTTPS::isDetected ( )

check if https is detected

Returns
boolean true, if https is detected by protocol or by automatic detection, if enabled, false otherwise

Definition at line 133 of file class.ilHTTPS.php.

References $headerName.

Referenced by enableSecureCookies().

{
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on")
return true;
if ($this->automaticHTTPSDetectionEnabled)
{
$headerName = "HTTP_".str_replace("-","_",$this->headerName);
/* echo $headerName;
echo $_SERVER[$headerName];*/
if (strcasecmp($_SERVER[$headerName],$this->headerValue)==0)
{
$_SERVER["HTTPS"] = "on";
return true;
}
/*
if(isset($_SERVER[$this->headerName]) && (strcasecmp($_SERVER[$this->headerName],$this->headerValue) == 0))
{
$_SERVER['HTTPS'] = 'on';
return true;
}
*/
}
return false;
}

+ Here is the caller graph for this function:

ilHTTPS::shouldSwitchProtocol (   $to_protocol)
protected
Parameters
bool$to_protocol
Returns
bool

Definition at line 64 of file class.ilHTTPS.php.

References $_GET.

Referenced by checkPort().

{
switch($to_protocol)
{
case self::PROTOCOL_HTTP:
$should_switch_to_http = (
!in_array(basename($_SERVER['SCRIPT_NAME']), $this->protected_scripts) &&
!in_array(strtolower($_GET['cmdClass']), $this->protected_classes)
) && $_SERVER['HTTPS'] == 'on';
return $should_switch_to_http;
break;
case self::PROTOCOL_HTTPS:
$should_switch_to_https = (
in_array(basename($_SERVER['SCRIPT_NAME']), $this->protected_scripts) ||
in_array(strtolower($_GET['cmdClass']), $this->protected_classes)
) && $_SERVER['HTTPS'] != 'on';
return $should_switch_to_https;
break;
}
return false;
}

+ Here is the caller graph for this function:

Field Documentation

ilHTTPS::$automaticHTTPSDetectionEnabled = false

Definition at line 23 of file class.ilHTTPS.php.

ilHTTPS::$enabled = false

Definition at line 20 of file class.ilHTTPS.php.

ilHTTPS::$headerName = false

Definition at line 24 of file class.ilHTTPS.php.

Referenced by isDetected().

ilHTTPS::$headerValue = false

Definition at line 25 of file class.ilHTTPS.php.

ilHTTPS::$instance = null
staticprivate

Definition at line 18 of file class.ilHTTPS.php.

Referenced by getInstance().

ilHTTPS::$protected_scripts = array()

Definition at line 21 of file class.ilHTTPS.php.

const ilHTTPS::PROTOCOL_HTTP = 1

Definition at line 15 of file class.ilHTTPS.php.

const ilHTTPS::PROTOCOL_HTTPS = 2

Definition at line 16 of file class.ilHTTPS.php.


The documentation for this class was generated from the following file: