the little random gallery script - here is the code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lane
    Will code for food...
    • Apr 2001
    • 8496

    #1

    the little random gallery script - here is the code

    i see a lot of people asking for this script on the boards.
    here is the code for ya:


    <?
    mt_srand((float)microtime()*1000000);
    $f=file("gallery.txt");
    $u=trim($f[mt_rand(0,sizeof($f)-1)]);
    header("Location: $u");
    ?>

    save this file as a php file (no shit ).
    the file format for gallery.txt needs to be one url per line with no empty lines, on a flat txt file.
    you should upload both files in ascii mode if you are running Windoze.
    its the least cpu-resource-consuming version that i could think of at this second

    cheers
    Lane

    [This message has been edited by Lane (edited 11-27-2001).]
  • Ludedude
    Suck it!
    • Jun 2001
    • 4432

    #2
    Hrm

    ------------------
    Make 60% recurring with these Babes!
    The Webmaster's Folder
    The Midnight TGP2 Submitter

    Comment

    • Theo
      HAL 9000
      • May 2001
      • 34515

      #3
      great lane
      my version is the following

      <?php
      $RANDOM_URL_FILE = "pornstars.txt";
      srand((double)microtime()*1000000);

      if (file_exists($RANDOM_URL_FILE)) {
      $arry = file($RANDOM_URL_FILE);
      // En: load file.
      // Fr: charge le fichier.

      for($i = 0; $i < sizeof($arry) ; $i++) {
      if (preg_match("/http:/", $arry[$i]))
      $good_arry[$j++] = chop($arry[$i]);
      # PHP 4.0 arry_push ($good_arry, $arry[$i]);
      }
      if ($good_arry) {
      header("Location: ".$good_arry[rand(0, sizeof($good_arry) -1)]);
      } else {
      echo "error no good URL";
      }
      } else {
      echo "error: can't open $RANDOM_URL_FILE file";
      }
      ?>

      i guess your's is better since there's no way i won't have the text file up

      Comment

      Working...