2014-03-10 18:38:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
// Aka my "I don't want to make a database" approach, sue me.
|
|
|
|
|
|
|
|
|
|
if(isset($_GET['file']))
|
|
|
|
|
dl_mod($_GET['file']);
|
|
|
|
|
|
|
|
|
|
function dl_mod($mod) {
|
2014-06-14 15:28:03 +01:00
|
|
|
if(strlen($mod) > 0 && file_exists("files/$mod") && strpos($mod, "/") === false) {
|
2014-03-10 18:38:33 +00:00
|
|
|
increment_dl_counter($mod);
|
|
|
|
|
header("Location: files/$mod");
|
2014-06-14 15:04:44 +01:00
|
|
|
} else echo("Hm, doesn't seem like that file exists :( <br><a href='./'>Back</a>");
|
2014-03-10 18:38:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function increment_dl_counter($mod) {
|
|
|
|
|
$path = "dls/$mod.txt";
|
|
|
|
|
$dls = get_dls($mod);
|
|
|
|
|
$dls_int = intval($dls);
|
|
|
|
|
++$dls_int;
|
|
|
|
|
|
|
|
|
|
file_put_contents($path, $dls_int);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_dls($mod) {
|
|
|
|
|
$path = 'dls/';
|
|
|
|
|
$file = "$path$mod.txt";
|
|
|
|
|
|
|
|
|
|
if(file_exists($file))
|
|
|
|
|
return file_get_contents($file);
|
|
|
|
|
|
|
|
|
|
if(!file_exists($path))
|
|
|
|
|
mkdir('dls/');
|
|
|
|
|
|
|
|
|
|
file_put_contents($file, '0');
|
|
|
|
|
return get_dls($mod);
|
|
|
|
|
}
|
2014-04-16 19:07:45 +01:00
|
|
|
|
2014-03-10 18:38:33 +00:00
|
|
|
?>
|