Guest User

Untitled

a guest
Nov 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1.     public function loadResource ( $key )
  2.     {  
  3.         $key_bits = explode ( ".", $key );
  4.  
  5.         $id = UrlShortener::shortToInt ( $key_bits [ 0 ] );
  6.         $type = $key_bits [ 1 ];
  7.        
  8.         $query = mysql_query ( "SELECT name, built FROM resources_v2 WHERE id = '$id' AND type = '$type' LIMIT 1" );
  9.        
  10.         if ( mysql_num_rows ( $query ) > 0 )
  11.         {
  12.             $row = mysql_fetch_assoc ( $query );
  13.            
  14.             if ( is_array ( $this -> packages [ $type ] [ $row [ 'name' ] ] ) )
  15.             {
  16.                 header("Cache-Control: max-age=1209600, must-revalidate");
  17.                 //header("Last-Modified: " . gmdate('D, d M Y H:i:s', strtotime ( $row [ 'built' ] ) ) . ' GMT' );
  18.                 //header("HTTP/1.1 304 Not Modified");
  19.                
  20.                 $path = $this -> getPath ( $type );
  21.  
  22.                 $content = '';
  23.                
  24.                 foreach ( $this -> packages [ $type ] [ $row [ 'name' ] ] [ 'files' ] as $file )
  25.                 {
  26.                     $content .= file_get_contents ( $path . $file ) . "\n";
  27.                 }
  28.            
  29.                 switch ( $type )
  30.                 {
  31.                     case "js":
  32.                         header ( "content-type: application/javascript" );
  33.                         echo $this -> minifyJS ( $content );
  34.                         break;
  35.                     case "css":
  36.                         header ( "content-type: text/css" );
  37.                         echo $this -> minifyCSS ( $content );
  38.                         break;
  39.                 }
  40.                
  41.                 return;
  42.             }
  43.         }
  44.        
  45.         header ( 'HTTP/1.0 404 Not Found' );
  46.         die ( "404, Not found" );
  47.     }
Add Comment
Please, Sign In to add comment