Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         admintools
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 5.2.2 and higher
13
 * @version         $Id: setparameter.php 1457 2011-06-25 17:18:50Z Luisehahne $
14
 * @filesource		$HeadURL:  $
15
 * @lastmodified    $Date:  $
16
 *
17
 */
18

    
19
require('../../config.php');
20
require_once(WB_PATH.'/framework/class.admin.php');
21
$admin = new admin('Media', 'media', false);
22
// Include the WB functions file
23
require_once(WB_PATH.'/framework/functions.php');
24

    
25
// check if theme language file exists for the language set by the user (e.g. DE, EN)
26
if(!file_exists(THEME_PATH .'/languages/'.LANGUAGE .'.php')) {
27
	// no theme language file exists for the language set by the user, include default theme language file EN.php
28
	require_once(THEME_PATH .'/languages/EN.php');
29
} else {
30
	// a theme language file exists for the language defined by the user, load it
31
	require_once(THEME_PATH .'/languages/'.LANGUAGE .'.php');
32
}
33

    
34
//Save post vars to the parameters file
35
if ( !is_null($admin->get_post_escaped("save"))) {
36
/*
37
	if (!$admin->checkFTAN())
38
	{
39
		$admin->print_error('::'.$MESSAGE['GENERIC_SECURITY_ACCESS'],'browse.php',false);
40
	}
41
*/
42
	//Check for existing settings entry, if not existing, create a record first!
43
	if (!$database->query ( "SELECT * FROM ".TABLE_PREFIX."settings where `name`='mediasettings'" )) {
44
		$database->query ( "INSERT INTO ".TABLE_PREFIX."settings (`name`,`value`) VALUES ('mediasettings','')" );
45
	}
46
	$dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
47
	$dirs[] = WB_PATH.MEDIA_DIRECTORY;
48
	foreach($dirs AS $name) {
49
		$r = str_replace(WB_PATH, '', $name);
50
		$r = str_replace(array('/',' '),'_',$r);
51
		$w = (int)$admin->get_post_escaped($r.'-w');
52
		$h = (int)$admin->get_post_escaped($r.'-h');
53
		$pathsettings[$r]['width']=$w; 
54
		$pathsettings[$r]['height']=$h;
55
	}
56
	$pathsettings['global']['admin_only'] = ($admin->get_post_escaped('admin_only')!=''?'checked':'');
57
	$pathsettings['global']['show_thumbs'] = ($admin->get_post_escaped('show_thumbs')!=''?'checked':'');
58
	$fieldSerialized = serialize($pathsettings);
59
	$database->query ( "UPDATE ".TABLE_PREFIX."settings SET `value` = '$fieldSerialized' WHERE `name`='mediasettings'" );
60
	header ("Location: browse.php");
61
}
62

    
63
include ('parameters.php');
64
if ($_SESSION['GROUP_ID'] != 1 && $pathsettings['global']['admin_only']) {
65
	echo "Sorry, settings not available";
66
	exit();
67
}
68

    
69
// Read data to display
70
$caller = "setparameter";
71

    
72
$template = new Template(THEME_PATH.'/templates');
73
$template->set_file('page', 'setparameter.htt');
74
$template->set_block('page', 'main_block', 'main');
75
if ($_SESSION['GROUP_ID'] != 1) {
76
	$template->set_var('DISPLAY_ADMIN', 'hide');
77
}
78
$template->set_var(array( 
79
				'TEXT_HEADER' => $TEXT['TEXT_HEADER'],
80
				'SAVE_TEXT' => $TEXT['SAVE'],
81
				'BACK' => $TEXT['BACK'],
82
			)
83
		);
84

    
85
$template->set_block('main_block', 'list_block', 'list');
86
$row_bg_color = '';
87
$dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
88
$dirs[] = WB_PATH.MEDIA_DIRECTORY;
89

    
90
$array_lowercase = array_map('strtolower', $dirs);
91
array_multisort($array_lowercase, SORT_ASC, SORT_STRING, $dirs);
92

    
93
foreach($dirs AS $name) {
94
	$relative = str_replace(WB_PATH, '', $name);
95
	$safepath = str_replace(array('/',' '),'_',$relative);
96
	$cur_width = $cur_height = '';
97
	if (isset($pathsettings[$safepath]['width'])) $cur_width = $pathsettings[$safepath]['width'];
98
	if (isset($pathsettings[$safepath]['height'])) $cur_height = $pathsettings[$safepath]['height'];
99
	$cur_width = ($cur_width ? (int)$cur_width : '-');
100
	$cur_height = ($cur_height ? (int)$cur_height : '-');
101

    
102
	if($row_bg_color == 'DEDEDE') $row_bg_color = 'EEEEEE';
103
	else $row_bg_color = 'DEDEDE';
104

    
105
	$template->set_var(array( 
106
					'ADMIN_URL' => ADMIN_URL,
107
					'PATH_NAME' => $relative,
108
					'WIDTH' => $TEXT['WIDTH'],
109
					'HEIGHT' => $TEXT['HEIGHT'],
110
					'FIELD_NAME_W' => $safepath.'-w',
111
					'FIELD_NAME_H' => $safepath.'-h',
112
					'CUR_WIDTH' => $cur_width,
113
					'CUR_HEIGHT' => $cur_height,
114
					'SETTINGS' => $TEXT['SETTINGS'],
115
					'ADMIN_ONLY' => $TEXT['ADMIN_ONLY'],
116
					'ADMIN_ONLY_SELECTED' => $pathsettings['global']['admin_only'],
117
					'NO_SHOW_THUMBS' => $TEXT['NO_SHOW_THUMBS'],
118
					'NO_SHOW_THUMBS_SELECTED' => $pathsettings['global']['show_thumbs'],
119
					'ROW_BG_COLOR' => $row_bg_color,
120
					'FTAN' => $admin->getFTAN()
121
				)
122
		);
123
	$template->parse('list', 'list_block', true);
124
}
125

    
126
$template->parse('main', 'main_block', false);
127
$template->pparse('output', 'page');
(14-14/16)