Example #1
0
function smarty_block_source($params, $content, &$smarty, &$repeat)
{
    // only output on the closing tag
    if (!$repeat) {
        $geshi = new Geshi($content, $params['lang']);
        $geshi->set_header_type(GESHI_HEADER_PRE);
        return $geshi->parse_code();
    }
}
Example #2
0
 /** 
  * Runs source code through Geshi syntax highlighting engine.
  *
  * @param string $source Source code to process
  * @param string $lang Language of source code
  * @return string
  * @access public
  */
 function syntax($source, $lang)
 {
     $source = $source;
     $language = $lang;
     $geshi = new Geshi($source, $lang);
     $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
     $geshi->set_header_type(GESHI_HEADER_DIV);
     return $geshi->parse_code();
 }
Example #3
0
 static function create($type, $options, $cachedDir)
 {
     //echo "$type---\n";
     switch ($type) {
         case "geshi":
             $provider = Geshi::getInstance();
             break;
         case "highlight":
             $provider = Highlight::getInstance();
             break;
         case "pygment":
             $provider = Pygment::getInstance();
             break;
         case "httpappspot":
             $provider = HttpAppspot::getInstance();
             break;
         case "httphiliteme":
             $provider = HttpHiliteme::getInstance();
             break;
         default:
             throw new \Exception("Highlighter < {$type} > not implemented");
     }
     $opt = array();
     $options[$type]['cssclass'] .= " " . $options['globals']['cssclass'];
     foreach ($options[$type] as $k => $v) {
         if ($v !== null and $v !== "") {
             $opt[$k] = $v;
         }
     }
     $opt = array_merge(array_diff($options['globals'], $opt), $opt);
     $provider->setOptions($opt);
     $provider->setCachedDir($cachedDir);
     return $provider;
 }
 public static function do_highlight($in)
 {
     // Look, ma! No Regex!
     $tokenizer = new HTMLTokenizer($in, false);
     $tokens = $tokenizer->parse();
     // fetch div, pre, code slices that have a class="highlight"
     $slices = $tokens->slice(array('div', 'pre', 'code'), array('class' => 'highlight'));
     // iterate the found slices
     foreach ($slices as $slice) {
         // store the class to use once we've stripped the container
         $classAttr = $slice[0]['attrs']['class'];
         // unique name to use in the cache for this slice/markup
         $sliceCacheName = 'plugin.highlight.' . md5((string) $slice) . filemtime(__FILE__);
         // trim off the div, and determine the value
         $slice->trim_container();
         $sliceValue = trim((string) $slice);
         // see if it's already been cached
         if (Cache::has($sliceCacheName)) {
             $output = Cache::get($sliceCacheName);
         } else {
             // trim off the CDATA wrapper, if applicable
             if (substr($sliceValue, 0, 9) == '<![CDATA[' && substr($sliceValue, -3) == ']]>') {
                 $sliceValue = substr($sliceValue, 9, -3);
             }
             $classes = array_filter(explode(' ', trim(str_replace('highlight', '', $classAttr))));
             // ugly, refactor
             $geshi = new Geshi(trim($sliceValue), isset($classes[0]) ? $classes[0] : 'php', HighlightPlugin::$geshi_path . '/geshi/');
             $geshi->set_header_type(GESHI_HEADER_PRE);
             $geshi->set_overall_class('geshicode');
             $output = @$geshi->parse_code();
             // @ is slow, but geshi is full of E_NOTICE
             Cache::set($sliceCacheName, $output);
         }
         $slice->tokenize_replace($output);
         $tokens->replace_slice($slice);
     }
     return (string) $tokens;
 }
Example #5
0
function git_blob($projectroot, $project, $hash, $file, $hashbase)
{
    global $gitphp_conf, $tpl;
    $cachekey = sha1($project) . "|" . $hashbase . "|" . $hash . "|" . sha1($file);
    if (!$tpl->is_cached('blob.tpl', $cachekey)) {
        $head = git_read_head($projectroot . $project);
        if (!isset($hashbase)) {
            $hashbase = $head;
        }
        if (!isset($hash) && isset($file)) {
            $hash = git_get_hash_by_path($projectroot . $project, $hashbase, $file, "blob");
        }
        $catout = git_cat_file($projectroot . $project, $hash);
        $tpl->assign("hash", $hash);
        $tpl->assign("hashbase", $hashbase);
        $tpl->assign("head", $head);
        if ($co = git_read_commit($projectroot . $project, $hashbase)) {
            $tpl->assign("fullnav", TRUE);
            $refs = read_info_ref($projectroot . $project);
            $tpl->assign("tree", $co['tree']);
            $tpl->assign("title", $co['title']);
            if (isset($file)) {
                $tpl->assign("file", $file);
            }
            if ($hashbase == "HEAD") {
                if (isset($refs[$head])) {
                    $tpl->assign("hashbaseref", $refs[$head]);
                }
            } else {
                if (isset($refs[$hashbase])) {
                    $tpl->assign("hashbaseref", $refs[$hashbase]);
                }
            }
        }
        $paths = git_path_trees($projectroot . $project, $hashbase, $file);
        $tpl->assign("paths", $paths);
        if ($gitphp_conf['filemimetype']) {
            $mime = file_mime($catout, $file);
            if ($mime) {
                $mimetype = strtok($mime, "/");
            }
        }
        if ($mimetype == "image") {
            $tpl->assign("mime", $mime);
            $tpl->assign("data", base64_encode($catout));
        } else {
            $usedgeshi = $gitphp_conf['geshi'];
            if ($usedgeshi) {
                $usedgeshi = FALSE;
                include_once $gitphp_conf['geshiroot'] . "geshi.php";
                if (class_exists("GeSHi")) {
                    $geshi = new GeSHi($catout, $lang = Geshi::get_language_name_from_extension(substr(strrchr($file, '.'), 1)));
                    if ($geshi) {
                        $lang = "";
                        if (isset($file)) {
                            $lang = $geshi->get_language_name_from_extension(substr(strrchr($file, '.'), 1));
                        }
                        if (isset($lang) && strlen($lang) > 0) {
                            #$geshi->set_source($catout);
                            #$geshi->set_language($lang);
                            #$geshi->set_header_type(GESHI_HEADER_DIV);
                            #$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
                            $tpl->assign("geshiout", $geshi->parse_code());
                            $usedgeshi = TRUE;
                        }
                    }
                }
            }
            if (!$usedgeshi) {
                $lines = explode("\n", $catout);
                $tpl->assign("lines", $lines);
            }
        }
    }
    $tpl->display('blob.tpl', $cachekey);
}
Example #6
0
 /**
  * Configure a geshi Instance the way we want it.
  * app/config/geshi.php
  *
  * @param Geshi $geshi
  * @return void
  */
 protected function _configureInstance($geshi)
 {
     $geshi->set_header_type(GESHI_HEADER_NONE);
     $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 2);
     $geshi->enable_classes();
     $geshi->set_tab_width(4);
 }
Example #7
0
function geshi_formatted($str, $type = 'PHP')
{
    global $_CONF, $CONF_FORUM;
    include_once 'geshi.php';
    $geshi = new Geshi($str, $type, "{$CONF_FORUM['path_include']}geshi");
    $geshi->set_header_type(GESHI_HEADER_DIV);
    //$geshi->enable_strict_mode(true);
    //$geshi->enable_classes();
    $geshi->enable_line_numbers(GESHI_NO_LINE_NUMBERS, 5);
    $geshi->set_overall_style('font-size: 12px; color: #000066; border: 1px solid #d0d0d0; background-color: #FAFAFA;', true);
    // Note the use of set_code_style to revert colours...
    $geshi->set_line_style('font: normal normal 95% \'Courier New\', Courier, monospace; color: #003030;', 'font-weight: bold; color: #006060;', true);
    $geshi->set_code_style('color: #000020;', 'color: #000020;');
    $geshi->set_line_style('background: red;', true);
    $geshi->set_link_styles(GESHI_LINK, 'color: #000060;');
    $geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;');
    $geshi->set_header_content("{$type} Formatted Code");
    $geshi->set_header_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 90%; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;');
    return $geshi->parse_code();
}
 public function getGeshiCss($value)
 {
     $geshi = new \Geshi('', $value);
     return $geshi->get_stylesheet(false);
 }
 /**
  * Helper function for overriding some GeSHi defaults.
  *
  * @param \Geshi $geshi
  *   Geshi object.
  * @param string $langcode
  *   The language.
  */
 public static function overrideGeshiDefaults(\Geshi &$geshi, $langcode)
 {
     $config = \Drupal::config('geshifilter.settings');
     // Override the some default GeSHi styles (e.g. GeSHi uses Courier by
     // default, which is ugly).
     $geshi->set_line_style('font-family: monospace; font-weight: normal;', 'font-family: monospace; font-weight: bold; font-style: italic;');
     $geshi->set_code_style('font-family: monospace; font-weight: normal; font-style: normal');
     // Overall class needed for CSS.
     $geshi->set_overall_class('geshifilter-' . $langcode);
     // Set keyword linking.
     $geshi->enable_keyword_links($config->get('enable_keyword_urls', TRUE));
 }
Example #10
0
 /**
  * ?????
  * @const string $svn_url リポジトリのURL
  */
 public function source_browse($package_name, $path = '')
 {
     if (empty($path)) {
         $this->redirect_method('source_browse', $package_name, '/trunk');
     }
     // TODO 仕様の確認
     // TODO SVNとの連携
     $package = C(OpenpearPackage)->find_get(Q::eq('name', $package_name));
     $path = rtrim(ltrim($path, ' /.'), '/');
     $local_root = File::absolute(OpenpearConfig::svn_root(), $package->name());
     $repo_path = File::absolute($local_root, $path);
     $info = Subversion::cmd('info', array($repo_path));
     if ($info['kind'] === 'dir') {
         $this->vars('tree', self::format_tree(Subversion::cmd('list', array($info['url']), array('revision' => $this->in_vars('rev', 'HEAD')))));
     } else {
         if ($info['kind'] === 'file') {
             $this->put_block('package/source_viewfile.html');
             $p = explode('.', $info['path']);
             $ext = array_pop($p);
             if (in_array($ext, $this->allowed_ext)) {
                 $source = Subversion::cmd('cat', array($info['url']), array('revision' => $this->in_vars('rev', 'HEAD')));
                 $this->vars('code', $source);
                 try {
                     $cache_key = array('syntax_highlight', md5($source));
                     if (Store::has($cache_key)) {
                         $this->vars('code', Store::get($cache_key));
                     } else {
                         include_once 'geshi/geshi.php';
                         $geshi = new Geshi($source, $ext);
                         $code = $geshi->parse_code();
                         Store::set($cache_key, $code);
                         $this->vars('code', $code);
                     }
                     $this->vars('geshi', true);
                 } catch (Exception $e) {
                     Log::debug($e);
                     $this->vars('geshi', false);
                 }
             }
         } else {
             $this->redirect_by_map('package', $package_name);
         }
     }
     $this->vars('path', $path);
     $this->vars('info', self::format_info($info));
     $this->vars('package', $package);
     $this->vars('real_url', File::absolute(OpenpearConfig::svn_url(), implode('/', array($package->name(), $path))));
     $this->vars('externals', Subversion::cmd('propget', array('svn:externals', $info['url'])));
     $this->add_vars_other_tree($package_name);
 }
Example #11
0
        // TODO validate?
    }
    // For the header's pagenav
    $info = git_get_commit_info($page['project'], $page['commit_id']);
    $page['commit_id'] = $info['h'];
    $page['tree_id'] = $info['tree'];
    $page['pathinfo'] = git_get_path_info($page['project'], $page['commit_id'], $page['path']);
    $page['data'] = fix_encoding(join("\n", run_git($page['project'], "cat-file blob {$page['hash']}")));
    $page['lastlog'] = git_get_commit_info($page['project'], 'HEAD', $page['path']);
    // GeSHi support
    if ($conf['geshi'] && strpos($page['path'], '.')) {
        $old_mask = error_reporting(E_ALL ^ E_NOTICE);
        require_once $conf['geshi_path'];
        $parts = explode('.', $page['path']);
        $ext = array_pop($parts);
        $geshi = new Geshi($page['data']);
        $lang = $geshi->get_language_name_from_extension($ext);
        if (strlen($lang) > 0) {
            $geshi->set_language($lang);
            if (is_int($conf['geshi_line_numbers'])) {
                if ($conf['geshi_line_numbers'] == 0) {
                    $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
                } else {
                    $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, $conf['geshi_line_numbers']);
                }
            }
            $page['html_data'] = $geshi->parse_code();
        }
        error_reporting($old_mask);
    }
} elseif (in_array($action, array_keys(VGPlugin::$plugin_actions))) {
Example #12
0
 /**
  * Display a file using appropriate highlighting
  *
  * @return void
  */
 public function showAction()
 {
     include_once 'geshi/geshi.php';
     $this->view->project = $this->_project;
     $config = new USVN_Config_Ini(USVN_CONFIG_FILE, USVN_CONFIG_SECTION);
     $project_name = str_replace(USVN_URL_SEP, '/', $this->_project->name);
     $svn_file_path = $this->getRequest()->getParam('file');
     $this->view->path = $svn_file_path;
     $local_file_path = USVN_SVNUtils::getRepositoryPath($config->subversion->path . "/svn/" . $project_name . "/" . $svn_file_path);
     $file_ext = pathinfo($svn_file_path, PATHINFO_EXTENSION);
     $revision = $this->getRequest()->getParam('rev');
     $file_rev = '';
     if (!empty($revision)) {
         if (is_numeric($revision) && $revision > 0) {
             $cmd = USVN_SVNUtils::svnCommand("log --non-interactive --revision {$revision} --quiet {$local_file_path}");
             $verif = USVN_ConsoleUtils::runCmdCaptureMessageUnsafe($cmd, $return);
             if (!$return) {
                 $this->view->revision = $revision;
                 $file_rev = '--revision ' . $revision;
             }
         }
     }
     if (empty($file_rev)) {
         $cmd = USVN_SVNUtils::svnCommand("info {$local_file_path}");
         $infos = USVN_ConsoleUtils::runCmdCaptureMessageUnsafe($cmd, $return);
         if (preg_match_all('#^([^:]+): (.*)$#m', $infos, $tmp)) {
             $infos = array();
             foreach ($tmp[1] as $k => $v) {
                 $infos[$v] = $tmp[2][$k];
             }
             $this->view->revision = $infos['Last Changed Rev'];
             if ($revision) {
                 $this->view->message = T_("The requested revision does not exist. Switching to the last changed revision.");
             }
         }
     }
     $cmd = USVN_SVNUtils::svnCommand("log --non-interactive --quiet {$local_file_path}");
     $revs = USVN_ConsoleUtils::runCmdCaptureMessageUnsafe($cmd, $return);
     if (preg_match_all('#^r([0-9]+) \\|#m', $revs, $tmp)) {
         $revs = array();
         $this->view->prev_revision = NULL;
         $this->view->next_revision = NULL;
         foreach ($tmp[1] as $k => $rev) {
             if ($this->view->prev_revision === NULL && intval($rev) < intval($this->view->revision)) {
                 $this->view->prev_revision = $rev;
             }
             if ($rev > $this->view->revision) {
                 $this->view->next_revision = $rev;
             }
             $revs[] = $rev;
         }
         $this->view->select_revisions = $revs;
     }
     $cmd = USVN_SVNUtils::svnCommand("cat --non-interactive {$file_rev} {$local_file_path}");
     $source = USVN_ConsoleUtils::runCmdCaptureMessageUnsafe($cmd, $return);
     if ($return) {
         throw new USVN_Exception(T_("Can't read from subversion repository.\nCommand:\n%s\n\nError:\n%s"), $cmd, $message);
     } else {
         $this->view->color_view = $this->getRequest()->getParam('color');
         $this->view->diff_view = $this->getRequest()->getParam('diff');
         $this->view->diff_revision = $this->getRequest()->getParam('drev');
         if ($this->view->diff_revision >= $this->view->revision) {
             $this->view->diff_revision = $this->view->prev_revision;
         }
         if ($this->getRequest()->getParam('post') === NULL) {
             $this->view->color_view = 1;
         }
         $geshi = new Geshi();
         $lang_name = $geshi->get_language_name_from_extension($file_ext);
         $this->view->language = $lang_name;
         $geshi->set_language($this->view->color_view ? $lang_name : NULL, true);
         $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
         if ($this->view->diff_view && ($this->view->diff_revision || $this->view->prev_revision)) {
             $d_revs = ($this->view->diff_revision ? $this->view->diff_revision : $this->view->prev_revision) . ':' . $this->view->revision;
             $cmd = USVN_SVNUtils::svnCommand("diff --non-interactive --revision {$d_revs} {$local_file_path}");
             $diff = USVN_ConsoleUtils::runCmdCaptureMessageUnsafe($cmd, $return);
             if ($return) {
                 $this->view->message = T_('The requested diff revision does not exist.');
             } else {
                 $new_source = array();
                 $source = explode("\n", $source);
                 array_pop($source);
                 // Skip the final "\n"
                 $diff = explode("\n", $diff);
                 array_pop($diff);
                 // Skip the final "\n"
                 $source_line = NULL;
                 $count_line = 0;
                 $diff_lines = array();
                 while (($line = array_shift($diff)) !== NULL) {
                     $line = trim($line);
                     if (preg_match('#^@@ \\-[0-9,]+ \\+([0-9]+),[0-9]+ @@$#', $line, $tmp)) {
                         if ($source_line === NULL) {
                             $source_line = 1;
                         }
                         while (intval($source_line) < intval($tmp[1])) {
                             array_push($new_source, array_shift($source));
                             $source_line++;
                             $count_line++;
                         }
                         continue;
                     }
                     if ($source_line !== NULL) {
                         $diff_char = substr($line, 0, 1);
                         if ($diff_char == '\\') {
                             continue;
                         } elseif ($diff_char == '-') {
                             array_push($new_source, substr($line, 1));
                             $diff_lines[$count_line] = '-';
                         } else {
                             if ($diff_char == '+') {
                                 $diff_lines[$count_line] = '+';
                             }
                             array_push($new_source, array_shift($source));
                             $source_line++;
                         }
                         $count_line++;
                     }
                 }
                 if (count($source)) {
                     $new_source = array_merge($new_source, $source);
                 }
                 $source = implode("\n", $new_source);
                 unset($new_source);
                 $this->view->diff_lines = $diff_lines;
             }
         }
         $geshi->set_source($source);
         $geshi->set_header_type(GESHI_HEADER_DIV);
         $this->view->highlighted_source = $geshi->parse_code();
         if ($this->view->diff_view) {
             if (preg_match('#^<div ([^>]*)><ol>(.*)</ol></div>(\\s*)$#s', $this->view->highlighted_source, $tmp)) {
                 $this->view->diff_div = $tmp[1];
                 $this->view->highlighted_source = $tmp[2];
             }
         }
     }
 }
Example #13
0
    public function showPaste()
    {
        // Nothing given? go home
        if (!array_key_exists('id', $_GET) && !array_key_exists('code', $_GET)) {
            redirect(WEB_PATH);
        }
        // Using code?
        if (array_key_exists('code', $_GET)) {
            $code = $this->_sql->escape(trim($_GET['code']));
            $q = "`code` = '{$code}'";
        } elseif (array_key_exists('id', $_GET)) {
            $id = $this->_sql->escape(trim($_GET['id']));
            $id = hexdec($id);
            // deliberately fail for new posts
            if ($id > 1080) {
                $id = -1;
            }
            $q = "`id` = '{$id}'";
        }
        // Try getting it
        $get = $this->_sql->query("\n\t\t\tselect\n\t\t\t\t`date`, `language`, `paste`, `id`, `code`, `password`, `ip`, `private`\n\t\t\tfrom\n\t\t\t\t`pastes`\n\t\t\twhere\n\t\t\t\t{$q}\n\t\t\tlimit 1\n\t\t");
        // Not existant?
        if ($this->_sql->num($get) == 0) {
            $this->_layout->error('Paste not existant');
        }
        // Is; get info then free ram
        $info = $this->_sql->fetch_assoc($get);
        $this->_sql->free($info);
        // permalink
        $permalink = 'http://bn6.it/' . ($info['code'] != '' ? 'p/' . htmlspecialchars($info['code']) : dechex($info['id']));
        // Is passworded
        if (!array_key_exists($info['id'], $_SESSION['my_pastes']) && strlen($info['password']) == 32) {
            // Show form if not submitted or if password is incorrect
            if (!array_key_exists('paste_pw', $_POST) || trim($info['password']) != md5($info['ip'] . $_POST['paste_pw'])) {
                // If password submitted but incorrect say so
                if (array_key_exists('paste_pw', $_POST) && trim($info['password']) != md5($info['ip'] . $_POST['paste_pw'])) {
                    $this->_layout->setError('Invalid password');
                }
                $this->_layout->head('Private Passworded Paste');
                echo '
				<form action="' . $permalink . '" method="post">
					<div id="pw_form">
						<div class="form_row"><label for="paste_pw">Password for paste:</label>
						<input type="password" id="paste_pw" name="paste_pw" /></div>
						<div class="form_row">
						<input type="submit" value="View" /></div>
					</div>
				</form>
				';
                $this->_layout->foot();
                return;
            }
        }
        // Update last viewed
        $this->_sql->query("update `pastes` set `last_view` = unix_timestamp() where `id` = '{$info['id']}' limit 1");
        // determine language
        $t = $this->getTypes(true);
        $type = 'plaintext';
        if ($info['language'] > 0) {
            foreach ($t as $ti) {
                if ($ti[0] == $info['language']) {
                    $type = $ti[1];
                    break;
                }
            }
        }
        // load geshi
        require_once LOCAL_PATH . 'geshi/geshi.php';
        $geshi = new Geshi($info['paste'], $type);
        $geshi->set_header_type(GESHI_HEADER_DIV);
        $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
        // Auto focus permalink box, if was me who submitted it
        if (array_key_exists($info['id'], $_SESSION['my_pastes'])) {
            $this->_layout->setSelect('perma');
            unset($_SESSION['my_pastes'][$info['id']]);
        }
        // start layout
        $this->_layout->head($type);
        // give it
        echo '<div id="paste">
		<div id="paste_body">
		' . $geshi->parse_code() . '
		</div>
		</div>
		<div id="paste_meta">
		<form action="" method="post" onsubmit="return false;" class="fake_form">
			<ul>
				<li><label for="perma">Permalink:</label> <input title="Protip: this field is auto-selected on any paste page for clickless copying" onfocus="this.select();" id="perma" type="text" class="uneditable" readonly="readonly" value="' . $permalink . '" /></li>
				<li>Date posted: ' . date('m/d/Y @ h:i A', $info['date']) . '</li>
				' . ($info['private'] ? '<li>This paste is private.</li>' : '') . '
			</ul>
		</form>
		</div>';
        // Show form with this paste stuff already in it
        echo '<h2>Revise/reply to paste</h2>';
        $this->showForm(array('reply' => true, 'lang' => $info['language'], 'post' => stripslashes($info['paste'])), false);
        // end layout
        $this->_layout->foot();
    }
Example #14
0
        $pUpload->incrementViews();
        header("Not Modified: Use browser cache", true, 304);
        return;
    }
}
/**
 *	Return things to the server...
 */
if ((isset($_GET["height"]) || isset($_GET["width"])) && substr($pUpload->mime_type, 0, 6) != "image/") {
    return;
} elseif (isset($_SEO[1])) {
    $sCacheItem = $aGlobalConfiguration["files"]["upload"] . "/cache/geshi-" . strtolower($_SEO[1]) . "-" . $pUpload->file_hash . ".html";
    $sRender = null;
    if (!file_exists($sCacheItem)) {
        $sContents = file_get_contents($pUpload->local_path);
        $pGeshi = new Geshi($sContents, $_SEO[1]);
        $sRender = $pGeshi->parse_code();
        file_put_contents($sCacheItem, $sRender);
    } else {
        $sRender = file_get_contents($sCacheItem);
    }
    header("Cache-Control: public");
    header("Last-Modified: " . date("r", filemtime($sCacheItem)));
    header("Content-Length: " . filesize($sCacheItem));
    header("Content-Type: text/html");
    header("Content-Transfer-Encoding: binary");
    header("Content-MD5: " . md5_file($sCacheItem));
    header("Content-Disposition: inline; filename=" . $pFunctions->quote($pUpload->file_name));
    echo $sRender;
} else {
    header("Cache-Control: public");