Cheetah
basic_settings.php
Go to the documentation of this file.
1 <?php
2 
8 define('CH_RETINA_PREFIX', 'retina_');
9 
10 require_once( '../inc/header.inc.php' );
11 
12 $GLOBALS['iAdminPage'] = 1;
13 
14 require_once( CH_DIRECTORY_PATH_INC . 'profiles.inc.php' );
15 require_once( CH_DIRECTORY_PATH_INC . 'design.inc.php' );
16 require_once( CH_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
17 require_once( CH_DIRECTORY_PATH_INC . 'utils.inc.php' );
18 ch_import('ChWsbAdminSettings');
19 
20 $logged['admin'] = member_auth( 1, true, true );
21 
22 //--- Process submit ---//
25 
27 
28 //--- Logo uploading ---//
29 if(isset($_POST['upload']) && isset($_FILES['new_file']))
30  $mixedResultLogo = setLogo($_POST, $_FILES);
31 else if(isset($_POST['delete']))
32  deleteLogo();
33 
34 //--- Site's settings saving ---//
35 if(isset($_POST['save']) && isset($_POST['cat'])) {
36  $sResult = $oSettings->saveChanges($_POST);
37 }
38 //--- Promo text saving ---//
39 if(isset($_POST['save_splash'])) {
40  //setParam('splash_editor', (process_db_input($_POST['editor']) == 'on' ? 'on' : ''));
41  setParam('splash_editor', ($_POST['editor'] == 'on' ? 'on' : ''));
42  //setParam('splash_code', process_db_input($_POST['code'], CH_TAGS_VALIDATE));
43  setParam('splash_code', clear_xss($_POST['code']));
44  //setParam('splash_visibility', process_db_input($_POST['visibility']));
45  setParam('splash_visibility', $_POST['visibility']);
46  //setParam('splash_logged', (process_db_input($_POST['logged']) == 'on' ? 'on' : ''));
47  setParam('splash_logged', ($_POST['logged'] == 'on' ? 'on' : ''));
48 
49 }
50 
52 $_page = array(
53  'name_index' => $iNameIndex,
54  'css_name' => array('forms_adv.css', 'settings.css'),
55  'header' => _t('_adm_page_cpt_settings_basic')
56 );
58  'page_code_settings' => DesignBoxAdmin(_t('_adm_box_cpt_settings_main'), $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $oSettings->getForm()))),
59  'page_code_logo' => PageCodeLogo($mixedResultLogo),
60  'page_code_promo' => PageCodePromo($mixedResultPromo),
61  'page_code_injectins' => PageCodeInjections(),
62 );
63 
65 
67 {
68  $aForm = array(
69  'form_attrs' => array(
70  'id' => 'adm-settings-injections',
71  'name' => 'adm-settings-injections',
72  'action' => $GLOBALS['site']['url_admin'] . 'basic_settings.php',
73  'method' => 'post',
74  ),
75  'params' => array(
76  'db' => array('submit_name' => 'save_injections'),
77  ),
78  'inputs' => array(
79  'head' => array(
80  'type' => 'textarea',
81  'name' => 'head',
82  'caption' => _t('_adm_txt_settings_injection_head'),
83  'info' => _t('_adm_dsc_settings_injection_head'),
84  ),
85  'body' => array(
86  'type' => 'textarea',
87  'name' => 'body',
88  'caption' => _t('_adm_txt_settings_injection_body'),
89  'info' => _t('_adm_dsc_settings_injection_body'),
90  ),
91  'save_injections' => array(
92  'type' => 'submit',
93  'name' => 'save_injections',
94  'value' => _t("_adm_btn_settings_save"),
95  )
96  )
97  );
99 
100  $sResult = '';
101  if ($oForm->isSubmittedAndValid ()) {
102  $b = $GLOBALS['MySQL']->res("UPDATE `sys_injections` SET `data` = '" . process_db_input($_POST['head']) . "' WHERE `name` = 'sys_head'");
103  $b |= $GLOBALS['MySQL']->res("UPDATE `sys_injections` SET `data` = '" . process_db_input($_POST['body']) . "' WHERE `name` = 'sys_body'");
104  if ($b)
105  $GLOBALS['MySQL']->cleanCache('sys_injections.inc');
106  $sResult = MsgBox(_t($b ? '_Success' : '_Error'));
107  }
108 
109  $oForm->aInputs['head']['value'] = $GLOBALS['MySQL']->getOne("SELECT `data` FROM `sys_injections` WHERE `name` = 'sys_head'");
110  $oForm->aInputs['body']['value'] = $GLOBALS['MySQL']->getOne("SELECT `data` FROM `sys_injections` WHERE `name` = 'sys_body'");
111 
112  return DesignBoxAdmin(_t('_adm_box_cpt_injections'), $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $sResult . $oForm->getCode())));
113 }
114 
116 {
117  $bEditor = getParam('splash_editor') == 'on';
118 
119  $aForm = array(
120  'form_attrs' => array(
121  'id' => 'adm-settings-form-splash',
122  'name' => 'adm-settings-form-splash',
123  'action' => $GLOBALS['site']['url_admin'] . 'basic_settings.php',
124  'method' => 'post',
125  ),
126  'params' => array(),
127  'inputs' => array(
128  'editor' => array(
129  'type' => 'checkbox',
130  'name' => 'editor',
131  'caption' => _t('_adm_txt_settings_splash_editor'),
132  'info' => _t('_adm_dsc_settings_splash_editor'),
133  'value' => 'on',
134  'checked' => $bEditor,
135  'attrs' => array(
136  'onchange' => 'javascript:splashEnableEditor(this)'
137  )
138  ),
139  'code' => array(
140  'type' => 'textarea',
141  'name' => 'code',
142  'caption' => '',
143  'value' => getParam('splash_code'),
144  'html' => $bEditor ? 2 : 0,
145  'colspan' => 2,
146  'tr_attrs' => array(
147  'id' => 'adm-bs-splash-editor-wrp'
148  ),
149  'attrs_wrapper' => array(
150  'style' => 'height:300px; width:100%;',
151  ),
152  'attrs' => array(
153  'id' => 'adm-bs-splash-editor',
154  'style' => 'height:300px; width:100%;',
155  )
156  ),
157  'visibility' => array(
158  'type' => 'radio_set',
159  'name' => 'visibility',
160  'caption' => _t('_adm_txt_settings_splash_visibility'),
161  'value' => getParam('splash_visibility'),
162  'values' => array(
163  CH_WSB_SPLASH_VIS_DISABLE => _t('_adm_txt_settings_splash_visibility_disable'),
164  CH_WSB_SPLASH_VIS_INDEX => _t('_adm_txt_settings_splash_visibility_index'),
165  CH_WSB_SPLASH_VIS_ALL => _t('_adm_txt_settings_splash_visibility_all')
166  ),
167  'dv' => '<br />'
168  ),
169  'logged' => array(
170  'type' => 'checkbox',
171  'name' => 'logged',
172  'caption' => _t('_adm_txt_settings_splash_logged'),
173  'value' => 'on',
174  'checked' => getParam('splash_logged') == 'on',
175  ),
176  'save_splash' => array(
177  'type' => 'submit',
178  'name' => 'save_splash',
179  'value' => _t("_adm_btn_settings_save"),
180  )
181  )
182  );
184 
185  $sContent = '';
186  $sContent .= MsgBox(_t('_adm_txt_settings_splash_warning'));
187  $sContent .= $oForm->getCode();
188 
189  return DesignBoxAdmin(_t('_adm_box_cpt_splash'), $GLOBALS['oAdmTemplate']->parseHtmlByName('splash.html', array(
190  'content' => $sContent
191  )));
192 }
193 
195 {
196  $aForm = array(
197  'form_attrs' => array(
198  'id' => 'adm-settings-form-logo',
199  'name' => 'adm-settings-form-logo',
200  'action' => $GLOBALS['site']['url_admin'] . 'basic_settings.php',
201  'method' => 'post',
202  'enctype' => 'multipart/form-data'
203  ),
204  'params' => array(),
205  'inputs' => array(
206  'upload_header_beg' => array(
207  'type' => 'block_header',
208  'caption' => _t('_adm_txt_settings_logo_header'),
209  'collapsable' => false,
210  'collapsed' => false
211  ),
212  'old_file' => array(
213  'type' => 'custom',
214  'content' => $GLOBALS['oFunctions']->genSiteLogo(),
215  'colspan' => true
216  ),
217  'new_file' => array(
218  'type' => 'file',
219  'name' => 'new_file',
220  'caption' => _t('_adm_txt_settings_logo_upload'),
221  'value' => '',
222  ),
223  'resize_header_beg' => array(
224  'type' => 'block_header',
225  'caption' => _t('_adm_txt_settings_resize_header'),
226  'collapsable' => false,
227  'collapsed' => false
228  ),
229  'resize' => array(
230  'type' => 'checkbox',
231  'name' => 'resize',
232  'caption' => _t('_adm_txt_settings_resize_enable'),
233  'value' => 'yes',
234  'checked' => true
235  ),
236  'new_width' => array(
237  'type' => 'text',
238  'name' => 'new_width',
239  'caption' => _t('_adm_txt_settings_resize_width'),
240  'value' => '64'
241  ),
242  'new_height' => array(
243  'type' => 'text',
244  'name' => 'new_height',
245  'caption' => _t('_adm_txt_settings_resize_height'),
246  'value' => '64'
247  ),
248  'resize_header_end' => array(
249  'type' => 'block_end'
250  ),
251  'upload' => array(
252  'type' => 'submit',
253  'name' => 'upload',
254  'value' => _t("_adm_btn_settings_upload"),
255  )
256  )
257  );
258 
259  if(isLogoUploaded()) {
260  $aControls = array(
261  'type' => 'input_set',
262  'name' => 'controls',
263  );
264  $aControls[] = $aForm['inputs']['upload'];
265  $aControls[] = array(
266  'type' => 'submit',
267  'name' => 'delete',
268  'value' => _t("_adm_btn_settings_delete"),
269  );
270 
271  $aForm['inputs']['upload'] = $aControls;
272  }
273 
275  $sResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $oForm->getCode()));
276 
277  if($mixedResultLogo !== true && !empty($mixedResultLogo))
279 
280  return DesignBoxAdmin(_t('_adm_box_cpt_logo'), $sResult);
281 }
282 
283 function isLogoUploaded()
284 {
285  global $dir;
286 
287  $sFileName = getParam('sys_main_logo');
288  return $sFileName && file_exists($dir['mediaImages'] . $sFileName);
289 }
290 
291 function setLogo(&$aData, &$aFile)
292 {
293  global $dir;
294 
295  $aFileInfo = getimagesize($aFile['new_file']['tmp_name']);
296  if(empty($aFileInfo))
297  return '_adm_txt_settings_file_not_image';
298 
299  $sExt = '';
300  switch( $aFileInfo['mime'] ) {
301  case 'image/jpeg': $sExt = 'jpg'; break;
302  case 'image/gif': $sExt = 'gif'; break;
303  case 'image/png': $sExt = 'png'; break;
304  }
305  if(empty($sExt))
306  return '_adm_txt_settings_file_wrong_format';
307 
308  $sFileName = time() . '.' . $sExt;
309  $sFileName2x = CH_RETINA_PREFIX . time() . '.' . $sExt;
310  $sFilePath = $dir['mediaImages'] . $sFileName;
311  $sFilePath2x = $dir['mediaImages'] . $sFileName2x;
312  if(!move_uploaded_file($aFile['new_file']['tmp_name'], $sFilePath))
313  return '_adm_txt_settings_file_cannot_move';
314 
316  $o->removeCropOptions ();
317  $o->setJpegOutput (false);
318  $o->setSquareResize (false);
319 
320  if(!empty($aData['resize'])) {
321  $iWidth = (int)$aData['new_width'];
322  $iHeight = (int)$aData['new_height'];
323  if($iWidth <= 0 || $iHeight <= 0)
324  return '_adm_txt_settings_logo_wrong_size';
325 
326  $o->setSize ($iWidth*2, $iHeight*2);
327  if($o->resize($sFilePath, $sFilePath2x) != IMAGE_ERROR_SUCCESS)
328  return '_adm_txt_settings_image_cannot_resize';
329 
330  $o->setSize ($iWidth, $iHeight);
331  if($o->resize($sFilePath, $sFilePath) != IMAGE_ERROR_SUCCESS)
332  return '_adm_txt_settings_image_cannot_resize';
333  }
334 
335  @unlink($dir['mediaImages'] . getParam('sys_main_logo'));
336  @unlink($dir['mediaImages'] . CH_RETINA_PREFIX . getParam('sys_main_logo'));
337  setParam('sys_main_logo', $sFileName);
338 
339  ch_import('ChWsbImageResize');
340  $aFileNewSize = ChWsbImageResize::getImageSize($sFilePath);
341  setParam('sys_main_logo_w', $aFileNewSize['w']);
342  setParam('sys_main_logo_h', $aFileNewSize['h']);
343 
344  return true;
345 }
346 
347 function deleteLogo()
348 {
349  global $dir;
350 
351  @unlink($dir['mediaImages'] . getParam('sys_main_logo'));
352  @unlink($dir['mediaImages'] . CH_RETINA_PREFIX . getParam('sys_main_logo'));
353  setParam('sys_main_logo', '');
354  setParam('sys_main_logo_w', '');
355  setParam('sys_main_logo_h', '');
356 }
process_db_input
process_db_input($sText, $iStripTags=0)
Definition: utils.inc.php:256
$iNameIndex
if(isset($_POST['save']) &&isset($_POST['cat'])) if(isset($_POST['save_splash'])) $iNameIndex
Definition: basic_settings.php:51
PageCodeInjections
PageCodeInjections()
Definition: basic_settings.php:66
ChTemplFormView
Definition: ChTemplFormView.php:11
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
$sResult
$sResult
Definition: advanced_settings.php:26
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
php
setLogo
setLogo(&$aData, &$aFile)
Definition: basic_settings.php:291
$sExt
$sExt
Definition: get_file.php:14
$oForm
$oForm
Definition: host_tools.php:42
DesignBoxAdmin
DesignBoxAdmin($sTitle, $sContent, $mixedTopItems='', $sBottomItems='', $iIndex=1)
Definition: admin_design.inc.php:50
deleteLogo
deleteLogo()
Definition: basic_settings.php:347
ChWsbImageResize\instance
static instance()
Definition: ChWsbImageResize.php:60
$mixedResultPromo
$mixedResultPromo
Definition: basic_settings.php:24
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
isLogoUploaded
isLogoUploaded()
Definition: basic_settings.php:283
$_page
$_page
Definition: basic_settings.php:52
CH_RETINA_PREFIX
const CH_RETINA_PREFIX
Definition: basic_settings.php:8
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
PageCodeAdmin
PageCodeAdmin($oTemplate=null)
Definition: admin_design.inc.php:45
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
$GLOBALS
$GLOBALS['iAdminPage']
Definition: basic_settings.php:12
time
that in the case of a Adaptation or at a minimum such credit will if a credit for all contributing authors of the Adaptation or Collection then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors For the avoidance of You may only use the credit required by this Section for the purpose of attribution in the manner set out above by exercising Your rights under this You may not implicitly or explicitly assert or imply any connection sponsorship or endorsement by the Original Licensor and or Attribution as of You or Your use of the without the express prior written permission of the Original Licensor and or Attribution Parties Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable if You Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or You must not modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author s honor or reputation Licensor agrees that in those in which any exercise of the right granted in modification or other derogatory action prejudicial to the Original Author s honor and the Licensor will waive or not as this to the fullest extent permitted by the applicable national to enable You to reasonably exercise Your right under Warranties and Disclaimer UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN LICENSOR OFFERS THE WORK AS IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE STATUTORY OR WITHOUT WARRANTIES OF FITNESS FOR A PARTICULAR OR THE ABSENCE OF LATENT OR OTHER OR THE PRESENCE OF ABSENCE OF WHETHER OR NOT DISCOVERABLE SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED SO SUCH EXCLUSION MAY NOT APPLY TO YOU Limitation on Liability EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES Termination This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License Individuals or entities who have received Adaptations or Collections from You under this will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses and will survive any termination of this License Subject to the above terms and the license granted here is Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time
Definition: license.txt:56
member_auth
member_auth($member=0, $error_handle=true, $bAjx=false)
Definition: admin.inc.php:262
ChWsbAdminSettings
Definition: ChWsbAdminSettings.php:35
PageCodePromo
PageCodePromo($mixedResultPromo)
Definition: basic_settings.php:115
$oSettings
$oSettings
Definition: basic_settings.php:26
setParam
setParam($sParamName, $sParamValue)
Definition: db.inc.php:149
IMAGE_ERROR_SUCCESS
const IMAGE_ERROR_SUCCESS
operation was successfull
Definition: ChWsbImageResize.php:22
$aForm
$aForm
Definition: forgot.php:43
PageCodeLogo
PageCodeLogo($mixedResultLogo)
Definition: basic_settings.php:194
$logged
$logged['admin']
Definition: basic_settings.php:20
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
$o
$o
Definition: cmd.php:193
$_page_cont
$_page_cont[$iNameIndex]
Definition: basic_settings.php:57
$mixedResultLogo
$mixedResultLogo
Definition: basic_settings.php:23
ChWsbImageResize\getImageSize
static getImageSize($sPath)
Definition: ChWsbImageResize.php:167
$dir
$dir
Definition: config.php:10
clear_xss
clear_xss($val)
Definition: utils.inc.php:700