1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category admin
|
5
|
* @package start
|
6
|
* @author Ryan Djurovich (2004-2009), WebsiteBaker Project
|
7
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
8
|
* @link http://www.websitebaker.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 2098 2014-02-11 01:37:03Z darkviper $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/start/index.php $
|
14
|
* @lastmodified $Date: 2014-02-11 02:37:03 +0100 (Tue, 11 Feb 2014) $
|
15
|
*
|
16
|
*/
|
17
|
|
18
|
if (!defined('WB_URL')) {
|
19
|
require_once('../../config.php');
|
20
|
}
|
21
|
$oDb = WbDatabase::getInstance();
|
22
|
$oTrans = Translate::getInstance();
|
23
|
$oTrans->enableAddon('admin\\start');
|
24
|
//$template->set_var($oTrans->getLangArray());
|
25
|
$admin = new admin('Start','start');
|
26
|
// ---------------------------------------
|
27
|
// $database = WbDatabase::getInstance();
|
28
|
|
29
|
require_once(WB_PATH.'/framework/functions.php');
|
30
|
if(defined('FINALIZE_SETUP')) {
|
31
|
$dirs = array( 'modules' => WB_PATH.'/modules/',
|
32
|
'templates' => WB_PATH.'/templates/',
|
33
|
'languages' => WB_PATH.'/languages/'
|
34
|
);
|
35
|
foreach($dirs AS $type => $dir) {
|
36
|
if( ($handle = opendir($dir)) ) {
|
37
|
while(false !== ($file = readdir($handle))) {
|
38
|
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
|
39
|
// Get addon type
|
40
|
if($type == 'modules') {
|
41
|
load_module($dir.'/'.$file, true);
|
42
|
// Pretty ugly hack to let modules run $admin->set_error
|
43
|
// See dummy class definition admin_dummy above
|
44
|
if(isset($admin->error) && $admin->error != '') {
|
45
|
$admin->print_error($admin->error);
|
46
|
}
|
47
|
} elseif($type == 'templates') {
|
48
|
load_template($dir.'/'.$file);
|
49
|
} elseif($type == 'languages') {
|
50
|
load_language($dir.'/'.$file);
|
51
|
}
|
52
|
}
|
53
|
}
|
54
|
closedir($handle);
|
55
|
}
|
56
|
}
|
57
|
$sql = 'DELETE FROM `'.$oDb-TablePrefix.'settings` WHERE `name`=\'FINALIZE_SETUP\'';
|
58
|
$oDb->doQuery($sql);
|
59
|
}
|
60
|
// ---------------------------------------
|
61
|
// check if it is neccessary to start the uograde-script
|
62
|
|
63
|
$msg = '';
|
64
|
$msg .= (is_readable(WB_PATH.'/install/')) ? $oTrans->MESSAGE_START_INSTALL_DIR_EXISTS.'<br />' : $msg;
|
65
|
$aReplace =array(
|
66
|
'file' => '<a style="font-weight:bold;" href="'.WB_URL.'/upgrade-script.php">upgrade-script.php</a>'
|
67
|
);
|
68
|
$msg .= (is_readable(WB_PATH.'/upgrade-script.php') ? replace_vars($oTrans->MESSAGE_START_UPGRADE_SCRIPT_EXISTS.'<br />',$aReplace) : '');
|
69
|
|
70
|
// ---------------------------------------
|
71
|
// check if it is neccessary to start the uograde-script
|
72
|
// ---------------------------------------
|
73
|
if(($admin->get_user_id()==1) && file_exists(WB_PATH.'/upgrade-script.php')) {
|
74
|
// check if it is neccessary to start the uograde-script
|
75
|
$sql = 'SELECT `value` FROM `'.$oDb-TablePrefix.'settings` WHERE `name`=\'wb_revision\'';
|
76
|
$wb_revision = $oDb->getOne($sql);
|
77
|
if (version_compare($wb_revision, REVISION ) < 0) {
|
78
|
echo "<p style=\"text-align:center;\"> If the <strong>upgrade script</strong> could not be start automatically.\n" .
|
79
|
"Please click <a style=\"font-weight:bold;\" " .
|
80
|
"href=\"".WB_URL."/upgrade-script.php\">on this link</a> to start the script!</p>\n";
|
81
|
|
82
|
echo "<script type=\"text/javascript\">
|
83
|
<!--
|
84
|
// Get the location object
|
85
|
var locationObj = document.location;
|
86
|
// Set the value of the location object
|
87
|
document.location = '".WB_URL."/upgrade-script.php';
|
88
|
-->
|
89
|
</script>";
|
90
|
|
91
|
// if(!headers_sent()) {
|
92
|
// header('Location: '.WB_URL.'/upgrade-script.php');
|
93
|
// exit;
|
94
|
// } else {
|
95
|
// echo "<p style=\"text-align:center;\"> The <strong>upgrade script</strong> could not be start automatically.\n" .
|
96
|
// "Please click <a style=\"font-weight:bold;\" " .
|
97
|
// "href=\"".WB_URL."/upgrade-script.php\">on this link</a> to start the script!</p>\n";
|
98
|
// exit;
|
99
|
// }
|
100
|
}
|
101
|
}
|
102
|
// ---------------------------------------
|
103
|
// workout to upgrade the groups system_permissions
|
104
|
// ---------------------------------------
|
105
|
if( ($admin->get_user_id()==1) && file_exists(ADMIN_PATH.'/groups/upgradePermissions.php') && !defined('GROUPS_UPDATED') )
|
106
|
{
|
107
|
// check if it is neccessary to start the uograde-script
|
108
|
$sql = 'SELECT `value` FROM `'.$oDb-TablePrefix.'settings` WHERE `name`=\'wb_revision\'';
|
109
|
$wb_revision = $database->get_one($sql);
|
110
|
if ((version_compare($wb_revision, '1800' ) < 0)&& !defined('GROUPS_UPDATED')) {
|
111
|
require_once (ADMIN_PATH.'/groups/upgradePermissions.php');
|
112
|
// build new or changed $sTempPermissions
|
113
|
if(upgrade_group_system_permissions()){
|
114
|
$cfg = array(
|
115
|
'groups_updated' => time()
|
116
|
);
|
117
|
if(db_update_key_value( 'settings', $cfg )) {
|
118
|
echo "<div class=\"note center rounded\"><h3>Hello Systemadministrator!</h3>".
|
119
|
"<p style=\"text-align:center;\">".
|
120
|
"The <strong>Administrator Groups Rights </strong> were updated automatically.\n" .
|
121
|
"Please click <a style=\"font-weight:bold;\" " .
|
122
|
"href=\"".ADMIN_URL."/logout/index.php\">on this link</a> to login again!</p>\n".
|
123
|
"<h3>Upgrading only start, if groups rights are not up to date!</h3></div>";
|
124
|
// Print admin footer
|
125
|
$admin->print_footer();
|
126
|
exit(0);
|
127
|
|
128
|
}
|
129
|
}
|
130
|
}
|
131
|
}
|
132
|
|
133
|
/**
|
134
|
* delete Outdated Confirmations
|
135
|
*/
|
136
|
$sql = 'DELETE FROM `'.$oDb-TablePrefix.'users` WHERE `confirm_timeout` BETWEEN 1 AND '.time();
|
137
|
$oDb->doQuery($sql);
|
138
|
|
139
|
/**
|
140
|
* delete stored ip adresses default after 60 days
|
141
|
*/
|
142
|
$sql = 'UPDATE `'.$oDb-TablePrefix.'users` SET `login_ip` = \'\' WHERE `login_when` < '.(time()-(60*84600));
|
143
|
$oDb->doQuery($sql);
|
144
|
|
145
|
// ---------------------------------------
|
146
|
// Setup template object, parse vars to it, then parse it
|
147
|
// Create new template object
|
148
|
$oTpl = new Template(dirname($admin->correct_theme_source('start.htt')),'keep');
|
149
|
$oTpl->set_file('page', 'start.htt');
|
150
|
$oTpl->set_block('page', 'main_block', 'main');
|
151
|
$oTpl->set_var($oTrans->getLangArray());
|
152
|
// Insert values into the template object
|
153
|
$oTpl->set_var(array(
|
154
|
'WELCOME_MESSAGE' => $oTrans->MESSAGE_START_WELCOME_MESSAGE,
|
155
|
'CURRENT_USER' => $oTrans->MESSAGE_START_CURRENT_USER,
|
156
|
'DISPLAY_NAME' => $admin->get_display_name(),
|
157
|
'DISPLAY_WARNING' => '',
|
158
|
'WARNING' => '',
|
159
|
'ADMIN_URL' => ADMIN_URL,
|
160
|
'WB_URL' => WB_URL,
|
161
|
'THEME_URL' => THEME_URL,
|
162
|
'WB_VERSION' => WB_VERSION,
|
163
|
'NO_CONTENT' => ''
|
164
|
)
|
165
|
);
|
166
|
|
167
|
// Insert permission values into the template object
|
168
|
$oTpl->set_block('main_block', 'show_pages_block', 'show_pages');
|
169
|
if($admin->get_permission('pages') != true)
|
170
|
{
|
171
|
$oTpl->set_block('show_pages', '');
|
172
|
} else {
|
173
|
$oTpl->parse('show_pages', 'show_pages_block', true);
|
174
|
}
|
175
|
|
176
|
$oTpl->set_block('main_block', 'show_addons_block', 'show_addons');
|
177
|
if($admin->get_permission('addons') != true)
|
178
|
{
|
179
|
$oTpl->set_block('show_addons', '');
|
180
|
} else {
|
181
|
$oTpl->parse('show_addons', 'show_addons_block', true);
|
182
|
}
|
183
|
|
184
|
$oTpl->set_block('main_block', 'show_settings_block', 'show_settings');
|
185
|
if($admin->get_permission('settings') != true)
|
186
|
{
|
187
|
$oTpl->set_block('show_settings', '');
|
188
|
} else {
|
189
|
$oTpl->parse('show_settings', 'show_settings_block', true);
|
190
|
}
|
191
|
|
192
|
$oTpl->set_block('main_block', 'show_access_block', 'show_access');
|
193
|
if($admin->get_permission('access') != true)
|
194
|
{
|
195
|
$oTpl->set_block('show_access', '');
|
196
|
} else {
|
197
|
$oTpl->parse('show_access', 'show_access_block', true);
|
198
|
}
|
199
|
|
200
|
$oTpl->set_block('main_block', 'show_media_block', 'show_media');
|
201
|
if($admin->get_permission('media') != true)
|
202
|
{
|
203
|
$oTpl->set_block('show_media', '');
|
204
|
} else {
|
205
|
$oTpl->parse('show_media', 'show_media_block', true);
|
206
|
}
|
207
|
|
208
|
$oTpl->set_block('main_block', 'show_admintools_block', 'show_admintools');
|
209
|
if($admin->get_permission('admintools') != true)
|
210
|
{
|
211
|
$oTpl->set_block('show_admintools', '');
|
212
|
} else {
|
213
|
$oTpl->parse('show_admintools', 'show_admintools_block', true);
|
214
|
}
|
215
|
|
216
|
$oTpl->set_block('main_block', 'show_preferences_block', 'show_preferences');
|
217
|
if($admin->get_permission('preferences') != true)
|
218
|
{
|
219
|
$oTpl->set_block('show_preferences', '');
|
220
|
} else {
|
221
|
$oTpl->parse('show_preferences', 'show_preferences_block', true);
|
222
|
}
|
223
|
|
224
|
$oTpl->set_block('main_block', 'show_install_block', 'show_install');
|
225
|
if($admin->get_user_id() != 1)
|
226
|
{
|
227
|
$oTpl->parse('show_install', '');
|
228
|
} else {
|
229
|
|
230
|
// Check if installation directory still exists
|
231
|
if(file_exists(WB_PATH.'/install/') || file_exists(WB_PATH.'/upgrade-script.php') ) {
|
232
|
// Check if user is part of Adminstrators group
|
233
|
if($admin->get_user_id()==1)
|
234
|
{
|
235
|
$oTpl->set_var('WARNING', $msg );
|
236
|
} else {
|
237
|
$oTpl->set_var('DISPLAY_WARNING', 'display:none;');
|
238
|
}
|
239
|
} else {
|
240
|
$oTpl->set_var('DISPLAY_WARNING', 'display:none;');
|
241
|
}
|
242
|
|
243
|
$oTpl->parse('show_install', 'show_install_block', true);
|
244
|
}
|
245
|
|
246
|
// Insert "Add-ons" section overview (pretty complex compared to normal)
|
247
|
$addons_overview = $oTrans->TEXT_MANAGE.' ';
|
248
|
$addons_count = 0;
|
249
|
if($admin->get_permission('modules') == true)
|
250
|
{
|
251
|
$addons_overview .= '<a href="'.ADMIN_URL.'/modules/index.php">'.$oTrans->MENU_MODULES.'</a>';
|
252
|
$addons_count = 1;
|
253
|
}
|
254
|
if($admin->get_permission('templates') == true)
|
255
|
{
|
256
|
if($addons_count == 1) { $addons_overview .= ', '; }
|
257
|
$addons_overview .= '<a href="'.ADMIN_URL.'/templates/index.php">'.$oTrans->MENU_TEMPLATES.'</a>';
|
258
|
$addons_count = 1;
|
259
|
}
|
260
|
if($admin->get_permission('languages') == true)
|
261
|
{
|
262
|
if($addons_count == 1) { $addons_overview .= ', '; }
|
263
|
$addons_overview .= '<a href="'.ADMIN_URL.'/languages/index.php">'.$oTrans->MENU_LANGUAGES.'</a>';
|
264
|
}
|
265
|
|
266
|
// Insert "Access" section overview (pretty complex compared to normal)
|
267
|
$access_overview = $oTrans->TEXT_MANAGE.' ';
|
268
|
$access_count = 0;
|
269
|
if($admin->get_permission('users') == true) {
|
270
|
$access_overview .= '<a href="'.ADMIN_URL.'/users/index.php">'.$oTrans->MENU_USERS.'</a>';
|
271
|
$access_count = 1;
|
272
|
}
|
273
|
if($admin->get_permission('groups') == true) {
|
274
|
if($access_count == 1) { $access_overview .= ', '; }
|
275
|
$access_overview .= '<a href="'.ADMIN_URL.'/groups/index.php">'.$oTrans->MENU_GROUPS.'</a>';
|
276
|
$access_count = 1;
|
277
|
}
|
278
|
|
279
|
// Insert section names and descriptions
|
280
|
$oTpl->set_var(array(
|
281
|
'PAGES' => $oTrans->MENU_PAGES,
|
282
|
'MEDIA' => $oTrans->MENU_MEDIA,
|
283
|
'ADDONS' => $oTrans->MENU_ADDONS,
|
284
|
'ACCESS' => $oTrans->MENU_ACCESS,
|
285
|
'PREFERENCES' => $oTrans->MENU_PREFERENCES,
|
286
|
'SETTINGS' => $oTrans->MENU_SETTINGS,
|
287
|
'ADMINTOOLS' => $oTrans->MENU_ADMINTOOLS,
|
288
|
'HOME_OVERVIEW' => $oTrans->OVERVIEW_START,
|
289
|
'PAGES_OVERVIEW' => $oTrans->OVERVIEW_PAGES,
|
290
|
'MEDIA_OVERVIEW' => $oTrans->OVERVIEW_MEDIA,
|
291
|
'ADDONS_OVERVIEW' => $addons_overview,
|
292
|
'ACCESS_OVERVIEW' => $access_overview,
|
293
|
'PREFERENCES_OVERVIEW' => $oTrans->OVERVIEW_PREFERENCES,
|
294
|
'SETTINGS_OVERVIEW' => $oTrans->OVERVIEW_SETTINGS,
|
295
|
'ADMINTOOLS_OVERVIEW' => $oTrans->OVERVIEW_ADMINTOOLS
|
296
|
)
|
297
|
);
|
298
|
|
299
|
// Parse template object
|
300
|
$oTpl->parse('main', 'main_block', false);
|
301
|
$oTpl->pparse('output', 'page');
|
302
|
|
303
|
// Print admin footer
|
304
|
$admin->print_footer();
|