forked from LEPTON-project/LEPTON
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
145 lines (128 loc) · 4.5 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
/**
* This file is part of LEPTON Core, released under the GNU GPL
* Please see LICENSE and COPYING files in your package for details, specially for terms and warranties.
*
* NOTICE:LEPTON CMS Package has several different licenses.
* Please see the individual license in the header of each single file or info.php of modules and templates.
*
* @author Website Baker Project, LEPTON Project
* @copyright 2004-2010 Website Baker Org. e.V.
* @copyright 2010-2015 LEPTON Project
* @link http://www.LEPTON-cms.org
* @license http://www.gnu.org/licenses/gpl.html
* @license_terms please see LICENSE and COPYING files in your package
* @version LEPTON 2
*/
$starttime = array_sum(explode(" ",microtime()));
define('DEBUG', true);
define("FRONTEND", true);
// Include config file
$config_file = dirname(__FILE__).'/config.php';
if(file_exists($config_file))
{
require_once($config_file);
} else {
/**
* File isn't there, so we try to run the installer
*
* Anmerkung: HTTP/1.1 verlangt einen absoluten URI inklusive dem Schema,
* Hostnamen und absoluten Pfad als Argument von Location:, manche, aber nicht alle
* Clients akzeptieren jedoch auch relative URIs.
*/
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
$file = 'install/index.php';
$target_url = 'http://'.$host.$uri.'/'.$file;
header('Location: '.$target_url);
die(); // make sure that the code below will not be executed
}
require_once(LEPTON_PATH.'/framework/class.frontend.php');
// Create new frontend object
$wb = new frontend();
// Figure out which page to display
// Stop processing if intro page was shown
$wb->page_select() or die();
// Collect info about the currently viewed page
// and check permissions
$wb->get_page_details();
// Collect general website settings
$wb->get_website_settings();
// Load functions available to templates, modules and code sections
// also, set some aliases for backward compatibility
require(LEPTON_PATH.'/framework/summary.frontend_functions.php');
// redirect menu-link
$this_page_id = PAGE_ID;
$sql = 'SELECT `module`, `block` FROM `'.TABLE_PREFIX.'sections` ';
$sql .= 'WHERE `page_id` = '.(int)$this_page_id.' AND `module` = "menu_link"';
$query_this_module = $database->query($sql);
if($query_this_module->numRows() == 1) // This is a menu_link. Get link of target-page and redirect
{
// get target_page_id
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_menu_link` WHERE `page_id` = '.(int)$this_page_id;
$query_tpid = $database->query($sql);
if($query_tpid->numRows() == 1)
{
$res = $query_tpid->fetchRow( MYSQL_ASSOC );
$target_page_id = $res['target_page_id'];
$redirect_type = $res['redirect_type'];
$anchor = ($res['anchor'] != '0' ? '#'.(string)$res['anchor'] : '');
$extern = $res['extern'];
// set redirect-type
if($redirect_type == 301) {
@header('HTTP/1.1 301 Moved Permanently', TRUE, 301);
}
if($target_page_id == -1)
{
if($extern != '')
{
$target_url = $extern.$anchor;
header('Location: '.$target_url);
exit;
}
}
else
{
// get link of target-page
$sql = 'SELECT `link` FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$target_page_id;
$target_page_link = $database->get_one($sql);
if($target_page_link != null)
{
$target_url = LEPTON_URL.PAGES_DIRECTORY.$target_page_link.PAGE_EXTENSION.$anchor;
header('Location: '.$target_url);
exit;
}
}
}
}
//Get pagecontent in buffer for Droplets and/or Filter operations
ob_start();
require(LEPTON_PATH.'/templates/'.TEMPLATE.'/index.php');
$output = ob_get_clean();
// wb->preprocess() -- replace all [wblink123] with real, internal links
$wb->preprocess($output);
// Load Droplet engine and process
if(file_exists(LEPTON_PATH .'/modules/droplets/droplets.php'))
{
include_once(LEPTON_PATH .'/modules/droplets/droplets.php');
if(function_exists('evalDroplets'))
{
evalDroplets($output);
}
}
// Output interface for Addons
if(file_exists(LEPTON_PATH .'/modules/output_interface/output_interface.php')) {
include_once(LEPTON_PATH .'/modules/output_interface/output_interface.php');
if(function_exists('output_interface')) {
output_interface($output);
}
}
// CSRF protection - add tokens to internal links
if ($wb->is_authenticated()) {
if (file_exists(LEPTON_PATH .'/framework/functions/function.addTokens.php')) {
include_once(LEPTON_PATH .'/framework/functions/function.addTokens.php');
if (function_exists('addTokens')) addTokens($output, $wb);
}
}
echo $output;
?>