akismet_get_server_connectivity

Definition:
function akismet_get_server_connectivity( $cache_timeout = 86400 ) {}

Parameters

  • $cache_timeout

Source code

function akismet_get_server_connectivity( $cache_timeout = 86400 ) {

	$servers = get_option('akismet_available_servers');

	if ( (time() - get_option('akismet_connectivity_time') < $cache_timeout) && $servers !== false )

		return $servers;

	

	// There's a race condition here but the effect is harmless.

	$servers = akismet_check_server_connectivity();

	update_option('akismet_available_servers', $servers);

	update_option('akismet_connectivity_time', time());

	return $servers;

}

453

akismet_get_key

Definition:
function akismet_get_key() {}

Source code

function akismet_get_key() {

	global $wpcom_api_key;

	if ( !empty($wpcom_api_key) )

		return $wpcom_api_key;

	return get_option('wordpress_api_key');

}

451

akismet_get_host

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

akismet_delete_old

Definition:
function akismet_delete_old() {}

Defined filters

  • akismet_optimize_table
    apply_filters('akismet_optimize_table', ($n == 11)

Defined actions

  • delete_comment
    do_action( 'delete_comment', $comment_ids );

Source code

function akismet_delete_old() {

	global $wpdb;

	$now_gmt = current_time('mysql', 1);

	$comment_ids = $wpdb->get_col("SELECT comment_id FROM $wpdb->comments WHERE DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'");

	if ( empty( $comment_ids ) )

		return;

		

	$comma_comment_ids = implode( ', ', array_map('intval', $comment_ids) );



	do_action( 'delete_comment', $comment_ids );

	$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_id IN ( $comma_comment_ids )");

	$wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id IN ( $comma_comment_ids )");

	clean_comment_cache( $comment_ids );

	$n = mt_rand(1, 5000);

	if ( apply_filters('akismet_optimize_table', ($n == 11)) ) // lucky number

		$wpdb->query("OPTIMIZE TABLE $wpdb->comments");



}

447

akismet_counter

Definition:
function akismet_counter() {}

Source code

function akismet_counter() {

	$plugin_dir = '/wp-content/plugins';

	if ( defined( 'PLUGINDIR' ) )

		$plugin_dir = '/' . PLUGINDIR;



?>

<style type="text/css">

#akismetwrap #aka,#aka:link,#aka:hover,#aka:visited,#aka:active{color:#fff;text-decoration:none}

#aka:hover{border:none;text-decoration:none}

#aka:hover #akismet1{display:none}

#aka:hover #akismet2,#akismet1{display:block}

#akismet2{display:none;padding-top:2px}

#akismeta{font-size:16px;font-weight:bold;line-height:18px;text-decoration:none}

#akismetcount{display:block;font:15px Verdana,Arial,Sans-Serif;font-weight:bold;text-decoration:none}

#akismetwrap #akismetstats{background:url(<?php echo get_option('siteurl'), $plugin_dir; ?>/akismet/akismet.gif) no-repeat top left;border:none;color:#fff;font:11px 'Trebuchet MS','Myriad Pro',sans-serif;height:40px;line-height:100%;overflow:hidden;padding:8px 0 0;text-align:center;width:120px}

</style>

<?php

$count = number_format_i18n(get_option('akismet_spam_count'));

?>

<div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><div id="akismet1"><span id="akismetcount"><?php echo $count; ?></span> <span id="akismetsc"><?php _e('spam comments') ?></span></div> <div id="akismet2"><span id="akismetbb"><?php _e('blocked by') ?></span><br /><span id="akismeta">Akismet</span></div></a></div></div>

<?php

}

445