Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         settings
6
 * @author          Ryan Djurovich, 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 2070 2014-01-03 01:21:42Z darkviper $
13
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/settings/index.php $
14
 * @lastmodified    $Date: 2014-01-03 02:21:42 +0100 (Fri, 03 Jan 2014) $
15
 *
16
 */
17

    
18
// Include config file
19
if(!defined('WB_URL'))
20
{
21
    $config_file = realpath('../../config.php');
22
    if(file_exists($config_file) && !defined('WB_URL'))
23
    {
24
    	require($config_file);
25
    }
26
}
27
if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
28

    
29
if(isset($_GET['advanced']) && $_GET['advanced'] == 'yes') {
30
	$admin = new admin('Settings', 'settings_advanced');
31
} else {
32
	$admin = new admin('Settings', 'settings_basic');
33
}
34

    
35
// add new values, later in upgrade-script
36
$cfg = array(
37
	'wbmail_signature' => defined('WBMAIL_SIGNATURE') ? WBMAIL_SIGNATURE : '',
38
	'confirmed_registration' => (defined('CONFIRMED_REGISTRATION') ? CONFIRMED_REGISTRATION : '0'),
39
	'page_extendet' => (defined('PAGE_EXTENDET') ? PAGE_EXTENDET : 'true'),
40
	);
41
db_update_key_value( 'settings', $cfg );
42

    
43
// Include the WB functions file
44
require_once(WB_PATH.'/framework/functions.php');
45
require_once(WB_PATH.'/framework/functions-utf8.php');
46

    
47
// Setup template object, parse vars to it, then parse it
48
// Create new template object
49
$oTpl = new Template(dirname($admin->correct_theme_source('settings.htt')),'comment');
50
//$oTpl->debug = true;
51
//$oTpl->filename_comments = true;
52
//$oTpl->unknown_regexp = "strict";
53
//$oTpl->halt_on_error = "report" ;
54

    
55
$oTpl->set_file('page',  'settings.htt');
56
$oTpl->set_block('page', 'main_block', 'main');
57

    
58
//$mLang = ModLanguage::getInstance();
59
//$mLang->setLanguage(dirname(__FILE__).'/languages/', LANGUAGE, DEFAULT_LANGUAGE);
60
$mLang = Translate::getinstance();
61
$mLang->enableAddon('admin\settings');
62
/*-- insert all needed vars from language files ----------------------------------------*/
63
$oTpl->set_var($mLang->getLangArray());
64

    
65
$oTpl->set_var('FTAN', $admin->getFTAN());
66

    
67
// Query current settings in the db, then loop through them and print them
68
$query = "SELECT * FROM `".TABLE_PREFIX."settings`";
69
if($results = $database->query($query)) {
70
    while($setting = $results->fetchRow(MYSQL_ASSOC)) {
71
    	$setting_name = $setting['name'];
72
    	$setting_value = ( $setting_name != 'wbmailer_smtp_password' ) ? htmlspecialchars($setting['value']) : htmlentities($setting['value'], ENT_COMPAT, 'UTF-8');
73
    	$oTpl->set_var(strtoupper($setting_name),($setting_value));
74
    }
75
}
76

    
77
$is_advanced = (isset($_GET['advanced']) && $_GET['advanced'] == 'yes');
78
// Tell the browser whether or not to show advanced options
79
    if($is_advanced)
80
    {
81
    	$oTpl->set_var('DISPLAY_ADVANCED', '');
82
    	$oTpl->set_var('ADVANCED_FILE_PERMS_ID', 'file_perms_box');
83
    	$oTpl->set_var('BASIC_FILE_PERMS_ID', 'hide');
84
    	$oTpl->set_var('ADVANCED', 'yes');
85
    	$oTpl->set_var('ADVANCED_BUTTON', '&lt;&lt; '.$mLang->TEXT_HIDE_ADVANCED);
86
    	$oTpl->set_var('ADVANCED_LINK', 'index.php?advanced=no');
87

    
88
    } else {
89
    	$oTpl->set_var('DISPLAY_ADVANCED', ' style="display: none;"');
90
    	$oTpl->set_var('BASIC_FILE_PERMS_ID', 'file_perms_box');
91
    	$oTpl->set_var('ADVANCED_FILE_PERMS_ID', 'hide');
92

    
93
    	$oTpl->set_var('ADVANCED', 'no');
94
    	$oTpl->set_var('ADVANCED_BUTTON', $mLang->TEXT_SHOW_ADVANCED.' &gt;&gt;');
95
    	$oTpl->set_var('ADVANCED_LINK', 'index.php?advanced=yes');
96
    }
97

    
98
	$sSelected = ' selected="selected"';
99
	$checked   = ' checked="checked"';
100

    
101
	$oTpl->set_var(array(
102
		'WB_URL' => WB_URL,
103
		'THEME_URL' => THEME_URL,
104
		'ADMIN_URL' => ADMIN_URL,
105
	 ));
106

    
107
//  Insert permissions values
108
	if($admin->get_permission('settings_advanced') != true)
109
	{
110
		$oTpl->set_var('DISPLAY_ADVANCED_BUTTON', 'hide');
111
	}
112

    
113
    /**
114
     * <!-- BEGIN show_page_level_limit_block -->
115
     * Insert page level limits
116
     */
117
    $oTpl->set_block('main_block', 'show_page_level_limit_block', 'show_page_level_limit');
118
    /**
119
     * <!-- BEGIN page_level_limit_list_block -->
120
     */
121
    $oTpl->set_block('show_page_level_limit_block', 'page_level_limit_list_block', 'page_level_limit_list');
122
	for($i = 1; $i <= 10; $i++)
123
	{
124
		$oTpl->set_var('NUMBER', $i);
125
		if(PAGE_LEVEL_LIMIT == $i)
126
	    {
127
			$oTpl->set_var('SELECTED', $sSelected);
128
		} else {
129
			$oTpl->set_var('SELECTED', '');
130
		}
131
		$oTpl->parse('page_level_limit_list', 'page_level_limit_list_block', true);
132
	}
133

    
134
    /**
135
     * <!-- END page_level_limit_list_block -->
136
     * <!-- END show_page_level_limit_block -->
137
     */
138
    if($is_advanced)
139
    {
140
    	$oTpl->parse('show_page_level_limit', 'show_page_level_limit_block', false);
141
    } else {
142
    	$oTpl->parse('show_page_level_limit', '');
143
    }
144

    
145
    /**
146
     * Work-out if page trash feature is disabled, in-line, or separate
147
     */
148
	if(PAGE_TRASH == 'disabled')
149
	{
150
    	$oTpl->set_var(array(
151
				'PAGE_TRASH_DISABLED' => $checked,
152
				'PAGE_TRASH_INLINE' => '',
153
				'DISPLAY_PAGE_TRASH_SEPARATE' => 'display: none;',
154
				));
155
	} elseif(PAGE_TRASH == 'inline')
156
	{
157
    	$oTpl->set_var(array(
158
				'PAGE_TRASH_INLINE' => $checked,
159
				'PAGE_TRASH_DISABLED' => '',
160
				'DISPLAY_PAGE_TRASH_SEPARATE' => 'display: none;',
161
				));
162
	} elseif(PAGE_TRASH == 'separate')
163
	{
164
		$oTpl->set_var('PAGE_TRASH_SEPARATE', $checked);
165
		$oTpl->set_var('DISPLAY_PAGE_TRASH_SEPARATE', 'display: inline;');
166
	}
167

    
168
    /**
169
     * <!-- BEGIN show_checkbox_1_block -->
170
     * advanced yes
171
     */
172
    $oTpl->set_block('main_block', 'show_checkbox_1_block', 'show_checkbox_1');
173
//  Work-out if page languages feature is enabled
174
	if(defined('PAGE_LANGUAGES') && PAGE_LANGUAGES == true)
175
	{
176
    	$oTpl->set_var(array(
177
				'PAGE_LANGUAGES_ENABLED' => $checked,
178
				'PAGE_LANGUAGES_DISABLED' => '',
179
				));
180
	} else {
181
    	$oTpl->set_var(array(
182
				'PAGE_LANGUAGES_DISABLED' => $checked,
183
				'PAGE_LANGUAGES_ENABLED' => '',
184
				));
185
	}
186

    
187
//  Work-out if page extended feature is enabled
188
	if(defined('PAGE_EXTENDET') && PAGE_EXTENDET == true)
189
	{
190
    	$oTpl->set_var(array(
191
				'PAGE_EXTENDET_ENABLED' => $checked,
192
				'PAGE_EXTENDET_DISABLED' => '',
193
				));
194
	} else {
195
    	$oTpl->set_var(array(
196
				'PAGE_EXTENDET_DISABLED' => $checked,
197
				'PAGE_EXTENDET_ENABLED' => '',
198
				));
199
	}
200

    
201
//  Work-out if multiple menus feature is enabled
202
	if(defined('MULTIPLE_MENUS') && MULTIPLE_MENUS == true)
203
	{
204
    	$oTpl->set_var(array(
205
				'MULTIPLE_MENUS_ENABLED' => $checked,
206
				'MULTIPLE_MENUS_DISABLED' => '',
207
				));
208
	} else {
209
    	$oTpl->set_var(array(
210
				'MULTIPLE_MENUS_DISABLED' => $checked,
211
				'MULTIPLE_MENUS_ENABLED' => '',
212
				));
213
	}
214

    
215
    /**
216
     * <!-- END show_checkbox_1_block -->
217
     * advanced yes
218
     */
219
    if($is_advanced)
220
    {
221
    	$oTpl->parse('show_checkbox_1', 'show_checkbox_1_block');
222
    } else {
223
    	$oTpl->parse('show_checkbox_1', '');
224
    }
225

    
226
//  Work-out if media home folder feature is enabled
227
    $oTpl->set_var('TEXT_HOME_FOLDERS', $mLang->TEXT_HOME_FOLDERS);
228
	if(HOME_FOLDERS)
229
	{
230
    	$oTpl->set_var(array(
231
				'HOME_FOLDERS_ENABLED' => $checked,
232
				'HOME_FOLDERS_DISABLED' => '',
233
				));
234
	} else {
235
    	$oTpl->set_var(array(
236
				'HOME_FOLDERS_DISABLED' => $checked,
237
				'HOME_FOLDERS_ENABLED' => '',
238
				));
239
	}
240

    
241
    $oTpl->set_block('main_block', 'show_checkbox_2_block', 'show_checkbox_2');
242
//  Work-out if manage sections feature is enabled
243
	if(MANAGE_SECTIONS)
244
	{
245
    	$oTpl->set_var(array(
246
				'MANAGE_SECTIONS_ENABLED' => $checked,
247
				'MANAGE_SECTIONS_DISABLED' => '',
248
				));
249
	} else {
250
    	$oTpl->set_var(array(
251
				'MANAGE_SECTIONS_DISABLED' => $checked,
252
				'MANAGE_SECTIONS_ENABLED' => '',
253
				));
254
	}
255

    
256
	// Work-out if section blocks feature is enabled
257
	if(defined('SECTION_BLOCKS') && SECTION_BLOCKS == true)
258
	{
259
    	$oTpl->set_var(array(
260
				'SECTION_BLOCKS_ENABLED' => $checked,
261
				'SECTION_BLOCKS_DISABLED' => '',
262
				));
263
	} else {
264
    	$oTpl->set_var(array(
265
				'SECTION_BLOCKS_DISABLED' => $checked,
266
				'SECTION_BLOCKS_ENABLED' => '',
267
				));
268
	}
269

    
270
    /**
271
     *
272
     */
273
    if($is_advanced)
274
    {
275
     	$oTpl->parse('show_checkbox_2', 'show_checkbox_2_block');
276
    } else {
277
    	$oTpl->parse('show_checkbox_2', '');
278
    }
279

    
280
	// Work-out if intro feature is enabled
281
	if(INTRO_PAGE)
282
	{
283
    	$oTpl->set_var(array(
284
				'INTRO_PAGE_ENABLED' => $checked,
285
				'INTRO_PAGE_DISABLED' => '',
286
				));
287
	} else {
288
    	$oTpl->set_var(array(
289
				'INTRO_PAGE_DISABLED' => $checked,
290
				'INTRO_PAGE_ENABLED' => '',
291
				));
292
	}
293
/**
294
 * <!-- BEGIN show_checkbox_3_block -->
295
 */
296
    $oTpl->set_block('main_block', 'show_checkbox_3_block', 'show_checkbox_3');
297
//  Work-out if homepage redirection feature is enabled
298
	if(defined('HOMEPAGE_REDIRECTION') && HOMEPAGE_REDIRECTION == true)
299
	{
300
    	$oTpl->set_var(array(
301
				'HOMEPAGE_REDIRECTION_ENABLED' => $checked,
302
				'HOMEPAGE_REDIRECTION_DISABLED' => '',
303
				));
304
	} else {
305
//		$oTpl->set_var('HOMEPAGE_REDIRECTION_DISABLED', $checked);
306
    	$oTpl->set_var(array(
307
				'HOMEPAGE_REDIRECTION_DISABLED' => $checked,
308
				'HOMEPAGE_REDIRECTION_ENABLED' => '',
309
				));
310
	}
311
//  Work-out if smart login feature is enabled
312
	if(defined('SMART_LOGIN') && SMART_LOGIN == true)
313
	{
314
		$oTpl->set_var('SMART_LOGIN_ENABLED', $checked);
315
    	$oTpl->set_var(array(
316
				'SMART_LOGIN_ENABLED' => $checked,
317
				'SMART_LOGIN_DISABLED' => '',
318
				));
319
	} else {
320
		$oTpl->set_var('SMART_LOGIN_DISABLED', $checked);
321
    	$oTpl->set_var(array(
322
				'SMART_LOGIN_DISABLED' => $checked,
323
				'SMART_LOGIN_ENABLED' => '',
324
				));
325
	}
326

    
327
    /**
328
     * <!-- END show_checkbox_3_block -->
329
     */
330
    if($is_advanced)
331
    {
332
    	$oTpl->parse('show_checkbox_3', 'show_checkbox_3_block');
333
    } else {
334
    	$oTpl->parse('show_checkbox_3', 'show_checkbox_3_block', '');
335
    }
336

    
337
//  Work-out if frontend login feature is enabled
338
	if(FRONTEND_LOGIN)
339
	{
340
    	$oTpl->set_var(array(
341
				'PRIVATE_ENABLED' => $checked,
342
				'PRIVATE_DISABLED' => '',
343
				));
344
	} else {
345
    	$oTpl->set_var(array(
346
				'PRIVATE_DISABLED' => $checked,
347
				'PRIVATE_ENABLED' => '',
348
				));
349
	}
350

    
351
	if(CONFIRMED_REGISTRATION)
352
	{
353
    	$oTpl->set_var(array(
354
				'CONFIRMED_REGISTRATION_ENABLED' => $checked,
355
				'CONFIRMED_REGISTRATION_DISABLED' => '',
356
				));
357
	} else {
358
    	$oTpl->set_var(array(
359
				'CONFIRMED_REGISTRATION_DISABLED' => $checked,
360
				'CONFIRMED_REGISTRATION_ENABLED' => '',
361
				));
362
	}
363

    
364
//  Insert groups into signup list
365
    $oTpl->set_block('main_block', 'group_list_block', 'group_list');
366
    $sql = "SELECT `group_id`, `name` FROM `".TABLE_PREFIX."groups` WHERE `group_id` != '1'";
367
	if($results = $database->query($sql)) {
368
    	if($results->numRows() > 0)
369
    	{
370
    		while($group = $results->fetchRow(MYSQL_ASSOC))
371
    	    {
372
    			$oTpl->set_var('ID', $group['group_id']);
373
    			$oTpl->set_var('NAME', $group['name']);
374
    			if(FRONTEND_SIGNUP == $group['group_id'])
375
    	        {
376
    				$oTpl->set_var('SELECTED', $sSelected);
377
    			} else {
378
    				$oTpl->set_var('SELECTED', '');
379
    			}
380
    			$oTpl->parse('group_list', 'group_list_block', true);
381
    		}
382
    	} else {
383
    		$oTpl->set_var('ID', 'disabled');
384
    		$oTpl->set_var('NAME', $mLang->MESSAGE_GROUPS_NO_GROUPS_FOUND);
385
    		$oTpl->parse('group_list', 'group_list_block', true);
386
    	}
387
	}
388

    
389
    /**
390
     * <!-- BEGIN show_redirect_timer_block -->
391
     */
392
    $oTpl->set_block('main_block', 'show_redirect_timer_block', 'show_redirect_timer');
393

    
394
    /**
395
     * <!-- END show_redirect_timer_block -->
396
     */
397
    if($is_advanced)
398
    {
399
    	$oTpl->parse('show_redirect_timer', 'show_redirect_timer_block');
400
    } else {
401
    	$oTpl->parse('show_redirect_timer', '');
402
    }
403

    
404
    /**
405
     * <!-- BEGIN show_php_error_level_block -->
406
     */
407
	// Insert default error reporting values
408
	require(ADMIN_PATH.'/interface/er_levels.php');
409
    $oTpl->set_block('main_block', 'show_php_error_level_block',  'show_php_error_level');
410
    $oTpl->set_block('show_php_error_level_block', 'php_error_list_block',  'php_error_list');
411
	foreach($ER_LEVELS AS $value => $title)
412
	{
413
		$oTpl->set_var('VALUE', $value);
414
		$oTpl->set_var('NAME', $title);
415
	    $selected = (ER_LEVEL == $value) ? $sSelected : '';
416
	    $oTpl->set_var('SELECTED', $selected);
417
		$oTpl->parse('php_error_list', 'php_error_list_block', true);
418
	}
419

    
420
    /**
421
     * <!-- END show_php_error_level_block -->
422
     */
423
    if($is_advanced)
424
    {
425
    	$oTpl->parse('show_php_error_level',  'show_php_error_level_block');
426
    } else {
427
    	$oTpl->parse('show_php_error_level', '');
428
    }
429

    
430
    /**
431
     * <!-- BEGIN show_wysiwyg_block -->
432
     */
433
//  Insert WYSIWYG modules
434
    $oTpl->set_block('main_block', 'show_wysiwyg_block',        'show_wysiwyg');
435
    $oTpl->set_block('show_wysiwyg_block', 'editor_list_block', 'editor_list');
436
	$file='none';
437
	$module_name=$mLang->TEXT_NONE;
438
	$oTpl->set_var('FILE', $file);
439
	$oTpl->set_var('NAME', $module_name);
440
	$selected = (!defined('WYSIWYG_EDITOR') || $file == WYSIWYG_EDITOR) ? $sSelected : '';
441
	$oTpl->set_var('SELECTED', $selected);
442
	$oTpl->parse('editor_list', 'editor_list_block', true);
443
	$sql  = 'SELECT `name`, `directory` FROM `'.TABLE_PREFIX.'addons` ';
444
	$sql .= 'WHERE `type` = \'module\' ';
445
	$sql .= 'AND `function` = \'wysiwyg\' ';
446
	$sql .= 'ORDER BY `name`';
447
	if( ($result = $database->query($sql)) && ($result->numRows() > 0) )
448
	{
449
		while($addon = $result->fetchRow(MYSQL_ASSOC))
450
	    {
451
			if( $admin->get_permission($addon['directory'],'module' ) )
452
			{
453
				$oTpl->set_var('FILE', $addon['directory']);
454
				$oTpl->set_var('NAME', $addon['name']);
455
				$selected = (!defined('WYSIWYG_EDITOR') || $addon['directory'] == WYSIWYG_EDITOR) ? $sSelected : '';
456
				$oTpl->set_var('SELECTED', $selected);
457
				$oTpl->parse('editor_list', 'editor_list_block', true);
458
			}
459
		}
460
	}
461

    
462
    /**
463
     * <!-- END show_wysiwyg_block -->
464
     */
465
    if($is_advanced)
466
    {
467
    	$oTpl->parse('show_wysiwyg','show_wysiwyg_block');
468
    } else {
469
    	$oTpl->parse('show_wysiwyg', '');
470
    }
471

    
472
//  Insert language values
473
    $oTpl->set_block('main_block', 'language_list_block', 'language_list');
474
	$sql  = 'SELECT `name`, `directory` FROM `'.TABLE_PREFIX.'addons` ';
475
	$sql .= 'WHERE `type` = \'language\' ';
476
	$sql .= 'AND `function` != \'theme\' ';
477
	$sql .= 'ORDER BY `directory`';
478
	if( ($result = $database->query($sql)) && ($result->numRows() > 0) )
479
	{
480
		while($addon = $result->fetchRow(MYSQL_ASSOC)) {
481
	        $langIcons = (empty($addon['directory'])) ? 'none' : strtolower($addon['directory']);
482

    
483
			$oTpl->set_var('CODE',        $addon['directory']);
484
			$oTpl->set_var('NAME',        $addon['name']);
485
			$oTpl->set_var('FLAG',        THEME_URL.'/images/flags/'.$langIcons);
486
			$oTpl->set_var('SELECTED',    (DEFAULT_LANGUAGE == $addon['directory'] ? $sSelected : '') );
487
			$oTpl->parse('language_list', 'language_list_block', true);
488
		}
489
	}
490
    /**
491
     * <!-- BEGIN show_charset_block -->
492
     */
493
//  Insert default charset values
494
    $oTpl->set_block('main_block', 'show_charset_block', 'show_charset');
495
	require(ADMIN_PATH.'/interface/charsets.php');
496
    $oTpl->set_block('show_charset_block', 'charset_list_block', 'charset_list');
497
	foreach($CHARSETS AS $code => $title) {
498
		$oTpl->set_var('VALUE', $code);
499
		$oTpl->set_var('NAME', $title);
500
		if(DEFAULT_CHARSET == $code) {
501
			$oTpl->set_var('SELECTED', $sSelected);
502
		} else {
503
			$oTpl->set_var('SELECTED', '');
504
		}
505
		$oTpl->parse('charset_list', 'charset_list_block', true);
506
	}
507
    /**
508
     * <!-- END show_charset_block -->
509
     */
510
    if($is_advanced)
511
    {
512
    	$oTpl->parse('show_charset', 'show_charset_block');
513
    } else {
514
    	$oTpl->parse('show_charset', '');
515
    }
516

    
517
//  nsert default timezone values
518
	require(ADMIN_PATH.'/interface/timezones.php');
519
    $oTpl->set_block('main_block', 'timezone_list_block','timezone_list');
520
	foreach($TIMEZONES AS $hour_offset => $title)
521
	{
522
//  Make sure we dont list "System Default" as we are setting this value!
523
		if($hour_offset != '-20') {
524
			$oTpl->set_var('VALUE', $hour_offset);
525
			$oTpl->set_var('NAME', $title);
526
			if(DEFAULT_TIMEZONE == $hour_offset*60*60) {
527
				$oTpl->set_var('SELECTED', $sSelected);
528
			} else {
529
				$oTpl->set_var('SELECTED', '');
530
			}
531
			$oTpl->parse('timezone_list', 'timezone_list_block', true);
532
		}
533
	}
534

    
535
//  Insert date format list
536
	require(ADMIN_PATH.'/interface/date_formats.php');
537
    $oTpl->set_block('main_block', 'date_format_list_block', 'date_format_list');
538
	foreach($DATE_FORMATS AS $format => $title) {
539
		$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
540
		if($format != 'system_default') {
541
			$oTpl->set_var('VALUE', $format);
542
		} else {
543
			$oTpl->set_var('VALUE', '');
544
		}
545
		$oTpl->set_var('NAME', $title);
546
		if(DEFAULT_DATE_FORMAT == $format) {
547
			$oTpl->set_var('SELECTED', $sSelected);
548
		} else {
549
			$oTpl->set_var('SELECTED', '');
550
		}
551
		$oTpl->parse('date_format_list', 'date_format_list_block', true);
552
	}
553

    
554
//  Insert time format list
555
	require(ADMIN_PATH.'/interface/time_formats.php');
556
    $oTpl->set_block('main_block', 'time_format_list_block', 'time_format_list');
557
	foreach($TIME_FORMATS AS $format => $title) {
558
		$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
559
		if($format != 'system_default') {
560
			$oTpl->set_var('VALUE', $format);
561
		} else {
562
			$oTpl->set_var('VALUE', '');
563
		}
564
		$oTpl->set_var('NAME', $title);
565
		if(DEFAULT_TIME_FORMAT == $format) {
566
			$oTpl->set_var('SELECTED', $sSelected);
567
		} else {
568
			$oTpl->set_var('SELECTED', '');
569
		}
570
		$oTpl->parse('time_format_list', 'time_format_list_block', true);
571
	}
572

    
573
// Insert templates
574
    $oTpl->set_block('main_block', 'template_list_block',         'template_list');
575
	$sql  = 'SELECT `name`, `directory` FROM `'.TABLE_PREFIX.'addons` ';
576
	$sql .= 'WHERE `type` = \'template\' ';
577
	$sql .= 'AND `function` != \'theme\' ';
578
	$sql .= 'ORDER BY `name`';
579
	if( ($result = $database->query($sql)) && ($result->numRows() > 0) )
580
	{
581
		while($addon = $result->fetchRow(MYSQL_ASSOC))
582
		{
583
			if( $admin->get_permission($addon['directory'],'template' ) )
584
			{
585
				$oTpl->set_var('FILE', $addon['directory']);
586
				$oTpl->set_var('NAME', $addon['name']);
587
				$selected = (($addon['directory'] == DEFAULT_TEMPLATE) ? $sSelected : '');
588
				$oTpl->set_var('SELECTED', $selected);
589
				$oTpl->parse('template_list', 'template_list_block', true);
590
			}
591
		}
592
	}
593

    
594
// Insert backend theme
595
    $oTpl->set_block('main_block', 'theme_list_block',            'theme_list');
596
	$sql  = 'SELECT `name`, `directory` FROM `'.TABLE_PREFIX.'addons` ';
597
	$sql .= 'WHERE `type` = \'template\' ';
598
	$sql .= 'AND `function` = \'theme\' ';
599
	$sql .= 'ORDER BY `name`';
600

    
601
	if( ($result = $database->query($sql)) && ($result->numRows() > 0) )
602
	{
603
		while($addon = $result->fetchRow(MYSQL_ASSOC))
604
		{
605
			if( $admin->get_permission($addon['directory'],'template' ) )
606
			{
607
				$oTpl->set_var('FILE', $addon['directory']);
608
				$oTpl->set_var('NAME', $addon['name']);
609
				$selected = (($addon['directory'] == DEFAULT_THEME) ? $sSelected : '');
610
				$oTpl->set_var('SELECTED', $selected);
611
				$oTpl->parse('theme_list', 'theme_list_block', true);
612
			}
613
		}
614
	}
615

    
616
//  Work-out if warn_page_leave feature is enabled
617
//	if (defined('WARN_PAGE_LEAVE') && WARN_PAGE_LEAVE == true)
618
//	{
619
//    	$oTpl->set_var(array(
620
//				'WARN_PAGE_LEAVE_ENABLED' => $checked,
621
//				'WARN_PAGE_LEAVE_DISABLED' => '',
622
//				));
623
//	} else {
624
//    	$oTpl->set_var(array(
625
//				'MANAGE_SECTIONS_DISABLED' => $checked,
626
//				'WARN_PAGE_LEAVE_DISABLED' => '',
627
//				));
628
//	}
629

    
630
/*  Make's sure GD library is installed */
631
//	if(extension_loaded('gd') && function_exists('imageCreateFromJpeg'))
632
//	{
633
//		$oTpl->set_var('GD_EXTENSION_ENABLED', '');
634
//	} else {
635
//		$oTpl->set_var('GD_EXTENSION_ENABLED', ' style="display: none;"');
636
//	}
637

    
638
//  Insert permissions values
639
//	if($admin->get_permission('settings_advanced') != true)
640
//	{
641
//		$oTpl->set_var('DISPLAY_ADVANCED_BUTTON', 'hide');
642
//	}
643

    
644
/**
645
 *
646
 *
647
 */
648
    $oTpl->set_block('main_block', 'show_search_block','show_search');
649
	$query = "SELECT * FROM `".TABLE_PREFIX."search` WHERE `extra` = '' ";
650
	if($results = $database->query($query))
651
    {
652
    	// Query current settings in the db, then loop through them and print them
653
    	while($setting = $results->fetchRow(MYSQL_ASSOC))
654
    	{
655
    		$setting_name = $setting['name'];
656
    		$setting_value = htmlspecialchars(($setting['value']));
657
    		switch($setting_name) {
658
    			// Search header
659
    			case 'header':
660
    				$oTpl->set_var('SEARCH_HEADER', $setting_value);
661
    			break;
662
    			// Search results header
663
    			case 'results_header':
664
    				$oTpl->set_var('SEARCH_RESULTS_HEADER', $setting_value);
665
    			break;
666
    			// Search results loop
667
    			case 'results_loop':
668
    				$oTpl->set_var('SEARCH_RESULTS_LOOP', $setting_value);
669
    			break;
670
    			// Search results footer
671
    			case 'results_footer':
672
    				$oTpl->set_var('SEARCH_RESULTS_FOOTER', $setting_value);
673
    			break;
674
    			// Search no results
675
    			case 'no_results':
676
    				$oTpl->set_var('SEARCH_NO_RESULTS', $setting_value);
677
    			break;
678
    			// Search footer
679
    			case 'footer':
680
    				$oTpl->set_var('SEARCH_FOOTER', $setting_value);
681
    			break;
682
    			// Search module-order
683
    			case 'module_order':
684
    				$oTpl->set_var('SEARCH_MODULE_ORDER', $setting_value);
685
    			break;
686
    			// Search max lines of excerpt
687
    			case 'max_excerpt':
688
    				$oTpl->set_var('SEARCH_MAX_EXCERPT', $setting_value);
689
    			break;
690
    			// time-limit
691
    			case 'time_limit':
692
    				$oTpl->set_var('SEARCH_TIME_LIMIT', $setting_value);
693
    			break;
694
    			// Search template
695
    			case 'template':
696
    				$search_template = $setting_value;
697
    			break;
698
    		}
699
    	}
700
	}
701

    
702
// Insert templates for search settings
703
    $oTpl->set_block('main_block', 'search_template_list_block',  'search_template_list');
704
	$search_template = ( ($search_template == DEFAULT_TEMPLATE) || ($search_template == '') ) ? '' : $search_template;
705
	$selected = ( ($search_template != DEFAULT_TEMPLATE) ) ?  $sSelected : '';
706

    
707
	$oTpl->set_var(array(
708
	        'FILE' => '',
709
			'TEXT_MODULE_ORDER' => $mLang->TEXT_MODULE_ORDER,
710
	        'NAME' => $mLang->TEXT_SYSTEM_DEFAULT,
711
	        'SELECTED' => $selected
712
	    ));
713
	$oTpl->parse('search_template_list', 'search_template_list_block', true);
714
	$sql  = 'SELECT `name`, `directory` FROM `'.TABLE_PREFIX.'addons` ';
715
	$sql .= 'WHERE `type` = \'template\' ';
716
	$sql .= 'AND `function` = \'template\' ';
717
	$sql .= 'ORDER BY `name`';
718
    if( ($result = $database->query($sql)) && ($result->numRows() > 0) )
719
	{
720
		while($addon = $result->fetchRow(MYSQL_ASSOC))
721
	    {
722
			if( $admin->get_permission($addon['directory'],'template' ) )
723
			{
724
				$oTpl->set_var('FILE', $addon['directory']);
725
				$oTpl->set_var('NAME', $addon['name']);
726
		        $selected = ($addon['directory'] == $search_template) ? $sSelected :  '';
727
				$oTpl->set_var('SELECTED', $selected);
728
				$oTpl->parse('search_template_list', 'search_template_list_block', true);
729
			}
730
		}
731
	}
732

    
733
	// Insert search select
734
//    $oTpl->set_var(array(
735
//		'TEXT_REGISTERED' => $mLang->TEXT_REGISTERED'],
736
//		'TEXT_PUBLIC' => $mLang->TEXT_PUBLIC,
737
//		'TEXT_PRIVATE' => $mLang->TEXT_PRIVATE'],
738
//		'TEXT_NONE' => $mLang->TEXT_NONE'],
739
//		'TEXT_MAX_EXCERPT' => $mLang->TEXT_MAX_EXCERPT'],
740
//		'TEXT_TIME_LIMIT' => $mLang->TEXT_TIME_LIMIT'],
741
//		'TEXT_VISIBILITY' => $mLang->TEXT_VISIBILITY'],
742
//		'TEXT_SEARCH' => $mLang->TEXT_SEARCH'],
743
//		));
744
	if(SEARCH == 'private')
745
	{
746
    	$oTpl->set_var(array(
747
				'PRIVATE_SEARCH' => $sSelected,
748
				'REGISTERED_SEARCH' => '',
749
				'NONE_SEARCH' => '',
750
				));
751
	} elseif(SEARCH == 'public') {
752
    	$oTpl->set_var(array(
753
				'PRIVATE_SEARCH' => '',
754
				'REGISTERED_SEARCH' => '',
755
				'NONE_SEARCH' => '',
756
				));
757
	} elseif(SEARCH == 'registered') {
758
    	$oTpl->set_var(array(
759
				'PRIVATE_SEARCH' => '',
760
				'REGISTERED_SEARCH' => $sSelected,
761
				'NONE_SEARCH' => '',
762
				));
763
	} elseif(SEARCH == 'none') {
764
    	$oTpl->set_var(array(
765
				'PRIVATE_SEARCH' => '',
766
				'REGISTERED_SEARCH' => '',
767
				'NONE_SEARCH' => $sSelected,
768
				));
769
	}
770

    
771
if($is_advanced)
772
{
773
	$oTpl->parse('show_search', 'show_search_block');
774
} else {
775
	$oTpl->parse('show_search', '');
776
}
777

    
778
    $oTpl->set_block('main_block', 'show_access_block','show_access');
779
//  Work-out which wbmailer routine should be checked
780
	$oTpl->set_var(array(
781
		'TEXT_WBMAILER_SMTP_AUTH_NOTICE' => $mLang->TEXT_REQUIRED.' '.$mLang->TEXT_WBMAILER_SMTP_AUTH,
782
		'SMTP_AUTH_SELECTED' => $checked,
783
		'TEXT_WBMAILER_DEFAULT_SETTINGS_NOTICE' => $mLang->TEXT_WBMAILER_DEFAULT_SETTINGS_NOTICE,
784
		'TEXT_WBMAILER_DEFAULT_SENDER_MAIL' => $mLang->TEXT_WBMAILER_DEFAULT_SENDER_MAIL,
785
		'TEXT_WBMAILER_DEFAULT_SENDER_NAME' => $mLang->TEXT_WBMAILER_DEFAULT_SENDER_NAME,
786
		'TEXT_WBMAILER_NOTICE' => $mLang->TEXT_WBMAILER_NOTICE,
787
		'TEXT_WBMAILER_FUNCTION' => $mLang->TEXT_WBMAILER_FUNCTION,
788
		'TEXT_WBMAILER_SMTP_HOST' => $mLang->TEXT_WBMAILER_SMTP_HOST,
789
		'TEXT_WBMAILER_PHP' => $mLang->TEXT_WBMAILER_PHP,
790
		'TEXT_WBMAILER_SMTP' => $mLang->TEXT_WBMAILER_SMTP,
791
		'TEXT_WBMAILER_SMTP_AUTH' => $mLang->TEXT_WBMAILER_SMTP_AUTH,
792
		'TEXT_WBMAILER_SMTP_USERNAME' => $mLang->TEXT_WBMAILER_SMTP_USERNAME,
793
		'TEXT_WBMAILER_SMTP_PASSWORD' => $mLang->TEXT_WBMAILER_SMTP_PASSWORD,
794
		));
795

    
796
	// Work-out if developer infos feature is enabled
797
	if(defined('DEV_INFOS') && DEV_INFOS == true)
798
	{
799
    	$oTpl->set_var(array(
800
				'DEV_INFOS_ENABLED' => $checked,
801
				'DEV_INFOS_DISABLED' => '',
802
				));
803
	} else {
804
    	$oTpl->set_var(array(
805
				'DEV_INFOS_DISABLED' => $checked,
806
				'DEV_INFOS_ENABLED' => '',
807
				));
808
	}
809

    
810
//  Work-out which server os should be checked
811
	if(OPERATING_SYSTEM == 'linux')
812
	{
813
		$oTpl->set_var('LINUX_SELECTED', $checked);
814
		$oTpl->set_var('WINDOWS_SELECTED', '');
815
	} elseif(OPERATING_SYSTEM == 'windows') {
816
		$oTpl->set_var('WINDOWS_SELECTED', $checked);
817
		$oTpl->set_var('LINUX_SELECTED', '');
818
	}
819

    
820
	if(WBMAILER_ROUTINE == 'phpmail')
821
	{
822
		$oTpl->set_var('PHPMAIL_SELECTED', $checked);
823
		$oTpl->set_var('SMTP_VISIBILITY', ' style="display: none;"');
824
//		$oTpl->set_var('SMTP_VISIBILITY_AUTH', '');
825
		$oTpl->set_var('SMTP_AUTH_SELECTED', '');
826
		$oTpl->set_var('SMTPMAIL_SELECTED',  '');
827
	} elseif(WBMAILER_ROUTINE == 'smtp')
828
	{
829
		$oTpl->set_var('SMTPMAIL_SELECTED', $checked);
830
		$oTpl->set_var('PHPMAIL_SELECTED', '');
831
		$oTpl->set_var('SMTP_VISIBILITY', '');
832
//		$oTpl->set_var('SMTP_VISIBILITY_AUTH', '');
833
	}
834
/* deprecated
835
	// Work-out if SMTP authentification should be checked
836
	if(WBMAILER_SMTP_AUTH)
837
	{
838
		$oTpl->set_var('SMTP_AUTH_SELECTED', $checked);
839
		if(WBMAILER_ROUTINE == 'smtp')
840
	    {
841
			$oTpl->set_var('SMTP_VISIBILITY_AUTH', '');
842

    
843
		} else {
844
			$oTpl->set_var('SMTP_VISIBILITY_AUTH', ' style="display: none;"');
845
		}
846
	} else {
847
		$oTpl->set_var('SMTP_VISIBILITY_AUTH', ' style="display: none;"');
848
	}
849
*/
850

    
851
	// Work-out if 777 permissions are set
852
	$oTpl->set_var('WORLD_WRITEABLE_SELECTED', '');
853
	if(STRING_FILE_MODE == '0777' AND STRING_DIR_MODE == '0777')
854
	{
855
		$oTpl->set_var('WORLD_WRITEABLE_SELECTED', $checked);
856
	}
857

    
858

    
859
	$oTpl->set_var(array(
860
		'FILE_U_R_CHECKED' => '',
861
		'FILE_U_W_CHECKED' => '',
862
		'FILE_U_E_CHECKED' => '',
863
		'FILE_G_R_CHECKED' => '',
864
		'FILE_G_W_CHECKED' => '',
865
		'FILE_G_E_CHECKED' => '',
866
		'FILE_O_R_CHECKED' => '',
867
		'FILE_O_W_CHECKED' => '',
868
		'FILE_O_E_CHECKED' => '',
869
		'DIR_U_R_CHECKED' => '',
870
		'DIR_U_W_CHECKED' => '',
871
		'DIR_U_E_CHECKED' => '',
872
		'DIR_G_R_CHECKED' => '',
873
		'DIR_G_W_CHECKED' => '',
874
		'DIR_G_E_CHECKED' => '',
875
		'DIR_O_R_CHECKED' => '',
876
		'DIR_O_W_CHECKED' => '',
877
		'DIR_O_E_CHECKED' => '',
878
		));
879

    
880
//  Work-out which file mode boxes are checked
881
	if(extract_permission(STRING_FILE_MODE, 'u', 'r'))
882
	{
883
		$oTpl->set_var('FILE_U_R_CHECKED', $checked);
884
	}
885
	if(extract_permission(STRING_FILE_MODE, 'u', 'w'))
886
	{
887
		$oTpl->set_var('FILE_U_W_CHECKED', $checked);
888
	}
889
	if(extract_permission(STRING_FILE_MODE, 'u', 'e'))
890
	{
891
		$oTpl->set_var('FILE_U_E_CHECKED', $checked);
892
	}
893
	if(extract_permission(STRING_FILE_MODE, 'g', 'r'))
894
	{
895
		$oTpl->set_var('FILE_G_R_CHECKED', $checked);
896
	}
897
	if(extract_permission(STRING_FILE_MODE, 'g', 'w'))
898
	{
899
		$oTpl->set_var('FILE_G_W_CHECKED', $checked);
900
	}
901
	if(extract_permission(STRING_FILE_MODE, 'g', 'e'))
902
	{
903
		$oTpl->set_var('FILE_G_E_CHECKED', $checked);
904
	}
905
	if(extract_permission(STRING_FILE_MODE, 'o', 'r'))
906
	{
907
		$oTpl->set_var('FILE_O_R_CHECKED', $checked);
908
	}
909
	if(extract_permission(STRING_FILE_MODE, 'o', 'w'))
910
	{
911
		$oTpl->set_var('FILE_O_W_CHECKED', $checked);
912
	}
913
	if(extract_permission(STRING_FILE_MODE, 'o', 'e'))
914
	{
915
		$oTpl->set_var('FILE_O_E_CHECKED', $checked);
916
	}
917
	// Work-out which dir mode boxes are checked
918
	if(extract_permission(STRING_DIR_MODE, 'u', 'r'))
919
	{
920
		$oTpl->set_var('DIR_U_R_CHECKED', $checked);
921
	}
922
	if(extract_permission(STRING_DIR_MODE, 'u', 'w'))
923
	{
924
		$oTpl->set_var('DIR_U_W_CHECKED', $checked);
925
	}
926
	if(extract_permission(STRING_DIR_MODE, 'u', 'e'))
927
	{
928
		$oTpl->set_var('DIR_U_E_CHECKED', $checked);
929
	}
930
	if(extract_permission(STRING_DIR_MODE, 'g', 'r'))
931
	{
932
		$oTpl->set_var('DIR_G_R_CHECKED', $checked);
933
	}
934
	if(extract_permission(STRING_DIR_MODE, 'g', 'w'))
935
	{
936
		$oTpl->set_var('DIR_G_W_CHECKED', $checked);
937
	}
938
	if(extract_permission(STRING_DIR_MODE, 'g', 'e'))
939
	{
940
		$oTpl->set_var('DIR_G_E_CHECKED', $checked);
941
	}
942
	if(extract_permission(STRING_DIR_MODE, 'o', 'r'))
943
	{
944
		$oTpl->set_var('DIR_O_R_CHECKED', $checked);
945
	}
946
	if(extract_permission(STRING_DIR_MODE, 'o', 'w'))
947
	{
948
		$oTpl->set_var('DIR_O_W_CHECKED', $checked);
949
	}
950
	if(extract_permission(STRING_DIR_MODE, 'o', 'e'))
951
	{
952
		$oTpl->set_var('DIR_O_E_CHECKED', $checked);
953
	}
954
	$sReadOnly = '';
955
	$sPagesEditType = 'text';
956
	if( $bPagesCanModify = ($database->get_one('SELECT COUNT(*) FROM `'.TABLE_PREFIX.'pages`'))!=0 ) {
957
		$sReadOnly = ' readonly="readonly"';
958
		$sPagesEditType = 'grey bold';
959
	}
960

    
961
	$oTpl->set_var(array(
962
		'PAGES_DIRECTORY' => PAGES_DIRECTORY,
963
		'PAGES_READONLY' => $sReadOnly,
964
		'PAGES_EDIT_TYPE' => $sPagesEditType,
965
		'PAGE_ICON_DIR'   => PAGE_ICON_DIR,
966
		'MEDIA_DIRECTORY' => MEDIA_DIRECTORY,
967
		'PAGE_EXTENSION' => PAGE_EXTENSION,
968
		'PAGE_SPACER' => PAGE_SPACER,
969
		'TABLE_PREFIX' => TABLE_PREFIX
970
	 ));
971

    
972
	// Insert Server Email value into template
973
	$oTpl->set_var('SERVER_EMAIL', SERVER_EMAIL);
974

    
975
// Insert language text and messages
976
	$oTpl->set_var(array(
977
		'TEXT_CHANGES' => $mLang->TEXT_CHANGES,
978
		'TEXT_FILES' => strtoupper(substr($mLang->TEXT_FILES, 0, 1)).substr($mLang->TEXT_FILES, 1),
979
		'TEXT_WARN_PAGE_LEAVE' => '',
980
		'TEXT_WORLD_WRITEABLE_FILE_PERMISSIONS' => $mLang->TEXT_WORLD_WRITEABLE_FILE_PERMISSIONS,
981
		'MODE_SWITCH_WARNING' => $mLang->MESSAGE_SETTINGS_MODE_SWITCH_WARNING,
982
		'WORLD_WRITEABLE_WARNING' => $mLang->MESSAGE_SETTINGS_WORLD_WRITEABLE_WARNING
983
		));
984

    
985
if($is_advanced && $admin->get_user_id()=='1')
986
{
987
	$oTpl->parse('show_access', 'show_access_block');
988
}else {
989
	$oTpl->parse('show_access' , '');
990
}
991

    
992
// Parse template objects output
993
$oTpl->parse('main', 'main_block',false);
994
$oTpl->pparse('output', 'page');
995
//$oTpl->p('page');
996
unset($oTpl);
997
$mLang->disableAddon();
998
$admin->print_footer();
(1-1/4)