WordPress.org

Plugin Directory

Changeset 533261


Ignore:
Timestamp:
04/19/12 05:20:44 (2 years ago)
Author:
josephscott
Message:

When re-checking comments look for alert messages from akismet.com.

When an alert is found schedule a re-check for 6 hours later to see if the
alert has been updated (possibly cleared).

Props tellyworth

File:
1 edited

Legend:

Unmodified
Added
Removed
  • akismet/trunk/akismet.php

    r533242 r533261  
    7171} 
    7272 
    73 function akismet_verify_key( $key, $ip = null ) { 
     73function akismet_check_key_status( $key, $ip = null ) { 
    7474    global $akismet_api_host, $akismet_api_port, $wpcom_api_key; 
    7575    $blog = urlencode( get_option('home') ); 
     
    7777        $key = $wpcom_api_key; 
    7878    $response = akismet_http_post("key=$key&blog=$blog", 'rest.akismet.com', '/1.1/verify-key', $akismet_api_port, $ip); 
     79    return $response; 
     80} 
     81 
     82function akismet_verify_key( $key, $ip = null ) { 
     83    $response = akismet_check_key_status( $key, $ip ); 
    7984    if ( !is_array($response) || !isset($response[1]) || $response[1] != 'valid' && $response[1] != 'invalid' ) 
    8085        return 'failed'; 
     
    483488    global $wpdb; 
    484489 
     490    // this should probably live in a function by itself 
     491    $status = akismet_check_key_status( akismet_get_key() ); 
     492    if ( isset($status[0]['x-akismet-alert-code']) ) { // or whatever header/s we decide on 
     493        update_option( 'akismet_alert_code', $status[0]['x-akismet-alert-code'] ); 
     494        update_option( 'akismet_alert_msg', $status[0]['x-akismet-alert-msg'] ); 
     495         
     496        // since there is currently a problem with the key, reschedule a check for 6 hours hence 
     497        wp_schedule_single_event( time() + 21600, 'akismet_schedule_cron_recheck' ); 
     498        return false; 
     499    } 
     500     
    485501    delete_option('akismet_available_servers'); 
    486502 
Note: See TracChangeset for help on using the changeset viewer.