First you need webspace where you can run something like php and which allows you to use the mod rewrite or to change extensions.
Then you need to write a little script which handles the img output in my case it looks like this:
Code:
$mysql_host = ""; $mysql_user = ""; $mysql_password = ""; $mysql_db = ""; @mysql_connect($mysql_host, $mysql_user, $mysql_password); @mysql_select_db($mysql_db); $ran = rand(1,71); $data = mysql_query('SELECT pic FROM images where id='.$ran); $wfile = mysql_result($data,0,'pic'); header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Content-type: image/gif"); $img=file_get_contents('./img/'.$wfile); echo $img;
It is important to send the Cache-Control so the browser dont cache that image, otherwise it would always show the same img untill the browser cache expires.
You should maybe builtin a referer check as well, so that your image isnt missused on other sites by other ppl.
Code:
$such = strpos($_SERVER['HTTP_REFERER'], 'elitepvpers.com'); if(isset($_SERVER['HTTP_REFERER']) && $such === false && $_SERVER['HTTP_REFERER']!=''){ * * * *header("Cache-Control: no-cache, must-revalidate"); * * * * header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); * * * * header("Content-type: image/gif"); * * * * $img=file_get_contents('./warning.gif'); * * * * echo $img; * * * * exit; }
The reason for the empty referer check is that some ppl use tools or browsers which clears the referer and we dont want to show them the warning.
Next todo is then to activate that the webserver redirect the image to the scripts, which you can define either in the config file of the webserver if you have the access to it or in the .htaccess
Code:
RewriteEngine on RewriteRule ^image\.jpg$ image.php
a more advance version would be for example:
Code:
RewriteEngine on RewriteRule ^image([0-9]{1,5})\.jpg$ image.php?p=$1
the [0-9] means all numbers between 0-9 are valid and the [1,5] that the number can be 1-5 positions long, so from 0-99999
If a request doesnt match that rule it wont rewrite it, for example image22222222.jpg will just look for that file.