// ... // </ol></pre> $geshi->set_line_style('color: #003030;', 'font-weight: bold; color: #006060;', true); $geshi->set_code_style('color: #000020;', true); // Styles for hyperlinks in the code. GESHI_LINK for default styles, GESHI_HOVER for hover style etc... // note that classes must be enabled for this to work. $geshi->set_link_styles(GESHI_LINK, 'color: #000060;'); $geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;'); // Use the header/footer functionality. This puts a div with content within the PRE element, so it is // affected by the styles set by set_overall_style. So if the PRE has a border then the header/footer will // appear inside it. $geshi->set_header_content('<SPEED> <TIME> GeSHi © 2004-2007, Nigel McNie, 2007-2008 Benny Baumann. View source of example.php for example of using GeSHi'); $geshi->set_header_content_style('font-family: sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;'); // You can use <TIME> and <VERSION> as placeholders $geshi->set_footer_content('Parsed in <TIME> seconds at <SPEED>, using GeSHi <VERSION>'); $geshi->set_footer_content_style('font-family: sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-top: 1px solid #d0d0d0; padding: 2px;'); } else { // make sure we don't preselect any language $_POST['language'] = null; } ?> <!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>GeSHi examples</title> <style type="text/css"> <!-- <?php if (isset($_POST['submit'])) { // Output the stylesheet. Note it doesn't output the <style> tag
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 = ""; }
$geshi->set_highlight_lines_extra_style('background:#FFFF88;'); $geshi->enable_keyword_links(false); //geshi line numbers $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $geshi->set_header_type(GESHI_HEADER_DIV); //geshi styling for syntax box $geshi->set_overall_style('color: #000066; border: 1px solid #d0d0d0; background-color: #fdfdf6; line-height:1.3em;', true); $geshi->set_line_style('font: normal normal \'Courier New\', Courier, monospace; color: #003030;', 'font-weight: bold; color: #006060; padding-right: 5px;', true); $geshi->set_code_style('color: #000020;', 'color: #000020;'); if ($drop['editable'] == 1) { if (!isset($_GET['passkey'])) { $editable = ' You may <a href="' . $DROP_CONF_siteURL . '/' . $drop['id'] . '/edit">edit this</a> drop.'; } else { $editable = ' You may <a href="' . substr($_SERVER['REQUEST_URI'], 0, -30) . '/edit?pkey=' . $_GET['passkey'] . '">edit this</a> drop.'; } } else { if ($drop['editable'] == 0) { $editable = ''; } else { die("WOAH! WE HAVE AN ERROR IN THE HOUSE!!! CONTACT THE AUTHORITIES!"); } } $geshi->set_header_content('You are viewing Drop #' . $drop['id'] . ' and it is being highlighted with the ' . $drop['lang'] . ' syntax.' . $editable); $geshi->set_header_content_style('font-family: Verdana, Arial, sans-serif; color: #414141; background-color: #d2d2c8; border-bottom: 1px solid #d0d0d0; padding: 2px;'); if (!isset($drops[1])) { $geshi->set_footer_content('Parsed in <TIME> seconds'); } $geshi->set_footer_content_style('font-family: Verdana, Arial, sans-serif; color: #414141; background-color: #d2d2c8; border-top: 1px solid #d0d0d0; padding: 2px;'); //geshi results echo $geshi->parse_code(); //echo $drop['text'];