Source for file mod_banners.php

Documentation is available at mod_banners.php

  1. <?php
  2. /**
  3. @package Mambo
  4. @author Mambo Foundation Inc see README.php
  5. @copyright Mambo Foundation Inc.
  6. *  See COPYRIGHT.php for copyright notices and details.
  7. @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see
  8. *  LICENSE.php
  9. *  Mambo is free software; you can redistribute it and/or
  10. *  modify it under the terms of the GNU General Public License
  11. *  as published by the Free Software Foundation; version 2 of the
  12. *  License.
  13. */
  14.  
  15. /** ensure this file is being included by a parent file */
  16. defined'_VALID_MOS' or die'Direct Access to this location is not allowed.' );
  17.  
  18. $clientids $params->get'banner_cids''' );
  19. $where '';
  20. if$clientids <> '' {
  21.     $where "\nAND cid in ($clientids)";
  22. }
  23.     
  24. $moduleclass_sfx $params->get'moduleclass_sfx' );
  25.  
  26. $sql "SELECT count(*) AS numrows FROM #__banner WHERE showBanner=1"
  27.     . (($where<>''$where "");
  28. $database->setQuery$sql );
  29.  
  30. $numrows $database->loadResult();
  31. if ($numrows === null{
  32.     echo $database->stderrtrue );
  33.     return;
  34. }
  35.  
  36. if ($numrows 1{
  37.     mt_srand(double) microtime()*1000000 );
  38.     $bannum mt_rand0--$numrows );
  39. else {
  40.     $bannum 0;
  41. }
  42.  
  43. $sql "SELECT * FROM #__banner WHERE showBanner=1 "
  44.     . (($where<>''$where "")
  45.     . "\nLIMIT $bannum,1";
  46. $database->setQuery$sql );
  47.  
  48. $banner null;
  49. if ($database->loadObject$banner )) {
  50.     $database->setQuery"UPDATE #__banner SET impmade=impmade+1 WHERE bid='$banner->bid');
  51.     if(!$database->query()) {
  52.         echo $database->stderrtrue );
  53.         return;
  54.     }
  55.     $banner->impmade++;
  56.     
  57.     if ($numrows 0{
  58.         // Check if this impression is the last one and print the banner
  59.         if ($banner->imptotal == $banner->impmade{
  60.             $query "INSERT INTO #__bannerfinish (cid, type, name, impressions, clicks, imageurl, datestart, dateend)
  61.                 VALUES ('$banner->cid', '$banner->type', '$banner->name', '$banner->impmade', '$banner->clicks', '$banner->imageurl', '$banner->date', now())";
  62.             $database->setQuery($query);
  63.             if(!$database->query()) {
  64.                 die($database->stderr(true));
  65.             }
  66.             
  67.             $query="DELETE FROM #__banner WHERE bid=$banner->bid";
  68.             $database->setQuery($query);
  69.             if(!$database->query()) {
  70.                 die($database->stderr(true));
  71.             }
  72.         }
  73.  
  74.         if (trim$banner->custombannercode )) {
  75.             echo $banner->custombannercode;
  76.         else if (eregi"(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$"$banner->imageurl )) {
  77.             $imageurl "$mosConfig_live_site/images/banners/$banner->imageurl";
  78.             echo "<a href=\"".sefRelToAbs("index.php?option=com_banners&amp;task=click&amp;bid=$banner->bid")."\" target=\"_blank\"><img src=\"$imageurl\" border=\"0\" alt=\"".T_('Banner')."\" /></a>";
  79.             
  80.         else if (eregi("\.swf$"$banner->imageurl)) {
  81.             $imageurl "$mosConfig_live_site/images/banners/".$banner->imageurl;
  82.             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\">
  83.                     <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>";
  84.         }
  85.     }
  86. else {
  87.     echo "&nbsp;";
  88. }
  89. ?>

Documentation generated on Mon, 05 May 2008 16:21:13 +0400 by phpDocumentor 1.4.0