In January 2014 my Paypal gateway has stopped working properly. Sometimes payments went through, sometimes they didn’t. After a period of debugging, I’ve noticed, that the Script stopped here:

                while (!feof($fp)) {
                        $res = fgets ($fp, 1024);
                        $debugger[] = 'res: '.$res;
                        // - DEAD END - //
                        if (strcmp ($res, "VERIFIED") == 0) {

I’ve found the solution to this problem in this Blog. I indeed made all the changes when Paypal has announced the switch to HTTP 1.1 in 2013, but those upgrade information seemed to be incomplete. The new response is now followed with “\r\n” and this is why the condition

if (strcmp ($res, "VERIFIED") == 0) { 

isn’t working anymore. The solution is simple and called trim:

$res = trim(fgets ($fp, 1024));

That’s it. Now, the gateway is working again!