goring_gap Posted February 27, 2007 Share Posted February 27, 2007 Hello, Re: ePDQ CPI Module I am getting a massive error log seemingly caused by the epdq payment module. I have had 7GB of the following... PHP Warning: fgets(): supplied argument is not a valid stream resource in /home/x/x/xxxxxxxx/public_html/includes/modules/payment/ePDQ.php PHP Fatal error: Maximum execution time of 30 seconds exceeded in /home/x/x/xxxxxxxx/public_html/includes/modules/payment/ePDQ.php on line 284 The offending line is: while (!feof($connection)) $responsedata .= fgets($connection, 1024); The same code seems to be in the previous/other epdq module also. It only starts to happen on average once per day at busy times! Any ideas most welcome? Regards, Simon Quote Link to comment Share on other sites More sharing options...
goring_gap Posted February 27, 2007 Author Share Posted February 27, 2007 Hello, Re: ePDQ CPI Module I am getting a massive error log seemingly caused by the epdq payment module. I have had 7GB of the following... PHP Warning: fgets(): supplied argument is not a valid stream resource in /home/x/x/xxxxxxxx/public_html/includes/modules/payment/ePDQ.php PHP Fatal error: Maximum execution time of 30 seconds exceeded in /home/x/x/xxxxxxxx/public_html/includes/modules/payment/ePDQ.php on line 284 The offending line is: while (!feof($connection)) $responsedata .= fgets($connection, 1024); The same code seems to be in the previous/other epdq module also. It only starts to happen on average once per day at busy times! Any ideas most welcome? Regards, Simon I have found the following from php help pages: stream_set_timeout() Its seems to suggest that the above function can be used to set a time for feof(). Can anyone advise how I would use it in the context of the following code from the epdq module (below) or if indeed it will help?? function PostData($requesthost, $requestdocument, $requestdata) { Global $customer_id; if (is_array($requestdata)): foreach($requestdata as $key => $value) $requestbodyarray[] = urlencode($key) . "=" . urlencode($value); $requestbody = implode("&", $requestbodyarray); endif; $requestheader = "POST $requestdocument HTTP/1.0\r\n"; $requestheader .= "Host: $requesthost\r\n"; $requestheader .= "Content-type: application/x-www-form-urlencoded\r\n"; $requestheader .= "Content-length: " . strlen($requestbody) . "\r\n"; $requestheader .= "\r\n"; $connection = fsockopen("$requesthost", 80); fputs($connection, $requestheader . $requestbody); $responsedata = ""; while (!feof($connection)) $responsedata .= fgets($connection, 1024); fclose($connection); $EncryptedResult = trim($responsedata); $EncryptedResult = strstr($responsedata, "value="); $EncryptedResult = substr(strstr($EncryptedResult, "\""), 1, strlen(strstr($EncryptedResult, "\"")) - strlen(strrchr($EncryptedResult, "\"")) - 1); $responsearray = explode("\n", str_replace("\r", "", $responsedata)); if (preg_match("|^HTTP/\S+ (\d+) |i", trim($responsearray[0]), $matches)): $returnarray["EncryptedResult"] = $EncryptedResult; return $returnarray; else: return false; endif; } Quote Link to comment Share on other sites More sharing options...
goring_gap Posted March 11, 2007 Author Share Posted March 11, 2007 Sorry to bump but this is becoming a real issue. Is anyone else have similar problems with the ePDQ module? It appears that both available modules use roughly the saem code: while (!feof($connection)) $responsedata .= fgets($connection, 1024); Quote Link to comment Share on other sites More sharing options...
goring_gap Posted September 11, 2007 Author Share Posted September 11, 2007 Hello, Re: ePDQ CPI Module I am getting a massive error log seemingly caused by the epdq payment module. I have had 7GB of the following... PHP Warning: fgets(): supplied argument is not a valid stream resource in /home/x/x/xxxxxxxx/public_html/includes/modules/payment/ePDQ.php PHP Fatal error: Maximum execution time of 30 seconds exceeded in /home/x/x/xxxxxxxx/public_html/includes/modules/payment/ePDQ.php on line 284 The offending line is: while (!feof($connection)) $responsedata .= fgets($connection, 1024); The same code seems to be in the previous/other epdq module also. It only starts to happen on average once per day at busy times! Any ideas most welcome? Regards, Simon I think the following provides a fix.... in /includes/modules/payment/epdq.php find $connection = fsockopen("$requesthost", 80); fputs($connection, $requestheader . $requestbody); $responsedata = ""; while (!feof($connection)) $responsedata .= fgets($connection, 1024); fclose($connection); and replace with... //fix for error log issue - start /*$connection = fsockopen("$requesthost", 80); fputs($connection, $requestheader . $requestbody); $responsedata = ""; while (!feof($connection)) $responsedata .= fgets($connection, 1024); fclose($connection);*/ $connection = fsockopen("$requesthost", 80); if (!$connection) { echo "Unable to contact ePDQ\n"; } else { fputs($connection, $requestheader . $requestbody); $responsedata = ""; stream_set_blocking($connection, FALSE ); //important stream_set_timeout($connection, 4); // set timeout value here in seconds $info = stream_get_meta_data($connection); while (!feof($connection) && !$info['timed_out']) { //check in the loop $responsedata .= fgets($connection, 1024); $info = stream_get_meta_data($connection); } fclose($connection); } //fix for error log issue - end it's a tricky issue to test with the epdq site going down so please post back here if it doesn't work for you? Simon Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.