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