summaryrefslogtreecommitdiff
path: root/lib/file/delete.php
blob: 1a65058a4d34260e56bfbcb78e387da356759eb2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php

require("lib/conf/file.php");

$title = "Delete a file";

if (count($args) < 3) header("location: index.php");
$id = intval($args[2]);

$info = mysql_fetch_assoc(sql("SELECT * FROM files WHERE id = $id"));

if ($info["owner"] == $user["id"]) {
	token_validate("Do you really want to delete this file ?", "file");
	if (has_mini($info["extension"])) unlink($savedir . $id . "-min." . $info["extension"]);
	unlink($savedir . $id . "." . $info["extension"]);
	sql("DELETE FROM files WHERE id = $id");
	header("location: file");
} else {
	$error = "You cannot delete this file.";
}
require("tpl/general/empty.php");