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