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