Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $nen = array();
- include_once( 'nen.php' );
- nen_ini();
- include_once ( $nen[ 'root' ]. 'trk tok.php');
- include_once ( $nen[ 'root' ]. 'trk echo.php');
- include_once( $nen[ 'root' ]. 'fasttoc.php' );
- //cycle_sourcefiles();
- //cycle_pagedata();
- cfg_toc();
- function fastcfg( $buffer = '' )
- {
- global $nen;
- $lines = explode("\r\n", $buffer);
- $cfg = array();
- $index = 0;
- while(true)
- {
- if( $index > count( $lines ) - 1 )
- {
- break;
- }
- $temp = explode( ":", $lines[ $index ] );
- $label[ $index ] = $temp[ 0 ];
- unset( $temp[ 0 ] );
- $value[ $index ] = implode( ":", $temp );
- $cfg[ $label[ $index ] ] = $value[ $index ];
- $index++;
- }
- return $cfg;
- }
- function swapcfg()
- {
- global $nen;
- $buffer = file_get_contents( $nen[ 'root' ]. 'pcre/dungeon-put.swap.pcre' );
- $cfg = fastcfg( $buffer );
- foreach( $cfg as $seek_k => $seek_v )
- {
- foreach( $cfg as $replace_k => $replace_v )
- {
- if( preg_match( '/swap\.([A-Z0-9]+)/', $replace_k, $replace_matches ) )
- {
- if( preg_match( '/\{\{swap\.('. $replace_matches[ 1 ]. ')\}\}/', $seek_v, $seek_matches ) )
- {
- $cfg[ $seek_k ] = str_replace( '{{swap.'. $seek_matches[ 1 ]. '}}', $replace_v, $cfg[ $seek_k ] );
- }
- }
- }
- }
- return $cfg;
- }
- function cfg_slimmer()
- {
- $cfg = swapcfg();
- foreach( $cfg as $swap_key => $swap_value )
- {
- if(preg_match('/swap.([0-9]+)/',$swap_key,$swap_matches))
- {
- unset( $cfg[ 'swap.'. $swap_matches[ 1 ] ] );
- }
- }
- trk_echo2( 'cfg', $cfg );
- return $cfg;
- }
- function cfg_toc()
- {
- global $nen;
- $toc_index = 0;
- $toc_pattern = '/(DUN)([0-9]{3})(.BAS)/';
- $toc = fasttoc( 'miscdun/', array( '.bas', '.BAS' ) );
- $toc_result = '';
- $cfg = cfg_slimmer();
- $toc_lines=array();
- $result = '';
- while( preg_match( $toc_pattern, $toc[ $toc_index ], $toc_matches ) )
- {
- if( $toc_index > count( $toc ) - 1 )
- {
- break;
- }
- $toc_lines[ $toc_index ] = explode( "\r\n", file_get_contents( $nen[ 'root' ] . 'miscdun/' . $toc[ $toc_index ] ) );
- $lines_index = 0;
- while(true)
- {
- if( $lines_index > count( $toc_lines ) - 1 )
- {
- break;
- }
- foreach( $cfg as $cfg_key => $cfg_value )
- {
- $cfg_index = 0;
- while(
- !preg_match( '/'.
- $cfg_value. '/',
- $toc_lines[ $toc_index ][ $lines_index ],
- $cfg_matches ) )
- {
- if ( $cfg_index > count( $cfg ) - 1 )
- {
- unset(
- $toc_lines
- [ $toc_index ]
- [ $lines_index ]
- );
- $lines_index--;
- $toc_lines =
- explode( "\r\n",
- implode( "\r\n",
- $toc_lines
- [ $toc_index ]
- ) );
- $cfg_index = 0;
- break;
- }
- $cfg_index++;
- }
- }
- $lines_index++;
- }
- file_put_contents( $nen[ 'root' ] . 'metaput/imap' . $toc_matches[ 2 ] . 'fb.dat', implode( "\r\n", $toc_lines[ $toc_index ] ) );
- $toc_index++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement