[wp-cvs] wordpress wp-trackback.php,1.18,1.19

Matthew Mullenweg saxmatt at users.sourceforge.net
Tue Sep 7 02:34:15 UTC 2004


Update of /cvsroot/cafelog/wordpress
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12705

Modified Files:
	wp-trackback.php 
Log Message:
Move trackbacks to new comment function.

Index: wp-trackback.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-trackback.php,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** wp-trackback.php	5 Sep 2004 01:50:38 -0000	1.18
--- wp-trackback.php	7 Sep 2004 02:34:12 -0000	1.19
***************
*** 1,9 ****
  <?php
! require(dirname(__FILE__) . '/wp-config.php');
  
  // trackback is done by a POST
  $request_array = 'HTTP_POST_VARS';
! $tb_id = explode('/', $_SERVER['REQUEST_URI']);
! $tb_id = intval($tb_id[count($tb_id)-1]);
  $tb_url = $_POST['url'];
  $title = $_POST['title'];
--- 1,30 ----
  <?php
! $doing_trackback = 1;
! require('./wp-config.php');
! include_once (ABSPATH . WPINC . '/functions-post.php');
! 
! function trackback_response($error = 0, $error_message = '') {
! 	header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
! 	if ($error) {
! 		echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
! 		echo "<response>\n";
! 		echo "<error>1</error>\n";
! 		echo "<message>$error_message</message>\n";
! 		echo "</response>";
! 	} else {
! 		echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
! 		echo "<response>\n";
! 		echo "<error>0</error>\n";
! 		echo "</response>";
! 	}
! 	die();
! }
  
  // trackback is done by a POST
  $request_array = 'HTTP_POST_VARS';
! if (!$tb_id) {
! 	$tb_id = explode('/', $_SERVER['REQUEST_URI']);
! 	$tb_id = intval($tb_id[count($tb_id)-1]);
! }
  $tb_url = $_POST['url'];
  $title = $_POST['title'];
***************
*** 11,31 ****
  $blog_name = $_POST['blog_name'];
  
! if (! $doing_trackback) {
      $doing_trackback = 1;
!     require('wp-blog-header.php');
  }
  
! if (is_single()) {
      $tb_id = $posts[0]->ID;
! }
  
  if (empty($title) && empty($tb_url) && empty($blog_name)) {
  	// If it doesn't look like a trackback at all...
  	header('Location: ' . get_permalink($tb_id));
  }
  
! if ((strlen(''.$tb_id)) && (empty($_GET['__mode'])) && (strlen(''.$tb_url))) {
! 
! 	@header('Content-Type: text/xml; charset=' . get_settings('blog_charset'));
  
  	$pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id");
--- 32,54 ----
  $blog_name = $_POST['blog_name'];
  
! if ( !$doing_trackback) {
      $doing_trackback = 1;
!     require('./wp-blog-header.php');
  }
  
! if ( is_single() ) 
      $tb_id = $posts[0]->ID;
! 
! if ( !$tb_id)
! 	trackback_response(1, 'I really need an ID for this to work.');
  
  if (empty($title) && empty($tb_url) && empty($blog_name)) {
  	// If it doesn't look like a trackback at all...
  	header('Location: ' . get_permalink($tb_id));
+ 	exit;
  }
  
! if ( !empty($tb_url) && !empty($title) && !empty($tb_url) ) {
! 	header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
  
  	$pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id");
***************
*** 34,93 ****
  		trackback_response(1, 'Sorry, trackbacks are closed for this item.');
  
! 	$tb_url = addslashes($tb_url);
! 	$title = strip_tags($title);
! 	$title = (strlen($title) > 255) ? substr($title, 0, 252).'...' : $title;
  	$excerpt = strip_tags($excerpt);
! 	$excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252).'...' : $excerpt;
  	$blog_name = htmlspecialchars($blog_name);
! 	$blog_name = (strlen($blog_name) > 255) ? substr($blog_name, 0, 252).'...' : $blog_name;
! 
! 	$comment = '<trackback />';
! 	$comment .= "<strong>$title</strong>\n$excerpt";
! 
! 	$author = addslashes(stripslashes(stripslashes($blog_name)));
! 	$email = '';
! 	$original_comment = $comment;
! 	$comment_post_ID = $tb_id;
! 
! 	$user_ip = $_SERVER['REMOTE_ADDR'];
! 	$user_domain = gethostbyaddr($user_ip);
! 	$now = current_time('mysql');
! 	$now_gmt = current_time('mysql', 1);
! 
! 	$user_agent = addslashes($_SERVER['HTTP_USER_AGENT']);
! 
! 	$comment = convert_chars($comment);
! 	$comment = format_to_post($comment);
  
! 	$comment_author = $author;
! 	$comment_author_email = $email;
  	$comment_author_url = $tb_url;
  
! 	$author = addslashes($author);
! 
! 	$comment_moderation = get_settings('comment_moderation');
! 	$moderation_notify = get_settings('moderation_notify');
  
! 	if(check_comment($author, $email, $url, $comment, $user_ip, $user_agent)) {
! 		$approved = 1;
! 	} else {
! 		$approved = 0;
! 	}
  
! 	$result = $wpdb->query("INSERT INTO $wpdb->comments 
! 	(comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent)
! 	VALUES 
! 	('$comment_post_ID', '$author', '$email', '$tb_url', '$user_ip', '$now', '$now_gmt', '$comment', '$approved', '$user_agent')
! 	");
  
- 	if (!$result) {
- 		die ("There is an error with the database, it can't store your comment...<br />Please contact the webmaster.");
- 	} else {
- 		$comment_ID = $wpdb->get_var('SELECT last_insert_id()');
- 		if (get_settings('comments_notify'))
- 			wp_notify_postauthor($comment_ID, 'trackback');
- 		trackback_response(0);
- 		do_action('trackback_post', $comment_ID);
- 	}
  }
  ?>
\ No newline at end of file
--- 57,81 ----
  		trackback_response(1, 'Sorry, trackbacks are closed for this item.');
  
! 	$title = strip_tags( htmlspecialchars( $title ) );
! 	$title = (strlen($title) > 250) ? substr($title, 0, 250) . '...' : $title;
  	$excerpt = strip_tags($excerpt);
! 	$excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252) . '...' : $excerpt;
  	$blog_name = htmlspecialchars($blog_name);
! 	$blog_name = (strlen($blog_name) > 250) ? substr($blog_name, 0, 250) . '...' : $blog_name;
  
! 	$comment_post_id = $tb_id;
! 	$commment_author = $blog_name;
! 	$comment_author_email = '';
  	$comment_author_url = $tb_url;
+ 	$comment_content = "<strong>$title</strong>\n\n$excerpt";
+ 	$comment_type = 'trackback';
  
! 	$commentdata = compact('comment_post_id', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
  
! 	wp_new_comment($commentdata);
  
! 	trackback_response(0);
! 	do_action('trackback_post', $wpdb->insert_id);
  
  }
  ?>
\ No newline at end of file




More information about the cvs mailing list