[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/includes/ -> frontend.php (source)

   1  <?php
   2  /**
   3  * @version $Id: frontend.php 5930 2006-12-06 00:49: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  defined( '_VALID_MOS' ) or die( 'Restricted access' );
  15  /**
  16  * Displays the capture output of the main element
  17  */
  18  function mosMainBody() {
  19      global $mosConfig_live_site;
  20      // message passed via the url
  21      $mosmsg = stripslashes( strval( mosGetParam( $_REQUEST, 'mosmsg', '' ) ) );
  22  
  23      $popMessages = false;
  24  
  25      // Browser Check
  26      $browserCheck = 0;
  27      if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && isset( $_SERVER['HTTP_REFERER'] ) && strpos($_SERVER['HTTP_REFERER'], $mosConfig_live_site) !== false ) {
  28          $browserCheck = 1;
  29      }
  30  
  31      // Session Check
  32      $sessionCheck = 0;
  33      // Session Cookie `name`
  34      $sessionCookieName     = mosMainFrame::sessionCookieName();
  35      // Get Session Cookie `value`
  36      $sessioncookie         = mosGetParam( $_COOKIE, $sessionCookieName, null );
  37      if ( (strlen($sessioncookie) == 32 || $sessioncookie == '-') ) {
  38          $sessionCheck = 1;
  39      }
  40  
  41      // limit mosmsg to 150 characters
  42      if ( strlen( $mosmsg ) > 150 ) {
  43          $mosmsg = substr( $mosmsg, 0, 150 );
  44      }
  45  
  46      // mosmsg outputed within html
  47      if ($mosmsg && !$popMessages && $browserCheck && $sessionCheck) {
  48          echo "\n<div class=\"message\">$mosmsg</div>";
  49      }
  50  
  51      echo $GLOBALS['_MOS_OPTION']['buffer'];
  52  
  53      // mosmsg outputed in JS Popup
  54      if ($mosmsg && $popMessages && $browserCheck && $sessionCheck) {
  55          echo "\n<script language=\"javascript\">alert('" . addslashes( $mosmsg ) . "');</script>";
  56      }
  57  }
  58  /**
  59  * Utility functions and classes
  60  */
  61  function mosLoadComponent( $name ) {
  62      // set up some global variables for use by frontend components
  63      global $mainframe, $database, $my, $acl;
  64      global $task, $Itemid, $id, $option, $gid;
  65  
  66      include( $mainframe->getCfg( 'absolute_path' )."/components/com_$name/$name.php" );
  67  }
  68  /**
  69  * Cache some modules information
  70  * @return array
  71  */
  72  function &initModules() {
  73      global $database, $my, $Itemid;
  74  
  75      if (!isset( $GLOBALS['_MOS_MODULES'] )) {
  76          $Itemid         = intval($Itemid);
  77          $check_Itemid     = '';
  78          if ($Itemid) {
  79              $check_Itemid = "OR mm.menuid = " . (int) $Itemid;
  80          }
  81  
  82          $query = "SELECT id, title, module, position, content, showtitle, params"
  83          . "\n FROM #__modules AS m"
  84          . "\n INNER JOIN #__modules_menu AS mm ON mm.moduleid = m.id"
  85          . "\n WHERE m.published = 1"
  86          . "\n AND m.access <= ". (int) $my->gid
  87          . "\n AND m.client_id != 1"
  88          . "\n AND ( mm.menuid = 0 $check_Itemid )"
  89          . "\n ORDER BY ordering";
  90  
  91          $database->setQuery( $query );
  92          $modules = $database->loadObjectList();
  93  
  94          foreach ($modules as $module) {
  95              $GLOBALS['_MOS_MODULES'][$module->position][] = $module;
  96          }
  97      }
  98      return $GLOBALS['_MOS_MODULES'];
  99  }
 100  /**
 101  * @param string THe template position
 102  */
 103  function mosCountModules( $position='left' ) {
 104      global $database, $my, $Itemid;
 105  
 106      $tp = intval( mosGetParam( $_GET, 'tp', 0 ) );
 107      if ($tp) {
 108          return 1;
 109      }
 110  
 111      $modules =& initModules();
 112      if (isset( $GLOBALS['_MOS_MODULES'][$position] )) {
 113          return count( $GLOBALS['_MOS_MODULES'][$position] );
 114      } else {
 115          return 0;
 116      }
 117  }
 118  /**
 119  * @param string The position
 120  * @param int The style.  0=normal, 1=horiz, -1=no wrapper
 121  */
 122  function mosLoadModules( $position='left', $style=0 ) {
 123      global $mosConfig_gzip, $mosConfig_absolute_path, $database, $my, $Itemid, $mosConfig_caching;
 124  
 125      $tp = intval( mosGetParam( $_GET, 'tp', 0 ) );
 126      if ($tp) {
 127          echo '<div style="height:50px;background-color:#eee;margin:2px;padding:10px;border:1px solid #f00;color:#700;">';
 128          echo $position;
 129          echo '</div>';
 130          return;
 131      }
 132      $style = intval( $style );
 133      $cache =& mosCache::getCache( 'com_content' );
 134  
 135      require_once ( $mosConfig_absolute_path . '/includes/frontend.html.php' );
 136  
 137      $allModules =& initModules();
 138      if (isset( $GLOBALS['_MOS_MODULES'][$position] )) {
 139          $modules = $GLOBALS['_MOS_MODULES'][$position];
 140      } else {
 141          $modules = array();
 142      }
 143  
 144      if (count( $modules ) < 1) {
 145          $style = 0;
 146      }
 147      if ($style == 1) {
 148          echo "<table cellspacing=\"1\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n";
 149          echo "<tr>\n";
 150      }
 151      $prepend = ($style == 1) ? "<td valign=\"top\">\n" : '';
 152      $postpend = ($style == 1) ? "</td>\n" : '';
 153  
 154      $count = 1;
 155      foreach ($modules as $module) {
 156          $params = new mosParameters( $module->params );
 157  
 158          echo $prepend;
 159  
 160          if ((substr("$module->module",0,4))=='mod_') {
 161          // normal modules
 162              if ($params->get('cache') == 1 && $mosConfig_caching == 1) {
 163              // module caching
 164                  $cache->call('modules_html::module2', $module, $params, $Itemid, $style, $my->gid  );
 165              } else {
 166                  modules_html::module2( $module, $params, $Itemid, $style, $count );
 167              }
 168          } else {
 169          // custom or new modules
 170              if ($params->get('cache') == 1 && $mosConfig_caching == 1) {
 171              // module caching
 172                  $cache->call('modules_html::module', $module, $params, $Itemid, $style, 0, $my->gid );
 173              } else {
 174                  modules_html::module( $module, $params, $Itemid, $style );
 175              }
 176          }
 177  
 178          echo $postpend;
 179  
 180          $count++;
 181      }
 182      if ($style == 1) {
 183          echo "</tr>\n</table>\n";
 184      }
 185  }
 186  /**
 187  * Assembles head tags
 188  */
 189  function mosShowHead() {
 190      global $database, $option, $my, $mainframe, $_VERSION, $task, $id;
 191      global $mosConfig_MetaDesc, $mosConfig_MetaKeys, $mosConfig_live_site, $mosConfig_sef, $mosConfig_absolute_path, $mosConfig_sitename, $mosConfig_favicon;
 192  
 193      $mainframe->appendMetaTag( 'description', $mosConfig_MetaDesc );
 194      $mainframe->appendMetaTag( 'keywords', $mosConfig_MetaKeys );
 195      $mainframe->addMetaTag( 'Generator', $_VERSION->PRODUCT . ' - ' . $_VERSION->COPYRIGHT);
 196      $mainframe->addMetaTag( 'robots', 'index, follow' );
 197  
 198      // cache activation
 199      if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
 200          $cache =& mosCache::getCache('com_content');
 201          echo $cache->call('mainframe->getHead', @$_SERVER['QUERY_STRING'], $id);
 202      } else {
 203          echo $mainframe->getHead();
 204      }
 205  
 206      if ( isset($mosConfig_sef) && $mosConfig_sef ) {
 207          echo "<base href=\"$mosConfig_live_site/\" />\r\n";
 208      }
 209  
 210      if ($my->id || $mainframe->get( 'joomlaJavascript' )) {
 211          ?>
 212          <script src="<?php echo $mosConfig_live_site;?>/includes/js/joomla.javascript.js" type="text/javascript"></script>
 213          <?php
 214      }
 215  
 216      $row = new mosComponent( $database );
 217      $query = "SELECT a.*"
 218      . "\n FROM #__components AS a"
 219      . "\n WHERE ( a.admin_menu_link = 'option=com_syndicate' OR a.admin_menu_link = 'option=com_syndicate&hidemainmenu=1' )"
 220      . "\n AND a.option = 'com_syndicate'"
 221      ;
 222      $database->setQuery( $query );
 223      $database->loadObject( $row );
 224  
 225      // get params definitions
 226      $syndicateParams = new mosParameters( $row->params, $mainframe->getPath( 'com_xml', $row->option ), 'component' );
 227  
 228      // needed to reduce query
 229      $GLOBALS['syndicateParams'] = $syndicateParams;
 230  
 231      $live_bookmark = $syndicateParams->get( 'live_bookmark', 0 );
 232  
 233      // and to allow disabling/enabling of selected feed types
 234      switch ( $live_bookmark ) {
 235          case 'RSS0.91':
 236              if ( !$syndicateParams->get( 'rss091', 1 ) ) {
 237                  $live_bookmark = 0;
 238              }
 239              break;
 240  
 241          case 'RSS1.0':
 242              if ( !$syndicateParams->get( 'rss10', 1 ) ) {
 243                  $live_bookmark = 0;
 244              }
 245              break;
 246  
 247          case 'RSS2.0':
 248              if ( !$syndicateParams->get( 'rss20', 1 ) ) {
 249                  $live_bookmark = 0;
 250              }
 251              break;
 252  
 253          case 'ATOM0.3':
 254              if ( !$syndicateParams->get( 'atom03', 1 ) ) {
 255                  $live_bookmark = 0;
 256              }
 257              break;
 258      }
 259  
 260      // support for Live Bookmarks ability for site syndication
 261      if ($live_bookmark) {
 262          $show = 1;
 263  
 264          $link_file     = $mosConfig_live_site . '/index2.php?option=com_rss&feed='. $live_bookmark .'&no_html=1';
 265  
 266          // xhtml check
 267          $link_file = ampReplace( $link_file );
 268  
 269          // security chcek
 270          $check = $syndicateParams->def( 'check', 1 );
 271          if($check) {
 272              // test if rssfeed module is published
 273              // if not disable access
 274              $query = "SELECT m.id"
 275              . "\n FROM #__modules AS m"
 276              . "\n WHERE m.module = 'mod_rssfeed'"
 277              . "\n AND m.published = 1"
 278              ;
 279              $database->setQuery( $query );
 280              $check = $database->loadResultArray();
 281              if(empty($check)) {
 282                  $show = 0;
 283              }
 284          }
 285          // outputs link tag for page
 286          if ($show) {
 287              // test if security check is enbled
 288              ?>
 289              <link rel="alternate" type="application/rss+xml" title="<?php echo $mosConfig_sitename; ?>" href="<?php echo $link_file; ?>" />
 290              <?php
 291          }
 292      }
 293  
 294      // favourites icon
 295      if ( !$mosConfig_favicon ) {
 296          $mosConfig_favicon = 'favicon.ico';
 297      }
 298      $icon = $mosConfig_absolute_path .'/images/'. $mosConfig_favicon;
 299      // checks to see if file exists
 300      if ( !file_exists( $icon ) ) {
 301          $icon = $mosConfig_live_site .'/images/favicon.ico';
 302      } else {
 303          $icon = $mosConfig_live_site .'/images/' .$mosConfig_favicon;
 304      }
 305  
 306      // outputs link tag for page
 307      ?>
 308      <link rel="shortcut icon" href="<?php echo $icon;?>" />
 309      <?php
 310  }
 311  ?>


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