| 1 | 1373 | Luisehahne | <?php
 | 
      
        | 2 |  |  | /**
 | 
      
        | 3 |  |  |  *
 | 
      
        | 4 | 1848 | darkviper |  * @category        Core
 | 
      
        | 5 |  |  |  * @package         Core_sys
 | 
      
        | 6 | 1373 | Luisehahne |  * @author          WebsiteBaker Project
 | 
      
        | 7 | 2122 | darkviper |  * @copyright      2009-, WebsiteBaker Org. e.V.
 | 
      
        | 8 |  |  |  * @link            http://websitebaker.org/
 | 
      
        | 9 | 1373 | Luisehahne |  * @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$
 | 
      
        | 13 | 2122 | darkviper |  * @filesource      $HeadURL$
 | 
      
        | 14 | 1373 | Luisehahne |  * @lastmodified    $Date$
 | 
      
        | 15 |  |  |  *
 | 
      
        | 16 |  |  |  */
 | 
      
        | 17 |  |  | 
 | 
      
        | 18 | 1948 | darkviper | // 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 | 1373 | Luisehahne | // Include config file
 | 
      
        | 22 | 2122 | darkviper | $sStartUpFile = __DIR__.'/framework/initialize.php';
 | 
      
        | 23 |  |  | if (file_exists($sStartUpFile) && !defined('SYSTEM_RUN')) {
 | 
      
        | 24 |  |  |     require($sStartUpFile);
 | 
      
        | 25 | 1373 | Luisehahne | }
 | 
      
        | 26 | 2122 | darkviper | /* ******************************************** */
 | 
      
        | 27 | 1373 | Luisehahne | // Check if the config file has been set-up
 | 
      
        | 28 | 2122 | darkviper | if (!defined('SYSTEM_RUN') || SYSTEM_RUN == false) {
 | 
      
        | 29 | 1373 | Luisehahne | /*
 | 
      
        | 30 | 1450 | DarkViper |  * 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 | 1373 | Luisehahne |  */
 | 
      
        | 34 | 2122 | darkviper |     $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 | 1373 | Luisehahne | }
 | 
      
        | 43 | 2122 | darkviper | /* ******************************************** */
 | 
      
        | 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 | 1373 | Luisehahne | // Create new frontend object
 | 
      
        | 62 | 1848 | darkviper | if (!isset($wb) || !($wb instanceof frontend)) {
 | 
      
        | 63 | 1782 | Luisehahne |     $wb = new frontend();
 | 
      
        | 64 |  |  | }
 | 
      
        | 65 | 1373 | Luisehahne | // 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 | 2122 | darkviper | require($oReg->AppPath.'framework/frontend.functions.php');
 | 
      
        | 76 | 2011 | darkviper | // reload all of the already defined global constants
 | 
      
        | 77 | 2122 | darkviper | $oReg->getWbConstants();
 | 
      
        | 78 | 1373 | Luisehahne | 
 | 
      
        | 79 | 2122 | darkviper | // 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 | 1626 | darkviper | // execute frontend output filters
 | 
      
        | 105 | 2122 | darkviper | 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 | 1373 | Luisehahne | echo $output;
 | 
      
        | 130 | 2122 | darkviper | flush();
 | 
      
        | 131 |  |  | //if (($oEvent = EventDispatcher::getInstance()->triggerEvent('afterContentSend', 'core'))) {
 | 
      
        | 132 | 1373 | Luisehahne | // end of wb-script
 | 
      
        | 133 |  |  | exit;
 |