From 159651f3aab974bb5dd332121b3b3d755622177c Mon Sep 17 00:00:00 2001 From: Benjamin Kaiser Date: Tue, 3 Feb 2015 15:02:24 +1000 Subject: [PATCH] fixes #1 on cowboy/php-simple-proxy Change all UNDEFINED notices to not trigger (use array_key_exists instead) --- ba-simple-proxy.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ba-simple-proxy.php b/ba-simple-proxy.php index b1fa6e8..e199893 100644 --- a/ba-simple-proxy.php +++ b/ba-simple-proxy.php @@ -163,8 +163,8 @@ curl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $_POST ); } - - if ( $_GET['send_cookies'] ) { + + if ( array_key_exists('send_cookies', $_GET) ) { $cookie = array(); foreach ( $_COOKIE as $key => $value ) { $cookie[] = $key . '=' . $value; @@ -180,9 +180,9 @@ curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch, CURLOPT_HEADER, true ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); - - curl_setopt( $ch, CURLOPT_USERAGENT, $_GET['user_agent'] ? $_GET['user_agent'] : $_SERVER['HTTP_USER_AGENT'] ); - + + curl_setopt( $ch, CURLOPT_USERAGENT, array_key_exists('user_agent', $_GET) ? $_GET['user_agent'] : $_SERVER['HTTP_USER_AGENT'] ); + list( $header, $contents ) = preg_split( '/([\r\n][\r\n])\\1/', curl_exec( $ch ), 2 ); $status = curl_getinfo( $ch ); @@ -193,7 +193,7 @@ // Split header text into an array. $header_text = preg_split( '/[\r\n]+/', $header ); -if ( $_GET['mode'] == 'native' ) { +if ( array_key_exists('mode', $_GET) && $_GET['mode'] == 'native' ) { if ( !$enable_native ) { $contents = 'ERROR: invalid mode'; $status = array( 'http_code' => 'ERROR' ); @@ -214,7 +214,7 @@ $data = array(); // Propagate all HTTP headers into the JSON data object. - if ( $_GET['full_headers'] ) { + if ( array_key_exists('full_headers', $_GET) ) { $data['headers'] = array(); foreach ( $header_text as $header ) { @@ -226,7 +226,7 @@ } // Propagate all cURL request / response info to the JSON data object. - if ( $_GET['full_status'] ) { + if ( array_key_exists('full_status', $_GET) ) { $data['status'] = $status; } else { $data['status'] = array();