Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: How I can find the image ID if the image is requested directly?  (Read 4693 times)

0 Members and 1 Guest are viewing this topic.

TigerClaw

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 28
How I can find the image ID if the image is requested directly?
« on: January 27, 2008, 08:48:58 pm »

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
Logged

Nibbler

  • Guest
Re: How I can find the image ID if the image is requested directly?
« Reply #1 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?
Logged

TigerClaw

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 28
Re: How I can find the image ID if the image is requested directly?
« Reply #2 on: January 27, 2008, 09:09:49 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.
Logged

Nibbler

  • Guest
Re: How I can find the image ID if the image is requested directly?
« Reply #3 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.
Logged

TigerClaw

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 28
Re: How I can find the image ID if the image is requested directly?
« Reply #4 on: January 27, 2008, 11:47:15 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  ;)
Logged

Nibbler

  • Guest
Re: How I can find the image ID if the image is requested directly?
« Reply #5 on: January 27, 2008, 11:49:17 pm »

Code: [Select]
SELECT pid FROM cpg_pictures WHERE filepath = 'filepathfromtheuri' AND filename = 'filenamefromtheuri' LIMIT 1
Logged

TigerClaw

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 28
Re: How I can find the image ID if the image is requested directly?
« Reply #6 on: January 27, 2008, 11:50:58 pm »

Code: [Select]
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
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 20 queries.