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 ">"; } } } } function cdata($parser, $cdata) { if ( $this->mode == "" || $this->mode == "DATAPLACE" || $this->mode == "PERSONPLACEFOUND" || $this->mode == "DOCPLACEFOUND" ) 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 ""; } } } 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 PIC( $a, $close=FALSE ) { if ( !$close ) { // print "\"Нажмите"; 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 TERMIN( $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 TERMINPLACE( $a, $close=FALSE ) { 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 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( "termin", "TERMINPLACE", $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); if ( ctype_digit($n) ) parse_file( "docs".".".$n, "DOCPLACE", $value ); else parse_file( "docs.0", "DOCPLACE", $value ); } else if ( $in == "personplace" ) { include("style.css"); print "Персоналии"; // print "$value ---"; parse_file( "persons", "PERSONPLACE", $value ); } else if ( $in == "picplace" ) { include("style.css"); print "Изображение"; print "

$d

"; // parse_file( "persons", "PERSONPLACE", $value ); } else { include 'header.php'; parse_file( $in ); include 'footer.php'; } ?>