From f375859de3ebaea3ec4650b72174d6852bbaa804 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 4 Aug 2015 12:37:18 -0400 Subject: [PATCH] #275 Only update dl count if the attachment exists --- download_attachment.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/download_attachment.php b/download_attachment.php index 387eb5c8..e5907d34 100755 --- a/download_attachment.php +++ b/download_attachment.php @@ -95,9 +95,6 @@ if ( isset($_GET['kb_att']) ) hesk_checkPermission('can_man_kb'); } } - - // Update the download count - hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_attachments` SET `download_count` = `download_count` + 1 WHERE `att_id` = '{$att_id}'"); } // Ticket attachments @@ -137,7 +134,7 @@ else } // Update the download count - hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."attachments` SET `download_count` = `download_count` + 1 WHERE `att_id` = '{$att_id}'"); + } // Path of the file on the server @@ -149,6 +146,13 @@ if ( ! file_exists($realpath)) hesk_error($hesklang['attdel']); } +// Update the download count +if ( isset($_GET['kb_att']) ) { + hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_attachments` SET `download_count` = `download_count` + 1 WHERE `att_id` = '{$att_id}'"); +} else { + hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."attachments` SET `download_count` = `download_count` + 1 WHERE `att_id` = '{$att_id}'"); +} + // Send the file as an attachment to prevent malicious code from executing header("Pragma: "); # To fix a bug in IE when running https header("Cache-Control: "); # To fix a bug in IE when running https