Skip to content

Commit bbcc49e

Browse files
author
Pat Patterson
committed
Fix PHP notices re undefined indices
1 parent a6f3946 commit bbcc49e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

proxy.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@
234234
curl_setopt( $ch, CURLOPT_POSTFIELDS, file_get_contents("php://input") );
235235
}
236236

237-
if ( $_GET['send_cookies'] ) {
237+
if ( isset($_GET['send_cookies']) ) {
238238
$cookie = array();
239239
foreach ( $_COOKIE as $key => $value ) {
240240
$cookie[] = $key . '=' . $value;
@@ -275,7 +275,7 @@
275275
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
276276

277277
curl_setopt( $ch, CURLOPT_USERAGENT,
278-
$_GET['user_agent'] ? $_GET['user_agent'] : $_SERVER['HTTP_USER_AGENT'] );
278+
isset($_GET['user_agent']) ? $_GET['user_agent'] : $_SERVER['HTTP_USER_AGENT'] );
279279

280280
list( $header, $contents ) = preg_split( '/([\r\n][\r\n])\\1/', curl_exec( $ch ), 2 );
281281

@@ -300,17 +300,23 @@
300300
}
301301

302302
if ( isset( $status['http_code'] ) ) {
303-
header("HTTP/1.1 ".$status['http_code']." ".$status['status_text']);
304-
print $contents;
305-
exit();
306-
}
303+
$header = "HTTP/1.1 ".$status['http_code'];
304+
if (isset($status['status_text'])) {
305+
$header .= " ".$status['status_text'];
306+
}
307+
header( $header );
307308

309+
$header_match = '/^(?:Content-Type|Content-Language|Set-Cookie)/i';
310+
} else {
311+
$header_match = '/^(?:HTTP|Content-Type|Content-Language|Set-Cookie)/i';
312+
}
313+
308314
foreach ( $header_text as $header ) {
309-
if ( preg_match( '/^(?:HTTP|Content-Type|Content-Language|Set-Cookie)/i', $header ) ) {
315+
if ( preg_match( $header_match, $header ) ) {
310316
header( $header );
311317
}
312318
}
313-
319+
314320
print $contents;
315321

316322
} else {

0 commit comments

Comments
 (0)