[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/ -> index.php (source)

   1  <?php
   2  /**
   3  * @version $Id: index.php 6024 2006-12-18 22:30:07Z friesengeist $
   4  * @package Joomla
   5  * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
   6  * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
   7  * Joomla! is free software. This version may have been modified pursuant
   8  * to the GNU General Public License, and as distributed it includes or
   9  * is derivative of works licensed under the GNU General Public License or
  10  * other free or open source software licenses.
  11  * See COPYRIGHT.php for copyright notices and details.
  12  */
  13  
  14  // Set flag that this is a parent file
  15  define( '_VALID_MOS', 1 );
  16  
  17  // checks for configuration file, if none found loads installation page
  18  if (!file_exists( 'configuration.php' ) || filesize( 'configuration.php' ) < 10) {
  19      $self = rtrim( dirname( $_SERVER['PHP_SELF'] ), '/\\' ) . '/';
  20      header("Location: http://" . $_SERVER['HTTP_HOST'] . $self . "installation/index.php" );
  21      exit();
  22  }
  23  
  24  require ( 'globals.php' );
  25  require_once( 'configuration.php' );
  26  
  27  // SSL check - $http_host returns <live site url>:<port number if it is 443>
  28  $http_host = explode(':', $_SERVER['HTTP_HOST'] );
  29  if( (!empty( $_SERVER['HTTPS'] ) && strtolower( $_SERVER['HTTPS'] ) != 'off' || isset( $http_host[1] ) && $http_host[1] == 443) && substr( $mosConfig_live_site, 0, 8 ) != 'https://' ) {
  30      $mosConfig_live_site = 'https://'.substr( $mosConfig_live_site, 7 );
  31  }
  32  
  33  require_once ( 'includes/joomla.php' );
  34  
  35  //Installation sub folder check, removed for work with SVN
  36  if (file_exists( 'installation/index.php' ) && $_VERSION->SVN == 0) {
  37      define( '_INSTALL_CHECK', 1 );
  38      include  ( $mosConfig_absolute_path .'/offline.php');
  39      exit();
  40  }
  41  
  42  // displays offline/maintanance page or bar
  43  if ($mosConfig_offline == 1) {
  44      require ( $mosConfig_absolute_path .'/offline.php' );
  45  }
  46  
  47  // load system bot group
  48  $_MAMBOTS->loadBotGroup( 'system' );
  49  
  50  // trigger the onStart events
  51  $_MAMBOTS->trigger( 'onStart' );
  52  
  53  if (file_exists( $mosConfig_absolute_path .'/components/com_sef/sef.php' )) {
  54      require_once( $mosConfig_absolute_path .'/components/com_sef/sef.php' );
  55  } else {
  56      require_once ( $mosConfig_absolute_path .'/includes/sef.php' );
  57  }
  58  require_once ( $mosConfig_absolute_path .'/includes/frontend.php' );
  59  
  60  // retrieve some expected url (or form) arguments
  61  $option = strval( strtolower( mosGetParam( $_REQUEST, 'option' ) ) );
  62  $Itemid = intval( mosGetParam( $_REQUEST, 'Itemid', null ) );
  63  
  64  if ($option == '') {
  65      if ($Itemid) {
  66          $query = "SELECT id, link"
  67          . "\n FROM #__menu"
  68          . "\n WHERE menutype = 'mainmenu'"
  69          . "\n AND id = " . (int) $Itemid
  70          . "\n AND published = 1"
  71          ;
  72          $database->setQuery( $query );
  73      } else {
  74          $query = "SELECT id, link"
  75          . "\n FROM #__menu"
  76          . "\n WHERE menutype = 'mainmenu'"
  77          . "\n AND published = 1"
  78          . "\n ORDER BY parent, ordering"
  79          ;
  80          $database->setQuery( $query, 0, 1 );
  81      }
  82      $menu = new mosMenu( $database );
  83      if ($database->loadObject( $menu )) {
  84          $Itemid = $menu->id;
  85      }
  86      $link = $menu->link;
  87      if (($pos = strpos( $link, '?' )) !== false) {
  88          $link = substr( $link, $pos+1 ). '&Itemid='.$Itemid;
  89      }
  90      parse_str( $link, $temp );
  91      /** this is a patch, need to rework when globals are handled better */
  92      foreach ($temp as $k=>$v) {
  93          $GLOBALS[$k] = $v;
  94          $_REQUEST[$k] = $v;
  95          if ($k == 'option') {
  96              $option = $v;
  97          }
  98      }
  99  }
 100  if ( !$Itemid ) {
 101  // when no Itemid give a default value
 102      $Itemid = 99999999;
 103  }
 104  
 105  // mainframe is an API workhorse, lots of 'core' interaction routines
 106  $mainframe = new mosMainFrame( $database, $option, '.' );
 107  $mainframe->initSession();
 108  
 109  // trigger the onAfterStart events
 110  $_MAMBOTS->trigger( 'onAfterStart' );
 111  
 112  // checking if we can find the Itemid thru the content
 113  if ( $option == 'com_content' && $Itemid === 0 ) {
 114      $id     = intval( mosGetParam( $_REQUEST, 'id', 0 ) );
 115      $Itemid = $mainframe->getItemid( $id );
 116  }
 117  
 118  /** do we have a valid Itemid yet?? */
 119  if ( $Itemid === 0 ) {
 120      /** Nope, just use the homepage then. */
 121      $query = "SELECT id"
 122      . "\n FROM #__menu"
 123      . "\n WHERE menutype = 'mainmenu'"
 124      . "\n AND published = 1"
 125      . "\n ORDER BY parent, ordering"
 126      ;
 127      $database->setQuery( $query, 0, 1 );
 128      $Itemid = $database->loadResult();
 129  }
 130  
 131  // patch to lessen the impact on templates
 132  if ($option == 'search') {
 133      $option = 'com_search';
 134  }
 135  
 136  // loads english language file by default
 137  if ($mosConfig_lang=='') {
 138      $mosConfig_lang = 'english';
 139  }
 140  include_once( $mosConfig_absolute_path .'/language/' . $mosConfig_lang . '.php' );
 141  
 142  // frontend login & logout controls
 143  $return     = strval( mosGetParam( $_REQUEST, 'return', NULL ) );
 144  $message     = intval( mosGetParam( $_POST, 'message', 0 ) );
 145  if ($option == 'login') {
 146      $mainframe->login();
 147  
 148      // JS Popup message
 149      if ( $message ) {
 150          ?>
 151          <script language="javascript" type="text/javascript">
 152          <!--//
 153          alert( "<?php echo addslashes( _LOGIN_SUCCESS ); ?>" );
 154          //-->
 155          </script>
 156          <?php
 157      }
 158  
 159      if ( $return && !( strpos( $return, 'com_registration' ) || strpos( $return, 'com_login' ) ) ) {
 160      // checks for the presence of a return url
 161      // and ensures that this url is not the registration or login pages
 162          // If a sessioncookie exists, redirect to the given page. Otherwise, take an extra round for a cookiecheck
 163          if (isset( $_COOKIE[mosMainFrame::sessionCookieName()] )) {
 164              mosRedirect( $return );
 165          } else {
 166              mosRedirect( $mosConfig_live_site .'/index.php?option=cookiecheck&return=' . urlencode( $return ) );
 167          }
 168      } else {
 169          // If a sessioncookie exists, redirect to the start page. Otherwise, take an extra round for a cookiecheck
 170          if (isset( $_COOKIE[mosMainFrame::sessionCookieName()] )) {
 171              mosRedirect( $mosConfig_live_site .'/index.php' );
 172          } else {
 173              mosRedirect( $mosConfig_live_site .'/index.php?option=cookiecheck&return=' . urlencode( $mosConfig_live_site .'/index.php' ) );
 174          }
 175      }
 176  
 177  } else if ($option == 'logout') {
 178      $mainframe->logout();
 179  
 180      // JS Popup message
 181      if ( $message ) {
 182          ?>
 183          <script language="javascript" type="text/javascript">
 184          <!--//
 185          alert( "<?php echo addslashes( _LOGOUT_SUCCESS ); ?>" );
 186          //-->
 187          </script>
 188          <?php
 189      }
 190  
 191      if ( $return && !( strpos( $return, 'com_registration' ) || strpos( $return, 'com_login' ) ) ) {
 192      // checks for the presence of a return url
 193      // and ensures that this url is not the registration or logout pages
 194          mosRedirect( $return );
 195      } else {
 196          mosRedirect( $mosConfig_live_site.'/index.php' );
 197      }
 198  } else if ($option == 'cookiecheck') {
 199      // No cookie was set upon login. If it is set now, redirect to the given page. Otherwise, show error message.
 200      if (isset( $_COOKIE[mosMainFrame::sessionCookieName()] )) {
 201          mosRedirect( $return );
 202      } else {
 203          mosErrorAlert( _ALERT_ENABLED );
 204      }
 205  }
 206  
 207  /** get the information about the current user from the sessions table */
 208  $my = $mainframe->getUser();
 209  
 210  // detect first visit
 211  $mainframe->detect();
 212  
 213  // set for overlib check
 214  $mainframe->set( 'loadOverlib', false );
 215  
 216  $gid = intval( $my->gid );
 217  
 218  // gets template for page
 219  $cur_template = $mainframe->getTemplate();
 220  /** temp fix - this feature is currently disabled */
 221  
 222  /** @global A places to store information from processing of the component */
 223  $_MOS_OPTION = array();
 224  
 225  // precapture the output of the component
 226  require_once ( $mosConfig_absolute_path . '/editor/editor.php' );
 227  
 228  ob_start();
 229  
 230  if ($path = $mainframe->getPath( 'front' )) {
 231      $task     = strval( mosGetParam( $_REQUEST, 'task', '' ) );
 232      $ret     = mosMenuCheck( $Itemid, $option, $task, $gid );
 233  
 234      if ($ret) {
 235          require_once( $path );
 236      } else {
 237          mosNotAuth();
 238      }
 239  } else {
 240      header( 'HTTP/1.0 404 Not Found' );
 241      echo _NOT_EXIST;
 242  }
 243  
 244  $_MOS_OPTION['buffer'] = ob_get_contents();
 245  
 246  ob_end_clean();
 247  
 248  initGzip();
 249  
 250  header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
 251  header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
 252  header( 'Cache-Control: no-store, no-cache, must-revalidate' );
 253  header( 'Cache-Control: post-check=0, pre-check=0', false );
 254  header( 'Pragma: no-cache' );
 255  
 256  // display the offline alert if an admin is logged in
 257  if (defined( '_ADMIN_OFFLINE' )) {
 258      include ( $mosConfig_absolute_path .'/offlinebar.php' );
 259  }
 260  
 261  // loads template file
 262  if ( !file_exists( $mosConfig_absolute_path .'/templates/'. $cur_template .'/index.php' ) ) {
 263      echo _TEMPLATE_WARN . $cur_template;
 264  } else {
 265      require_once( $mosConfig_absolute_path .'/templates/'. $cur_template .'/index.php' );
 266      echo '<!-- '. time() .' -->';
 267  }
 268  
 269  // displays queries performed for page
 270  if ($mosConfig_debug) {
 271      echo $database->_ticker . ' queries executed';
 272      echo '<pre>';
 273       foreach ($database->_log as $k=>$sql) {
 274           echo $k+1 . "\n" . $sql . '<hr />';
 275      }
 276      echo '</pre>';
 277  }
 278  
 279  doGzip();
 280  ?>


Généré le : Wed Nov 21 14:43:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics