From 2a199313e8d795b24d8da3ddd3237354237b9308 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 2 Feb 2011 17:13:57 +0100 Subject: fix bug when using client to download Do not check the client version when downloading because this breaks curl. Probably because we output and later set HTTP headers in file_mod->download(). Signed-off-by: Florian Pritz --- application/controllers/file.php | 8 ++++---- application/models/file_mod.php | 11 +++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/application/controllers/file.php b/application/controllers/file.php index 7d97913f2..f8a19f88d 100644 --- a/application/controllers/file.php +++ b/application/controllers/file.php @@ -20,10 +20,6 @@ class File extends CI_Controller { // official client uses "fb-client/$version" as useragent if (strpos($_SERVER['HTTP_USER_AGENT'], 'fb-client') !== false) { - $client_version = substr($_SERVER['HTTP_USER_AGENT'], 10); - if ($this->var->latest_client != $client_version) { - echo "Your are using an old client version. Latest is ".$this->var->latest_client."\n"; - } $this->var->cli_client = "fb-client"; } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'libcurl') !== false) { $this->var->cli_client = "curl"; @@ -43,6 +39,7 @@ class File extends CI_Controller { } elseif ($id != "file" && $this->file_mod->id_exists($id)) { $this->file_mod->download(); } elseif ($this->var->cli_client) { + $this->file_mod->check_client_version(); die("No upload or unknown ID requested.\n"); } elseif ($id && $id != "file") { $this->file_mod->non_existent(); @@ -86,6 +83,7 @@ class File extends CI_Controller { // Allow users to delete IDs if their password matches the one used when uploading function delete() { + $this->file_mod->check_client_version(); $data = array(); $id = $this->uri->segment(3); $password = $this->file_mod->get_password(); @@ -127,6 +125,7 @@ class File extends CI_Controller { // XXX: this is too vulnerable to bots function do_paste() { + $this->file_mod->check_client_version(); // FIXME: disable until bot problem is really fixed return $this->upload_form(); @@ -165,6 +164,7 @@ class File extends CI_Controller { // TODO: merge with do_paste() function do_upload() { + $this->file_mod->check_client_version(); $data = array(); $extension = $this->input->post('extension'); // TODO: Display nice error for cli clients diff --git a/application/models/file_mod.php b/application/models/file_mod.php index 4737efa0e..f781e1676 100644 --- a/application/models/file_mod.php +++ b/application/models/file_mod.php @@ -147,6 +147,17 @@ class File_mod extends CI_Model { $this->load->view('file/footer', $data); } + function check_client_version() + { + if ($this->var->cli_client == "fb-client") { + $client_version = substr($_SERVER['HTTP_USER_AGENT'], 10); + if ($this->var->latest_client != $client_version) { + echo "Your are using an old client version. Latest is ".$this->var->latest_client."\n"; + } + } + + } + // download a given ID // TODO: make smaller function download() -- cgit v1.2.3-24-g4f1b