Skip to content

HTTPS clone URL

Subversion checkout URL

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