8 define(
'CH_SECURITY_EXCEPTIONS',
true);
16 require_once(
'../inc/header.inc.php' );
17 require_once( CH_DIRECTORY_PATH_INC .
'design.inc.php' );
18 require_once( CH_DIRECTORY_PATH_INC .
'admin_design.inc.php' );
19 require_once( CH_DIRECTORY_PATH_INC .
'utils.inc.php' );
26 db_res(
"DELETE FROM `sys_banners` WHERE ID = '{$iBannerID}'" );
38 'header' =>
_t(
'_adm_bann_title'),
39 'header_text' =>
_t(
'_adm_bann_title')
52 $aBannerInfo =
db_arr(
"SELECT * FROM `sys_banners` WHERE `ID` = '{$iBannerID}'");
54 $sBannerPut =
banner_put($aBannerInfo[
'ID'], 0);
57 <
table cellspacing=
"0" cellpadding=
"0" width=
"100%" height=
"200" align=
"center" style=
"border: 1px solid #ccc;">
59 <tr><td align=center bgcolor=white>{$sBannerPut}</td></tr>
62 $sResult =
$GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'design_box_content.html', array(
'content' => $sPreview));
69 $sClicksC =
_t(
'_adm_bann_clicks');
70 $sImpressionsC =
_t(
'_adm_bann_impressions');
71 $sPreviewC =
_t(
'_Preview');
72 $sEditC =
_t(
'_Edit');
73 $sDeleteC =
_t(
'_Delete');
76 $banners_res =
db_res(
"SELECT * FROM `sys_banners` ORDER BY `ID` DESC");
77 $sExistedBanners =
MsgBox(
_t(
'_Empty'));
78 if ( $banners_res ->rowCount() ) {
79 $sExistedBanners =
"<table cellspacing=1 cellpadding=2 border=0 class=small1 width=100%>";
80 while ( $banns_arr = $banners_res->fetch() ) {
81 $imp =
db_arr(
"SELECT COUNT(*) FROM `sys_banners_shows` WHERE `ID` = '{$banns_arr['ID']}'");
82 $clicks =
db_arr(
"SELECT COUNT(*) FROM `sys_banners_clicks` WHERE `ID` = '{$banns_arr['ID']}'");
84 $class = ( !$banns_arr[
'Active'] ) ?
'table_err' :
'panel';
87 $sExistedBanners .= <<<EOF
90 (<
a href=
"banners.php?action=preview&banner_id={$banns_arr['ID']}">{$sPreviewC}</
a> |
91 <
a href=
"banners.php?banner_id={$banns_arr['ID']}">{$sEditC}</
a> |
92 <
a href=
"banners.php?banner_id={$banns_arr['ID']}&action=delete">{$sDeleteC}</
a>)
96 <td><
b>{$clicks[0]}</
b> {$sClicksC} </td>
97 <td><
b>{$imp[0]}</
b> {$sImpressionsC} </td>
101 $sExistedBanners .=
"</table>";
104 $sResult =
$GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'design_box_content.html', array(
'content' => $sExistedBanners));
110 $sAsNew =
_t(
'_adm_bann_Insert_as_new');
111 $sErrorC =
_t(
'_Error Occured');
112 $sApplyChangesC =
_t(
'_Submit');
113 $sTopC =
_t(
'_adm_bann_Top');
114 $sLeftC =
_t(
'_adm_bann_Left');
115 $sRightC =
_t(
'_adm_bann_Right');
116 $sBottomC =
_t(
'_adm_bann_Bottom');
117 $sHShiftC =
_t(
'_adm_bann_HShift');
118 $sVShiftC =
_t(
'_adm_bann_VShift');
119 $sTitleC =
_t(
'_Title');
121 $sActiveC =
_t(
'_Active');
122 $sTextC =
_t(
'_Text');
123 $sStartDateC =
_t(
'_Start date');
124 $sEndDateC =
_t(
'_Expiration date');
125 $sPositionOnPageC =
_t(
'_adm_bann_Position_on_the_page');
128 $start_date_default =
"2012-01-01";
129 $end_date_default =
"2020-01-01";
131 $start_date =
ch_get(
'start_date') !==
false ?
ch_get(
'start_date') : $start_date_default;
132 $end_date =
ch_get(
'end_date') !==
false ?
ch_get(
'end_date') : $end_date_default;
134 $Title =
$Url = $Active = $Text = $Position = $lhshift = $lvshift = $rhshift = $rvshift =
'';
139 $banns_arr =
db_arr(
"SELECT * FROM `sys_banners` WHERE `ID`='{$iBannerID}'");
143 $Title = $banns_arr[
'Title'];
144 $Url = $banns_arr[
'Url'];
145 $Text = $banns_arr[
'Text'];
146 $Active = $banns_arr[
'Active'];
147 $Position = $banns_arr[
'Position'];
149 $lhshift = $banns_arr[
'lhshift'];
150 $lvshift = $banns_arr[
'lvshift'];
151 $rhshift = $banns_arr[
'rhshift'];
152 $rvshift = $banns_arr[
'rvshift'];
155 $start_date = $banns_arr[
'campaign_start'];
156 $end_date = $banns_arr[
'campaign_end'];
159 $sFormTitle = htmlspecialchars($Title);
160 $sFormUrl = htmlspecialchars(
$Url);
161 $sFormActiveState = ($Active) ?
'checked="checked"' :
'';
163 $sFormActiveStateVal = ($Active) ?
'yes' :
'';
164 $sFormActiveStateChk = ($Active) ?
true :
false;
166 $sFormBannerText = $Text;
167 $sFormStartDate = $start_date;
168 $sFormEndDate = $end_date;
170 $sTopPosState = (substr_count($Position,
"1") > 0 ) ?
'checked="checked"' :
'';
171 $sLeftPosState = (substr_count($Position,
"2") > 0 ) ?
'checked="checked"' :
'';
172 $sRightPosState = (substr_count($Position,
"3") > 0 ) ?
'checked="checked"' :
'';
173 $sBottomPosState = (substr_count($Position,
"4") > 0 ) ?
'checked="checked"' :
'';
175 $sTopShift = (substr_count($Position,
"2") > 0 ) ? $lhshift :
'';
176 $sLeftShift = (substr_count($Position,
"2") > 0 ) ? $lvshift :
'';
177 $sRightShift = (substr_count($Position,
"3") > 0 ) ? $rhshift :
'';
178 $sBottomShift = (substr_count($Position,
"3") > 0 ) ? $rvshift :
'';
180 $sActionAdd = (
$action ==
"modify") ? $sAsNew .
' <input type=checkbox name=as_new />' :
'';
182 $sCustomPositions = <<<EOF
184 .banner-positions td {
188 <
table class=
"banner-positions" border=0 width=100% cellspacing=10 cellpading=20>
190 <td colspan=5 align=center><input
type=checkbox
name=
"pos_top" {$sTopPosState} />{$sTopC}</td>
193 <td colspan=2 align=center><input
type=checkbox
name=
"pos_left" {$sLeftPosState} />{$sLeftC}</td>
195 <td colspan=2 align=center><input
type=checkbox
name=
"pos_right" {$sRightPosState} />{$sRightC}</td>
205 <td><input
name=
"lhshift" type=input size=5
value={$sTopShift} /></td>
206 <td><input
name=
"lvshift" type=input size=5
value={$sLeftShift} /></td>
208 <td><input
name=
"rhshift" type=input size=5
value={$sRightShift} /></td>
209 <td><input
name=
"rvshift" type=input size=5
value={$sBottomShift} /></td>
212 <td colspan=5 align=center><input
type=checkbox
name=
"pos_bottom" {$sBottomPosState} />{$sBottomC}</td>
219 'form_attrs' => array(
220 'name' =>
'apply_ip_list_form',
221 'action' =>
$GLOBALS[
'site'][
'url_admin'] .
'banners.php',
226 'table' =>
'sys_banners',
228 'submit_name' =>
'add_button',
232 'BannerTitle' => array(
235 'value' => $sFormTitle,
236 'caption' => $sTitleC,
240 'params' => array(2,128),
241 'error' =>
_t(
'_chars_to_chars', 2, 128),
247 'BannerUrl' => array(
250 'value' => $sFormUrl,
257 'BannerActive' => array(
258 'type' =>
'checkbox',
260 'caption' => $sActiveC,
262 'checked' => $sFormActiveStateChk,
264 'BannerText' => array(
265 'type' =>
'textarea',
267 'value' => $sFormBannerText,
268 'caption' => $sTextC,
272 'params' => array(10,32000),
273 'error' =>
_t(
'_chars_to_chars', 10, 32000),
279 'StartDate' => array(
281 'name' =>
'start_date',
282 'value' => $sFormStartDate,
283 'caption' => $sStartDateC,
292 'name' =>
'end_date',
293 'value' => $sFormEndDate,
294 'caption' => $sEndDateC,
301 'Positions' => array(
303 'name' =>
'Position',
304 'caption' => $sPositionOnPageC,
305 'content' => $sCustomPositions
309 'name' =>
'banner_id',
317 'add_button' => array(
319 'name' =>
'add_button',
320 'value' => $sApplyChangesC,
328 if (
$oForm->isSubmittedAndValid()) {
329 list($iYearStart, $iMonthStart, $iDayStart) = explode(
'-',
$oForm->getCleanValue(
'start_date'));
330 $sDateStart =
"{$iYearStart}-{$iMonthStart}-{$iDayStart}";
332 list($iYearEnd, $iMonthEnd, $iDayEnd) = explode(
'-',
$oForm->getCleanValue(
'end_date'));
333 $sDateEnd =
"{$iYearEnd}-{$iMonthEnd}-{$iDayEnd}";
335 $sCurTime = date(
"Y-m-d");
337 $iLastId = (int)
$oForm->getCleanValue(
'banner_id');
340 if(
$oForm->getCleanValue(
'pos_top') ==
"on" ) $banner_pos .=
'1';
341 if(
$oForm->getCleanValue(
'pos_left') ==
"on" ) $banner_pos .=
'2';
342 if(
$oForm->getCleanValue(
'pos_right') ==
"on" ) $banner_pos .=
'3';
343 if(
$oForm->getCleanValue(
'pos_bottom') ==
"on" ) $banner_pos .=
'4';
344 $banner_pos = (int)$banner_pos;
346 $banner_lhshift = (int)
$oForm->getCleanValue(
'lhshift');
347 $banner_lvshift = (int)
$oForm->getCleanValue(
'lvshift');
348 $banner_rhshift = (int)
$oForm->getCleanValue(
'rhshift');
349 $banner_rvshift = (int)
$oForm->getCleanValue(
'rvshift');
352 'Position' => $banner_pos,
353 'Active' =>
'' !=
$oForm->getCleanValue(
'Active') ? 1 : 0,
354 'Created' => $sCurTime,
355 'campaign_start' => $sDateStart,
356 'campaign_end' => $sDateEnd,
357 'lhshift' => $banner_lhshift,
358 'lvshift' => $banner_lvshift,
359 'rhshift' => $banner_rhshift,
360 'rvshift' => $banner_rvshift,
363 if (
$oForm->getCleanValue(
'action') ==
'modify' &&
$oForm->getCleanValue(
'as_new') !=
"on" && $iLastId > 0 ) {
364 $oForm->update($iLastId, $aValsAdd);
366 if (
$oForm->getCleanValue(
'action') ==
'new' ||
$oForm->getCleanValue(
'as_new') ==
"on" &&
$oForm->getCleanValue(
'action') ==
'modify' ) {
367 $iLastId =
$oForm->insert($aValsAdd);