To expand my comment, see the block if ($REFERRER == '').
<?php
$allowed_domains = array('mydomain.com','yourdomain.com');
$REFERRER = $_SERVER['HTTP_REFERER'];
if ($REFERRER == '') {
}
$domain = substr($REFERRER, strpos($REFERRER, '://')+3);
$domain = substr($domain, 0, strpos($domain, '/'));
if (!in_array($domain, $allowed_domains)) {
exit(header('Location: error.php'));
}
?>
Please note that the above will be skipped to always refer to those browsers that did not report that the referrer is redirected to the error.php page.
My suggestion is to do something like ...
...
<?php
$dsalt = "AAAAB3NzaC1yc2EAAAABJQAAAIBNnuGAM6ZKURAS9h9ag".
"H85T1eIE+jlLkq7GhFny8wMJNpSM0stTDWeEYfL+4xWIE".
"lIF3NFvRpDAG/cgXuVmlBcO0ZxxKosrDv0dXCXNt5ciPJ".
"UjFi1e0FEJtkO32xrTDEB2IUg9rZ0tiqqsqnTCZBQ4AEvpMi";
$dkey = sha1($dsalt.date('mDY G'));
echo "<a href=\"http://yourdomain.com/download.php?key=$dkey\">Download stuff</a>";
?>
- ('/path/to/domaincheck.php')
<?php
$dkey = $_GET['key'];
$dsalt = "AAAAB3NzaC1yc2EAAAABJQAAAIBNnuGAM6ZKURAS9h9ag".
"H85T1eIE+jlLkq7GhFny8wMJNpSM0stTDWeEYfL+4xWIE".
"lIF3NFvRpDAG/cgXuVmlBcO0ZxxKosrDv0dXCXNt5ciPJ".
"UjFi1e0FEJtkO32xrTDEB2IUg9rZ0tiqqsqnTCZBQ4AEvpMi";
if (sha1($dsalt.date('mDY G')) != $dkey) {
exit(header('Location: error.php'));
}
?>
, $dsalts . puttgen.exe.
- . , , -. $dkey (, ).
theirserver.com yourserver.com