Advertisement
jargon

Roe XAMPP Builder

Sep 24th, 2021
1,385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.75 KB | None | 0 0
  1. <?php
  2.  
  3. $nen = array();
  4. include_once( 'nen.php' );
  5.  
  6. nen_ini();
  7.  
  8. include_once ( $nen[ 'root' ]. 'trk tok.php');
  9. include_once ( $nen[ 'root' ]. 'trk echo.php');
  10. include_once( $nen[ 'root' ]. 'fasttoc.php' );
  11.  
  12. regex_toc();
  13.  
  14. function regex_swap()
  15. {
  16.     global $nen;
  17.    
  18.     //load regex from disk
  19.     $buffer = file_get_contents( $nen[ 'root' ]. 'pcre/roe.swap.pcre' );
  20.    
  21.     $lines = explode("\r\n", $buffer);
  22.    
  23.     $regex = array();
  24.    
  25.     // splice all regex into memory
  26.     $index = 0;
  27.     while(true)
  28.     {
  29.         if( $index > count( $lines ) - 1 )
  30.         {
  31.             break;
  32.         }
  33.        
  34.         $temp = explode( ":", $lines[ $index ] );
  35.         $label[ $index ] = $temp[ 0 ];
  36.        
  37.         unset( $temp[ 0 ] );
  38.         $value[ $index ] = implode( ":", $temp );
  39.        
  40.         $regex[ $label[ $index ] ] = $value[ $index ];
  41.        
  42.         $index++;
  43.     }
  44.        
  45.     trk_echo2('regex',$regex);
  46.    
  47.     // embed all numeric regex into all alpha regex
  48.     foreach( $regex as $alpha_key => $alpha_value )
  49.     {
  50.         if( preg_match( '/swap\.([A-Z]+)/', $alpha_key) )
  51.         {
  52.             foreach( $regex as $numeric_key => $numeric_value )
  53.             {
  54.                 if( preg_match( '/swap\.([0-9]+)/', $numeric_key) )
  55.                 {
  56.                     $regex[ $alpha_key ] =
  57.                     str_replace(
  58.                     '{{'. $numeric_key. '}}',
  59.                     $regex[ $numeric_key ],
  60.                     $regex[ $alpha_key ] );
  61.                 }
  62.             }
  63.         }
  64.     }
  65.    
  66.     // delete all numeric regex lines
  67.     foreach( $regex as $swap_key => $swap_value )
  68.     {
  69.         if(preg_match('/swap\.([0-9]+)/',$swap_key,$swap_matches))
  70.         {
  71.             unset( $regex[ 'swap.'. $swap_matches[ 1 ] ] );
  72.         }
  73.     }
  74.  
  75.     trk_echo2( 'regex', $regex );
  76.    
  77.     return $regex;
  78. }
  79.    
  80. function regex_toc()
  81. {
  82.     global $nen;
  83.    
  84.     $replace = "$0\n";
  85.    
  86.     // top of page (title)
  87.     echo '<html><head><title>Roe XAMPP Builder (MkRoe)</title></head><body>';
  88.  
  89.    
  90.     // table of contents filename pattern
  91.     $toc_index = 0;
  92.     $toc_pattern = '/(R)([0-9]{7})\-fbc(\.bas|\.BAS)/';
  93.    
  94.     $toc = fasttoc( 'miscroe/', array( '.bas', '.BAS' ) );
  95.  
  96.     $toc_result = '';
  97.     // load regex  
  98.     $regex = regex_swap();
  99.    
  100.     $toc_lines=array();
  101.    
  102.     $result = '';
  103.    
  104.     // loop through toc
  105.     while(
  106.         ($toc_index > count( $toc ) - 1)?false:preg_match(
  107.         $toc_pattern,
  108.         $toc[ $toc_index ],
  109.         $toc_matches
  110.         )
  111.     )
  112.     {
  113.         if( $toc_index > count( $toc ) - 1 )
  114.         {
  115.             break;
  116.         }
  117.        
  118.         $ret=array();
  119.        
  120.         // echo current toc filename
  121.         echo '<h3>'. htmlentities( 'miscroe/' . $toc[ $toc_index ] ). '</h3>';
  122.                
  123.         $page = file_get_contents( $nen[ 'root' ] . 'miscroe/' . $toc[ $toc_index ] );
  124.        
  125.         echo str_replace( "\r\n", '<br>'."\r\n", htmlentities( $page ) );
  126.        
  127.        
  128.         // cycle through and perform all alpha regex
  129.         foreach( $regex as $alpha_key => $alpha_value )
  130.         {              
  131.             if( preg_match( '/swap\.([A-Z]+)/', $alpha_key ) )
  132.             {
  133.                 echo '<h3>Filter:&nbsp;'. htmlentities( $alpha_key . ':'. $alpha_value ). '</h3>';
  134.        
  135.                 // perform current alpha regex
  136.                 if(
  137.                 preg_match(
  138.                 $alpha_value,
  139.                 $page,
  140.                 $alpha_matches
  141.                 ))
  142.                 {
  143.                    
  144.                     trk_echo2( 'matches', count( $alpha_matches ) );
  145.                    
  146.                     $match_index = 0;
  147.                     while( $match_index < count( $alpha_matches ) )
  148.                     {
  149.                         // add creation card to collection
  150.                         if( !isset( $ret[ $alpha_matches[ $match_index ] ] ) )
  151.                         {
  152.                             $ret[ $alpha_matches[ $match_index ] ] = 0;
  153.                         }
  154.                         $ret[ $alpha_matches[ $match_index ] ]++;
  155.                         $match_index++;
  156.                     }
  157.                 }
  158.             }
  159.         }
  160.        
  161.         trk_echo2( 'ret', $ret );
  162.        
  163.         // sort creation card collection
  164.         ksort( $ret );
  165.        
  166.         // implode creation card collection
  167.         $crtnret = implode( "\r\n", $ret );
  168.        
  169.         //echo str_replace( "\r\n", '<br>'."\r\n", htmlentities( $page ) );
  170.        
  171.         // save creation card collection to file
  172.         file_put_contents( $nen[ 'root' ] . 'metaroe/crtnlist' . $toc_matches[ 2 ] . 'fb.dat', $crtnret );
  173.  
  174.         $toc_index++;      
  175.        
  176.     }
  177.    
  178.     // bottom of page
  179.     echo '</body></html>';
  180.  
  181. }
  182.  
  183. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement