• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

classes/class.ilHTTPS.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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                 // only check standard port in the moment
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 ?>

Generated on Fri Dec 13 2013 09:06:33 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1