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 2109 2014-11-25 13:15:56Z darkviper $
13
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/settings/index.php $
14
 * @lastmodified    $Date: 2014-11-25 14:15:56 +0100 (Tue, 25 Nov 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(isset($_GET['advanced']) && $_GET['advanced'] == 'yes') {
28
	$admin = new admin('Settings', 'settings_advanced');
29
} else {
30
	$admin = new admin('Settings', 'settings_basic');
31
}
32
$oDb = WbDatabase::getInstance();
33
$oTrans = Translate::getInstance();
34
$oTrans->enableAddon('admin\\settings');
35

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

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

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

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

    
59
/*-- insert all needed vars from language files ----------------------------------------*/
60
$oTpl->set_var($oTrans->getLangArray());
61

    
62
$oTpl->set_var('FTAN', $admin->getFTAN());
63

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

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

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

    
90
    	$oTpl->set_var('ADVANCED', 'no');
91
    	$oTpl->set_var('ADVANCED_BUTTON', $oTrans->TEXT_SHOW_ADVANCED.' &gt;&gt;');
92
    	$oTpl->set_var('ADVANCED_LINK', 'index.php?advanced=yes');
93
    }
94

    
95
	$sSelected = ' selected="selected"';
96
	$checked   = ' checked="checked"';
97

    
98
	$oTpl->set_var(array(
99
		'WB_URL'    => WB_URL,
100
		'THEME_URL' => THEME_URL,
101
		'ADMIN_URL' => ADMIN_URL,
102
	 ));
103

    
104
//  Insert permissions values
105
	if ($admin->get_permission('settings_advanced') != true) {
106
		$oTpl->set_var('DISPLAY_ADVANCED_BUTTON', 'hide');
107
	}
108

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

    
130
    /**
131
     * <!-- END page_level_limit_list_block -->
132
     * <!-- END show_page_level_limit_block -->
133
     */
134
    if($is_advanced)
135
    {
136
    	$oTpl->parse('show_page_level_limit', 'show_page_level_limit_block', false);
137
    } else {
138
    	$oTpl->parse('show_page_level_limit', '');
139
    }
140

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

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

    
180
//  Work-out if page extended feature is enabled
181
	if(defined('PAGE_EXTENDET') && PAGE_EXTENDET == true) {
182
    	$oTpl->set_var(array(
183
				'PAGE_EXTENDET_ENABLED' => $checked,
184
				'PAGE_EXTENDET_DISABLED' => '',
185
				));
186
	} else {
187
    	$oTpl->set_var(array(
188
				'PAGE_EXTENDET_DISABLED' => $checked,
189
				'PAGE_EXTENDET_ENABLED' => '',
190
				));
191
	}
192

    
193
//  Work-out if multiple menus feature is enabled
194
	if(defined('MULTIPLE_MENUS') && MULTIPLE_MENUS == true) {
195
    	$oTpl->set_var(array(
196
				'MULTIPLE_MENUS_ENABLED' => $checked,
197
				'MULTIPLE_MENUS_DISABLED' => '',
198
				));
199
	} else {
200
    	$oTpl->set_var(array(
201
				'MULTIPLE_MENUS_DISABLED' => $checked,
202
				'MULTIPLE_MENUS_ENABLED' => '',
203
				));
204
	}
205

    
206
    /**
207
     * <!-- END show_checkbox_1_block -->
208
     * advanced yes
209
     */
210
    if($is_advanced) {
211
    	$oTpl->parse('show_checkbox_1', 'show_checkbox_1_block');
212
    } else {
213
    	$oTpl->parse('show_checkbox_1', '');
214
    }
215

    
216
//  Work-out if media home folder feature is enabled
217
    $oTpl->set_var('TEXT_HOME_FOLDERS', $oTrans->TEXT_HOME_FOLDERS);
218
	if(HOME_FOLDERS)
219
	{
220
    	$oTpl->set_var(array(
221
				'HOME_FOLDERS_ENABLED' => $checked,
222
				'HOME_FOLDERS_DISABLED' => '',
223
				));
224
	} else {
225
    	$oTpl->set_var(array(
226
				'HOME_FOLDERS_DISABLED' => $checked,
227
				'HOME_FOLDERS_ENABLED' => '',
228
				));
229
	}
230

    
231
    $oTpl->set_block('main_block', 'show_checkbox_2_block', 'show_checkbox_2');
232
//  Work-out if manage sections feature is enabled
233
	if(MANAGE_SECTIONS)
234
	{
235
    	$oTpl->set_var(array(
236
				'MANAGE_SECTIONS_ENABLED' => $checked,
237
				'MANAGE_SECTIONS_DISABLED' => '',
238
				));
239
	} else {
240
    	$oTpl->set_var(array(
241
				'MANAGE_SECTIONS_DISABLED' => $checked,
242
				'MANAGE_SECTIONS_ENABLED' => '',
243
				));
244
	}
245

    
246
	// Work-out if section blocks feature is enabled
247
	if(defined('SECTION_BLOCKS') && SECTION_BLOCKS == true)
248
	{
249
    	$oTpl->set_var(array(
250
				'SECTION_BLOCKS_ENABLED' => $checked,
251
				'SECTION_BLOCKS_DISABLED' => '',
252
				));
253
	} else {
254
    	$oTpl->set_var(array(
255
				'SECTION_BLOCKS_DISABLED' => $checked,
256
				'SECTION_BLOCKS_ENABLED' => '',
257
				));
258
	}
259

    
260
    /**
261
     *
262
     */
263
    if($is_advanced)
264
    {
265
     	$oTpl->parse('show_checkbox_2', 'show_checkbox_2_block');
266
    } else {
267
    	$oTpl->parse('show_checkbox_2', '');
268
    }
269

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

    
317
    /**
318
     * <!-- END show_checkbox_3_block -->
319
     */
320
    if($is_advanced)
321
    {
322
    	$oTpl->parse('show_checkbox_3', 'show_checkbox_3_block');
323
    } else {
324
    	$oTpl->parse('show_checkbox_3', 'show_checkbox_3_block', '');
325
    }
326

    
327
//  Work-out if frontend login feature is enabled
328
	if(FRONTEND_LOGIN)
329
	{
330
    	$oTpl->set_var(array(
331
				'PRIVATE_ENABLED' => $checked,
332
				'PRIVATE_DISABLED' => '',
333
				));
334
	} else {
335
    	$oTpl->set_var(array(
336
				'PRIVATE_DISABLED' => $checked,
337
				'PRIVATE_ENABLED' => '',
338
				));
339
	}
340

    
341
	if(CONFIRMED_REGISTRATION)
342
	{
343
    	$oTpl->set_var(array(
344
				'CONFIRMED_REGISTRATION_ENABLED' => $checked,
345
				'CONFIRMED_REGISTRATION_DISABLED' => '',
346
				));
347
	} else {
348
    	$oTpl->set_var(array(
349
				'CONFIRMED_REGISTRATION_DISABLED' => $checked,
350
				'CONFIRMED_REGISTRATION_ENABLED' => '',
351
				));
352
	}
353

    
354
//  Insert groups into signup list
355
    $oTpl->set_block('main_block', 'group_list_block', 'group_list');
356
    $sql = 'SELECT `group_id`, `name` FROM `'.$oDb->TablePrefix.'groups` '
357
         . 'WHERE `group_id` != 1';
358
	if (($results = $oDb->doQuery($sql))) {
359
    	if ($results->numRows() > 0) {
360
    		while($group = $results->fetchRow(MYSQL_ASSOC)) {
361
    			$oTpl->set_var('ID', $group['group_id']);
362
    			$oTpl->set_var('NAME', $group['name']);
363
    			if(FRONTEND_SIGNUP == $group['group_id'])
364
    	        {
365
    				$oTpl->set_var('SELECTED', $sSelected);
366
    			} else {
367
    				$oTpl->set_var('SELECTED', '');
368
    			}
369
    			$oTpl->parse('group_list', 'group_list_block', true);
370
    		}
371
    	} else {
372
    		$oTpl->set_var('ID', 'disabled');
373
    		$oTpl->set_var('NAME', $oTrans->MESSAGE_GROUPS_NO_GROUPS_FOUND);
374
    		$oTpl->parse('group_list', 'group_list_block', true);
375
    	}
376
	}
377

    
378
    /**
379
     * <!-- BEGIN show_redirect_timer_block -->
380
     */
381
    $oTpl->set_block('main_block', 'show_redirect_timer_block', 'show_redirect_timer');
382

    
383
    /**
384
     * <!-- END show_redirect_timer_block -->
385
     */
386
    if ($is_advanced) {
387
    	$oTpl->parse('show_redirect_timer', 'show_redirect_timer_block');
388
    } else {
389
    	$oTpl->parse('show_redirect_timer', '');
390
    }
391

    
392
    /**
393
     * <!-- BEGIN show_php_error_level_block -->
394
     */
395
	// Insert default error reporting values
396
	require(ADMIN_PATH.'/interface/er_levels.php');
397
    $oTpl->set_block('main_block', 'show_php_error_level_block',  'show_php_error_level');
398
    $oTpl->set_block('show_php_error_level_block', 'php_error_list_block',  'php_error_list');
399
	foreach($ER_LEVELS AS $value => $title)
400
	{
401
		$oTpl->set_var('VALUE', $value);
402
		$oTpl->set_var('NAME', $title);
403
	    $selected = (ER_LEVEL == $value) ? $sSelected : '';
404
	    $oTpl->set_var('SELECTED', $selected);
405
		$oTpl->parse('php_error_list', 'php_error_list_block', true);
406
	}
407

    
408
    /**
409
     * <!-- END show_php_error_level_block -->
410
     */
411
    if ($is_advanced) {
412
    	$oTpl->parse('show_php_error_level',  'show_php_error_level_block');
413
    } else {
414
    	$oTpl->parse('show_php_error_level', '');
415
    }
416

    
417
    /**
418
     * <!-- BEGIN show_wysiwyg_block -->
419
     */
420
//  Insert WYSIWYG modules
421
    $oTpl->set_block('main_block', 'show_wysiwyg_block',        'show_wysiwyg');
422
    $oTpl->set_block('show_wysiwyg_block', 'editor_list_block', 'editor_list');
423
	$file='none';
424
	$module_name = $oTrans->TEXT_NONE;
425
	$oTpl->set_var('FILE', $file);
426
	$oTpl->set_var('NAME', $module_name);
427
	$selected = (!defined('WYSIWYG_EDITOR') || $file == WYSIWYG_EDITOR) ? $sSelected : '';
428
	$oTpl->set_var('SELECTED', $selected);
429
	$oTpl->parse('editor_list', 'editor_list_block', true);
430
	$sql = 'SELECT `name`, `directory` FROM `'.$oDb->TablePrefix.'addons` '
431
	     . 'WHERE `type` = \'module\' AND `function` = \'wysiwyg\' '
432
	     . 'ORDER BY `name`';
433
	if (($result = $oDb->doQuery($sql))) {
434
		while ($addon = $result->fetchRow(MYSQL_ASSOC)) {
435
			if ($admin->get_permission($addon['directory'],'module' )) {
436
				$oTpl->set_var('FILE', $addon['directory']);
437
				$oTpl->set_var('NAME', $addon['name']);
438
				$selected = (!defined('WYSIWYG_EDITOR') || $addon['directory'] == WYSIWYG_EDITOR) ? $sSelected : '';
439
				$oTpl->set_var('SELECTED', $selected);
440
				$oTpl->parse('editor_list', 'editor_list_block', true);
441
			}
442
		}
443
	}
444

    
445
    /**
446
     * <!-- END show_wysiwyg_block -->
447
     */
448
    if($is_advanced)
449
    {
450
    	$oTpl->parse('show_wysiwyg','show_wysiwyg_block');
451
    } else {
452
    	$oTpl->parse('show_wysiwyg', '');
453
    }
454

    
455
//  Insert language values
456
    $oTpl->set_block('main_block', 'language_list_block', 'language_list');
457
	$sql = 'SELECT `name`, `directory` FROM `'.$oDb->TablePrefix.'addons` '
458
	     . 'WHERE `type` = \'language\' AND `function` != \'theme\' '
459
	     . 'ORDER BY `directory`';
460
	if (($result = $oDb->doQuery($sql))) {
461
		while($addon = $result->fetchRow(MYSQL_ASSOC)) {
462
	        $langIcons = (empty($addon['directory'])) ? 'none' : strtolower($addon['directory']);
463
			$oTpl->set_var('CODE',        $addon['directory']);
464
			$oTpl->set_var('NAME',        $addon['name']);
465
			$oTpl->set_var('FLAG',        THEME_URL.'/images/flags/'.$langIcons);
466
			$oTpl->set_var('SELECTED',    (DEFAULT_LANGUAGE == $addon['directory'] ? $sSelected : '') );
467
			$oTpl->parse('language_list', 'language_list_block', true);
468
		}
469
	}
470
    /**
471
     * <!-- BEGIN show_charset_block -->
472
     */
473
//  Insert default charset values
474
    $oTpl->set_block('main_block', 'show_charset_block', 'show_charset');
475
	require(ADMIN_PATH.'/interface/charsets.php');
476
    $oTpl->set_block('show_charset_block', 'charset_list_block', 'charset_list');
477
	foreach ($CHARSETS AS $code => $title) {
478
		$oTpl->set_var('VALUE', $code);
479
		$oTpl->set_var('NAME', $title);
480
		if(DEFAULT_CHARSET == $code) {
481
			$oTpl->set_var('SELECTED', $sSelected);
482
		} else {
483
			$oTpl->set_var('SELECTED', '');
484
		}
485
		$oTpl->parse('charset_list', 'charset_list_block', true);
486
	}
487
    /**
488
     * <!-- END show_charset_block -->
489
     */
490
    if ($is_advanced) {
491
    	$oTpl->parse('show_charset', 'show_charset_block');
492
    } else {
493
    	$oTpl->parse('show_charset', '');
494
    }
495

    
496
//  insert default timezone values
497
	require(ADMIN_PATH.'/interface/timezones.php');
498
    $oTpl->set_block('main_block', 'timezone_list_block','timezone_list');
499
	foreach ($TIMEZONES AS $hour_offset => $title) {
500
//  Make sure we dont list "System Default" as we are setting this value!
501
		if($hour_offset != '-20') {
502
			$oTpl->set_var('VALUE', $hour_offset);
503
			$oTpl->set_var('NAME', $title);
504
			if(DEFAULT_TIMEZONE == $hour_offset*60*60) {
505
				$oTpl->set_var('SELECTED', $sSelected);
506
			} else {
507
				$oTpl->set_var('SELECTED', '');
508
			}
509
			$oTpl->parse('timezone_list', 'timezone_list_block', true);
510
		}
511
	}
512

    
513
//  Insert date format list
514
	require(ADMIN_PATH.'/interface/date_formats.php');
515
    $oTpl->set_block('main_block', 'date_format_list_block', 'date_format_list');
516
	foreach ($DATE_FORMATS AS $format => $title) {
517
		$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
518
		if($format != 'system_default') {
519
			$oTpl->set_var('VALUE', $format);
520
		} else {
521
			$oTpl->set_var('VALUE', '');
522
		}
523
		$oTpl->set_var('NAME', $title);
524
		if(DEFAULT_DATE_FORMAT == $format) {
525
			$oTpl->set_var('SELECTED', $sSelected);
526
		} else {
527
			$oTpl->set_var('SELECTED', '');
528
		}
529
		$oTpl->parse('date_format_list', 'date_format_list_block', true);
530
	}
531

    
532
//  Insert time format list
533
	require(ADMIN_PATH.'/interface/time_formats.php');
534
    $oTpl->set_block('main_block', 'time_format_list_block', 'time_format_list');
535
	foreach($TIME_FORMATS AS $format => $title) {
536
		$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
537
		if($format != 'system_default') {
538
			$oTpl->set_var('VALUE', $format);
539
		} else {
540
			$oTpl->set_var('VALUE', '');
541
		}
542
		$oTpl->set_var('NAME', $title);
543
		if(DEFAULT_TIME_FORMAT == $format) {
544
			$oTpl->set_var('SELECTED', $sSelected);
545
		} else {
546
			$oTpl->set_var('SELECTED', '');
547
		}
548
		$oTpl->parse('time_format_list', 'time_format_list_block', true);
549
	}
550

    
551
// Insert templates
552
    $oTpl->set_block('main_block', 'template_list_block', 'template_list');
553
	$sql = 'SELECT `name`, `directory` FROM `'.$oDb->TablePrefix.'addons` '
554
	     . 'WHERE `type` = \'template\' AND `function` != \'theme\' '
555
	     . 'ORDER BY `name`';
556
	if (($result = $database->query($sql))) {
557
		while ($addon = $result->fetchRow(MYSQL_ASSOC)) {
558
			if ($admin->get_permission($addon['directory'],'template' )) {
559
				$oTpl->set_var('FILE', $addon['directory']);
560
				$oTpl->set_var('NAME', $addon['name']);
561
				$selected = (($addon['directory'] == DEFAULT_TEMPLATE) ? $sSelected : '');
562
				$oTpl->set_var('SELECTED', $selected);
563
				$oTpl->parse('template_list', 'template_list_block', true);
564
			}
565
		}
566
	}
567

    
568
// Insert backend theme
569
    $oTpl->set_block('main_block', 'theme_list_block', 'theme_list');
570
	$sql = 'SELECT `name`, `directory` FROM `'.$oDb->TablePrefix.'addons` '
571
	     . 'WHERE `type` = \'template\' AND `function` = \'theme\' '
572
	     . 'ORDER BY `name`';
573
	if (($result = $database->query($sql))) {
574
		while ($addon = $result->fetchRow(MYSQL_ASSOC)) {
575
			if ($admin->get_permission($addon['directory'],'template' )) {
576
				$oTpl->set_var('FILE', $addon['directory']);
577
				$oTpl->set_var('NAME', $addon['name']);
578
				$selected = (($addon['directory'] == DEFAULT_THEME) ? $sSelected : '');
579
				$oTpl->set_var('SELECTED', $selected);
580
				$oTpl->parse('theme_list', 'theme_list_block', true);
581
			}
582
		}
583
	}
584

    
585
//  Work-out if warn_page_leave feature is enabled
586
//	if (defined('WARN_PAGE_LEAVE') && WARN_PAGE_LEAVE == true)
587
//	{
588
//    	$oTpl->set_var(array(
589
//				'WARN_PAGE_LEAVE_ENABLED' => $checked,
590
//				'WARN_PAGE_LEAVE_DISABLED' => '',
591
//				));
592
//	} else {
593
//    	$oTpl->set_var(array(
594
//				'MANAGE_SECTIONS_DISABLED' => $checked,
595
//				'WARN_PAGE_LEAVE_DISABLED' => '',
596
//				));
597
//	}
598

    
599
/*  Make's sure GD library is installed */
600
//	if(extension_loaded('gd') && function_exists('imageCreateFromJpeg'))
601
//	{
602
//		$oTpl->set_var('GD_EXTENSION_ENABLED', '');
603
//	} else {
604
//		$oTpl->set_var('GD_EXTENSION_ENABLED', ' style="display: none;"');
605
//	}
606

    
607
//  Insert permissions values
608
//	if($admin->get_permission('settings_advanced') != true)
609
//	{
610
//		$oTpl->set_var('DISPLAY_ADVANCED_BUTTON', 'hide');
611
//	}
612

    
613
/**
614
 *
615
 *
616
 */
617
    $oTpl->set_block('main_block', 'show_search_block','show_search');
618
	$sql = 'SELECT * FROM `'.$oDb->TablePrefix.'search` WHERE `extra` = \'\'';
619
	if (($results = $oDb->doQuery($sql))) {
620
    	// Query current settings in the db, then loop through them and print them
621
    	while ($setting = $results->fetchRow(MYSQL_ASSOC)) {
622
    		$setting_name = $setting['name'];
623
    		$setting_value = htmlspecialchars(($setting['value']));
624
    		switch($setting_name) {
625
    			// Search header
626
    			case 'header':
627
    				$oTpl->set_var('SEARCH_HEADER', $setting_value);
628
    			break;
629
    			// Search results header
630
    			case 'results_header':
631
    				$oTpl->set_var('SEARCH_RESULTS_HEADER', $setting_value);
632
    			break;
633
    			// Search results loop
634
    			case 'results_loop':
635
    				$oTpl->set_var('SEARCH_RESULTS_LOOP', $setting_value);
636
    			break;
637
    			// Search results footer
638
    			case 'results_footer':
639
    				$oTpl->set_var('SEARCH_RESULTS_FOOTER', $setting_value);
640
    			break;
641
    			// Search no results
642
    			case 'no_results':
643
    				$oTpl->set_var('SEARCH_NO_RESULTS', $setting_value);
644
    			break;
645
    			// Search footer
646
    			case 'footer':
647
    				$oTpl->set_var('SEARCH_FOOTER', $setting_value);
648
    			break;
649
    			// Search module-order
650
    			case 'module_order':
651
    				$oTpl->set_var('SEARCH_MODULE_ORDER', $setting_value);
652
    			break;
653
    			// Search max lines of excerpt
654
    			case 'max_excerpt':
655
    				$oTpl->set_var('SEARCH_MAX_EXCERPT', $setting_value);
656
    			break;
657
    			// time-limit
658
    			case 'time_limit':
659
    				$oTpl->set_var('SEARCH_TIME_LIMIT', $setting_value);
660
    			break;
661
    			// Search template
662
    			case 'template':
663
    				$search_template = $setting_value;
664
    			break;
665
    		}
666
    	}
667
	}
668

    
669
// Insert templates for search settings
670
    $oTpl->set_block('main_block', 'search_template_list_block', 'search_template_list');
671
	$search_template = ( ($search_template == DEFAULT_TEMPLATE) || ($search_template == '') ) ? '' : $search_template;
672
	$selected = ( ($search_template != DEFAULT_TEMPLATE) ) ?  $sSelected : '';
673

    
674
	$oTpl->set_var(array(
675
        'FILE'              => '',
676
        'TEXT_MODULE_ORDER' => $oTrans->TEXT_MODULE_ORDER,
677
        'NAME'              => $oTrans->TEXT_SYSTEM_DEFAULT,
678
        'SELECTED'          => $selected
679
    ));
680
	$oTpl->parse('search_template_list', 'search_template_list_block', true);
681
	$sql = 'SELECT `name`, `directory` FROM `'.$oDb->TablePrefix.'addons` '
682
	     . 'WHERE `type` = \'template\' AND `function` = \'template\' '
683
	     . 'ORDER BY `name`';
684
    if (($result = $oDb->doQuery($sql))) {
685
		while ($addon = $result->fetchRow(MYSQL_ASSOC)) {
686
			if ($admin->get_permission($addon['directory'],'template' )) {
687
				$oTpl->set_var('FILE', $addon['directory']);
688
				$oTpl->set_var('NAME', $addon['name']);
689
		        $selected = ($addon['directory'] == $search_template) ? $sSelected :  '';
690
				$oTpl->set_var('SELECTED', $selected);
691
				$oTpl->parse('search_template_list', 'search_template_list_block', true);
692
			}
693
		}
694
	}
695

    
696
	// Insert search select
697
//    $oTpl->set_var(array(
698
//		'TEXT_REGISTERED' => $oTrans->TEXT_REGISTERED'],
699
//		'TEXT_PUBLIC' => $oTrans->TEXT_PUBLIC,
700
//		'TEXT_PRIVATE' => $oTrans->TEXT_PRIVATE'],
701
//		'TEXT_NONE' => $oTrans->TEXT_NONE'],
702
//		'TEXT_MAX_EXCERPT' => $oTrans->TEXT_MAX_EXCERPT'],
703
//		'TEXT_TIME_LIMIT' => $oTrans->TEXT_TIME_LIMIT'],
704
//		'TEXT_VISIBILITY' => $oTrans->TEXT_VISIBILITY'],
705
//		'TEXT_SEARCH' => $oTrans->TEXT_SEARCH'],
706
//		));
707
	if(SEARCH == 'private')
708
	{
709
    	$oTpl->set_var(array(
710
				'PRIVATE_SEARCH' => $sSelected,
711
				'REGISTERED_SEARCH' => '',
712
				'NONE_SEARCH' => '',
713
				));
714
	} elseif(SEARCH == 'public') {
715
    	$oTpl->set_var(array(
716
				'PRIVATE_SEARCH' => '',
717
				'REGISTERED_SEARCH' => '',
718
				'NONE_SEARCH' => '',
719
				));
720
	} elseif(SEARCH == 'registered') {
721
    	$oTpl->set_var(array(
722
				'PRIVATE_SEARCH' => '',
723
				'REGISTERED_SEARCH' => $sSelected,
724
				'NONE_SEARCH' => '',
725
				));
726
	} elseif(SEARCH == 'none') {
727
    	$oTpl->set_var(array(
728
				'PRIVATE_SEARCH' => '',
729
				'REGISTERED_SEARCH' => '',
730
				'NONE_SEARCH' => $sSelected,
731
				));
732
	}
733

    
734
    if ($is_advanced) {
735
        $oTpl->parse('show_search', 'show_search_block');
736
    } else {
737
        $oTpl->parse('show_search', '');
738
    }
739

    
740
    $oTpl->set_block('main_block', 'show_access_block','show_access');
741
//  Work-out which wbmailer routine should be checked
742
	$oTpl->set_var(array(
743
		'TEXT_WBMAILER_SMTP_AUTH_NOTICE'        => $oTrans->TEXT_REQUIRED.' '.$oTrans->TEXT_WBMAILER_SMTP_AUTH,
744
		'SMTP_AUTH_SELECTED'                    => $checked,
745
		'TEXT_WBMAILER_DEFAULT_SETTINGS_NOTICE' => $oTrans->TEXT_WBMAILER_DEFAULT_SETTINGS_NOTICE,
746
		'TEXT_WBMAILER_DEFAULT_SENDER_MAIL'     => $oTrans->TEXT_WBMAILER_DEFAULT_SENDER_MAIL,
747
		'TEXT_WBMAILER_DEFAULT_SENDER_NAME'     => $oTrans->TEXT_WBMAILER_DEFAULT_SENDER_NAME,
748
		'TEXT_WBMAILER_NOTICE'                  => $oTrans->TEXT_WBMAILER_NOTICE,
749
		'TEXT_WBMAILER_FUNCTION'                => $oTrans->TEXT_WBMAILER_FUNCTION,
750
		'TEXT_WBMAILER_SMTP_HOST'               => $oTrans->TEXT_WBMAILER_SMTP_HOST,
751
		'TEXT_WBMAILER_PHP'                     => $oTrans->TEXT_WBMAILER_PHP,
752
		'TEXT_WBMAILER_SMTP'                    => $oTrans->TEXT_WBMAILER_SMTP,
753
		'TEXT_WBMAILER_SMTP_AUTH'               => $oTrans->TEXT_WBMAILER_SMTP_AUTH,
754
		'TEXT_WBMAILER_SMTP_USERNAME'           => $oTrans->TEXT_WBMAILER_SMTP_USERNAME,
755
		'TEXT_WBMAILER_SMTP_PASSWORD'           => $oTrans->TEXT_WBMAILER_SMTP_PASSWORD,
756
	));
757

    
758
	// Work-out if developer infos feature is enabled
759
	if (defined('DEV_INFOS') && DEV_INFOS == true) {
760
    	$oTpl->set_var(array(
761
				'DEV_INFOS_ENABLED' => $checked,
762
				'DEV_INFOS_DISABLED' => '',
763
				));
764
	} else {
765
    	$oTpl->set_var(array(
766
				'DEV_INFOS_DISABLED' => $checked,
767
				'DEV_INFOS_ENABLED' => '',
768
				));
769
	}
770

    
771
//  Work-out which server os should be checked
772
	if(OPERATING_SYSTEM == 'linux')
773
	{
774
		$oTpl->set_var('LINUX_SELECTED', $checked);
775
		$oTpl->set_var('WINDOWS_SELECTED', '');
776
	} elseif(OPERATING_SYSTEM == 'windows') {
777
		$oTpl->set_var('WINDOWS_SELECTED', $checked);
778
		$oTpl->set_var('LINUX_SELECTED', '');
779
	}
780

    
781
	if(WBMAILER_ROUTINE == 'phpmail')
782
	{
783
		$oTpl->set_var('PHPMAIL_SELECTED', $checked);
784
		$oTpl->set_var('SMTP_VISIBILITY', ' style="display: none;"');
785
//		$oTpl->set_var('SMTP_VISIBILITY_AUTH', '');
786
		$oTpl->set_var('SMTP_AUTH_SELECTED', '');
787
		$oTpl->set_var('SMTPMAIL_SELECTED',  '');
788
	} elseif(WBMAILER_ROUTINE == 'smtp')
789
	{
790
		$oTpl->set_var('SMTPMAIL_SELECTED', $checked);
791
		$oTpl->set_var('PHPMAIL_SELECTED', '');
792
		$oTpl->set_var('SMTP_VISIBILITY', '');
793
//		$oTpl->set_var('SMTP_VISIBILITY_AUTH', '');
794
	}
795
/* deprecated
796
	// Work-out if SMTP authentification should be checked
797
	if(WBMAILER_SMTP_AUTH)
798
	{
799
		$oTpl->set_var('SMTP_AUTH_SELECTED', $checked);
800
		if(WBMAILER_ROUTINE == 'smtp')
801
	    {
802
			$oTpl->set_var('SMTP_VISIBILITY_AUTH', '');
803

    
804
		} else {
805
			$oTpl->set_var('SMTP_VISIBILITY_AUTH', ' style="display: none;"');
806
		}
807
	} else {
808
		$oTpl->set_var('SMTP_VISIBILITY_AUTH', ' style="display: none;"');
809
	}
810
*/
811

    
812
	// Work-out if 777 permissions are set
813
	$oTpl->set_var('WORLD_WRITEABLE_SELECTED', '');
814
	if(STRING_FILE_MODE == '0777' AND STRING_DIR_MODE == '0777')
815
	{
816
		$oTpl->set_var('WORLD_WRITEABLE_SELECTED', $checked);
817
	}
818

    
819

    
820
	$oTpl->set_var(array(
821
		'FILE_U_R_CHECKED' => '',
822
		'FILE_U_W_CHECKED' => '',
823
		'FILE_U_E_CHECKED' => '',
824
		'FILE_G_R_CHECKED' => '',
825
		'FILE_G_W_CHECKED' => '',
826
		'FILE_G_E_CHECKED' => '',
827
		'FILE_O_R_CHECKED' => '',
828
		'FILE_O_W_CHECKED' => '',
829
		'FILE_O_E_CHECKED' => '',
830
		'DIR_U_R_CHECKED' => '',
831
		'DIR_U_W_CHECKED' => '',
832
		'DIR_U_E_CHECKED' => '',
833
		'DIR_G_R_CHECKED' => '',
834
		'DIR_G_W_CHECKED' => '',
835
		'DIR_G_E_CHECKED' => '',
836
		'DIR_O_R_CHECKED' => '',
837
		'DIR_O_W_CHECKED' => '',
838
		'DIR_O_E_CHECKED' => '',
839
		));
840

    
841
//  Work-out which file mode boxes are checked
842
	if(extract_permission(STRING_FILE_MODE, 'u', 'r'))
843
	{
844
		$oTpl->set_var('FILE_U_R_CHECKED', $checked);
845
	}
846
	if(extract_permission(STRING_FILE_MODE, 'u', 'w'))
847
	{
848
		$oTpl->set_var('FILE_U_W_CHECKED', $checked);
849
	}
850
	if(extract_permission(STRING_FILE_MODE, 'u', 'e'))
851
	{
852
		$oTpl->set_var('FILE_U_E_CHECKED', $checked);
853
	}
854
	if(extract_permission(STRING_FILE_MODE, 'g', 'r'))
855
	{
856
		$oTpl->set_var('FILE_G_R_CHECKED', $checked);
857
	}
858
	if(extract_permission(STRING_FILE_MODE, 'g', 'w'))
859
	{
860
		$oTpl->set_var('FILE_G_W_CHECKED', $checked);
861
	}
862
	if(extract_permission(STRING_FILE_MODE, 'g', 'e'))
863
	{
864
		$oTpl->set_var('FILE_G_E_CHECKED', $checked);
865
	}
866
	if(extract_permission(STRING_FILE_MODE, 'o', 'r'))
867
	{
868
		$oTpl->set_var('FILE_O_R_CHECKED', $checked);
869
	}
870
	if(extract_permission(STRING_FILE_MODE, 'o', 'w'))
871
	{
872
		$oTpl->set_var('FILE_O_W_CHECKED', $checked);
873
	}
874
	if(extract_permission(STRING_FILE_MODE, 'o', 'e'))
875
	{
876
		$oTpl->set_var('FILE_O_E_CHECKED', $checked);
877
	}
878
	// Work-out which dir mode boxes are checked
879
	if(extract_permission(STRING_DIR_MODE, 'u', 'r'))
880
	{
881
		$oTpl->set_var('DIR_U_R_CHECKED', $checked);
882
	}
883
	if(extract_permission(STRING_DIR_MODE, 'u', 'w'))
884
	{
885
		$oTpl->set_var('DIR_U_W_CHECKED', $checked);
886
	}
887
	if(extract_permission(STRING_DIR_MODE, 'u', 'e'))
888
	{
889
		$oTpl->set_var('DIR_U_E_CHECKED', $checked);
890
	}
891
	if(extract_permission(STRING_DIR_MODE, 'g', 'r'))
892
	{
893
		$oTpl->set_var('DIR_G_R_CHECKED', $checked);
894
	}
895
	if(extract_permission(STRING_DIR_MODE, 'g', 'w'))
896
	{
897
		$oTpl->set_var('DIR_G_W_CHECKED', $checked);
898
	}
899
	if(extract_permission(STRING_DIR_MODE, 'g', 'e'))
900
	{
901
		$oTpl->set_var('DIR_G_E_CHECKED', $checked);
902
	}
903
	if(extract_permission(STRING_DIR_MODE, 'o', 'r'))
904
	{
905
		$oTpl->set_var('DIR_O_R_CHECKED', $checked);
906
	}
907
	if(extract_permission(STRING_DIR_MODE, 'o', 'w'))
908
	{
909
		$oTpl->set_var('DIR_O_W_CHECKED', $checked);
910
	}
911
	if(extract_permission(STRING_DIR_MODE, 'o', 'e'))
912
	{
913
		$oTpl->set_var('DIR_O_E_CHECKED', $checked);
914
	}
915
	$sReadOnly = '';
916
	$sPagesEditType = 'text';
917
    $sql = 'SELECT COUNT(*) FROM `'.$oDb->TablePrefix.'pages`';
918
	if ($oDb->getOne($sql)) {
919
		$sReadOnly = ' readonly="readonly"';
920
		$sPagesEditType = 'grey bold';
921
	}
922

    
923
	$oTpl->set_var(array(
924
		'PAGES_DIRECTORY' => PAGES_DIRECTORY,
925
		'PAGES_READONLY' => $sReadOnly,
926
		'PAGES_EDIT_TYPE' => $sPagesEditType,
927
		'PAGE_ICON_DIR'   => PAGE_ICON_DIR,
928
		'MEDIA_DIRECTORY' => MEDIA_DIRECTORY,
929
		'PAGE_EXTENSION' => PAGE_EXTENSION,
930
		'PAGE_SPACER' => PAGE_SPACER,
931
		'TABLE_PREFIX' => TABLE_PREFIX
932
	 ));
933

    
934
	// Insert Server Email value into template
935
	$oTpl->set_var('SERVER_EMAIL', SERVER_EMAIL);
936

    
937
// Insert language text and messages
938
	$oTpl->set_var(array(
939
		'TEXT_CHANGES' => $oTrans->TEXT_CHANGES,
940
		'TEXT_FILES' => strtoupper(substr($oTrans->TEXT_FILES, 0, 1)).substr($oTrans->TEXT_FILES, 1),
941
		'TEXT_WARN_PAGE_LEAVE' => '',
942
		'TEXT_WORLD_WRITEABLE_FILE_PERMISSIONS' => $oTrans->TEXT_WORLD_WRITEABLE_FILE_PERMISSIONS,
943
		'MODE_SWITCH_WARNING' => $oTrans->MESSAGE_SETTINGS_MODE_SWITCH_WARNING,
944
		'WORLD_WRITEABLE_WARNING' => $oTrans->MESSAGE_SETTINGS_WORLD_WRITEABLE_WARNING
945
		));
946

    
947
    if ($is_advanced && $admin->get_user_id()=='1') {
948
        $oTpl->parse('show_access', 'show_access_block');
949
    }else {
950
        $oTpl->parse('show_access' , '');
951
    }
952

    
953
    // Parse template objects output
954
    $oTpl->parse('main', 'main_block',false);
955
    $oTpl->pparse('output', 'page');
956
    //$oTpl->p('page');
957
    unset($oTpl);
958
    $admin->print_footer();
(1-1/4)