Skip to content

HTTPS clone URL

Subversion checkout URL

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