diff options
author | Florian Pritz <bluewind@xinu.at> | 2011-09-11 16:00:22 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2011-09-11 18:12:36 +0200 |
commit | 3e99f93830d61be76205474bacc749e97d9e3ca5 (patch) | |
tree | d065b3e7e42f74e9038570a1d921ba3e883f9250 /application/controllers/file.php | |
parent | 599cf82ff710d01de97231e3fa73fff2b514708e (diff) |
add upload_history page
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers/file.php')
-rw-r--r-- | application/controllers/file.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php index 13787eeb6..07bc56dd7 100644 --- a/application/controllers/file.php +++ b/application/controllers/file.php @@ -12,6 +12,7 @@ class File extends CI_Controller { function __construct() { parent::__construct(); + mb_internal_encoding('UTF-8'); $this->load->helper(array('form', 'filebin')); $this->load->model('file_mod'); $this->var->cli_client = false; @@ -94,6 +95,53 @@ class File extends CI_Controller { echo $this->config->item('upload_max_size'); } + function upload_history() + { + $password = $this->file_mod->get_password(); + + $this->load->library("MemcacheLibrary"); + if (! $cached = $this->memcachelibrary->get("history_".$this->var->view_dir."_".$password)) { + $data = array(); + $query = array(); + $lengths = array(); + $data['title'] = 'Upload history'; + + if ($password != "NULL") { + $query = $this->db->query(" + SELECT id, filename, mimetype, date, hash + FROM files + WHERE password = ? + ORDER BY date + ", array($password))->result_array(); + } + + foreach($query as $key => $item) { + $query[$key]["date"] = date("r", $item["date"]); + // Keep track of longest string to pad plaintext output correctly + foreach(array("id", "filename", "mimetype", "date", "hash") as $length_key) { + if (!isset($lengths[$length_key])) { + $lengths[$length_key] = 0; + } + $len = mb_strlen($query[$key][$length_key]); + if ($len > $lengths[$length_key]) { + $lengths[$length_key] = $len; + } + } + } + + $data["query"] = $query; + $data["lengths"] = $lengths; + + $cached = ""; + $cached .= $this->load->view($this->var->view_dir.'/header', $data, true); + $cached .= $this->load->view($this->var->view_dir.'/upload_history', $data, true); + $cached .= $this->load->view($this->var->view_dir.'/footer', $data, true); + $this->memcachelibrary->set('history_'.$this->var->view_dir."_".$password, $cached, 42); + } + + echo $cached; + } + // Allow users to delete IDs if their password matches the one used when uploading function delete() { |