Skip to:
Content

bbPress.org

Changeset 5654


Ignore:
Timestamp:
03/24/2015 06:45:01 AM (6 years ago)
Author:
netweb
Message:

Akismet: Pass additional user and post information to Aksimet helping identify suspicious new posts

  • comment_total: Total user posts via bbp_get_user_post_count()
  • comment_last_active_gmt: Topic last active time via bbp_get_topic_last_reply_id()
  • comment_account_registered_gmt: User registered via $userdata->user_registered

Props eoigal. Fixes #2591

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/extend/akismet.php

    r5559 r5654  
    116116        /** Author ************************************************************/
    117117
     118        $user_data['last_active'] = '';
     119        $user_data['registered']  = date( 'Y-m-d H:i:s');
     120        $user_data['total_posts'] = (int) bbp_get_user_post_count( $post_data['post_author'] );
     121
    118122        // Get user data
    119123        $userdata       = get_userdata( $post_data['post_author'] );
     
    121125
    122126        // Author is anonymous
    123         if ( !empty( $anonymous_data ) ) {
     127        if ( ! empty( $anonymous_data ) ) {
    124128            $user_data['name']    = $anonymous_data['bbp_anonymous_name'];
    125129            $user_data['email']   = $anonymous_data['bbp_anonymous_email'];
     
    127131
    128132        // Author is logged in
    129         } elseif ( !empty( $userdata ) ) {
    130             $user_data['name']    = $userdata->display_name;
    131             $user_data['email']   = $userdata->user_email;
    132             $user_data['website'] = $userdata->user_url;
     133        } elseif ( ! empty( $userdata ) ) {
     134            $user_data['name']       = $userdata->display_name;
     135            $user_data['email']      = $userdata->user_email;
     136            $user_data['website']    = $userdata->user_url;
     137            $user_data['registered'] = $userdata->user_registered;
    133138
    134139        // Missing author data, so set some empty strings
     
    141146        /** Post **************************************************************/
    142147
    143         // Use post parent for permalink
    144         if ( !empty( $post_data['post_parent'] ) ) {
     148        if ( ! empty( $post_data['post_parent'] ) ) {
     149            // Use post parent for permalink
    145150            $post_permalink = get_permalink( $post_data['post_parent'] );
     151
     152            // Use post parent to get datetime of last reply on this topic
     153            if ( $reply_id = bbp_get_topic_last_reply_id( $post_data['post_parent'] ) ) {
     154                $user_data['last_active'] = get_post_field( 'post_date', $reply_id );
     155            }
    146156        }
    147157
    148158        // Put post_data back into usable array
    149159        $_post = array(
    150             'comment_author'       => $user_data['name'],
    151             'comment_author_email' => $user_data['email'],
    152             'comment_author_url'   => $user_data['website'],
    153             'comment_content'      => $post_data['post_content'],
    154             'comment_post_ID'      => $post_data['post_parent'],
    155             'comment_type'         => $post_data['post_type'],
    156             'permalink'            => $post_permalink,
    157             'referrer'             => $_SERVER['HTTP_REFERER'],
    158             'user_agent'           => $_SERVER['HTTP_USER_AGENT'],
    159             'user_ID'              => $post_data['post_author'],
    160             'user_ip'              => bbp_current_author_ip(),
    161             'user_role'            => $this->get_user_roles( $post_data['post_author'] ),
     160            'comment_author'                 => $user_data['name'],
     161            'comment_author_email'           => $user_data['email'],
     162            'comment_author_url'             => $user_data['website'],
     163            'comment_content'                => $post_data['post_content'],
     164            'comment_post_ID'                => $post_data['post_parent'],
     165            'comment_type'                   => $post_data['post_type'],
     166            'comment_total'                  => $user_data['total_posts'],
     167            'comment_last_active_gmt'        => $user_data['last_active'],
     168            'comment_account_registered_gmt' => $user_data['registered'],
     169            'permalink'                      => $post_permalink,
     170            'referrer'                       => $_SERVER['HTTP_REFERER'],
     171            'user_agent'                     => $_SERVER['HTTP_USER_AGENT'],
     172            'user_ID'                        => $post_data['post_author'],
     173            'user_ip'                        => bbp_current_author_ip(),
     174            'user_role'                      => $this->get_user_roles( $post_data['post_author'] ),
    162175        );
    163176
Note: See TracChangeset for help on using the changeset viewer.