1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category admin
|
5
|
* @package media
|
6
|
* @author Ryan Djurovich, WebsiteBaker Project
|
7
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
8
|
* @link http://www.websitebaker2.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: setparameter.php 1529 2011-11-25 05:03:32Z Luisehahne $
|
13
|
* @filesource $HeadURL: $
|
14
|
* @lastmodified $Date: $
|
15
|
*
|
16
|
*/
|
17
|
|
18
|
require('../../config.php');
|
19
|
require_once(WB_PATH.'/framework/class.admin.php');
|
20
|
$admin = new admin('Media', 'media', false);
|
21
|
// Include the WB functions file
|
22
|
require_once(WB_PATH.'/framework/functions.php');
|
23
|
|
24
|
// check if theme language file exists for the language set by the user (e.g. DE, EN)
|
25
|
if(!file_exists(THEME_PATH .'/languages/'.LANGUAGE .'.php')) {
|
26
|
// no theme language file exists for the language set by the user, include default theme language file EN.php
|
27
|
require_once(THEME_PATH .'/languages/EN.php');
|
28
|
} else {
|
29
|
// a theme language file exists for the language defined by the user, load it
|
30
|
require_once(THEME_PATH .'/languages/'.LANGUAGE .'.php');
|
31
|
}
|
32
|
|
33
|
//Save post vars to the parameters file
|
34
|
if ( !is_null($admin->get_post_escaped("save"))) {
|
35
|
/*
|
36
|
if (!$admin->checkFTAN())
|
37
|
{
|
38
|
$admin->print_error('::'.$MESSAGE['GENERIC_SECURITY_ACCESS'],'browse.php',false);
|
39
|
}
|
40
|
*/
|
41
|
|
42
|
if(DEFAULT_THEME != ' wb_theme') {
|
43
|
//Check for existing settings entry, if not existing, create a record first!
|
44
|
if (!$database->query ( "SELECT * FROM ".TABLE_PREFIX."settings where `name`='mediasettings'" )) {
|
45
|
$database->query ( "INSERT INTO ".TABLE_PREFIX."settings (`name`,`value`) VALUES ('mediasettings','')" );
|
46
|
}
|
47
|
} else {
|
48
|
$pathsettings = array();
|
49
|
}
|
50
|
|
51
|
$dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
|
52
|
$dirs[] = WB_PATH.MEDIA_DIRECTORY;
|
53
|
foreach($dirs AS $name) {
|
54
|
$r = str_replace(WB_PATH, '', $name);
|
55
|
$r = str_replace(array('/',' '),'_',$r);
|
56
|
$w = (int)$admin->get_post_escaped($r.'-w');
|
57
|
$h = (int)$admin->get_post_escaped($r.'-h');
|
58
|
$pathsettings[$r]['width']=$w;
|
59
|
$pathsettings[$r]['height']=$h;
|
60
|
}
|
61
|
$pathsettings['global']['admin_only'] = ($admin->get_post_escaped('admin_only')!=''?'checked':'');
|
62
|
$pathsettings['global']['show_thumbs'] = ($admin->get_post_escaped('show_thumbs')!=''?'checked':'');
|
63
|
$fieldSerialized = serialize($pathsettings);
|
64
|
$database->query ( "UPDATE ".TABLE_PREFIX."settings SET `value` = '$fieldSerialized' WHERE `name`='mediasettings'" );
|
65
|
header ("Location: browse.php");
|
66
|
}
|
67
|
|
68
|
include ('parameters.php');
|
69
|
if ($_SESSION['GROUP_ID'] != 1 && $pathsettings['global']['admin_only']) {
|
70
|
echo "Sorry, settings not available";
|
71
|
exit();
|
72
|
}
|
73
|
|
74
|
// Read data to display
|
75
|
$caller = "setparameter";
|
76
|
|
77
|
// Setup template object, parse vars to it, then parse it
|
78
|
$ThemePath = realpath(WB_PATH.$admin->correct_theme_source('setparameter.htt'));
|
79
|
// Create new template object
|
80
|
$template = new Template($ThemePath);
|
81
|
$template->set_file('page', 'setparameter.htt');
|
82
|
$template->set_block('page', 'main_block', 'main');
|
83
|
if ($_SESSION['GROUP_ID'] != 1) {
|
84
|
$template->set_var('DISPLAY_ADMIN', 'hide');
|
85
|
}
|
86
|
$template->set_var(array(
|
87
|
'TEXT_HEADER' => $TEXT['TEXT_HEADER'],
|
88
|
'SAVE_TEXT' => $TEXT['SAVE'],
|
89
|
'BACK' => $TEXT['BACK'],
|
90
|
)
|
91
|
);
|
92
|
|
93
|
$template->set_block('main_block', 'list_block', 'list');
|
94
|
$row_bg_color = '';
|
95
|
$dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
|
96
|
$dirs[] = WB_PATH.MEDIA_DIRECTORY;
|
97
|
|
98
|
$array_lowercase = array_map('strtolower', $dirs);
|
99
|
array_multisort($array_lowercase, SORT_ASC, SORT_STRING, $dirs);
|
100
|
|
101
|
foreach($dirs AS $name) {
|
102
|
$relative = str_replace(WB_PATH, '', $name);
|
103
|
$safepath = str_replace(array('/',' '),'_',$relative);
|
104
|
$cur_width = $cur_height = '';
|
105
|
if (isset($pathsettings[$safepath]['width'])) $cur_width = $pathsettings[$safepath]['width'];
|
106
|
if (isset($pathsettings[$safepath]['height'])) $cur_height = $pathsettings[$safepath]['height'];
|
107
|
$cur_width = ($cur_width ? (int)$cur_width : '-');
|
108
|
$cur_height = ($cur_height ? (int)$cur_height : '-');
|
109
|
|
110
|
if($row_bg_color == 'DEDEDE') $row_bg_color = 'EEEEEE';
|
111
|
else $row_bg_color = 'DEDEDE';
|
112
|
|
113
|
$template->set_var(array(
|
114
|
'ADMIN_URL' => ADMIN_URL,
|
115
|
'PATH_NAME' => $relative,
|
116
|
'WIDTH' => $TEXT['WIDTH'],
|
117
|
'HEIGHT' => $TEXT['HEIGHT'],
|
118
|
'FIELD_NAME_W' => $safepath.'-w',
|
119
|
'FIELD_NAME_H' => $safepath.'-h',
|
120
|
'CUR_WIDTH' => $cur_width,
|
121
|
'CUR_HEIGHT' => $cur_height,
|
122
|
'SETTINGS' => $TEXT['SETTINGS'],
|
123
|
'ADMIN_ONLY' => $TEXT['ADMIN_ONLY'],
|
124
|
'ADMIN_ONLY_SELECTED' => $pathsettings['global']['admin_only'],
|
125
|
'NO_SHOW_THUMBS' => $TEXT['NO_SHOW_THUMBS'],
|
126
|
'NO_SHOW_THUMBS_SELECTED' => $pathsettings['global']['show_thumbs'],
|
127
|
'ROW_BG_COLOR' => $row_bg_color,
|
128
|
'FTAN' => $admin->getFTAN()
|
129
|
)
|
130
|
);
|
131
|
$template->parse('list', 'list_block', true);
|
132
|
}
|
133
|
|
134
|
$template->parse('main', 'main_block', false);
|
135
|
$template->pparse('output', 'page');
|