summaryrefslogtreecommitdiff
path: root/lib/file/delete.php
blob: 296b560d8f8bbf8bce379b436e53446de28a7738 (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"] || $user['priv'] >= $priv_admin) {
	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");