summaryrefslogtreecommitdiffstats
path: root/system/application/models/file_mod.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-09-04 15:56:01 +0200
committerFlorian Pritz <bluewind@xssn.at>2010-09-04 15:56:01 +0200
commit88563f3cc431982e9968e0124d5da1e802ba3073 (patch)
treeba577ee2731a8c4988390fe8d2b8e96e08eadc81 /system/application/models/file_mod.php
parentdd71c144096163dfa921f20912843d1a5e2618dd (diff)
skip show_url page for text
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'system/application/models/file_mod.php')
-rw-r--r--system/application/models/file_mod.php23
1 files changed, 20 insertions, 3 deletions
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);
+ }
}
}