home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / blocks / block-Advertising.php next >
PHP Script  |  2004-01-10  |  3KB  |  58 lines

  1. <?php
  2.  
  3. /************************************************************************/
  4. /* PHP-NUKE: Web Portal System                                          */
  5. /* ===========================                                          */
  6. /*                                                                      */
  7. /* Copyright (c) 2002 by Francisco Burzi                                */
  8. /* http://phpnuke.org                                                   */
  9. /*                                                                      */
  10. /* Note: If you need more than one banner block, just copy this file    */
  11. /*       with another name                                              */
  12. /*                                                                      */
  13. /* This program is free software. You can redistribute it and/or modify */
  14. /* it under the terms of the GNU General Public License as published by */
  15. /* the Free Software Foundation; either version 2 of the License.       */
  16. /************************************************************************/
  17.  
  18. if (eregi("block-Advertising.php",$_SERVER[PHP_SELF])) {
  19.     Header("Location: ../index.php");
  20.     die();
  21. }
  22.  
  23. global $prefix, $db;
  24.  
  25. $numrows = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_banner WHERE type='1' AND active='1'"));
  26.  
  27. if ($numrows>1) {
  28.     $numrows = $numrows-1;
  29.     mt_srand((double)microtime()*1000000);
  30.     $bannum = mt_rand(0, $numrows);
  31. } else {
  32.     $bannum = 0;
  33. }
  34.  
  35. $row = $db->sql_fetchrow($db->sql_query("SELECT bid, imageurl, alttext FROM ".$prefix."_banner WHERE type='1' AND active='1' LIMIT $bannum,1"));
  36.     $bid = intval($row['bid']);
  37.     $imageurl = $row['imageurl'];
  38.     $alttext = $row['alttext'];
  39. if (!is_admin($admin)) {
  40.     $db->sql_query("UPDATE ".$prefix."_banner SET impmade=impmade+1 WHERE bid='$bid'");
  41. }
  42. if($numrows>0) {
  43.     $row2 = $db->sql_fetchrow($db->sql_query("SELECT cid, imptotal, impmade, clicks, date FROM ".$prefix."_banner WHERE bid='$bid'"));
  44.     $cid = intval($row2['cid']);
  45.     $imptotal = intval($row2['imptotal']);
  46.     $impmade = intval($row2['impmade']);
  47.     $clicks = intval($row2['clicks']);
  48.     $date = $row2['date'];
  49.  
  50. /* Check if this impression is the last one and print the banner */
  51.  
  52.     if (($imptotal <= $impmade) AND ($imptotal != 0)) {
  53.     $db->sql_query("UPDATE ".$prefix."_banner SET active='0' WHERE bid='$bid'");
  54.     }
  55.     $content = "<center><br><a href=\"banners.php?op=click&bid=$bid\" target=\"_blank\"><img src=\"$imageurl\" border=\"1\" alt=\"$alttext\" title=\"$alttext\"></a><br><br></center>";
  56. }
  57.  
  58. ?>