Ticket #1683: 1683.diff
| File 1683.diff, 5.6 KB (added by , 21 years ago) |
|---|
-
wp-includes/functions-post.php
456 456 return false; 457 457 } 458 458 459 function wp_new_comment( $commentdata, $ spam = false ) {459 function wp_new_comment( $commentdata, $runchecks = true ) { 460 460 global $wpdb; 461 461 462 462 $commentdata = apply_filters('preprocess_comment', $commentdata); … … 485 485 $post_author = $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = '$comment_post_ID' LIMIT 1"); 486 486 } 487 487 488 // Simple duplicate check 489 $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND ( comment_author = '$author' "; 490 if ( $email ) $dupe .= "OR comment_author_email = '$email' "; 491 $dupe .= ") AND comment_content = '$comment' LIMIT 1"; 492 if ( $wpdb->get_var($dupe) ) 493 die( __('Duplicate comment detected; it looks as though you\'ve already said that!') ); 488 if ( $runchecks ) { 489 // Simple duplicate check 490 $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND ( comment_author = '$author' "; 491 if ( $email ) $dupe .= "OR comment_author_email = '$email' "; 492 $dupe .= ") AND comment_content = '$comment' LIMIT 1"; 493 if ( $wpdb->get_var($dupe) ) 494 die( __('Duplicate comment detected; it looks as though you\'ve already said that!') ); 494 495 495 // Simple flood-protection 496 if ( $lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = '$user_ip' OR comment_author_email = '$email' ORDER BY comment_date DESC LIMIT 1") ) { 497 $time_lastcomment = mysql2date('U', $lasttime); 498 $time_newcomment = mysql2date('U', $now_gmt); 499 if ( ($time_newcomment - $time_lastcomment) < 15 ) { 500 do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment); 501 die( __('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.') ); 496 // Simple flood-protection 497 if ( $lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = '$user_ip' OR comment_author_email = '$email' ORDER BY comment_date DESC LIMIT 1") ) { 498 $time_lastcomment = mysql2date('U', $lasttime); 499 $time_newcomment = mysql2date('U', $now_gmt); 500 if ( ($time_newcomment - $time_lastcomment) < 15 ) { 501 do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment); 502 die( __('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.') ); 503 } 502 504 } 503 }504 505 505 if ( $userdata && ( $user_id == $post_author || $user->has_cap('level_9') ) ) { 506 if ( $userdata && ( $user_id == $post_author || $user->has_cap('level_9') ) ) { 507 $approved = 1; 508 } else { 509 if ( check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) ) 510 $approved = 1; 511 else 512 $approved = 0; 513 if ( wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) ) 514 $approved = 'spam'; 515 } 516 517 $approved = apply_filters('pre_comment_approved', $approved); 518 } else { 519 // Importers can make $runchecks false to ensuring comment approval. 506 520 $approved = 1; 507 } else {508 if ( check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) )509 $approved = 1;510 else511 $approved = 0;512 if ( wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) )513 $approved = 'spam';514 521 } 515 522 516 $approved = apply_filters('pre_comment_approved', $approved);517 518 523 $result = $wpdb->query("INSERT INTO $wpdb->comments 519 524 (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, comment_type, user_id) 520 525 VALUES -
wp-admin/import/blogger.php
500 500 if ( $comment_post_ID == comment_exists($comment_author, $comment_date) ) { 501 501 $skippedcommentcount++; 502 502 } else { 503 $result = $wpdb->query(" 504 INSERT INTO $wpdb->comments 505 (comment_post_ID,comment_author,comment_author_url,comment_date,comment_content) 506 VALUES 507 ('$comment_post_ID','$comment_author','$comment_author_url','$comment_date','$comment_content') 508 "); 503 $commentdata = compact('comment_date', 'comment_author', 'comment_author_url', 'comment_content', 'comment_post_ID'); 504 wp_new_comment($commentdata, false); 509 505 } 510 506 $commentcount++; 511 507 } … … 582 578 if ( count($this->import['blogs']) > 1 ) 583 579 echo "<li>In case you haven't done it already, you can import the posts from any other blogs you may have:" . $this->show_blogs() . "</li>\n"; 584 580 if ( $n = count($this->import['blogs'][$_GET['blog']]['newusers']) ) 585 echo "<li>Since we had to create $n new user s, you probably want to go to <a href='users.php' target='_parent'>Authors & Users</a>, where you can give them new passwords or delete them. If you want to make all of the imported posts yours, you will be given that option when you delete the new authors.</li>\n";581 echo "<li>Since we had to create $n new user".($n > 1 ? 's' : '').", you probably want to go to <a href='users.php' target='_parent'>Authors & Users</a>, where you can give them new passwords or delete them. If you want to make all of the imported posts yours, you will be given that option when you delete the new authors.</li>\n"; 586 582 587 583 echo "\n<ul>"; 588 584 }