summaryrefslogtreecommitdiffstats
path: root/system/application
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-03-21 16:34:03 +0100
committerFlorian Pritz <bluewind@xssn.at>2010-03-21 16:34:03 +0100
commitd20200755368790d412d65171d77fcb89d08f1ad (patch)
treeb21985f415cb894038eb755f4c7c3daee9449dad /system/application
parentc4f1fecccbf094efc87190d8e634f4d4ed0bd8ad (diff)
add /plain to display files as plain text
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'system/application')
-rw-r--r--system/application/models/file_mod.php9
-rw-r--r--system/application/views/file/html_header.php1
2 files changed, 8 insertions, 2 deletions
diff --git a/system/application/models/file_mod.php b/system/application/models/file_mod.php
index bc2259622..4ab4fc32c 100644
--- a/system/application/models/file_mod.php
+++ b/system/application/models/file_mod.php
@@ -163,12 +163,13 @@ class File_mod extends Model {
header("HTTP/1.1 304 Not Modified");
header('Etag: "'.$etag.'"');
} else {
- if ($mode
+ if ($mode && $mode != 'plain'
&& $this->mime2extension($type)
&& filesize($file) <= $this->config->item('upload_max_text_size')
) {
$data['title'] = $filedata['filename'];
$data['raw_link'] = site_url($id);
+ $data['plain_link'] = site_url($id.'/plain');
header("Content-Type: text/html\n");
echo $this->load->view('file/html_header', $data, true);
// only rewrite if it's fast
@@ -178,7 +179,11 @@ class File_mod extends Model {
echo shell_exec(FCPATH.'scripts/syntax-highlighting.sh '.$filedata['filename'].'.'.$mode.' < '.escapeshellarg($file));
echo $this->load->view('file/html_footer', $data, true);
} else {
- header("Content-Type: ".$type."\n");
+ if ($mode == 'plain') {
+ header("Content-Type: ".$type."\n");
+ } else {
+ header("Content-Type: text/plain\n");
+ }
header("Content-disposition: inline; filename=\"".$filedata['filename']."\"\n");
header("Content-Length: ".filesize($file)."\n");
header("Last-Modified: ".date('D, d M Y H:i:s', $filedate)." GMT");
diff --git a/system/application/views/file/html_header.php b/system/application/views/file/html_header.php
index 069ea6f1d..fdd46acb9 100644
--- a/system/application/views/file/html_header.php
+++ b/system/application/views/file/html_header.php
@@ -7,6 +7,7 @@
<body>
<div class="top_bar">
<a class="raw_link no" href="<?php echo $raw_link; ?>">Raw</a>
+ <a class="raw_link no" href="<?php echo $plain_link; ?>">Plain</a>
</div>
<table class="content">
<tr>