Jump to content

Image display/load script?


acctman

Recommended Posts

I'd like to rewrite the way images are shown on my site, with a php script so if image http://domain.com/2005/02/39/39-3001.jpg is loading the url would show http://domain1.com/display.php?3001 and display.php would not allow direct access from other domains the referring URL would have to be coming from domain1.com or domain2.com. The html img src code has to be able to read "http://domain1.com/display.php?3001"  and display an image

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/94815-image-displayload-script/
Share on other sites

You want to use .htaccess and url re-writing.

 

I'm no expert, so google it or I'm sure someone will help out soon enough.

 

Edit: found it

RewriteEngine on
rewriterule (.*)\.jpg$ /display.php?a=$1.jpg [R,L]

 

Should work I think. Then in display.php just make sure the referrer is allowed (in_array() should do the job nicely) and display the image.

The following is if you want to go down the PHP path:

 

How is it supposed to map 3001 to 2005/02/39/39-3001.jpg with just "?3001"?

 

It would have to know where the image was, but if the script knew that, it could just do something like:

 

[psuedo code]

 

if(referer == from this site) {
    //get image id from the ?number (process $_SERVER['QUERY_STRING'])
     if(image_exists) {
          readfile(path_to_image);
         exit;
     }
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.