diff options
author | Florian Pritz <bluewind@xinu.at> | 2012-05-01 23:39:57 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2012-05-03 00:50:17 +0200 |
commit | d6c76b1fe30fc8065c985c31df633c3c6cbbed9f (patch) | |
tree | f7ee89a9ccff3d16e14e89b045493f0b29fe4c3b /application/models | |
parent | 8f93ff5aea99ca98693a47d3f09043f65dee9ac2 (diff) |
add ID/info to display more information about a file
The table is shared with the old delete_form, but it doesn't display the
delete button in info mode.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/models')
-rw-r--r-- | application/models/file_mod.php | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/application/models/file_mod.php b/application/models/file_mod.php index d91157a33..ab273cf58 100644 --- a/application/models/file_mod.php +++ b/application/models/file_mod.php @@ -9,14 +9,13 @@ class File_mod extends CI_Model { - var $data = array(); + var $data; function __construct() { parent::__construct(); + $this->data =& get_instance()->data; $this->load->model("muser"); - $this->data["title"] = "FileBin"; - $this->data["username"] = $this->muser->get_username(); } // Returns an unused ID @@ -55,7 +54,7 @@ class File_mod extends CI_Model { function get_filedata($id) { $sql = ' - SELECT hash, filename, mimetype, date, user + SELECT hash, filename, mimetype, date, user, filesize FROM `files` WHERE `id` = ? LIMIT 1'; @@ -268,6 +267,11 @@ class File_mod extends CI_Model { exit(); } + if ($mode == 'info') { + $this->display_info($id); + return; + } + // if there is no mimetype mapping we can't highlight it $can_highlight = $this->can_highlight($type); @@ -287,12 +291,7 @@ class File_mod extends CI_Model { header("Content-Type: text/html\n"); $this->data['current_highlight'] = htmlspecialchars($mode); - - if (filesize($file) > $this->config->item("small_upload_size")) { - $this->data['timeout'] = date("r", $filedata["date"] + $this->config->item("upload_max_age")); - } else { - $this->data['timeout'] = "never"; - } + $this->data['timeout'] = $this->get_timeout_string($id); echo $this->load->view($this->var->view_dir.'/html_header', $this->data, true); @@ -327,6 +326,18 @@ class File_mod extends CI_Model { exit(); } + function get_timeout_string($id) + { + $filedata = $this->get_filedata($id); + $file = $this->file($filedata["hash"]); + + if (filesize($file) > $this->config->item("small_upload_size")) { + return date("r", $filedata["date"] + $this->config->item("upload_max_age")); + } else { + return "unknown"; + } + } + private function unused_file($hash) { $sql = ' @@ -343,6 +354,22 @@ class File_mod extends CI_Model { } } + function display_info($id) + { + $this->data["title"] .= " - Info $id"; + $this->data["filedata"] = $this->get_filedata($id); + $this->data["id"] = $id; + $this->data['timeout'] = $this->get_timeout_string($id); + + if (!isset($this->data["can_delete"])) { + $this->data["can_delete"] = false; + } + + $this->load->view($this->var->view_dir.'/header', $this->data); + $this->load->view($this->var->view_dir.'/file_info', $this->data); + $this->load->view($this->var->view_dir.'/footer', $this->data); + } + function delete_id($id) { $this->muser->require_access(); |