Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 105 lines (84 sloc) 3.518 kb
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
1 <?php
75d97463 » rboren
2004-09-18 Trackback fix ups.
2
1baf503d » ryan
2005-06-10 Break blog header up into functional chunks. Stick it all in a WP cla…
3 if (empty($wp)) {
4 require_once('wp-config.php');
5 wp('tb=1');
75d97463 » rboren
2004-09-18 Trackback fix ups.
6 }
7
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
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>";
ee856b34 » michelvaldrighi
2004-09-23 moved die() command, fixes bug #309
16 die();
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
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 }
08709cf1 » saxmatt
2003-12-22 Non-trackback requests to wp-trackback.php now redirect to the post.
24
25 // trackback is done by a POST
26 $request_array = 'HTTP_POST_VARS';
65bbec71 » saxmatt
2004-12-16 Comments refactoring and cleanup
27
68b4b3c6 » matt
2005-04-20 Line ending fixes and commenting cleanups from Scott Reilly
28 if ( !$_GET['tb_id'] ) {
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
29 $tb_id = explode('/', $_SERVER['REQUEST_URI']);
68b4b3c6 » matt
2005-04-20 Line ending fixes and commenting cleanups from Scott Reilly
30 $tb_id = intval( $tb_id[ count($tb_id) - 1 ] );
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
31 }
65bbec71 » saxmatt
2004-12-16 Comments refactoring and cleanup
32
b7371396 » markjaquith
2007-01-05 Delay Trackback data escaping until after mb_convert_encoding(). Prop…
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']);
551e52ff » saxmatt
2004-10-04 Code cleanup and some fixes from the WP Japan folks.
40
41 if ($charset)
42 $charset = strtoupper( trim($charset) );
43 else
d877c399 » matt
2005-04-20 Better charset audo-detection - http://mosquito.wordpress.org/view.ph…
44 $charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
551e52ff » saxmatt
2004-10-04 Code cleanup and some fixes from the WP Japan folks.
45
65bbec71 » saxmatt
2004-12-16 Comments refactoring and cleanup
46 if ( function_exists('mb_convert_encoding') ) { // For international trackbacks
849a0d29 » ryan
2006-08-30 Use get_option instead of get_settings. Just 'cause.
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);
551e52ff » saxmatt
2004-10-04 Code cleanup and some fixes from the WP Japan folks.
50 }
08709cf1 » saxmatt
2003-12-22 Non-trackback requests to wp-trackback.php now redirect to the post.
51
b7371396 » markjaquith
2007-01-05 Delay Trackback data escaping until after mb_convert_encoding(). Prop…
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
9f534eba » ryan
2006-11-19 Remove trailing spaces and convert spaces to tabs. Props Nazgul. fixe…
57 if ( is_single() || is_page() )
58 $tb_id = $posts[0]->ID;
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
59
68b4b3c6 » matt
2005-04-20 Line ending fixes and commenting cleanups from Scott Reilly
60 if ( !intval( $tb_id ) )
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
61 trackback_response(1, 'I really need an ID for this to work.');
08709cf1 » saxmatt
2003-12-22 Non-trackback requests to wp-trackback.php now redirect to the post.
62
63 if (empty($title) && empty($tb_url) && empty($blog_name)) {
64 // If it doesn't look like a trackback at all...
ff19f4b5 » ryan
2006-06-27 Use wp_redirect().
65 wp_redirect(get_permalink($tb_id));
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
66 exit;
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
67 }
68
858ba5ea » ryan
2007-01-25 Remove redundant check. Props Mittineague. fixes #3665
69 if ( !empty($tb_url) && !empty($title) ) {
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
70 header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
71
25ae03ee » saxmatt
2004-05-24 Giant commit, sorry mailing list people. Move all table names to new …
72 $pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id");
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
73
68b4b3c6 » matt
2005-04-20 Line ending fixes and commenting cleanups from Scott Reilly
74 if ( 'open' != $pingstatus )
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
75 trackback_response(1, 'Sorry, trackbacks are closed for this item.');
76
c3e1d51c » saxmatt
2004-12-12 Axing htmlspecialchars because it double-encodes-encodes. Better erro…
77 $title = wp_specialchars( strip_tags( $title ) );
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
78 $excerpt = strip_tags($excerpt);
b64e3361 » ryan
2005-12-28 Use mb_strcut instead of mb_substr. fixes #2163
79 if ( function_exists('mb_strcut') ) { // For international trackbacks
849a0d29 » ryan
2006-08-30 Use get_option instead of get_settings. Just 'cause.
80 $excerpt = mb_strcut($excerpt, 0, 252, get_option('blog_charset')) . '...';
81 $title = mb_strcut($title, 0, 250, get_option('blog_charset')) . '...';
60006e43 » ryan
2005-11-16 Use mb_substr for trackback titles. Props zet. fixes #1474
82 } else {
f3c4d80b » matt
2005-11-14 Cut international trackbacks, fixes #1647
83 $excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252) . '...' : $excerpt;
60006e43 » ryan
2005-11-16 Use mb_substr for trackback titles. Props zet. fixes #1474
84 $title = (strlen($title) > 250) ? substr($title, 0, 250) . '...' : $title;
85 }
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
86
7602d178 » matt
2007-03-23 (int)er the dragon.
87 $comment_post_ID = (int) $tb_id;
00d3d3fe » michelvaldrighi
2004-09-22 fixes for bug #311, by bronski
88 $comment_author = $blog_name;
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
89 $comment_author_email = '';
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
90 $comment_author_url = $tb_url;
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
91 $comment_content = "<strong>$title</strong>\n\n$excerpt";
92 $comment_type = 'trackback';
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
93
3c34012a » saxmatt
2005-01-11 Don't accept duplicate pings
94 $dupe = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_author_url = '$comment_author_url'");
95 if ( $dupe )
efcb63ad » ryan
2006-08-30 s/URI/URL/. Props Nazgul. fixes #2666
96 trackback_response(1, 'We already have a ping from that URL for this post.');
3c34012a » saxmatt
2005-01-11 Don't accept duplicate pings
97
00d3d3fe » michelvaldrighi
2004-09-22 fixes for bug #311, by bronski
98 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
99
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
100 wp_new_comment($commentdata);
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
101
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
102 do_action('trackback_post', $wpdb->insert_id);
31066f32 » saxmatt
2005-02-12 Don't die before action
103 trackback_response(0);
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
104 }
105 ?>
Something went wrong with that request. Please try again.