Project

General

Profile

1 1373 Luisehahne
<?php
2
/**
3
 *
4
 * @category        frontend
5
 * @package         page
6
 * @author          WebsiteBaker Project
7 1520 darkviper
 * @copyright       2009-, Website Baker Org. e.V.
8 1373 Luisehahne
 * @link			http://www.websitebaker2.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$
13
 * @filesource		$HeadURL$
14
 * @lastmodified    $Date$
15
 *
16
 */
17
18
// Include config file
19
$config_file = dirname(__FILE__).'/config.php';
20
if(file_exists($config_file))
21
{
22
	require_once($config_file);
23
}
24
25
// Check if the config file has been set-up
26 1450 DarkViper
if(!defined('TABLE_PREFIX'))
27 1373 Luisehahne
{
28
/*
29 1450 DarkViper
 * Remark:  HTTP/1.1 requires a qualified URI incl. the scheme, name
30
 * of the host and absolute path as the argument of location. Some, but
31
 * not all clients will accept relative URIs also.
32 1373 Luisehahne
 */
33
	$host       = $_SERVER['HTTP_HOST'];
34 1383 FrankH
	$uri        = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
35 1373 Luisehahne
	$file       = 'install/index.php';
36
	$target_url = 'http://'.$host.$uri.'/'.$file;
37 1450 DarkViper
	$sResponse  = $_SERVER['SERVER_PROTOCOL'].' 307 Temporary Redirect';
38
	header($sResponse);
39 1373 Luisehahne
	header('Location: '.$target_url);
40
	exit;	// make sure that subsequent code will not be executed
41
}
42
43
require_once(WB_PATH.'/framework/class.frontend.php');
44
// Create new frontend object
45
$wb = new frontend();
46
47
// Figure out which page to display
48
// Stop processing if intro page was shown
49
$wb->page_select() or die();
50
51
// Collect info about the currently viewed page
52
// and check permissions
53
$wb->get_page_details();
54
55
// Collect general website settings
56
$wb->get_website_settings();
57
58
// Load functions available to templates, modules and code sections
59
// also, set some aliases for backward compatibility
60
require(WB_PATH.'/framework/frontend.functions.php');
61
62
// redirect menu-link
63
$this_page_id = PAGE_ID;
64
65
$php43 = version_compare(phpversion(), '4.3', '>=');
66
67
$sql  = 'SELECT `module`, `block` FROM `'.TABLE_PREFIX.'sections` ';
68
$sql .= 'WHERE `page_id` = '.(int)$this_page_id.' AND `module` = "menu_link"';
69
$query_this_module = $database->query($sql);
70
if($query_this_module->numRows() == 1)  // This is a menu_link. Get link of target-page and redirect
71
{
72
	// get target_page_id
73
	$sql  = 'SELECT * FROM `'.TABLE_PREFIX.'mod_menu_link` WHERE `page_id` = '.(int)$this_page_id;
74
	$query_tpid = $database->query($sql);
75
	if($query_tpid->numRows() == 1)
76
	{
77
		$res = $query_tpid->fetchRow();
78
		$target_page_id = $res['target_page_id'];
79
		$redirect_type = $res['redirect_type'];
80
		$anchor = ($res['anchor'] != '0' ? '#'.(string)$res['anchor'] : '');
81
		$extern = $res['extern'];
82
		// set redirect-type
83
		if($redirect_type == 301)
84
		{
85
			if($php43)
86
			{
87
				@header('HTTP/1.1 301 Moved Permanently', TRUE, 301);
88
			}
89
			else
90
			{
91
				@header('HTTP/1.1 301 Moved Permanently');
92
			}
93
		}
94
		if($target_page_id == -1)
95
		{
96
			if($extern != '')
97
			{
98
				$target_url = $extern.$anchor;
99
				header('Location: '.$target_url);
100
				exit;
101
			}
102
		}
103
		else
104
		{
105
			// get link of target-page
106
			$sql  = 'SELECT `link` FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$target_page_id;
107
			$target_page_link = $database->get_one($sql);
108
			if($target_page_link != null)
109
			{
110
				$target_url = WB_URL.PAGES_DIRECTORY.$target_page_link.PAGE_EXTENSION.$anchor;
111
				header('Location: '.$target_url);
112
				exit;
113
			}
114
		}
115
	}
116
}
117
//Get pagecontent in buffer for Droplets and/or Filter operations
118
ob_start();
119
require(WB_PATH.'/templates/'.TEMPLATE.'/index.php');
120
$output = ob_get_contents();
121
if(ob_get_length() > 0) { ob_end_clean(); }
122 1626 darkviper
// execute frontend output filters
123
	if(file_exists(WB_PATH .'/modules/output_filter/index.php')) {
124
		include_once(WB_PATH .'/modules/output_filter/index.php');
125 1520 darkviper
		if(function_exists('executeFrontendOutputFilter')) {
126
			$output = executeFrontendOutputFilter($output);
127
		}
128
	}
129 1450 DarkViper
// now send complete page to the browser
130 1373 Luisehahne
echo $output;
131
// end of wb-script
132
exit;