Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00033 class ilHTTPS
00034 {
00035 var $enabled = false;
00036 var $protected_scripts = array();
00037
00038 function ilHTTPS()
00039 {
00040 global $ilias;
00041
00042 if($this->enabled = (bool) $ilias->getSetting('https'))
00043 {
00044 $this->__readProtectedScripts();
00045 }
00046 }
00047
00048 function checkPort()
00049 {
00050 if(!$this->enabled)
00051 {
00052 return true;
00053 }
00054 if(in_array(basename($_SERVER["SCRIPT_NAME"]),$this->protected_scripts) and
00055 $_SERVER["HTTPS"] != 'on')
00056 {
00057 header("location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
00058 exit;
00059 }
00060 if(!in_array(basename($_SERVER["SCRIPT_NAME"]),$this->protected_scripts) and
00061 $_SERVER["HTTPS"] == 'on')
00062 {
00063 header("location: http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
00064 exit;
00065 }
00066 return true;
00067 }
00068
00069 function __readProtectedScripts()
00070 {
00071 $this->protected_scripts[] = 'login.php';
00072 $this->protected_scripts[] = 'start_bmf.php';
00073
00074 return true;
00075 }
00076
00082 function _checkHTTPS()
00083 {
00084
00085 $port = 443;
00086
00087 if(($sp = @fsockopen($_SERVER["SERVER_NAME"],$port,$errno,$error)) === false)
00088 {
00089 return false;
00090 }
00091 fclose($sp);
00092 return true;
00093 }
00100 function _checkHTTP()
00101 {
00102 $port = 80;
00103
00104 if(($sp = @fsockopen($_SERVER["SERVER_NAME"],$port,$errno,$error)) === false)
00105 {
00106 return false;
00107 }
00108 fclose($sp);
00109 return true;
00110 }
00111 }
00112 ?>