forked from glFusion/glfusion
/
index.php
306 lines (267 loc) · 13.6 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<?php
// +--------------------------------------------------------------------------+
// | glFusion CMS |
// +--------------------------------------------------------------------------+
// | index.php |
// | |
// | This is the admin index page that does nothing more that login you in. |
// +--------------------------------------------------------------------------+
// | Copyright (C) 2008-2016 by the following authors: |
// | |
// | Mark R. Evans mark AT glfusion DOT org |
// | Joe Mucchiello joe AT throwingdice DOT com |
// | |
// | Copyright (C) 2000-2008 by the following authors: |
// | |
// | Authors: Jason Whittenburg - jwhitten AT securitygeeks DOT com |
// +--------------------------------------------------------------------------+
// | |
// | This program is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU General Public License |
// | as published by the Free Software Foundation; either version 2 |
// | of the License, or (at your option) any later version. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software Foundation, |
// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// | |
// +--------------------------------------------------------------------------+
require_once '../lib-common.php';
require_once 'auth.inc.php';
// MAIN
if (isset($_GET['mode']) && ($_GET['mode'] == 'logout')) {
print COM_refresh($_CONF['site_url'] . '/users.php?mode=logout');
}
// this defines the amount of icons displayed next to another in the CC-block
define ('ICONS_PER_ROW', 6);
function _checkUpgrades()
{
global $_CONF, $_TABLES, $LANG_UPGRADE;
$retval = '';
$lastrun = DB_getItem( $_TABLES['vars'], 'value', "name = 'updatecheck'" );
if ( $lastrun + $_CONF['update_check_interval'] <= time() ) {
// run version check
list($upToDate,$pluginsUpToDate,$pluginData) = _checkVersion();
if ( $upToDate == 0 || $pluginsUpToDate == 0 ) {
$retval = '<p style="width:100%;text-align:center;"><span class="alert pluginAlert" style="text-align:center;font-size:1.5em;">' . $LANG_UPGRADE['updates_available'] . '</span></p>';
}
DB_query("REPLACE INTO {$_TABLES['vars']} (name, value) VALUES ('updatecheck',UNIX_TIMESTAMP())");
}
return $retval;
}
/**
* Renders an entry (icon) for the "Command and Control" center
*
* @param template $template template to use
* @param string $url URL the entry links to
* @param string $image URL of the icon
* @param string $label text to use under the icon
* @return void
*
*/
function render_cc_item (&$template, $url = '', $image = '', $label = '')
{
if (!empty ($url)) {
$template->set_var ('page_url', $url);
$template->set_var ('page_image', $image);
$template->set_var ('option_label', $label);
$template->set_var ('cell_width', ((int)(100 / ICONS_PER_ROW)) . '%');
return $template->parse ('cc_main_options', 'ccitem', false);
}
return '';
}
/**
* Prints the command & control block at the top
*
* TODO: The moderation items should be displayed with the help of <ul><li>
* instead of div's.
*
*/
function commandcontrol()
{
global $_CONF, $_TABLES, $LANG01, $LANG_MB01, $LANG_AM, $LANG_LOGO, $LANG29, $LANG_LOGVIEW, $LANG_SOCIAL, $_IMAGE_TYPE, $_DB_dbms;
$retval = '';
$admin_templates = new Template($_CONF['path_layout'] . 'admin/moderation');
$admin_templates->set_file (array ('cc' => 'moderation.thtml',
'ccrow' => 'ccrow.thtml',
'ccitem' => 'ccitem.thtml'));
$admin_templates->set_var('site_admin_url', $_CONF['site_admin_url']);
$admin_templates->set_var('title','glFusion ' . GVERSION . PATCHLEVEL . ' -- ' . $LANG29[34]);
$retval .= '<h2>glFusion ' . GVERSION . PATCHLEVEL . ' -- ' . $LANG29[34].'</h2>';
$showTrackbackIcon = (($_CONF['trackback_enabled'] ||
$_CONF['pingback_enabled'] || $_CONF['ping_enabled'])
&& SEC_hasRights('story.ping'));
$cc_arr = array(
array('condition' => SEC_hasRights('story.edit'),
'url' => $_CONF['site_admin_url'] . '/story.php',
'lang' => $LANG01[11], 'image' => '/images/icons/story.'),
array('condition' => SEC_hasRights('block.edit'),
'url' => $_CONF['site_admin_url'] . '/block.php',
'lang' => $LANG01[12], 'image' => '/images/icons/block.'),
array('condition' => SEC_hasRights('topic.edit'),
'url' => $_CONF['site_admin_url'] . '/topic.php',
'lang' => $LANG01[13], 'image' => '/images/icons/topic.'),
array('condition' => SEC_hasRights('user.edit'),
'url' => $_CONF['site_admin_url'] . '/user.php',
'lang' => $LANG01[17], 'image' => '/images/icons/user.'),
array('condition' => SEC_hasRights('group.edit'),
'url' => $_CONF['site_admin_url'] . '/group.php',
'lang' => $LANG01[96], 'image' => '/images/icons/group.'),
array('condition' => SEC_hasRights('user.mail'),
'url' => $_CONF['site_admin_url'] . '/mail.php',
'lang' => $LANG01[105], 'image' => '/images/icons/mail.'),
array('condition' => SEC_hasRights ('syndication.edit'),
'url' => $_CONF['site_admin_url'] . '/syndication.php',
'lang' => $LANG01[38], 'image' => '/images/icons/syndication.'),
array('condition' => $showTrackbackIcon,
'url' => $_CONF['site_admin_url'] . '/trackback.php',
'lang' => $LANG01[116], 'image' => '/images/icons/trackback.'),
array('condition' => SEC_hasRights('plugin.edit'),
'url' => $_CONF['site_admin_url'] . '/plugins.php',
'lang' => $LANG01[98], 'image' => '/images/icons/plugins.'),
array('condition' => SEC_inGroup('Root'),
'url' => $_CONF['site_admin_url'] . '/clearctl.php',
'lang' => $LANG01['ctl'], 'image' => '/images/icons/ctl.'),
array('condition' => SEC_inGroup('Root'),
'url' => $_CONF['site_admin_url'].'/envcheck.php',
'lang' => $LANG01['env_check'], 'image' => '/images/icons/envcheck.'),
array('condition' => SEC_inGroup('Root'),
'url' => $_CONF['site_admin_url'] . '/logview.php',
'lang' => $LANG_LOGVIEW['logview'], 'image' => '/images/icons/logview.'),
array('condition' => SEC_hasRights('menu.admin'),
'url' => $_CONF['site_admin_url'] . '/menu.php',
'lang' => $LANG_MB01['menu_builder'], 'image' => '/images/icons/menubuilder.'),
array('condition' => SEC_hasRights('logo.admin'),
'url' => $_CONF['site_admin_url'] . '/logo.php',
'lang' => $LANG_LOGO['logo_admin'], 'image' => '/images/icons/logo.'),
array('condition' => SEC_hasRights('autotag.admin'),
'url' => $_CONF['site_admin_url'] . '/autotag.php',
'lang' => $LANG_AM['title'], 'image' => '/images/icons/autotag.'),
array('condition' => SEC_inGroup('Root'),
'url' => $_CONF['site_admin_url'] . '/sfs.php',
'lang' => 'SFS User Check', 'image' => '/images/icons/sfs.'),
array('condition' => SEC_hasRights('social.admin'),
'url' => $_CONF['site_admin_url'].'/social.php',
'lang' => $LANG_SOCIAL['label'], 'image' => '/images/icons/social.'),
);
$admin_templates->set_var('cc_icon_width', floor(100/ICONS_PER_ROW));
for ($i = 0; $i < count ($cc_arr); $i++) {
if ($cc_arr[$i]['condition']) {
$item = render_cc_item ($admin_templates, $cc_arr[$i]['url'],
$_CONF['layout_url'] . $cc_arr[$i]['image'] . $_IMAGE_TYPE,
$cc_arr[$i]['lang']);
$items[$cc_arr[$i]['lang']] = $item;
}
}
// now add the plugins
$plugins = PLG_getCCOptions ();
for ($i = 0; $i < count ($plugins); $i++) {
$cur_plugin = current ($plugins);
$item = render_cc_item ($admin_templates, $cur_plugin->adminurl,
$cur_plugin->plugin_image, $cur_plugin->adminlabel);
$items[$cur_plugin->adminlabel] = $item;
next ($plugins);
}
// and finally, add the remaining admin items
$doclang = COM_getLanguageName();
if ( @file_exists($_CONF['path_html'] . 'docs/' . $doclang . '/index.html') ) {
$docUrl = $_CONF['site_url'].'/docs/'.$doclang.'/index.html';
} else {
$docUrl = $_CONF['site_url'].'/docs/english/index.html';
}
$cc_arr = array(
array('condition' => SEC_inGroup ('Root'),
'url' => $_CONF['site_admin_url'] . '/database.php',
'lang' => $LANG01[103], 'image' => '/images/icons/database.'),
array('condition' => ($_CONF['link_documentation'] == 1),
'url' => $docUrl,
'lang' => $LANG01[113], 'image' => '/images/icons/docs.'),
array('condition' => (SEC_inGroup ('Root') &&
($_CONF['link_versionchecker'] == 1)),
'url' => $_CONF['site_admin_url'].'/vercheck.php',
'lang' => $LANG01[107], 'image' => '/images/icons/versioncheck.'),
array('condition' => (SEC_inGroup ('Root')),
'url'=>$_CONF['site_admin_url'] . '/configuration.php',
'lang' => $LANG01[129], 'image' => '/images/icons/configuration.'),
array('condition' => SEC_isModerator(),
'url'=>$_CONF['site_admin_url'] . '/moderation.php',
'lang' => $LANG01[10], 'image' => '/images/icons/moderation.'),
);
for ($i = 0; $i < count ($cc_arr); $i++) {
if ($cc_arr[$i]['condition']) {
$item = render_cc_item ($admin_templates, $cc_arr[$i]['url'],
$_CONF['layout_url'] . $cc_arr[$i]['image'] . $_IMAGE_TYPE,
$cc_arr[$i]['lang']);
$items[$cc_arr[$i]['lang']] = $item;
}
}
if ($_CONF['sort_admin']) {
uksort ($items, 'strcasecmp');
}
// logout is always the last entry
$item = render_cc_item ($admin_templates,
$_CONF['site_url'] . '/users.php?mode=logout',
$_CONF['layout_url'] . '/images/icons/logout.' . $_IMAGE_TYPE,
$LANG01[35]);
$items[$LANG01[35]] = $item;
reset($items);
$cols = 0;
$cc_main_options = '';
foreach ($items as $key => $val) {
$cc_main_options .= $val . LB;
$cols++;
if ($cols == ICONS_PER_ROW) {
$admin_templates->set_var('cc_main_options', $cc_main_options);
$admin_templates->parse ('cc_rows', 'ccrow', true);
$admin_templates->clear_var ('cc_main_options');
$cc_main_options = '';
$cols = 0;
}
}
if($cols > 0) {
// "flush out" any unrendered entries
$admin_templates->set_var('cc_main_options', $cc_main_options);
$admin_templates->parse ('cc_rows', 'ccrow', true);
$admin_templates->clear_var ('cc_main_options');
}
$retval .= $admin_templates->finish($admin_templates->parse('output','cc'));
return $retval;
}
/**
* Display a reminder to execute the security check script
*
*/
function security_check_reminder()
{
global $_CONF, $_TABLES, $_IMAGE_TYPE, $MESSAGE;
$retval = '';
if (!SEC_inGroup ('Root')) {
return $retval;
}
$done = DB_getItem ($_TABLES['vars'], 'value', "name = 'security_check'");
if ($done != 1) {
$retval .= COM_showMessage(92,'','',true,'error');
}
return $retval;
}
// MAIN
$display = COM_siteHeader('menu', $LANG29[34]);
$msg = COM_getMessage();
if ($msg > 0) {
$plugin = '';
if (isset($_GET['plugin'])) {
$plugin = COM_applyFilter($_GET['plugin']);
}
$display .= COM_showMessage($msg, $plugin);
}
$display .= _checkUpgrades();
$display .= security_check_reminder();
$display .= commandcontrol();
$display .= COM_siteFooter();
echo $display;
?>