Source of: highlight.php



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<?php $title = $_FILES['my_text']['name']; ?>
<title>Source of:
<?php echo $title ?>
</title>
<link rel="StyleSheet" href="simple1.css" type="text/css" media="screen" />
<style type="text/css" media="all">
@import "style1.css";
div.phpcode span.html { color: #000; }
div.phpcode span.comment { color: #f80; }
div.phpcode span.default { color: #00b; }
div.phpcode span.keyword { color: #070; }
div.phpcode span.string { color: #d00; }
h1 { font-size: 140%; }
</style>
</head>
<body>
<h1>Source of:
<?php echo $title ?>
</h1>
<ins>
<hr />
</ins>
<?php
// Use class names instead of colors
ini_set('highlight.comment', 'comment');
ini_set('highlight.default', 'default');
ini_set('highlight.keyword', 'keyword');
ini_set('highlight.string', 'string');
ini_set('highlight.html', 'html');

// Highlight PHP code
function highlight_php($code, $return = FALSE)
{
// Using OB, as highlight_string() only supports
// returning the result from 4.2.0
ob_start();
highlight_string($code);
$highlighted = ob_get_contents();
ob_end_clean();

// Fix output to use CSS classes and wrap well
// Hacked by Hal to get rid of ugly nbsps
$highlighted = '<div class="phpcode">' . str_replace(
array(
'<code>',
'</code>',
'<font color="',
'</font>',
'&nbsp;'
),
array(
"<pre><code>",
"</code></pre>",
'<span class="',
'</span>',
' '
),
$highlighted
) . '</div>';

if (
$return) { return $highlighted; }
else { echo
$highlighted; }
}

echo @
highlight_php(join("", file($_FILES['my_text']['tmp_name'])));

?>
</body>
</html>