diff options
author | Florian Pritz <bluewind@xssn.at> | 2010-03-21 16:34:03 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xssn.at> | 2010-03-21 16:34:03 +0100 |
commit | d20200755368790d412d65171d77fcb89d08f1ad (patch) | |
tree | b21985f415cb894038eb755f4c7c3daee9449dad /system/application/models | |
parent | c4f1fecccbf094efc87190d8e634f4d4ed0bd8ad (diff) |
add /plain to display files as plain text
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'system/application/models')
-rw-r--r-- | system/application/models/file_mod.php | 9 |
1 files changed, 7 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"); |