Project

General

Profile

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