"return 0;" in the "if ($response === false)"-statement below gets me a "500 Internal Server Error". The error check is of course relevant as otherwise the $response (in this case not an object) is later treated as an object - and that error sure shows up in the logs. The code consists of many similar sections of code "if($the_commission...)" calling the transfer-function.
If the code in the if-statement is "return 1;" then no 500-error occurs, but there are of course no real transactions. But even with the 500 error, I still get all the "core meltdown" emails - all four of them!
There is no error log or error cache generated. The curl_exec just times out, resulting in the error, which then enters the if-statement (with return 0😉 resulting in the 500 error.
BTW: The time out (the "error" source) is a new thing, it has not happened before - so the if-statement is new. If I type the curl_exec $postData in a browser, then the site responds correctly, i.e. an error message in XML-format.
.......
if ($the_commission > 0.01) {
.......
if (transfer($the_commission, $account, "Product commission") > 0) {
mysql_query("INSERT INTO transactions_account (account_transactions_customers_id,
.......
mysql_query("UPDATE transactions SET transactions_handle_time = '" . $distribution_time . "'
.......
} /* if (transfer(...*/
} /* if ($the_commission...*/
.......
if ($the_leftover> 0.01) {
.......
function transfer($amount, $recipient, $subject) {
$session = curl_init();
// Preparation of transfer
$header = array();
$url = "https://www.moneybookers.com/app/pay.pl";
$postData = "email=info@mine.com";
$postData = $postData . "&password=f1cc72314737d2a445c70fc464422fb0";
$postData = $postData . "¤cy=EUR";
$postData = $postData . "&action=prepare";
$postData = $postData . "&amount=" . $amount;
$postData = $postData . "&bnf_email=" . $recipient;
$postData = $postData . "&subject=" . $subject;
$postData = $postData . "¬e=Monthly payment";
$header[] = "Content-Type: application/x-www-form-urlencoded";
$header[] = "Content-Length: ".strlen($postData);
curl_setopt($session, CURLOPT_FRESH_CONNECT, true);
curl_setopt($session, CURLOPT_HEADER, true);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($session, CURLOPT_URL, $url);
curl_setopt($session, CURLOPT_HTTPHEADER, $header);
curl_setopt($session, CURLOPT_POSTFIELDS, $postData);
$response = curl_exec($session);
if ($response === false) {
$err = curl_error($session);
$title = "Core meltdown: " . $recipient . ".";
$msg = stripslashes($err);
mail('test@mine.com', $title, $msg, 'From: Info' );
curl_close($session);
return 0;
}
$xml = simplexml_load_string(substr($response, strpos($response, "<?xml")));
$sid = $xml->sid;
....