Hi I need help from someone who knows Perl and PHP.
Anyone know how to convert the following Perl script into PHP?
#!/usr/bin/perl
ensure the shebang line points to your perl program.
upload in ASCII and CHMOD to 755.
create a directory named "random" and place in here all your text files.
call the script in an SSI such as - <!--#include virtual="/cgi-local/random.pl?file=####" -->
where "####" is the name of your text file, without the ".txt" part.
so if you wanted to load "images.txt" the SSI would be -
<!--#include virtual="/cgi-local/random?file=images" -->
The only restriction in creating your text file is that you must have one item per line.
do not modify below this point
print "Content-type: text/html\n\n";
if (length ($ENV{'QUERY_STRING'}) > 0){
$buffer = $ENV{'QUERY_STRING'};
#seperate all name/value pairs at the &
@pairs = split(/&/, $buffer);
foreach $pair (@pairs){
#seperate each name/value pair at =
($name, $value) = split(/=/, $pair);
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$in{$name} = $value;
}
}
$file = $in{'file'};
$flash = $in{'flash'};
if (length($flash) > 0){
$fmsg = 'message=';
}
open (DATA, "/serverpath/random/$file.txt") || die "Cant open list.txt, $!";
@ = <data>;
close (DATA);
$line = (int(rand $#data));
print "$fmsg$data[$line]";