From 88563f3cc431982e9968e0124d5da1e802ba3073 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 4 Sep 2010 15:56:01 +0200 Subject: skip show_url page for text Signed-off-by: Florian Pritz --- system/application/models/file_mod.php | 23 ++++++++++++++++++++--- system/application/views/file/show_url.php | 2 +- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/application/models/file_mod.php b/system/application/models/file_mod.php index e2698fe68..cee7aed8f 100644 --- a/system/application/models/file_mod.php +++ b/system/application/models/file_mod.php @@ -98,19 +98,36 @@ class File_mod extends Model { function show_url($id, $mode) { $data = array(); + $redirect = false; if ($mode) { $data['url'] = site_url($id).'/'.$mode; } else { $data['url'] = site_url($id).'/'; + + $filedata = $this->get_filedata($id); + $file = $this->file($filedata['hash']); + $type = $filedata['mimetype'] ? $filedata['mimetype'] : exec(FCPATH.'scripts/mimetype -b --orig-name '.escapeshellarg($filedata['filename']).' '.escapeshellarg($file)); + $mode = $this->mime2extension($type); + $mode = $this->filename2extension($filedata['filename']) ? $this->filename2extension($filedata['filename']) : $mode; + + // If we detected a highlightable file redirect, + // otherwise show the URL because browsers would just show a DL dialog + if ($mode) { + $redirect = true; + } } if ($this->var->cli_client) { echo $data['url']."\n"; } else { - $this->load->view('file/header', $data); - $this->load->view('file/show_url', $data); - $this->load->view('file/footer', $data); + if ($redirect) { + redirect($data['url']); + } else { + $this->load->view('file/header', $data); + $this->load->view('file/show_url', $data); + $this->load->view('file/footer', $data); + } } } diff --git a/system/application/views/file/show_url.php b/system/application/views/file/show_url.php index 73073ec04..62d34c661 100644 --- a/system/application/views/file/show_url.php +++ b/system/application/views/file/show_url.php @@ -1,4 +1,4 @@
- You can get your file/paste here:
+ You can get your file here:

-- cgit v1.2.3-24-g4f1b