-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
150 lines (128 loc) · 4.22 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
146
147
148
149
150
<?php
session_start();
define('CACHE_DIR', 'cms/cache/');
// get query string passed by mod_rewrite:
if(isset($_GET['qs']))
{
if(get_magic_quotes_gpc()) $_GET['qs'] = stripslashes($_GET['qs']);
$qs = $_GET['qs'];
}
else
{$qs = '';}
/* comment the following line if you DONOT want to have automatic mobile web */
if(isset($_GET['mobile'])) {$mobile=TRUE;} else {$mobile=FALSE;}
// check if requested page is cached and if so displays it:
if(empty($_POST) && file_exists('./'.CACHE_DIR.'settings.php'))
{
include('./'.CACHE_DIR.'settings.php');
if(empty($_SESSION[$settings['session_prefix'].'user_id']))
{
if($qs=='') $cache_file = rawurlencode(strtolower($settings['index_page'])).'.cache';
else $cache_file = rawurlencode(strtolower($qs)).'.cache';
if(file_exists('./'.CACHE_DIR.$cache_file))
{
include('./'.CACHE_DIR.$cache_file);
exit; // that's it if cached page is available.
}
}
}
define('IN_INDEX', TRUE);
try
{
require('./cms/includes/functions.inc.php');
// load replacement functions for the multibyte string functions
// if they are not available:
if(!defined('MB_CASE_LOWER')) require('./cms/includes/functions.mb_replacements.inc.php');
require('./cms/includes/classes/Database.class.php');
$database = new Database();
$settings = get_settings();
// access permission check for not registered users:
if($settings['check_access_permission']==1 && !isset($_SESSION[$settings['session_prefix'].'user_id']))
{
if(is_access_denied()) raise_error('403');
}
// set timezone:
if($settings['time_zone']) date_default_timezone_set($settings['time_zone']);
define('BASE_URL', get_base_url());
define('BASE_PATH', get_base_path());
define('MEDIA_DIR', 'media/');
define('SMILIES_DIR', 'media/smilies/');
define('IMAGE_IDENTIFIER', 'photo');
define('CATEGORY_IDENTIFIER', 'tag_');
define('AMPERSAND_REPLACEMENT', ':AMP:');
define('WYSIWYG_EDITOR', 'cms/modules/tiny_mce/tiny_mce.js');
if($settings['content_functions']==1) require(BASE_PATH.'cms/includes/functions.content.inc.php');
require('./cms/includes/classes/Template.class.php');
$template = new Template();
if($settings['caching'])
{
$cache = new Cache(BASE_PATH.CACHE_DIR, $settings);
if(!empty($_POST) || isset($_SESSION[$settings['session_prefix'].'user_id']))
{
$cache->doCaching = false;
}
}
if(isset($_SESSION[$settings['session_prefix'].'user_id']))
{
$template->assign('admin', true);
}
else
{
$template->assign('admin', false);
}
$template->assign('settings', $settings);
$template->assign('BASE_URL', BASE_URL);
$qsp = explode(',',$qs);
if($qsp[0] == '')
{
define('PAGE', strtolower($settings['index_page']));
}
else
{
define('PAGE',strtolower($qsp[0]));
}
// append comma separated parameters to $_GET ($_GET['get_1'], $_GET['get_2'] etc.):
if(isset($qsp[1]))
{
$items = count($qsp);
for($i=1;$i<$items;++$i)
{
$_GET['get_'.$i] = $qsp[$i];
}
}
if(isset($_GET['get_1']) && $_GET['get_1']==IMAGE_IDENTIFIER && isset($_GET['get_2']))
{
// photo:
include(BASE_PATH.'cms/includes/photo.inc.php');
}
else
{
// regular content:
include(BASE_PATH.'cms/includes/content.inc.php');
}
// comment the following line if you DONOT want to have automatic mobile web
if($mobile && $settings['mobile']=="1") $template_file=isset($template_mobile_file)?$template_mobile_file:$template_file;
// display template:
if(isset($template_file))
{
$template->assign('lang', Localization::$lang);
$template->assign('content_type', $content_type);
$template->assign('charset', Localization::$lang['charset']);
header('Content-Type: '.$content_type.'; charset='.Localization::$lang['charset']);
$template->display(BASE_PATH.'templates/'.$template_file);
// create cache file:
if(isset($cache))
{
if($cache->cacheId && $cache->doCaching)
{
$cache_content = $cache->createCacheContent($template->fetch(BASE_PATH.'templates/'.$template_file), $content_type, CHARSET);
$cache->createChacheFile($cache_content);
}
}
}
} // end try
catch(Exception $exception)
{
include('./cms/includes/exception.inc.php');
}
?>