summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/controllers/file.php13
-rw-r--r--application/models/file_mod.php47
-rw-r--r--application/views/file/file_info.php (renamed from application/views/file/delete_form.php)6
3 files changed, 45 insertions, 21 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index 751b72ce2..079802dbc 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -180,13 +180,12 @@ class File extends CI_Controller {
echo $cached;
}
- // Allow users to delete IDs if their password matches the one used when uploading
+ // Allow users to delete their own IDs
function delete()
{
$this->muser->require_access();
$id = $this->uri->segment(3);
- $this->data["title"] .= " - Delete $id";
$this->data["id"] = $id;
$process = $this->input->post("process");
@@ -194,11 +193,6 @@ class File extends CI_Controller {
$process = true;
}
- $this->data["filedata"] = $this->file_mod->get_filedata($id);
- if ($this->data["filedata"]) {
- $this->data["filedata"]["size"] = filesize($this->file_mod->file($this->data["filedata"]["hash"]));
- }
-
if ($id && !$this->file_mod->id_exists($id)) {
$this->output->set_status_header(404);
$this->data["msg"] = "Unknown ID.";
@@ -213,11 +207,10 @@ class File extends CI_Controller {
}
}
+ $this->data["filedata"] = $this->file_mod->get_filedata($id);
$this->data["can_delete"] = $this->data["filedata"]["user"] == $this->muser->get_userid();
- $this->load->view($this->var->view_dir.'/header', $this->data);
- $this->load->view($this->var->view_dir.'/delete_form', $this->data);
- $this->load->view($this->var->view_dir.'/footer', $this->data);
+ $this->file_mod->display_info($id);
}
// Handle pastes
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();
diff --git a/application/views/file/delete_form.php b/application/views/file/file_info.php
index 55827c019..1e9d9fdfd 100644
--- a/application/views/file/delete_form.php
+++ b/application/views/file/file_info.php
@@ -19,8 +19,12 @@
<td class="text"><?php echo date("r", $filedata["date"]); ?></td>
</tr>
<tr>
+ <td class="title">Date of removal</td>
+ <td class="text"><?php echo $timeout; ?></td>
+ </tr>
+ <tr>
<td class="title">Size</td>
- <td class="text"><?php echo format_bytes($filedata["size"]); ?></td>
+ <td class="text"><?php echo format_bytes($filedata["filesize"]); ?></td>
</tr>
<tr>
<td class="title">Mimetype</td>