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.Text',
|
---|
24 | 'REQUEST.Text',
|
---|
25 | 'POST.Url',
|
---|
26 | 'REQUEST.Url',
|
---|
27 | );
|
---|
28 |
|
---|
29 | require_once( '../inc/header.inc.php' );
|
---|
30 | require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
|
---|
31 | require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
|
---|
32 | require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
|
---|
33 |
|
---|
34 | $logged['admin'] = member_auth(1, true, true);
|
---|
35 |
|
---|
36 | //Possible deletion
|
---|
37 | $iBannerID = (int)$_REQUEST['banner_id'];
|
---|
38 | if ( $iBannerID > 0 && $_REQUEST['action'] == "delete" ) {
|
---|
39 | db_res( "DELETE FROM `sys_banners` WHERE ID = '{$iBannerID}'" );
|
---|
40 | }
|
---|
41 |
|
---|
42 | $sManageBannersBlock = getManageBannersBlock();
|
---|
43 | $sExistedBannersBlock = getExistedBannersBlock();
|
---|
44 | $sPreviewBlock = getPreviewBlock($iBannerID);
|
---|
45 |
|
---|
46 | bx_import('BxTemplFormView');
|
---|
47 |
|
---|
48 | $iNameIndex = 14;
|
---|
49 | $_page = array(
|
---|
50 | 'name_index' => $iNameIndex,
|
---|
51 | 'css_name' => array('forms_adv.css', /*'plugins/jquery/themes/|ui.datepicker.css',*/ 'plugins/jquery/themes/|calendar-blue.css'),
|
---|
52 | 'js_name' => array(/*'ui.datepicker.js',*/ 'jquery.dynDateTime.js', 'plugins/jquery/langs/|calendar-en.js'),
|
---|
53 | 'header' => _t('_adm_bann_title'),
|
---|
54 | 'header_text' => _t('_adm_bann_title')
|
---|
55 | );
|
---|
56 |
|
---|
57 | $_page_cont[$iNameIndex]['page_main_code'] = $sPreviewBlock . $sExistedBannersBlock . $sManageBannersBlock;
|
---|
58 |
|
---|
59 | PageCodeAdmin();
|
---|
60 |
|
---|
61 | // Functions
|
---|
62 | function getPreviewBlock($iBannerID) {
|
---|
63 | $sPreview = MsgBox(_t('_Empty'));
|
---|
64 |
|
---|
65 | if ($_GET['action'] == 'preview' && $iBannerID > 0) {
|
---|
66 | $aBannerInfo = db_arr("SELECT * FROM `sys_banners` WHERE `ID` = '{$iBannerID}'");
|
---|
67 | $sBannerTitle = process_line_output($aBannerInfo['Title']);
|
---|
68 | $sBannerPut = banner_put($aBannerInfo['ID'], 0);
|
---|
69 |
|
---|
70 | $sPreview = <<<EOF
|
---|
71 | <table cellspacing=1 cellpadding=1 width=90% height=200 align=center style="border: 1px solid #ccc;">
|
---|
72 | {$sBannerTitle}
|
---|
73 | <tr><td align=center bgcolor=white>{$sBannerPut}</td></tr>
|
---|
74 | </table>
|
---|
75 | EOF;
|
---|
76 | $sResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $sPreview));
|
---|
77 | return DesignBoxContent(_t('_Preview'), $sResult, 1);
|
---|
78 | }
|
---|
79 | }
|
---|
80 |
|
---|
81 | function getExistedBannersBlock() {
|
---|
82 | $sClicksC = _t('_adm_bann_clicks');
|
---|
83 | $sImpressionsC = _t('_adm_bann_impressions');
|
---|
84 | $sPreviewC = _t('_Preview');
|
---|
85 | $sEditC = _t('_Edit');
|
---|
86 | $sDeleteC = _t('_Delete');
|
---|
87 |
|
---|
88 | // Get banner info from database.
|
---|
89 | $banners_res = db_res("SELECT * FROM `sys_banners` ORDER BY `ID` DESC");
|
---|
90 | $sExistedBanners = MsgBox(_t('_Empty'));
|
---|
91 | if ( mysql_num_rows( $banners_res ) ) {
|
---|
92 | $sExistedBanners = "<table cellspacing=1 cellpadding=2 border=0 class=small1 width=100%>";
|
---|
93 | while ( $banns_arr = mysql_fetch_array( $banners_res ) ) {
|
---|
94 | $imp = db_arr("SELECT COUNT(*) FROM `sys_banners_shows` WHERE `ID` = '{$banns_arr['ID']}'");
|
---|
95 | $clicks = db_arr("SELECT COUNT(*) FROM `sys_banners_clicks` WHERE `ID` = '{$banns_arr['ID']}'");
|
---|
96 |
|
---|
97 | $class = ( !$banns_arr['Active'] ) ? 'table_err' : 'panel';
|
---|
98 | $sBannerTitle = process_line_output($banns_arr['Title']);
|
---|
99 |
|
---|
100 | $sExistedBanners .= <<<EOF
|
---|
101 | <tr class={$class}>
|
---|
102 | <td>
|
---|
103 | (<a href="banners.php?action=preview&banner_id={$banns_arr['ID']}">{$sPreviewC}</a> |
|
---|
104 | <a href="banners.php?banner_id={$banns_arr['ID']}">{$sEditC}</a> |
|
---|
105 | <a href="banners.php?banner_id={$banns_arr['ID']}&action=delete">{$sDeleteC}</a>)
|
---|
106 | {$sBannerTitle}
|
---|
107 | </a>
|
---|
108 | </td>
|
---|
109 | <td><b>{$clicks[0]}</b> {$sClicksC} </td>
|
---|
110 | <td><b>{$imp[0]}</b> {$sImpressionsC} </td>
|
---|
111 | </tr>
|
---|
112 | EOF;
|
---|
113 | }
|
---|
114 | $sExistedBanners .= "</table>";
|
---|
115 | }
|
---|
116 |
|
---|
117 | $sResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $sExistedBanners));
|
---|
118 | return DesignBoxContent(_t('_adm_mmi_banners'), $sResult, 1);
|
---|
119 | }
|
---|
120 |
|
---|
121 | function getManageBannersBlock() {
|
---|
122 | $sAsNew = _t('_adm_bann_Insert_as_new');
|
---|
123 | $sErrorC = _t('_Error Occured');
|
---|
124 | $sApplyChangesC = _t('_Submit');
|
---|
125 | $sTopC = _t('_Top');
|
---|
126 | $sLeftC = _t('_adm_bann_Left');
|
---|
127 | $sRightC = _t('_adm_bann_Right');
|
---|
128 | $sBottomC = _t('_Bottom');
|
---|
129 | $sHShiftC = _t('_adm_bann_HShift');
|
---|
130 | $sVShiftC = _t('_adm_bann_VShift');
|
---|
131 | $sTitleC = _t('_Title');
|
---|
132 | $sUrlC = _t('_URL');
|
---|
133 | $sActiveC = _t('_Active');
|
---|
134 | $sTextC = _t('_Text');
|
---|
135 | $sStartDateC = _t('_Start date');
|
---|
136 | $sEndDateC = _t('_Expiration date');
|
---|
137 | $sDefaultC = _t('_adm_bann_default');
|
---|
138 | $sPositionOnPageC = _t('_adm_bann_Position_on_the_page');
|
---|
139 |
|
---|
140 | // get start & end dates
|
---|
141 | $start_date_default = "2008-01-01 00:00:00";
|
---|
142 | $end_date_default = "2015-01-01 00:00:00";
|
---|
143 |
|
---|
144 | $start_date = $_REQUEST['start_date'] ? $_REQUEST['start_date'] : $start_date_default;
|
---|
145 | $end_date = $_REQUEST['end_date'] ? $_REQUEST['end_date'] : $end_date_default;
|
---|
146 |
|
---|
147 | $Title = $Url = $Active = $Text = $Position = $lhshift = $lvshift = $rhshift = $rvshift = '';
|
---|
148 | $iBannerID = (int)$_GET['banner_id'];
|
---|
149 | $action = "new";
|
---|
150 |
|
---|
151 | if ($iBannerID > 0 && ! strlen($_GET['action'])) { //banner edit
|
---|
152 | $banns_arr = db_arr("SELECT * FROM `sys_banners` WHERE `ID`='{$iBannerID}'");
|
---|
153 |
|
---|
154 | $action = "modify";
|
---|
155 |
|
---|
156 | $Title = $banns_arr['Title'];
|
---|
157 | $Url = $banns_arr['Url'];
|
---|
158 | $Text = $banns_arr['Text'];
|
---|
159 | $Active = $banns_arr['Active'];
|
---|
160 | $Position = $banns_arr['Position'];
|
---|
161 |
|
---|
162 | $lhshift = $banns_arr['lhshift'];
|
---|
163 | $lvshift = $banns_arr['lvshift'];
|
---|
164 | $rhshift = $banns_arr['rhshift'];
|
---|
165 | $rvshift = $banns_arr['rvshift'];
|
---|
166 |
|
---|
167 | list($iYearStart, $iMonthStart, $iDayStart) = explode( '-', $banns_arr['campaign_start']);
|
---|
168 | //$start_date = "{$iDayStart}/{$iMonthStart}/{$iYearStart}";
|
---|
169 | $start_date = "{$iYearStart}-{$iMonthStart}-{$iDayStart} 00:00:00";
|
---|
170 |
|
---|
171 | list($iYearEnd, $iMonthEnd, $iDayEnd) = explode( '-', $banns_arr['campaign_end']);
|
---|
172 | //$end_date = "{$iDayEnd}/{$iMonthEnd}/{$iYearEnd}";
|
---|
173 | $end_date = "{$iYearEnd}-{$iMonthEnd}-{$iDayEnd} 00:00:00";
|
---|
174 | }
|
---|
175 |
|
---|
176 | $sFormTitle = htmlspecialchars($Title);
|
---|
177 | $sFormUrl = htmlspecialchars($Url);
|
---|
178 | $sFormActiveState = ($Active) ? 'checked="checked"' : '';
|
---|
179 |
|
---|
180 | $sFormActiveStateVal = ($Active) ? 'yes' : '';
|
---|
181 | $sFormActiveStateChk = ($Active) ? true : false;
|
---|
182 |
|
---|
183 | $sFormBannerText = $Text;
|
---|
184 | $sFormStartDate = $start_date;
|
---|
185 | $sFormStartDateDef = $start_date_default;
|
---|
186 | $sFormEndDate = $end_date;
|
---|
187 | $sFormEndDateDef = $end_date_default;
|
---|
188 |
|
---|
189 | $sTopPosState = (substr_count($Position,"1") > 0 ) ? 'checked="checked"' : '';
|
---|
190 | $sLeftPosState = (substr_count($Position,"2") > 0 ) ? 'checked="checked"' : '';
|
---|
191 | $sRightPosState = (substr_count($Position,"3") > 0 ) ? 'checked="checked"' : '';
|
---|
192 | $sBottomPosState = (substr_count($Position,"4") > 0 ) ? 'checked="checked"' : '';
|
---|
193 |
|
---|
194 | $sTopShift = (substr_count($Position,"2") > 0 ) ? $lhshift : '';
|
---|
195 | $sLeftShift = (substr_count($Position,"2") > 0 ) ? $lvshift : '';
|
---|
196 | $sRightShift = (substr_count($Position,"3") > 0 ) ? $rhshift : '';
|
---|
197 | $sBottomShift = (substr_count($Position,"3") > 0 ) ? $rvshift : '';
|
---|
198 |
|
---|
199 | $sActionAdd = ($action == "modify") ? $sAsNew . ' <input type=checkbox name=as_new />' : '';
|
---|
200 |
|
---|
201 | $sCustomPositions = <<<EOF
|
---|
202 | <table border=0 width=100% cellspacing=10 cellpading=20>
|
---|
203 | <tr>
|
---|
204 | <td colspan=5 align=center><input type=checkbox name="pos_top" {$sTopPosState} />{$sTopC}</td>
|
---|
205 | </tr>
|
---|
206 | <tr>
|
---|
207 | <td colspan=2 align=center><input type=checkbox name="pos_left" {$sLeftPosState} />{$sLeftC}</td>
|
---|
208 | <td> </td>
|
---|
209 | <td colspan=2 align=center><input type=checkbox name="pos_right" {$sRightPosState} />{$sRightC}</td>
|
---|
210 | </tr>
|
---|
211 | <tr>
|
---|
212 | <td>{$sHShiftC}</td>
|
---|
213 | <td>{$sVShiftC}</td>
|
---|
214 | <td> </td>
|
---|
215 | <td>{$sHShiftC}</td>
|
---|
216 | <td>{$sVShiftC}</td>
|
---|
217 | </tr>
|
---|
218 | <tr>
|
---|
219 | <td><input name="lhshift" type=input size=5 value={$sTopShift} /></td>
|
---|
220 | <td><input name="lvshift" type=input size=5 value={$sLeftShift} /></td>
|
---|
221 | <td> </td>
|
---|
222 | <td><input name="rhshift" type=input size=5 value={$sRightShift} /></td>
|
---|
223 | <td><input name="rvshift" type=input size=5 value={$sBottomShift} /></td>
|
---|
224 | </tr>
|
---|
225 | <tr>
|
---|
226 | <td colspan=5 align=center><input type=checkbox name="pos_bottom" {$sBottomPosState} />{$sBottomC}</td>
|
---|
227 | </tr>
|
---|
228 | </table>
|
---|
229 | {$sActionAdd}
|
---|
230 | EOF;
|
---|
231 |
|
---|
232 | $aForm = array(
|
---|
233 | 'form_attrs' => array(
|
---|
234 | 'name' => 'apply_ip_list_form',
|
---|
235 | 'action' => $_SERVER['PHP_SELF'],
|
---|
236 | 'method' => 'post',
|
---|
237 | ),
|
---|
238 | 'params' => array (
|
---|
239 | 'db' => array(
|
---|
240 | 'table' => 'sys_banners',
|
---|
241 | 'key' => 'ID',
|
---|
242 | 'submit_name' => 'add_button',
|
---|
243 | ),
|
---|
244 | ),
|
---|
245 | 'inputs' => array(
|
---|
246 | 'BannerTitle' => array(
|
---|
247 | 'type' => 'text',
|
---|
248 | 'name' => 'Title',
|
---|
249 | 'value' => $sFormTitle,
|
---|
250 | 'caption' => $sTitleC,
|
---|
251 | 'required' => true,
|
---|
252 | 'checker' => array (
|
---|
253 | 'func' => 'length',
|
---|
254 | 'params' => array(2,128),
|
---|
255 | 'error' => _t('_chars_to_chars', 2, 128),
|
---|
256 | ),
|
---|
257 | 'db' => array (
|
---|
258 | 'pass' => 'Xss',
|
---|
259 | ),
|
---|
260 | ),
|
---|
261 | 'BannerUrl' => array(
|
---|
262 | 'type' => 'text',
|
---|
263 | 'name' => 'Url',
|
---|
264 | 'value' => $sFormUrl,
|
---|
265 | 'caption' => $sUrlC,
|
---|
266 | 'required' => false,
|
---|
267 | 'db' => array (
|
---|
268 | 'pass' => 'Xss',
|
---|
269 | ),
|
---|
270 | ),
|
---|
271 | 'BannerActive' => array(
|
---|
272 | 'type' => 'checkbox',
|
---|
273 | 'name' => 'Active',
|
---|
274 | 'caption' => $sActiveC,
|
---|
275 | 'value' => $sFormActiveStateVal,
|
---|
276 | 'checked' => $sFormActiveStateChk,
|
---|
277 | ),
|
---|
278 | 'BannerText' => array(
|
---|
279 | 'type' => 'textarea',
|
---|
280 | 'name' => 'Text',
|
---|
281 | 'value' => $sFormBannerText,
|
---|
282 | 'caption' => $sTextC,
|
---|
283 | 'required' => true,
|
---|
284 | 'checker' => array (
|
---|
285 | 'func' => 'length',
|
---|
286 | 'params' => array(10,32000),
|
---|
287 | 'error' => _t('_chars_to_chars', 10, 32000),
|
---|
288 | ),
|
---|
289 | 'db' => array (
|
---|
290 | 'pass' => 'All',
|
---|
291 | ),
|
---|
292 | ),
|
---|
293 | 'StartDate' => array(
|
---|
294 | 'type' => 'datetime',
|
---|
295 | 'name' => 'start_date',
|
---|
296 | 'value' => $sFormStartDate,
|
---|
297 | 'caption' => $sStartDateC,
|
---|
298 | 'label' => "{$sDefaultC}: {$sFormStartDateDef}",
|
---|
299 | 'required' => true,
|
---|
300 | 'checker' => array (
|
---|
301 | 'func' => 'DateTime',
|
---|
302 | 'error' => $sErrorC,
|
---|
303 | ),
|
---|
304 | 'display' => 'filterDate',
|
---|
305 | ),
|
---|
306 | 'EndDate' => array(
|
---|
307 | 'type' => 'datetime',
|
---|
308 | 'name' => 'end_date',
|
---|
309 | 'value' => $sFormEndDate,
|
---|
310 | 'caption' => $sEndDateC,
|
---|
311 | 'label' => "{$sDefaultC}: {$sFormEndDateDef}",
|
---|
312 | 'required' => true,
|
---|
313 | 'checker' => array (
|
---|
314 | 'func' => 'DateTime',
|
---|
315 | 'error' => $sErrorC,
|
---|
316 | ),
|
---|
317 | 'display' => 'filterDate',
|
---|
318 | ),
|
---|
319 | 'Positions' => array(
|
---|
320 | 'type' => 'custom',
|
---|
321 | 'name' => 'Position',
|
---|
322 | 'caption' => $sPositionOnPageC,
|
---|
323 | 'content' => $sCustomPositions
|
---|
324 | ),
|
---|
325 | 'ID' => array(
|
---|
326 | 'type' => 'hidden',
|
---|
327 | 'name' => 'banner_id',
|
---|
328 | 'value' => $iBannerID,
|
---|
329 | ),
|
---|
330 | 'Action' => array(
|
---|
331 | 'type' => 'hidden',
|
---|
332 | 'name' => 'action',
|
---|
333 | 'value' => $action,
|
---|
334 | ),
|
---|
335 | 'add_button' => array(
|
---|
336 | 'type' => 'submit',
|
---|
337 | 'name' => 'add_button',
|
---|
338 | 'value' => $sApplyChangesC,
|
---|
339 | ),
|
---|
340 | ),
|
---|
341 | );
|
---|
342 |
|
---|
343 | $sResult = '';
|
---|
344 | $oForm = new BxTemplFormView($aForm);
|
---|
345 | $oForm->initChecker();
|
---|
346 | if ($oForm->isSubmittedAndValid()) {
|
---|
347 | list($iYearStart, $iMonthStart, $iDayStart) = explode( '-', $_REQUEST['start_date']);
|
---|
348 | $sDateStart = "{$iYearStart}-{$iMonthStart}-{$iDayStart}";
|
---|
349 |
|
---|
350 | list($iYearEnd, $iMonthEnd, $iDayEnd) = explode( '-', $_REQUEST['end_date']);
|
---|
351 | $sDateEnd = "{$iYearEnd}-{$iMonthEnd}-{$iDayEnd}";
|
---|
352 |
|
---|
353 | $sCurTime = date("Y-m-d");// 2010-12-31
|
---|
354 |
|
---|
355 | $iLastId = (int)$_REQUEST['banner_id'];
|
---|
356 |
|
---|
357 | $banner_pos = "";
|
---|
358 | if ( $_REQUEST['pos_top'] == "on" ) $banner_pos .= '1';
|
---|
359 | if ( $_REQUEST['pos_left'] == "on" ) $banner_pos .= '2';
|
---|
360 | if ( $_REQUEST['pos_right'] == "on" ) $banner_pos .= '3';
|
---|
361 | if ( $_REQUEST['pos_bottom'] == "on" ) $banner_pos .= '4';
|
---|
362 | $banner_pos = (int)$banner_pos;
|
---|
363 |
|
---|
364 | $banner_active = (isset($_REQUEST['Active'])) ? 1 : 0 ;
|
---|
365 |
|
---|
366 | $banner_lhshift = (int)$_REQUEST['lhshift'];
|
---|
367 | $banner_lvshift = (int)$_REQUEST['lvshift'];
|
---|
368 | $banner_rhshift = (int)$_REQUEST['rhshift'];
|
---|
369 | $banner_rvshift = (int)$_REQUEST['rvshift'];
|
---|
370 |
|
---|
371 | $aValsAdd = array (
|
---|
372 | 'Position' => $banner_pos,
|
---|
373 | 'Active' => $banner_active,
|
---|
374 | 'Created' => $sCurTime,
|
---|
375 | 'campaign_start' => $sDateStart,
|
---|
376 | 'campaign_end' => $sDateEnd,
|
---|
377 | 'lhshift' => $banner_lhshift,
|
---|
378 | 'lvshift' => $banner_lvshift,
|
---|
379 | 'rhshift' => $banner_rhshift,
|
---|
380 | 'rvshift' => $banner_rvshift,
|
---|
381 | );
|
---|
382 |
|
---|
383 | if ( $_REQUEST['action'] == 'modify' && $_REQUEST['as_new'] != "on" && $iLastId > 0 ) {
|
---|
384 | $oForm->update($iLastId, $aValsAdd);
|
---|
385 | }
|
---|
386 | if ( $_REQUEST['action'] == 'new' || $_REQUEST['as_new'] == "on" && $_REQUEST['action'] == 'modify' ) {
|
---|
387 | $iLastId = $oForm->insert($aValsAdd);
|
---|
388 | }
|
---|
389 |
|
---|
390 | $sResult = ($iLastId > 0) ? MsgBox(_t('_Success'), 3) : MsgBox($sErrorC);
|
---|
391 | }
|
---|
392 |
|
---|
393 | return DesignBoxContent(_t('_adm_bann_title'), $sResult . $oForm->getCode(), 1);
|
---|
394 | }
|
---|
395 |
|
---|
396 | ?>
|
---|