<?php</span>="color: #FF8000">//error_reporting(E_ALL);class SyntaxColour {  var $in_php = false;  var $in_html_comment = false;  var $in_html_tag = false;  var $in_html_string = false;  var $html_parsing_arguments = false;  var $html_parsing_param = false;  var $html_existing = false;  var $in_php_ml_comment = false;  var $in_php_sl_comment = false;  var $in_php_string_dq = false;  var $in_php_string_sq = false;  function processCode($source) {    $len = strlen($source);    do {      $this -> output_char = true; // !?!      $ofset_increment = $this -> process($source, $ofs);      if ($ofset_increment == 0) {        $ca = substr($source, $ofs, 1);        echo "$ca";        $ofs += 1;      }      $ofs += $ofset_increment;    } while ($ofs <= $len);  }  function process($source, $ofs) {    if (match($source, $ofs, "&lt;?")) {      $this -> in_php = true;      echo "<SPAN CLASS=\"php_tags\">&lt;?</SPAN><SPAN CLASS=\"php_method\">";      return 5;    }    if ($this -> in_php) { // in PHP...      if (match($source, $ofs, "\\")) {        $escaped = substr($source, $ofs, 2);        echo "<SPAN CLASS='php_escaped'>$escaped</SPAN>";        return 2;      }      if (!$this -> in_php_string_sq) {        if (!$this -> in_php_string_dq) {          if ($this -> in_php_sl_comment) { // in_php_sl_comment            if (match($source, $ofs, "")) {              echo "</SPAN>";              $this -> in_php_sl_comment = false;              return 0;            }          } else { // !in_php_sl_comment            if (match($source, $ofs, "//")) {              echo "<SPAN CLASS='php_comment'>//";              $this -> in_php_sl_comment = true;              return 2;            }            if ($this -> in_php_ml_comment) { // in_php_ml_comment              if (match($source, $ofs, "*/")) {                echo "*/</SPAN>";                $this -> in_php_ml_comment = false;                return 2;              }            } else { // !in_php_ml_comment              if (match($source, $ofs, "/*")) {                echo "<SPAN CLASS='php_comment'>/*";                $this -> in_php_ml_comment = true;                return 2;              }            }          }        }      }      if (!$this -> in_php_ml_comment) { // !in_php_ml_comment        if (!$this -> in_php_sl_comment) { // !in_php_sl_comment          $char = substr($source, $ofs, 1);          if (!$this -> in_php_string_sq) {            if (match($source, $ofs, "\"")) {              if ($this -> in_php_string_dq) {                echo "\"</SPAN>";                $this -> in_php_string_dq = false;                return 1;              } else {                echo "<SPAN CLASS='php_string'>";                $this -> in_php_string_dq = true;                return 0;              }            }          }          if (!$this -> in_php_string_dq) {            if (match($source, $ofs, "'")) {              if ($this -> in_php_string_sq) {                echo "'</SPAN>";                $this -> in_php_string_sq = false;                return 1;              } else {                echo "<SPAN CLASS='php_string'>";                $this -> in_php_string_sq = true;                return 0;              }            }          }          if (!$this -> in_php_string_sq) {            if (!$this -> in_php_string_dq) {              if (isABracket($char)) {                echo "<SPAN CLASS='php_brackets'>$char</SPAN>";                return 1;              }              if (isABrace($char)) {                echo "<SPAN CLASS='php_braces'>$char</SPAN>";                return 1;              }              if (isOperators($char)) {                echo "<SPAN CLASS='php_operate'>$char</SPAN>";                return 1;              }              if (isPunctuation($char)) {                echo "<SPAN CLASS='php_punct'>$char</SPAN>";                return 1;              }              if (match($source, $ofs, "&gt;")) {                echo "<SPAN CLASS='php_punct'>&gt;</SPAN>";                return 4;              }              if (match($source, $ofs, "&lt;")) {                echo "<SPAN CLASS='php_punct'>&lt;</SPAN>";                return 4;              }              if (isANumber($char)) { // +                $length = returnLengthOfTheNumberAt($source, $ofs);                $number = substr($source, $ofs, $length);                $number_raw = $number;                if (isPlusOrMinus(substr($number_raw, 0, 1))) {                  $number_raw = substr($number_raw, 1);                }                if (substr($number_raw, 0, 1) == ".") {                  $number_raw = substr($number_raw, 1);                }                if (isAPositiveNumber($number_raw)) {                  echo "<SPAN CLASS='php_number'>$number</SPAN>";                  return $length;                }              }              if (!isATerminator($char)) {                if (isATerminator(substr($source, $ofs -1, 1))) {                  $length = returnLengthOfTheVariableAt($source, $ofs);                  $keyword = substr($source, $ofs, $length);                  if (isAKeyword($keyword)) {                    echo "<SPAN CLASS='php_keyword'>$keyword</SPAN>";                    return $length;                  } else                    if (isAConstant($keyword)) {                      echo "<SPAN CLASS='php_const'>$keyword</SPAN>";                      return $length;                    }                }              }            }          }          if ($char == "$") {            $length = returnLengthOfTheVariableAt($source, $ofs);            $var = substr($source, $ofs, $length);            echo "<SPAN CLASS='php_var'>$var</SPAN>";            return $length;          }        }      }    } else { // in HTML...      if ($this -> html_existing) {        if (match($source, $ofs, ">")) {          $this -> html_existing = false;        }      } else {        if (match($source, $ofs, "<")) {          $this -> html_existing = true;        }        if (match($source, $ofs, "&lt;!--")) {          echo "<SPAN CLASS='html_comment'>&lt;!--";          $this -> in_html_comment = true;          return 7;        }        if ($this -> in_html_comment == false) {          if (match($source, $ofs, "&lt;/")) { // </            echo "<SPAN CLASS='html_angle'>&lt;<SPAN CLASS='html_tag_clos'>/";            $this -> in_html_tag = true;            $this -> html_parsing_arguments = false;            $this -> html_parsing_param = false;            return 5;          } else            if (match($source, $ofs, "&lt;")) { // <              echo "<SPAN CLASS='html_angle'>&lt;<SPAN CLASS='html_tag_open'>";              $this -> in_html_tag = true;              $this -> html_parsing_arguments = false;              $this -> html_parsing_param = false;              return 4;            }          if (match($source, $ofs, "&gt;")) { // >            if ($this -> html_parsing_arguments) {              echo "</SPAN>";              $this -> html_parsing_arguments = false;            }            if ($this -> html_parsing_param) {              echo "</SPAN>";              $this -> html_parsing_param = false;            }            echo "</SPAN>&gt;</SPAN>";            $this -> in_html_tag = false;            return 4;          }          if ($this -> in_html_tag == true) {            if (!$this -> in_html_string) {              if (!$this -> html_parsing_param) {                if (match($source, $ofs, " ")) { // " "                  if ($this -> html_parsing_arguments) {                    echo "</SPAN>";                    $this -> html_parsing_arguments = false;                  }                  echo "<SPAN CLASS='html_param'>";                  $this -> html_parsing_param = true;                }              }              if (match($source, $ofs, "=")) { // =                if ($this -> html_parsing_param) {                  echo "</SPAN>";                  $this -> html_parsing_param = false;                }                echo "<SPAN CLASS='html_equals'>=</SPAN><SPAN CLASS='html_argument'>";                $this -> html_parsing_arguments = true;                return 1;              }              if ($this -> html_parsing_arguments) { // +                $digit = substr($source, $ofs, 1);                if (isANumber($digit)) { // +                  $length = returnLengthOfTheNumberAt($source, $ofs);                  $number = substr($source, $ofs, $length);                  echo "<SPAN CLASS='html_number'>$number</SPAN>";                  return $length;                }              }              if (match($source, $ofs, "'") || match($source, $ofs, "\"")) {                echo "<SPAN CLASS='html_string'>";                $this -> in_html_string = true;              }            } else              if ($this -> in_html_string) {                if (match($source, $ofs, "\"")) {                  echo "\"</SPAN>";                  $this -> in_html_string = false;                  return 1;                }                if (match($source, $ofs, "'")) {                  echo "'</SPAN>";                  $this -> in_html_string = false;                  return 1;                }              }          } else { // not in HTML tag...            if (match($source, $ofs, "&amp;")) {              $pentity = substr($source, $ofs +5, 8);              $peoend = strpos($pentity, ";");              if (!(peoend == false)) {                $aentity = substr($source, $ofs +5, $peoend);                echo "<SPAN CLASS='html_entity'>&amp;$aentity;</SPAN>";                return $peoend +6;              }            }          }        }        if (match($source, $ofs, "--&gt;")) {          echo "--&gt;</SPAN>";          $this -> in_html_comment = false;          return 6;        }      }    }    if (match($source, $ofs, "?&gt;")) {      $this -> in_php = false;      echo "</SPAN><SPAN CLASS=\"php_tags\">?&gt;</SPAN>";      return 5;    }    return 0;  }}$URL = $_GET['url'];if ($URL != null) {  colourURL($URL);}$path = $_GET['file'];if ($path != null) {  colourFile("$path");}function setUpStyles($title, $background = '#000000', $php_method = '#F0F0C0', $php_keyword = '#FFFF00', $php_string = '#A0A0FF', $php_comment = '#40FF40', $php_tags_bg = '#FFFF00', $php_tags = '#000080', $php_punct = '#FFD000', $php_brackets = '#FFD0D0', $php_braces = '#FF9090', $php_escaped = '#F08060', $php_operate = '#C0A0E0', $php_number = '#FFB090', $php_var = '#A0D0F0', $php_const = '#20E0E0', $html_text = '#FFFFFF', $html_comment = '#40FF40', $html_equals = '#F0F0C0', $html_string = '#C0C0FF', $html_number = '#F0C000', $html_entity = '#FF8060', $html_argument = '#C0E0C0', $html_param = '#E0C0C0', $html_angle = '#D0D020', $html_tag_open = '#FFE0A0', $html_tag_clos = '#E0A0E0') {  echo "<HTML><HEAD><TITLE>Source for $title</TITLE><style>\n";  echo "body { color: $html_text; background-color: $background; }\n";  echo ".source span.php_method   { color: $php_method; }\n";  echo ".source span.php_keyword  { color: $php_keyword; font-weight: bold;}\n";  echo ".source span.php_string   { color: $php_string; }\n";  echo ".source span.php_comment  { color: $php_comment; font-style: italic; }\n";  echo ".source span.php_tags     { color: $php_tags; background-color: $php_tags_bg; }\n";  echo ".source span.php_punct    { color: $php_punct; }\n";  echo ".source span.php_brackets { color: $php_brackets; }\n";  echo ".source span.php_braces   { color: $php_braces; }\n";  echo ".source span.php_escaped  { color: $php_escaped; }\n";  echo ".source span.php_operate  { color: $php_operate; }\n";  echo ".source span.php_number   { color: $php_number; }\n";  echo ".source span.php_var      { color: $php_var; }\n";  echo ".source span.php_const    { color: $php_const; font-weight: bold; }\n";  echo ".source span.html_text    { color: $html_text; }\n";  echo ".source span.html_equals  { color: $html_equals; font-weight: normal ; }\n";  echo ".source span.html_string  { color: $html_string; font-weight: normal ; }\n";  echo ".source span.html_number  { color: $html_number; font-weight: normal ; }\n";  echo ".source span.html_entity  { color: $html_entity; }\n";  echo ".source span.html_argument{ color: $html_argument; font-weight: bold; }\n";  echo ".source span.html_param   { color: $html_param; font-weight: bold; }\n";  echo ".source span.html_angle   { color: $html_angle; font-weight: bold; }\n";  echo ".source span.html_tag_open{ color: $html_tag_open; font-weight: bold; }\n";  echo ".source span.html_tag_clos{ color: $html_tag_clos; font-weight: bold; }\n";  echo ".source span.html_comment { color: $html_comment; font-style: italic; }\n";  echo "</style></HEAD><BODY>";}function colourFile($path) {  $chars_ok = ereg("([^a-zA-Z0-9/ :._-])|(\../|\./)", $path);  if ($chars_ok) {    die("Path contains forbidden characters or sequence");  }  $file = "../".$path;  if (!isSet($file)) {    die("Error: File not found");  } else {    $source = highlight_file($file, true);    output($path, $source);  }}function colourURL($url) {  $legal = strpos($url, "http");  if (($legal === false) || ($legal > 0)) {    die("URLs must start with 'http'");  }  $url_chars_ok = ereg("([^a-zA-Z0-9/ :._-])|(\../|\./)", $url);  if ($url_chars_ok) {    die("URL contains forbidden characters or sequence");  }  $handle = fopen($url, "r");  if ($handle == null) {    die("Error: The specified URL was not found");  }  $file = file($url);  $f_contents = implode("", file($url));  $source = highlight_string($f_contents, true);  fclose($handle);  output($url, $source);}function output($title, $source) {  setUpStyles($title);  $source = replaceCode($source);  startPrintingCode();  $sc = new SyntaxColour();  $sc -> processCode($source);  endPrintingCode();}function startPrintingCode() {  echo '<PRE CLASS="source">';}function endPrintingCode() {  echo '</PRE>';  echo '</BODY>';  echo '</HTML>';}function replaceCode($source) {  $search[0] = '<font color="'.ini_get('highlight.html').'">';  $search[1] = '<font color="'.ini_get('highlight.default').'">';  $search[2] = '<font color="'.ini_get('highlight.keyword').'">';  $search[3] = '<font color="'.ini_get('highlight.string').'">';  $search[4] = '<font color="'.ini_get('highlight.comment').'">';  $search[5] = '</font>';  $search[6] = '&nbsp;';  $search[7] = '<br />';  $search[8] = '';  $replace[0] = '';  $replace[1] = '';  $replace[2] = '';  $replace[3] = '';  $replace[4] = '';  $replace[5] = '';  $replace[6] = ' ';  $replace[7] = '';  $replace[8] = '';  return str_replace($search, $replace, $source);}function match($source, $ofs, $string) {  $len = strlen($string);  if (strlen($source) < $ofs + $len) {    return false;  }  $slice = substr($source, $ofs, $len);  return ($string == $slice);}function isANumber($digit) {  if ((strpos("0123456789+-%", $digit) == false)) {    return false;  }  return true;}function isADigitOrADot($digit) {  if ((strpos("0123456789.", $digit) == false)) {    return false;  }  return true;}function isPunctuation($char) {  if ((strpos(".,:;", $char) == false)) {    return false;  }  return true;}function isOperators($char) {  if ((strpos("!=|*+-/", $char) == false)) {    return false;  }  return true;}function isATerminator($char) {  if ($char < "0") {    return true;  }  if ((strpos("=[]{}|`;?*/<>&$", $char) == false)) {    return false;  }  return true;}function isABracket($char) {  if ((strpos("[]()", $char) == false)) {    return false;  }  return true;}function isABrace($char) {  if ((strpos("{}", $char) == false)) {    return false;  }  return true;}function isPlusOrMinus($char) {  if ((strpos("-+", $char) == false)) {    return false;  }  return true;}function isAPositiveNumber($number) {  $length = strlen($number);  if ($length < 1) {    return false;  }  for ($i = 0; $i < $length; $i ++) {    if (!isADigitOrADot(substr($number, $i, 1))) {      return false;    }  }  return true;}function returnLengthOfTheNumberAt($source, $ofs) {  $index = 0;  do {    $index = $index +1;    $digit = substr($source, $ofs + $index, 1);  } while (isANumber($digit));  return $index;}function returnLengthOfTheVariableAt($source, $ofs) {  $index = 0;  do {    $index = $index +1;    $digit = substr($source, $ofs + $index, 1);  } while (!isATerminator($digit));  return $index;}function isAKeyword($keyword) {  $keywords = array("and", "or", "xor", "array", "as", "break", "case", "cfunction", "class", "const", "continue", "declare", "default", "die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends", "for", "foreach", "function", "global", "if", "include", "include_once", "isset", "list", "new", "old_function", "print", "require", "require_once", "return", "static", "switch", "unset", "use", "var", "while", "__FUNCTION__", "__CLASS__", "__FILE__", "__LINE__");  $length = sizeof($keywords);  for ($i = 0; $i < $length; $i ++) {    if ($keyword == $keywords[$i]) {      return true;    }  }  return false;}function isAConstant($constant) {  $constants = array("php", "true", "false", "null");  $length = sizeof($constants);  for ($i = 0; $i < $length; $i ++) {    if ($constant == $constants[$i]) {      return true;    }  }  return false;}?>