1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category admin
|
5
|
* @package start
|
6
|
* @author Ryan Djurovich (2004-2009), WebsiteBaker Project
|
7
|
* @copyright 2009-2012, WebsiteBaker Org. e.V.
|
8
|
* @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: index.php 1804 2012-11-01 22:50:49Z Luisehahne $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/start/index.php $
|
14
|
* @lastmodified $Date: 2012-11-01 23:50:49 +0100 (Thu, 01 Nov 2012) $
|
15
|
*
|
16
|
*/
|
17
|
//$string = "pages,pages_view,pages_add,pages_add_l0,pages_settings,pages_modify,pages_intro,pages_delete,media,media_view,media_upload,media_rename,media_delete,media_create,addons,modules,modules_view,modules_install,modules_uninstall,templates,templates_view,templates_install,templates_uninstall,languages,languages_view,languages_install,languages_uninstall,settings,settings_basic,settings_advanced,access,users,users_view,users_add,users_modify,users_delete,groups,groups_view,groups_add,groups_modify,groups_delete,admintools
|
18
|
//media,media_create,media_upload,media_view,preferences,preferences_view,pages,pages_modify,pages_view";
|
19
|
//$regex = "/(pages)+[a-z]*[_]([a-z_0-9]+)[^,]/im";
|
20
|
//preg_match_all ($regex, $string, $output);
|
21
|
//
|
22
|
|
23
|
$config_file = realpath('../../config.php');
|
24
|
if(file_exists($config_file) && !defined('WB_URL'))
|
25
|
{
|
26
|
require_once($config_file);
|
27
|
}
|
28
|
|
29
|
if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
|
30
|
|
31
|
$admin = new admin('Start','start');
|
32
|
// ---------------------------------------
|
33
|
// $database = WbDatabase::getInstance();
|
34
|
|
35
|
if(defined('FINALIZE_SETUP')) {
|
36
|
require_once(WB_PATH.'/framework/functions.php');
|
37
|
$dirs = array( 'modules' => WB_PATH.'/modules/',
|
38
|
'templates' => WB_PATH.'/templates/',
|
39
|
'languages' => WB_PATH.'/languages/'
|
40
|
);
|
41
|
foreach($dirs AS $type => $dir) {
|
42
|
if( ($handle = opendir($dir)) ) {
|
43
|
while(false !== ($file = readdir($handle))) {
|
44
|
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
|
45
|
// Get addon type
|
46
|
if($type == 'modules') {
|
47
|
load_module($dir.'/'.$file, true);
|
48
|
// Pretty ugly hack to let modules run $admin->set_error
|
49
|
// See dummy class definition admin_dummy above
|
50
|
if(isset($admin->error) && $admin->error != '') {
|
51
|
$admin->print_error($admin->error);
|
52
|
}
|
53
|
} elseif($type == 'templates') {
|
54
|
load_template($dir.'/'.$file);
|
55
|
} elseif($type == 'languages') {
|
56
|
load_language($dir.'/'.$file);
|
57
|
}
|
58
|
}
|
59
|
}
|
60
|
closedir($handle);
|
61
|
}
|
62
|
}
|
63
|
$sql = 'DELETE FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'FINALIZE_SETUP\'';
|
64
|
if($database->query($sql)) { }
|
65
|
}
|
66
|
// ---------------------------------------
|
67
|
// check if it is neccessary to start the uograde-script
|
68
|
$msg = '';
|
69
|
$msg .= (is_readable(WB_PATH.'/install/')) ? $MESSAGE['START_INSTALL_DIR_EXISTS'].'<br />' : $msg;
|
70
|
$msg .= (is_readable(WB_PATH.'/upgrade-script.php')) ? $MESSAGE['START_UPGRADE_SCRIPT_EXISTS'].'<br />' : '';
|
71
|
//$msg .= ''.$MESSAGE['START_UPGRADE_SCRIPT_EXISTS'].'<br />';
|
72
|
|
73
|
// ---------------------------------------
|
74
|
// check if it is neccessary to start the uograde-script
|
75
|
// ---------------------------------------
|
76
|
if(($admin->get_user_id()==1) && file_exists(WB_PATH.'/upgrade-script.php')) {
|
77
|
// check if it is neccessary to start the uograde-script
|
78
|
$sql = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'wb_revision\'';
|
79
|
if($wb_revision=$database->get_one($sql)) {
|
80
|
}
|
81
|
if (version_compare($wb_revision, REVISION ) < 0) {
|
82
|
if(!headers_sent()) {
|
83
|
header('Location: '.WB_URL.'/upgrade-script.php');
|
84
|
exit;
|
85
|
} else {
|
86
|
echo "<p style=\"text-align:center;\"> The <strong>upgrade script</strong> could not be start automatically.\n" .
|
87
|
"Please click <a style=\"font-weight:bold;\" " .
|
88
|
"href=\"".WB_URL."/upgrade-script.php\">on this link</a> to start the script!</p>\n";
|
89
|
exit;
|
90
|
}
|
91
|
}
|
92
|
}
|
93
|
// ---------------------------------------
|
94
|
// workout to upgrade the groups system_permissions
|
95
|
// ---------------------------------------
|
96
|
if( ($admin->get_user_id()==1) &&
|
97
|
file_exists(ADMIN_PATH.'/groups/upgradePermissions.php') && !defined('GROUPS_UPDATED') )
|
98
|
{
|
99
|
// check if it is neccessary to start the uograde-script
|
100
|
$sql = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'wb_revision\'';
|
101
|
if($wb_revision = $database->get_one($sql)) {
|
102
|
|
103
|
}
|
104
|
|
105
|
if ((version_compare($wb_revision, '1800' ) < 0)&& !defined('GROUPS_UPDATED')) {
|
106
|
require_once (ADMIN_PATH.'/groups/upgradePermissions.php');
|
107
|
// build new or changed $sTempPermissions
|
108
|
if(upgrade_group_system_permissions()){
|
109
|
$cfg = array(
|
110
|
'groups_updated' => time()
|
111
|
);
|
112
|
if(db_update_key_value( 'settings', $cfg )) {
|
113
|
echo "<div class=\"note center rounded\"><h3>Hello Systemadministrator!</h3>".
|
114
|
"<p style=\"text-align:center;\">".
|
115
|
"The <strong>Administrator Groups Rights </strong> were updated automatically.\n" .
|
116
|
"Please click <a style=\"font-weight:bold;\" " .
|
117
|
"href=\"".ADMIN_URL."/logout/index.php\">on this link</a> to login again!</p>\n".
|
118
|
"<h3>Upgrading only start, if groups rights are not up to date!</h3></div>";
|
119
|
// Print admin footer
|
120
|
$admin->print_footer();
|
121
|
exit(0);
|
122
|
|
123
|
}
|
124
|
}
|
125
|
}
|
126
|
}
|
127
|
|
128
|
/**
|
129
|
* delete Outdated Confirmations
|
130
|
*/
|
131
|
$sql = 'DELETE FROM `'.TABLE_PREFIX.'users` WHERE `confirm_timeout` BETWEEN 1 AND '.time();
|
132
|
WbDatabase::getInstance()->query($sql);
|
133
|
|
134
|
// ---------------------------------------
|
135
|
// Setup template object, parse vars to it, then parse it
|
136
|
// Create new template object
|
137
|
$oTpl = new Template(dirname($admin->correct_theme_source('start.htt')),'keep');
|
138
|
$oTpl->set_file('page', 'start.htt');
|
139
|
$oTpl->set_block('page', 'main_block', 'main');
|
140
|
|
141
|
// Insert values into the template object
|
142
|
$oTpl->set_var(array(
|
143
|
'WELCOME_MESSAGE' => $MESSAGE['START_WELCOME_MESSAGE'],
|
144
|
'CURRENT_USER' => $MESSAGE['START_CURRENT_USER'],
|
145
|
'DISPLAY_NAME' => $admin->get_display_name(),
|
146
|
'DISPLAY_WARNING' => '',
|
147
|
'WARNING' => '',
|
148
|
'ADMIN_URL' => ADMIN_URL,
|
149
|
'WB_URL' => WB_URL,
|
150
|
'THEME_URL' => THEME_URL,
|
151
|
'WB_VERSION' => WB_VERSION,
|
152
|
'NO_CONTENT' => ''
|
153
|
)
|
154
|
);
|
155
|
|
156
|
// Insert permission values into the template object
|
157
|
$oTpl->set_block('main_block', 'show_pages_block', 'show_pages');
|
158
|
if($admin->get_permission('pages') != true)
|
159
|
{
|
160
|
$oTpl->set_block('show_pages', '');
|
161
|
} else {
|
162
|
$oTpl->parse('show_pages', 'show_pages_block', true);
|
163
|
}
|
164
|
|
165
|
$oTpl->set_block('main_block', 'show_addons_block', 'show_addons');
|
166
|
if($admin->get_permission('addons') != true)
|
167
|
{
|
168
|
$oTpl->set_block('show_addons', '');
|
169
|
} else {
|
170
|
$oTpl->parse('show_addons', 'show_addons_block', true);
|
171
|
}
|
172
|
|
173
|
$oTpl->set_block('main_block', 'show_settings_block', 'show_settings');
|
174
|
if($admin->get_permission('settings') != true)
|
175
|
{
|
176
|
$oTpl->set_block('show_settings', '');
|
177
|
} else {
|
178
|
$oTpl->parse('show_settings', 'show_settings_block', true);
|
179
|
}
|
180
|
|
181
|
$oTpl->set_block('main_block', 'show_access_block', 'show_access');
|
182
|
if($admin->get_permission('access') != true)
|
183
|
{
|
184
|
$oTpl->set_block('show_access', '');
|
185
|
} else {
|
186
|
$oTpl->parse('show_access', 'show_access_block', true);
|
187
|
}
|
188
|
|
189
|
$oTpl->set_block('main_block', 'show_media_block', 'show_media');
|
190
|
if($admin->get_permission('media') != true)
|
191
|
{
|
192
|
$oTpl->set_block('show_media', '');
|
193
|
} else {
|
194
|
$oTpl->parse('show_media', 'show_media_block', true);
|
195
|
}
|
196
|
|
197
|
$oTpl->set_block('main_block', 'show_admintools_block', 'show_admintools');
|
198
|
if($admin->get_permission('admintools') != true)
|
199
|
{
|
200
|
$oTpl->set_block('show_admintools', '');
|
201
|
} else {
|
202
|
$oTpl->parse('show_admintools', 'show_admintools_block', true);
|
203
|
}
|
204
|
|
205
|
$oTpl->set_block('main_block', 'show_preferences_block', 'show_preferences');
|
206
|
if($admin->get_permission('preferences') != true)
|
207
|
{
|
208
|
$oTpl->set_block('show_preferences', '');
|
209
|
} else {
|
210
|
$oTpl->parse('show_preferences', 'show_preferences_block', true);
|
211
|
}
|
212
|
|
213
|
|
214
|
/*
|
215
|
if($admin->get_permission('pages') != true)
|
216
|
{
|
217
|
$oTpl->set_var('DISPLAY_PAGES', 'display:none;');
|
218
|
}
|
219
|
if($admin->get_permission('media') != true)
|
220
|
{
|
221
|
$oTpl->set_var('DISPLAY_MEDIA', 'display:none;');
|
222
|
}
|
223
|
if($admin->get_permission('addons') != true)
|
224
|
{
|
225
|
$oTpl->set_var('DISPLAY_ADDONS', 'display:none;');
|
226
|
}
|
227
|
if($admin->get_permission('access') != true)
|
228
|
{
|
229
|
$oTpl->set_var('DISPLAY_ACCESS', 'display:none;');
|
230
|
}
|
231
|
if($admin->get_permission('settings') != true)
|
232
|
{
|
233
|
$oTpl->set_var('DISPLAY_SETTINGS', 'display:none;');
|
234
|
}
|
235
|
if($admin->get_permission('admintools') != true)
|
236
|
{
|
237
|
$oTpl->set_var('DISPLAY_ADMINTOOLS', 'display:none;');
|
238
|
}
|
239
|
*/
|
240
|
|
241
|
|
242
|
$oTpl->set_block('main_block', 'show_install_block', 'show_install');
|
243
|
if($admin->get_user_id() != 1)
|
244
|
{
|
245
|
$oTpl->parse('show_install', '');
|
246
|
} else {
|
247
|
|
248
|
// Check if installation directory still exists
|
249
|
if(file_exists(WB_PATH.'/install/') || file_exists(WB_PATH.'/upgrade-script.php') ) {
|
250
|
// Check if user is part of Adminstrators group
|
251
|
if($admin->get_user_id()==1)
|
252
|
{
|
253
|
$oTpl->set_var('WARNING', $msg );
|
254
|
} else {
|
255
|
$oTpl->set_var('DISPLAY_WARNING', 'display:none;');
|
256
|
}
|
257
|
} else {
|
258
|
$oTpl->set_var('DISPLAY_WARNING', 'display:none;');
|
259
|
}
|
260
|
|
261
|
$oTpl->parse('show_install', 'show_install_block', true);
|
262
|
}
|
263
|
|
264
|
// Insert "Add-ons" section overview (pretty complex compared to normal)
|
265
|
$addons_overview = $TEXT['MANAGE'].' ';
|
266
|
$addons_count = 0;
|
267
|
if($admin->get_permission('modules') == true)
|
268
|
{
|
269
|
$addons_overview .= '<a href="'.ADMIN_URL.'/modules/index.php">'.$MENU['MODULES'].'</a>';
|
270
|
$addons_count = 1;
|
271
|
}
|
272
|
if($admin->get_permission('templates') == true)
|
273
|
{
|
274
|
if($addons_count == 1) { $addons_overview .= ', '; }
|
275
|
$addons_overview .= '<a href="'.ADMIN_URL.'/templates/index.php">'.$MENU['TEMPLATES'].'</a>';
|
276
|
$addons_count = 1;
|
277
|
}
|
278
|
if($admin->get_permission('languages') == true)
|
279
|
{
|
280
|
if($addons_count == 1) { $addons_overview .= ', '; }
|
281
|
$addons_overview .= '<a href="'.ADMIN_URL.'/languages/index.php">'.$MENU['LANGUAGES'].'</a>';
|
282
|
}
|
283
|
|
284
|
// Insert "Access" section overview (pretty complex compared to normal)
|
285
|
$access_overview = $TEXT['MANAGE'].' ';
|
286
|
$access_count = 0;
|
287
|
if($admin->get_permission('users') == true) {
|
288
|
$access_overview .= '<a href="'.ADMIN_URL.'/users/index.php">'.$MENU['USERS'].'</a>';
|
289
|
$access_count = 1;
|
290
|
}
|
291
|
if($admin->get_permission('groups') == true) {
|
292
|
if($access_count == 1) { $access_overview .= ', '; }
|
293
|
$access_overview .= '<a href="'.ADMIN_URL.'/groups/index.php">'.$MENU['GROUPS'].'</a>';
|
294
|
$access_count = 1;
|
295
|
}
|
296
|
|
297
|
// Insert section names and descriptions
|
298
|
$oTpl->set_var(array(
|
299
|
'PAGES' => $MENU['PAGES'],
|
300
|
'MEDIA' => $MENU['MEDIA'],
|
301
|
'ADDONS' => $MENU['ADDONS'],
|
302
|
'ACCESS' => $MENU['ACCESS'],
|
303
|
'PREFERENCES' => $MENU['PREFERENCES'],
|
304
|
'SETTINGS' => $MENU['SETTINGS'],
|
305
|
'ADMINTOOLS' => $MENU['ADMINTOOLS'],
|
306
|
'HOME_OVERVIEW' => $OVERVIEW['START'],
|
307
|
'PAGES_OVERVIEW' => $OVERVIEW['PAGES'],
|
308
|
'MEDIA_OVERVIEW' => $OVERVIEW['MEDIA'],
|
309
|
'ADDONS_OVERVIEW' => $addons_overview,
|
310
|
'ACCESS_OVERVIEW' => $access_overview,
|
311
|
'PREFERENCES_OVERVIEW' => $OVERVIEW['PREFERENCES'],
|
312
|
'SETTINGS_OVERVIEW' => $OVERVIEW['SETTINGS'],
|
313
|
'ADMINTOOLS_OVERVIEW' => $OVERVIEW['ADMINTOOLS']
|
314
|
)
|
315
|
);
|
316
|
|
317
|
// Parse template object
|
318
|
$oTpl->parse('main', 'main_block', false);
|
319
|
$oTpl->pparse('output', 'page');
|
320
|
|
321
|
// Print admin footer
|
322
|
$admin->print_footer();
|