Okay, let's see. I think a lock file...
PHP Code:
<?php
// redir.php
$url = $_GET['url'];
$fn = $url . '.lock';
$allow = true;
if(file_exists($fn)) {
// read the file
$file = fopen($fn, 'r');
$numclicks = fread($file, filesize($file));
fclose($file);
if($numclicks == 5) $allow = false;
else {
$file = fopen($fn, 'w');
fputs($file, $numclicks + 1);
fclose($file);
}
} else {
// create the file
$file = fopen($fn, "w");
fputs($file, "0");
fclose($file);
}
if($allow) require($url);
else {
?>
<html>
<head>
<meta http-equiv="refresh" content="5;homepage.htm"/>
<title>Page disallowed</title>
</head>
<body>
This page has been disallowed due to too many clicks. You should be redirected <a href="homepage.htm">here</a> in five seconds.
</body>
</html>
<?php } ?>
Replace your links with this script; the URL must be absolute. For example, <a href="http://www.mysite.com/pages/foo.htm"> becomes <a href="redir.php?url=http%3a%2f%2fwww%2emysite%2ecom%2fpages%2ffoo%2ehtm">.
The above script requires PHP to be installed and enabled on your server. Also, I'm not sure what require() would make of a CGI script.
Bookmarks