Skip to content
Newer
Older
100644 92 lines (74 sloc) 2.74 KB
43e4a8a The great renaming.
saxmatt authored
1 <?php
75d9746 Trackback fix ups.
rboren authored
2
3 if ( !$doing_trackback) {
4 $doing_trackback = 1;
5 require('wp-blog-header.php');
6 }
7
b650b07 Move trackbacks to new comment function.
saxmatt authored
8 include_once (ABSPATH . WPINC . '/functions-post.php');
9
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';
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 }
10c6b7e Changed to superglobals, and eliminated $use_cache (since we always do).
saxmatt authored
33 $tb_url = $_POST['url'];
34 $title = $_POST['title'];
35 $excerpt = $_POST['excerpt'];
36 $blog_name = $_POST['blog_name'];
551e52f Code cleanup and some fixes from the WP Japan folks.
saxmatt authored
37 $charset = $_POST['charset'];
38
39 if ($charset)
40 $charset = strtoupper( trim($charset) );
41 else
42 $charset = 'auto';
43
44 if ( function_exists('mb_convert_encoding') ) {
45 $title = mb_convert_encoding($title, get_settings('blog_charset'), $charset);
46 $excerpt = mb_convert_encoding($excerpt, get_settings('blog_charset'), $charset);
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
b650b07 Move trackbacks to new comment function.
saxmatt authored
50 if ( is_single() )
6d55b31 Clean feed and trackback URLs.
rboren authored
51 $tb_id = $posts[0]->ID;
b650b07 Move trackbacks to new comment function.
saxmatt authored
52
53 if ( !$tb_id)
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...
58 header('Location: ' . 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
67 if ('closed' == $pingstatus)
68 trackback_response(1, 'Sorry, trackbacks are closed for this item.');
69
b650b07 Move trackbacks to new comment function.
saxmatt authored
70 $title = strip_tags( htmlspecialchars( $title ) );
71 $title = (strlen($title) > 250) ? substr($title, 0, 250) . '...' : $title;
43e4a8a The great renaming.
saxmatt authored
72 $excerpt = strip_tags($excerpt);
b650b07 Move trackbacks to new comment function.
saxmatt authored
73 $excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252) . '...' : $excerpt;
43e4a8a The great renaming.
saxmatt authored
74 $blog_name = htmlspecialchars($blog_name);
b650b07 Move trackbacks to new comment function.
saxmatt authored
75 $blog_name = (strlen($blog_name) > 250) ? substr($blog_name, 0, 250) . '...' : $blog_name;
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
00d3d3f fixes for bug #311, by bronski
michelvaldrighi authored
84 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
43e4a8a The great renaming.
saxmatt authored
85
b650b07 Move trackbacks to new comment function.
saxmatt authored
86 wp_new_comment($commentdata);
43e4a8a The great renaming.
saxmatt authored
87
b650b07 Move trackbacks to new comment function.
saxmatt authored
88 trackback_response(0);
89 do_action('trackback_post', $wpdb->insert_id);
43e4a8a The great renaming.
saxmatt authored
90
91 }
92 ?>
Something went wrong with that request. Please try again.