summaryrefslogtreecommitdiffstats
path: root/system/application
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
parentdd71c144096163dfa921f20912843d1a5e2618dd (diff)
skip show_url page for text
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'system/application')
-rw-r--r--system/application/models/file_mod.php23
-rw-r--r--system/application/views/file/show_url.php2
2 files changed, 21 insertions, 4 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);
+ }
}
}
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 @@
<div style="text-align:center">
- You can get your file/paste here:<br />
+ You can get your file here:<br />
<a href="<?php echo $url; ?>"><?php echo $url; ?></a><br />
</div>