Make WordPress Core


Ignore:
Timestamp:
09/07/2004 02:34:12 AM (22 years ago)
Author:
saxmatt
Message:

Move trackbacks to new comment function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions-post.php

    r1604 r1616  
    344344}
    345345
     346function wp_new_comment($commentdata) {
     347        global $wpdb;
     348        extract($commentdata);
     349
     350        $comment_post_id = (int) $comment_post_id;
     351
     352        $comment_author = strip_tags($comment_author);
     353        $comment_author = htmlspecialchars($comment_author);
     354        $comment_author = $wpdb->escape($comment_author);
     355
     356        $comment_author_email = preg_replace('/[^a-z+_.@-]/i', '', $comment_author_email);
     357
     358        $comment_author_url = strip_tags($comment_author_url);
     359        $comment_author_url = htmlspecialchars($comment_author_url);
     360        $comment_author_url = $wpdb->escape($comment_author_url);
     361
     362        $comment_content = apply_filters('comment_content_presave', $comment_content);
     363        $comment_content = $wpdb->escape($comment_content);
     364
     365        $user_ip = addslashes($_SERVER['REMOTE_ADDR']);
     366        $user_domain = addslashes( gethostbyaddr($user_ip) );
     367        $now = current_time('mysql');
     368        $now_gmt = current_time('mysql', 1);
     369        $user_agent = addslashes($_SERVER['HTTP_USER_AGENT']);
     370
     371        // Simple flood-protection
     372        if ( $lasttime = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_author_IP = '$user_ip' ORDER BY comment_date DESC LIMIT 1") ) {
     373                $time_lastcomment= mysql2date('U', $lasttime);
     374                $time_newcomment= mysql2date('U', $now);
     375                if ( ($time_newcomment - $time_lastcomment) < 15 )
     376                        die( __('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.') );
     377        }
     378
     379        if( check_comment($author, $email, $url, $comment, $user_ip, $user_agent) )
     380                $approved = 1;
     381        else
     382                $approved = 0;
     383
     384        $result = $wpdb->query("INSERT INTO $wpdb->comments
     385        (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent)
     386        VALUES
     387        ('$comment_post_ID', '$author', '$email', '$tb_url', '$user_ip', '$now', '$now_gmt', '$comment', '$approved', '$user_agent')
     388        ");
     389
     390        if ( get_option('comments_notify') )
     391                wp_notify_postauthor($wpdb->insert_id, $comment_type);
     392
     393        return $result;
     394}
     395
    346396?>
Note: See TracChangeset for help on using the changeset viewer.