Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dir = "hints/";
- $file = $file . '.xml';
- $file = $dir.$file;
- // if ( !isset($file) )
- // {
- // $file = "force_quit.xml";
- // }
- $xmlParser = xml_parser_create();
- $params = array();
- $level = array();
- $openFile = fopen($file, "r");
- if (!$openFile) {
- echo $error = "<span class=\"error\">Couldn't open the file for reading</span>";
- die;
- }
- $data = fread($openFile, filesize($file));
- fclose($openFile);
- xml_parse_into_struct($xmlParser, $data, $vals, $index);
- xml_parser_free($xmlParser);
- foreach( $vals as $xmlElement )
- {
- if ( $xmlElement['type'] == "open" )
- {
- if ( array_key_exists("attributes", $xmlElement) )
- {
- list( $level [$xmlElement['level']], $extra) = array_values( $xmlElement['attributes'] );
- } else
- {
- $level[$xmlElement['level']] = $xmlElement['tag'];
- }
- }
- if ( $xmlElement['type'] == 'complete' )
- {
- $start_level = 1;
- $php_stmt = '$params';
- while ( $start_level < $xmlElement['level'] )
- {
- $php_stmt .= '[strtolower($level[' . $start_level . '])]';
- $start_level++;
- }
- $php_stmt .= '[strtolower($xmlElement[\'tag\'])] = $xmlElement[\'value\'];';
- eval($php_stmt);
- }
- }
- ?>
Add Comment
Please, Sign In to add comment