Gossamer Forum
Home : General : Perl Programming :

Re: [fluffyduck] download counter not accurate on mac

Quote Reply
Re: [fluffyduck] download counter not accurate on mac In reply to
I would be more inclined to use something like this;

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 Smile

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!
Subject Author Views Date
Thread download counter not accurate on mac fluffyduck 8643 Dec 1, 2003, 2:51 PM
Thread Re: [fluffyduck] download counter not accurate on mac
Andy 8405 Dec 2, 2003, 2:36 AM
Thread Re: [Andy] download counter not accurate on mac
Recall 8414 Dec 2, 2003, 9:28 AM
Thread Re: [Recall] download counter not accurate on mac
Andy 8399 Dec 2, 2003, 9:31 AM
Thread Re: [Andy] download counter not accurate on mac
Recall 8410 Dec 2, 2003, 10:28 AM
Thread Re: [Recall] download counter not accurate on mac
Andy 8376 Dec 2, 2003, 10:31 AM
Thread Re: [Andy] download counter not accurate on mac
Recall 8401 Dec 2, 2003, 10:33 AM
Thread Re: [Recall] download counter not accurate on mac
fluffyduck 8325 Dec 3, 2003, 2:46 PM
Post Re: [fluffyduck] download counter not accurate on mac
Recall 8310 Dec 3, 2003, 5:20 PM