Make WordPress Core


Ignore:
Timestamp:
10/14/2004 07:26:41 AM (20 years ago)
Author:
saxmatt
Message:

Trackback and pingback cleanups.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions-post.php

    r1778 r1794  
    361361    $comment_author = strip_tags($comment_author);
    362362    $comment_author = htmlspecialchars($comment_author);
    363     $comment_author = $wpdb->escape($comment_author);
    364363
    365364    $comment_author_email = preg_replace('/[^a-z+_.@-]/i', '', $comment_author_email);
     
    367366    $comment_author_url = strip_tags($comment_author_url);
    368367    $comment_author_url = htmlspecialchars($comment_author_url);
    369     $comment_author_url = $wpdb->escape($comment_author_url);
    370368
    371369    $comment_content = apply_filters('comment_content_presave', $comment_content);
    372     $comment_content = $wpdb->escape($comment_content);
    373370
    374371    $user_ip = addslashes($_SERVER['REMOTE_ADDR']);
     
    407404}
    408405
     406function do_trackbacks($post_id) {
     407    global $wpdb;
     408
     409    $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $post_id");
     410    $to_ping = get_to_ping($post_id);
     411    $pinged  = get_pung($post_id);
     412    $content = strip_tags($post->post_content);
     413    $excerpt = strip_tags($post->post_excerpt);
     414    $post_title = strip_tags($post->post_title);
     415
     416    if ( $excerpt )
     417        $excerpt = substr($excerpt, 0, 252) . '...';
     418    else
     419        $excerpt = substr($content, 0, 252) . '...';
     420
     421    if ($to_ping) : foreach ($to_ping as $tb_ping) :
     422        $tb_ping = trim($tb_ping);
     423        if ( !in_array($tb_ping, $pinged) )
     424         trackback($tb_ping, $post_title, $excerpt, $post_id);
     425    endforeach; endif;
     426}
     427
     428function get_pung($post_id) { // Get URIs already pung for a post
     429    global $wpdb;
     430    $pung = $wpdb->get_var("SELECT pinged FROM $wpdb->posts WHERE ID = $post_id");
     431    $pung = trim($pung);
     432    $pung = preg_split('/\s/', $pung);
     433    return $pung;
     434}
     435
     436function get_to_ping($post_id) { // Get any URIs in the todo list
     437    global $wpdb;
     438    $to_ping = $wpdb->get_var("SELECT to_ping FROM $wpdb->posts WHERE ID = $post_id");
     439    $to_ping = trim($to_ping);
     440    $to_ping = preg_split('/\s/', $to_ping);
     441    return $to_ping;
     442}
     443
     444function add_ping($post_id, $uri) { // Add a URI to those already pung
     445    global $wpdb;
     446    $pung = $wpdb->get_var("SELECT pinged FROM $wpdb->posts WHERE ID = $post_id");
     447    $pung = trim($pung);
     448    $pung = preg_split('/\s/', $pung);
     449    $pung[] = $uri;
     450    $new = implode("\n", $pung);
     451    return $wpdb->query("UPDATE $wpdb->posts SET pinged = '$new' WHERE ID = $post_id");
     452}
     453
    409454?>
Note: See TracChangeset for help on using the changeset viewer.