home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / blocks / block-amazon.php < prev    next >
Encoding:
PHP Script  |  2002-09-16  |  2.4 KB  |  52 lines

  1. <?php
  2.  
  3. /************************************************************************/
  4. /* PHP-NUKE: Web Portal System                                          */
  5. /* ===========================                                          */
  6. /*                                                                      */
  7. /* Copyright (c) 2001 by Francisco Burzi (fbc@mandrakesoft.com)         */
  8. /* http://phpnuke.org                                                   */
  9. /*                                                                      */
  10. /* This program is free software. You can redistribute it and/or modify */
  11. /* it under the terms of the GNU General Public License as published by */
  12. /* the Free Software Foundation; either version 2 of the License.       */
  13. /************************************************************************/
  14.  
  15. if (eregi("block-Amazon.php",$PHP_SELF)) {
  16.     Header("Location: index.php");
  17.     die();
  18. }
  19.  
  20. /***************************************************************/
  21. /* To use this block you only need to download .jpg or .gif    */
  22. /* images from amazon.com and copy them to the /images/amazon  */
  23. /* directory, then edit the $amazon_id variable to fit your ID */
  24. /* of the Associates program. If you don't change the ID, all  */
  25. /* the comissions ($) will go to my account! You're adviced.   */
  26. /* But if you want to help PHP-Nuke project, you can leave the */
  27. /* $amazon_id variable intact.                                 */
  28. /*                                                             */
  29. /* You need to know that any image in the amazon's directory   */
  30. /* has the same ASIN name as its filename given by Amazon. If  */
  31. /* you don't know what this is, leave it as is or disable it.  */
  32. /***************************************************************/
  33.  
  34. $amazon_id = "phpnuke-20";
  35.  
  36. mt_srand((double)microtime()*1000000);
  37. $imgs = dir('images/amazon');
  38. while ($file = $imgs->read()) {
  39.     if (eregi("gif", $file) || eregi("jpg", $file)) {
  40.     $imglist .= "$file ";
  41.     }
  42. }
  43. closedir($imgs->handle);
  44. $imglist = explode(" ", $imglist);
  45. $a = sizeof($imglist)-2;
  46. $random = mt_rand(0, $a);
  47. $image = $imglist[$random];
  48. $asin = explode(".", $image);
  49. $content = "<br><center><a href=\"http://www.amazon.com/exec/obidos/ASIN/$asin[0]/$amazon_id\" target=\"_blank\">";
  50. $content .= "<img src=\"images/amazon/$image\" border=\"0\" alt=\"\"><br><br></center>";
  51.  
  52. ?>