Your IP : 216.73.216.224


Current Path : /home/b/o/u/bourgleram/www/398a1/
Upload File :
Current File : /home/b/o/u/bourgleram/www/398a1/classes.tar

HTMLSax3/Decorators.php000066600000007147152526670570010721 0ustar00<?php
class XML_HTMLSax3_Trim {
 var $orig_obj;
 var $orig_method;
 function XML_HTMLSax3_Trim(&$orig_obj, $orig_method) {
  $this->orig_obj =& $orig_obj;
  $this->orig_method = $orig_method;
 }
 function trimData(&$parser, $data) {
  $data = trim($data);
  if ($data != '') {
   $this->orig_obj->{$this->orig_method}($parser, $data);
  }
 }
}
class XML_HTMLSax3_CaseFolding {
 var $orig_obj;
 var $orig_open_method;
 var $orig_close_method;
 function XML_HTMLSax3_CaseFolding(&$orig_obj, $orig_open_method, $orig_close_method) {
  $this->orig_obj =& $orig_obj;
  $this->orig_open_method = $orig_open_method;
  $this->orig_close_method = $orig_close_method;
 }
 function foldOpen(&$parser, $tag, $attrs=array(), $empty = FALSE) {
  $this->orig_obj->{$this->orig_open_method}($parser, strtoupper($tag), $attrs, $empty);
 }
 function foldClose(&$parser, $tag, $empty = FALSE) {
  $this->orig_obj->{$this->orig_close_method}($parser, strtoupper($tag), $empty);
 }
}
class XML_HTMLSax3_Linefeed {
 var $orig_obj;
 var $orig_method;
 function XML_HTMLSax3_LineFeed(&$orig_obj, $orig_method) {
  $this->orig_obj =& $orig_obj;
  $this->orig_method = $orig_method;
 }
 function breakData(&$parser, $data) {
  $data = explode("\n",$data);
  foreach ( $data as $chunk ) {
   $this->orig_obj->{$this->orig_method}($parser, $chunk);
  }
 }
}
class XML_HTMLSax3_Tab {
 var $orig_obj;
 var $orig_method;
 function XML_HTMLSax3_Tab(&$orig_obj, $orig_method) {
  $this->orig_obj =& $orig_obj;
  $this->orig_method = $orig_method;
 }
 function breakData(&$parser, $data) {
  $data = explode("\t",$data);
  foreach ( $data as $chunk ) {
   $this->orig_obj->{$this->orig_method}($this, $chunk);
  }
 }
}
class XML_HTMLSax3_Entities_Parsed {
 var $orig_obj;
 var $orig_method;
 function XML_HTMLSax3_Entities_Parsed(&$orig_obj, $orig_method) {
  $this->orig_obj =& $orig_obj;
  $this->orig_method = $orig_method;
 }
 function breakData(&$parser, $data) {
  $data = preg_split('/(&.+?;)/',$data,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  foreach ( $data as $chunk ) {
   $chunk = html_entity_decode($chunk,ENT_NOQUOTES);
   $this->orig_obj->{$this->orig_method}($this, $chunk);
  }
 }
}
if (version_compare(phpversion(), '4.3', '<') && !function_exists('html_entity_decode') ) {
 function html_entity_decode($str, $style=ENT_NOQUOTES) {
  return strtr($str,
   array_flip(get_html_translation_table(HTML_ENTITIES,$style)));
 }
}
class XML_HTMLSax3_Entities_Unparsed {
 var $orig_obj;
 var $orig_method;
 function XML_HTMLSax3_Entities_Unparsed(&$orig_obj, $orig_method) {
  $this->orig_obj =& $orig_obj;
  $this->orig_method = $orig_method;
 }
 function breakData(&$parser, $data) {
  $data = preg_split('/(&.+?;)/',$data,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  foreach ( $data as $chunk ) {
   $this->orig_obj->{$this->orig_method}($this, $chunk);
  }
 }
}

class XML_HTMLSax3_Escape_Stripper {
 var $orig_obj;
 var $orig_method;
 function XML_HTMLSax3_Escape_Stripper(&$orig_obj, $orig_method) {
  $this->orig_obj =& $orig_obj;
  $this->orig_method = $orig_method;
 }
 function strip(&$parser, $data) {
  if ( substr($data,0,2) == '--' ) {
   $patterns = array(
    '/^\-\-/',    // Opening comment: --
    '/\-\-$/',    // Closing comment: --
   );
   $data = preg_replace($patterns,'',$data);

  } else if ( substr($data,0,1) == '[' ) {
   $patterns = array(
    '/^\[.*CDATA.*\[/s', // Opening CDATA
    '/\].*\]$/s',    // Closing CDATA
    );
   $data = preg_replace($patterns,'',$data);
  }

  $this->orig_obj->{$this->orig_method}($this, $data);
 }
}
?>HTMLSax3/States.php000066600000012027152526670570010050 0ustar00<?php
define('XML_HTMLSAX3_STATE_STOP', 0);
define('XML_HTMLSAX3_STATE_START', 1);
define('XML_HTMLSAX3_STATE_TAG', 2);
define('XML_HTMLSAX3_STATE_OPENING_TAG', 3);
define('XML_HTMLSAX3_STATE_CLOSING_TAG', 4);
define('XML_HTMLSAX3_STATE_ESCAPE', 6);
define('XML_HTMLSAX3_STATE_JASP', 7);
define('XML_HTMLSAX3_STATE_PI', 8);
class XML_HTMLSax3_StartingState  {
 function parse(&$context) {
  $data = $context->scanUntilString('<');
  if ($data != '') {
   $context->handler_object_data->
    {$context->handler_method_data}($context->htmlsax, $data);
  }
  $context->IgnoreCharacter();
  return XML_HTMLSAX3_STATE_TAG;
 }
}
class XML_HTMLSax3_TagState {
 function parse(&$context) {
  switch($context->ScanCharacter()) {
  case '/':
   return XML_HTMLSAX3_STATE_CLOSING_TAG;
   break;
  case '?':
   return XML_HTMLSAX3_STATE_PI;
   break;
  case '%':
   return XML_HTMLSAX3_STATE_JASP;
   break;
  case '!':
   return XML_HTMLSAX3_STATE_ESCAPE;
   break;
  default:
   $context->unscanCharacter();
   return XML_HTMLSAX3_STATE_OPENING_TAG;
  }
 }
}
class XML_HTMLSax3_ClosingTagState {
 function parse(&$context) {
  $tag = $context->scanUntilCharacters('/>');
  if ($tag != '') {
   $char = $context->scanCharacter();
   if ($char == '/') {
    $char = $context->scanCharacter();
    if ($char != '>') {
     $context->unscanCharacter();
    }
   }
   $context->handler_object_element->
    {$context->handler_method_closing}($context->htmlsax, $tag, FALSE);
  }
  return XML_HTMLSAX3_STATE_START;
 }
}
class XML_HTMLSax3_OpeningTagState {
 function parseAttributes(&$context) {
  $Attributes = array();
 
  $context->ignoreWhitespace();
  $attributename = $context->scanUntilCharacters("=/> \n\r\t");
  while ($attributename != '') {
   $attributevalue = NULL;
   $context->ignoreWhitespace();
   $char = $context->scanCharacter();
   if ($char == '=') {
    $context->ignoreWhitespace();
    $char = $context->ScanCharacter();
    if ($char == '"') {
     $attributevalue= $context->scanUntilString('"');
     $context->IgnoreCharacter();
    } else if ($char == "'") {
     $attributevalue = $context->scanUntilString("'");
     $context->IgnoreCharacter();
    } else {
     $context->unscanCharacter();
     $attributevalue =
      $context->scanUntilCharacters("> \n\r\t");
    }
   } else if ($char !== NULL) {
    $attributevalue = NULL;
    $context->unscanCharacter();
   }
   $Attributes[$attributename] = $attributevalue;
   
   $context->ignoreWhitespace();
   $attributename = $context->scanUntilCharacters("=/> \n\r\t");
  }
  return $Attributes;
 }

 function parse(&$context) {
  $tag = $context->scanUntilCharacters("/> \n\r\t");
  if ($tag != '') {
   $this->attrs = array();
   $Attributes = $this->parseAttributes($context);
   $char = $context->scanCharacter();
   if ($char == '/') {
    $char = $context->scanCharacter();
    if ($char != '>') {
     $context->unscanCharacter();
    }
    $context->handler_object_element->
     {$context->handler_method_opening}($context->htmlsax, $tag, 
     $Attributes, TRUE);
    $context->handler_object_element->
     {$context->handler_method_closing}($context->htmlsax, $tag, 
     TRUE);
   } else {
    $context->handler_object_element->
     {$context->handler_method_opening}($context->htmlsax, $tag, 
     $Attributes, FALSE);
   }
  }
  return XML_HTMLSAX3_STATE_START;
 }
}

class XML_HTMLSax3_EscapeState {
 function parse(&$context) {
  $char = $context->ScanCharacter();
  if ($char == '-') {
   $char = $context->ScanCharacter();
   if ($char == '-') {
    $context->unscanCharacter();
    $context->unscanCharacter();
    $text = $context->scanUntilString('-->');
    $text .= $context->scanCharacter();
    $text .= $context->scanCharacter();
   } else {
    $context->unscanCharacter();
    $text = $context->scanUntilString('>');
   }
  } else if ( $char == '[') {
   $context->unscanCharacter();
   $text = $context->scanUntilString(']>');
   $text.= $context->scanCharacter();
  } else {
   $context->unscanCharacter();
   $text = $context->scanUntilString('>');
  }

  $context->IgnoreCharacter();
  if ($text != '') {
   $context->handler_object_escape->
   {$context->handler_method_escape}($context->htmlsax, $text);
  }
  return XML_HTMLSAX3_STATE_START;
 }
}
class XML_HTMLSax3_JaspState {
 function parse(&$context) {
  $text = $context->scanUntilString('%>');
  if ($text != '') {
   $context->handler_object_jasp->
    {$context->handler_method_jasp}($context->htmlsax, $text);
  }
  $context->IgnoreCharacter();
  $context->IgnoreCharacter();
  return XML_HTMLSAX3_STATE_START;
 }
}
class XML_HTMLSax3_PiState {
 function parse(&$context) {
  $target = $context->scanUntilCharacters(" \n\r\t");
  $data = $context->scanUntilString('?>');
  if ($data != '') {
   $context->handler_object_pi->
   {$context->handler_method_pi}($context->htmlsax, $target, $data);
  }
  $context->IgnoreCharacter();
  $context->IgnoreCharacter();
  return XML_HTMLSAX3_STATE_START;
 }
}
?>HTMLSax3/index.php000066600000000002152526670570007702 0ustar00X
index.php000066600000000002152526670570006377 0ustar00X
safehtml.php000066600000022246152526670570007111 0ustar00<?php
/**
 * SafeHTML Parser
 *
 * @package SafeHTML
 * @author  Roman Ivanov <thingol@mail.ru>
 * @copyright  2004-2005 Roman Ivanov
 * @license http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
 * @version    1.3.7
 * @link    http://pixel-apes.com/safehtml/
 */

if (!defined('_ECRIRE_INC_VERSION')) return;

require_once(XML_HTMLSAX3 . 'HTMLSax3.php');

class SafeHTML 
{
 var $_xhtml = '';
 
 var $_counter = array();
 
 var $_stack = array();
 
 var $_dcCounter = array();
 
 var $_dcStack = array();
 
 var $_listScope = 0; 
 
 var $_liStack = array();

 var $_protoRegexps = array();
 
 var $_cssRegexps = array();

 var $singleTags = array('area', 'br', 'img', 'input', 'hr', 'wbr', );

 var $deleteTags = array(
  'applet', 'base',   'basefont', 'bgsound', 'blink',  'body', 
  'embed',  'frame',  'frameset', 'head', 'html',   'ilayer', 
  'iframe', 'layer',  'link',  'meta', 'object', 'style', 
  'title',  'script', 
  );

 var $deleteTagsContent = array('script', 'style', 'title', 'xml', );

 var $protocolFiltering = 'white';

 var $blackProtocols = array(
  'about',   'chrome',  'data',    'disk',  'hcp',  
  'help', 'javascript', 'livescript', 'lynxcgi',  'lynxexec', 
  'ms-help', 'ms-its',  'mhtml',   'mocha', 'opera',   
  'res',  'resource',   'shell',   'vbscript', 'view-source', 
  'vnd.ms.radio',    'wysiwyg', 
  );

 var $whiteProtocols = array(
  'ed2k',   'file', 'ftp',  'gopher', 'http',  'https', 
  'irc',    'mailto', 'news', 'nntp', 'telnet', 'webcal', 
  'xmpp', 'callto',
  );

 var $protocolAttributes = array(
  'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc', 'src', 
  );

 var $cssKeywords = array(
  'absolute', 'behavior',    'behaviour',   'content', 'expression', 
  'fixed', 'include-source', 'moz-binding',
  );

 var $noClose = array();

 var $closeParagraph = array(
  'address', 'blockquote', 'center', 'dd',   'dir',    'div', 
  'dl',   'dt',   'h1',  'h2',   'h3',  'h4', 
  'h5',   'h6',   'hr',  'isindex', 'listing',   'marquee', 
  'menu', 'multicol',   'ol',  'p',    'plaintext', 'pre', 
  'table',   'ul',   'xmp', 
  );

 var $tableTags = array(
  'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th', 
  'thead',   'tr', 
  );

 var $listTags = array('dir', 'menu', 'ol', 'ul', 'dl', );

 var $attributes = array('dynsrc', 'id', 'name', );

 var $attributesNS = array('xml:lang', );

 function SafeHTML() 
 {
  //making regular expressions based on Proto & CSS arrays
  foreach ($this->blackProtocols as $proto) {
   $preg = "/[\s\x01-\x1F]*";
   for ($i=0; $i<strlen($proto); $i++) {
    $preg .= $proto{$i} . "[\s\x01-\x1F]*";
   }
   $preg .= ":/i";
   $this->_protoRegexps[] = $preg;
  }

  foreach ($this->cssKeywords as $css) {
   $this->_cssRegexps[] = '/' . $css . '/i';
  }
  return true;
 }

 function _writeAttrs ($attrs,$tag=null) 
 {
  if (is_array($attrs)) {
   foreach ($attrs as $name => $value) {

    $name = strtolower($name);

    if (strpos($name, 'on') === 0) {
     continue;
    }
    if (strpos($name, 'data') === 0) {
     continue;
    }
    if ($tag !='a' AND in_array($name, $this->attributes)) {
     continue;
    }
    if (!preg_match("/^[a-z0-9-]+$/i", $name)) {
      if (!in_array($name, $this->attributesNS))
      {
       continue;
      }
    }

    if (($value === TRUE) || (is_null($value))) {
     $value = $name;
    }

    if ($name == 'style') {
                   
                   // removes insignificant backslahes
       $value = str_replace("\\", '', $value);

                   // removes CSS comments
                   while (1)
                   {
                     $_value = preg_replace("!/\*.*?\*/!s", '', $value);
                     if ($_value == $value) break;
                     $value = $_value;
                   }
                   
                   // replace all & to &amp;
       $value = str_replace('&amp;', '&', $value);
       $value = str_replace('&', '&amp;', $value);

       foreach ($this->_cssRegexps as $css) {
        if (preg_match($css, $value)) { 
         continue 2;
        }
       }
       foreach ($this->_protoRegexps as $proto) {
        if (preg_match($proto, $value)) {
         continue 2;
        }
       }
    }

    $tempval = preg_replace_callback('/&#(\d+);?/m', create_function('$m', 'return chr($m[1]);'), $value); 
    $tempval = preg_replace_callback('/&#x([0-9a-f]+);?/mi', create_function('$m', 'return chr(hexdec($m[1]));'), $tempval);

    if ((in_array($name, $this->protocolAttributes)) && 
     (strpos($tempval, ':') !== false)) 
    {
     if ($this->protocolFiltering == 'black') {
      foreach ($this->_protoRegexps as $proto) {
       if (preg_match($proto, $tempval)) continue 2;
      }
     } else {
      $_tempval = explode(':', $tempval);
      $proto = $_tempval[0];
      if (!in_array($proto, $this->whiteProtocols)) {
       continue;
      }
     }
    }

    $value = str_replace("\"", "&quot;", $value);
    $this->_xhtml .= ' ' . $name . '="' . $value . '"';
   }
  }
  return true;
 }

 function _openHandler(&$parser, $name, $attrs) 
 {
  $name = strtolower($name);

  if (in_array($name, $this->deleteTagsContent)) {
   array_push($this->_dcStack, $name);
   $this->_dcCounter[$name] = isset($this->_dcCounter[$name]) ? $this->_dcCounter[$name]+1 : 1;
  }
  if (count($this->_dcStack) != 0) {
   return true;
  }

  if (in_array($name, $this->deleteTags)) {
   return true;
  }
  
  if (!preg_match("/^[a-z0-9]+$/i", $name)) {
   if (preg_match("!(?:\@|://)!i", $name)) {
    $this->_xhtml .= '&lt;' . $name . '&gt;';
   }
   return true;
  }

  if (in_array($name, $this->singleTags)) {
   $this->_xhtml .= '<' . $name;
   $this->_writeAttrs($attrs);
   $this->_xhtml .= ' />';
   return true;
  }

  // TABLES: cannot open table elements when we are not inside table
  if ((isset($this->_counter['table'])) && ($this->_counter['table'] <= 0) 
   && (in_array($name, $this->tableTags))) 
  {
   return true;
  }

  // PARAGRAPHS: close paragraph when closeParagraph tags opening
  if ((in_array($name, $this->closeParagraph)) && (in_array('p', $this->_stack))) {
   $this->_closeHandler($parser, 'p');
  }

  // LISTS: we should close <li> if <li> of the same level opening
  if ($name == 'li' && count($this->_liStack) && 
   $this->_listScope == $this->_liStack[count($this->_liStack)-1]) 
  {
   $this->_closeHandler($parser, 'li');
  }

  // LISTS: we want to know on what nesting level of lists we are
  if (in_array($name, $this->listTags)) {
   $this->_listScope++;
  }
  if ($name == 'li') {
   array_push($this->_liStack, $this->_listScope);
  }
   
  $this->_xhtml .= '<' . $name;
  $this->_writeAttrs($attrs,$name);
  $this->_xhtml .= '>';
  array_push($this->_stack,$name);
  $this->_counter[$name] = isset($this->_counter[$name]) ? $this->_counter[$name]+1 : 1;
  return true;
 }

 function _closeHandler(&$parser, $name) 
 {

  $name = strtolower($name);

  if (isset($this->_dcCounter[$name]) && ($this->_dcCounter[$name] > 0) && 
   (in_array($name, $this->deleteTagsContent))) 
  {
     while ($name != ($tag = array_pop($this->_dcStack))) {
   $this->_dcCounter[$tag]--;
     }

     $this->_dcCounter[$name]--;
  }

  if (count($this->_dcStack) != 0) {
   return true;
  }

  if ((isset($this->_counter[$name])) && ($this->_counter[$name] > 0)) {
     while ($name != ($tag = array_pop($this->_stack))) {
      $this->_closeTag($tag);
     }

     $this->_closeTag($name);
  }
  return true;
 }

 function _closeTag($tag) 
 {
  if (!in_array($tag, $this->noClose)) {
   $this->_xhtml .= '</' . $tag . '>';
  }

  $this->_counter[$tag]--;

  if (in_array($tag, $this->listTags)) {
   $this->_listScope--;
  }

  if ($tag == 'li') {
   array_pop($this->_liStack);
  }
  return true;
 }

 function _dataHandler(&$parser, $data) 
 {
  if (count($this->_dcStack) == 0) {
   $this->_xhtml .= $data;
  }
  return true;
 }

 function _escapeHandler(&$parser, $data) 
 {
  return true;
 }

 function getXHTML () 
 {
  while ($tag = array_pop($this->_stack)) {
   $this->_closeTag($tag);
  }
  
  return $this->_xhtml;
 }

 function clear() 
 {
  $this->_xhtml = '';
  return true;
 }

 function parse($doc) 
 {

    // Save all '<' symbols
    $doc = preg_replace("/<(?=[^a-zA-Z\/\!\?\%])/", '&lt;', $doc);

    // Web documents shouldn't contains \x00 symbol
    $doc = str_replace("\x00", '', $doc);

    // Opera6 bug workaround
    $doc = str_replace("\xC0\xBC", '&lt;', $doc);

    // UTF-7 encoding ASCII decode
    $doc = $this->repackUTF7($doc);

    // Instantiate the parser
    $parser= new XML_HTMLSax3();

    // Set up the parser
    $parser->set_object($this);

    $parser->set_element_handler('_openHandler','_closeHandler');
    $parser->set_data_handler('_dataHandler');
    $parser->set_escape_handler('_escapeHandler');

    $parser->parse($doc);

    return $this->getXHTML();

 }

    function repackUTF7($str)
    {
       return preg_replace_callback('!\+([0-9a-zA-Z/]+)\-!', array($this, 'repackUTF7Callback'), $str);
    }

    function repackUTF7Callback($str)
    {
       $str = base64_decode($str[1]);
       $str = preg_replace_callback('/^((?:\x00.)*)((?:[^\x00].)+)/', array($this, 'repackUTF7Back'), $str);
       return preg_replace('/\x00(.)/', '$1', $str);
    }

    function repackUTF7Back($str)
    {
       return $str[1].'+'.rtrim(base64_encode($str[2]), '=').'-';
    }
}

?>
HTMLSax3.php000066600000023731152526670570006611 0ustar00<?php
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group                                |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license,      |
// | that is bundled with this package in the file LICENSE, and is        |
// | available at through the world-wide-web at                           |
// | http://www.php.net/license/3_0.txt.                                  |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to          |
// | license@php.net so we can mail you a copy immediately.               |
// +----------------------------------------------------------------------+
// | Authors: Alexander Zhukov <alex@veresk.ru> Original port from Python |
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> Port to PEAR + more  |
// | Authors: Many @ Sitepointforums Advanced PHP Forums                  |
// +----------------------------------------------------------------------+
//

if (!defined('_ECRIRE_INC_VERSION')) return;

if (!defined('XML_HTMLSAX3')) {
 define('XML_HTMLSAX3', 'XML/');
}
require_once(XML_HTMLSAX3 . 'HTMLSax3/States.php');
require_once(XML_HTMLSAX3 . 'HTMLSax3/Decorators.php');

class XML_HTMLSax3_StateParser {
 var $htmlsax;
 var $handler_object_element;
 var $handler_method_opening;
 var $handler_method_closing;
 var $handler_object_data;
 var $handler_method_data;
 var $handler_object_pi;
 var $handler_method_pi;
 var $handler_object_jasp;
 var $handler_method_jasp;
 var $handler_object_escape;
 var $handler_method_escape;
 var $handler_default;
 var $parser_options = array();
 var $rawtext;
 var $position;
 var $length;
 var $State = array();

 function XML_HTMLSax3_StateParser (& $htmlsax) {
  $this->htmlsax = & $htmlsax;

  $this->State[XML_HTMLSAX3_STATE_START] = new XML_HTMLSax3_StartingState();

  $this->State[XML_HTMLSAX3_STATE_CLOSING_TAG] = new XML_HTMLSax3_ClosingTagState();
  $this->State[XML_HTMLSAX3_STATE_TAG] = new XML_HTMLSax3_TagState();
  $this->State[XML_HTMLSAX3_STATE_OPENING_TAG] = new XML_HTMLSax3_OpeningTagState();

  $this->State[XML_HTMLSAX3_STATE_PI] = new XML_HTMLSax3_PiState();
  $this->State[XML_HTMLSAX3_STATE_JASP] = new XML_HTMLSax3_JaspState();
  $this->State[XML_HTMLSAX3_STATE_ESCAPE] = new XML_HTMLSax3_EscapeState();
 }

 function unscanCharacter() {
  $this->position -= 1;
 }

 function ignoreCharacter() {
  $this->position += 1;
 }

 function scanCharacter() {
  if ($this->position < $this->length) {
   return $this->rawtext{$this->position++};
  }
 }

 function scanUntilString($string) {
  $start = $this->position;
  $this->position = strpos($this->rawtext, $string, $start);
  if ($this->position === FALSE) {
   $this->position = $this->length;
  }
  return substr($this->rawtext, $start, $this->position - $start);
 }

 function scanUntilCharacters($string) {}

 function ignoreWhitespace() {}

 function parse($data) {
  if ($this->parser_options['XML_OPTION_TRIM_DATA_NODES']==1) {
   $decorator = new XML_HTMLSax3_Trim(
    $this->handler_object_data,
    $this->handler_method_data);
   $this->handler_object_data =& $decorator;
   $this->handler_method_data = 'trimData';
  }
  if ($this->parser_options['XML_OPTION_CASE_FOLDING']==1) {
   $open_decor = new XML_HTMLSax3_CaseFolding(
    $this->handler_object_element,
    $this->handler_method_opening,
    $this->handler_method_closing);
   $this->handler_object_element =& $open_decor;
   $this->handler_method_opening ='foldOpen';
   $this->handler_method_closing ='foldClose';
  }
  if ($this->parser_options['XML_OPTION_LINEFEED_BREAK']==1) {
   $decorator = new XML_HTMLSax3_Linefeed(
    $this->handler_object_data,
    $this->handler_method_data);
   $this->handler_object_data =& $decorator;
   $this->handler_method_data = 'breakData';
  }
  if ($this->parser_options['XML_OPTION_TAB_BREAK']==1) {
   $decorator = new XML_HTMLSax3_Tab(
    $this->handler_object_data,
    $this->handler_method_data);
   $this->handler_object_data =& $decorator;
   $this->handler_method_data = 'breakData';
  }
  if ($this->parser_options['XML_OPTION_ENTITIES_UNPARSED']==1) {
   $decorator = new XML_HTMLSax3_Entities_Unparsed(
    $this->handler_object_data,
    $this->handler_method_data);
   $this->handler_object_data =& $decorator;
   $this->handler_method_data = 'breakData';
  }
  if ($this->parser_options['XML_OPTION_ENTITIES_PARSED']==1) {
   $decorator = new XML_HTMLSax3_Entities_Parsed(
    $this->handler_object_data,
    $this->handler_method_data);
   $this->handler_object_data =& $decorator;
   $this->handler_method_data = 'breakData';
  }
  // Note switched on by default
  if ($this->parser_options['XML_OPTION_STRIP_ESCAPES']==1) {
   $decorator = new XML_HTMLSax3_Escape_Stripper(
    $this->handler_object_escape,
    $this->handler_method_escape);
   $this->handler_object_escape =& $decorator;
   $this->handler_method_escape = 'strip';
  }
  $this->rawtext = $data;
  $this->length = strlen($data);
  $this->position = 0;
  $this->_parse();
 }

 function _parse($state = XML_HTMLSAX3_STATE_START) {
  do {
   $state = $this->State[$state]->parse($this);
  } while ($state != XML_HTMLSAX3_STATE_STOP &&
     $this->position < $this->length);
 }
}

class XML_HTMLSax3_StateParser_Lt430 extends XML_HTMLSax3_StateParser {
 function XML_HTMLSax3_StateParser_Lt430(& $htmlsax) {
  parent::XML_HTMLSax3_StateParser($htmlsax);
  $this->parser_options['XML_OPTION_TRIM_DATA_NODES'] = 0;
  $this->parser_options['XML_OPTION_CASE_FOLDING'] = 0;
  $this->parser_options['XML_OPTION_LINEFEED_BREAK'] = 0;
  $this->parser_options['XML_OPTION_TAB_BREAK'] = 0;
  $this->parser_options['XML_OPTION_ENTITIES_PARSED'] = 0;
  $this->parser_options['XML_OPTION_ENTITIES_UNPARSED'] = 0;
  $this->parser_options['XML_OPTION_STRIP_ESCAPES'] = 0;
 }

 function scanUntilCharacters($string) {
  $startpos = $this->position;
  while ($this->position < $this->length && strpos($string, $this->rawtext{$this->position}) === FALSE) {
   $this->position++;
  }
  return substr($this->rawtext, $startpos, $this->position - $startpos);
 }

 function ignoreWhitespace() {
  while ($this->position < $this->length && 
   strpos(" \n\r\t", $this->rawtext{$this->position}) !== FALSE) {
   $this->position++;
  }
 }

 function parse($data) {
  parent::parse($data);
 }
}

class XML_HTMLSax3_StateParser_Gtet430 extends XML_HTMLSax3_StateParser {
 function XML_HTMLSax3_StateParser_Gtet430(& $htmlsax) {
  parent::XML_HTMLSax3_StateParser($htmlsax);
  $this->parser_options['XML_OPTION_TRIM_DATA_NODES'] = 0;
  $this->parser_options['XML_OPTION_CASE_FOLDING'] = 0;
  $this->parser_options['XML_OPTION_LINEFEED_BREAK'] = 0;
  $this->parser_options['XML_OPTION_TAB_BREAK'] = 0;
  $this->parser_options['XML_OPTION_ENTITIES_PARSED'] = 0;
  $this->parser_options['XML_OPTION_ENTITIES_UNPARSED'] = 0;
  $this->parser_options['XML_OPTION_STRIP_ESCAPES'] = 0;
 }
 function scanUntilCharacters($string) {
  $startpos = $this->position;
  $length = strcspn($this->rawtext, $string, $startpos);
  $this->position += $length;
  return substr($this->rawtext, $startpos, $length);
 }

 function ignoreWhitespace() {
  $this->position += strspn($this->rawtext, " \n\r\t", $this->position);
 }

 function parse($data) {
  parent::parse($data);
 }
}

class XML_HTMLSax3_NullHandler {
 function DoNothing() {
 }
}

class XML_HTMLSax3 {
 var $state_parser;

 function XML_HTMLSax3() {
  if (version_compare(phpversion(), '4.3', 'ge')) {
   $this->state_parser = new XML_HTMLSax3_StateParser_Gtet430($this);
  } else {
   $this->state_parser = new XML_HTMLSax3_StateParser_Lt430($this);
  }
  $nullhandler = new XML_HTMLSax3_NullHandler();
  $this->set_object($nullhandler);
  $this->set_element_handler('DoNothing', 'DoNothing');
  $this->set_data_handler('DoNothing');
  $this->set_pi_handler('DoNothing');
  $this->set_jasp_handler('DoNothing');
  $this->set_escape_handler('DoNothing');
 }

 function set_object(&$object) {
  if ( is_object($object) ) {
   $this->state_parser->handler_default =& $object;
   return true;
  } else {
   require_once('PEAR.php');
   PEAR::raiseError('XML_HTMLSax3::set_object requires '.
    'an object instance');
  }
 }

 function set_option($name, $value=1) {
  if ( array_key_exists($name,$this->state_parser->parser_options) ) {
   $this->state_parser->parser_options[$name] = $value;
   return true;
  } else {
   require_once('PEAR.php');
   PEAR::raiseError('XML_HTMLSax3::set_option('.$name.') illegal');
  }
 }

 function set_data_handler($data_method) {
  $this->state_parser->handler_object_data =& $this->state_parser->handler_default;
  $this->state_parser->handler_method_data = $data_method;
 }

 function set_element_handler($opening_method, $closing_method) {
  $this->state_parser->handler_object_element =& $this->state_parser->handler_default;
  $this->state_parser->handler_method_opening = $opening_method;
  $this->state_parser->handler_method_closing = $closing_method;
 }

 function set_pi_handler($pi_method) {
  $this->state_parser->handler_object_pi =& $this->state_parser->handler_default;
  $this->state_parser->handler_method_pi = $pi_method;
 }

 function set_escape_handler($escape_method) {
  $this->state_parser->handler_object_escape =& $this->state_parser->handler_default;
  $this->state_parser->handler_method_escape = $escape_method;
 }

 function set_jasp_handler ($jasp_method) {
  $this->state_parser->handler_object_jasp =& $this->state_parser->handler_default;
  $this->state_parser->handler_method_jasp = $jasp_method;
 }

 function get_current_position() {
  return $this->state_parser->position;
 }

 function get_length() {
  return $this->state_parser->length;
 }

 function parse($data) {
  $this->state_parser->parse($data);
 }
}
?>