From 189e232fc65ab356eef9997a81a9755d17c41b37 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Fri, 13 Apr 2012 20:34:01 +0200 Subject: 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 --- application/controllers/file.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'application/controllers') 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; -- cgit v1.2.3-24-g4f1b