Uutiset:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu
Advertisement:

Download counter not counting

Aloittaja s(in|mf), helmikuu 06, 2007, 05:27:14 AP

« edellinen - seuraava »

s(in|mf)

SMF Version: SMF 1.1.1
Forgive me if this question has been asked before - I did multiple searches, but did not find a solution to this specific problem.

The short
I want the download counter for attachment downloads to increase each and every time a file is downloaded, no matter if it is downloaded by the same user or within the same session.

The long

Problem
If I download an attachment for the first time, I see the download counter increasing in the topic and in the database (table {prefix}attachments, attribute 'downloads') as it is supposed to. However, if I download the same file again the counter does not increase.

What I have tried
If I go to the top-level index.php file, I see a variable called $actionArray which contains this line:
'dlattach' => array('Display.php'), 'Download')

This means that in the file Display.php in the Sources directory, the function Download will be executed each time someone clicks to download a file.
On line 973 of Display.php (I made some modifications so it could be in a slightly different location) I see the following code:

// Update the download counter (unless it's a thumbnail).
   if ($attachmentType != 3)
      db_query("
         UPDATE LOW_PRIORITY {$db_prefix}attachments
         SET downloads = downloads + 1
         WHERE ID_ATTACH = $ID_ATTACH
         LIMIT 1", __FILE__, __LINE__);

Now this query should update the download counter each and every time someone downloads a file, but it doesn't.

Bug or feature?
I understand that this is might be a feature (it probably is...), so that if a same user downloads an attachment twice or multiple times, the counter doesn't keep increasing. However I Do want it to increase.


Problem is, I don't know where to look to disable this feature. Can anyone help me out with this? Thanks.

s(in|mf)

Is there really nobody who can at least give his/her thoughts on this?

SleePy

s(in|mf),

Where you able to resolve this?
I believe the attachments system tracks which file you downloaded so it doesn't add to it.

You could most likely change this somewhere in the Sources (which I can't remember at the moment) so it doesn't do this.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

gafai

I found its about cache....  :o

In Display.php change:

Lainaa// If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE.
   if (!isset($_REQUEST['image']) && in_array(substr($real_filename, -4), array('.gif', '.jpg', '.bmp', '.png', 'jpeg', 'tiff')))
      header('Cache-Control: no-cache');
      else
   header('Cache-Control: max-age=' . (525600 * 60) . ', private');
to this
Lainaa// If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE.
   if (!isset($_REQUEST['image']) && in_array(substr($real_filename, -4), array('.gif', '.jpg', '.bmp', '.png', 'jpeg', 'tiff')))
      header('Cache-Control: no-cache');
      else
header('Cache-Control: no-cache');
   //header('Cache-Control: max-age=' . (525600 * 60) . ', private');

Aleksi "Lex" Kilpinen

Please avoid bumping topics that are years old and are not activily discussed in anymore, unless there is a real strong reason for you to do so. As this topic is more than 4 years old, I'll mark this solved.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Advertisement: