preg_match_all("#\\[geshi=(.*?)\\](.*?)\\[/geshi\\]#si", $text, $matches, PREG_PATTERN_ORDER); for ($i = 0; $i < count($matches[1]); $i++) { $lines = explode("\n", $matches[2][$i]); if (count($lines) < 200) { $input = str_replace('<br>', '', str_replace('<br />', '', str_replace('<br />', '', stripslashes($matches[2][$i])))); //replace problematic characters $search = array("\\", """, "'", "\", """, "'", "<", ">", "&"); $replace = array("\\\\", "\"", "'", "\\", "\"", "\\'", "<", ">", "&"); $input = str_replace($search, $replace, $input); $geshi = new GeSHi($input, $matches[1][$i]); $geshi->set_header_type(GESHI_HEADER_PRE); $geshi->set_overall_style('font-family:\'Courier New\', Courier; font-size:12px;'); $geshi->set_link_styles(GESHI_LINK, 'font-weight:bold;'); $geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;'); $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 10); $geshi->set_footer_content($locale['bb_geshi_info']); $geshi->set_footer_content_style('font-family:Verdana,Arial,sans-serif;color:#808080;font-size:9px;font-weight:bold;background-color:#f0f0ff;border-top: 1px solid #d0d0d0;padding:2px;width:400px'); if (preg_match("/\\/forum\\//i", FUSION_REQUEST) && isset($data['post_id'])) { $geshi_save = "<a href='" . INCLUDES . "bbcodes/geshi_bbcode_save.php?thread_id=" . $_GET['thread_id'] . "&post_id=" . $data['post_id'] . "&code_id=" . $i . "'><img src='" . INCLUDES . "bbcodes/images/geshi_save.png' alt='" . $locale['bb_geshi_save'] . "' title='" . $locale['bb_geshi_save'] . "' style='border:none' /></a> "; } else { $geshi_save = ""; } $text = preg_replace("#\\[geshi=(.*?)\\](.*?)\\[/geshi\\]#si", '$2', $text); $text = str_replace($matches[2][$i], "<div class='tbl-border tbl2' style='width:400px'>" . $geshi_save . "<strong>GeSHi: " . $geshi->get_language_name() . "</strong></div><div class='tbl-border tbl1' style='width:400px;height:auto;white-space:nowrap;overflow:auto;background-color:#ffffff;'><code style='white-space:nowrap'>" . $geshi->parse_code() . "</code></div>", $text); } else { $ccount = substr_count($text, "[geshi="); for ($i = 0; $i < $ccount; $i++) { if (preg_match("/\\/forum\\//i", FUSION_REQUEST) && isset($data['post_id'])) { $geshi_save = "<a href=\\'" . INCLUDES . "bbcodes/geshi_bbcode_save.php?thread_id=" . $_GET['thread_id'] . "&post_id=" . $data['post_id'] . "&code_id=" . $i . "\\'><img src=\\'" . INCLUDES . "bbcodes/images/geshi_save.png\\' alt=\\'" . $locale['bb_geshi_save'] . "\\' title=\\'" . $locale['bb_geshi_save'] . "\\' style=\\'border:none\\' /></a> "; } else { $geshi_save = "";
///////////////////////////////////////////////////////////////////////// if (!defined("IN_PASTE")) { die("Access denied!"); } // Parse code in geshi lib include_once 'libs/geshi/geshi.php'; $id = isset($_GET["id"]) ? $_GET["id"] : ""; $p = $startUp->getPaste($id); if (isset($_GET['download'])) { header("Content-type: text/plain"); header("Content-Disposition: attachment; filename=" . $p['title'] . ""); header("Content-Description: " . $p['lang'] . " Generated Data"); echo html_entity_decode(htmlspecialchars_decode($p['paste'])); exit; } if (!empty($p)) { $geshi = new GeSHi(html_entity_decode(htmlspecialchars_decode($p['paste'])), $p['lang']); $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); $geshi->set_header_type(GESHI_HEADER_DIV); $geshi->set_case_keywords(GESHI_CAPS_LOWER); $geshi->set_footer_content('Parsed in <TIME> seconds'); $smarty->assign("result", $geshi->parse_code()); $smarty->assign("getPaste", $p); // Update hits $startUp->updateHits($id); } $hook->set_title('title_paste', 'Detail paste'); $hook->addcontentPaste('defaultpaste', '', 3); if ($hook->hook_exist('paste_page')) { $hook->execute_hook('paste_page'); }
} // Prepare GeSHi instance $geshi = new GeSHi(); $geshi->set_language('text'); $geshi->load_from_file($path); $geshi->set_header_type(GESHI_HEADER_PRE); $geshi->enable_classes(); $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 10); $geshi->set_overall_style('color: #000066; border: 1px solid #d0d0d0; background-color: #f0f0f0;', true); $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_link_styles(GESHI_LINK, 'color: #000060;'); $geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;'); $geshi->set_header_content('Source code viewer - ' . $path . ' - ' . $geshi->get_language_name()); $geshi->set_header_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;'); $geshi->set_footer_content('Parsed in <TIME> seconds, using GeSHi <VERSION>'); $geshi->set_footer_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-top: 1px solid #d0d0d0; padding: 2px;'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Source code viewer - <?php echo $path; ?> - <?php $geshi->get_language_name(); ?> </title> <style type="text/css"> <!--