How I can find the image ID if the image is requested directly? How I can find the image ID if the image is requested directly?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

How I can find the image ID if the image is requested directly?

Started by TigerClaw, January 27, 2008, 08:48:58 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

TigerClaw

I'm trying to realize this:

A visitors ask directly an image like:

http://coppergallery/albums/test/image.jpg

Can I understand the pos number related to that image, which is needed by displayimage?

http://coppermine-gallery.net/demo/cpg14x/displayimage.php?pos=-361

1) Is it possible to pass direclty the image file to displayimage?

2) If not, I was thinking about taking the image name from the requested url then pass the variable to a php file with the necessary code to make a db query and find the image pos. The problem is I don't know how to write a similar script  ::)

Anyone can help?  ;D

Nibbler

I don't understand. If you redirect the file itself to displayimage.php what stops you going into an infinite loop?

TigerClaw

Quote from: Nibbler on January 27, 2008, 08:57:03 PM
I don't understand. If you redirect the file itself to displayimage.php what stops you going into an infinite loop?

Hi Nibbler,

I forgot to add that via htaccess we can check the HTTP Referrer to avoid the infinite loop if the request is generate from the coppermine website.
The displayimage will be requested only if someone is calling the image directly or from another site.

Nibbler

What if the referer is empty?

I don't think there is any easy way to do this. You'd need to create a script that looks up the filename to get the pid and hook that into mod_rewrite.

TigerClaw

Quote from: Nibbler on January 27, 2008, 09:16:48 PM
What if the referer is empty?

I don't think there is any easy way to do this. You'd need to create a script that looks up the filename to get the pid and hook that into mod_rewrite.

Do you know what SQL query I have to use to find the pid giving a file name? I do not know much about MySQL query but I can work on the other issues  ;)

Nibbler

SELECT pid FROM cpg_pictures WHERE filepath = 'filepathfromtheuri' AND filename = 'filenamefromtheuri' LIMIT 1

TigerClaw

Quote from: Nibbler on January 27, 2008, 11:49:17 PM
SELECT pid FROM cpg_pictures WHERE filepath = 'filepathfromtheuri' AND filename = 'filenamefromtheuri' LIMIT 1

Thx! I will work on it and I will see what I can do