Project

General

Profile

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 1989 2013-10-19 00:57:02Z Luisehahne $
13
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/start/index.php $
14
 * @lastmodified    $Date: 2013-10-19 02:57:02 +0200 (Sat, 19 Oct 2013) $
15
 *
16
 */
17

    
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
$admin = new admin('Start','start');
27
// ---------------------------------------
28
//	$database = WbDatabase::getInstance();
29

    
30
require_once(WB_PATH.'/framework/functions.php');
31
if(defined('FINALIZE_SETUP')) {
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
	if($database->query($sql)) { }
60
}
61
// ---------------------------------------
62
// check if it is neccessary to start the uograde-script
63

    
64
$msg  = '';
65
$msg .= (is_readable(WB_PATH.'/install/')) ?  $MESSAGE['START_INSTALL_DIR_EXISTS'].'<br />' : $msg;
66
$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
//$msg .= ''.$MESSAGE['START_UPGRADE_SCRIPT_EXISTS'].'<br />';
71

    
72
// ---------------------------------------
73
// check if it is neccessary to start the uograde-script
74
// ---------------------------------------
75
if(($admin->get_user_id()==1) && file_exists(WB_PATH.'/upgrade-script.php')) {
76
	// 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
	}
80
	if (version_compare($wb_revision, REVISION ) < 0) {
81
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
	}
104
}
105
// ---------------------------------------
106
// workout to upgrade the groups system_permissions
107
// ---------------------------------------
108
if( ($admin->get_user_id()==1) &&
109
	file_exists(ADMIN_PATH.'/groups/upgradePermissions.php') && !defined('GROUPS_UPDATED') )
110
{
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

    
115
	}
116

    
117
	if ((version_compare($wb_revision, '1800' )  < 0)&& !defined('GROUPS_UPDATED')) {
118
		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
/**
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
/**
147
 * delete stored ip adresses default after 60 days
148
 */
149
$sql = 'UPDATE `'.TABLE_PREFIX.'users` SET `login_ip` = \'\' WHERE `login_when` < '.(time()-(60*84600));
150
WbDatabase::getInstance()->query($sql);
151

    
152
// ---------------------------------------
153
// Setup template object, parse vars to it, then parse it
154
// Create new template object
155
$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

    
159
// Insert values into the template object
160
$oTpl->set_var(array(
161
					'WELCOME_MESSAGE' => $MESSAGE['START_WELCOME_MESSAGE'],
162
					'CURRENT_USER' => $MESSAGE['START_CURRENT_USER'],
163
					'DISPLAY_NAME' => $admin->get_display_name(),
164
                    'DISPLAY_WARNING' => '',
165
                    'WARNING' => '',
166
					'ADMIN_URL' => ADMIN_URL,
167
					'WB_URL' => WB_URL,
168
					'THEME_URL' => THEME_URL,
169
					'WB_VERSION' => WB_VERSION,
170
					'NO_CONTENT' => ''
171
				)
172
			);
173

    
174
// Insert permission values into the template object
175
$oTpl->set_block('main_block', 'show_pages_block', 'show_pages');
176
if($admin->get_permission('pages') != true)
177
{
178
	$oTpl->set_block('show_pages', '');
179
} else {
180
	$oTpl->parse('show_pages', 'show_pages_block', true);
181
}
182

    
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
if($admin->get_permission('media') != true)
209
{
210
	$oTpl->set_block('show_media', '');
211
} else {
212
	$oTpl->parse('show_media', 'show_media_block', true);
213
}
214

    
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
if($admin->get_permission('addons') != true)
242
{
243
	$oTpl->set_var('DISPLAY_ADDONS', 'display:none;');
244
}
245
if($admin->get_permission('access') != true)
246
{
247
	$oTpl->set_var('DISPLAY_ACCESS', 'display:none;');
248
}
249
if($admin->get_permission('settings') != true)
250
{
251
	$oTpl->set_var('DISPLAY_SETTINGS', 'display:none;');
252
}
253
if($admin->get_permission('admintools') != true)
254
{
255
	$oTpl->set_var('DISPLAY_ADMINTOOLS', 'display:none;');
256
}
257
*/
258

    
259

    
260
$oTpl->set_block('main_block', 'show_install_block', 'show_install');
261
if($admin->get_user_id() != 1)
262
{
263
	$oTpl->parse('show_install', '');
264
} else {
265

    
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
}
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
$oTpl->set_var(array(
317
					'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

    
335
// Parse template object
336
$oTpl->parse('main', 'main_block', false);
337
$oTpl->pparse('output', 'page');
338

    
339
// Print admin footer
340
$admin->print_footer();
    (1-1/1)