Skip to content

Commit

Permalink
Revert "Count download file for press only #10837"
Browse files Browse the repository at this point in the history
This reverts commit 951f30e.
  • Loading branch information
sambaptista committed Nov 18, 2024
1 parent ac75472 commit 7d2a3ac
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server/Application/Handler/DownloadFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ class DownloadFile extends AbstractHandler
public function handle(ServerRequestInterface $request): ResponseInterface
{
$path = 'data/download-file-counter/alternative_groceries_report_nov_2024.pdf';
$cookie_name = 'artisans_pdf_download_2';
$cookie_name = 'artisans_pdf_download_1';

// Increment counter if no cookie = first visit
if (!isset($_COOKIE[$cookie_name]) && isset($_REQUEST['press'])) {
if (!isset($_COOKIE[$cookie_name])) {
$download_count = 0;
if (file_exists(self::COUNTER_PATH)) {
$download_count = (int) (file_get_contents(self::COUNTER_PATH));
}
++$download_count;
file_put_contents(self::COUNTER_PATH, $download_count);

// Flag cookie
setcookie($cookie_name, 'true', time() + (86400 * 1000), '/'); // 1000 days
}

// Flag cookie
setcookie($cookie_name, 'true', time() + (86400 * 60), '/'); // 60 days

if (!is_readable($path)) {
return $this->createError('File not found on disk, or not readable');
}
Expand Down

0 comments on commit 7d2a3ac

Please sign in to comment.