/* Where the magic happens... */
if (preg_match ("/^example\.com\\subdirectory/i", $_POST["custom"]) || preg_match ("/~example\.com\\subdirectory~/i", $_POST["txn_type"]))
curlpsr ("http://example.org/subdirectory/ipn.php", http_build_query ($_POST));
/**/
else if (preg_match ("/^example\.com/i", $_POST["custom"]) || preg_match ("/~example\.com~/i", $_POST["rp_invoice_id"]))
curlpsr ("http://example.org/?s2member_paypal_notify=1", http_build_query ($_POST));
<?php
/*
Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
<mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
*/
@ignore_user_abort(true);
/*
---- Central IPN Processing: ---------------------------------------------------------------------------------
With PayPal® Pro integration you absolutely MUST set an IPN URL inside your PayPal® account.
PayPal® Pro integration does NOT allow the IPN location to be overridden on a per-transaction basis.
So ... if you're using a single PayPal® Pro account for multiple cross-domain installations,
and you need to receive IPN notifications for each of your domains; you'll want to create
a central IPN processing script that scans variables in each IPN response,
forking itself out to each of your individual domains.
In rare cases when this is necessary, you'll find two variables in all IPN responses for s2Member.
The originating domain name will always be included somewhere within, either:
`custom` and/or `rp_invoice_id`; depending on the type of transaction.
These variables can be used to test incoming IPNs, and fork to the proper installation.
---- Instructions: -------------------------------------------------------------------------------------------
1. Set the IPN URL ( in your PayPal® account ) to the location of this script on your server.
This central processor forks IPNs out to a particular installation of s2Member ( on a particular domain ).
2. Now, here's where the magic happens ( PLEASE CHANGE: www.site1.com, www.site2.com. ).
*/
if (stripos ($_POST["custom"], "www.site1.com") !== false || stripos ($_POST["rp_invoice_id"], "www.site1.com") !== false)
curlpsr ("http://www.site1.com/?s2member_paypal_notify=1", http_build_query ($_POST));
/**/
elseif (stripos ($_POST["custom"], "www.site2.com") !== false || stripos ($_POST["rp_invoice_id"], "www.site2.com") !== false)
curlpsr ("http://www.site2.com/?s2member_paypal_notify=1", http_build_query ($_POST));
/*
This is just a utility function ( you must have the cURL extension for PHP enabled ).
*/
function curlpsr ($url = FALSE, $postvars = array (), $max_con_secs = 20, $max_stream_secs = 20, $headers = array ())
{
if (($url = trim ($url)) && ($c = curl_init ()))
{
if (is_array ($postvars)) /* Because cURL can't deal with complex arrays. */
/* Since cURL can't deal with complex arrays, we force this to a query string. */
$postvars = http_build_query ($postvars);
/**/
curl_setopt_array ($c, /* Configure options. */
array (CURLOPT_URL => $url, CURLOPT_POST => true,/**/
CURLOPT_FOLLOWLOCATION => false, CURLOPT_MAXREDIRS => 0,/**/
CURLOPT_CONNECTTIMEOUT => $max_con_secs, CURLOPT_TIMEOUT => $max_stream_secs, /* Initial connection & stream seconds. */
CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $headers, CURLOPT_POSTFIELDS => $postvars,/**/
CURLOPT_ENCODING => "", CURLOPT_VERBOSE => false, CURLOPT_FAILONERROR => true, CURLOPT_FORBID_REUSE => true, CURLOPT_SSL_VERIFYPEER => false));
/**/
$o = trim (curl_exec ($c));
/**/
curl_close($c);
}
/**/
return (!empty ($o)) ? $o : false;
}
?>
Statistics: Posted by Jason Caldwell — April 15th, 2011, 3:55 pm
Statistics: Posted by scott_van — April 12th, 2011, 10:30 pm
Statistics: Posted by Cristián Lávaque — April 12th, 2011, 7:43 pm
/* Where the magic happens... */
if (preg_match ("/^example\.com\\subdirectory/i", $_POST["custom"]) || preg_match ("/~example\.com\\subdirectory~/i", $_POST["txn_type"]))
curlpsr ("http://example.org/subdirectory/ipn.php", http_build_query ($_POST));
/**/
else if (preg_match ("/^example\.com/i", $_POST["custom"]) || preg_match ("/~example\.com~/i", $_POST["rp_invoice_id"]))
curlpsr ("http://example.org/?s2member_paypal_notify=1", http_build_query ($_POST));
Statistics: Posted by scott_van — April 12th, 2011, 5:13 pm
Statistics: Posted by scott_van — April 12th, 2011, 1:51 pm