Guest User

Untitled

a guest
Nov 23rd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 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. switch ( $type )
  25. {
  26. case "js":
  27. header ( "content-type: application/javascript" );
  28. break;
  29. case "css":
  30. header ( "content-type: text/css" );
  31. break;
  32. }
  33.  
  34. foreach ( $this -> packages [ $type ] [ $row [ 'name' ] ] [ 'files' ] as $file )
  35. {
  36. //$content .= file_get_contents ( $path . $file ) . "\n";
  37. include ( $path . $file );
  38. }
  39.  
  40. /*switch ( $type )
  41. {
  42. case "js":
  43. header ( "content-type: application/javascript" );
  44. echo $this -> minifyJS ( $content );
  45. break;
  46. case "css":
  47. header ( "content-type: text/css" );
  48. echo $this -> minifyCSS ( $content );
  49. break;
  50. }*/
  51.  
  52. return;
  53. }
  54. }
  55.  
  56. header ( 'HTTP/1.0 404 Not Found' );
  57. die ( "404, Not found" );
  58. }
Add Comment
Please, Sign In to add comment