diff options
| author | Fyorl <gaelreth@gmail.com> | 2012-08-04 14:48:07 +0100 |
|---|---|---|
| committer | Fyorl <gaelreth@gmail.com> | 2012-08-04 14:48:07 +0100 |
| commit | ed1435d04093132b751e940937e7f4f4b0687031 (patch) | |
| tree | ffeff9b63a18eaa9b8262b16794ba0390a2ceeb8 /phpBB | |
| parent | 20a2ceccbdbb47229750735bfcdf2a5d05353d95 (diff) | |
| download | forums-ed1435d04093132b751e940937e7f4f4b0687031.tar forums-ed1435d04093132b751e940937e7f4f4b0687031.tar.gz forums-ed1435d04093132b751e940937e7f4f4b0687031.tar.bz2 forums-ed1435d04093132b751e940937e7f4f4b0687031.tar.xz forums-ed1435d04093132b751e940937e7f4f4b0687031.zip | |
[feature/attach-dl] Added function for incrementing download counter
PHPBB3-11042
Diffstat (limited to 'phpBB')
| -rw-r--r-- | phpBB/download/file.php | 10 | ||||
| -rw-r--r-- | phpBB/includes/functions_download.php | 21 |
2 files changed, 23 insertions, 8 deletions
diff --git a/phpBB/download/file.php b/phpBB/download/file.php index f360132b0f..cec4aa55b3 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -407,10 +407,7 @@ if ($attachment) else if (($display_cat == ATTACHMENT_CATEGORY_NONE/* || $display_cat == ATTACHMENT_CATEGORY_IMAGE*/) && !$attachment['is_orphan'] && !phpbb_http_byte_range($attachment['filesize'])) { // Update download count - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' - SET download_count = download_count + 1 - WHERE attach_id = ' . $attachment['attach_id']; - $db->sql_query($sql); + phpbb_increment_downloads($db, $attachment['attach_id']); } if ($display_cat == ATTACHMENT_CATEGORY_IMAGE && $mode === 'view' && (strpos($attachment['mimetype'], 'image') === 0) && ((strpos(strtolower($user->browser), 'msie') !== false) && (strpos(strtolower($user->browser), 'msie 8.0') === false))) @@ -443,10 +440,7 @@ if ($attachment) if ($attachments) { - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' - SET download_count = download_count + 1 - WHERE ' . $db->sql_in_set('attach_id', $attach_ids); - $db->sql_query($sql); + phpbb_increment_downloads($db, $attach_ids); if (!in_array($archive, compress::methods())) { diff --git a/phpBB/includes/functions_download.php b/phpBB/includes/functions_download.php index 1486113013..b01712357d 100644 --- a/phpBB/includes/functions_download.php +++ b/phpBB/includes/functions_download.php @@ -592,3 +592,24 @@ function phpbb_parse_range_request($request_array, $filesize) ); } } + +/** +* Increments the download count of all provided attachments +* +* @param dbal $db The database object +* @param array|int $ids The attach_id of each attachment +* +* @return null +*/ +function phpbb_increment_downloads($db, $ids) +{ + if (!is_array($ids)) + { + $ids = array($ids); + } + + $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' + SET download_count = download_count + 1 + WHERE ' . $db->sql_in_set('attach_id', $ids); + $db->sql_query($sql); +} |
