summaryrefslogtreecommitdiffstats
path: root/application/controllers/file.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2012-04-13 20:34:01 +0200
committerFlorian Pritz <bluewind@xinu.at>2012-04-13 20:34:01 +0200
commit189e232fc65ab356eef9997a81a9755d17c41b37 (patch)
tree7de5f3d622eb955d5dfc381225688c819681cf48 /application/controllers/file.php
parent4397fbcba26037acc2c1323e73e5a54200da7c17 (diff)
Add nuke_id() command
This can be used to remove an ID and all other IDs referencing the same hash. Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers/file.php')
-rw-r--r--application/controllers/file.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index 49434699c..f6a37eaf8 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -379,6 +379,32 @@ class File extends CI_Controller {
closedir($outer_dh);
}
+ function nuke_id()
+ {
+ if (!$this->input->is_cli_request()) return;
+
+ $id = $this->uri->segment(3);
+
+
+ $file_data = $this->file_mod->get_filedata($id);
+
+ if (empty($file_data)) {
+ echo "unknown id \"$id\"\n";
+ return;
+ }
+
+ $hash = $file_data["hash"];
+
+ $this->db->query("
+ DELETE FROM files
+ WHERE hash = ?
+ ", array($hash));
+
+ unlink($this->file_mod->file($hash));
+
+ echo "removed hash \"$hash\"\n";
+ }
+
function update_file_sizes()
{
if (!$this->input->is_cli_request()) return;