HOTLINK-PROTECTION.PHP

I wrote these functions to keep my GD generated images from being hotlinked. This was based on the idea that both the php script calling the image, and the image itself would have the same server time. If you try to use this script on a site that uses multiple servers, it would be a good idea to synchronize their cpu clocks. date_filter is to be used in the script calling the php resource you want to protect.

<img src="image.php?df=<?= date_filter($month_array) ?>" />

You would then use hotlink_protect from your image file, to validate that the df parameter. If it returns false, it means that the php resource file did not get the parameter that was expected.

I used a two dimensional array in order to allow for temporary hotlinking, that would be uninterrupted by me changing the values for the months. This would be achieved by rotating the subarrays: Making $month_array[1] = $month_array[0], and creating a whole new set for $month_array[0]. This should discourage people from trying to guess your parameter.