#!/usr/bin/perl ###################################################################### # Random Link Version 1.0 # # Copyright 1999 Frederic TYNDIUK (FTLS) All Rights Reserved. # # E-Mail: tyndiuk@ftls.org Script License: GPL # # Created 05/30/99 Last Modified 05/30/99 # # Scripts Archive at: http://www.ftls.org/cgi/ # ###################################################################### # Function : # # Random Link, change location of each click # ###################################################################### ##################### license & copyright header ##################### # # # Copyright (c) 1999 TYNDIUK Frederic # # # # This program is free software; you can redistribute it and/or # # modify it under the terms of the GNU General Public License as # # published by the Free Software Foundation; either version 2 of # # the License, or (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program in the file 'COPYING'; if not, write to # # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # # Boston, MA 02111-1307, USA, or contact the author: # # # # TYNDIUK Frederic # # # # # ################### end license & copyright header ################### ###################################################################### # Necessary Variables # $RandomLinkFile = "random-link-url.txt"; $UseLog = 0; # Use Log File ? 1 = YES; 0 = NO $RandomLogFile = "/cgi-bin/randomlink/Random-Link-Log.txt"; # Nothing Below this line needs to be altered! # ###################################################################### srand(time); open(LINKS,"$RandomLinkFile") || &Error("Cannot Open Links File : $RandomLinkFile, Error $!\n"); $NbLines = @LinkFile = ; close(LINKS); $Url = $LinkFile[int rand $NbLines]; if ($UseLog) { @date = localtime(time); $date[4]++; $date[5] += 1900; $Time = "$date[4]/$date[3]/$date[5]"; open(LOG,">>$RandomLogFile") || &Error("Cannot Write Log File : $RandomLogFile, Error $!\n"); print LOG "[$Time] - $ENV{'REMOTE_HOST'} -> $Url\n"; close(LOG); } print "Location: $Url\n\n"; sub Error { my($ErrorText) = @_; print "Content-type: text/html\n\n"; print "Error: ".$ErrorText; exit; }