diff options
Diffstat (limited to 'lib/file/delete.php')
-rw-r--r-- | lib/file/delete.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/file/delete.php b/lib/file/delete.php new file mode 100644 index 0000000..1a65058 --- /dev/null +++ b/lib/file/delete.php @@ -0,0 +1,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"); |