Advertisement
jargon

Roe XAMPP Builder (Dungeon Put)

Sep 27th, 2021
1,519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.10 KB | None | 0 0
  1. <?php
  2.  
  3. include_once( 'go.php' );
  4. $me = me_shorthand( $_SERVER['SCRIPT_NAME'] );
  5.  
  6. // top of page (title)
  7. echo '<html><head><title>Roe XAMPP Builder (mk'.
  8. ( !is_null( $me ) ? ' '. $me['mk'] : '').
  9. ( !is_null( $me ) ? ' '. $me['me'] : '').
  10. ')</title><style>'. nen_css() . '</style></head><body>';
  11.  
  12. // copyright header
  13. echo '<table style="width:100%;text-align:top;"><tr><th colspan="2">
  14. <span style="alignment:center center;font-size:170%;">Roe Collector Card Game</span><br><span style="alignment:center center;font-size:120%;">Copyright 1997, 2021 Tim Keal</span></th></tr>';
  15.  
  16. echo '<tr><td>';
  17. // perform regex upon data from table of contents
  18. if( !is_null( $me ) ){
  19.    
  20.  
  21.     //cycle_sourcefiles();
  22.     //cycle_pagedata();
  23.     cycle_pagedata( $me[ 'mk' ], $me[ 'me' ] );
  24. }
  25. echo '</td></tr>';
  26.  
  27. echo '</table>';
  28.  
  29. // bottom of page
  30. echo '</body></html>';
  31.  
  32. function cycle_pagedata($mk = '', $me = '')
  33. {
  34.     global $nen;
  35.        
  36.     $toc_magic = 'dun';
  37.    
  38.     $toc = fasttoc( 'misc'. $toc_magic. '/', array( '.bas', '.BAS' ) );
  39.    
  40.     $page = '';
  41.     $toc_index = 0;
  42.  
  43.     $toc_pattern = '/(^<?magicnumber>{{$toc_magic}}(<?sourcehandle>[0-9]{3})(?<extension>\.bas|\.BAS)$/m';
  44.     $toc_pattern = str_replace( '{{$toc_magic}}', $toc_magic, $toc_pattern );
  45.    
  46.     $toc_pattern2 = file_get_contents( $nen[ 'root' ] . 'pcre/toc-'. strtolower( $me ). '.pattern.pcre' );
  47.     $toc_pattern2 = str_replace( '{{$toc_magic}}', $toc_magic, $toc_pattern2 );
  48.    
  49.     if( $toc_pattern !== $toc_pattern2)
  50.     {
  51.         $toc_pattern = $toc_pattern2;
  52.     }
  53.     unset( $toc_pattern2 );
  54.    
  55.     $pattern='/^(?<linenumber>\d{3,5}) IF (?<resource>MAP)\((?<T>[A-Z]+),(?<TT>[A-Z]+)\)=(?<assignment>\d+)(?: AND \(?([A-Z]+)(=|<>)(\d+)(?: (AND|OR) ([A-Z]+)(=|<>)(\d+)\))?)? THEN PUT\(\(\k<T>-1\)\*(\d+),\(\k<TT>-1\)\*(\d+)\),(?<sprite>[A-Z]{2})$/gm';
  56.    
  57.     $pattern2 = file_get_contents( $nen[ 'root' ] . 'pcre/'. $toc_magic. '-'. strtolower( $me ). '.pattern.pcre' );
  58.    
  59.     if( $pattern !== $pattern2)
  60.     {
  61.         $pattern = $pattern2;
  62.     }
  63.     unset( $pattern2 );
  64.    
  65.     trk_echo2( 'toc', $toc );  
  66.     trk_echo2( 'pattern', $pattern );
  67.    
  68.     trk_echo2( 'toc_index', ( $toc_index + 1 ). ' of '. count( $toc ). ':'. $toc[ $toc_index ] );
  69.    
  70.     while(
  71.     ( $toc_index > ( count( $toc ) - 1 ) )
  72.     ?
  73.     false
  74.     :
  75.     preg_match_all( $toc_pattern, $toc[ $toc_index ], $toc_matches, PREG_SET_ORDER, 0 )
  76.     )
  77.     {
  78.         trk_echo2( 'toc_index', ( $toc_index + 1 ). ' of '. count( $toc ). ':'. $toc[ $toc_index ] );
  79.        
  80.         $page2 = '';
  81.        
  82.         $toc_magic = strtolower( $toc_matches[ 'magicnumber' ] );
  83.        
  84.         echo '<h3>'. htmlentities( 'misc'. $toc_magic. '/'. $toc_matches[ 'sourcehandle' ]. $toc_matches[ 'extension' ] ). '</h3>';
  85.        
  86.         $page = file_get_contents( $nen[ 'root' ] . 'misc'. $toc_magic. '/'. $toc[ $toc_index ] );
  87.        
  88.         while( preg_match_all( $pattern, $page, $matches, PREG_SET_ORDER, 0 ) )
  89.         {                  
  90.             if( strlen( $page2 ) > 0 )
  91.             {
  92.                 $page2 .= "\r\n";
  93.             }
  94.            
  95.             $page2 .= $matches[ 0 ];
  96.        
  97.         }
  98.        
  99.         file_put_contents( $nen[ 'root' ].
  100.         'meta'. strtolower( $me ). '/R'. $mk. '-'. $me. $toc_matches[ 'sourcehandle' ].  $toc_matches[ 'extension' ]. '.dat', $page2 );
  101.        
  102.         echo $page2;
  103.        
  104.         $toc_index++;
  105.     }
  106.  
  107. }
  108.  
  109. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement