| 1 | <?php
 | 
  
    | 2 | /**
 | 
  
    | 3 |  *
 | 
  
    | 4 |  * @category        Core
 | 
  
    | 5 |  * @package         Core_sys
 | 
  
    | 6 |  * @author          WebsiteBaker Project
 | 
  
    | 7 |  * @copyright      2009-, WebsiteBaker Org. e.V.
 | 
  
    | 8 |  * @link            http://websitebaker.org/
 | 
  
    | 9 |  * @license         http://www.gnu.org/licenses/gpl.html
 | 
  
    | 10 |  * @platform        WebsiteBaker 2.8.x
 | 
  
    | 11 |  * @requirements    PHP 5.2.2 and higher
 | 
  
    | 12 |  * @version         $Id: index.php 2122 2015-03-17 22:59:36Z darkviper $
 | 
  
    | 13 |  * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/index.php $
 | 
  
    | 14 |  * @lastmodified    $Date: 2015-03-17 23:59:36 +0100 (Tue, 17 Mar 2015) $
 | 
  
    | 15 |  *
 | 
  
    | 16 |  */
 | 
  
    | 17 | 
 | 
  
    | 18 | // compatibility between old and new access file format
 | 
  
    | 19 | if (isset($iPageId)) { $page_id = $iPageId; }
 | 
  
    | 20 | if (isset($page_id) && !isset($iPageId)) { $iPageId = $page_id; }
 | 
  
    | 21 | // Include config file
 | 
  
    | 22 | $sStartUpFile = __DIR__.'/framework/initialize.php';
 | 
  
    | 23 | if (file_exists($sStartUpFile) && !defined('SYSTEM_RUN')) {
 | 
  
    | 24 |     require($sStartUpFile);
 | 
  
    | 25 | }
 | 
  
    | 26 | /* ******************************************** */
 | 
  
    | 27 | // Check if the config file has been set-up
 | 
  
    | 28 | if (!defined('SYSTEM_RUN') || SYSTEM_RUN == false) {
 | 
  
    | 29 | /*
 | 
  
    | 30 |  * Remark:  HTTP/1.1 requires a qualified URI incl. the scheme, name
 | 
  
    | 31 |  * of the host and absolute path as the argument of location. Some, but
 | 
  
    | 32 |  * not all clients will accept relative URIs also.
 | 
  
    | 33 |  */
 | 
  
    | 34 |     $host       = $_SERVER['HTTP_HOST'];
 | 
  
    | 35 |     $uri        = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
 | 
  
    | 36 |     $file       = 'install/index.php';
 | 
  
    | 37 |     $target_url = 'http://'.$host.$uri.'/'.$file;
 | 
  
    | 38 |     $sResponse  = $_SERVER['SERVER_PROTOCOL'].' 307 Temporary Redirect';
 | 
  
    | 39 |     header($sResponse);
 | 
  
    | 40 |     header('Location: '.$target_url);
 | 
  
    | 41 |     exit; // make sure that subsequent code will not be executed
 | 
  
    | 42 | }
 | 
  
    | 43 | /* ******************************************** */
 | 
  
    | 44 | // dispatch RSS requests *** mandatory argument:  ?rss=$iSectionId
 | 
  
    | 45 | if (($iRssSectionId = intval((@$_GET['rss'] ?: 0))) && defined('SYSTEM_RUN')) {
 | 
  
    | 46 |     $sql = 'SELECT `module` FROM `'.$oDb-TablePrefix.'sections` '
 | 
  
    | 47 |          . 'WHERE `section_id`='.$iRssSectionId;
 | 
  
    | 48 |     if (($sRssAddon = $oDb->getOne($sql))) {
 | 
  
    | 49 |         $sRssClass = 'm_'.$sRssAddon.'_RssFeeder';
 | 
  
    | 50 |         if (class_exist($sRssClass)) {
 | 
  
    | 51 |             $oRss = new $sRssClass(WbAdapter::getInstance(), $iRssSectionId);
 | 
  
    | 52 |             $oRss->setTemplate();
 | 
  
    | 53 |             $oRss->doExecute();
 | 
  
    | 54 |             exit;
 | 
  
    | 55 |         }
 | 
  
    | 56 |     }
 | 
  
    | 57 |     RssFeederAbstract::sendRssError();
 | 
  
    | 58 |     exit;
 | 
  
    | 59 | }
 | 
  
    | 60 | /* ******************************************** */
 | 
  
    | 61 | // Create new frontend object
 | 
  
    | 62 | if (!isset($wb) || !($wb instanceof frontend)) {
 | 
  
    | 63 |     $wb = new frontend();
 | 
  
    | 64 | }
 | 
  
    | 65 | // Figure out which page to display
 | 
  
    | 66 | // Stop processing if intro page was shown
 | 
  
    | 67 | $wb->page_select() or die();
 | 
  
    | 68 | // Collect info about the currently viewed page
 | 
  
    | 69 | // and check permissions
 | 
  
    | 70 | $wb->get_page_details();
 | 
  
    | 71 | // Collect general website settings
 | 
  
    | 72 | $wb->get_website_settings();
 | 
  
    | 73 | // Load functions available to templates, modules and code sections
 | 
  
    | 74 | // also, set some aliases for backward compatibility
 | 
  
    | 75 | require($oReg->AppPath.'framework/frontend.functions.php');
 | 
  
    | 76 | // reload all of the already defined global constants
 | 
  
    | 77 | $oReg->getWbConstants();
 | 
  
    | 78 | 
 | 
  
    | 79 | // load and run template file
 | 
  
    | 80 | $output = '';
 | 
  
    | 81 | if (is_readable($oReg->TemplatePath.'index.php')) {
 | 
  
    | 82 | //    EventDispatcher::getInstance()->triggerEvent('beforeTemplateStart', 'core');
 | 
  
    | 83 | // load new Template-Code-Class if available
 | 
  
    | 84 |     if (is_readable($oReg->TemplatePath.'TemplateCode.php')) {
 | 
  
    | 85 |         require($oReg->TemplatePath.'TemplateCode.php');
 | 
  
    | 86 |         if (class_exist('TemplateCode', false)) {
 | 
  
    | 87 |             $oTpl = new TemplateCode($oReg);
 | 
  
    | 88 |             if(!$oTpl instanceof TemplateCodeAbstract) {
 | 
  
    | 89 |             // quit if TemplateCode does not implement the correct interface
 | 
  
    | 90 |                 throw new AppException('TemplateCode does not extends TemplateCodeAbstract!');
 | 
  
    | 91 |             }
 | 
  
    | 92 |         }
 | 
  
    | 93 |     }
 | 
  
    | 94 | // activate language files of the template if it's exists
 | 
  
    | 95 |     $oTrans->enableTemplate(str_replace('/', '\\', rtrim($oReg->TemplateDir, '/')));
 | 
  
    | 96 |     ob_start();
 | 
  
    | 97 |     // run the template
 | 
  
    | 98 |         require($oReg->TemplatePath.'index.php');
 | 
  
    | 99 |     // catch the output of the template
 | 
  
    | 100 |     $output = ob_get_clean();
 | 
  
    | 101 | } else {
 | 
  
    | 102 |     throw new AppException('['.$oReg->TemplateDir.'] is not a readable, valid template!!');
 | 
  
    | 103 | }
 | 
  
    | 104 | // execute frontend output filters
 | 
  
    | 105 | if(file_exists($oReg->AppPath .'modules/OutputFilter/index.php')) {
 | 
  
    | 106 |     include_once($oReg->AppPath .'modules/OutputFilter/index.php');
 | 
  
    | 107 |     if(function_exists('executeFrontendOutputFilter')) {
 | 
  
    | 108 |         $output = executeFrontendOutputFilter($output);
 | 
  
    | 109 |     }
 | 
  
    | 110 | }
 | 
  
    | 111 | /* *** trigger event to replace overcomming outputFilter ****************************** */
 | 
  
    | 112 | //if (($oEvent = EventDispatcher::getInstance())) {
 | 
  
    | 113 | //    $oEvent->triggerEvent('beforeContentSend', 'core', $output);
 | 
  
    | 114 | //    $output = $oEvent->getInfo();
 | 
  
    | 115 | //}
 | 
  
    | 116 | /* ************************************************************************************ */
 | 
  
    | 117 | // check if headers already sent
 | 
  
    | 118 | $sFile = $sLine = '';
 | 
  
    | 119 | if (headers_sent($sFile, $sLine)) {
 | 
  
    | 120 |     $sMsg = 'headers already sent in '.$sFile.' in Line '.$sLine.'!! '.PHP_EOL
 | 
  
    | 121 |           . 'it is not possible to set the right charset for your site!';
 | 
  
    | 122 |     throw new RuntimeException($sMsg);
 | 
  
    | 123 | }
 | 
  
    | 124 | // send header to fix IE-Charset-bug which ignores <meta charset="xx">
 | 
  
    | 125 | // -- prepared to send the header-buffer (including Cookies) in future --//
 | 
  
    | 126 | header('Content-Type: text/html; charset='.$oReg->DefaultCharset);
 | 
  
    | 127 | flush();
 | 
  
    | 128 | // now send the complete content to the browser
 | 
  
    | 129 | echo $output;
 | 
  
    | 130 | flush();
 | 
  
    | 131 | //if (($oEvent = EventDispatcher::getInstance()->triggerEvent('afterContentSend', 'core'))) {
 | 
  
    | 132 | // end of wb-script
 | 
  
    | 133 | exit;
 |