source: trunk/inc/banners.inc.php

Last change on this file was 2, checked in by george, 14 years ago
  • Přidáno: Trunk revize 13719.
File size: 4.1 KB
Line 
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
21require_once("header.inc.php");
22$bann_click_url = BX_DOL_URL_ROOT . "click.php";
23
24function banner_put_nv($Position, $Track = 1) {
25 global $bann_click_url;
26
27 $out = "";
28
29 $query = "SELECT * FROM `sys_banners` WHERE `Active` <> 0 AND `campaign_start` <= NOW() AND `campaign_end` >= NOW() ";
30
31 switch($Position) {
32 case 1:
33 case 2:
34 case 3:
35 case 4:
36 $query .= " AND `Position` LIKE '%{$Position}%' ";
37 break;
38 default:
39 return '';
40 }
41
42 $query .= "ORDER BY RAND() LIMIT 1";
43
44 $arr = db_arr( $query );
45
46 if ( !$arr[0] )
47 return '';
48
49 switch ($Position) {
50 case 2:
51 $hshift = $arr['lhshift'];
52 $vshift = $arr['lvshift'];
53 break;
54 case 3:
55 $hshift = $arr['rhshift'];
56 $vshift = $arr['rvshift'];
57 break;
58 }
59
60 $arr['Text'] = html_entity_decode($arr['Text']);
61
62 $sLinkWrapper = $arr['Url'] ? "<a target=\"_blank\" href=\"{$bann_click_url}?{$arr['ID']}\" onmouseout=\"ce()\" onfocus=\"ss('{$arr['Url']}')\" onmouseover=\"return ss('{$arr['Url']}')\">{$arr['Text']}</a><br />" : $arr['Text'];
63
64 if( $Position == 2 || $Position == 3 ) {
65 $sPosition = ($Position == 2) ? "left:" : "right:";
66
67$out .= <<<EOF
68<div style="position:relative; margin:0; padding:0; width:1px; height:1px">
69 <div style="position:absolute; {$sPosition}{$hshift}px; top:{$vshift}px; z-index:60">
70 {$sLinkWrapper}
71 </div>
72</div>
73EOF;
74
75 } else {
76 $out .= '<table width="100%" style="padding: 10px 0px 10px 0px;" align="center">' . "\n";
77 $out .= <<<EOF
78 <tr>
79 <td align="center">
80 {$sLinkWrapper}
81 </td>
82 </tr>
83</table>
84EOF;
85 }
86
87 if ( $Track ) {
88 db_res("INSERT INTO `sys_banners_shows` SET `ID` = {$arr['ID']}, `Date` = '".time()."', `IP` = '". $_SERVER['REMOTE_ADDR'] ."'", 0);
89 }
90
91 switch($Position) {
92 /*case 1:
93 $out = '' . $out . '';
94 break;*/
95 case 2:
96 $out = '<div style="position:absolute;top:0px;left:0px;width:1px;height:1px;">' . $out . '</div>';
97 break;
98 case 3:
99 $out = '<div style="position:absolute;top:0px;right:0px;width:1px;height:1px;">' . $out . '</div>';
100 break;
101 /*case 4:
102 $out = '' . $out . '';
103 break;*/
104 }
105 return $out;
106}
107
108function banner_put($ID = 0, $Track = 1) {
109 global $bann_click_url;
110
111 if ( !$ID ) {
112 // Get only banners that are active and for which promotion period has not expired.
113 $bann_arr = db_arr("SELECT `ID`, `Url`, `Text` FROM `sys_banners` WHERE `Active` <> 0 AND `campaign_start` <= NOW() AND `campaign_end` >= NOW() ORDER BY RAND() LIMIT 1");
114 } else {
115 $bann_arr = db_arr("SELECT `ID`, `Url`, `Text` FROM `sys_banners` WHERE `ID` = $ID LIMIT 1");
116 }
117 if ( !$bann_arr )
118 return "";
119
120 if ( $Track ) {
121 db_res("INSERT INTO `sys_banners_shows` SET `ID` = {$bann_arr['ID']}, `Date` = '".time()."', `IP` = '". $_SERVER['REMOTE_ADDR']. "'", 0);
122 }
123
124 $bann_arr['Text'] = html_entity_decode($bann_arr['Text']);
125 $sOutputCode = $bann_arr['Url'] ? "<a target=\"_blank\" href=\"{$bann_click_url}?{$bann_arr['ID']}\" onmouseout=\"ce()\" onfocus=\"ss('{$bann_arr['Url']}')\" onmouseover=\"return ss('{$bann_arr['Url']}')\">{$bann_arr['Text']}</a>" : $bann_arr['Text'];
126
127 return $sOutputCode;
128}
129
130?>
Note: See TracBrowser for help on using the repository browser.