Skip to content

Commit 6722558

Browse files
committed
Enable Callback Delay
1 parent 3d6ef5d commit 6722558

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

index.php

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ function process_transaction($parsed, $request)
671671
$result = ltrim($result, SPACE_TRIMMER);
672672
$arr6 = explode("=", $result, 2);
673673
$variable = $arr6[0];
674-
$value = $arr6[1];
674+
$value = @$arr6[1];
675675

676676
if(stripos($variable, '$OUTPUT.') === 0)
677677
{
@@ -1471,7 +1471,7 @@ function send_callback_sync($output)
14711471
if(!$hostFound)
14721472
{
14731473
$target_host = $url_info['host'];
1474-
$port = $url_info['port'] * 1;
1474+
$port = @$url_info['port'] * 1;
14751475
$scheme = $url_info['scheme'];
14761476
if($port != 0)
14771477
{
@@ -1502,8 +1502,24 @@ function send_callback_sync($output)
15021502
return $res;
15031503
}
15041504

1505-
function send_response($output, $parsed)
1505+
function send_response($output, $parsed, $async)
15061506
{
1507+
$response = NULL;
1508+
if(isset($output['BODY']))
1509+
{
1510+
$response = @$output['BODY'];
1511+
}
1512+
if($async)
1513+
{
1514+
ob_start();
1515+
1516+
if($response != NULL)
1517+
{
1518+
echo $response;
1519+
}
1520+
}
1521+
1522+
15071523
if(isset($output['STATUS']))
15081524
{
15091525
$status = trim($output['STATUS']);
@@ -1550,13 +1566,27 @@ function send_response($output, $parsed)
15501566
header("Content-type: $content_type");
15511567
}
15521568
}
1569+
header('Connection: close');
15531570

1554-
if(isset($output['BODY']))
1571+
if($response != NULL)
15551572
{
1556-
$response = @$output['BODY'];
15571573
header("Content-length: ".strlen($response));
1574+
}
1575+
if($async)
1576+
{
1577+
ob_end_flush();
1578+
ob_flush();
1579+
flush();
1580+
if(function_exists('fastcgi_finish_request'))
1581+
{
1582+
fastcgi_finish_request(); //required for PHP-FPM (PHP > 5.3.3)
1583+
}
1584+
}
1585+
else
1586+
{
15581587
echo $response;
15591588
}
1589+
15601590
}
15611591

15621592
function get_user_browser(){
@@ -1625,14 +1655,15 @@ function get_user_browser(){
16251655
// Finally, send response to client
16261656
if(!empty($output))
16271657
{
1628-
send_response($output, $parsed);
1658+
send_response($output, $parsed, true);
16291659

16301660
if(isset($output['CALLBACK_URL']))
16311661
{
16321662
$clbk = send_callback($output);
16331663
}
16341664
}
16351665
}
1666+
die(); //a must especially if set_time_limit=0 is used and the task ends
16361667
}
16371668
else
16381669
{

0 commit comments

Comments
 (0)