Revision 2122
Added by darkviper over 10 years ago
| index.php | ||
|---|---|---|
| 4 | 4 |
* @category Core |
| 5 | 5 |
* @package Core_sys |
| 6 | 6 |
* @author WebsiteBaker Project |
| 7 |
* @copyright 2009-, WebsiteBaker Org. e.V.
|
|
| 8 |
* @link http://www.websitebaker2.org/
|
|
| 7 |
* @copyright 2009-, WebsiteBaker Org. e.V. |
|
| 8 |
* @link http://websitebaker.org/
|
|
| 9 | 9 |
* @license http://www.gnu.org/licenses/gpl.html |
| 10 | 10 |
* @platform WebsiteBaker 2.8.x |
| 11 | 11 |
* @requirements PHP 5.2.2 and higher |
| 12 | 12 |
* @version $Id$ |
| 13 |
* @filesource $HeadURL$
|
|
| 13 |
* @filesource $HeadURL$
|
|
| 14 | 14 |
* @lastmodified $Date$ |
| 15 | 15 |
* |
| 16 | 16 |
*/ |
| ... | ... | |
| 19 | 19 |
if (isset($iPageId)) { $page_id = $iPageId; }
|
| 20 | 20 |
if (isset($page_id) && !isset($iPageId)) { $iPageId = $page_id; }
|
| 21 | 21 |
// Include config file |
| 22 |
$config_file = dirname(__FILE__).'/config.php'; |
|
| 23 |
if(file_exists($config_file) && !defined('WB_URL'))
|
|
| 24 |
{
|
|
| 25 |
require_once($config_file); |
|
| 22 |
$sStartUpFile = __DIR__.'/framework/initialize.php'; |
|
| 23 |
if (file_exists($sStartUpFile) && !defined('SYSTEM_RUN')) {
|
|
| 24 |
require($sStartUpFile); |
|
| 26 | 25 |
} |
| 26 |
/* ******************************************** */ |
|
| 27 | 27 |
// Check if the config file has been set-up |
| 28 |
if(!defined('TABLE_PREFIX'))
|
|
| 29 |
{
|
|
| 28 |
if (!defined('SYSTEM_RUN') || SYSTEM_RUN == false) {
|
|
| 30 | 29 |
/* |
| 31 | 30 |
* Remark: HTTP/1.1 requires a qualified URI incl. the scheme, name |
| 32 | 31 |
* of the host and absolute path as the argument of location. Some, but |
| 33 | 32 |
* not all clients will accept relative URIs also. |
| 34 | 33 |
*/ |
| 35 |
$host = $_SERVER['HTTP_HOST'];
|
|
| 36 |
$uri = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
|
|
| 37 |
$file = 'install/index.php';
|
|
| 38 |
$target_url = 'http://'.$host.$uri.'/'.$file;
|
|
| 39 |
$sResponse = $_SERVER['SERVER_PROTOCOL'].' 307 Temporary Redirect';
|
|
| 40 |
header($sResponse);
|
|
| 41 |
header('Location: '.$target_url);
|
|
| 42 |
exit; // make sure that subsequent code will not be executed
|
|
| 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
|
|
| 43 | 42 |
} |
| 44 |
|
|
| 45 |
//require_once(WB_PATH.'/framework/class.frontend.php'); |
|
| 46 |
|
|
| 47 |
if(!class_exists('frontend', false)){ include(WB_PATH.'/framework/class.frontend.php'); }
|
|
| 48 |
|
|
| 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 |
/* ******************************************** */ |
|
| 49 | 61 |
// Create new frontend object |
| 50 | 62 |
if (!isset($wb) || !($wb instanceof frontend)) {
|
| 51 | 63 |
$wb = new frontend(); |
| 52 | 64 |
} |
| 53 |
|
|
| 54 | 65 |
// Figure out which page to display |
| 55 | 66 |
// Stop processing if intro page was shown |
| 56 | 67 |
$wb->page_select() or die(); |
| 57 |
|
|
| 58 | 68 |
// Collect info about the currently viewed page |
| 59 | 69 |
// and check permissions |
| 60 | 70 |
$wb->get_page_details(); |
| 61 |
|
|
| 62 | 71 |
// Collect general website settings |
| 63 | 72 |
$wb->get_website_settings(); |
| 64 |
|
|
| 65 | 73 |
// Load functions available to templates, modules and code sections |
| 66 | 74 |
// also, set some aliases for backward compatibility |
| 67 |
require(WB_PATH.'/framework/frontend.functions.php');
|
|
| 75 |
require($oReg->AppPath.'framework/frontend.functions.php');
|
|
| 68 | 76 |
// reload all of the already defined global constants |
| 69 |
WbAdaptor::getInstance()->getWbConstants(); |
|
| 70 |
// redirect menu-link |
|
| 71 |
/** |
|
| 72 |
* |
|
| 73 |
* Removed the extra handling of menu links in index.php |
|
| 74 |
* Moved it to the view.php of module menu links. |
|
| 75 |
* Now the extra functionality of this module is seperated from the |
|
| 76 |
* core and you can uninstall it if you like. |
|
| 77 |
* Freeing the core from unnecessary code. |
|
| 78 |
* |
|
| 79 |
* |
|
| 80 |
*/ |
|
| 77 |
$oReg->getWbConstants(); |
|
| 81 | 78 |
|
| 82 |
ob_start(); |
|
| 83 |
require(WB_PATH.'/templates/'.TEMPLATE.'/index.php'); |
|
| 84 |
$output = ob_get_contents(); |
|
| 85 |
if(ob_get_length() > 0) { ob_end_clean(); }
|
|
| 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 |
} |
|
| 86 | 104 |
// execute frontend output filters |
| 87 |
if(file_exists(WB_PATH .'/modules/output_filter/index.php')) {
|
|
| 88 |
include_once(WB_PATH .'/modules/output_filter/index.php'); |
|
| 89 |
if(function_exists('executeFrontendOutputFilter')) {
|
|
| 90 |
$output = executeFrontendOutputFilter($output); |
|
| 91 |
} |
|
| 92 |
} |
|
| 93 |
// now send complete page to the browser |
|
| 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 |
|
| 94 | 129 |
echo $output; |
| 130 |
flush(); |
|
| 131 |
//if (($oEvent = EventDispatcher::getInstance()->triggerEvent('afterContentSend', 'core'))) {
|
|
| 95 | 132 |
// end of wb-script |
| 96 | 133 |
exit; |
Also available in: Unified diff
! /index.php adapted for WB-2.8.4