Jump to content

[SOLVED] fsocketopen


steviez

Recommended Posts

Hi,

 

I have just installed a paypal IPN script on my site and im reciveing this error:

 

Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of fsockopen(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer.

 

Whats wrong and how can i fix it?

Link to comment
Share on other sites

I have done that but now all i get is a blank page and a email saying bad order. Here is the code:

 

<?php
class paypal_ipn
{
var $paypal_post_vars;
var $paypal_response;
var $timeout;

var $error_email;

function paypal_ipn($paypal_post_vars) {
	$this->paypal_post_vars = $paypal_post_vars;
	$this->timeout = 120;
}

function send_response()
{
	$fp = @fsockopen( "www.paypal.com", 80, $errno, $errstr, 120 );

	if (!$fp) {
		$this->error_out("PHP fsockopen() error: " . $errstr , "");
	} else {
		foreach($this->paypal_post_vars AS $key => $value) {
			if (@get_magic_quotes_gpc()) {
				$value = stripslashes($value);
			}
			$values[] = "$key" . "=" . urlencode($value);
		}

		$response = @implode("&", $values);
		$response .= "&cmd=_notify-validate";

		fputs( $fp, "POST /cgi-bin/webscr HTTP/1.0\r\n" );
		fputs( $fp, "Content-type: application/x-www-form-urlencoded\r\n" );
		fputs( $fp, "Content-length: " . strlen($response) . "\r\n\n" );
		fputs( $fp, "$response\n\r" );
		fputs( $fp, "\r\n" );

		$this->send_time = time();
		$this->paypal_response = "";

		// get response from paypal
		while (!feof($fp)) {
			$this->paypal_response .= fgets( $fp, 1024 );

			if ($this->send_time < time() - $this->timeout) {
				$this->error_out("Timed out waiting for a response from PayPal. ($this->timeout seconds)" , "");
			}
		}

		fclose( $fp );

	}

}

function is_verified() {
	if( ereg("VERIFIED", $this->paypal_response) )
		return true;
	else
		return false;
} 

function get_payment_status() {
	return $this->paypal_post_vars['payment_status'];
}

function error_out($message, $em_headers)
{

	$date = date("D M j G:i:s T Y", time());
	$message .= "\n\nThe following data was received from PayPal:\n\n";

	@reset($this->paypal_post_vars);
	while( @list($key,$value) = @each($this->paypal_post_vars)) {
		$message .= $key . ':' . " \t$value\n";
	}
	mail($this->error_email, "[$date] paypay_ipn notification", $message, $em_headers);

}
}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.