<?
/* this function is in your wp-includes/comment-functions.php */
/* THIS IS FOR WP v1.5 */
/* BACK UP BEFORE OVERWRITING ANYTHING */
/* this function will send emails to the author of a comment if
/* someone replies to him/her. replies to your own comment will not count
/* if you use dodo's threaded comments hack with javascript, you may replace the
   wp_notify_postauthor function with the code below.
   */
if ( ! function_exists('wp_notify_postauthor') ) {
function 
wp_notify_postauthor($comment_id$comment_type='') {
    global 
$wpdb;
    
    
$comment $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
    
$post $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1");
    
$user $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID='$post->post_author' LIMIT 1");

    if (
'' == $user->user_email) return false// If there's no email to send the comment to

    
if($user->user_email == $comment->comment_author_email) return false// do not notify the author of his/her own comments

    
$send_to_email $user->user_email;

    
$comment_author_domain gethostbyaddr($comment->comment_author_IP);

    
$blogname get_settings('blogname');

    
    
$comment_reply_ID $comment->comment_reply_ID;
    
    if ( empty( 
$comment_type ) ) $comment_type 'comment';
    
    if (
'comment' == $comment_type) {
        if(
$comment_reply_ID != '0') { wp_notify_postauthor($comment_id'reply'); return; }



        
$notify_message  "New comment on your post #$comment->comment_post_ID \"".$post->post_title."\"\r\n\r\n";
        
$notify_message .= "Author : $comment->comment_author (IP: $comment->comment_author_IP , $comment_author_domain)\r\n";
        
$notify_message .= "E-mail : $comment->comment_author_email\r\n";
        
$notify_message .= "URI    : $comment->comment_author_url\r\n";
        
$notify_message .= "Whois  : http://ws.arin.net/cgi-bin/whois.pl?queryinput=$comment->comment_author_IP\r\n";
        
$notify_message .= "Comment:\r\n $comment->comment_content \r\n\r\n";
        
$notify_message .= "You can see all comments on this post here: \r\n";
        
$subject '[' $blogname '] Comment: "' .$post->post_title.'"';
    } elseif (
'trackback' == $comment_type) {
        
$notify_message  "New trackback on your post #$comment_post_ID \"".$post->post_title."\"\r\n\r\n";
        
$notify_message .= "Website: $comment->comment_author (IP: $comment->comment_author_IP , $comment_author_domain)\r\n";
        
$notify_message .= "URI    : $comment->comment_author_url\r\n";
        
$notify_message .= "Excerpt: \n $comment->comment_content \r\n\r\n";
        
$notify_message .= "You can see all trackbacks on this post here: \r\n";
        
$subject '[' $blogname '] Trackback: "' .$post->post_title.'"';
    } elseif (
'pingback' == $comment_type) {
        
$notify_message  "New pingback on your post #$comment_post_ID \"".$post->post_title."\"\r\n\r\n";
        
$notify_message .= "Website: $comment->comment_author\r\n";
        
$notify_message .= "URI    : $comment->comment_author_url\r\n";
        
$notify_message .= "Excerpt: \n[...] $comment->comment_content [...]\r\n\r\n";
        
$notify_message .= "You can see all pingbacks on this post here: \r\n";
        
$subject '[' $blogname '] Pingback: "' .$post->post_title.'"';
     } elseif (
'reply' == $comment_type) {
        
$post_comment_author_email $comment->comment_author_email;
        
        
$mail_addr $wpdb->get_var("SELECT comment_author_email FROM $wpdb->comments WHERE comment_ID = '$comment_reply_ID'");

        
        
$send_to_email $mail_addr;
        if(
'' == $mail_addr && $post_comment_author_email == $mail_addr) return false;


        
$notify_message "New reply to your comment #$comment->comment_reply_ID in post \"".stripslashes($post->post_title)."\"\n";
        
$notify_message .= "Author : $comment->comment_author\n";
        
$notify_message .= "Website: $comment->comment_author_url\n";
        
$notify_message .= "E-mail : $comment->comment_author_email\r\n";
        
$notify_message .= "Comment:\n".stripslashes($comment->comment_content)."\n\n";
        
$notify_message .= "You can see all comments on this post here: \n\n";
        
$subject '[' $blogname '] Comment: "' .stripslashes($post->post_title).'"';
    
    }
    
$notify_message .= get_permalink($comment->comment_post_ID) . '#comments';

    if(
'reply' != $comment_type) {
        
$notify_message .= "\r\n\r\nTo delete this comment:\r\n" get_settings('siteurl') . "/wp-admin/post.php?action=confirmdeletecomment&p=".$comment->comment_post_ID."&comment=$comment_id";
    }

    if (
'' == $comment->comment_author_email || '' == $comment->comment_author) {
        
$from "From: \"$blogname\" <wordpress@" $_SERVER['SERVER_NAME'] . '>';
    } else {
        
$from 'From: "' $comment->comment_author "\" <$comment->comment_author_email>";
    }

    
$message_headers "MIME-Version: 1.0\n"
        
"$from\n"
        
"Content-Type: text/plain; charset=\"" get_settings('blog_charset') . "\"\n";

    @
wp_mail($send_to_email$subject$notify_message$message_headers);
 
   
    return 
true;
}
}
/* end of function modified by dodo http://pure-essence.net */

?>