<?php
defined('DOIT') or die('Restricted access');
include_once(PATH."/core/file.class.php");
//Is a file just being downloaded?
if (isset($_POST["downloadid"])) {
$dlid=intval($_POST["downloadid"]);
$db=new Database();
//look it up in the db
$db->query("select * from mod_download where `id`=$dlid");
$dlfile=$db->getdata();
if ($dlfile) {
$filepath=PATH."/".$dlfile["location"]."/".$dlfile["filename"];
$myfile = new File($filepath);
$db->query("update mod_download set `downloads`=`downloads`+1 where `id`=$dlid");
//download file
header("Content-Type: $myfile->mime");
header("Content-Disposition: attachment; filename=\"".$myfile->name.".".$myfile->ext."\"");
readfile($filepath);
}
$db->close();
}
?>