Created
October 16, 2020 14:00
-
-
Save tinshade/5949fcbc0528346d8044232526dd23d3 to your computer and use it in GitHub Desktop.
PHP code to check if you are on LocalHost or On the Server. Mostly useful to switch between local and server DB without changing the config file too often.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$whitelist = array('127.0.0.1','::1'); | |
if(!in_array($_SERVER['REMOTE_ADDR'], $whitelist)){ | |
echo 'Not Whitelisted<br/>'.$_SERVER['REMOTE_ADDR']; | |
}else{ | |
echo 'Whitelisted<br/>'.$_SERVER['REMOTE_ADDR']; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment