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
https://forums.phpfreaks.com/topic/84956-solved-fsocketopen/
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
https://forums.phpfreaks.com/topic/84956-solved-fsocketopen/#findComment-433213
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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