home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / blocks / block-advertising.php next >
Encoding:
PHP Script  |  2002-09-16  |  2.4 KB  |  54 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",$PHP_SELF)) {
  19.     Header("Location: index.php");
  20.     die();
  21. }
  22.  
  23. global $prefix, $dbi;
  24.  
  25. $bresult = sql_query("select * from ".$prefix."_banner WHERE type='1' AND active='1'", $dbi);
  26. $numrows = sql_num_rows($bresult, $dbi);
  27.  
  28. if ($numrows>1) {
  29.     $numrows = $numrows-1;
  30.     mt_srand((double)microtime()*1000000);
  31.     $bannum = mt_rand(0, $numrows);
  32. } else {
  33.     $bannum = 0;
  34. }
  35. $bresult2 = sql_query("select bid, imageurl, alttext from ".$prefix."_banner WHERE type='1' AND active='1' limit $bannum,1", $dbi);
  36. list($bid, $imageurl, $alttext) = sql_fetch_row($bresult2, $dbi);
  37.     
  38. if (is_admin($admin)) {
  39. } else {
  40.     sql_query("update ".$prefix."_banner set impmade=impmade+1 where bid='$bid'", $dbi);
  41. }
  42. if($numrows>0) {
  43.     $aborrar = sql_query("select cid, imptotal, impmade, clicks, date from ".$prefix."_banner where bid=$bid", $dbi);
  44.     list($cid, $imptotal, $impmade, $clicks, $date) = sql_fetch_row($aborrar, $dbi);
  45.  
  46. /* Check if this impression is the last one and print the banner */
  47.  
  48.     if (($imptotal <= $impmade) AND ($imptotal != 0)) {
  49.         sql_query("update ".$prefix."_banner set active='0' WHERE bid='$bid'", $dbi);
  50.     }
  51.     $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>";
  52. }
  53.  
  54. ?>