Skip to content

Commit

Permalink
Prevent notices in php log because of undefined vars
Browse files Browse the repository at this point in the history
  • Loading branch information
torinfo committed May 24, 2022
1 parent c1257b7 commit 6d3fff1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions xapi_proxy.php
Expand Up @@ -427,8 +427,12 @@ function convertToCurl($headers)
}
}
// Split header text into an array.
$header_text = preg_split( '/[\r\n]+/', $header );
if ( (isset($_GET['mode'] ) && $_GET['mode'] == 'native') || $force_native) {
$header_text = array();
if (isset($header))
{
$header_text = preg_split( '/[\r\n]+/', $header );
}
if ( (isset($_GET['mode'] ) && $_GET['mode'] == 'native') || (isset($force_native) && $force_native)) {
if ( !$enable_native ) {
$contents = 'ERROR: invalid mode';
$status = array( 'http_code' => 'ERROR' );
Expand Down Expand Up @@ -473,11 +477,14 @@ function convertToCurl($headers)
$data['contents'] = $decoded_json ? $decoded_json : $contents;

// Generate appropriate content-type header.
$is_xhr = strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
$is_xhr = false;
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
$is_xhr = strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}
header( 'Content-type: application/' . ( $is_xhr ? 'json' : 'x-javascript' ) );

// Get JSONP callback.
$jsonp_callback = $enable_jsonp && isset($_GET['callback']) ? $_GET['callback'] : null;
$jsonp_callback = isset($enable_jsonp) && $enable_jsonp && isset($_GET['callback']) ? $_GET['callback'] : null;

// Generate JSON/JSONP string
$json = json_encode( $data );
Expand Down

0 comments on commit 6d3fff1

Please sign in to comment.