|
| 1 | +<?php |
| 2 | + |
| 3 | +/** Set ABSPATH for execution */ |
| 4 | +define( 'ABSPATH', dirname(dirname(__FILE__)) ); |
| 5 | +define( 'WPINC', '/wp-includes' ); |
| 6 | + |
| 7 | +/** |
| 8 | + * @ignore |
| 9 | + */ |
| 10 | +function __() {} |
| 11 | + |
| 12 | +/** |
| 13 | + * @ignore |
| 14 | + */ |
| 15 | +function _c() {} |
| 16 | + |
| 17 | +/** |
| 18 | + * @ignore |
| 19 | + */ |
| 20 | +function add_filter() {} |
| 21 | + |
| 22 | +/** |
| 23 | + * @ignore |
| 24 | + */ |
| 25 | +function attribute_escape() {} |
| 26 | + |
| 27 | +/** |
| 28 | + * @ignore |
| 29 | + */ |
| 30 | +function apply_filters() {} |
| 31 | + |
| 32 | +/** |
| 33 | + * @ignore |
| 34 | + */ |
| 35 | +function get_option() {} |
| 36 | + |
| 37 | +/** |
| 38 | + * @ignore |
| 39 | + */ |
| 40 | +function is_lighttpd_before_150() {} |
| 41 | + |
| 42 | +/** |
| 43 | + * @ignore |
| 44 | + */ |
| 45 | +function add_action() {} |
| 46 | + |
| 47 | +/** |
| 48 | + * @ignore |
| 49 | + */ |
| 50 | +function do_action_ref_array() {} |
| 51 | + |
| 52 | +/** |
| 53 | + * @ignore |
| 54 | + */ |
| 55 | +function get_bloginfo() {} |
| 56 | + |
| 57 | +/** |
| 58 | + * @ignore |
| 59 | + */ |
| 60 | +function is_admin() {return true;} |
| 61 | + |
| 62 | +/** |
| 63 | + * @ignore |
| 64 | + */ |
| 65 | +function site_url() {} |
| 66 | + |
| 67 | +/** |
| 68 | + * @ignore |
| 69 | + */ |
| 70 | +function admin_url() {} |
| 71 | + |
| 72 | +/** |
| 73 | + * @ignore |
| 74 | + */ |
| 75 | +function wp_guess_url() {} |
| 76 | + |
| 77 | +function get_file($path) { |
| 78 | + |
| 79 | + if ( function_exists('realpath') ) |
| 80 | + $path = realpath($path); |
| 81 | + |
| 82 | + if ( ! $path || ! @is_file($path) ) |
| 83 | + return ''; |
| 84 | + |
| 85 | + return @file_get_contents($path); |
| 86 | +} |
| 87 | + |
| 88 | +if ( isset($_GET['test']) && 1 == $_GET['test'] ) { |
| 89 | + if ( ini_get('zlib.output_compression') ) |
| 90 | + exit(''); |
| 91 | + |
| 92 | + $out = 'var wpCompressionTest = 1;'; |
| 93 | + |
| 94 | + $compressed = false; |
| 95 | + if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') ) { |
| 96 | + header('Content-Encoding: deflate'); |
| 97 | + $out = gzdeflate( $out, 3 ); |
| 98 | + $compressed = true; |
| 99 | + } elseif ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) { |
| 100 | + header('Content-Encoding: gzip'); |
| 101 | + $out = gzencode( $out, 3 ); |
| 102 | + $compressed = true; |
| 103 | + } |
| 104 | + |
| 105 | + if ( ! $compressed ) |
| 106 | + exit(''); |
| 107 | + |
| 108 | + header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' ); |
| 109 | + header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); |
| 110 | + header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); |
| 111 | + header( 'Pragma: no-cache' ); |
| 112 | + header( 'Content-Type: application/x-javascript; charset=UTF-8' ); |
| 113 | + echo $out; |
| 114 | + exit; |
| 115 | +} |
| 116 | + |
| 117 | +$load = preg_replace( '/[^a-z0-9,_-]*/i', '', $_GET['load'] ); |
| 118 | +$load = explode(',', $load); |
| 119 | + |
| 120 | +if ( empty($load) ) |
| 121 | + exit; |
| 122 | + |
| 123 | +require(ABSPATH . '/wp-includes/script-loader.php'); |
| 124 | +require(ABSPATH . '/wp-includes/version.php'); |
| 125 | + |
| 126 | +// Discard any buffers |
| 127 | +while ( @ob_end_clean() ); |
| 128 | + |
| 129 | +$compress = ( isset($_GET['c']) && 1 == $_GET['c'] ); |
| 130 | +$expires_offset = 31536000; |
| 131 | +$out = ''; |
| 132 | + |
| 133 | +$wp_scripts = new WP_Scripts(); |
| 134 | +wp_default_scripts($wp_scripts); |
| 135 | + |
| 136 | +foreach( $load as $handle ) { |
| 137 | + if ( !array_key_exists($handle, $wp_scripts->registered) ) |
| 138 | + continue; |
| 139 | + |
| 140 | + $path = ABSPATH . $wp_scripts->registered[$handle]->src; |
| 141 | + $out .= get_file($path) . "\n"; |
| 142 | +} |
| 143 | + |
| 144 | +header('Content-Type: application/x-javascript; charset=UTF-8'); |
| 145 | +header('Vary: Accept-Encoding'); // Handle proxies |
| 146 | +header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT'); |
| 147 | +header("Cache-Control: public, max-age=$expires_offset"); |
| 148 | + |
| 149 | +if ( $compress && ! ini_get('zlib.output_compression') ) { |
| 150 | + if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') ) { |
| 151 | + header('Content-Encoding: deflate'); |
| 152 | + $out = gzdeflate( $out, 3 ); |
| 153 | + } elseif ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) { |
| 154 | + header('Content-Encoding: gzip'); |
| 155 | + $out = gzencode( $out, 3 ); |
| 156 | + } |
| 157 | +} |
| 158 | + |
| 159 | +echo $out; |
| 160 | +exit; |
0 commit comments