Greetings everyone!
I'm a newbie to CGI, hopefully some of you more experienced programmers can help me out.
I have a CGI script which i only want to allow beeing executed 1000 times a day. after the script is beeing called more than 1'000 times i want to redirect the users to the page "sorry.htm"
In php this would be easy. i don't know in cgi...
i thought about adding a simple count function which i found here..
as far as i understand i have the page views in variable $counter now.
now i need to redirect if more than x views, else i want to execute the script...
can this be done like that? any tip or snipplets? i searched the whole night but wasn't able to get it running...
maybay someone will point me in the right direction...
cheers mxds
I'm a newbie to CGI, hopefully some of you more experienced programmers can help me out.
I have a CGI script which i only want to allow beeing executed 1000 times a day. after the script is beeing called more than 1'000 times i want to redirect the users to the page "sorry.htm"
In php this would be easy. i don't know in cgi...
i thought about adding a simple count function which i found here..
Code:
open (COUNT, "<../cgi-bin/count.txt") ||Error('open', 'file');
flock (COUNT, 1) ||Error('lock', 'file');
my $counter = <COUNT>;
close (COUNT);
++$counter;
open (COUNT, ">../cgi-bin/count.txt") ||Error('open', 'file');
flock (COUNT, 1) ||Error('lock', 'file');
print COUNT "$counter";
close (COUNT);
as far as i understand i have the page views in variable $counter now.
now i need to redirect if more than x views, else i want to execute the script...
Code:
if ($counter > 1000 ) {
print "<meta http-equiv=\"refresh\"
content=\"0:url=http:/foo.com/sorry.htm\">";
}
can this be done like that? any tip or snipplets? i searched the whole night but wasn't able to get it running...
maybay someone will point me in the right direction...
cheers mxds