Cheetah
banners.php
Go to the documentation of this file.
1 <?php
2 
8 define('CH_SECURITY_EXCEPTIONS', true);
10  'POST.Text',
11  'REQUEST.Text',
12  'POST.Url',
13  'REQUEST.Url',
14 );
15 
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' );
20 
21 $logged['admin'] = member_auth(1, true, true);
22 
23 //Possible deletion
24 $iBannerID = (int)ch_get('banner_id');
25 if ( $iBannerID > 0 && ch_get('action') == "delete" ) {
26  db_res( "DELETE FROM `sys_banners` WHERE ID = '{$iBannerID}'" );
27 }
28 
32 
33 ch_import('ChTemplFormView');
34 
36 $_page = array(
37  'name_index' => $iNameIndex,
38  'header' => _t('_adm_bann_title'),
39  'header_text' => _t('_adm_bann_title')
40 );
41 
43 
45 
46 // Functions
48 {
49  $sPreview = MsgBox(_t('_Empty'));
50 
51  if (getGetFieldIfSet('action') == 'preview' && $iBannerID > 0) {
52  $aBannerInfo = db_arr("SELECT * FROM `sys_banners` WHERE `ID` = '{$iBannerID}'");
53  $sBannerTitle = process_line_output($aBannerInfo['Title']);
54  $sBannerPut = banner_put($aBannerInfo['ID'], 0);
55 
56  $sPreview = <<<EOF
57 <table cellspacing="0" cellpadding="0" width="100%" height="200" align="center" style="border: 1px solid #ccc;">
58  {$sBannerTitle}
59  <tr><td align=center bgcolor=white>{$sBannerPut}</td></tr>
60 </table>
61 EOF;
62  $sResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $sPreview));
63  return DesignBoxContent(_t('_Preview'), $sResult, 1);
64  }
65 }
66 
68 {
69  $sClicksC = _t('_adm_bann_clicks');
70  $sImpressionsC = _t('_adm_bann_impressions');
71  $sPreviewC = _t('_Preview');
72  $sEditC = _t('_Edit');
73  $sDeleteC = _t('_Delete');
74 
75  // Get banner info from database.
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']}'");
83 
84  $class = ( !$banns_arr['Active'] ) ? 'table_err' : 'panel';
85  $sBannerTitle = process_line_output($banns_arr['Title']);
86 
87  $sExistedBanners .= <<<EOF
88 <tr class={$class}>
89  <td>
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>)&nbsp;
93  {$sBannerTitle}
94  </a>
95  </td>
96  <td><b>{$clicks[0]}</b> {$sClicksC} </td>
97  <td><b>{$imp[0]}</b> {$sImpressionsC} </td>
98 </tr>
99 EOF;
100  }
101  $sExistedBanners .= "</table>";
102  }
103 
104  $sResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $sExistedBanners));
105  return DesignBoxContent(_t('_adm_mmi_banners'), $sResult, 11);
106 }
107 
109 {
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');
120  $sUrlC = _t('_URL');
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');
126 
127  // get start & end dates
128  $start_date_default = "2012-01-01";
129  $end_date_default = "2020-01-01";
130 
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;
133 
134  $Title = $Url = $Active = $Text = $Position = $lhshift = $lvshift = $rhshift = $rvshift = '';
135  $iBannerID = (int)getGetFieldIfSet('banner_id');
136  $action = "new";
137 
138  if ($iBannerID > 0 && ! strlen(ch_get('action'))) { //banner edit
139  $banns_arr = db_arr("SELECT * FROM `sys_banners` WHERE `ID`='{$iBannerID}'");
140 
141  $action = "modify";
142 
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'];
148 
149  $lhshift = $banns_arr['lhshift'];
150  $lvshift = $banns_arr['lvshift'];
151  $rhshift = $banns_arr['rhshift'];
152  $rvshift = $banns_arr['rvshift'];
153 
154 
155  $start_date = $banns_arr['campaign_start'];
156  $end_date = $banns_arr['campaign_end'];
157  }
158 
159  $sFormTitle = htmlspecialchars($Title);
160  $sFormUrl = htmlspecialchars($Url);
161  $sFormActiveState = ($Active) ? 'checked="checked"' : '';
162 
163  $sFormActiveStateVal = ($Active) ? 'yes' : '';
164  $sFormActiveStateChk = ($Active) ? true : false;
165 
166  $sFormBannerText = $Text;
167  $sFormStartDate = $start_date;
168  $sFormEndDate = $end_date;
169 
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"' : '';
174 
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 : '';
179 
180  $sActionAdd = ($action == "modify") ? $sAsNew . '&nbsp;<input type=checkbox name=as_new />' : '';
181 
182  $sCustomPositions = <<<EOF
183 <style>
184 .banner-positions td {
185  border:none;
186 }
187 </style>
188 <table class="banner-positions" border=0 width=100% cellspacing=10 cellpading=20>
189  <tr>
190  <td colspan=5 align=center><input type=checkbox name="pos_top" {$sTopPosState} />{$sTopC}</td>
191  </tr>
192  <tr>
193  <td colspan=2 align=center><input type=checkbox name="pos_left" {$sLeftPosState} />{$sLeftC}</td>
194  <td>&nbsp;</td>
195  <td colspan=2 align=center><input type=checkbox name="pos_right" {$sRightPosState} />{$sRightC}</td>
196  </tr>
197  <tr>
198  <td>{$sHShiftC}</td>
199  <td>{$sVShiftC}</td>
200  <td>&nbsp;</td>
201  <td>{$sHShiftC}</td>
202  <td>{$sVShiftC}</td>
203  </tr>
204  <tr>
205  <td><input name="lhshift" type=input size=5 value={$sTopShift} /></td>
206  <td><input name="lvshift" type=input size=5 value={$sLeftShift} /></td>
207  <td>&nbsp;</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>
210  </tr>
211  <tr>
212  <td colspan=5 align=center><input type=checkbox name="pos_bottom" {$sBottomPosState} />{$sBottomC}</td>
213  </tr>
214 </table>
215 {$sActionAdd}
216 EOF;
217 
218  $aForm = array(
219  'form_attrs' => array(
220  'name' => 'apply_ip_list_form',
221  'action' => $GLOBALS['site']['url_admin'] . 'banners.php',
222  'method' => 'post',
223  ),
224  'params' => array (
225  'db' => array(
226  'table' => 'sys_banners',
227  'key' => 'ID',
228  'submit_name' => 'add_button',
229  ),
230  ),
231  'inputs' => array(
232  'BannerTitle' => array(
233  'type' => 'text',
234  'name' => 'Title',
235  'value' => $sFormTitle,
236  'caption' => $sTitleC,
237  'required' => true,
238  'checker' => array (
239  'func' => 'length',
240  'params' => array(2,128),
241  'error' => _t('_chars_to_chars', 2, 128),
242  ),
243  'db' => array (
244  'pass' => 'Xss',
245  ),
246  ),
247  'BannerUrl' => array(
248  'type' => 'text',
249  'name' => 'Url',
250  'value' => $sFormUrl,
251  'caption' => $sUrlC,
252  'required' => false,
253  'db' => array (
254  'pass' => 'Xss',
255  ),
256  ),
257  'BannerActive' => array(
258  'type' => 'checkbox',
259  'name' => 'Active',
260  'caption' => $sActiveC,
261  'value' => 1,
262  'checked' => $sFormActiveStateChk,
263  ),
264  'BannerText' => array(
265  'type' => 'textarea',
266  'name' => 'Text',
267  'value' => $sFormBannerText,
268  'caption' => $sTextC,
269  'required' => true,
270  'checker' => array (
271  'func' => 'length',
272  'params' => array(10,32000),
273  'error' => _t('_chars_to_chars', 10, 32000),
274  ),
275  'db' => array (
276  'pass' => 'All',
277  ),
278  ),
279  'StartDate' => array(
280  'type' => 'date',
281  'name' => 'start_date',
282  'value' => $sFormStartDate,
283  'caption' => $sStartDateC,
284  'required' => true,
285  'checker' => array (
286  'func' => 'Date',
287  'error' => $sErrorC,
288  ),
289  ),
290  'EndDate' => array(
291  'type' => 'date',
292  'name' => 'end_date',
293  'value' => $sFormEndDate,
294  'caption' => $sEndDateC,
295  'required' => true,
296  'checker' => array (
297  'func' => 'Date',
298  'error' => $sErrorC,
299  ),
300  ),
301  'Positions' => array(
302  'type' => 'custom',
303  'name' => 'Position',
304  'caption' => $sPositionOnPageC,
305  'content' => $sCustomPositions
306  ),
307  'ID' => array(
308  'type' => 'hidden',
309  'name' => 'banner_id',
310  'value' => $iBannerID,
311  ),
312  'Action' => array(
313  'type' => 'hidden',
314  'name' => 'action',
315  'value' => $action,
316  ),
317  'add_button' => array(
318  'type' => 'submit',
319  'name' => 'add_button',
320  'value' => $sApplyChangesC,
321  ),
322  ),
323  );
324 
325  $sResult = '';
327  $oForm->initChecker();
328  if ($oForm->isSubmittedAndValid()) {
329  list($iYearStart, $iMonthStart, $iDayStart) = explode( '-', $oForm->getCleanValue('start_date'));
330  $sDateStart = "{$iYearStart}-{$iMonthStart}-{$iDayStart}";
331 
332  list($iYearEnd, $iMonthEnd, $iDayEnd) = explode( '-', $oForm->getCleanValue('end_date'));
333  $sDateEnd = "{$iYearEnd}-{$iMonthEnd}-{$iDayEnd}";
334 
335  $sCurTime = date("Y-m-d");// 2010-12-31
336 
337  $iLastId = (int)$oForm->getCleanValue('banner_id');
338 
339  $banner_pos = "";
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;
345 
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');
350 
351  $aValsAdd = array (
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,
361  );
362 
363  if ($oForm->getCleanValue('action') == 'modify' && $oForm->getCleanValue('as_new') != "on" && $iLastId > 0 ) {
364  $oForm->update($iLastId, $aValsAdd);
365  }
366  if ($oForm->getCleanValue('action') == 'new' || $oForm->getCleanValue('as_new') == "on" && $oForm->getCleanValue('action') == 'modify' ) {
367  $iLastId = $oForm->insert($aValsAdd);
368  }
369 
370  $sResult = ($iLastId > 0) ? MsgBox(_t('_Success'), 3) : MsgBox($sErrorC);
371  }
372 
373  return DesignBoxContent(_t('_adm_bann_title'), $sResult . $oForm->getCode(), 11);
374 }
ChTemplFormView
Definition: ChTemplFormView.php:11
$Url
$Url
Definition: click.php:16
getManageBannersBlock
getManageBannersBlock()
Definition: banners.php:108
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
getExistedBannersBlock
getExistedBannersBlock()
Definition: banners.php:67
name
Core AllowHostnameUnderscore underscores are not permitted in host most browsers do the right thing when faced with an underscore in the host name
Definition: Core.AllowHostnameUnderscore.txt:11
$sResult
$sResult
Definition: advanced_settings.php:26
$logged
$logged['admin']
Definition: banners.php:21
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ch_get
ch_get($sName)
Definition: utils.inc.php:1664
$_page_cont
$_page_cont[$iNameIndex]['page_main_code']
Definition: banners.php:42
php
getPreviewBlock
getPreviewBlock($iBannerID)
Definition: banners.php:47
banner_put
banner_put($ID=0, $Track=1)
Definition: banners.inc.php:96
$iNameIndex
$iNameIndex
Definition: banners.php:35
a
Filter ExtractStyleBlocks Scope FilterParam ExtractStyleBlocksScope DESCRIPTION< p > If you would like users to be able to define external but only allow them to specify CSS declarations for a specific node and prevent them from fiddling with other use this directive It accepts any valid CSS and will prepend this to any CSS declaration extracted from the document For if this directive is set to< code > selector< code > a
Definition: Filter.ExtractStyleBlocks.Scope.txt:15
$oForm
$oForm
Definition: host_tools.php:42
db_arr
db_arr($query, $bindings=[])
Definition: db.inc.php:76
$_page
$_page
Definition: banners.php:36
table
and distribute a copy of this License along with the Library You may charge a fee for the physical act of transferring a and you may at your option offer warranty protection in exchange for a fee You may modify your copy or copies of the Library or any portion of thus forming a work based on the and copy and distribute such modifications or work under the terms of Section provided that you also meet all of these other than as an argument passed when the facility is then you must make a good faith effort to ensure in the event an application does not supply such function or table
Definition: license.txt:180
$sManageBannersBlock
if( $iBannerID > 0 &&ch_get('action')=="delete") $sManageBannersBlock
Definition: banners.php:29
$sExistedBannersBlock
$sExistedBannersBlock
Definition: banners.php:30
type
if(!defined("USER_STATUS_TYPE")) define("USER_STATUS_TYPE" type
Definition: constants.inc.php:13
PageCodeAdmin
PageCodeAdmin($oTemplate=null)
Definition: admin_design.inc.php:45
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
value
URI Base such as when URI MakeAbsolute is on You may use a non absolute URI for this value
Definition: URI.Base.txt:11
member_auth
member_auth($member=0, $error_handle=true, $bAjx=false)
Definition: admin.inc.php:262
$sPreviewBlock
$sPreviewBlock
Definition: banners.php:31
process_line_output
process_line_output($text, $maxwordlen=100)
Definition: utils.inc.php:328
$action
$action
Definition: index.php:66
getGetFieldIfSet
getGetFieldIfSet($sField)
Definition: utils.inc.php:1966
$iBannerID
$iBannerID
Definition: banners.php:24
db_res
db_res($query, $bindings=[])
Definition: db.inc.php:39
$aForm
$aForm
Definition: forgot.php:43
$aChSecurityExceptions
$aChSecurityExceptions
Definition: banners.php:9
b
el b
Definition: Output.SortAttr.txt:8
DesignBoxContent
DesignBoxContent($title, $content, $db_num=0, $caption_item='', $bottom_item='')
Definition: design.inc.php:78
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10