| @@ -1,63 +1,40 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class Pass_Action extends Red_Action { |
| 4 | - public function process_external( $url ) { | |
| 5 | - echo @wp_remote_fopen( $url ); | |
| 6 | - } | |
| 4 | + function process_before( $code, $target ) { | |
| 5 | + // Determine what we are passing to: local URL, remote URL, file | |
| 6 | + if ( substr( $target, 0, 7 ) === 'http://' || substr( $target, 0, 8 ) === 'https://' ) { | |
| 7 | + echo @wp_remote_fopen( $target ); | |
| 8 | + die(); | |
| 9 | + } | |
| 10 | + else if ( substr( $target, 0, 7 ) === 'file://' ) { | |
| 11 | + $parts = explode( '?', substr( $target, 7 ) ); | |
| 12 | + if ( count( $parts ) > 1 ) { | |
| 13 | + // Put parameters into the environment | |
| 14 | + $args = explode( '&', $parts[1] ); | |
| 7 | 15 | |
| 8 | - /** | |
| 9 | - * This is deprecated and will be removed in a future version | |
| 10 | - */ | |
| 11 | - public function process_file( $url ) { | |
| 12 | - $parts = explode( '?', substr( $url, 7 ) ); | |
| 13 | - | |
| 14 | - if ( count( $parts ) > 1 ) { | |
| 15 | - // Put parameters into the environment | |
| 16 | - $args = explode( '&', $parts[1] ); | |
| 17 | - | |
| 18 | - if ( count( $args ) > 0 ) { | |
| 19 | - foreach ( $args as $arg ) { | |
| 20 | - $tmp = explode( '=', $arg ); | |
| 21 | - | |
| 22 | - if ( count( $tmp ) === 1 ) { | |
| 23 | - $_GET[ $arg ] = ''; | |
| 24 | - } else { | |
| 25 | - $_GET[ $tmp[0] ] = $tmp[1]; | |
| 16 | + if ( count( $args ) > 0 ) { | |
| 17 | + foreach ( $args as $arg ) { | |
| 18 | + $tmp = explode( '=', $arg ); | |
| 19 | + if ( count( $tmp ) === 1 ) | |
| 20 | + $_GET[ $arg ] = ''; | |
| 21 | + else | |
| 22 | + $_GET[ $tmp[0] ] = $tmp[1]; | |
| 26 | 23 | } |
| 27 | 24 | } |
| 28 | 25 | } |
| 29 | - } | |
| 30 | 26 | |
| 31 | - @include $parts[0]; | |
| 32 | - } | |
| 33 | - | |
| 34 | - public function process_internal( $target ) { | |
| 35 | - // Another URL on the server | |
| 36 | - $_SERVER['REQUEST_URI'] = $target; | |
| 37 | - | |
| 38 | - if ( strpos( $target, '?' ) ) { | |
| 39 | - $_SERVER['QUERY_STRING'] = substr( $target, strpos( $target, '?' ) + 1 ); | |
| 40 | - parse_str( $_SERVER['QUERY_STRING'], $_GET ); | |
| 27 | + include( $parts[0] ); | |
| 28 | + exit(); | |
| 41 | 29 | } |
| 42 | - | |
| 43 | - return true; | |
| 44 | - } | |
| 45 | - | |
| 46 | - public function is_external( $target ) { | |
| 47 | - return substr( $target, 0, 7 ) === 'http://' || substr( $target, 0, 8 ) === 'https://'; | |
| 48 | - } | |
| 49 | - | |
| 50 | - public function process_before( $code, $target ) { | |
| 51 | - // External target | |
| 52 | - if ( $this->is_external( $target ) ) { | |
| 53 | - $this->process_external( $target ); | |
| 54 | - exit(); | |
| 30 | + else { | |
| 31 | + $_SERVER['REQUEST_URI'] = $target; | |
| 32 | + if ( strpos( $target, '?' ) ) { | |
| 33 | + $_SERVER['QUERY_STRING'] = substr( $target, strpos( $target, '?' ) + 1 ); | |
| 34 | + parse_str( $_SERVER['QUERY_STRING'], $_GET ); | |
| 35 | + } | |
| 55 | 36 | } |
| 56 | 37 | |
| 57 | - return $this->process_internal( $target ); | |
| 58 | - } | |
| 59 | - | |
| 60 | - public function needs_target() { | |
| 61 | 38 | return true; |
| 62 | 39 | } |
| 63 | 40 | } |