diff --git a/b2-include/b2functions.php b/b2-include/b2functions.php index cdf446e913..fd568de5fc 100644 --- a/b2-include/b2functions.php +++ b/b2-include/b2functions.php @@ -1453,13 +1453,7 @@ function wp_get_comment_status($comment_id) { } } - -/* wp_notify_postauthor - notifies the author of a post about a new comment - needs the id of the new comment - always returns true - */ -function wp_notify_postauthor($comment_id) { +function wp_notify_postauthor($comment_id, $comment_type) { global $wpdb, $tablecomments, $tableposts, $tableusers; global $querystring_start, $querystring_equal, $querystring_separator; global $blogfilename, $blogname, $siteurl; @@ -1468,29 +1462,46 @@ function wp_notify_postauthor($comment_id) { $post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID='$comment->comment_post_ID' LIMIT 1"); $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID='$post->post_author' LIMIT 1"); - if ("" != $user->user_email) { + if ('' == $user->user_email) return false; // If there's no email to send the comment to + $comment_author_domain = gethostbyaddr($comment->comment_author_IP); - $notify_message = "New comment on your post #$comment->comment_post_ID \"".stripslashes($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 .= "URL : $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".stripslashes($comment->comment_content)."\r\n\r\n"; - $notify_message .= "You can see all comments on this post here: \r\n"; - $notify_message .= $siteurl.'/'.$blogfilename.'?p='.$comment_post_ID.'&c=1#comments'; - - $subject = '[' . stripslashes($blogname) . '] Comment: "' .stripslashes($post->post_title).'"'; - if ('' != $comment->comment_author_email) { - $from = "From: \"$comment->comment_author\" <$comment->comment_author_email>"; - } else { - $from = 'From: "' . stripslashes($comment->comment_author) . "\" <$user->user_email>"; + $blogname = stripslashes($blogname); + + if ('comment' == $comment_type) { + $notify_message = "New comment on your post #$comment->comment_post_ID \"".stripslashes($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".stripslashes($comment->comment_content)."\r\n\r\n"; + $notify_message .= "You can see all comments on this post here: \r\n"; + $subject = '[' . $blogname . '] Comment: "' .stripslashes($post->post_title).'"'; + } elseif ('trackback' == $comment_type) { + $notify_message = "New trackback on your post #$comment_post_ID \"".stripslashes($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".stripslashes($comment->comment_content)."\r\n\r\n"; + $notify_message .= "You can see all trackbacks on this post here: \r\n"; + $subject = '[' . $blogname . '] Trackback: "' .stripslashes($post->post_title).'"'; + } elseif ('pingback' == $comment_type) { + $notify_message = "New pingback on your post #$comment_post_ID \"".stripslashes($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[...] $original_context [...]\r\n\r\n"; + $notify_message .= "You can see all pingbacks on this post here: \r\n"; + $subject = '[' . $blogname . '] Pingback: "' .stripslashes($post->post_title).'"'; + } + $notify_message .= get_permalink() . '#comments'; + + if ('' == $comment->comment_author_email || '' == $comment->comment_author) { + $from = "From: \"$blogname\" '; + } else { + $from = 'From: "' . stripslashes($comment->comment_author) . "\" <$comment->comment_author_email>"; } - $from .= "\nX-Mailer: WordPress $b2_version with PHP/" . phpversion(); @mail($user->user_email, $subject, $notify_message, $from); - } - + return true; } @@ -1525,7 +1536,6 @@ function wp_notify_moderator($comment_id) { $subject = '[' . stripslashes($blogname) . '] Please approve: "' .stripslashes($post->post_title).'"'; $admin_email = get_settings("admin_email"); $from = "From: $admin_email"; - $from .= "\nX-Mailer: WordPress $b2_version with PHP/" . phpversion(); @mail($admin_email, $subject, $notify_message, $from); diff --git a/b2comments.post.php b/b2comments.post.php index a0815e77ed..e7881e0e8c 100644 --- a/b2comments.post.php +++ b/b2comments.post.php @@ -93,28 +93,22 @@ if ($ok) { // if there was no comment from this IP in the last 10 seconds } else { // none $approved = 1; } - $wpdb->query("INSERT INTO $tablecomments (comment_ID,comment_post_ID,comment_author,comment_author_email,comment_author_url,comment_author_IP,comment_date,comment_content,comment_karma,comment_approved) VALUES ('0', '$comment_post_ID', '$author', '$email', '$url', '$user_ip', '$now', '$comment', '0', '$approved')"); + $wpdb->query("INSERT INTO $tablecomments + (comment_ID, comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved) + VALUES + ('0', '$comment_post_ID', '$author', '$email', '$url', '$user_ip', '$now', '$comment', '$approved') + "); -/* $comment_ID = $wpdb->get_var('SELECT last_insert_id()'); - $fp = fopen("/tmp/wpdebug.txt", "w+"); - fwrite($fp, "comment_moderation: $comment_moderation\n"); - fwrite($fp, "moderation_notify : $moderation_notify\n"); - if (($moderation_notify) && (!$approved)) { wp_notify_moderator($comment_ID); - fwrite($fp, "notify moderator -> $comment_ID\n"); } if (($comment_notify) && ($approved)) { - wp_notify_postauthor($comment_ID); - fwrite($fp, "notify postauthor -> $comment_ID\n"); + wp_notify_postauthor($comment_ID, 'comment'); } - - fclose($fp); -*/ if ($email == '') $email = ' '; // this to make sure a cookie is set for 'no email' diff --git a/b2trackback.php b/b2trackback.php index 4fbf595dab..18b8829198 100644 --- a/b2trackback.php +++ b/b2trackback.php @@ -1,6 +1,4 @@ -get_var("SELECT ping_status FROM $tableposts WHERE ID = $tb_id"); if ('closed' == $pingstatus) - die('Sorry, trackbacks are closed for this item.'); + trackback_response(1, 'Sorry, trackbacks are closed for this item.'); $tb_url = addslashes($tb_url); $title = strip_tags($title); @@ -47,7 +44,7 @@ if ((strlen(''.$tb_id)) && (empty($HTTP_GET_VARS['__mode'])) && (strlen(''.$tb_u $blog_name = (strlen($blog_name) > 255) ? substr($blog_name, 0, 252).'...' : $blog_name; $comment = ''; - $comment .= "$title
$excerpt"; + $comment .= "$title\n$excerpt"; $author = addslashes($blog_name); $email = ''; @@ -57,7 +54,7 @@ if ((strlen(''.$tb_id)) && (empty($HTTP_GET_VARS['__mode'])) && (strlen(''.$tb_u $user_ip = $HTTP_SERVER_VARS['REMOTE_ADDR']; $user_domain = gethostbyaddr($user_ip); $time_difference = get_settings('time_difference'); - $now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600))); + $now = current_time('mysql'); $comment = convert_chars($comment); $comment = format_to_post($comment); @@ -68,30 +65,30 @@ if ((strlen(''.$tb_id)) && (empty($HTTP_GET_VARS['__mode'])) && (strlen(''.$tb_u $author = addslashes($author); - $result = $wpdb->query("INSERT INTO $tablecomments VALUES ('0', '$comment_post_ID', '$author', '$email', '$tb_url', '$user_ip', '$now', '$comment', '0')"); + $comment_moderation = get_settings('comment_moderation'); + $moderation_notify = get_settings('moderation_notify'); + + if ('manual' == $comment_moderation) { + $approved = 0; + } else if ('auto' == $comment_moderation) { + $approved = 0; + } else { // none + $approved = 1; + } + + $result = $wpdb->query("INSERT INTO $tablecomments + (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved) + VALUES + ('$comment_post_ID', '$author', '$email', '$tb_url', '$user_ip', '$now', '$comment', '$approved') + "); + if (!$result) { - die ("There is an error with the database, it can't store your comment...
Contact the webmaster"); + die ("There is an error with the database, it can't store your comment...
Please contact the webmaster."); } else { - $postdata = get_postdata($comment_post_ID); - $authordata = get_userdata($postdata["Author_ID"]); - if ($comments_notify && '' != $authordata->user_email) { - - $notify_message = "New trackback on your post #$comment_post_ID \"".stripslashes($postdata['Title'])."\"\r\n\r\n"; - $notify_message .= "Website: $comment_author (IP: $user_ip , $user_domain)\r\n"; - $notify_message .= "URI : $comment_author_url\r\n"; - $notify_message .= "Excerpt: \n".stripslashes($original_comment)."\r\n\r\n"; - $notify_message .= "You can see all trackbacks on this post here: \r\n"; - $notify_message .= "$siteurl/$blogfilename?p=$comment_post_ID&c=1\r\n\r\n"; - - $subject = '[' . stripslashes($blogname) . '] Trackback: "' .stripslashes($postdata['Title']).'"'; - - $from = "From: wordpress@".$HTTP_SERVER_VARS['SERVER_NAME']; - $from .= "\r\nX-Mailer: WordPress $b2_version with PHP/" . phpversion(); - - @mail($authordata->user_email, $subject, $notify_message, $from); - } + $comment_ID = $wpdb->get_var('SELECT last_insert_id()'); + if ($comments_notify) + wp_notify_postauthor($comment_ID, 'trackback'); trackback_response(0); } } -} ?> \ No newline at end of file