Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Big error log with ePDQ CPI Module


goring_gap

Recommended Posts

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

Link to comment
Share on other sites

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;
	}

Link to comment
Share on other sites

  • 2 weeks later...

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);
Link to comment
Share on other sites

  • 5 months later...
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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...