From b4e0acc50ce686cc57ca854dd319bb722d1d7f7d Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Fri, 1 Jul 2011 22:10:59 +0200 Subject: add ascii highlighting with escape color support Signed-off-by: Florian Pritz --- application/models/file_mod.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'application/models') diff --git a/application/models/file_mod.php b/application/models/file_mod.php index 2ba44f551..a1ad73b92 100644 --- a/application/models/file_mod.php +++ b/application/models/file_mod.php @@ -247,12 +247,14 @@ class File_mod extends CI_Model { exit(); } + + $special_modes = array("ascii"); // directly download the file - if (!$mode // user didn't specify a mode/didn't enable autodetection + if (!in_array($mode, $special_modes) && (!$mode // user didn't specify a mode/didn't enable autodetection || !$this->mime2extension($type) // file can't be highlighted || $mode == "plain" // user wants to the the plain file || filesize($file) > $this->config->item('upload_max_text_size') - ) { + )) { if ($mode == 'plain') { $type = "text/plain"; } @@ -283,8 +285,12 @@ class File_mod extends CI_Model { if (! $cached = $this->memcachelibrary->get($filedata['hash'].'_'.$mode)) { ob_start(); if ($mode == "rmd") { - echo ''."\n"; - passthru('/usr/bin/perl /usr/bin/perlbin/vendor/Markdown.pl '.escapeshellarg($file)); + echo ''."\n"; + passthru('/usr/bin/perl /usr/bin/vendor_perl/vendor/Markdown.pl '.escapeshellarg($file)); + } elseif ($mode == "ascii") { + echo '
'."\n";
+				passthru('/usr/bin/perl '.FCPATH.'scripts/ansi2html '.escapeshellarg($file));
+				echo "
\n"; } else { echo '
';
 				// generate line numbers (links)
-- 
cgit v1.2.3-24-g4f1b