Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $user_agent = getenv("HTTP_USER_AGENT");
- if(strpos($user_agent, "Win") !== FALSE)
- {
- $db_user = ($_SERVER['HTTP_HOST'] == 'localhost' || $_SERVER['HTTP_HOST'] == getHostByName(getHostName())) ? 'root' : 'database_name';
- $db_pass = ($_SERVER['HTTP_HOST'] == 'localhost' || $_SERVER['HTTP_HOST'] == getHostByName(getHostName())) ? '' : '';
- }elseif(strpos($user_agent, "Mac") !== FALSE){
- $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
- $res = socket_connect($sock, '8.8.8.8', 53);
- // You might want error checking code here based on the value of $res
- socket_getsockname($sock, $current_ip); // Use $current_ip Variable For The Mac Current IP Address
- socket_shutdown($sock);
- socket_close($sock);
- $db_user = ($_SERVER['HTTP_HOST'] == 'localhost' || $_SERVER['HTTP_HOST'] == $current_ip) ? 'root' : 'database_name';
- $db_pass = ($_SERVER['HTTP_HOST'] == 'localhost' || $_SERVER['HTTP_HOST'] == $current_ip) ? '' : '';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement