From b88bdf6727a91451450a066f37e865e3b1b5a60d Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 29 Aug 2013 17:56:21 +0200 Subject: Replace echo with show_error; misc cleanup Signed-off-by: Florian Pritz --- application/controllers/file.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'application') diff --git a/application/controllers/file.php b/application/controllers/file.php index c336db92b..992252ff5 100644 --- a/application/controllers/file.php +++ b/application/controllers/file.php @@ -562,17 +562,14 @@ class File extends MY_Controller { $this->muser->require_access("apikey"); if (!is_cli_client()) { - echo "Not a listed cli client, please use the history to delete uploads.\n"; - return; + show_error("Not a listed cli client, please use the history to delete uploads.\n", 403); } $id = $this->uri->segment(3); $this->data["id"] = $id; if ($id && !$this->mfile->id_exists($id)) { - $this->output->set_status_header(404); - echo "Unknown ID '$id'.\n"; - return; + show_error("Unknown ID '$id'.", 404); } if ($this->mfile->delete_id($id)) { @@ -586,6 +583,7 @@ class File extends MY_Controller { function do_paste() { // desktop clients get a cookie to claim the ID later + // don't force them to log in just yet if (is_cli_client()) { $this->muser->require_access(); } @@ -620,6 +618,7 @@ class File extends MY_Controller { function do_upload() { // desktop clients get a cookie to claim the ID later + // don't force them to log in just yet if (is_cli_client()) { $this->muser->require_access("apikey"); } @@ -651,15 +650,15 @@ class File extends MY_Controller { UPLOAD_ERR_EXTENSION => "A PHP extension stopped the file upload", ); - $this->data["msg"] = "Unknown error."; + $msg = "Unknown error."; if (isset($errors[$file['error']])) { - $this->data["msg"] = $errors[$file['error']]; + $msg = $errors[$file['error']]; } else { - $this->data["msg"] = "Unknown error code: ".$file['error'].". Please report a bug."; + $msg = "Unknown error code: ".$file['error'].". Please report a bug."; } - show_error("Error while uploading: ".$this->data["msg"], 400); + show_error("Error while uploading: ".$msg, 400); } $filesize = filesize($file['tmp_name']); -- cgit v1.2.3-24-g4f1b