| 1 |
<?php |
| 2 |
|
| 3 |
class Pass_Action extends Red_Action { |
| 4 |
public function process_external( $url ) { |
| 5 |
echo @wp_remote_fopen( $url ); |
| 6 |
} |
| 7 |
|
| 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]; |
| 26 |
} |
| 27 |
} |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 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 ); |
| 41 |
} |
| 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 is_file( $target ) { |
| 51 |
return substr( $target, 0, 7 ) === 'file://'; |
| 52 |
} |
| 53 |
|
| 54 |
public function process_before( $code, $target ) { |
| 55 |
// External target |
| 56 |
if ( $this->is_external( $target ) ) { |
| 57 |
$this->process_external( $target ); |
| 58 |
exit(); |
| 59 |
} |
| 60 |
|
| 61 |
// file:// targetw |
| 62 |
if ( $this->is_file( $target ) ) { |
| 63 |
if ( defined( 'REDIRECTION_SUPPORT_PASS_FILE' ) && REDIRECTION_SUPPORT_PASS_FILE ) { |
| 64 |
$this->process_file( $target ); |
| 65 |
exit(); |
| 66 |
} |
| 67 |
|
| 68 |
return; |
| 69 |
} |
| 70 |
|
| 71 |
return $this->process_internal( $target ); |
| 72 |
} |
| 73 |
} |
| 74 |
|