[TEP-COMMIT] [CVS catalog] move the banner functions to a new osC_Banner class
hpdl-OfajU3CKLf1/[email protected] 28 Nov 2004 18:37:14 -0000
| Newsgroups | gmane.comp.web.oscommerce.cvs |
|---|---|
| Message-ID | <[email protected]> |
<html>
<head>
<style><!--
body {background-color:#ffffff;}
.file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
.pathname {font-family:monospace; float:right;}
.fileheader {margin-bottom:.5em;}
.diff {margin:0;}
.tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
.tasklist ul {margin-top:0;margin-bottom:0;}
tr.alt {background-color:#eeeeee}
#added {background-color:#ddffdd;}
#addedchars {background-color:#99ff99;font-weight:bolder;}
tr.alt #added {background-color:#ccf7cc;}
#removed {background-color:#ffdddd;}
#removedchars {background-color:#ff9999;font-weight:bolder;}
tr.alt #removed {background-color:#f7cccc;}
#info {color:#888888;}
#context {background-color:#eeeeee;}
td {padding-left:.3em;padding-right:.3em;}
tr.head {border-bottom-width:1px;border-bottom-style:solid;}
tr.head td {padding:0;padding-top:.2em;}
.task {background-color:#ffff00;}
.comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
.error {color:red;}
hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>catalog/catalog</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt><a href="#file1">redirect.php</a></tt></td><td align="right" id="added">+5</td><td align="right" id="removed">-7</td><td nowrap="nowrap" align="center"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/redirect.php?rev=1.12&content-type=text/vnd.viewcvs-markup">1.12</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/redirect.php.diff?r1=1.12&r2=1.13">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/redirect.php?rev=1.13&content-type=text/vnd.viewcvs-markup">1.13</a></td></tr>
<tr class="alt"><td><tt>includes/<a href="#file2">footer.php</a></tt></td><td align="right" id="added">+2</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/footer.php?rev=1.30&content-type=text/vnd.viewcvs-markup">1.30</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/footer.php.diff?r1=1.30&r2=1.31">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/footer.php?rev=1.31&content-type=text/vnd.viewcvs-markup">1.31</a></td></tr>
<tr><td><tt>includes/classes/<a href="#file3"><span id="added">banner.php</span></a></tt></td><td align="right" id="added">+241</td><td></td><td nowrap="nowrap" align="right">added <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/banner.php?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt>includes/functions/<span id="removed">banner.php</span></tt></td><td></td><td></td><td nowrap="nowrap"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/functions/banner.php?rev=1.14&content-type=text/vnd.viewcvs-markup">1.14</a> removed</td></tr>
<tr><td><tt>includes/modules/services/<a href="#file5">banner.php</a></tt></td><td align="right" id="added">+13</td><td align="right" id="removed">-6</td><td nowrap="nowrap" align="center"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules/services/banner.php?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules/services/banner.php.diff?r1=1.1&r2=1.2">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules/services/banner.php?rev=1.2&content-type=text/vnd.viewcvs-markup">1.2</a></td></tr>
<tr><td></td><td align="right" id="added">+261</td><td align="right" id="removed">-15</td><td></td></tr>
</table>
<small id="info">1 added + 1 removed + 3 modified, total 5 files</small><br />
<pre class="comment">
move the banner functions to a new osC_Banner class
add a banner service module parameter to control if duplicate banners in
the same group should be displayed on the same page or not
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a><br /></span>
<div class="fileheader"><big><b>redirect.php</b></big> <small id="info"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/redirect.php?rev=1.12&content-type=text/vnd.viewcvs-markup">1.12</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/redirect.php.diff?r1=1.12&r2=1.13">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/redirect.php?rev=1.13&content-type=text/vnd.viewcvs-markup">1.13</a></small></div>
<pre class="diff"><small id="info">diff -u -r1.12 -r1.13
--- redirect.php 2004/01/10 20:18:01 1.12
+++ redirect.php 2004/11/28 18:37:10 1.13
@@ -5,7 +5,7 @@
</small></pre><pre class="diff" id="context"> osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
</pre><pre class="diff" id="removed">- Copyright (c) 200<span id="removedchars">3</span> osCommerce
</pre><pre class="diff" id="added">+ Copyright (c) 200<span id="addedchars">4</span> osCommerce
</pre><pre class="diff" id="context">
Released under the GNU General Public License
*/
</pre><pre class="diff"><small id="info">@@ -14,12 +14,10 @@
</small></pre><pre class="diff" id="context">
switch ($_GET['action']) {
case 'banner':
</pre><pre class="diff" id="removed">- $banner_query = tep_db_query("select banners_url from " . TABLE_BANNERS . " where banners_id = '" . (int)$_GET['goto'] . "'");
- if (tep_db_num_rows($banner_query)) {
- $banner = tep_db_fetch_array($banner_query);
- tep_update_banner_click_count($_GET['goto']);
-
- tep_redirect($banner['banners_url']);
</pre><pre class="diff" id="added">+ if (isset($_GET['goto']) && is_numeric($_GET['goto'])) {
+ if ($osC_Services->isStarted('banner') && $osC_Banner->isActive($_GET['goto'])) {
+ tep_redirect($osC_Banner->getURL($_GET['goto'], true));
+ }
</pre><pre class="diff" id="context"> }
break;
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a><br /></span>
<div class="fileheader"><big><b>footer.php</b></big> <small id="info"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/footer.php?rev=1.30&content-type=text/vnd.viewcvs-markup">1.30</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/footer.php.diff?r1=1.30&r2=1.31">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/footer.php?rev=1.31&content-type=text/vnd.viewcvs-markup">1.31</a></small></div>
<pre class="diff"><small id="info">diff -u -r1.30 -r1.31
--- footer.php 2004/11/24 15:55:04 1.30
+++ footer.php 2004/11/28 18:37:11 1.31
@@ -43,12 +43,12 @@
</small></pre><pre class="diff" id="context"> </tr>
</table>
<?php
</pre><pre class="diff" id="removed">- if ($osC_Services->isStarted('banner') && ($banner = tep_banner_exists('dynamic', '468x50'))) {
</pre><pre class="diff" id="added">+ if ($osC_Services->isStarted('banner') && $osC_Banner->exists('468x50')) {
</pre><pre class="diff" id="context"> ?>
<br>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
</pre><pre class="diff" id="removed">- <td align="center"><?php echo tep_display_banner('dynamic', '468x50'); ?></td>
</pre><pre class="diff" id="added">+ <td align="center"><?php echo $osC_Banner->display(); ?></td>
</pre><pre class="diff" id="context"> </tr>
</table>
<?php
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname" id="added"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes">classes</a><br /></span>
<div class="fileheader" id="added"><big><b>banner.php</b></big> <small id="info">added at <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/banner.php?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N banner.php
--- /dev/null Sun Nov 28 19:37:11 2004
+++ /tmp/cvsAAABXaqIO Sun Nov 28 19:37:12 2004
@@ -0,0 +1,241 @@
</small></pre><pre class="diff" id="added">+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2004 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ class osC_Banner {
+
+/* Public variables */
+ var $show_duplicates_in_group = false;
+
+/* Private variables */
+ var $_exists_id,
+ $_shown_ids = array();
+
+/* Class constructor */
+
+ function osC_Banner() {
+ if (SERVICE_BANNER_SHOW_DUPLICATE == 'True') {
+ $this->show_duplicates_in_group = true;
+ }
+ }
+
+/* Public methods */
+
+ function activate($id) {
+ $this->_setStatus($id, true);
+ }
+
+ function activateAll() {
+ global $osC_Database;
+
+ $Qbanner = $osC_Database->query('select banners_id, date_scheduled from :table_banners where date_scheduled != ""');
+ $Qbanner->bindTable(':table_banners', TABLE_BANNERS);
+ $Qbanner->execute();
+
+ if ($Qbanner->numberOfRows() > 0) {
+ while ($Qbanner->next()) {
+ if (date('Y-m-d H:i:s') >= $Qbanner->value('date_scheduled')) {
+ $this->activate($Qbanner->valueInt('banners_id'));
+ }
+ }
+ }
+
+ $Qbanner->freeResult();
+ }
+
+ function expire($id) {
+ $this->_setStatus($id, false);
+ }
+
+ function expireAll() {
+ global $osC_Database;
+
+ $Qbanner = $osC_Database->query('select b.banners_id, b.expires_date, b.expires_impressions, sum(bh.banners_shown) as banners_shown from :table_banners b, :table_banners_history bh where b.status = 1 and b.banners_id = bh.banners_id group by b.banners_id');
+ $Qbanner->bindTable(':table_banners', TABLE_BANNERS);
+ $Qbanner->bindTable(':table_banners_history', TABLE_BANNERS_HISTORY);
+ $Qbanner->execute();
+
+ if ($Qbanner->numberOfRows() > 0) {
+ while ($Qbanner->next()) {
+ if (tep_not_null($Qbanner->value('expires_date'))) {
+ if (date('Y-m-d H:i:s') >= $Qbanner->value('expires_date')) {
+ $this->expire($Qbanner->valueInt('banners_id'));
+ }
+ } elseif (tep_not_null($Qbanner->valueInt('expires_impressions'))) {
+ if ( ($Qbanner->valueInt('expires_impressions') > 0) && ($Qbanner->valueInt('banners_shown') >= $Qbanner->valueInt('expires_impressions')) ) {
+ $this->expire($Qbanner->valueInt('banners_id'));
+ }
+ }
+ }
+ }
+
+ $Qbanner->freeResult();
+ }
+
+ function isActive($id) {
+ global $osC_Database;
+
+ $Qbanner = $osC_Database->query('select banners_id from :table_banners where status = 1 and banners_id = :banners_id');
+ $Qbanner->bindTable(':table_banners', TABLE_BANNERS);
+ $Qbanner->bindInt(':banners_id', $id);
+ $Qbanner->execute();
+
+ if ($Qbanner->numberOfRows() > 0) {
+ return true;
+ }
+
+ return false;
+ }
+
+ function exists($group) {
+ global $osC_Database;
+
+ $Qbanner = $osC_Database->query('select banners_id from :table_banners where status = 1 and banners_group = :banners_group');
+
+ if ( ($this->show_duplicates_in_group === false) && (sizeof($this->_shown_ids) > 0) ) {
+ $Qbanner->appendQuery('and banners_id not in (:banner_ids)');
+ $Qbanner->bindRaw(':banner_ids', implode(',', $this->_shown_ids));
+ }
+
+ $Qbanner->bindTable(':table_banners', TABLE_BANNERS);
+ $Qbanner->bindValue(':banners_group', $group);
+ $Qbanner->executeRandom();
+
+ if ($Qbanner->numberOfRows() > 0) {
+ $this->_exists_id = $Qbanner->valueInt('banners_id');
+
+ return true;
+ }
+
+ return false;
+ }
+
+ function display($id = '') {
+ global $osC_Database;
+
+ $banner_string = false;
+
+ if (empty($id) && isset($this->_exists_id) && is_numeric($this->_exists_id)) {
+ $id = $this->_exists_id;
+
+ unset($this->_exists_id);
+ }
+
+ $Qbanner = $osC_Database->query('select * from :table_banners where banners_id = :banners_id and status = 1');
+ $Qbanner->bindTable(':table_banners', TABLE_BANNERS);
+ $Qbanner->bindInt(':banners_id', $id);
+ $Qbanner->execute();
+
+ if ($Qbanner->numberOfRows() > 0) {
+ if (tep_not_null($Qbanner->value('banners_html_text'))) {
+ $banner_string = $Qbanner->value('banners_html_text');
+ } else {
+ $banner_string = '<a href="' . tep_href_link(FILENAME_REDIRECT, 'action=banner&goto=' . $Qbanner->valueInt('banners_id')) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $Qbanner->value('banners_image'), $Qbanner->value('banners_title')) . '</a>';
+ }
+
+ $this->_updateDisplayCount($Qbanner->valueInt('banners_id'));
+
+ if ($this->show_duplicates_in_group === false) {
+ $this->_shown_ids[] = $Qbanner->valueInt('banners_id');
+ }
+ }
+
+ $Qbanner->freeResult();
+
+ return $banner_string;
+ }
+
+ function getURL($id, $increment_click = false) {
+ global $osC_Database;
+
+ $url = false;
+
+ $Qbanner = $osC_Database->query('select banners_url from :table_banners where banners_id = :banners_id and status = 1');
+ $Qbanner->bindTable(':table_banners', TABLE_BANNERS);
+ $Qbanner->bindInt(':banners_id', $id);
+ $Qbanner->execute();
+
+ if ($Qbanner->numberOfRows() > 0) {
+ $url = $Qbanner->value('banners_url');
+
+ if ($increment_click === true) {
+ $this->_updateClickCount($id);
+ }
+ }
+
+ $Qbanner->freeResult();
+
+ return $url;
+ }
+
+/* Private methods */
+
+ function _setStatus($id, $active) {
+ global $osC_Database;
+
+ if ($active === true) {
+ $Qbanner = $osC_Database->query('update :table_banners set status = 1, date_status_change = now(), date_scheduled = NULL where banners_id = :banners_id');
+ $Qbanner->bindTable(':table_banners', TABLE_BANNERS);
+ $Qbanner->bindInt(':banners_id', $id);
+ $Qbanner->execute();
+ } else {
+ $Qbanner = $osC_Database->query('update :table_banners set status = 0, date_status_change = now() where banners_id = :banners_id');
+ $Qbanner->bindTable(':table_banners', TABLE_BANNERS);
+ $Qbanner->bindInt(':banners_id', $id);
+ $Qbanner->execute();
+ }
+
+ $Qbanner->freeResult();
+ }
+
+ function _updateDisplayCount($id) {
+ global $osC_Database;
+
+ $Qcheck = $osC_Database->query('select count(*) as count from :table_banners_history where banners_id = :banners_id and date_format(banners_history_date, "%Y%m%d") = date_format(now(), "%Y%m%d")');
+ $Qcheck->bindTable(':table_banners_history', TABLE_BANNERS_HISTORY);
+ $Qcheck->bindInt(':banners_id', $id);
+ $Qcheck->execute();
+
+ if ($Qcheck->valueInt('count') > 0) {
+ $Qbanner = $osC_Database->query('update :table_banners_history set banners_shown = banners_shown + 1 where banners_id = :banners_id and date_format(banners_history_date, "%Y%m%d") = date_format(now(), "%Y%m%d")');
+ } else {
+ $Qbanner = $osC_Database->query('insert into :table_banners_history (banners_id, banners_shown, banners_history_date) values (:banners_id, 1, now())');
+ }
+ $Qbanner->bindTable(':table_banners_history', TABLE_BANNERS_HISTORY);
+ $Qbanner->bindInt(':banners_id', $id);
+ $Qbanner->execute();
+
+ $Qcheck->freeResult();
+ $Qbanner->freeResult();
+ }
+
+ function _updateClickCount($id) {
+ global $osC_Database;
+
+ $Qcheck = $osC_Database->query('select count(*) as count from :table_banners_history where banners_id = :banners_id and date_format(banners_history_date, "%Y%m%d") = date_format(now(), "%Y%m%d")');
+ $Qcheck->bindTable(':table_banners_history', TABLE_BANNERS_HISTORY);
+ $Qcheck->bindInt(':banners_id', $id);
+ $Qcheck->execute();
+
+ if ($Qcheck->valueInt('count') > 0) {
+ $Qbanner = $osC_Database->query('update :table_banners_history set banners_clicked = banners_clicked + 1 where banners_id = :banners_id and date_format(banners_history_date, "%Y%m%d") = date_format(now(), "%Y%m%d")');
+ } else {
+ $Qbanner = $osC_Database->query('insert into :table_banners_history (banners_id, banners_clicked, banners_history_date) values (:banners_id, 1, now())');
+ }
+ $Qbanner->bindTable(':table_banners_history', TABLE_BANNERS_HISTORY);
+ $Qbanner->bindInt(':banners_id', $id);
+ $Qbanner->execute();
+
+ $Qcheck->freeResult();
+ $Qbanner->freeResult();
+ }
+ }
+?>
</pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname" id="removed"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/functions">functions</a><br /></span>
<div class="fileheader" id="removed"><big><b>banner.php</b></big> <small id="info">removed after <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/functions/banner.php?rev=1.14&content-type=text/vnd.viewcvs-markup">1.14</a></small></div>
<pre class="diff"><small id="info">diff -N banner.php
--- /tmp/cvsAAAk7aiJO Sun Nov 28 19:37:12 2004
+++ /dev/null Sun Nov 28 19:37:11 2004
@@ -1,182 +0,0 @@
</small></pre><pre class="diff" id="removed">-<?php
-/*
- $Id$
-
- osCommerce, Open Source E-Commerce Solutions
- http://www.oscommerce.com
-
- Copyright (c) 2004 osCommerce
-
- Released under the GNU General Public License
-*/
-
-////
-// Sets the status of a banner
- function tep_set_banner_status($banners_id, $status) {
- global $osC_Database;
-
- if ($status == '1') {
- $Qbanner = $osC_Database->query('update :table_banners set status = 1, date_status_change = now(), date_scheduled = NULL where banners_id = :banners_id');
- $Qbanner->bindRaw(':table_banners', TABLE_BANNERS);
- $Qbanner->bindInt(':banners_id', $banners_id);
- $Qbanner->execute();
- } else {
- $Qbanner = $osC_Database->query('update :table_banners set status = 0, date_status_change = now() where banners_id = :banners_id');
- $Qbanner->bindRaw(':table_banners', TABLE_BANNERS);
- $Qbanner->bindInt(':banners_id', $banners_id);
- $Qbanner->execute();
- }
-
- $Qbanner->freeResult();
- }
-
-////
-// Auto activate banners
- function tep_activate_banners() {
- global $osC_Database;
-
- $Qbanner = $osC_Database->query('select banners_id, date_scheduled from :table_banners where date_scheduled != ""');
- $Qbanner->bindRaw(':table_banners', TABLE_BANNERS);
- $Qbanner->execute();
-
- if ($Qbanner->numberOfRows()) {
- while ($Qbanner->next()) {
- if (date('Y-m-d H:i:s') >= $Qbanner->value('date_scheduled')) {
- tep_set_banner_status($Qbanner->valueInt('banners_id'), '1');
- }
- }
- }
-
- $Qbanner->freeResult();
- }
-
-////
-// Auto expire banners
- function tep_expire_banners() {
- global $osC_Database;
-
- $Qbanner = $osC_Database->query('select b.banners_id, b.expires_date, b.expires_impressions, sum(bh.banners_shown) as banners_shown from :table_banners b, :table_banners_history bh where b.status = 1 and b.banners_id = bh.banners_id group by b.banners_id');
- $Qbanner->bindRaw(':table_banners', TABLE_BANNERS);
- $Qbanner->bindRaw(':table_banners_history', TABLE_BANNERS_HISTORY);
- $Qbanner->execute();
-
- if ($Qbanner->numberOfRows()) {
- while ($Qbanner->next()) {
- if (tep_not_null($Qbanner->value('expires_date'))) {
- if (date('Y-m-d H:i:s') >= $Qbanner->value('expires_date')) {
- tep_set_banner_status($Qbanner->valueInt('banners_id'), '0');
- }
- } elseif (tep_not_null($Qbanner->valueInt('expires_impressions'))) {
- if ( ($Qbanner->valueInt('expires_impressions') > 0) && ($Qbanner->valueInt('banners_shown') >= $Qbanner->valueInt('expires_impressions')) ) {
- tep_set_banner_status($Qbanner->valueInt('banners_id'), '0');
- }
- }
- }
- }
-
- $Qbanner->freeResult();
- }
-
-////
-// Display a banner from the specified group or banner id ($identifier)
- function tep_display_banner($action, $identifier) {
- global $osC_Database;
-
- if ($action == 'dynamic') {
- $Qbannercheck = $osC_Database->query('select count(*) as count from :table_banners where status = 1 and banners_group = :banners_group');
- $Qbannercheck->bindRaw(':table_banners', TABLE_BANNERS);
- $Qbannercheck->bindValue(':banners_group', $identifier);
- $Qbannercheck->execute();
-
- if ($Qbannercheck->valueInt('count') > 0) {
- $Qbanner = $osC_Database->query('select banners_id, banners_title, banners_image, banners_html_text from :table_banners where banners_group = :banners_group and status = 1');
- $Qbanner->bindRaw(':table_banners', TABLE_BANNERS);
- $Qbanner->bindValue(':banners_group', $identifier);
- $Qbanner->executeRandom();
- }
-
- $Qbannercheck->freeResult();
- } elseif ($action == 'static') {
- $Qbanner = $osC_Database->query('select banners_id, banners_title, banners_image, banners_html_text from :table_banners where banners_id = :banners_id and status = 1');
- $Qbanner->bindRaw(':table_banners', TABLE_BANNERS);
- $Qbanner->bindInt(':banners_id', $identifier);
- $Qbanner->execute();
- }
-
- if ($Qbanner->numberOfRows() === 1) {
- if (tep_not_null($Qbanner->value('banners_html_text'))) {
- $banner_string = $Qbanner->value('banners_html_text');
- } else {
- $banner_string = '<a href="' . tep_href_link(FILENAME_REDIRECT, 'action=banner&goto=' . $Qbanner->valueInt('banners_id')) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $Qbanner->value('banners_image'), $Qbanner->value('banners_title')) . '</a>';
- }
-
- tep_update_banner_display_count($Qbanner->valueInt('banners_id'));
-
- $Qbanner->freeResult();
-
- return $banner_string;
- } else {
- return false;
- }
- }
-
-////
-// Check to see if a banner exists
- function tep_banner_exists($action, $identifier) {
- global $osC_Database;
-
- if ($action == 'dynamic') {
- $Qbanner = $osC_Database->query('select banners_id, banners_title, banners_image, banners_html_text from :table_banners where status = 1 and banners_group = :banners_group');
- $Qbanner->bindRaw(':table_banners', TABLE_BANNERS);
- $Qbanner->bindValue(':banners_group', $identifier);
- $Qbanner->executeRandom();
- } else {
- $Qbanner = $osC_Database->query('select banners_id, banners_title, banners_image, banners_html_text from :table_banners where status = 1 and banners_id = :banners_id');
- $Qbanner->bindRaw(':table_banners', TABLE_BANNERS);
- $Qbanner->bindInt(':banners_id', $identifier);
- $Qbanner->execute();
- }
-
- if ($Qbanner->numberOfRows()) {
- return true;
- } else {
- return false;
- }
- }
-
-////
-// Update the banner display statistics
- function tep_update_banner_display_count($banner_id) {
- global $osC_Database;
-
- $Qbannercheck = $osC_Database->query('select count(*) as count from :table_banners_history where banners_id = :banners_id and date_format(banners_history_date, "%Y%m%d") = date_format(now(), "%Y%m%d")');
- $Qbannercheck->bindRaw(':table_banners_history', TABLE_BANNERS_HISTORY);
- $Qbannercheck->bindInt(':banners_id', $banner_id);
- $Qbannercheck->execute();
-
- if ($Qbannercheck->valueInt('count') > 0) {
- $Qbanner = $osC_Database->query('update :table_banners_history set banners_shown = banners_shown + 1 where banners_id = :banners_id and date_format(banners_history_date, "%Y%m%d") = date_format(now(), "%Y%m%d")');
- } else {
- $Qbanner = $osC_Database->query('insert into :table_banners_history (banners_id, banners_shown, banners_history_date) values (:banners_id, 1, now())');
- }
- $Qbanner->bindRaw(':table_banners_history', TABLE_BANNERS_HISTORY);
- $Qbanner->bindInt(':banners_id', $banner_id);
- $Qbanner->execute();
-
- $Qbannercheck->freeResult();
- $Qbanner->freeResult();
- }
-
-////
-// Update the banner click statistics
- function tep_update_banner_click_count($banner_id) {
- global $osC_Database;
-
- $Qbanner = $osC_Database->query('update :table_banners_history set banners_clicked = banners_clicked + 1 where banners_id = :banners_id and date_format(banners_history_date, "%Y%m%d") = date_format(now(), "%Y%m%d")');
- $Qbanner->bindRaw(':table_banners_history', TABLE_BANNERS_HISTORY);
- $Qbanner->bindInt(':banners_id', $banner_id);
- $Qbanner->execute();
-
- $Qbanner->freeResult();
- }
-?>
<hr /><a name="file5" /><div class="file">
<span class="pathname"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules">modules</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules/services">services</a><br /></span>
<div class="fileheader"><big><b>banner.php</b></big> <small id="info"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules/services/banner.php?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules/services/banner.php.diff?r1=1.1&r2=1.2">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules/services/banner.php?rev=1.2&content-type=text/vnd.viewcvs-markup">1.2</a></small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- banner.php 2004/04/13 08:02:18 1.1
+++ banner.php 2004/11/28 18:37:12 1.2
@@ -18,11 +18,14 @@
</small></pre><pre class="diff" id="context"> $preceeds;
function start() {
</pre><pre class="diff" id="removed">- include('includes/functions/banner.php');
</pre><pre class="diff" id="added">+ global $osC_Banner;
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- tep_activate_banners();
- tep_expire_banners();
</pre><pre class="diff" id="added">+ require('includes/classes/banner.php');
+ $osC_Banner = new osC_Banner();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="added">+ $osC_Banner->activateAll();
+ $osC_Banner->expireAll();
+
</pre><pre class="diff" id="context"> return true;
}
</pre><pre class="diff"><small id="info">@@ -31,15 +34,19 @@
</small></pre><pre class="diff" id="context"> }
function install() {
</pre><pre class="diff" id="removed">- return false;
</pre><pre class="diff" id="added">+ global $osC_Database;
+
+ $osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Display Duplicate Banners', 'SERVICE_BANNER_SHOW_DUPLICATE', 'False', 'Show duplicate banners in the same banner group on the same page?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
</pre><pre class="diff" id="context"> }
function remove() {
</pre><pre class="diff" id="removed">- return false;
</pre><pre class="diff" id="added">+ global $osC_Database;
+
+ $osC_Database->simpleQuery("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
</pre><pre class="diff" id="context"> }
function keys() {
</pre><pre class="diff" id="removed">- return false;
</pre><pre class="diff" id="added">+ return array('SERVICE_BANNER_SHOW_DUPLICATE');
</pre><pre class="diff" id="context"> }
}
?>
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -> email">CVSspam</a> 0.2.9</small></center>
</body></html>
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/