[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/sitemgr/sitemgr-site/ -> index.php (source)

   1  <?php
   2      /**************************************************************************\
   3      * eGroupWare SiteMgr - Web Content Management                              *
   4      * http://www.egroupware.org                                                *
   5      * --------------------------------------------                             *
   6      *  This program is free software; you can redistribute it and/or modify it *
   7      *  under the terms of the GNU General Public License as published by the   *
   8      *  Free Software Foundation; either version 2 of the License, or (at your  *
   9      *  option) any later version.                                              *
  10      \**************************************************************************/
  11  
  12      /* $Id: index.php 22650 2006-10-16 20:55:25Z nelius_weiss $ */
  13  
  14      $site_id=0;
  15      /**
  16       * Determine the site from the URL ($_SERVER['PHP_SELF'])
  17       * 
  18       * @param array &$anon_account anon account_info with keys 'user', 'passwd' and optional 'passwd_type'
  19       * @return boolean true if a site is found or dies if not site defined for the URL
  20       */
  21  	function sitemgr_get_site(&$anon_account)
  22      {
  23          global $site_url, $site_id, $sitemgr_info;
  24  
  25          $site_urls[] = $path = preg_replace('/\/[^\/]*$/','',$_SERVER['PHP_SELF']) . '/';
  26          $site_urls[] = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_ADDR'] . $path;
  27          $site_urls[] = $site_url  = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . $path;
  28  
  29          //echo "<p>sitemgr_get_site('$site_url')</p>\n";
  30          $GLOBALS['egw']->db->select('egw_sitemgr_sites','anonymous_user,anonymous_passwd,site_id',
  31              array('site_url' => $site_urls),__LINE__,__FILE__,false,'','sitemgr');
  32  
  33          if ($GLOBALS['egw']->db->next_record())
  34          {
  35              $anon_account = array(
  36                  'login'  => $GLOBALS['egw']->db->f('anonymous_user'),
  37                  'passwd' => $GLOBALS['egw']->db->f('anonymous_passwd'),
  38                  'passwd_type' => 'text',
  39              );
  40              $sitemgr_info['anonymous_user'] = $anon_account['login'];
  41              
  42              if($GLOBALS['egw_info']['server']['allow_cookie_auth'])
  43              {
  44                  $eGW_remember = explode('::::',stripslashes($_COOKIE['eGW_remember']));
  45                  if($eGW_remember[0] && $eGW_remember[1] && $eGW_remember[2])
  46                  {
  47                      $anon_account = array(
  48                          'login' => $eGW_remember[0],
  49                          'passwd' => $eGW_remember[1],
  50                          'passwd_type' => $eGW_remember[2],
  51                      );
  52                  }
  53              }
  54              if (!$anon_account['login'])
  55              {
  56                  die(lang('NO ANONYMOUS USER ACCOUNTS INSTALLED.  NOTIFY THE ADMINISTRATOR.'));
  57              }
  58              $site_id = $GLOBALS['egw']->db->f('site_id');
  59              //echo "<p>sitemgr_get_site('$site_url') site_id=$site_id, anon_account=".print_r($anon_account,true)."</p>\n";
  60              return true;
  61          }
  62          die(lang('THERE IS NO WEBSITE CONFIGURED FOR URL %1.  NOTIFY THE ADMINISTRATOR.',$site_url.' ('.$GLOBALS['egw_info']['server']['default_domain'].')'));
  63      }
  64  
  65      $GLOBALS['egw_info'] = array(
  66          'flags' => array(
  67              'disable_Template_class' => True,
  68              'noheader'   => True,
  69              'currentapp' => 'sitemgr-link',
  70              'autocreate_session_callback' => 'sitemgr_get_site',
  71      ));
  72  
  73      include ('./config.inc.php');
  74  
  75      // do we use a different domain and are already loged in?
  76      if (isset($GLOBALS['egw_info']['server']['default_domain']) && 
  77          @$_REQUEST['domain'] != $GLOBALS['egw_info']['server']['default_domain'])
  78      {
  79          // force our default domain
  80          $_GET['domain'] = $_COOKIE['domain'] = $_REQUEST['domain'] = $GLOBALS['egw_info']['server']['default_domain'];
  81          unset($_GET['sessionid']);
  82          unset($_COOKIE['sessionid']);
  83          unset($_REQUEST['sessionid']);
  84      }
  85      if (!file_exists($sitemgr_info['egw_path'] . 'header.inc.php'))
  86      {
  87          die("Header file not found.  Either your path to eGroupWare in the config.inc.php file is bad, or you have not setup eGroupWare.");
  88      }
  89  
  90      include($sitemgr_info['egw_path'] . 'header.inc.php');
  91  
  92      if (!$site_id)
  93      {
  94          sitemgr_get_site($anon_account);
  95      }
  96      
  97      // switch to current website. 
  98      if ($GLOBALS['egw_info']['user']['preferences']['sitemgr']['currentsite'] != $site_id)
  99      {
 100          $GLOBALS['egw_info']['user']['preferences']['sitemgr']['currentsite'] = $site_id;
 101          $GLOBALS['egw']->preferences->change('sitemgr','currentsite', $site_id);
 102          $GLOBALS['egw']->preferences->save_repository(True);
 103      }
 104  
 105      if($GLOBALS['egw_info']['server']['usecookies'] && $_COOKIE['sessionid'] != $GLOBALS['egw_info']['user']['sessionid'])
 106      {
 107          // happens if eGW runs on cookies and sitemgr has to use an URL to forward the session to the other site/domain
 108          $GLOBALS['egw']->session->phpgw_setcookie('sessionid',$GLOBALS['egw_info']['user']['sessionid']);
 109          $GLOBALS['egw']->session->phpgw_setcookie('kp3',$GLOBALS['egw_info']['user']['kp3']);
 110          $GLOBALS['egw']->session->phpgw_setcookie('domain',$GLOBALS['egw_info']['user']['domain']);
 111      }
 112      include ('./functions.inc.php');
 113  
 114      $Common_BO =& CreateObject('sitemgr.Common_BO');
 115      require_once  './inc/class.sitebo.inc.php';
 116      $objbo =& new sitebo;
 117      $Common_BO->sites->set_currentsite($site_url,$objbo->getmode());
 118      if($objbo->getmode() != 'Production')
 119      {
 120          // we need this to avoid the "attempt to access ..." errors if users contribute to multiple websites.
 121          // This does not solve the Problem if they work simultanus in two browsers :-(
 122          $GLOBALS['egw']->preferences->change('sitemgr','currentsite', $Common_BO->sites->urltoid($site_url));
 123          $GLOBALS['egw']->preferences->save_repository(True);
 124      }
 125      $sitemgr_info = array_merge($sitemgr_info,$Common_BO->sites->current_site);
 126      $sitemgr_info['sitelanguages'] = explode(',',$sitemgr_info['site_languages']);
 127      $objbo->setsitemgrPreferredLanguage();
 128      $GLOBALS['egw']->translation->add_app('common');    // as we run as sitemgr-site
 129      $GLOBALS['egw']->translation->add_app('sitemgr');    // as we run as sitemgr-site
 130  
 131      $templateroot = $GLOBALS['sitemgr_info']['site_dir'] . SEP . 'templates' . SEP . $GLOBALS['sitemgr_info']['themesel'];
 132  
 133      include_once  './inc/class.Template3.inc.php';
 134      if (file_exists($templateroot.'/main.tpl'))            // native sitemgr template
 135      {
 136          include_once  './inc/class.ui.inc.php';
 137      }
 138      elseif (file_exists($templateroot.'/index.php'))    // mambo open source template
 139      {
 140          include_once  './inc/class.mos_ui.inc.php';
 141      }
 142      if (!class_exists('ui'))
 143      {
 144          echo '<h3>'.lang("Invalid template directory '%1' !!!",$templateroot)."</h3>\n";
 145          if (!is_dir($GLOBALS['sitemgr_info']['site_dir'] . SEP . 'templates') || !is_readable($GLOBALS['sitemgr_info']['site_dir'] . SEP . 'templates'))
 146          {
 147              echo lang("The filesystem path to your sitemgr-site directory '%1' is probably wrong. Go to SiteMgr --> Define Websites and edit/fix the concerned Site.",$GLOBALS['sitemgr_info']['site_dir']);
 148          }
 149          elseif (!is_dir($templateroot) || !is_readable($templateroot))
 150          {
 151              echo lang("You may have deinstalled the used template '%1'. Reinstall it or go to SiteMgr --> Configure Website and select an other one.",$GLOBALS['sitemgr_info']['themesel']);
 152          }
 153          $GLOBALS['egw']->common->egw_exit();
 154      }
 155      $objui =& new ui;
 156  
 157      $page =& CreateObject('sitemgr.Page_SO');
 158  
 159      $page_id = $_GET['page_id'];
 160      $page_name = $_GET['page_name'];
 161      $category_id = $_GET['category_id'];
 162      $toc = $_GET['toc'];
 163      $index = $_GET['index'];
 164  
 165      if ($page_name && $page_name != 'index.php')
 166      {
 167          $objui->displayPageByName($page_name);
 168      }
 169      elseif($category_id)
 170      {
 171          $cat = $Common_BO->cats->getCategory($category_id);
 172          if ($cat->index_page_id > 0)
 173          {
 174              $page = $Common_BO->pages->getPage($cat->index_page_id);
 175              if ($page->id)
 176              {
 177                  $objui->displayPage($page->id);
 178              }
 179          }
 180          if (!$cat->index_page_id || !is_object($page) || !$page->id)    // fallback to regular toc if index-page is missing
 181          {
 182              $objui->displayTOC($category_id);
 183          }
 184      }
 185      elseif ($page_id)
 186      {
 187          $objui->displayPage($page_id);
 188      }
 189      elseif (isset($index))
 190      {
 191          $objui->displayIndex();
 192      }
 193      elseif (isset($toc))
 194      {
 195          $objui->displayTOC();
 196      }
 197      else
 198      {
 199          if ($sitemgr_info['home_page_id'])
 200          {
 201              $objui->displayPage($sitemgr_info['home_page_id']);
 202          }
 203          else
 204          {
 205              $index = 1; 
 206              $objui->displayIndex();
 207          }
 208      }
 209      if (DEBUG_TIMER)
 210      {
 211          $GLOBALS['debug_timer_stop'] = perfgetmicrotime();
 212          echo 'Page loaded in ' . ($GLOBALS['debug_timer_stop'] - $GLOBALS['debug_timer_start']) . ' seconds.';
 213      }
 214  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7