Advertisement
jargon

Dugeon XAMPP Builder (MkPut)

Sep 28th, 2021
1,678
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.39 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>\d+)(?<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.     $card_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})$/m';
  56.    
  57.     $card_pattern2 = file_get_contents( $nen[ 'root' ] . 'pcre/'. $toc_magic. '-'. strtolower( $me ). '.pattern.pcre' );
  58.    
  59.     if( $card_pattern !== $card_pattern2)
  60.     {
  61.         $card_pattern = $card_pattern2;
  62.     }
  63.     unset( $card_pattern2 );
  64.    
  65.     trk_echo2( 'toc', $toc );  
  66.     trk_echo2( 'toc.pattern', $toc_pattern );
  67.     trk_echo2( 'card.pattern', $card_pattern );
  68.    
  69.     while(
  70.     ( $toc_index > ( count( $toc ) - 1 ) )
  71.     ?
  72.     false
  73.     :
  74.     preg_match( $toc_pattern, $toc[ $toc_index ], $toc_matches )
  75.     )
  76.     {
  77.         trk_echo2( 'toc_index', ( $toc_index + 1 ). ' of '. count( $toc ). ':'. $toc[ $toc_index ] );
  78.        
  79.         $page2 = '';
  80.        
  81.         $toc_magic = strtolower( $toc_matches[ 'magicnumber' ] );
  82.        
  83.         echo '<h3>'. htmlentities( 'misc'. $toc_magic. '/'. $toc_magic. $toc_matches[ 'sourcehandle' ]. $toc_matches[ 'extension' ] ). '</h3>';
  84.        
  85.         $page = file_get_contents( $nen[ 'root' ] . 'misc'. $toc_magic. '/'. $toc[ $toc_index ] );
  86.  
  87.         echo '<h3>'. htmlentities( 'misc'. $toc_magic. '/'. $toc[ $toc_index ] ). '</h3>'; 
  88.        
  89.         while( preg_match_all( $card_pattern, $page, $card_matches, PREG_SET_ORDER, 0 ) )
  90.         {                  
  91.             foreach($card_matches as $card_key => $card_value )
  92.             {
  93.                 if( strlen( $page2 ) > 0 )
  94.                 {
  95.                     $page2 .= "\r\n";
  96.                 }
  97.                 $page2 .= $card_value;
  98.             }
  99.         }
  100.        
  101.         echo '<h3>'. htmlentities( 'meta'. strtolower( $me ). '/R'. $mk. '-'. $me. $toc_matches[ 'sourcehandle' ].  $toc_matches[ 'extension' ]. '.dat' ). '</h3>';
  102.  
  103.         file_put_contents( $nen[ 'root' ].
  104.         'meta'. strtolower( $me ). '/R'. $mk. '-'. $me. $toc_matches[ 'sourcehandle' ].  $toc_matches[ 'extension' ]. '.dat', $page2 );
  105.        
  106.         echo $page2;
  107.        
  108.         $toc_index++;
  109.     }
  110.  
  111. }
  112.  
  113. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement