Jump to content


Photo

Count times image in folder has been viewed


  • Please log in to reply
2 replies to this topic

#1 nosheep

nosheep
  • Members
  • Pip
  • Newbie
  • 2 posts
  • LocationClinton, NY

Posted 20 May 2006 - 09:13 PM

I don't know if this is the correct forum or not, but I'm working on a site for a friend to host images. He wants members' images to only be able to be viewed a certain number of times per month. Where the problem comes in is trying to log the views in a database. I have used .htaccess successfully in the past to watermark and deny access to images if certain conditions were not met, but now, when I point the browser to a .jpg file, I get the error below:

Bad Request
Your browser sent a request that this server could not understand.

Invalid URI in request GET /joe/user_files/1.jpg HTTP/1.1


The files that I need to track are in the folder /joe/user_files/
check_auth.php lives in the same folder.
My .htaccess file looks like this:

AddHandler checkauth .jpg
AddHandler checkauth .jpeg
AddHandler checkauth .gif

Action checkauth check_auth.php

I can't for the life of me figure out what I'm doing wrong. I've also tried the code below in my .htaccess file to no avail:

AddHandler checkauth .jpg
AddHandler checkauth .jpeg
AddHandler checkauth .gif

Action checkauth /user_files/check_auth.php

I know that it is probably something super simple, but at the moment, I can't get past it. Thanks in advance for any help.

- nosheep

#2 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 21 May 2006 - 08:38 PM

use a database that has id,path/pic_name,path/thumbnail_name,times_this_month

search database for all pics that still can be viewed this month and put into an array

Using the array, list name and thumbnail as clickable links.

when a pic is displayed increment the times_this_month by 1 for that pic

then create a cron that at 12:00:01 AM on the first of each month runs a script to reset all the times_this_month to zero

Lite...

(if you are concerned that someone may link directly to a picture, use the seldgehammer approach and have a cron rename the paths with random names each night/hour etc)

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#3 nosheep

nosheep
  • Members
  • Pip
  • Newbie
  • 2 posts
  • LocationClinton, NY

Posted 23 May 2006 - 04:10 AM

Thanks so much! It's nice to know there are still good people in the world.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users