<?php

/*if(!file_exists('counter.txt')){
    file_put_contents('counter.txt', '0');
}
file_put_contents('counter.txt', ((int) file_get_contents('counter.txt')) + 1);*/

$jsonString = file_get_contents('click_count.json');
$data = json_decode($jsonString, true);

if ($_GET['href'] == 'mv2_windows.zip') {
    $data['windows_downloads'] += 1;
} elseif ($_GET['href'] == 'mv2_linux.zip') {
    $data['linux_downloads'] += 1;
}

$newJsonString = json_encode($data);
file_put_contents('click_count.json', $newJsonString);

header('Location: ' . $_GET['href']);

?>
