| [ Index ] | PHP Cross Reference of Mambo 4.6.5 |
|
| [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Mambo 4 * @subpackage Banners 5 * @author Mambo Foundation Inc see README.php 6 * @copyright (C) 2000 - 2009 Mambo Foundation Inc. 7 * See COPYRIGHT.php for copyright notices and details. 8 * @license GNU/GPL Version 2, see LICENSE.php 9 * 10 * Redistributions of files must retain the above copyright notice. 11 * 12 * Mambo is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation; version 2 of the License. 15 */ 16 17 /** ensure this file is being included by a parent file */ 18 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 19 20 $bid = intval( mosGetParam( $_REQUEST, 'bid', 0 ) ); 21 22 $task = mosGetParam( $_REQUEST, "task", "" ); 23 switch($task) 24 { 25 case "click": 26 clickbanner( $bid ); 27 break; 28 29 default: 30 viewbanner( $mainframe->getCfg( 'live_site' )); 31 break; 32 } 33 34 function viewbanner( $_live_site) { 35 global $database, $mosConfig_live_site; 36 37 $database->setQuery( "SELECT count(*) AS numrows FROM #__banner WHERE showBanner=1" ); 38 39 $numrows = $database->loadResult(); 40 if ($numrows === null) { 41 echo $database->stderr( true ); 42 return; 43 } 44 45 if ($numrows > 1) { 46 mt_srand( (double) microtime()*1000000 ); 47 $bannum = mt_rand( 0, --$numrows ); 48 } else { 49 $bannum = 0; 50 } 51 52 $database->setQuery( "SELECT * FROM #__banner WHERE showBanner=1 LIMIT $bannum,1" ); 53 54 $banner = null; 55 if ($database->loadObject( $banner )) { 56 $database->setQuery( "UPDATE #__banner SET impmade=impmade+1 WHERE bid='$banner->bid'" ); 57 if(!$database->query()) { 58 echo $database->stderr( true ); 59 return; 60 } 61 $banner->impmade++; 62 63 if ($numrows > 0) { 64 // Check if this impression is the last one and print the banner 65 if ($banner->imptotal == $banner->impmade) { 66 $query = "INSERT INTO #__bannerfinish (cid, type, name, impressions, clicks, imageurl, datestart, dateend) 67 VALUES ('$banner->cid', '$banner->type', '$banner->name', '$banner->impmade', '$banner->clicks', '$banner->imageurl', '$banner->date', now())"; 68 $database->setQuery($query); 69 if(!$database->query()) { 70 die($database->stderr(true)); 71 } 72 73 $query="DELETE FROM #__banner WHERE bid=$banner->bid"; 74 $database->setQuery($query); 75 if(!$database->query()) { 76 die($database->stderr(true)); 77 } 78 } 79 80 if (trim( $banner->custombannercode )) { 81 echo $banner->custombannercode; 82 } else if (eregi( "(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$", $banner->imageurl )) { 83 $imageurl = "$mosConfig_live_site/images/banners/$banner->imageurl"; 84 echo "<a href=\"".sefRelToAbs("index.php?option=com_banners&task=click&bid=$banner->bid")."\" target=\"_blank\"><img src=\"$imageurl\" border=\"0\" alt=\"Advertisement\" /></a>"; 85 86 } else if (eregi("\.swf$", $banner->imageurl)) { 87 $imageurl = "$mosConfig_live_site/images/banners/".$banner->imageurl; 88 echo "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" border=\"5\"> 89 <param name=\"movie\" value=\"$imageurl\"><embed src=\"$imageurl\" loop=\"false\" pluginspage=\"http://www.macromedia.com/go/get/flashplayer\" type=\"application/x-shockwave-flash\"></embed></object>"; 90 } 91 } 92 } else { 93 echo " "; 94 } 95 } 96 97 /** 98 /* Function to redirect the clicks to the correct url and add 1 click 99 */ 100 function clickbanner( $bid ) 101 { 102 global $database, $mainframe; 103 require_once( $mainframe->getPath( 'class' ) ); 104 $row = new mosBanner($database); 105 $row->load($bid); 106 $row->clicks(); 107 108 $pat = "http.*://"; 109 if (!eregi( $pat, $row->clickurl )) { 110 $clickurl = "http://$row->clickurl"; 111 } else { 112 $clickurl = $row->clickurl; 113 } 114 mosRedirect( $clickurl ); 115 } 116 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed May 23 00:05:01 2012 | Cross-referenced by PHPXref 0.7 |
| Mambo API: Mambo is Free software released under the GNU/General Public License, Version 2 |