Source for file include_others.inc

Documentation is available at include_others.inc

  1. <?php
  2. /**
  3. * Master include file for the whole project.
  4. *
  5. * Master include file for CIB components, parses
  6. * the URI to determine which other include files
  7. * are needed by the current script. This file starts
  8. * the session. One of the sub-included files normally
  9. * will create the appropriate database connections.
  10. *
  11. * This file is part of CompInaBox.
  12. * @package CompInaBox
  13. * @author Eric D. Nielsen <nielsene@alum.mit.edu>
  14. * @copyright CompInaBox Copyright 2002-2005, Eric D. Nielsen. All Rights Reserved.
  15. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  16. * @filesource
  17. */
  18. /**
  19. * Include basic path information
  20. */
  21. require("paths.inc");
  22. $PHP_SELF=$_SERVER["REQUEST_URI"];
  23.  
  24. // redirect to a secure page, if ssl should be used for all transactions and
  25. // currently on an insecure page.
  26.  
  27. if (strpos($_SERVER["SERVER_PROTOCOL"],"HTTPS") ||
  28. (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"]=="on"))
  29. $usesSSL=TRUE;
  30. else
  31. $usesSSL=FALSE;
  32.  
  33.  
  34. if ($CIB_USES_SSL=="ALWAYS" && $usesSSL==FALSE)
  35. {
  36. header("Location: https://$CIB_HOSTNAME"."$CIB_DOMAIN{$PHP_SELF}");
  37. exit;
  38. }
  39.  
  40. // redirect to a insecure page, if ssl should not be used at all and
  41. // currently on a secure page.
  42.  
  43. if ($CIB_USES_SSL=="NEVER" && $usesSSL==TRUE)
  44. {
  45. header("Location: http://$CIB_HOSTNAME"."$CIB_DOMAIN{$PHP_SELF}");
  46. exit;
  47. }
  48.  
  49. // if we only use ssl sometimes is the responsibilities of ssl requiring
  50. // pages to handle the redirect if reached insecurely
  51.  
  52. // Now we need to grab the toolname and the compname: these will be the first
  53. // and second directory components of the URL.
  54.  
  55.  
  56.  
  57. $CIB_LAST_SLASH = strrpos($CIB_WEB_INSTALL_DIR,'/');
  58. $CIB_REQUEST_PATH = substr($PHP_SELF,$CIB_LAST_SLASH+2);
  59. $CIB_PATH_COMPONENTS = explode('/',$CIB_REQUEST_PATH);
  60.  
  61. $CIB_NUM_PATH_COMPONENTS = count($CIB_PATH_COMPONENTS);
  62. if ($CIB_NUM_PATH_COMPONENTS==1 || $CIB_PATH_COMPONENTS[0]=="SCRIPTS" ||
  63. $CIB_PATH_COMPONENTS[0]=="accounts")
  64. {
  65. $CIB_TOOL_ROLE="core";
  66. }
  67. else
  68. {
  69. $CIB_TOOL_ROLE = $CIB_PATH_COMPONENTS[0];
  70. }
  71.  
  72. if ($CIB_TOOL_ROLE=="") $CIB_TOOL_ROLE="core";
  73. $CIB_TOOL_NAME = $CIB_ROLE_TO_NAME_LUT[$CIB_TOOL_ROLE];
  74. if ($CIB_NUM_PATH_COMPONENTS>2 && in_array($CIB_TOOL_ROLE,array("register")))
  75. {
  76. $CIB_COMP_UNIXNAME = $CIB_PATH_COMPONENTS[1];
  77. if ($CIB_COMP_UNIXNAME=="SCRIPTS")
  78. $CIB_COMP_UNIXNAME = "";
  79. }
  80. else
  81. {
  82. $CIB_COMP_UNIXNAME="";
  83. }
  84. if (in_array($CIB_TOOL_NAME,array("SlidingDoors","PrepStep")))
  85. include_once("$CIB_CONFIG_PATH/tools/{$CIB_TOOL_NAME}_config.inc");
  86. if (""!=$CIB_COMP_UNIXNAME)
  87. {
  88. include("$CIB_CONFIG_PATH/comps/{$CIB_COMP_UNIXNAME}_config.inc");
  89. }
  90. session_start();
  91. include("$CIB_INCLUDE_PATH/tools/{$CIB_TOOL_NAME}_header.inc");
  92. if (isset($authorizationLevels))
  93. $authenticationRequired=TRUE;
  94. else if (!isset($authenticationRequired)) $authenticationRequired=FALSE;
  95. if ($authenticationRequired)
  96. {
  97. if (!isset($user)) $user="";
  98. include_once("$CIB_INCLUDE_PATH/session_user_setup.inc");
  99. newTimestamp("Found user permissions");
  100. $gate = new Gate();
  101. $guard = new Guard();
  102. if ($authenticationRequired)
  103. $gate->lowerPortcullis();
  104. if (isset($authorizationLevels))
  105. $gate->lockGate($authorizationLevels);
  106. newTimestamp("Locked gate");
  107. if (isset($user) && $user!="" &&
  108. $guard->recognizesUser($user->getUsername()))
  109. {
  110. $guard->unlockGateWithKeys($gate,$user->getKeys(),
  111. "{$CIB_BASE_URL}access-denied.php");
  112. newTimestamp("Successful unlocked gate");
  113. }
  114. else
  115. {
  116. $guard->referToScribe($PHP_SELF);
  117. exit;
  118. }
  119. }
  120.  
  121. ?>

Documentation generated on Tue, 25 Apr 2006 13:02:57 -0400 by phpDocumentor 1.3.0RC3