I would be more inclined to use something like this;
use CGI;
my $IN = new CGI;
my $file = $IN->param('download');
my $read_write = $file;
$read_write =~ s/\//_/gi;
$read_write =~ s/ /_/gi;
$read_write =~ s/:/_/gi;
$read_write =~ s/http:\/\///gi;
# if this hasn't been counter before, then create a new file...
if (!-e $read_write) {
open(READFILES,">$read_write") || die $!;
print READFILES '1';
close(READFILES);
# redirect to the file...
print "Location: $file \n\n";
exit;
} else {
my $hits;
open(READFILES,"<$read_write") || die $!;
$hits = <READFILES>;
close(READFILES);
$hits++;
open(READFILES,">counter.cnt") || die $!;
print READFILES $hits;
close(READFILES);
# redirect to the file...
print "Location: $file \n\n";
exit;
}
Its untested.. but should work
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Code:
#!/usr/bin/perl use CGI;
my $IN = new CGI;
my $file = $IN->param('download');
my $read_write = $file;
$read_write =~ s/\//_/gi;
$read_write =~ s/ /_/gi;
$read_write =~ s/:/_/gi;
$read_write =~ s/http:\/\///gi;
# if this hasn't been counter before, then create a new file...
if (!-e $read_write) {
open(READFILES,">$read_write") || die $!;
print READFILES '1';
close(READFILES);
# redirect to the file...
print "Location: $file \n\n";
exit;
} else {
my $hits;
open(READFILES,"<$read_write") || die $!;
$hits = <READFILES>;
close(READFILES);
$hits++;
open(READFILES,">counter.cnt") || die $!;
print READFILES $hits;
close(READFILES);
# redirect to the file...
print "Location: $file \n\n";
exit;
}
Its untested.. but should work
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!