コード例 #1
0
ファイル: Ajax.php プロジェクト: adrianjonmiller/vadsupplies
 /**
  * Uses wp_ajax_(action).
  *
  * Get the blocked IP data.
  *
  * @since 2.0.0
  *
  * @link http://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_(action)
  */
 public function wp_ajax_get_blocked_ip()
 {
     global $wpdb;
     check_ajax_referer('zero-spam', 'security');
     $ajax_nonce = wp_create_nonce('zero-spam');
     $ip = $_REQUEST['ip'];
     $data = zerospam_get_blocked_ip($ip);
     if ($data) {
         $data->is_blocked = zerospam_is_blocked($ip);
         $data->start_date_txt = date('l, F j, Y', strtotime($data->start_date));
         $data->end_date_txt = date('l, F j, Y', strtotime($data->end_date));
         echo json_encode((array) $data);
     }
     die;
 }
コード例 #2
0
function zerospam_is_blocked($ip)
{
    global $wpdb;
    $table_name = $wpdb->prefix . 'zerospam_blocked_ips';
    $check = zerospam_get_blocked_ip($ip);
    $current = current_time('timestamp');
    if (empty($check)) {
        return false;
    }
    // Check block type
    if ('temporary' == $check->type && $current >= strtotime($check->start_date) && $current <= strtotime($check->end_date)) {
        return true;
    }
    if ('permanent' == $check->type) {
        return true;
    }
    return false;
}