Make WordPress Core

Changeset 636


Ignore:
Timestamp:
12/22/2003 02:46:40 AM (21 years ago)
Author:
saxmatt
Message:

Trackback on edit done.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form.php

    r608 r636  
    2727        }
    2828        if ($use_trackback) {
    29             $form_trackback = '<p><label for="trackback"><a href="http://wordpress.org/docs/reference/post/#trackback" title="Help on trackbacks"><strong>TrackBack</strong> an <acronym title="Uniform Resource Locator">URL</acronym></a>:</label> (Separate multiple <acronym title="Uniform Resource Locator">URL</acronym>s with commas.)<br />
     29            $form_trackback = '<p><label for="trackback"><a href="http://wordpress.org/docs/reference/post/#trackback" title="Help on trackbacks"><strong>TrackBack</strong> an <acronym title="Uniform Resource Locator">URL</acronym></a>:</label> (Separate multiple <acronym title="Uniform Resource Locator">URL</acronym>s with spaces.)<br />
    3030            <input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" /></p>';
     31            if ('' != $pinged) {
     32                $form_trackback .= '<p>Already pinged:</p><ul>';
     33                $already_pinged = explode("\n", trim($pinged));
     34                foreach ($already_pinged as $pinged_url) {
     35                    $form_trackback .= "\n\t<li>$pinged_url</li>";
     36                }
     37                $form_trackback .= '</ul>';
     38            }
    3139        } else {
    3240            $form_trackback = '';
     
    4351        $form_pingback = '<input type="hidden" name="post_pingback" value="0" />';
    4452        $form_prevstatus = '<input type="hidden" name="prev_status" value="'.$post_status.'" />';
    45         $form_trackback = '';
     53        if ($use_trackback) {
     54            $form_trackback = '<p><label for="trackback"><a href="http://wordpress.org/docs/reference/post/#trackback" title="Help on trackbacks"><strong>TrackBack</strong> an <acronym title="Uniform Resource Locator">URL</acronym></a></label>
     55             (Separate multiple <acronym title="Uniform Resource Locator">URL</acronym>s with spaces.)<br />
     56            <input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. str_replace("\n", ' ', $to_ping) .'" /></p>';
     57            if ('' != $pinged) {
     58                $form_trackback .= '<p>Already pinged:</p><ul>';
     59                $already_pinged = explode("\n", trim($pinged));
     60                foreach ($already_pinged as $pinged_url) {
     61                    $form_trackback .= "\n\t<li>$pinged_url</li>";
     62                }
     63                $form_trackback .= '</ul>';
     64            }
     65        } else {
     66            $form_trackback = '';
     67        }
    4668        break;
    4769    case "editcomment":
  • trunk/wp-admin/post.php

    r631 r636  
    6363            $post_password = addslashes($HTTP_POST_VARS['post_password']);
    6464            $post_name = sanitize_title($post_title);
     65            $trackback = $HTTP_POST_VARS['trackback_url'];
     66        // Format trackbacks
     67        $trackback = preg_replace('|\s+|', '\n', $trackback);
    6568
    6669        if ($user_level == 0)
     
    8790        if((get_settings('use_geo_positions')) && (strlen($latstr) > 2) && (strlen($lonstr) > 2) ) {
    8891        $postquery ="INSERT INTO $tableposts
    89                 (ID, post_author, post_date, post_content, post_title, post_lat, post_lon, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name)
     92                (ID, post_author, post_date, post_content, post_title, post_lat, post_lon, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping)
    9093                VALUES
    91                 ('0', '$user_ID', '$now', '$content', '$post_title', $post_latf, $post_lonf,'$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name')
     94                ('0', '$user_ID', '$now', '$content', '$post_title', $post_latf, $post_lonf,'$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$trackback')
    9295                ";
    9396        } else {
    9497        $postquery ="INSERT INTO $tableposts
    95                 (ID, post_author, post_date, post_content, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name)
     98                (ID, post_author, post_date, post_content, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping)
    9699                VALUES
    97                 ('0', '$user_ID', '$now', '$content', '$post_title', '$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name')
     100                ('0', '$user_ID', '$now', '$content', '$post_title', '$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$trackback')
    98101                ";
    99102        }
     
    141144       
    142145        if ('' != $HTTP_POST_VARS['save']) $location = "post.php?action=edit&post=$post_ID";
    143         header("Location: $location");
     146       
     147        header("Location: $location");
    144148
    145149        if ($post_status == 'publish') {
     
    154158            }
    155159
    156             if (!empty($HTTP_POST_VARS['trackback_url'])) {
     160            // Time for trackbacks
     161            $to_ping = $wpdb->get_var("SELECT to_ping FROM $tableposts WHERE ID = $post_ID");
     162            $pinged = $wpdb->get_var("SELECT pinged FROM $tableposts WHERE ID = $post_ID");
     163            $pinged = explode("\n", $pinged);
     164            if ('' != $to_ping) {
    157165                if (strlen($excerpt) > 0) {
    158166                    $the_excerpt = (strlen(strip_tags($excerpt)) > 255) ? substr(strip_tags($excerpt), 0, 252) . '...' : strip_tags($excerpt)   ;
     
    160168                    $the_excerpt = (strlen(strip_tags($content)) > 255) ? substr(strip_tags($content), 0, 252) . '...' : strip_tags($content);
    161169                }
    162                 $excerpt = stripslashes($the_excerpt);
    163                 $trackback_urls = explode(',', $HTTP_POST_VARS['trackback_url']);
    164                 foreach($trackback_urls as $tb_url) {
    165                     $tb_url = trim($tb_url);
    166                     trackback($tb_url, stripslashes($post_title), $excerpt, $post_ID);
    167                 }
    168             }
     170                $excerpt = stripslashes($the_excerpt);
     171                $to_pings = explode("\n", $to_ping);
     172                foreach ($to_pings as $tb_ping) {
     173                    $tb_ping = trim($tb_ping);
     174                    if (!in_array($tb_ping, $pinged)) {
     175                     trackback($tb_ping, stripslashes($post_title), $excerpt, $post_ID);
     176                    }
     177                }
     178            }
     179
    169180        } // end if publish
    170181
     
    196207            $ping_status = $postdata['ping_status'];
    197208            $post_password = $postdata['post_password'];
     209            $to_ping = $postdata['to_ping'];
     210            $pinged = $postdata['pinged'];
    198211
    199212            include('edit-form.php');
     
    246259            $post_password = addslashes($HTTP_POST_VARS['post_password']);
    247260            $post_name = sanitize_title($post_title);
     261            $trackback = $HTTP_POST_VARS['trackback_url'];
     262        // Format trackbacks
     263        $trackback = preg_replace('|\s+|', '\n', $trackback);
    248264
    249265        if (($user_level > 4) && (!empty($HTTP_POST_VARS['edit_date']))) {
     
    274290                ping_status = '$ping_status',
    275291                post_password = '$post_password',
    276                 post_name = '$post_name'
     292                post_name = '$post_name',
     293                to_ping = '$trackback'
    277294            WHERE ID = $post_ID ");
    278295
     
    302319            pingWeblogs($blog_ID);
    303320            pingBlogs($blog_ID);
    304 
    305             if ($post_pingback) {
    306                 pingback($content, $post_ID);
    307             }
    308 
    309             if (!empty($HTTP_POST_VARS['trackback_url'])) {
    310                 $excerpt = (strlen(strip_tags($content)) > 255) ? substr(strip_tags($content), 0, 252) . '...' : strip_tags($content);
    311                 $excerpt = stripslashes($excerpt);
    312                 $trackback_urls = explode(',', $HTTP_POST_VARS['trackback_url']);
    313                 foreach($trackback_urls as $tb_url) {
    314                     $tb_url = trim($tb_url);
    315                     trackback($tb_url, stripslashes($post_title), $excerpt, $post_ID);
    316                 }
    317             }
     321        } // end if moving from draft/private to published
     322        if ($post_status == 'publish') {
     323            // Trackback time.
     324            $to_ping = trim($wpdb->get_var("SELECT to_ping FROM $tableposts WHERE ID = $post_ID"));
     325            $pinged = trim($wpdb->get_var("SELECT pinged FROM $tableposts WHERE ID = $post_ID"));
     326            $pinged = explode("\n", $pinged);
     327            if ('' != $to_ping) {
     328                if (strlen($excerpt) > 0) {
     329                    $the_excerpt = (strlen(strip_tags($excerpt)) > 255) ? substr(strip_tags($excerpt), 0, 252) . '...' : strip_tags($excerpt)   ;
     330                } else {
     331                    $the_excerpt = (strlen(strip_tags($content)) > 255) ? substr(strip_tags($content), 0, 252) . '...' : strip_tags($content);
     332                }
     333                $excerpt = stripslashes($the_excerpt);
     334                $to_pings = explode("\n", $to_ping);
     335                foreach ($to_pings as $tb_ping) {
     336                    $tb_ping = trim($tb_ping);
     337                    if (!in_array($tb_ping, $pinged)) {
     338                     trackback($tb_ping, stripslashes($post_title), $excerpt, $post_ID);
     339                    }
     340                }
     341            }
    318342        } // end if publish
     343       
    319344
    320345        $location = "Location: post.php";
     
    358383        }
    359384
    360         // pingWeblogs($blog_ID);
    361385        $sendback = $HTTP_SERVER_VARS['HTTP_REFERER'];
    362386        if (strstr($sendback, 'post.php')) $sendback = $siteurl .'/wp-admin/post.php';
  • trunk/wp-admin/upgrade-072-to-080.php

    r632 r636  
    6060$wpdb->show_errors();
    6161
    62 
     62// Create ping status fields
     63
     64$query = "ALTER TABLE $tableposts ADD `to_ping` TEXT NOT NULL";
     65maybe_add_column($tableposts, 'to_ping', $query);
     66$query = "ALTER TABLE $tableposts ADD `pinged` TEXT NOT NULL";
     67maybe_add_column($tableposts, 'pinged', $query);
    6368
    6469// Create category_nicename field
  • trunk/wp-includes/functions.php

    r628 r636  
    589589        'comment_status' => $post->comment_status,
    590590        'ping_status' => $post->ping_status,
    591         'post_password' => $post->post_password
     591        'post_password' => $post->post_password,
     592        'to_ping' => $post->to_ping,
     593        'pinged' => $post->pinged
    592594    );
    593595    return $postdata;
     
    888890
    889891
    890 // trackback - send
     892// Send a Trackback
    891893function trackback($trackback_url, $title, $excerpt, $ID) {
    892     global $siteurl, $blogfilename, $blogname;
    893     global $querystring_start, $querystring_equal;
    894     $title = urlencode($title);
     894    global $blogname, $wpdb, $tableposts;
     895    $title = urlencode(stripslashes($title));
    895896    $excerpt = urlencode(stripslashes($excerpt));
    896     $blog_name = urlencode($blogname);
    897     $url = urlencode($siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal.$ID);
     897    $blog_name = urlencode(stripslashes($blogname));
     898    $tb_url = $trackback_url;
     899    $url = urlencode(get_permalink($ID));
    898900    $query_string = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt";
    899     if (strstr($trackback_url, '?')) {
    900         $trackback_url .= "&".$query_string;;
    901         $fp = @fopen($trackback_url, 'r');
    902         $result = @fread($fp, 4096);
    903         @fclose($fp);
    904 /* debug code
    905         $debug_file = 'trackback.log';
    906         $fp = fopen($debug_file, 'a');
    907         fwrite($fp, "\n*****\nTrackback URL query:\n\n$trackback_url\n\nResponse:\n\n");
    908         fwrite($fp, $result);
    909         fwrite($fp, "\n\n");
    910         fclose($fp);
     901    $trackback_url = parse_url($trackback_url);
     902    $http_request  = 'POST '.$trackback_url['path']." HTTP/1.0\r\n";
     903    $http_request .= 'Host: '.$trackback_url['host']."\r\n";
     904    $http_request .= 'Content-Type: application/x-www-form-urlencoded'."\r\n";
     905    $http_request .= 'Content-Length: '.strlen($query_string)."\r\n";
     906    $http_request .= "\r\n";
     907    $http_request .= $query_string;
     908    $fs = @fsockopen($trackback_url['host'], 80);
     909    @fputs($fs, $http_request);
     910/*
     911    $debug_file = 'trackback.log';
     912    $fp = fopen($debug_file, 'a');
     913    fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n");
     914    while(!@feof($fs)) {
     915        fwrite($fp, @fgets($fs, 4096));
     916    }
     917    fwrite($fp, "\n\n");
     918    fclose($fp);
    911919*/
    912     } else {
    913         $trackback_url = parse_url($trackback_url);
    914         $http_request  = 'POST '.$trackback_url['path']." HTTP/1.0\r\n";
    915         $http_request .= 'Host: '.$trackback_url['host']."\r\n";
    916         $http_request .= 'Content-Type: application/x-www-form-urlencoded'."\r\n";
    917         $http_request .= 'Content-Length: '.strlen($query_string)."\r\n";
    918         $http_request .= "\r\n";
    919         $http_request .= $query_string;
    920         $fs = @fsockopen($trackback_url['host'], 80);
    921         @fputs($fs, $http_request);
    922 /* debug code
    923         $debug_file = 'trackback.log';
    924         $fp = fopen($debug_file, 'a');
    925         fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n");
    926         while(!@feof($fs)) {
    927             fwrite($fp, @fgets($fs, 4096));
    928         }
    929         fwrite($fp, "\n\n");
    930         fclose($fp);
    931 */
    932         @fclose($fs);
    933     }
     920    @fclose($fs);
     921
     922    $wpdb->query("UPDATE $tableposts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = $ID");
     923    $wpdb->query("UPDATE $tableposts SET to_ping = REPLACE(to_ping, '$tb_url', '') WHERE ID = $ID");
    934924    return $result;
    935925}
  • trunk/wp-trackback.php

    r601 r636  
    4242    $comment .= "<strong>$title</strong>\n$excerpt";
    4343
    44     $author = addslashes($blog_name);
     44    $author = addslashes(stripslashes(stripslashes($blog_name)));
    4545    $email = '';
    4646    $original_comment = $comment;
Note: See TracChangeset for help on using the changeset viewer.