summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/controllers/file.php65
-rw-r--r--application/views/file/deleted.php13
-rw-r--r--application/views/file/file_info.php65
-rw-r--r--application/views/file/upload_history.php47
-rw-r--r--application/views/file_plaintext/delete_form.php2
-rw-r--r--application/views/file_plaintext/deleted.php9
6 files changed, 119 insertions, 82 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index 079802dbc..2a56df96c 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -180,37 +180,64 @@ class File extends CI_Controller {
echo $cached;
}
- // Allow users to delete their own IDs
- function delete()
+ function do_delete()
{
$this->muser->require_access();
- $id = $this->uri->segment(3);
- $this->data["id"] = $id;
+ $ids = $this->input->post("ids");
+ $errors = array();
+ $msgs = array();
+ $deleted_count = 0;
+ $total_count = 0;
- $process = $this->input->post("process");
- if ($this->var->cli_client) {
- $process = true;
+ if (!$ids) {
+ show_error("No IDs specified");
}
- if ($id && !$this->file_mod->id_exists($id)) {
- $this->output->set_status_header(404);
- $this->data["msg"] = "Unknown ID.";
- } elseif ($process) {
+ foreach ($ids as $id) {
+ $total_count++;
+
+ if (!$this->file_mod->id_exists($id)) {
+ $errors[] = "'$id' didn't exist anymore.";
+ continue;
+ }
+
if ($this->file_mod->delete_id($id)) {
- $this->load->view($this->var->view_dir.'/header', $this->data);
- $this->load->view($this->var->view_dir.'/deleted', $this->data);
- $this->load->view($this->var->view_dir.'/footer', $this->data);
- return;
+ $msgs[] = "'$id' has been removed.";
+ $deleted_count++;
} else {
- $this->data["msg"] = "Deletion failed. Do you really own that file?";
+ $errors[] = "'$id' couldn't be deleted.";
}
}
- $this->data["filedata"] = $this->file_mod->get_filedata($id);
- $this->data["can_delete"] = $this->data["filedata"]["user"] == $this->muser->get_userid();
+ $this->data["errors"] = $errors;
+ $this->data["msgs"] = $msgs;
+ $this->data["deleted_count"] = $deleted_count;
+ $this->data["total_count"] = $total_count;
+
+ $this->load->view($this->var->view_dir.'/header', $this->data);
+ $this->load->view($this->var->view_dir.'/deleted', $this->data);
+ $this->load->view($this->var->view_dir.'/footer', $this->data);
+ }
+
+ function delete()
+ {
+ $this->muser->require_access();
+
+ $id = $this->uri->segment(3);
+ $this->data["id"] = $id;
+
+ if ($id && !$this->file_mod->id_exists($id)) {
+ $this->output->set_status_header(404);
+ echo "Unknown ID '$id'.\n";
+ return;
+ }
- $this->file_mod->display_info($id);
+ if ($this->file_mod->delete_id($id)) {
+ echo "$id has been deleted.\n";
+ } else {
+ echo "Deletion failed. Do you really own that file?\n";
+ }
}
// Handle pastes
diff --git a/application/views/file/deleted.php b/application/views/file/deleted.php
index f12433808..ef02398d9 100644
--- a/application/views/file/deleted.php
+++ b/application/views/file/deleted.php
@@ -1,3 +1,14 @@
<div class="center">
- <p><?php echo $id; ?> has been deleted.</p>
+ <?php if (!empty($errors)) {
+ echo "<p>";
+ echo implode("<br />\n", $errors);
+ echo "</p>";
+ } ?>
+ <?php if (!empty($msgs)) {
+ echo "<p>";
+ echo implode("<br />\n", $msgs);
+ echo "</p>";
+ } ?>
+
+ <p><?php echo $deleted_count; ?> of <?php echo $total_count; ?> deleted.</p>
</div>
diff --git a/application/views/file/file_info.php b/application/views/file/file_info.php
index 1e9d9fdfd..779ece854 100644
--- a/application/views/file/file_info.php
+++ b/application/views/file/file_info.php
@@ -1,39 +1,30 @@
<div class="center">
- <?php echo form_open('file/delete/'.$id); ?>
- <?php if(isset($msg)) echo "<p>".$msg."</p>"; ?>
- <?php if($filedata): ?>
- <?php if($can_delete) { ?>
- <p>You are about to delete the following upload:</p>
- <?php } ?>
- <table style="margin: auto">
- <tr>
- <td class="title">ID</td>
- <td class="text"><a href="<?php echo site_url($id); ?>/"><?php echo $id; ?></a></td>
- </tr>
- <tr>
- <td class="title">Filename</td>
- <td class="text"><?php echo $filedata["filename"]; ?></td>
- </tr>
- <tr>
- <td class="title">Date of upload</td>
- <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["filesize"]); ?></td>
- </tr>
- <tr>
- <td class="title">Mimetype</td>
- <td class="text"><?php echo $filedata["mimetype"]; ?></td>
- </tr>
- </table>
- <?php if($can_delete) { ?>
- <input type="submit" value="Delete" name="process" />
- <?php } ?>
- <?php endif; ?>
- </form>
+ <?php if($filedata): ?>
+ <table style="margin: auto">
+ <tr>
+ <td class="title">ID</td>
+ <td class="text"><a href="<?php echo site_url($id); ?>/"><?php echo $id; ?></a></td>
+ </tr>
+ <tr>
+ <td class="title">Filename</td>
+ <td class="text"><?php echo $filedata["filename"]; ?></td>
+ </tr>
+ <tr>
+ <td class="title">Date of upload</td>
+ <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["filesize"]); ?></td>
+ </tr>
+ <tr>
+ <td class="title">Mimetype</td>
+ <td class="text"><?php echo $filedata["mimetype"]; ?></td>
+ </tr>
+ </table>
+ <?php endif; ?>
</div>
diff --git a/application/views/file/upload_history.php b/application/views/file/upload_history.php
index 8f0f8e3d7..2f0d0f41f 100644
--- a/application/views/file/upload_history.php
+++ b/application/views/file/upload_history.php
@@ -1,23 +1,26 @@
-<table class="results">
-<tr>
- <th></th>
- <th>ID</th>
- <th>Filename</th>
- <th>Mimetype
- <th>Date</th>
- <th>Hash</th>
- <th>Size</th>
-</tr>
+<?php echo form_open("file/do_delete"); ?>
+ <table class="results">
+ <tr>
+ <th></th>
+ <th>ID</th>
+ <th>Filename</th>
+ <th>Mimetype
+ <th>Date</th>
+ <th>Hash</th>
+ <th>Size</th>
+ </tr>
-<?php foreach($query as $key => $item): ?>
-<tr class="<?php echo even_odd(); ?>">
- <td><a href="<?php echo site_url("file/delete/".$item["id"]); ?>"><img src="<?php echo base_url(); ?>data/img/fuge-icons/cross.png" /></a></td>
- <td><a href="<?php echo site_url("/".$item["id"]); ?>/"><?php echo $item["id"]; ?></a></td>
- <td><?php echo htmlspecialchars($item["filename"]); ?></td>
- <td><?php echo $item["mimetype"]; ?></td>
- <td><?php echo $item["date"]; ?></td>
- <td><?php echo $item["hash"]; ?></td>
- <td><?php echo $item["filesize"]; ?></td>
-</tr>
-<?php endforeach; ?>
-</table>
+ <?php foreach($query as $key => $item): ?>
+ <tr class="<?php echo even_odd(); ?>">
+ <td><input type="checkbox" name="ids[<?php echo $item["id"]; ?>]" value="<?php echo $item["id"]; ?>" /></td>
+ <td><a href="<?php echo site_url("/".$item["id"]); ?>/"><?php echo $item["id"]; ?></a></td>
+ <td><?php echo htmlspecialchars($item["filename"]); ?></td>
+ <td><?php echo $item["mimetype"]; ?></td>
+ <td><?php echo $item["date"]; ?></td>
+ <td><?php echo $item["hash"]; ?></td>
+ <td><?php echo $item["filesize"]; ?></td>
+ </tr>
+ <?php endforeach; ?>
+ </table>
+ <input type="submit" value="Delete checked" name="process" />
+</form>
diff --git a/application/views/file_plaintext/delete_form.php b/application/views/file_plaintext/delete_form.php
deleted file mode 100644
index ba736078c..000000000
--- a/application/views/file_plaintext/delete_form.php
+++ /dev/null
@@ -1,2 +0,0 @@
-<?php if(isset($msg)) echo $msg; ?>
-
diff --git a/application/views/file_plaintext/deleted.php b/application/views/file_plaintext/deleted.php
index e5683b9d4..347766092 100644
--- a/application/views/file_plaintext/deleted.php
+++ b/application/views/file_plaintext/deleted.php
@@ -1 +1,8 @@
-<?php echo $id; ?> has been deleted.
+<?php if (!empty($errors)) {
+ echo implode("\n", $errors);
+} ?>
+<?php if (!empty($msgs)) {
+ echo implode("\n", $msgs);
+} ?>
+
+<?php echo $deleted_count; ?> of <?php echo $total_count; ?> deleted.