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' );
- regex_toc();
- function regex_swap()
- {
- global $nen;
- //load regex from disk
- $buffer = file_get_contents( $nen[ 'root' ]. 'pcre/roe.swap.pcre' );
- $lines = explode("\r\n", $buffer);
- $regex = array();
- // splice all regex into memory
- $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 );
- $regex[ $label[ $index ] ] = $value[ $index ];
- $index++;
- }
- trk_echo2('regex',$regex);
- // embed all numeric regex into all alpha regex
- foreach( $regex as $alpha_key => $alpha_value )
- {
- if( preg_match( '/swap\.([A-Z]+)/', $alpha_key) )
- {
- foreach( $regex as $numeric_key => $numeric_value )
- {
- if( preg_match( '/swap\.([0-9]+)/', $numeric_key) )
- {
- $regex[ $alpha_key ] =
- str_replace(
- '{{'. $numeric_key. '}}',
- $regex[ $numeric_key ],
- $regex[ $alpha_key ] );
- }
- }
- }
- }
- // delete all numeric regex lines
- foreach( $regex as $swap_key => $swap_value )
- {
- if(preg_match('/swap\.([0-9]+)/',$swap_key,$swap_matches))
- {
- unset( $regex[ 'swap.'. $swap_matches[ 1 ] ] );
- }
- }
- trk_echo2( 'regex', $regex );
- return $regex;
- }
- function regex_toc()
- {
- global $nen;
- $replace = "$0\n";
- // top of page (title)
- echo '<html><head><title>Roe XAMPP Builder (MkRoe)</title></head><body>';
- // table of contents filename pattern
- $toc_index = 0;
- $toc_pattern = '/(R)([0-9]{7})\-fbc(\.bas|\.BAS)/';
- $toc = fasttoc( 'miscroe/', array( '.bas', '.BAS' ) );
- $toc_result = '';
- // load regex
- $regex = regex_swap();
- $toc_lines=array();
- $result = '';
- // loop through toc
- while(
- ($toc_index > count( $toc ) - 1)?false:preg_match(
- $toc_pattern,
- $toc[ $toc_index ],
- $toc_matches
- )
- )
- {
- if( $toc_index > count( $toc ) - 1 )
- {
- break;
- }
- $ret=array();
- // echo current toc filename
- echo '<h3>'. htmlentities( 'miscroe/' . $toc[ $toc_index ] ). '</h3>';
- $page = file_get_contents( $nen[ 'root' ] . 'miscroe/' . $toc[ $toc_index ] );
- echo str_replace( "\r\n", '<br>'."\r\n", htmlentities( $page ) );
- // cycle through and perform all alpha regex
- foreach( $regex as $alpha_key => $alpha_value )
- {
- if( preg_match( '/swap\.([A-Z]+)/', $alpha_key ) )
- {
- echo '<h3>Filter: '. htmlentities( $alpha_key . ':'. $alpha_value ). '</h3>';
- // perform current alpha regex
- if(
- preg_match(
- $alpha_value,
- $page,
- $alpha_matches
- ))
- {
- trk_echo2( 'matches', count( $alpha_matches ) );
- $match_index = 0;
- while( $match_index < count( $alpha_matches ) )
- {
- // add creation card to collection
- if( !isset( $ret[ $alpha_matches[ $match_index ] ] ) )
- {
- $ret[ $alpha_matches[ $match_index ] ] = 0;
- }
- $ret[ $alpha_matches[ $match_index ] ]++;
- $match_index++;
- }
- }
- }
- }
- trk_echo2( 'ret', $ret );
- // sort creation card collection
- ksort( $ret );
- // implode creation card collection
- $crtnret = implode( "\r\n", $ret );
- //echo str_replace( "\r\n", '<br>'."\r\n", htmlentities( $page ) );
- // save creation card collection to file
- file_put_contents( $nen[ 'root' ] . 'metaroe/crtnlist' . $toc_matches[ 2 ] . 'fb.dat', $crtnret );
- $toc_index++;
- }
- // bottom of page
- echo '</body></html>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement