Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
function akismet_admin_warnings()
{
    global $wpcom_api_key;
    if (!get_option('wordpress_api_key') && !$wpcom_api_key && !isset($_POST['submit'])) {
        function akismet_warning()
        {
            echo "\n\t\t\t<div id='akismet-warning' class='updated fade'><p><strong>" . __('Akismet is almost ready.') . "</strong> " . sprintf(__('You must <a href="%1$s">enter your Akismet API key</a> for it to work.'), "plugins.php?page=akismet-key-config") . "</p></div>\n\t\t\t";
        }
        add_action('admin_notices', 'akismet_warning');
        return;
    } elseif (get_option('akismet_connectivity_time') && empty($_POST) && is_admin() && !akismet_server_connectivity_ok()) {
        function akismet_warning()
        {
            echo "\n\t\t\t<div id='akismet-warning' class='updated fade'><p><strong>" . __('Akismet has detected a problem.') . "</strong> " . sprintf(__('A server or network problem is preventing Akismet from working correctly.  <a href="%1$s">Click here for more information</a> about how to fix the problem.'), "plugins.php?page=akismet-key-config") . "</p></div>\n\t\t\t";
        }
        add_action('admin_notices', 'akismet_warning');
        return;
    }
}