| 1 |
<?php |
| 2 |
|
| 3 |
class Pass_Action extends Red_Action { |
| 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] ); |
| 15 |
|
| 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]; |
| 23 |
} |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
include( $parts[0] ); |
| 28 |
exit(); |
| 29 |
} |
| 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 |
} |
| 36 |
} |
| 37 |
|
| 38 |
return true; |
| 39 |
} |
| 40 |
} |
| 41 |
|