#!/usr/bin/perl ##################################################### # Script by MP.Prakash R.Lewis # # http://www.bestnetcraft.com # # This script is offered in the same terms as Perl. # # Comments and suggestions may be sent through # # http://www.bestnetcraft.com/contact.html # # No liability or damage will be accepted by the # # author under any circumstances. # ##################################################### # configuration part # requires a lookup table called as 'lookup' # This script is intended to redirect the visitor as per the parameters # passed as Query string. In addition it also writes in a log file - all # the transaction details - date,time,parameter passed,User_ip and where he # came from. There is an admin script to check the logs.In case you invoke # the script without any parameter, it sends them to a page selected at random. $envy =$ENV{'QUERY_STRING'}; $human ="http://www.bestnetcraft/index.html"; # Change to your site address $robo ="http://www.bestnetcraft/content.html";# change to you site address $file="/user/lookup"; $log_file="/user/guide.log"; srand; &get_date; ®ular; &logg; sub regular { $envy =~s/\D//g; open (FH,$file)|| print "Location: $robo\n\n"; @arr=; close (FH); $total=$#arr; if ($envy eq "" ) { $randum_num = int(rand($total + 1)); $envy =$randum_num; } my $no=$#arr; for ($i=0;$i <=$no; $i++) { @matter=split(/\|/,@arr[$i]); if ($matter[0] ==$envy) { $human= $matter[1]; return $human; last; } } } sub logg { my $ip=$ENV{'REMOTE_ADDR'}; my $reff=$ENV{'HTTP_REFERER'}; open (FH,">>$log_file"); flock FH, 2; print FH "$date\|$envy\|$ip\|$reff\n"; flock FH, 8; close (FH); } sub get_date { @days = ('Sun','Mon','Tue','Wed', 'Thu','Fri','Sat'); @months = ('Jan','Feb','Mar','Apr','May','Jun','Jul', 'Aug','Sep','Oct','Nov','Dec'); ($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6]; $time = sprintf("%02d:%02d:%02d",$hour,$min,$sec); $year += 1900; $hours = $hour; $years = $year; $mdays = $mday; $mons = $mon; $mons +=1; $wdays = $wday; if ($hours < 10) { $hours = "0$hours"; } if ($min < 10) { $min = "0$min"; } if ($sec < 10) { $sec = "0$sec"; } if ($mday < 10) { $mday = "0$mday"; } $time = "$hours:$min"; $date = "$mdays/$mons/$years at $time"; }