2003-12-11 01:22:36 +01:00
|
|
|
<?php
|
|
|
|
require(dirname(__FILE__) . '/wp-config.php');
|
2003-12-22 04:10:54 +01:00
|
|
|
|
|
|
|
// trackback is done by a POST
|
|
|
|
$request_array = 'HTTP_POST_VARS';
|
2004-04-21 00:56:47 +02:00
|
|
|
$tb_id = explode('/', $_SERVER['REQUEST_URI']);
|
2003-12-22 04:10:54 +01:00
|
|
|
$tb_id = intval($tb_id[count($tb_id)-1]);
|
2004-04-21 00:56:47 +02:00
|
|
|
$tb_url = $_POST['url'];
|
|
|
|
$title = $_POST['title'];
|
|
|
|
$excerpt = $_POST['excerpt'];
|
|
|
|
$blog_name = $_POST['blog_name'];
|
2003-12-22 04:10:54 +01:00
|
|
|
|
2004-06-01 01:35:32 +02:00
|
|
|
if (! $doing_trackback) {
|
|
|
|
$doing_trackback = 1;
|
|
|
|
require('wp-blog-header.php');
|
|
|
|
}
|
2004-02-05 21:55:50 +01:00
|
|
|
|
2004-07-28 04:43:54 +02:00
|
|
|
if (is_single()) {
|
2004-02-05 21:55:50 +01:00
|
|
|
$tb_id = $posts[0]->ID;
|
|
|
|
}
|
2003-12-22 04:10:54 +01:00
|
|
|
|
|
|
|
if (empty($title) && empty($tb_url) && empty($blog_name)) {
|
|
|
|
// If it doesn't look like a trackback at all...
|
|
|
|
header('Location: ' . get_permalink($tb_id));
|
2003-12-11 01:22:36 +01:00
|
|
|
}
|
|
|
|
|
2004-04-21 00:56:47 +02:00
|
|
|
if ((strlen(''.$tb_id)) && (empty($_GET['__mode'])) && (strlen(''.$tb_url))) {
|
2003-12-11 01:22:36 +01:00
|
|
|
|
2004-08-30 09:16:40 +02:00
|
|
|
@header('Content-Type: text/xml; charset=' . get_settings('blog_charset'));
|
2003-12-11 01:22:36 +01:00
|
|
|
|
2004-05-24 10:22:18 +02:00
|
|
|
$pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id");
|
2003-12-11 01:22:36 +01:00
|
|
|
|
|
|
|
if ('closed' == $pingstatus)
|
|
|
|
trackback_response(1, 'Sorry, trackbacks are closed for this item.');
|
|
|
|
|
|
|
|
$tb_url = addslashes($tb_url);
|
|
|
|
$title = strip_tags($title);
|
|
|
|
$title = (strlen($title) > 255) ? substr($title, 0, 252).'...' : $title;
|
|
|
|
$excerpt = strip_tags($excerpt);
|
|
|
|
$excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252).'...' : $excerpt;
|
|
|
|
$blog_name = htmlspecialchars($blog_name);
|
|
|
|
$blog_name = (strlen($blog_name) > 255) ? substr($blog_name, 0, 252).'...' : $blog_name;
|
|
|
|
|
|
|
|
$comment = '<trackback />';
|
|
|
|
$comment .= "<strong>$title</strong>\n$excerpt";
|
|
|
|
|
2003-12-22 03:46:40 +01:00
|
|
|
$author = addslashes(stripslashes(stripslashes($blog_name)));
|
2003-12-11 01:22:36 +01:00
|
|
|
$email = '';
|
|
|
|
$original_comment = $comment;
|
|
|
|
$comment_post_ID = $tb_id;
|
|
|
|
|
2004-04-21 00:56:47 +02:00
|
|
|
$user_ip = $_SERVER['REMOTE_ADDR'];
|
2003-12-11 01:22:36 +01:00
|
|
|
$user_domain = gethostbyaddr($user_ip);
|
2004-03-25 03:39:16 +01:00
|
|
|
$now = current_time('mysql');
|
|
|
|
$now_gmt = current_time('mysql', 1);
|
2003-12-11 01:22:36 +01:00
|
|
|
|
2004-09-05 03:50:39 +02:00
|
|
|
$user_agent = addslashes($_SERVER['HTTP_USER_AGENT']);
|
|
|
|
|
2003-12-11 01:22:36 +01:00
|
|
|
$comment = convert_chars($comment);
|
|
|
|
$comment = format_to_post($comment);
|
|
|
|
|
|
|
|
$comment_author = $author;
|
|
|
|
$comment_author_email = $email;
|
|
|
|
$comment_author_url = $tb_url;
|
|
|
|
|
|
|
|
$author = addslashes($author);
|
|
|
|
|
|
|
|
$comment_moderation = get_settings('comment_moderation');
|
|
|
|
$moderation_notify = get_settings('moderation_notify');
|
|
|
|
|
2004-09-05 03:50:39 +02:00
|
|
|
if(check_comment($author, $email, $url, $comment, $user_ip, $user_agent)) {
|
2003-12-11 01:22:36 +01:00
|
|
|
$approved = 1;
|
2004-03-21 09:31:33 +01:00
|
|
|
} else {
|
|
|
|
$approved = 0;
|
2003-12-11 01:22:36 +01:00
|
|
|
}
|
|
|
|
|
2004-05-24 10:22:18 +02:00
|
|
|
$result = $wpdb->query("INSERT INTO $wpdb->comments
|
2004-09-05 03:50:39 +02:00
|
|
|
(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)
|
2003-12-11 01:22:36 +01:00
|
|
|
VALUES
|
2004-09-05 03:50:39 +02:00
|
|
|
('$comment_post_ID', '$author', '$email', '$tb_url', '$user_ip', '$now', '$now_gmt', '$comment', '$approved', '$user_agent')
|
2003-12-11 01:22:36 +01:00
|
|
|
");
|
|
|
|
|
|
|
|
if (!$result) {
|
2004-03-01 20:55:45 +01:00
|
|
|
die ("There is an error with the database, it can't store your comment...<br />Please contact the webmaster.");
|
2003-12-11 01:22:36 +01:00
|
|
|
} else {
|
|
|
|
$comment_ID = $wpdb->get_var('SELECT last_insert_id()');
|
2004-03-01 07:13:32 +01:00
|
|
|
if (get_settings('comments_notify'))
|
2003-12-11 01:22:36 +01:00
|
|
|
wp_notify_postauthor($comment_ID, 'trackback');
|
|
|
|
trackback_response(0);
|
2004-03-25 21:18:20 +01:00
|
|
|
do_action('trackback_post', $comment_ID);
|
2003-12-11 01:22:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|