[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/modules/ -> mod_banners.php (source)

   1  <?php
   2  /**
   3  * @version $Id: mod_banners.php 6087 2006-12-24 18:59:57Z robs $
   4  * @package Joomla
   5  * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
   6  * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
   7  * Joomla! is free software. This version may have been modified pursuant
   8  * to the GNU General Public License, and as distributed it includes or
   9  * is derivative of works licensed under the GNU General Public License or
  10  * other free or open source software licenses.
  11  * See COPYRIGHT.php for copyright notices and details.
  12  */
  13  
  14  // no direct access
  15  defined( '_VALID_MOS' ) or die( 'Restricted access' );
  16  
  17  // clientids must be an integer
  18  $clientids = $params->get( 'banner_cids', '' );
  19  
  20  $banner = null;
  21  
  22  $where = '';
  23  if ( $clientids != '' ) {
  24      $clientidsArray = explode( ',', $clientids );
  25      mosArrayToInts( $clientidsArray );
  26      $where = "\n AND ( cid=" . implode( " OR cid=", $clientidsArray ) . " )";
  27  }
  28  
  29  $query = "SELECT *"
  30  . "\n FROM #__banner"
  31  . "\n WHERE showBanner=1 "
  32  . $where
  33  ;
  34  $database->setQuery( $query );
  35  $banners = $database->loadObjectList();
  36  $numrows = count( $banners );
  37  
  38  $bannum = 0;
  39  if ($numrows > 1) {
  40      $numrows--;
  41      mt_srand( (double) microtime()*1000000 );
  42      $bannum = mt_rand( 0, $numrows );
  43  }
  44  
  45  if ($numrows){
  46      $banner = $banners[$bannum];
  47  
  48      $query = "UPDATE #__banner"
  49      . "\n SET impmade = impmade + 1"
  50      . "\n WHERE bid = " . (int) $banner->bid
  51      ;
  52      $database->setQuery( $query );
  53      if(!$database->query()) {
  54          echo $database->stderr( true );
  55          return;
  56      }
  57      $banner->impmade++;
  58  
  59      if ($numrows > 0) {
  60          // Check if this impression is the last one and print the banner
  61          if ($banner->imptotal == $banner->impmade) {
  62  
  63              $query = "INSERT INTO #__bannerfinish ( cid, type, name, impressions, clicks, imageurl, datestart, dateend )"
  64              . "\n VALUES ( " . (int) $banner->cid . ", " . $database->Quote( $banner->type ) . ", "
  65              . $database->Quote( $banner->name ) . ", " . (int) $banner->impmade . ", " . (int) $banner->clicks
  66              . ", " . $database->Quote( $banner->imageurl ) . ", " . $database->Quote( $banner->date ) . ", 'now()' )"
  67              ;
  68              $database->setQuery($query);
  69              if(!$database->query()) {
  70                  die($database->stderr(true));
  71              }
  72  
  73              $query = "DELETE FROM #__banner"
  74              . "\n WHERE bid = " . (int) $banner->bid
  75              ;
  76              $database->setQuery($query);
  77              if(!$database->query()) {
  78                  die($database->stderr(true));
  79              }
  80          }
  81  
  82          if (trim( $banner->custombannercode )) {
  83              echo $banner->custombannercode;
  84          } else if (eregi( "(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$", $banner->imageurl )) {
  85              $imageurl     = $mosConfig_live_site .'/images/banners/'. $banner->imageurl;
  86              $link        = sefRelToAbs( 'index.php?option=com_banners&amp;task=click&amp;bid='. $banner->bid );
  87              if( !defined('_BANNER_ALT') ) DEFINE('_BANNER_ALT','Advertisement');
  88              echo '<a href="'. $link .'" target="_blank"><img src="'. $imageurl .'" border="0" alt="Advertisement" /></a>';
  89  
  90          } else if (eregi("\.swf$", $banner->imageurl)) {
  91              $imageurl     = "$mosConfig_live_site/images/banners/".$banner->imageurl;
  92              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\">
  93                      <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>";
  94          }
  95      }
  96  } else {
  97      echo "&nbsp;";
  98  }
  99  ?>


Généré le : Wed Nov 21 14:43:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics