Project

General

Profile

1 1425 Luisehahne
<?php
2
/**
3
 *
4
 * @category        admin
5 1476 Luisehahne
 * @package         media
6 1818 Luisehahne
 * @author          Ryan Djurovich (2004-2009), WebsiteBaker Project
7
 * @copyright       2009-2012, WebsiteBaker Org. e.V.
8 1425 Luisehahne
 * @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$
13 1818 Luisehahne
 * @filesource		$HeadURL$
14
 * @lastmodified    $Date$
15 1425 Luisehahne
 *
16
 */
17
18 1818 Luisehahne
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 1425 Luisehahne
$admin = new admin('Media', 'media', false);
29
// Include the WB functions file
30
require_once(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 1818 Luisehahne
// 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 1425 Luisehahne
45
//Save post vars to the parameters file
46
if ( !is_null($admin->get_post_escaped("save"))) {
47 1457 Luisehahne
/*
48 1425 Luisehahne
	if (!$admin->checkFTAN())
49
	{
50 1457 Luisehahne
		$admin->print_error('::'.$MESSAGE['GENERIC_SECURITY_ACCESS'],'browse.php',false);
51 1425 Luisehahne
	}
52 1457 Luisehahne
*/
53 1476 Luisehahne
54 1818 Luisehahne
	$pathsettings = array();
55
	if(DEFAULT_THEME != '') {
56 1476 Luisehahne
		//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 1425 Luisehahne
	}
63 1476 Luisehahne
64 1818 Luisehahne
	$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 1425 Luisehahne
	$dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
68 1818 Luisehahne
69 1425 Luisehahne
	$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 1818 Luisehahne
		$pathsettings[$r]['width']=$w;
76 1425 Luisehahne
		$pathsettings[$r]['height']=$h;
77
	}
78 1818 Luisehahne
//	$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 1425 Luisehahne
	$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 1818 Luisehahne
if ($_SESSION['GROUP_ID'] != 1 && (isset($pathsettings['global']['admin_only']) && $pathsettings['global']['admin_only']) ) {
87 1425 Luisehahne
	echo "Sorry, settings not available";
88
	exit();
89
}
90
91
// Read data to display
92
$caller = "setparameter";
93
94 1529 Luisehahne
// Setup template object, parse vars to it, then parse it
95
// Create new template object
96 1625 Luisehahne
$template = new Template(dirname($admin->correct_theme_source('setparameter.htt')));
97 1425 Luisehahne
$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 1818 Luisehahne
$template->set_var(array(
103 1457 Luisehahne
				'TEXT_HEADER' => $TEXT['TEXT_HEADER'],
104
				'SAVE_TEXT' => $TEXT['SAVE'],
105
				'BACK' => $TEXT['BACK'],
106
			)
107
		);
108 1425 Luisehahne
109
$template->set_block('main_block', 'list_block', 'list');
110
$row_bg_color = '';
111
$dirs = directory_list(WB_PATH.MEDIA_DIRECTORY);
112 1818 Luisehahne
113 1425 Luisehahne
$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 1818 Luisehahne
	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
//
127
    $bPathCanEdit = (preg_match('/'.$currentHome.'/i', $safepath)) ? true : false;
128 1425 Luisehahne
129 1818 Luisehahne
//	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 1425 Luisehahne
133 1818 Luisehahne
	$template->set_var(array(
134 1457 Luisehahne
					'ADMIN_URL' => ADMIN_URL,
135
					'PATH_NAME' => $relative,
136
					'WIDTH' => $TEXT['WIDTH'],
137
					'HEIGHT' => $TEXT['HEIGHT'],
138
					'FIELD_NAME_W' => $safepath.'-w',
139
					'FIELD_NAME_H' => $safepath.'-h',
140 1818 Luisehahne
					'CAN_EDIT_CLASS' => ($bPathCanEdit==false) ? '' : 'bold',
141
					'READ_ONLY_DIR' => ($bPathCanEdit==false) ? ' readonly="readonly"' : '',
142
					'CUR_HEIGHT' => $cur_height,
143 1457 Luisehahne
					'CUR_WIDTH' => $cur_width,
144
					'SETTINGS' => $TEXT['SETTINGS'],
145
					'ADMIN_ONLY' => $TEXT['ADMIN_ONLY'],
146 1818 Luisehahne
					'ADMIN_ONLY_SELECTED' => isset($pathsettings['global']['admin_only']) ? $pathsettings['global']['admin_only']:'',
147 1457 Luisehahne
					'NO_SHOW_THUMBS' => $TEXT['NO_SHOW_THUMBS'],
148 1818 Luisehahne
					'NO_SHOW_THUMBS_SELECTED' => isset($pathsettings['global']['show_thumbs']) ? $pathsettings['global']['show_thumbs']:'',
149 1457 Luisehahne
					'ROW_BG_COLOR' => $row_bg_color,
150
					'FTAN' => $admin->getFTAN()
151
				)
152
		);
153 1425 Luisehahne
	$template->parse('list', 'list_block', true);
154
}
155
156
$template->parse('main', 'main_block', false);
157
$template->pparse('output', 'page');