Advertisement
jargon

undefined array key 'ts' on line 57

Jan 3rd, 2022
1,464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.51 KB | None | 0 0
  1. <?php
  2.  
  3. function include_mostrecent()
  4. {
  5.     global $nen, $prj;
  6.     $ret = '';
  7.  
  8.     $me_long = 'most recent';
  9.     $me = str_replace( ' ', '', $me_long );
  10.  
  11.     $ext_array = array( '.7z', '.zip' );
  12.     $ext_pcre = str_replace( '.', '\\.', implode( '|', $ext_array ) );
  13.  
  14.     $toc = fasttoc( 'showcase/vault/' . $prj . '/builds', $ext_array );
  15.    
  16.     if( count( $toc ) === 0 )
  17.     {
  18.         $nen['swap.ct'][$me] = count( $toc );
  19.         $ret = '';
  20.         return $ret;
  21.     }
  22.    
  23.     $ct = 0;
  24.        
  25.     $span = 4;
  26.     $count = 0;
  27.    
  28.     $pattern = '/(?<project>.*)(?<ts>(?<yyyy>[0-9]{4})-(?<mmdd>[0-9]{4})-(?<hhmm>[0-9]{4}))(?<comment>.*)(?<ext>\.(7x|zip))/';
  29.  
  30.     $latest = '0000-0000-0000';
  31.     $latest_filename = '';
  32.  
  33.     $index = 0;
  34.     for( $index = 0; $index < count( $toc ); $index++ )
  35.     {      
  36.         preg_match( $pattern, $toc[ $index ], $matches );
  37.         $timestamp = $matches['ts'];
  38.        
  39.         if( $timestamp > $latest )
  40.         {
  41.             $latest = $timestamp;
  42.             $latest_filename = $toc[ $index ];
  43.         }
  44.  
  45.     }
  46.                    
  47.     $ret .= '<tr><td colspan="1" style="width:25%;text-align:center;font-size:170%;bold;">';
  48.                        
  49.     $ret .= '<h2><a href="./showcase/vault/' . $prj . '/builds/' . $latest_filename . '">' . $latest_filename . '</a></h2>';
  50.  
  51.     $ret .= '</td>';
  52.     $ret .= '</tr>';
  53.        
  54.     if ( strlen( $ret ) !== 0)
  55.     {
  56.         $ret = '<table colspan="' . $span . '" style="width:100%;"><th colspan="' . $span . '"><h2 style="text-align:center;" id="' . $me . '">' . ucwords( $prj ) . ' :: ' . ucwords($me_long) . '</h2></th>' . $ret . '</table>';
  57.     }
  58.  
  59.     $nen[ 'swap.ct' ][ $me ] = count($toc);
  60.  
  61.     return $ret;
  62. }
  63.  
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement