id = xml_parser_create(); xml_set_object($this->id, $this); xml_set_element_handler($this->id, "tag_open", "tag_close"); xml_set_character_data_handler($this->id, "cdata"); } function errorxml( $s ) { print(sprintf("XML error: %s at line %d", $s, xml_get_current_line_number($this->id))); exit; } function parse($data, $mode = "", $value = "",$value1 = "",$value2 = "") { $this->mode = $mode; $this->value = $value; $this->value1 = $value1; $this->value2 = $value2; if ( !xml_parse($this->id, "$data") ) { $this->errorxml( xml_error_string(xml_get_error_code($this->id)) ); } } function tag_open($parser, $tag, $attributes) { // global $in; if ( $this->mode == "" ) { if ( in_array( $tag, $this->known ) ) { eval( "\$this->$tag(\$attributes,0);"); } else { print "<".$tag; foreach( $attributes as $k=>$v ) print " $k=$v"; print ">"; } } else if ( $tag == "TERMINPLACE" && $this->mode == $tag ) { if ( $attributes[ "VALUE" ] == $this->value || $attributes[ "ALT" ] == $this->value ) { print "

". $attributes[ "VALUE" ]. "

"; print "

".$attributes[ "DESCRIPTION" ]."

"; } } else if ( $tag == "TITLE" && $this->mode == $tag ) { // if ( $this->value == $attributes[ "ACTION" ] ) // print "

{$attributes[ "VALUE" ]}"; // else $y = $this->oldpos*70+20; // if ( $this->value == $attributes[ "ACTION" ] ) // print "
{$attributes[ "VALUE" ]}
"; // else // print "
{$attributes[ "VALUE" ]}
"; $this->oldpos++; if ( !isset($attributes[ "ACTION" ]) ) print "{$attributes[ "VALUE" ]}
"; else if ( $this->value == $attributes[ "ACTION" ] ) print "{$attributes[ "VALUE" ]}
"; else print "{$attributes[ "VALUE" ]}
"; } else if ( $this->mode == "DATAPLACE" ) { if ( in_array( $tag, $this->known ) ) { eval( "\$this->$tag(\$attributes,0);"); } else { print "<".$tag; foreach( $attributes as $k=>$v ) print " $k=$v"; print ">"; } } else if ( $this->mode == "PERSONPLACE" || $this->mode == "PERSONPLACEFOUND" ) { if ( $this->mode == "PERSONPLACE" && $tag == "PERSON" && $attributes[ "ALT" ] == $this->value ) { $this->mode = "PERSONPLACEFOUND"; $this->PERSON( $attributes,0 ); } else if ( $this->mode == "PERSONPLACEFOUND" ) { if ( in_array( $tag, $this->known ) ) { eval( "\$this->$tag(\$attributes,0);"); } else { print "<".$tag; foreach( $attributes as $k=>$v ) print " $k=$v"; print ">"; } } } else if ( $this->mode == "DOCPLACE" || $this->mode == "DOCPLACEFOUND" ) { if ( $this->mode == "DOCPLACE" && $tag == "DOC" && ($attributes[ "ALT" ] == $this->value && strlen($attributes[ "ALT" ])==strlen($this->value)) ) { // print "ffff".$this->value.$attributes[ "ALT" ]; $this->mode = "DOCPLACEFOUND"; $this->DOC( $attributes,0 ); } else if ( $this->mode == "DOCPLACEFOUND" ) { if ( in_array( $tag, $this->known ) ) { eval( "\$this->$tag(\$attributes,0);"); } else { print "<".$tag; foreach( $attributes as $k=>$v ) print " $k=$v"; print ">"; } } } else if ( $this->mode == "TERMPLACE" || $this->mode == "TERMPLACEFOUND" ) { if ( $this->mode == "TERMPLACE" && $tag == "TERM" && ($attributes[ "ALT" ] == $this->value && strlen($attributes[ "ALT" ])==strlen($this->value)) ) { // print "ffff".$this->value.$attributes[ "ALT" ]; $this->mode = "TERMPLACEFOUND"; $this->TERM( $attributes,0 ); } else if ( $this->mode == "TERMPLACEFOUND" ) { if ( in_array( $tag, $this->known ) ) { eval( "\$this->$tag(\$attributes,0);"); } else { print "<".$tag; foreach( $attributes as $k=>$v ) print " $k=$v"; print ">"; } } } else if ( $this->mode == "IVENTPLACE" || $this->mode == "IVENTPLACEFOUND" ) { if ( $this->mode == "IVENTPLACE" && $tag == "IVENT" && ($attributes[ "ALT" ] == $this->value && strlen($attributes[ "ALT" ])==strlen($this->value)) ) { // print "ffff".$this->value.$attributes[ "ALT" ]; $this->mode = "IVENTPLACEFOUND"; $this->IVENT( $attributes,0 ); } else if ( $this->mode == "IVENTPLACEFOUND" ) { if ( in_array( $tag, $this->known ) ) { eval( "\$this->$tag(\$attributes,0);"); } else { print "<".$tag; foreach( $attributes as $k=>$v ) print " $k=$v"; print ">"; } } } else if ( $this->mode == "GEOPLACE" || $this->mode == "GEOPLACEFOUND" ) { if ( $this->mode == "GEOPLACE" && $tag == "GEO" && ($attributes[ "ALT" ] == $this->value && strlen($attributes[ "ALT" ])==strlen($this->value)) ) { // print "ffff".$this->value.$attributes[ "ALT" ]; $this->mode = "GEOPLACEFOUND"; $this->GEO( $attributes,0 ); } else if ( $this->mode == "GEOPLACEFOUND" ) { if ( in_array( $tag, $this->known ) ) { eval( "\$this->$tag(\$attributes,0);"); } else { print "<".$tag; foreach( $attributes as $k=>$v ) print " $k=$v"; print ">"; } } } } function cdata($parser, $cdata) { if ( $this->mode == "" || $this->mode == "DATAPLACE" || $this->mode == "PERSONPLACEFOUND" || $this->mode == "DOCPLACEFOUND" || $this->mode == "TERMPLACEFOUND" || $this->mode == "IVENTPLACEFOUND" || $this->mode == "GEOPLACEFOUND" ) print $cdata; } function tag_close($parser, $tag) { if ( $this->mode == "" ) { if ( in_array( $tag, $this->known ) ) { eval( "\$this->$tag(array(),1);"); } else { print ""; } } else if ( $this->mode == "DATAPLACE" ) { if ( in_array( $tag, $this->known ) ) { eval( "\$this->$tag(array(),1);"); } else { print ""; } } else if ( $this->mode == "PERSONPLACEFOUND" ) { if ( $tag == "PERSON" ) $this->mode = "PERSONPLACE"; else if ( in_array( $tag, $this->known ) ) { eval( "\$this->$tag(array(),1);"); } else { print ""; } } else if ( $this->mode == "DOCPLACEFOUND" ) { if ( $tag == "DOC" ) $this->mode = "DOCPLACE"; else if ( in_array( $tag, $this->known ) ) { eval( "\$this->$tag(array(),1);"); } else { print ""; } } else if ( $this->mode == "IVENTPLACEFOUND" ) { if ( $tag == "IVENT" ) $this->mode = "IVENTPLACE"; else if ( in_array( $tag, $this->known ) ) { eval( "\$this->$tag(array(),1);"); } else { print ""; } } else if ( $this->mode == "GEOPLACEFOUND" ) { if ( $tag == "GEO" ) $this->mode = "GEOPLACE"; else if ( in_array( $tag, $this->known ) ) { eval( "\$this->$tag(array(),1);"); } else { print ""; } } else if ( $this->mode == "TERMPLACEFOUND" ) { if ( $tag == "TERM" ) $this->mode = "TERMPLACE"; else if ( in_array( $tag, $this->known ) ) { eval( "\$this->$tag(array(),1);"); } else { print ""; } } } function freexml() { xml_parser_free($this->id); } function REF( $a, $close=FALSE ) { if ( !$close ) { print ""; } else { print ""; } } function DESC( $a, $close=FALSE ) { if ( !$close ) { print "
"; } else { print "
"; } } function CITE( $a, $close=FALSE ) { if ( !$close ) { print "
"; } else { print "
"; } } function QUEST( $a, $close=FALSE ) { if ( !$close ) { print "

"; } else { print "

"; } } function SDESC( $a, $close=FALSE ) { if ( !$close ) { print "
"; } else { print "
"; } } function DIC( $a, $close=FALSE ) { if ( !$close ) { print "
"; } else { print "
"; } } function WORD( $a, $close=FALSE ) { if ( !$close ) { print ""; } else { print " - "; } } function DOCUMENT( $a, $close=FALSE ) { } function TITLE( $a, $close=FALSE ) { if ( !$close ) { print "

".$a["VALUE"]."

"; } } function TERM( $a, $close=FALSE ) { if ( !$close ) { if ( isset( $a["ALT"] ) ) $v = $a["ALT"]; else $v=$a["VALUE"]; // print "".$a["VALUE"].""; // print "".$a["VALUE"].""; // print ""; print "".$a["VALUE"].""; } } function TERMPLACE( $a, $close=FALSE ) { if ( !$close ) { if ( isset( $a["ALT"] ) ) $v = $a["ALT"]; else $v=$a["VALUE"]; // print "".$a["VALUE"].""; // print "".$a["VALUE"].""; // print ""; print "".$a["VALUE"].""; } // if ( !$close ) // { // print "

".$a["VALUE"]."

".$a["DESCRIPTION"]."

"; // } } function ABC( $a, $close=FALSE ) { if ( !$close ) { print "

".$a["ALT"]." - ".$a["DESCRIPTION"]."

"; } } function DATA( $a, $close=FALSE ) { if ( !$close ) { if ( $this->mode == "DATAPLACE" && $a[ "YEAR" ]==$this->value && $a[ "DAY" ]==$this->value1 ) { print "
"; } if ( $this->oldyear != $a[ "YEAR" ] ) { print "".$a[ "YEAR" ]. "
"; $this->oldyear = $a[ "YEAR" ]; } print "".$a[ "DAY" ]. ""; } } function CHRO( $a, $close=FALSE ) { if ( !$close ) { // print ""; // print ""; } else print ""; } function PERSON( $a, $close=FALSE ) { if ( !$close ) { print "

{$a["DESCRIPTION"]}

"; } } function PERSONPLACE( $a, $close=FALSE ) { if ( !$close ) { // print ""; if ( isset($a["VALUE"]) ) print "{$a["VALUE"]}"; else print "{$a["ALT"]}"; } } function DOC( $a, $close=FALSE ) { if ( !$close ) { print "

{$a["DESCRIPTION"]}

"; } } function DOCPLACE( $a, $close=FALSE ) { if ( !$close ) { // print ""; print "{$a["VALUE"]}"; } } function IVENT( $a, $close=FALSE ) { if ( !$close ) { print "

{$a["DESCRIPTION"]}

"; } } function IVENTPLACE( $a, $close=FALSE ) { if ( !$close ) { // print ""; print "{$a["VALUE"]}"; } } function GEO( $a, $close=FALSE ) { if ( !$close ) { print "

{$a["DESCRIPTION"]}

"; } } function GEOPLACE( $a, $close=FALSE ) { if ( !$close ) { // print ""; print "{$a["VALUE"]}"; } } // function TERM( $a, $close=FALSE ) // { // if ( !$close ) // { // print "

{$a["DESCRIPTION"]}

"; // } // } // function TERMPLACE( $a, $close=FALSE ) // { // if ( !$close ) // { //// print ""; // print "{$a["VALUE"]}"; // } // } } function parse_file( $f, $mode="", $value="", $value1="", $value2="" ) { if (strstr( $f, '/') !="" ) $f ='intro'; $filename = $path_reader . $f; $fd = fopen ($filename, "r"); $contents = fread ($fd, filesize ($filename)); $x = new xml(); $x->parse( $contents, $mode, $value, $value1, $value2 ); $x->freexml(); fclose ($fd); } ?> Термины"; parse_file( "term", "TERMPLACE", $value ); } else if ( $in == "indexplace" ) { include("style.css"); parse_file( "index", "TITLE" ); } else if ( $in == "dataplace" ) { include("style.css"); print "Хронология"; parse_file( "chro", "DATAPLACE", $year, $day ); } else if ( $in == "docplace" ) { include("style.css"); print "Документы"; $n = substr( $value, 0, 1); parse_file( "docs".".".$n, "DOCPLACE", $value ); } else if ( $in == "iventplace" ) { include("style.css"); print "События"; $n = substr( $value, 0, 1); // parse_file( "ivent".".".$n, "IVENTPLACE", $value ); parse_file( "ivent", "IVENTPLACE", $value ); } else if ( $in == "termplace" ) { include("style.css"); print "Термины"; $n = substr( $value, 0, 1); parse_file( "term".".".$n, "TERMPLACE", $value ); } else if ( $in == "geoplace" ) { include("style.css"); print "Местоположения"; // $n = substr( $value, 0, 1); parse_file( "geo", "GEOPLACE", $value ); } else if ( $in == "personplace" ) { include("style.css"); print "Персоналии"; parse_file( "person", "PERSONPLACE", $value ); } else { include 'header.php'; parse_file( $in ); include 'footer.php'; } ?>