input.php
| 1 | <?php |
| 2 | |
| 3 | // vars |
| 4 | $expires_offset = 31536000; // 1 year |
| 5 | $out = ''; |
| 6 | $prefix = 'input/'; |
| 7 | $files = array( |
| 8 | 'actions.js', |
| 9 | 'color-picker.js', |
| 10 | 'date-picker.js', |
| 11 | 'file.js', |
| 12 | 'image.js', |
| 13 | 'relationship.js', |
| 14 | 'tab.js', |
| 15 | 'validation.js', |
| 16 | 'wysiwyg.js' |
| 17 | ); |
| 18 | |
| 19 | |
| 20 | // helpers |
| 21 | function get_file($path) |
| 22 | { |
| 23 | if ( function_exists('realpath') ) |
| 24 | $path = realpath($path); |
| 25 | |
| 26 | if ( ! $path || ! @is_file($path) ) |
| 27 | return ''; |
| 28 | |
| 29 | return @file_get_contents($path); |
| 30 | } |
| 31 | |
| 32 | if( $files ) |
| 33 | { |
| 34 | foreach( $files as $file ) { |
| 35 | $out .= get_file( $prefix . $file ) . "\n"; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | |
| 40 | // set headers to return a JS file |
| 41 | header('Content-Type: application/x-javascript; charset=UTF-8'); |
| 42 | header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT'); |
| 43 | header("Cache-Control: public, max-age=$expires_offset"); |
| 44 | |
| 45 | echo $out; |
| 46 | exit; |
| 47 | |
| 48 | ?> |