Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 111 lines (90 sloc) 3.702 kb
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
1 <?php
a6a1522a » ryan
2008-05-25 File file level phpdoc from jacobsantos. see #7037
2 /**
3 * Handle Trackbacks and Pingbacks sent to WordPress
4 *
5 * @package WordPress
6 */
75d97463 » rboren
2004-09-18 Trackback fix ups.
7
1baf503d » ryan
2005-06-10 Break blog header up into functional chunks. Stick it all in a WP cla…
8 if (empty($wp)) {
5b811357 » ryan
2008-05-21 Allow wp-config.php to exist one level up from WordPress root directo…
9 require_once('./wp-load.php');
f05ee184 » westi
2010-01-08 Switch to passing arrays instead of query strings to functions. Fixes…
10 wp( array( 'tb' => '1' ) );
75d97463 » rboren
2004-09-18 Trackback fix ups.
11 }
12
a6a1522a » ryan
2008-05-25 File file level phpdoc from jacobsantos. see #7037
13 /**
14 * trackback_response() - Respond with error or success XML message
15 *
8bcc5969 » nacin
2010-02-24 Spelling and grammar fun. Fixes #11875 props cnorris23
16 * @param int|bool $error Whether there was an error
a6a1522a » ryan
2008-05-25 File file level phpdoc from jacobsantos. see #7037
17 * @param string $error_message Error message if an error occurred
18 */
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
19 function trackback_response($error = 0, $error_message = '') {
20 header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
21 if ($error) {
22 echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
23 echo "<response>\n";
24 echo "<error>1</error>\n";
25 echo "<message>$error_message</message>\n";
26 echo "</response>";
ee856b34 » michelvaldrighi
2004-09-23 moved die() command, fixes bug #309
27 die();
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
28 } else {
29 echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
30 echo "<response>\n";
31 echo "<error>0</error>\n";
32 echo "</response>";
33 }
34 }
08709cf1 » saxmatt
2003-12-22 Non-trackback requests to wp-trackback.php now redirect to the post.
35
36 // trackback is done by a POST
37 $request_array = 'HTTP_POST_VARS';
65bbec71 » saxmatt
2004-12-16 Comments refactoring and cleanup
38
c3f7df6b » azaozz
2009-11-26 Fix notices and phpdoc, props hakre, fixes #10758
39 if ( !isset($_GET['tb_id']) || !$_GET['tb_id'] ) {
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
40 $tb_id = explode('/', $_SERVER['REQUEST_URI']);
68b4b3c6 » matt
2005-04-20 Line ending fixes and commenting cleanups from Scott Reilly
41 $tb_id = intval( $tb_id[ count($tb_id) - 1 ] );
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
42 }
65bbec71 » saxmatt
2004-12-16 Comments refactoring and cleanup
43
c3f7df6b » azaozz
2009-11-26 Fix notices and phpdoc, props hakre, fixes #10758
44 $tb_url = isset($_POST['url']) ? $_POST['url'] : '';
45 $charset = isset($_POST['charset']) ? $_POST['charset'] : '';
b7371396 » markjaquith
2007-01-05 Delay Trackback data escaping until after mb_convert_encoding(). Prop…
46
47 // These three are stripslashed here so that they can be properly escaped after mb_convert_encoding()
c3f7df6b » azaozz
2009-11-26 Fix notices and phpdoc, props hakre, fixes #10758
48 $title = isset($_POST['title']) ? stripslashes($_POST['title']) : '';
49 $excerpt = isset($_POST['excerpt']) ? stripslashes($_POST['excerpt']) : '';
50 $blog_name = isset($_POST['blog_name']) ? stripslashes($_POST['blog_name']) : '';
551e52ff » saxmatt
2004-10-04 Code cleanup and some fixes from the WP Japan folks.
51
52 if ($charset)
144618f7 » ryan
2009-10-14 Strip commas and spaces from charset. Props Jose Carlos Norte
53 $charset = str_replace( array(',', ' '), '', strtoupper( trim($charset) ) );
551e52ff » saxmatt
2004-10-04 Code cleanup and some fixes from the WP Japan folks.
54 else
d877c399 » matt
2005-04-20 Better charset audo-detection - http://mosquito.wordpress.org/view.ph…
55 $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.
56
121fca16 » ryan
2008-03-28 Drop trackbacks that request UTF-7
57 // No valid uses for UTF-7
58 if ( false !== strpos($charset, 'UTF-7') )
59 die;
60
65bbec71 » saxmatt
2004-12-16 Comments refactoring and cleanup
61 if ( function_exists('mb_convert_encoding') ) { // For international trackbacks
849a0d29 » ryan
2006-08-30 Use get_option instead of get_settings. Just 'cause.
62 $title = mb_convert_encoding($title, get_option('blog_charset'), $charset);
63 $excerpt = mb_convert_encoding($excerpt, get_option('blog_charset'), $charset);
64 $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.
65 }
08709cf1 » saxmatt
2003-12-22 Non-trackback requests to wp-trackback.php now redirect to the post.
66
b7371396 » markjaquith
2007-01-05 Delay Trackback data escaping until after mb_convert_encoding(). Prop…
67 // Now that mb_convert_encoding() has been given a swing, we need to escape these three
68 $title = $wpdb->escape($title);
69 $excerpt = $wpdb->escape($excerpt);
70 $blog_name = $wpdb->escape($blog_name);
71
9f534eba » ryan
2006-11-19 Remove trailing spaces and convert spaces to tabs. Props Nazgul. fixe…
72 if ( is_single() || is_page() )
73 $tb_id = $posts[0]->ID;
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
74
c3f7df6b » azaozz
2009-11-26 Fix notices and phpdoc, props hakre, fixes #10758
75 if ( !isset($tb_id) || !intval( $tb_id ) )
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
76 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.
77
78 if (empty($title) && empty($tb_url) && empty($blog_name)) {
79 // If it doesn't look like a trackback at all...
ff19f4b5 » ryan
2006-06-27 Use wp_redirect().
80 wp_redirect(get_permalink($tb_id));
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
81 exit;
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
82 }
83
858ba5ea » ryan
2007-01-25 Remove redundant check. Props Mittineague. fixes #3665
84 if ( !empty($tb_url) && !empty($title) ) {
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
85 header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
86
25788ba1 » ryan
2008-02-04 Add filters to comments_open() and pings_open(). Props tellyworth. fi…
87 if ( !pings_open($tb_id) )
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
88 trackback_response(1, 'Sorry, trackbacks are closed for this item.');
89
6e181bb9 » ryan
2008-03-03 Multi-byte character safe excerpting from nbachiyski. fixes #6077
90 $title = wp_html_excerpt( $title, 250 ).'...';
91 $excerpt = wp_html_excerpt( $excerpt, 252 ).'...';
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
92
7602d178 » matt
2007-03-23 (int)er the dragon.
93 $comment_post_ID = (int) $tb_id;
00d3d3fe » michelvaldrighi
2004-09-22 fixes for bug #311, by bronski
94 $comment_author = $blog_name;
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
95 $comment_author_email = '';
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
96 $comment_author_url = $tb_url;
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
97 $comment_content = "<strong>$title</strong>\n\n$excerpt";
98 $comment_type = 'trackback';
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
99
248a0c06 » ryan
2008-04-14 Prepare DB queries in more places. Props filosofo. see #6644
100 $dupe = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $comment_post_ID, $comment_author_url) );
3c34012a » saxmatt
2005-01-11 Don't accept duplicate pings
101 if ( $dupe )
efcb63ad » ryan
2006-08-30 s/URI/URL/. Props Nazgul. fixes #2666
102 trackback_response(1, 'We already have a ping from that URL for this post.');
3c34012a » saxmatt
2005-01-11 Don't accept duplicate pings
103
00d3d3fe » michelvaldrighi
2004-09-22 fixes for bug #311, by bronski
104 $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.
105
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
106 wp_new_comment($commentdata);
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
107
b650b073 » saxmatt
2004-09-07 Move trackbacks to new comment function.
108 do_action('trackback_post', $wpdb->insert_id);
31066f32 » saxmatt
2005-02-12 Don't die before action
109 trackback_response(0);
43e4a8a9 » saxmatt
2003-12-11 The great renaming.
110 }
a6a1522a » ryan
2008-05-25 File file level phpdoc from jacobsantos. see #7037
111 ?>
Something went wrong with that request. Please try again.