Definition:
function akismet_get_host($host) {}
Parameters
- $host
Source code
function akismet_get_host($host) { // if all servers are accessible, just return the host name. // if not, return an IP that was known to be accessible at the last check. if ( akismet_server_connectivity_ok() ) { return $host; } else { $ips = akismet_get_server_connectivity(); // a firewall may be blocking access to some Akismet IPs if ( count($ips) > 0 && count(array_filter($ips)) < count($ips) ) { // use DNS to get current IPs, but exclude any known to be unreachable $dns = (array)gethostbynamel( rtrim($host, '.') . '.' ); $dns = array_filter($dns); foreach ( $dns as $ip ) { if ( array_key_exists( $ip, $ips ) && empty( $ips[$ip] ) ) unset($dns[$ip]); } // return a random IP from those available if ( count($dns) ) return $dns[ array_rand($dns) ]; } } // if all else fails try the host name return $host; }
449
No comments yet... Be the first to leave a reply!