Advertisement
jargon

Pzlm Dot Org Repo: Ladders & Leader Boards

Apr 4th, 2022
1,191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.57 KB | None | 0 0
  1. <?php
  2.  
  3. function include_ladders()
  4. {
  5.     global $nen;
  6.     $ret = '';
  7.  
  8.     $me_name = 'Ladders';
  9.     $me = strtolower( str_replace( ' ', '', $me_name ) );
  10.        
  11.     $ext_array = array( '' );
  12.     $ext_pcre = str_replace( '.', '\.', implode( '|', $ext_array ) );
  13.  
  14.     $toc = fasttoc( $nen[ 'vault' ], $ext_array );
  15.    
  16.     if( count( $toc ) === 0 )
  17.     {
  18.         $nen['swap.ct'][$me] = count( $toc );
  19.         $ret = '';
  20.         return $ret;
  21.     }
  22.  
  23.     $sections = array
  24.     (
  25.         3 => 'About',
  26.         4 => 'Thumbs',
  27.         5 => 'Vods',
  28.         6 => 'Most Recent',
  29.         7 => 'Submissions'
  30.     );
  31.  
  32.     $sections_old = array
  33.     (
  34.         3 => 'articles',
  35.         4 => 'thumbs',
  36.         5 => 'vods',
  37.         6 => 'mostrecent',
  38.         7 => 'builds'
  39.     );
  40.  
  41.     $ext = array
  42.     (
  43.         3 => array( '.txt' ),
  44.         4 => array( '.png', '.gif', '.jpeg', 'jpg', '.apng' ),
  45.         5 => array( '.mp4', '.mpeg', '.mpg' ),
  46.         6 => array( ),
  47.         7 => array( '.7z', '.zip' )
  48.     );
  49.  
  50.  
  51.     $div = 2;
  52.     $count = 0;
  53.    
  54.     $index = 0;
  55.     while(true)
  56.     {
  57.         if( $index > count( $toc ) - 1 )
  58.         {
  59.             break;
  60.         }
  61.        
  62.         $entry = $toc[ $index ];
  63.        
  64.         if ( preg_match('/(.*)/', $entry, $matches ) )
  65.         {
  66.             $id = $matches[ 1 ];
  67.                        
  68.             if( $index === 0 )
  69.             {
  70.                 $col = 0;
  71.                 $row = 0;
  72.             }      
  73.             else
  74.             {  
  75.                 $col = ( ( $index ) % $div ) + 0;
  76.                 $row = ( floor( $index / $div ) );
  77.             }
  78.                        
  79.             $position = 'position: absolute;';
  80.            
  81.             $width = 'width: ' . ( 25 ) . 'vw;';
  82.             $height = 'height: ' . ( 35 ) . 'vh;';
  83.            
  84.             $left ='left: ' . ( $col * floor ( 75 / $div ) + 25 ) . 'vw;';
  85.             $top = 'top: ' . ( $row * 35 ) . 'vh;';
  86.            
  87.             $right = 'right: ' . 'auto;';
  88.             $bottom = 'bottom: ' . 'auto;';
  89.  
  90.             $cfg = array
  91.             (
  92.                 1 => 'prj',
  93.                 2 => $id,
  94.                 8 => substr($id, 0 , 1)
  95.             );
  96.            
  97.             $out = array();
  98.            
  99.             foreach( $sections as $key => $value )
  100.             {
  101.                 $s = strtolower( str_replace( ' ', '', $value ) );
  102.                 $s2 = strtolower( str_replace( ' ', '', $sections_old[ $key ] ) );
  103.            
  104.                 $out[ $key ] = '<a href="?prj=' . urlencode( $id ) . '&sect=' . urlencode( $s ) . '">';
  105.                
  106.                 if( count( $ext[ $key ] ) !== 0 )
  107.                 {
  108.                     $out[ $key ] .= count( fasttoc( $nen[ 'vault' ] . $id . '/' . $s2, $ext[ $key ] ) );
  109.                     $out[ $key ] .= '&nbsp;' . $value;
  110.                 }
  111.                 else
  112.                 {
  113.                     $out[ $key ] .= $value;
  114.                 }
  115.                 $out[ $key ] .= '</a>';
  116.            
  117.             }
  118.            
  119. $thumbtoc = ( is_dir( $nen[ 'root' ] . $nen[ 'vault' ] . $id . '/thumbs' ) ? fasttoc( $nen[ 'vault' ] . $id . '/thumbs', array( '.png', '.gif', '.jpg', '.jpeg', '.apng' ) ) : array() );
  120.  
  121. $thumb = ( count( $thumbtoc ) === 0 ? 'http://puzzlum.org/repo/site%20data/art/placeholder.png' : 'http://puzzlum.org/repo/' . $nen[ 'vault' ] . $id . '/thumbs/' . $thumbtoc[ rand( 1, count( $thumbtoc ) ) - 1 ] );
  122.  
  123. $thumb = str_replace( ' ', '%20', $thumb );
  124.  
  125. $ret .=
  126. '<div class=\'wrapper\'>
  127.     <figure>
  128.         <div class=\'label\' style=\'background-image:url(' . $thumb . ');\'>
  129.             <a href=\'?prj=' . urlencode( $id ) . '&sect=' . urlencode( $s ) . '\'>
  130.                 <img src=\'http://puzzlum.org/repo/site%20data/art/floppy-overlay.png\' alt=\'' . $id . '\' />
  131.             </a>
  132.         </div>
  133.         <figcaption>' .
  134.             ( count( $out ) > 0 ? '<ul><li><a href="?prj=' . urlencode( $id ) . '&sect=' . urlencode( $s ) . '">' . $id . '</a></li><li>' : '' ) . implode( '</li><li>', $out ) . ( count( $out ) > 0 ? '</li></ul>' : '' ) .
  135.         '</figcaption>
  136.     </figure>
  137. </div><p><img src=\'http://puzzlum.org/repo/site%20data/art/separators/Green%20Oil%20Scuff.png\' alt=\'Green Oil Pipe Separator\'/></p>';
  138.                
  139.             $count++;
  140.         }
  141.    
  142.     $index++;
  143.    
  144.     }
  145.    
  146.     $nen['swap.ct'][$me] = count( $toc );
  147.    
  148.     if( $nen[ 'sect' ] !== $me )
  149.     {
  150.         return '';
  151.     }
  152.     else
  153.     {
  154.         return $ret;
  155.     }
  156.    
  157. }
  158.  
  159. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement