27 lines
676 B
PHP
27 lines
676 B
PHP
<?php
|
|
require("inc/connect.php");
|
|
|
|
$uid = $_GET['uid'];
|
|
|
|
if($uid == "")
|
|
header("Location: /index");
|
|
|
|
//Get file data
|
|
$query = "SELECT file.id, `file`, project.uid FROM `file`, `project` WHERE file.`project-id`=project.id AND file.uid = '$uid'";
|
|
$temp = ExecQuery($query);
|
|
|
|
if($temp->num_rows < 1)
|
|
header("Location: /index");
|
|
|
|
$result = $temp->fetch_assoc();
|
|
|
|
$file_location = "/download/" . $result['uid'] . "/" . $result['file'];
|
|
$ip = $_SERVER['REMOTE_ADDR'];
|
|
$id = $result['id'];
|
|
|
|
//Add download to database
|
|
$query = "INSERT INTO `download` (`file-id`, `time`, `ip`) VALUES ($id, NOW(), '$ip')";
|
|
ExecQuery($query);
|
|
|
|
header("Location: $file_location");
|
|
?>
|