Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 103 lines (83 sloc) 3.428 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)) {
5897a90 Consistently include wp-config.php. fixes #3349
markjaquith authored
4 require_once('./wp-config.php');
1baf503 Break blog header up into functional chunks. Stick it all in a WP cl…
ryan authored
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
b737139 Delay Trackback data escaping until after mb_convert_encoding(). Pro…
markjaquith authored
33 $tb_url = $_POST['url'];
34 $charset = $_POST['charset'];
35
36 // These three are stripslashed here so that they can be properly escaped after mb_convert_encoding()
37 $title = stripslashes($_POST['title']);
38 $excerpt = stripslashes($_POST['excerpt']);
39 $blog_name = stripslashes($_POST['blog_name']);
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
849a0d2 Use get_option instead of get_settings. Just 'cause.
ryan authored
47 $title = mb_convert_encoding($title, get_option('blog_charset'), $charset);
48 $excerpt = mb_convert_encoding($excerpt, get_option('blog_charset'), $charset);
49 $blog_name = mb_convert_encoding($blog_name, get_option('blog_charset'), $charset);
551e52f Code cleanup and some fixes from the WP Japan folks.
saxmatt authored
50 }
08709cf Non-trackback requests to wp-trackback.php now redirect to the post.
saxmatt authored
51
b737139 Delay Trackback data escaping until after mb_convert_encoding(). Pro…
markjaquith authored
52 // Now that mb_convert_encoding() has been given a swing, we need to escape these three
53 $title = $wpdb->escape($title);
54 $excerpt = $wpdb->escape($excerpt);
55 $blog_name = $wpdb->escape($blog_name);
56
9f534eb Remove trailing spaces and convert spaces to tabs. Props Nazgul. fix…
ryan authored
57 if ( is_single() || is_page() )
58 $tb_id = $posts[0]->ID;
b650b07 Move trackbacks to new comment function.
saxmatt authored
59
68b4b3c Line ending fixes and commenting cleanups from Scott Reilly
matt authored
60 if ( !intval( $tb_id ) )
b650b07 Move trackbacks to new comment function.
saxmatt authored
61 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
62
63 if (empty($title) && empty($tb_url) && empty($blog_name)) {
64 // If it doesn't look like a trackback at all...
ff19f4b Use wp_redirect().
ryan authored
65 wp_redirect(get_permalink($tb_id));
b650b07 Move trackbacks to new comment function.
saxmatt authored
66 exit;
43e4a8a The great renaming.
saxmatt authored
67 }
68
858ba5e Remove redundant check. Props Mittineague. fixes #3665
ryan authored
69 if ( !empty($tb_url) && !empty($title) ) {
b650b07 Move trackbacks to new comment function.
saxmatt authored
70 header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
43e4a8a The great renaming.
saxmatt authored
71
25788ba Add filters to comments_open() and pings_open(). Props tellyworth. …
ryan authored
72 if ( !pings_open($tb_id) )
43e4a8a The great renaming.
saxmatt authored
73 trackback_response(1, 'Sorry, trackbacks are closed for this item.');
74
c3e1d51 Axing htmlspecialchars because it double-encodes-encodes. Better erro…
saxmatt authored
75 $title = wp_specialchars( strip_tags( $title ) );
43e4a8a The great renaming.
saxmatt authored
76 $excerpt = strip_tags($excerpt);
b64e336 Use mb_strcut instead of mb_substr. fixes #2163
ryan authored
77 if ( function_exists('mb_strcut') ) { // For international trackbacks
849a0d2 Use get_option instead of get_settings. Just 'cause.
ryan authored
78 $excerpt = mb_strcut($excerpt, 0, 252, get_option('blog_charset')) . '...';
79 $title = mb_strcut($title, 0, 250, get_option('blog_charset')) . '...';
60006e4 Use mb_substr for trackback titles. Props zet. fixes #1474
ryan authored
80 } else {
f3c4d80 Cut international trackbacks, fixes #1647
matt authored
81 $excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252) . '...' : $excerpt;
60006e4 Use mb_substr for trackback titles. Props zet. fixes #1474
ryan authored
82 $title = (strlen($title) > 250) ? substr($title, 0, 250) . '...' : $title;
83 }
43e4a8a The great renaming.
saxmatt authored
84
7602d17 (int)er the dragon.
matt authored
85 $comment_post_ID = (int) $tb_id;
00d3d3f fixes for bug #311, by bronski
michelvaldrighi authored
86 $comment_author = $blog_name;
b650b07 Move trackbacks to new comment function.
saxmatt authored
87 $comment_author_email = '';
43e4a8a The great renaming.
saxmatt authored
88 $comment_author_url = $tb_url;
b650b07 Move trackbacks to new comment function.
saxmatt authored
89 $comment_content = "<strong>$title</strong>\n\n$excerpt";
90 $comment_type = 'trackback';
43e4a8a The great renaming.
saxmatt authored
91
3c34012 Don't accept duplicate pings
saxmatt authored
92 $dupe = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_author_url = '$comment_author_url'");
93 if ( $dupe )
efcb63a s/URI/URL/. Props Nazgul. fixes #2666
ryan authored
94 trackback_response(1, 'We already have a ping from that URL for this post.');
3c34012 Don't accept duplicate pings
saxmatt authored
95
00d3d3f fixes for bug #311, by bronski
michelvaldrighi authored
96 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
43e4a8a The great renaming.
saxmatt authored
97
b650b07 Move trackbacks to new comment function.
saxmatt authored
98 wp_new_comment($commentdata);
43e4a8a The great renaming.
saxmatt authored
99
b650b07 Move trackbacks to new comment function.
saxmatt authored
100 do_action('trackback_post', $wpdb->insert_id);
31066f3 Don't die before action
saxmatt authored
101 trackback_response(0);
43e4a8a The great renaming.
saxmatt authored
102 }
103 ?>
Something went wrong with that request. Please try again.