Skip to content

Instantly share code, notes, and snippets.

@rmdhfz
Last active April 14, 2022 02:51
Show Gist options
  • Save rmdhfz/e13a82c71adb8788329403481bed7da6 to your computer and use it in GitHub Desktop.
Save rmdhfz/e13a82c71adb8788329403481bed7da6 to your computer and use it in GitHub Desktop.
Whitelist Incoming IP (midtrans) for Post Notification Payment
<?php
$RequestIP = (isset($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
$IP_MIDTRANS = ['103\.208\..*', '103\.208\..*', '103\.127\..*', '103\.127\..*'];
if(!preg_match('/^(' . implode('|', $IP_MIDTRANS) . ')/', $RequestIP)){
http_response_code(401);
return false;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment