1 | <?php
|
---|
2 |
|
---|
3 | /***************************************************************************
|
---|
4 | * Dolphin Smart Community Builder
|
---|
5 | * -----------------
|
---|
6 | * begin : Mon Mar 23 2006
|
---|
7 | * copyright : (C) 2006 BoonEx Group
|
---|
8 | * website : http://www.boonex.com/
|
---|
9 | * This file is part of Dolphin - Smart Community Builder
|
---|
10 | *
|
---|
11 | * Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
|
---|
12 | * http://creativecommons.org/licenses/by/3.0/
|
---|
13 | *
|
---|
14 | * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
---|
15 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
16 | * See the Creative Commons Attribution 3.0 License for more details.
|
---|
17 | * You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
|
---|
18 | * see license.txt file; if not, write to marketing@boonex.com
|
---|
19 | ***************************************************************************/
|
---|
20 |
|
---|
21 | define('BX_SECURITY_EXCEPTIONS', true);
|
---|
22 | $aBxSecurityExceptions = array(
|
---|
23 | 'POST.content_text',
|
---|
24 | 'REQUEST.content_text',
|
---|
25 | );
|
---|
26 |
|
---|
27 | require_once( '../inc/header.inc.php' );
|
---|
28 |
|
---|
29 | $GLOBALS['iAdminPage'] = 1;
|
---|
30 |
|
---|
31 | require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
|
---|
32 | require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
|
---|
33 | require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
|
---|
34 | require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
|
---|
35 | bx_import('BxDolAdminSettings');
|
---|
36 |
|
---|
37 | $logged['admin'] = member_auth( 1, true, true );
|
---|
38 |
|
---|
39 | //--- Process submit ---//
|
---|
40 | $mixedResultLogo = '';
|
---|
41 | $mixedResultPromo = '';
|
---|
42 |
|
---|
43 | $oSettings = new BxDolAdminSettings(7);
|
---|
44 |
|
---|
45 | //--- Logo uploading ---//
|
---|
46 | if(isset($_POST['upload']) && isset($_FILES['new_file']))
|
---|
47 | $mixedResultLogo = setLogo($_POST, $_FILES);
|
---|
48 |
|
---|
49 | //--- Promo image uploading ---//
|
---|
50 | if(isset($_POST['save_image']) && isset($_FILES['browse_image'])) {
|
---|
51 | setParam('enable_flash_promo', ($_POST['type'] == 'image' ? 'on' : ''));
|
---|
52 |
|
---|
53 | $mixedResultPromo = setPromoImage($_FILES);
|
---|
54 | }
|
---|
55 | //--- Promo image deleting ---//
|
---|
56 | if( $_GET['delete'] and strlen( $_GET['delete'] ) ) {
|
---|
57 | $sFile = process_pass_data( $_GET['delete'] );
|
---|
58 |
|
---|
59 | $sFile = str_replace('\\', '', $sFile);
|
---|
60 | $sFile = str_replace('/', '', $sFile);
|
---|
61 |
|
---|
62 | $bResult = @unlink($dir['imagesPromo'] . $sFile);
|
---|
63 |
|
---|
64 | if(!$bResult)
|
---|
65 | $mixedResultPromo = '_adm_txt_settings_file_cannot_delete';
|
---|
66 | }
|
---|
67 |
|
---|
68 | //--- Site's settings saving ---//
|
---|
69 | if(isset($_POST['save']) && isset($_POST['cat'])) {
|
---|
70 | $sResult = $oSettings->saveChanges($_POST);
|
---|
71 | }
|
---|
72 | //--- Promo text saving ---//
|
---|
73 | if(isset($_POST['save_text']) && isset($_POST['content_text'])) {
|
---|
74 | setParam('enable_flash_promo', ($_POST['type'] == 'text' ? '' : 'on'));
|
---|
75 | setParam('custom_promo_code', $_POST['content_text']);
|
---|
76 | $sCacheFile = BX_DIRECTORY_PATH_CACHE . 'sys_options.php';
|
---|
77 | @unlink ($sCacheFile);
|
---|
78 | }
|
---|
79 |
|
---|
80 | $iNameIndex = 4;
|
---|
81 | $_page = array(
|
---|
82 | 'name_index' => $iNameIndex,
|
---|
83 | 'css_name' => array('forms_adv.css', 'settings.css'),
|
---|
84 | 'header' => _t('_adm_page_cpt_settings')
|
---|
85 | );
|
---|
86 | $_page_cont[$iNameIndex] = array(
|
---|
87 | 'page_code_settings' => DesignBoxAdmin(_t('_adm_box_cpt_settings_main'), $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $oSettings->getForm()))),
|
---|
88 | 'page_code_logo' => PageCodeLogo($mixedResultLogo),
|
---|
89 | 'page_code_promo' => PageCodePromo($mixedResultPromo)
|
---|
90 | );
|
---|
91 |
|
---|
92 | PageCodeAdmin();
|
---|
93 |
|
---|
94 | function PageCodePromo($mixedResultPromo) {
|
---|
95 | $aFormImage = array(
|
---|
96 | 'form_attrs' => array(
|
---|
97 | 'id' => 'adm-settings-form-promo-image',
|
---|
98 | 'name' => 'adm-settings-form-promo-image',
|
---|
99 | 'action' => $_SERVER['PHP_SELF'],
|
---|
100 | 'method' => 'post',
|
---|
101 | 'enctype' => 'multipart/form-data'
|
---|
102 | ),
|
---|
103 | 'params' => array(),
|
---|
104 | 'inputs' => array(
|
---|
105 | 'type' => array(
|
---|
106 | 'type' => 'hidden',
|
---|
107 | 'name' => 'type',
|
---|
108 | 'value' => 'image',
|
---|
109 | ),
|
---|
110 | 'content_text' => array(
|
---|
111 | 'type' => 'custom',
|
---|
112 | 'caption' => _t('_adm_txt_settings_promo_uploaded'),
|
---|
113 | 'content' => getPromoImages(),
|
---|
114 | ),
|
---|
115 | 'browse_image' => array(
|
---|
116 | 'type' => 'file',
|
---|
117 | 'name' => 'browse_image',
|
---|
118 | 'caption' => _t('_adm_txt_settings_promo_browse'),
|
---|
119 | 'value' => '',
|
---|
120 | ),
|
---|
121 | 'save_image' => array(
|
---|
122 | 'type' => 'submit',
|
---|
123 | 'name' => 'save_image',
|
---|
124 | 'value' => _t("_adm_btn_settings_save"),
|
---|
125 | )
|
---|
126 | )
|
---|
127 | );
|
---|
128 | $oFormImage = new BxTemplFormView($aFormImage);
|
---|
129 |
|
---|
130 | $aFormText = array(
|
---|
131 | 'form_attrs' => array(
|
---|
132 | 'id' => 'adm-settings-form-promo-text',
|
---|
133 | 'name' => 'adm-settings-form-promo-text',
|
---|
134 | 'action' => $_SERVER['PHP_SELF'],
|
---|
135 | 'method' => 'post',
|
---|
136 | 'enctype' => 'multipart/form-data'
|
---|
137 | ),
|
---|
138 | 'params' => array(),
|
---|
139 | 'inputs' => array(
|
---|
140 | 'type' => array(
|
---|
141 | 'type' => 'hidden',
|
---|
142 | 'name' => 'type',
|
---|
143 | 'value' => 'text',
|
---|
144 | ),
|
---|
145 | 'content_text' => array(
|
---|
146 | 'type' => 'textarea',
|
---|
147 | 'name' => 'content_text',
|
---|
148 | 'caption' => '',
|
---|
149 | 'value' => stripslashes(getParam('custom_promo_code')),
|
---|
150 | 'colspan' => true,
|
---|
151 | 'html' => 2,
|
---|
152 | 'db' => array (
|
---|
153 | 'pass' => 'XssHtml',
|
---|
154 | ),
|
---|
155 | ),
|
---|
156 | 'save_text' => array(
|
---|
157 | 'type' => 'submit',
|
---|
158 | 'name' => 'save_text',
|
---|
159 | 'value' => _t("_adm_btn_settings_save"),
|
---|
160 | )
|
---|
161 | )
|
---|
162 | );
|
---|
163 | $oFormText = new BxTemplFormView($aFormText);
|
---|
164 |
|
---|
165 | $bPromoImage = getParam('enable_flash_promo') == 'on';
|
---|
166 | $sResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('promo.html', array(
|
---|
167 | 'checked_image' => $bPromoImage ? 'checked="checked"' : '',
|
---|
168 | 'checked_text' => !$bPromoImage ? 'checked="checked"' : '',
|
---|
169 | 'style_image' => $bPromoImage ? '' : 'display:none;',
|
---|
170 | 'style_text' => !$bPromoImage ? '' : 'display:none;',
|
---|
171 | 'content_image' => $oFormImage->getCode(),
|
---|
172 | 'content_text' => $oFormText->getCode()
|
---|
173 | ));
|
---|
174 |
|
---|
175 | return DesignBoxAdmin(_t('_adm_box_cpt_promo'), $sResult);
|
---|
176 | }
|
---|
177 |
|
---|
178 | function PageCodeLogo($mixedResultLogo) {
|
---|
179 | $aForm = array(
|
---|
180 | 'form_attrs' => array(
|
---|
181 | 'id' => 'adm-settings-form-logo',
|
---|
182 | 'name' => 'adm-settings-form-logo',
|
---|
183 | 'action' => $_SERVER['PHP_SELF'],
|
---|
184 | 'method' => 'post',
|
---|
185 | 'enctype' => 'multipart/form-data'
|
---|
186 | ),
|
---|
187 | 'params' => array(),
|
---|
188 | 'inputs' => array(
|
---|
189 | 'upload_header_beg' => array(
|
---|
190 | 'type' => 'block_header',
|
---|
191 | 'caption' => _t('_adm_txt_settings_logo_header'),
|
---|
192 | 'collapsable' => false,
|
---|
193 | 'collapsed' => false
|
---|
194 | ),
|
---|
195 | 'old_file' => array(
|
---|
196 | 'type' => 'custom',
|
---|
197 | 'content' => getMainLogo(),
|
---|
198 | 'colspan' => true
|
---|
199 | ),
|
---|
200 | 'new_file' => array(
|
---|
201 | 'type' => 'file',
|
---|
202 | 'name' => 'new_file',
|
---|
203 | 'caption' => _t('_adm_txt_settings_logo_upload'),
|
---|
204 | 'value' => '',
|
---|
205 | ),
|
---|
206 | 'resize_header_beg' => array(
|
---|
207 | 'type' => 'block_header',
|
---|
208 | 'caption' => _t('_adm_txt_settings_resize_header'),
|
---|
209 | 'collapsable' => false,
|
---|
210 | 'collapsed' => false
|
---|
211 | ),
|
---|
212 | 'resize' => array(
|
---|
213 | 'type' => 'checkbox',
|
---|
214 | 'name' => 'resize',
|
---|
215 | 'caption' => _t('_adm_txt_settings_resize_enable'),
|
---|
216 | 'value' => 'yes',
|
---|
217 | 'checked' => true
|
---|
218 | ),
|
---|
219 | 'new_width' => array(
|
---|
220 | 'type' => 'text',
|
---|
221 | 'name' => 'new_width',
|
---|
222 | 'caption' => _t('_adm_txt_settings_resize_width'),
|
---|
223 | 'value' => '64'
|
---|
224 | ),
|
---|
225 | 'new_height' => array(
|
---|
226 | 'type' => 'text',
|
---|
227 | 'name' => 'new_height',
|
---|
228 | 'caption' => _t('_adm_txt_settings_resize_height'),
|
---|
229 | 'value' => '64'
|
---|
230 | ),
|
---|
231 | 'resize_header_end' => array(
|
---|
232 | 'type' => 'block_end'
|
---|
233 | ),
|
---|
234 | 'upload' => array(
|
---|
235 | 'type' => 'submit',
|
---|
236 | 'name' => 'upload',
|
---|
237 | 'value' => _t("_adm_btn_settings_upload"),
|
---|
238 | )
|
---|
239 | )
|
---|
240 | );
|
---|
241 |
|
---|
242 | $oForm = new BxTemplFormView($aForm);
|
---|
243 | $sResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $oForm->getCode()));
|
---|
244 |
|
---|
245 | if($mixedResultLogo !== true && !empty($mixedResultLogo))
|
---|
246 | $sResult = MsgBox(_t($mixedResultLogo), 3) . $sResult;
|
---|
247 |
|
---|
248 | return DesignBoxAdmin(_t('_adm_box_cpt_logo'), $sResult);
|
---|
249 | }
|
---|
250 |
|
---|
251 | function setLogo(&$aData, &$aFile) {
|
---|
252 | global $dir;
|
---|
253 |
|
---|
254 | $aFileInfo = getimagesize($aFile['new_file']['tmp_name']);
|
---|
255 | if(empty($aFileInfo))
|
---|
256 | return '_adm_txt_settings_file_not_image';
|
---|
257 |
|
---|
258 | $sExt = '';
|
---|
259 | switch( $aFileInfo['mime'] ) {
|
---|
260 | case 'image/jpeg': $sExt = 'jpg'; break;
|
---|
261 | case 'image/gif': $sExt = 'gif'; break;
|
---|
262 | case 'image/png': $sExt = 'png'; break;
|
---|
263 | }
|
---|
264 | if(empty($sExt))
|
---|
265 | return '_adm_txt_settings_file_wrong_format';
|
---|
266 |
|
---|
267 | $sFileName = mktime() . '.' . $sExt;
|
---|
268 | $sFilePath = $dir['mediaImages'] . $sFileName;
|
---|
269 | if(!move_uploaded_file($aFile['new_file']['tmp_name'], $sFilePath))
|
---|
270 | return '_adm_txt_settings_file_cannot_move';
|
---|
271 |
|
---|
272 | if(!empty($aData['resize'])) {
|
---|
273 | $iWidth = (int)$aData['new_width'];
|
---|
274 | $iHeight = (int)$aData['new_height'];
|
---|
275 | if($iWidth <= 0 || $iHeight <= 0)
|
---|
276 | return '_adm_txt_settings_logo_wrong_size';
|
---|
277 |
|
---|
278 | if(imageResize($sFilePath, $sFilePath, $iWidth, $iHeight) != IMAGE_ERROR_SUCCESS)
|
---|
279 | return '_adm_txt_settings_image_cannot_resize';
|
---|
280 | }
|
---|
281 |
|
---|
282 | @unlink($dir['mediaImages'] . getParam('sys_main_logo'));
|
---|
283 | setParam('sys_main_logo', $sFileName);
|
---|
284 |
|
---|
285 | return true;
|
---|
286 | }
|
---|
287 | function getPromoImages() {
|
---|
288 | global $site;
|
---|
289 |
|
---|
290 | $aFiles = getPromoImagesArray();
|
---|
291 | if(empty($aFiles))
|
---|
292 | return MsgBox('_empty');
|
---|
293 |
|
---|
294 | $aResult = array();
|
---|
295 | foreach($aFiles as $sFile) {
|
---|
296 | $aResult[] = array(
|
---|
297 | 'delete_url' => $_SERVER['PHP_SELF'] . "?delete=" . urlencode($sFile),
|
---|
298 | 'title' => $sFile
|
---|
299 | );
|
---|
300 | }
|
---|
301 | return $GLOBALS['oAdmTemplate']->parseHtmlByName('promo_images.html', array(
|
---|
302 | 'bx_repeat:images' => $aResult,
|
---|
303 | 'images_url' => $site['imagesPromo']
|
---|
304 | ));
|
---|
305 | }
|
---|
306 | function setPromoImage(&$aFile) {
|
---|
307 | global $dir;
|
---|
308 |
|
---|
309 | $aFileInfo = getimagesize($aFile['browse_image']['tmp_name']);
|
---|
310 | if(empty($aFileInfo))
|
---|
311 | return '_adm_txt_settings_file_not_image';
|
---|
312 |
|
---|
313 | $sExt = '';
|
---|
314 | switch( $aFileInfo['mime'] ) {
|
---|
315 | case 'image/jpeg': $sExt = 'jpg'; break;
|
---|
316 | case 'image/gif': $sExt = 'gif'; break;
|
---|
317 | case 'image/png': $sExt = 'png'; break;
|
---|
318 | }
|
---|
319 | if(empty($sExt))
|
---|
320 | return '_adm_txt_settings_file_wrong_format';
|
---|
321 |
|
---|
322 | $sFileName = $aFile['browse_image']['name'];
|
---|
323 | $sFilePath = $dir['imagesPromo'] . $sFileName;
|
---|
324 | if(!move_uploaded_file($aFile['browse_image']['tmp_name'], $sFilePath))
|
---|
325 | return '_adm_txt_settings_file_cannot_move';
|
---|
326 |
|
---|
327 | $iWidth = (int)getParam('promoWidth');
|
---|
328 | if($iWidth == 0)
|
---|
329 | $iWidth = 960;
|
---|
330 |
|
---|
331 | if(imageResize($sFilePath, $sFilePath, $iWidth, $iWidth, true) != IMAGE_ERROR_SUCCESS)
|
---|
332 | return '_adm_txt_settings_image_cannot_resize';
|
---|
333 |
|
---|
334 | chmod($sFilePath, 0644);
|
---|
335 | return true;
|
---|
336 | }
|
---|
337 |
|
---|
338 | ?>
|
---|