[ Index ]
 

Code source de WordPress 2.1.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/ -> wp-trackback.php (source)

   1  <?php
   2  
   3  if (empty($wp)) {
   4      require_once('wp-config.php');
   5      wp('tb=1');
   6  }
   7  
   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>";
  16          die();
  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  }
  24  
  25  // trackback is done by a POST
  26  $request_array = 'HTTP_POST_VARS';
  27  
  28  if ( !$_GET['tb_id'] ) {
  29      $tb_id = explode('/', $_SERVER['REQUEST_URI']);
  30      $tb_id = intval( $tb_id[ count($tb_id) - 1 ] );
  31  }
  32  
  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']);
  40  
  41  if ($charset)
  42      $charset = strtoupper( trim($charset) );
  43  else
  44      $charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
  45  
  46  if ( function_exists('mb_convert_encoding') ) { // For international trackbacks
  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);
  50  }
  51  
  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  
  57  if ( is_single() || is_page() )
  58      $tb_id = $posts[0]->ID;
  59  
  60  if ( !intval( $tb_id ) )
  61      trackback_response(1, 'I really need an ID for this to work.');
  62  
  63  if (empty($title) && empty($tb_url) && empty($blog_name)) {
  64      // If it doesn't look like a trackback at all...
  65      wp_redirect(get_permalink($tb_id));
  66      exit;
  67  }
  68  
  69  if ( !empty($tb_url) && !empty($title) && !empty($tb_url) ) {
  70      header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
  71  
  72      $pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id");
  73  
  74      if ( 'open' != $pingstatus )
  75          trackback_response(1, 'Sorry, trackbacks are closed for this item.');
  76  
  77      $title =  wp_specialchars( strip_tags( $title ) );
  78      $excerpt = strip_tags($excerpt);
  79      if ( function_exists('mb_strcut') ) { // For international trackbacks
  80          $excerpt = mb_strcut($excerpt, 0, 252, get_option('blog_charset')) . '...';
  81          $title = mb_strcut($title, 0, 250, get_option('blog_charset')) . '...';
  82      } else {
  83          $excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252) . '...' : $excerpt;
  84          $title = (strlen($title) > 250) ? substr($title, 0, 250) . '...' : $title;
  85      }
  86  
  87      $comment_post_ID = $tb_id;
  88      $comment_author = $blog_name;
  89      $comment_author_email = '';
  90      $comment_author_url = $tb_url;
  91      $comment_content = "<strong>$title</strong>\n\n$excerpt";
  92      $comment_type = 'trackback';
  93  
  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 )
  96          trackback_response(1, 'We already have a ping from that URL for this post.');
  97  
  98      $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
  99  
 100      wp_new_comment($commentdata);
 101  
 102      do_action('trackback_post', $wpdb->insert_id);
 103      trackback_response(0);
 104  }
 105  ?>


Généré le : Fri Mar 30 19:41:27 2007 par Balluche grâce à PHPXref 0.7