Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- # this is an example of a bad idea
- # X_FORWARDED_FOR can be spoofed.
- public static function getIPAddress() {
- if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) ) {
- $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
- } elseif ( isset($_SERVER['HTTP_CLIENT_IP']) ) {
- $ip = $_SERVER['HTTP_CLIENT_IP'];
- } else {
- $ip = $_SERVER['REMOTE_ADDR'];
- }
- return $ip;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement