--- code-viewer.txt Mon Aug 29 07:08:37 2005 +++ code-viewer.php Sun Nov 18 09:33:15 2007 @@ -9,14 +9,15 @@ */ /* Configuration Settings */ -$default_path = "http://elasticdog.com/code/"; // the absolute path of your code folder +$default_path = "http://{$_SERVER['HTTP_HOST']}/code/"; // the absolute path of your code folder /* --- STOP EDITING --- */ +require_once('geshi/geshi.php'); function code_viewer($text) { global $default_path; - $count = preg_match_all('//', $text, $matches); + $count = preg_match_all('//', $text, $matches); for ($i = 0; $i < $count; $i++) { // Determine if the specified path is absolute, or relative to the root path @@ -29,6 +30,9 @@ $path = $default_path . $matches[1][$i]; } + if(strtolower($matches[3][$i]) != "") { + $language = $matches[3][$i]; + } // Open the file // If the file can't be found, print an error message if ($lines = @file($path)) { @@ -44,8 +48,11 @@ } else { $numtabs = strlen($line) - strlen(ltrim($line)); // determine the number of tabs $line = trim($line); // trim leading/trailing whitespace - - $codelist .= "\t" . '
  • ' . htmlspecialchars($line) . '
  • ' . "\n"; + if(isset($language)) { + $codelist .= "\t" . '
  • ' . geshi_highlight($line, $language, null, true) . '
  • ' . "\n"; + } else { + $codelist .= "\t" . '
  • ' . htmlspecialchars($line) . '
  • ' . "\n"; + } } } @@ -76,4 +83,4 @@ add_filter('the_content', 'code_viewer', 9); add_filter('the_content', 'fix_bad_p'); -?> \ No newline at end of file +?>