Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 95 lines (75 sloc) 2.977 kB
43e4a8a The great renaming.
saxmatt authored
1 <?php
65bbec7 Comments refactoring and cleanup
saxmatt authored
2 require_once( dirname(__FILE__) . '/wp-config.php' );
75d9746 Trackback fix ups.
rboren authored
3
65bbec7 Comments refactoring and cleanup
saxmatt authored
4 if ( empty($doing_trackback) ) {
5 $doing_trackback = true;
6 require_once('wp-blog-header.php');
75d9746 Trackback fix ups.
rboren authored
7 }
8
b650b07 Move trackbacks to new comment function.
saxmatt authored
9 function trackback_response($error = 0, $error_message = '') {
10 header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
11 if ($error) {
12 echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
13 echo "<response>\n";
14 echo "<error>1</error>\n";
15 echo "<message>$error_message</message>\n";
16 echo "</response>";
ee856b3 moved die() command, fixes bug #309
michelvaldrighi authored
17 die();
b650b07 Move trackbacks to new comment function.
saxmatt authored
18 } else {
19 echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
20 echo "<response>\n";
21 echo "<error>0</error>\n";
22 echo "</response>";
23 }
24 }
08709cf Non-trackback requests to wp-trackback.php now redirect to the post.
saxmatt authored
25
26 // trackback is done by a POST
27 $request_array = 'HTTP_POST_VARS';
65bbec7 Comments refactoring and cleanup
saxmatt authored
28
b650b07 Move trackbacks to new comment function.
saxmatt authored
29 if (!$tb_id) {
30 $tb_id = explode('/', $_SERVER['REQUEST_URI']);
31 $tb_id = intval($tb_id[count($tb_id)-1]);
32 }
65bbec7 Comments refactoring and cleanup
saxmatt authored
33
34 $tb_url = $_POST['url'];
35 $title = $_POST['title'];
36 $excerpt = $_POST['excerpt'];
10c6b7e Changed to superglobals, and eliminated $use_cache (since we always do).
saxmatt authored
37 $blog_name = $_POST['blog_name'];
65bbec7 Comments refactoring and cleanup
saxmatt authored
38 $charset = $_POST['charset'];
551e52f Code cleanup and some fixes from the WP Japan folks.
saxmatt authored
39
40 if ($charset)
41 $charset = strtoupper( trim($charset) );
42 else
43 $charset = 'auto';
44
65bbec7 Comments refactoring and cleanup
saxmatt authored
45 if ( function_exists('mb_convert_encoding') ) { // For international trackbacks
46 $title = mb_convert_encoding($title, get_settings('blog_charset'), $charset);
47 $excerpt = mb_convert_encoding($excerpt, get_settings('blog_charset'), $charset);
551e52f Code cleanup and some fixes from the WP Japan folks.
saxmatt authored
48 $blog_name = mb_convert_encoding($blog_name, get_settings('blog_charset'), $charset);
49 }
08709cf Non-trackback requests to wp-trackback.php now redirect to the post.
saxmatt authored
50
b650b07 Move trackbacks to new comment function.
saxmatt authored
51 if ( is_single() )
6d55b31 Clean feed and trackback URLs.
rboren authored
52 $tb_id = $posts[0]->ID;
b650b07 Move trackbacks to new comment function.
saxmatt authored
53
65bbec7 Comments refactoring and cleanup
saxmatt authored
54 if ( !$tb_id )
b650b07 Move trackbacks to new comment function.
saxmatt authored
55 trackback_response(1, 'I really need an ID for this to work.');
08709cf Non-trackback requests to wp-trackback.php now redirect to the post.
saxmatt authored
56
57 if (empty($title) && empty($tb_url) && empty($blog_name)) {
58 // If it doesn't look like a trackback at all...
59 header('Location: ' . get_permalink($tb_id));
b650b07 Move trackbacks to new comment function.
saxmatt authored
60 exit;
43e4a8a The great renaming.
saxmatt authored
61 }
62
b650b07 Move trackbacks to new comment function.
saxmatt authored
63 if ( !empty($tb_url) && !empty($title) && !empty($tb_url) ) {
64 header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
43e4a8a The great renaming.
saxmatt authored
65
25ae03e Giant commit, sorry mailing list people. Move all table names to new …
saxmatt authored
66 $pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id");
43e4a8a The great renaming.
saxmatt authored
67
65bbec7 Comments refactoring and cleanup
saxmatt authored
68 if ('open' != $pingstatus)
43e4a8a The great renaming.
saxmatt authored
69 trackback_response(1, 'Sorry, trackbacks are closed for this item.');
70
c3e1d51 Axing htmlspecialchars because it double-encodes-encodes. Better erro…
saxmatt authored
71 $title = wp_specialchars( strip_tags( $title ) );
b650b07 Move trackbacks to new comment function.
saxmatt authored
72 $title = (strlen($title) > 250) ? substr($title, 0, 250) . '...' : $title;
43e4a8a The great renaming.
saxmatt authored
73 $excerpt = strip_tags($excerpt);
b650b07 Move trackbacks to new comment function.
saxmatt authored
74 $excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252) . '...' : $excerpt;
43e4a8a The great renaming.
saxmatt authored
75
00d3d3f fixes for bug #311, by bronski
michelvaldrighi authored
76 $comment_post_ID = $tb_id;
77 $comment_author = $blog_name;
b650b07 Move trackbacks to new comment function.
saxmatt authored
78 $comment_author_email = '';
43e4a8a The great renaming.
saxmatt authored
79 $comment_author_url = $tb_url;
b650b07 Move trackbacks to new comment function.
saxmatt authored
80 $comment_content = "<strong>$title</strong>\n\n$excerpt";
81 $comment_type = 'trackback';
43e4a8a The great renaming.
saxmatt authored
82
3c34012 Don't accept duplicate pings
saxmatt authored
83 $dupe = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_author_url = '$comment_author_url'");
84 if ( $dupe )
85 trackback_response(1, 'We already have a ping from that URI for this post.');
86
00d3d3f fixes for bug #311, by bronski
michelvaldrighi authored
87 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
43e4a8a The great renaming.
saxmatt authored
88
b650b07 Move trackbacks to new comment function.
saxmatt authored
89 wp_new_comment($commentdata);
43e4a8a The great renaming.
saxmatt authored
90
b650b07 Move trackbacks to new comment function.
saxmatt authored
91 trackback_response(0);
92 do_action('trackback_post', $wpdb->insert_id);
43e4a8a The great renaming.
saxmatt authored
93
94 }
95 ?>
Something went wrong with that request. Please try again.