summaryrefslogtreecommitdiff
path: root/lib/image/delete.php
diff options
context:
space:
mode:
authorNicolas BERNSTEIN <alexis211@gmail.com>2011-09-17 16:48:29 +0200
committerNicolas BERNSTEIN <alexis211@gmail.com>2011-09-17 16:48:29 +0200
commitd0060968b77c39bdf8abffb071c971c166b59edb (patch)
tree0be52e00a25bd298235a0cf916fb07496d3ab95f /lib/image/delete.php
downloadBits-d0060968b77c39bdf8abffb071c971c166b59edb.tar.gz
Bits-d0060968b77c39bdf8abffb071c971c166b59edb.zip
First commit.
Diffstat (limited to 'lib/image/delete.php')
-rw-r--r--lib/image/delete.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/image/delete.php b/lib/image/delete.php
new file mode 100644
index 0000000..e6716ec
--- /dev/null
+++ b/lib/image/delete.php
@@ -0,0 +1,21 @@
+<?php
+
+require("lib/conf/image.php");
+
+$title = "Delete an image";
+
+if (count($args) < 3) header("location: index.php");
+$id = intval($args[2]);
+
+$info = mysql_fetch_assoc(sql("SELECT * FROM images WHERE id = $id"));
+
+if ($info["owner"] == $user["id"]) {
+ token_validate("Do you really want to delete this image ?", "image");
+ unlink($savedir . $id . "-min." . $info["extension"]);
+ unlink($savedir . $id . "." . $info["extension"]);
+ sql("DELETE FROM images WHERE id = $id");
+ header("location: image");
+} else {
+ $error = "You cannot delete this image.";
+}
+require("tpl/general/empty.php");