PDA

View Full Version : Hey Waz - Perl question



Zach
January 18th, 2004, 02:00
You know Perl ?

Got a script I'd be interested in having you look over for a minute.

Its very small

Jet Set Willy
January 18th, 2004, 09:41
I know Perl a bit, yeah.

Zach
January 18th, 2004, 20:35
Ok, well basically this is a script to help curve folks from linking to files etc..
It works pretty much, but I recently noticed in Mozilla it gives away the location where the files are stored. I was wondering if you might be able to "fix" that, or whatever.



#!/usr/bin/perl
###############################################
## ##
## Downloader v.1 ##
## ----------------------------------------- ##
## by Graeme (webmaster@cgi-scripting.com) ##
## http://www.CGI-Scripting.com ##
## ############################
## This version of Downloader is free, if anyone sold it to you ##
## please contact me. Please DO NOT remove any of the copyrights or ##
## links to our site, they keep this CGI free for everyone. ##
## ##
## (c) Copyright 2000 CGI Scripting ##
################################################## #######################

# Look in the readme.txt file for help setting up this script

$defaulturl = "http://www.gamerzdomain.net";

@okaysites = ("http://gamerzdomain.net", "http://www.gamerzdomain.net");

$url_1 = "http://www.gamerzdomain.net/insertdownloadlocation";
$url_2 = "http://www.gamerzdomain.net/insertdownloadlocation";
$url_3 = "http://www.gamerzdomain.net/insertdownloadlocation";
$url_4 = "http://www.gamerzdomain.net/insertdownloadlocationt";


####################### DO NOT EDIT BELOW THIS LINE ######################

@querypairs = split(/&/, $ENV{'QUERY_STRING'});
foreach $querypair (@querypairs) {
($queryname, $queryvalue) = split(/=/, $querypair);
$queryvalue =~ tr/+/ /;
$queryvalue =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$queryvalue =~ s/<([^>]|\n)*>//g;
if ($QUERY{$queryname}) { $QUERY{$queryname} = $QUERY{$queryname}.",".$queryvalue; }
else { $QUERY{$queryname} = $queryvalue; }
}

$reffer = $ENV{'HTTP_REFERER'};
$yes = 0;
foreach $domain (@okaysites) {
if ($reffer =~ /$domain/) {
$yes = 1;
}
}

$theu = "url"."_"."$QUERY{'site'}";

if ($$theu && $yes == 1) {
print "Location: $$theu/$QUERY{'filename'}\n\n";
} else {
print "Location: $defaulturl\n\n";
}
exit;

Jet Set Willy
January 18th, 2004, 20:40
I think you need another script/approach, really. You'll never be able to hide the real location of a file from a browser - it needs to know at some point, or it can't get there. Mozilla has a habit of showing the user the truth, unfortunately.

Zach
January 18th, 2004, 22:01
Yea I was hoping you wouldn't have something like that to say.

I actually have another script that does work on my own server and is PHP, however for some reason it won't work on Jay's and nothing else I have found is satisfactory.

Even the support people at his dopey web host don't know why it won't run. But hes changing over to my host in a few months so I guess we'll ride it out till then.

Thanks for looking tho.