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