New comment notification system.
git-svn-id: http://svn.automattic.com/wordpress/trunk@555 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
451de48541
commit
0a243e8bbf
|
@ -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,28 +1462,45 @@ 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';
|
||||
$blogname = stripslashes($blogname);
|
||||
|
||||
$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>";
|
||||
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\" <wordpress@" . $HTTP_SERVER_VARS['SERVER_NAME'] . '>';
|
||||
} 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);
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?php if (!empty($tb)) {
|
||||
|
||||
} else {
|
||||
<?php
|
||||
|
||||
if (!empty($HTTP_GET_VARS['tb_id'])) {
|
||||
// trackback is done by a GET
|
||||
|
@ -24,19 +22,18 @@ if ((strlen(''.$tb_id)) && (empty($HTTP_GET_VARS['__mode'])) && (strlen(''.$tb_u
|
|||
|
||||
@header('Content-Type: text/xml');
|
||||
|
||||
|
||||
require_once('wp-config.php');
|
||||
require_once($abspath.$b2inc.'/b2template.functions.php');
|
||||
require_once($abspath.$b2inc.'/b2vars.php');
|
||||
require_once($abspath.$b2inc.'/b2functions.php');
|
||||
|
||||
if (!$use_trackback) {
|
||||
if (!$use_trackback)
|
||||
trackback_response(1, 'Sorry, this weblog does not allow you to trackback its posts.');
|
||||
}
|
||||
|
||||
$pingstatus = $wpdb->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 = '<trackback />';
|
||||
$comment .= "<strong>$title</strong><br />$excerpt";
|
||||
$comment .= "<strong>$title</strong>\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...<br />Contact the <a href=\"mailto:$admin_email\">webmaster</a>");
|
||||
die ("There is an error with the database, it can't store your comment...<br />Please contact the <a href='mailto:$admin_email'>webmaster</a>.");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue