From d20200755368790d412d65171d77fcb89d08f1ad Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 21 Mar 2010 16:34:03 +0100 Subject: add /plain to display files as plain text Signed-off-by: Florian Pritz --- system/application/models/file_mod.php | 9 +++++++-- system/application/views/file/html_header.php | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'system/application') 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 @@ -- cgit v1.2.3-24-g4f1b