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',
|
---|
24 | 'REQUEST.content',
|
---|
25 | );
|
---|
26 |
|
---|
27 | require_once( '../inc/header.inc.php' );
|
---|
28 | require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
|
---|
29 | require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
|
---|
30 | require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
|
---|
31 | bx_import('BxTemplFormView');
|
---|
32 |
|
---|
33 | $logged['admin'] = member_auth( 1, true, true );
|
---|
34 |
|
---|
35 | $iNameIndex = 0;
|
---|
36 | $_page = array(
|
---|
37 | 'name_index' => $iNameIndex,
|
---|
38 | 'css_name' => array('forms_adv.css'),
|
---|
39 | 'header' => _t('_adm_page_cpt_css_edit'),
|
---|
40 | 'header_text' => _t('_adm_box_cpt_css_edit')
|
---|
41 | );
|
---|
42 | $_page_cont[$iNameIndex]['page_main_code'] = PageCodeEdit();
|
---|
43 | define('BX_PROMO_CODE', DesignBoxAdmin (_t('_adm_box_cpt_design_templates'), '
|
---|
44 | <div class="RSSAggrCont" rssid="boonex_unity_market_templates" rssnum="5" member="0">
|
---|
45 | <div class="loading_rss">
|
---|
46 | <img src="' . getTemplateImage('loading.gif') . '" alt="' . _t('_loading ...') . '" />
|
---|
47 | </div>
|
---|
48 | </div>'));
|
---|
49 |
|
---|
50 | PageCodeAdmin();
|
---|
51 |
|
---|
52 | function PageCodeEdit() {
|
---|
53 | $aForm = array(
|
---|
54 | 'form_attrs' => array(
|
---|
55 | 'id' => 'adm-css-edit',
|
---|
56 | 'name' => 'adm-css-edit',
|
---|
57 | 'action' => $_SERVER['PHP_SELF'],
|
---|
58 | 'method' => 'post',
|
---|
59 | 'enctype' => 'multipart/form-data',
|
---|
60 | ),
|
---|
61 | 'params' => array (
|
---|
62 | 'db' => array(
|
---|
63 | 'table' => '',
|
---|
64 | 'key' => '',
|
---|
65 | 'uri' => '',
|
---|
66 | 'uri_title' => '',
|
---|
67 | 'submit_name' => 'adm-css-save'
|
---|
68 | ),
|
---|
69 | ),
|
---|
70 | 'inputs' => array (
|
---|
71 | 'css_file' => array(
|
---|
72 | 'type' => 'select',
|
---|
73 | 'name' => 'css_file',
|
---|
74 | 'caption' => _t('_adm_txt_css_file'),
|
---|
75 | 'value' => '',
|
---|
76 | 'values' => array(),
|
---|
77 | 'attrs' => array(
|
---|
78 | 'onchange' => "javascript:document.forms['adm-css-edit'].submit();"
|
---|
79 | )
|
---|
80 | ),
|
---|
81 | 'content' => array(
|
---|
82 | 'type' => 'textarea',
|
---|
83 | 'name' => 'content',
|
---|
84 | 'caption' => _t('_adm_txt_css_content', $sFileName),
|
---|
85 | 'value' => '',
|
---|
86 | 'db' => array (
|
---|
87 | 'pass' => 'XssHtml',
|
---|
88 | ),
|
---|
89 | ),
|
---|
90 | 'adm-css-save' => array(
|
---|
91 | 'type' => 'submit',
|
---|
92 | 'name' => 'adm-css-save',
|
---|
93 | 'value' => _t('_adm_btn_css_save'),
|
---|
94 | ),
|
---|
95 | )
|
---|
96 | );
|
---|
97 |
|
---|
98 | //--- Get CSS files ---//
|
---|
99 | $aItems = array();
|
---|
100 | $sBasePath = BX_DIRECTORY_PATH_ROOT . "templates/tmpl_" . $GLOBALS['oSysTemplate']->getCode() . "/css/";
|
---|
101 |
|
---|
102 | $rHandle = opendir($sBasePath);
|
---|
103 | while(($sFile = readdir($rHandle)) !== false)
|
---|
104 | if(is_file($sBasePath . $sFile) && substr($sFile, -3) == 'css')
|
---|
105 | $aItems[] = array('key' => $sFile, 'value' => $sFile);
|
---|
106 | closedir($rHandle);
|
---|
107 |
|
---|
108 | $sCurrentFile = isset($_POST['css_file']) && preg_match("/^\w+\.css$/", $_POST['css_file']) ? $_POST['css_file'] : $aItems[0]['key'];
|
---|
109 | $aForm['inputs']['css_file']['value'] = $sCurrentFile;
|
---|
110 | $aForm['inputs']['css_file']['values'] = $aItems;
|
---|
111 |
|
---|
112 | //--- Get CSS file's content ---//
|
---|
113 | $sContent = '';
|
---|
114 | $sAbsolutePath = $sBasePath . $sCurrentFile;
|
---|
115 | if(strlen($sCurrentFile) > 0 && is_file($sAbsolutePath) ) {
|
---|
116 | $rHandle = fopen($sAbsolutePath, 'r');
|
---|
117 | while(!feof($rHandle))
|
---|
118 | $sContent .= fgets($rHandle, 4096);
|
---|
119 | fclose($rHandle);
|
---|
120 | }
|
---|
121 | //$aForm['inputs']['content']['value'] = isset($_POST['content']) ? $_POST['content'] : $sContent;
|
---|
122 | $aForm['inputs']['content']['value'] = $sContent;
|
---|
123 |
|
---|
124 | $oForm = new BxTemplFormView($aForm);
|
---|
125 | $oForm->initChecker();
|
---|
126 |
|
---|
127 | if($oForm->isSubmittedAndValid()) {
|
---|
128 | if(file_exists($sAbsolutePath) && isRWAccessible($sAbsolutePath) ) {
|
---|
129 | $rHandle = fopen($sAbsolutePath, 'w');
|
---|
130 | if($rHandle) {
|
---|
131 | fwrite($rHandle, clear_xss($_POST['content']));
|
---|
132 | fclose($rHandle);
|
---|
133 |
|
---|
134 | $mixedResult = '_adm_txt_css_success_save';
|
---|
135 | } else
|
---|
136 | $mixedResult = '_adm_txt_css_failed_save';
|
---|
137 | } else
|
---|
138 | $mixedResult = '_adm_txt_css_cannot_write';
|
---|
139 | }
|
---|
140 |
|
---|
141 | $sResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $oForm->getCode()));
|
---|
142 |
|
---|
143 | if ($mixedResult !== true && !empty($mixedResult))
|
---|
144 | $sResult = MsgBox(_t($mixedResult, $sCurrentFile), 3) . $sResult;
|
---|
145 |
|
---|
146 | return $sResult;
|
---|
147 | }
|
---|
148 |
|
---|
149 | ?>
|
---|