1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| $paypal_iplist = gethostbynamel('www.paypal.com');
$paypal_iplist2 = gethostbynamel('notify.paypal.com');
$paypal_iplist = array_merge( $paypal_iplist, $paypal_iplist2 );
$paypal_sandbox_hostname = 'ipn.sandbox.paypal.com';
$remote_hostname = gethostbyaddr( $_SERVER['REMOTE_ADDR'] );
$valid_ip = false;
if( $paypal_sandbox_hostname == $remote_hostname ) {
$valid_ip = true;
$hostname = 'www.sandbox.paypal.com';
}
else {
$ips = "";
// Loop through all allowed IPs and test if the remote IP connected here
// is a valid IP address
foreach( $paypal_iplist as $ip ) {
$ips .= "$ip,\n";
$parts = explode( ".", $ip );
$first_three = $parts[0].".".$parts[1].".".$parts[2];
if( preg_match("/^$first_three/", $_SERVER['REMOTE_ADDR']) ) {
$valid_ip = true;
}
}
$hostname = 'www.paypal.com';
} |
Partager