Changeset 592

Show
Ignore:
Timestamp:
06/23/06 10:32:27 (2 years ago)
Author:
donncha
Message:

WP merge

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-content/themes/classic/comments-popup.php

    r524 r592  
    3030<?php 
    3131// this line is WordPress' motor, do not delete it. 
    32 $comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : ''; 
    33 $comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : ''; 
    34 $comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : ''; 
     32$commenter = wp_get_current_commenter(); 
     33extract($commenter); 
    3534$comments = get_approved_comments($id); 
    3635$commentstatus = get_post($id); 
  • trunk/wp-content/themes/default/comments-popup.php

    r524 r592  
    3030<?php 
    3131// this line is WordPress' motor, do not delete it. 
    32 $comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : ''; 
    33 $comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : ''; 
    34 $comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : ''; 
     32$commenter = wp_get_current_commenter(); 
     33extract($commenter); 
    3534$comments = get_approved_comments($id); 
    3635$post = get_post($id); 
  • trunk/wp-includes/comment-template.php

    r565 r592  
    274274        global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity; 
    275275 
    276         if ( is_single() || is_page() || $withcomments ) : 
    277                 $req = get_settings('require_name_email'); 
    278                 $comment_author = ''; 
    279                 if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) { 
    280                         $comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]); 
    281                         $comment_author = stripslashes($comment_author); 
    282                         $comment_author = wp_specialchars($comment_author, true); 
    283                 } 
    284                 $comment_author_email = ''; 
    285                 if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) { 
    286                         $comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]); 
    287                         $comment_author_email = stripslashes($comment_author_email); 
    288                         $comment_author_email = wp_specialchars($comment_author_email, true);            
    289                 } 
    290                 $comment_author_url = ''; 
    291                 if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) { 
    292                         $comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]); 
    293                         $comment_author_url = stripslashes($comment_author_url); 
    294                         $comment_author_url = wp_specialchars($comment_author_url, true);                
    295                 } 
     276        if ( ! (is_single() || is_page() || $withcomments) ) 
     277                return; 
     278 
     279        $req = get_settings('require_name_email'); 
     280        $commenter = wp_get_current_commenter(); 
     281        extract($commenter); 
    296282 
    297283        // TODO: Use API instead of SELECTs. 
     
    310296        else 
    311297                require( ABSPATH . 'wp-content/themes/default/comments.php'); 
    312  
    313         endif; 
    314298} 
    315299 
  • trunk/wp-includes/comment.php

    r579 r592  
    147147} 
    148148 
     149function sanitize_comment_cookies() { 
     150        if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) { 
     151                $comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]); 
     152                $comment_author = stripslashes($comment_author); 
     153                $comment_author = wp_specialchars($comment_author, true); 
     154                $_COOKIE['comment_author_'.COOKIEHASH] = $comment_author; 
     155        } 
     156 
     157        if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) { 
     158                $comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]); 
     159                $comment_author_email = stripslashes($comment_author_email); 
     160                $comment_author_email = wp_specialchars($comment_author_email, true);    
     161                $_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email; 
     162        } 
     163 
     164        if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) { 
     165                $comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]); 
     166                $comment_author_url = stripslashes($comment_author_url); 
     167                $comment_author_url = wp_specialchars($comment_author_url, true); 
     168                $_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url; 
     169        } 
     170} 
     171 
    149172function wp_allow_comment($commentdata) { 
    150173        global $wpdb; 
     
    274297                return false; 
    275298        } 
     299} 
     300 
     301function wp_get_current_commenter() { 
     302        // Cookies should already be sanitized. 
     303 
     304        $comment_author = ''; 
     305        if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) 
     306                $comment_author = $_COOKIE['comment_author_'.COOKIEHASH]; 
     307 
     308        $comment_author_email = ''; 
     309        if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) 
     310                $comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH]; 
     311 
     312        $comment_author_url = ''; 
     313        if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) 
     314                $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH]; 
     315 
     316        return compact('comment_author', 'comment_author_email', 'comment_author_url'); 
    276317} 
    277318 
     
    437478} 
    438479 
    439 function pingback($content, $post_ID) { 
    440         global $wp_version, $wpdb; 
    441         include_once (ABSPATH . WPINC . '/class-IXR.php'); 
    442  
    443         // original code by Mort (http://mort.mine.nu:8080) 
    444         $log = debug_fopen(ABSPATH . '/pingback.log', 'a'); 
    445         $post_links = array(); 
    446         debug_fwrite($log, 'BEGIN '.date('YmdHis', time())."\n"); 
    447  
    448         $pung = get_pung($post_ID); 
    449  
    450         // Variables 
    451         $ltrs = '\w'; 
    452         $gunk = '/#~:.?+=&%@!\-'; 
    453         $punc = '.:?\-'; 
    454         $any = $ltrs . $gunk . $punc; 
    455  
    456         // Step 1 
    457         // Parsing the post, external links (if any) are stored in the $post_links array 
    458         // This regexp comes straight from phpfreaks.com 
    459         // http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php 
    460         preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp); 
    461  
    462         // Debug 
    463         debug_fwrite($log, 'Post contents:'); 
    464         debug_fwrite($log, $content."\n"); 
    465  
    466         // Step 2. 
    467         // Walking thru the links array 
    468         // first we get rid of links pointing to sites, not to specific files 
    469         // Example: 
    470         // http://dummy-weblog.org 
    471         // http://dummy-weblog.org/ 
    472         // http://dummy-weblog.org/post.php 
    473         // We don't wanna ping first and second types, even if they have a valid <link/> 
    474  
    475         foreach($post_links_temp[0] as $link_test) : 
    476                 if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself 
    477                                 && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments. 
    478                         $test = parse_url($link_test); 
    479                         if (isset($test['query'])) 
    480                                 $post_links[] = $link_test; 
    481                         elseif(($test['path'] != '/') && ($test['path'] != '')) 
    482                                 $post_links[] = $link_test; 
    483                 endif; 
    484         endforeach; 
    485  
    486         do_action('pre_ping',  array(&$post_links, &$pung)); 
    487  
    488         foreach ($post_links as $pagelinkedto){ 
    489                 debug_fwrite($log, "Processing -- $pagelinkedto\n"); 
    490                 $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048); 
    491  
    492                 if ($pingback_server_url) { 
    493                         @ set_time_limit( 60 );  
    494                          // Now, the RPC call 
    495                         debug_fwrite($log, "Page Linked To: $pagelinkedto \n"); 
    496                         debug_fwrite($log, 'Page Linked From: '); 
    497                         $pagelinkedfrom = get_permalink($post_ID); 
    498                         debug_fwrite($log, $pagelinkedfrom."\n"); 
    499  
    500                         // using a timeout of 3 seconds should be enough to cover slow servers 
    501                         $client = new IXR_Client($pingback_server_url); 
    502                         $client->timeout = 3; 
    503                         $client->useragent .= ' -- WordPress/' . $wp_version; 
    504  
    505                         // when set to true, this outputs debug messages by itself 
    506                         $client->debug = false; 
    507  
    508                         if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto ) ) 
    509                                 add_ping( $post_ID, $pagelinkedto ); 
    510                         else 
    511                                 debug_fwrite($log, "Error.\n Fault code: ".$client->getErrorCode()." : ".$client->getErrorMessage()."\n"); 
    512                 } 
    513         } 
    514  
    515         debug_fwrite($log, "\nEND: ".time()."\n****************************\n"); 
    516         debug_fclose($log); 
    517 
     480// 
     481// Ping and trackback functions. 
     482// 
    518483 
    519484function discover_pingback_server_uri($url, $timeout_bytes = 2048) { 
     
    607572} 
    608573 
    609 function is_local_attachment($url) { 
    610         if ( !strstr($url, get_bloginfo('home') ) ) 
    611                 return false; 
    612         if ( strstr($url, get_bloginfo('home') . '/?attachment_id=') ) 
    613                 return true; 
    614         if ( $id = url_to_postid($url) ) { 
    615                 $post = & get_post($id); 
    616                 if ( 'attachment' == $post->post_type ) 
    617                         return true; 
    618         } 
    619         return false; 
     574function do_all_pings() { 
     575        global $wpdb; 
     576 
     577        // Do pingbacks 
     578        while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { 
     579                $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';"); 
     580                pingback($ping->post_content, $ping->ID); 
     581        } 
     582         
     583        // Do Enclosures 
     584        while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { 
     585                $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';"); 
     586                do_enclose($enclosure->post_content, $enclosure->ID); 
     587        } 
     588 
     589        // Do Trackbacks 
     590        $trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'"); 
     591        if ( is_array($trackbacks) ) { 
     592                foreach ( $trackbacks as $trackback ) { 
     593                        do_trackbacks($trackback->ID); 
     594                } 
     595        } 
     596 
     597        //Do Update Services/Generic Pings 
     598        generic_ping(); 
     599
     600 
     601function do_trackbacks($post_id) { 
     602        global $wpdb; 
     603 
     604        $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $post_id"); 
     605        $to_ping = get_to_ping($post_id); 
     606        $pinged  = get_pung($post_id); 
     607        if ( empty($to_ping) ) { 
     608                $wpdb->query("UPDATE $wpdb->posts SET to_ping = '' WHERE ID = '$post_id'"); 
     609                return; 
     610        } 
     611 
     612        if (empty($post->post_excerpt)) 
     613                $excerpt = apply_filters('the_content', $post->post_content); 
     614        else 
     615                $excerpt = apply_filters('the_excerpt', $post->post_excerpt); 
     616        $excerpt = str_replace(']]>', ']]&gt;', $excerpt); 
     617        $excerpt = strip_tags($excerpt); 
     618        if ( function_exists('mb_strcut') ) // For international trackbacks 
     619        $excerpt = mb_strcut($excerpt, 0, 252, get_settings('blog_charset')) . '...'; 
     620        else 
     621                $excerpt = substr($excerpt, 0, 252) . '...'; 
     622 
     623        $post_title = apply_filters('the_title', $post->post_title); 
     624        $post_title = strip_tags($post_title); 
     625 
     626        if ($to_ping) : foreach ($to_ping as $tb_ping) : 
     627                $tb_ping = trim($tb_ping); 
     628                if ( !in_array($tb_ping, $pinged) ) { 
     629                        trackback($tb_ping, $post_title, $excerpt, $post_id); 
     630                        $pinged[] = $tb_ping; 
     631                } else { 
     632                        $wpdb->query("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '$tb_ping', '')) WHERE ID = '$post_id'"); 
     633                } 
     634        endforeach; endif; 
     635
     636 
     637function generic_ping($post_id = 0) { 
     638        $services = get_settings('ping_sites'); 
     639        $services = preg_replace("|(\s)+|", '$1', $services); // Kill dupe lines 
     640        $services = trim($services); 
     641        if ( '' != $services ) { 
     642                $services = explode("\n", $services); 
     643                foreach ($services as $service) { 
     644                        weblog_ping($service); 
     645                } 
     646        } 
     647 
     648        return $post_id; 
     649
     650 
     651function pingback($content, $post_ID) { 
     652        global $wp_version, $wpdb; 
     653        include_once (ABSPATH . WPINC . '/class-IXR.php'); 
     654 
     655        // original code by Mort (http://mort.mine.nu:8080) 
     656        $log = debug_fopen(ABSPATH . '/pingback.log', 'a'); 
     657        $post_links = array(); 
     658        debug_fwrite($log, 'BEGIN '.date('YmdHis', time())."\n"); 
     659 
     660        $pung = get_pung($post_ID); 
     661 
     662        // Variables 
     663        $ltrs = '\w'; 
     664        $gunk = '/#~:.?+=&%@!\-'; 
     665        $punc = '.:?\-'; 
     666        $any = $ltrs . $gunk . $punc; 
     667 
     668        // Step 1 
     669        // Parsing the post, external links (if any) are stored in the $post_links array 
     670        // This regexp comes straight from phpfreaks.com 
     671        // http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php 
     672        preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp); 
     673 
     674        // Debug 
     675        debug_fwrite($log, 'Post contents:'); 
     676        debug_fwrite($log, $content."\n"); 
     677 
     678        // Step 2. 
     679        // Walking thru the links array 
     680        // first we get rid of links pointing to sites, not to specific files 
     681        // Example: 
     682        // http://dummy-weblog.org 
     683        // http://dummy-weblog.org/ 
     684        // http://dummy-weblog.org/post.php 
     685        // We don't wanna ping first and second types, even if they have a valid <link/> 
     686 
     687        foreach($post_links_temp[0] as $link_test) : 
     688                if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself 
     689                                && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments. 
     690                        $test = parse_url($link_test); 
     691                        if (isset($test['query'])) 
     692                                $post_links[] = $link_test; 
     693                        elseif(($test['path'] != '/') && ($test['path'] != '')) 
     694                                $post_links[] = $link_test; 
     695                endif; 
     696        endforeach; 
     697 
     698        do_action('pre_ping',  array(&$post_links, &$pung)); 
     699 
     700        foreach ($post_links as $pagelinkedto){ 
     701                debug_fwrite($log, "Processing -- $pagelinkedto\n"); 
     702                $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048); 
     703 
     704                if ($pingback_server_url) { 
     705                        @ set_time_limit( 60 );  
     706                         // Now, the RPC call 
     707                        debug_fwrite($log, "Page Linked To: $pagelinkedto \n"); 
     708                        debug_fwrite($log, 'Page Linked From: '); 
     709                        $pagelinkedfrom = get_permalink($post_ID); 
     710                        debug_fwrite($log, $pagelinkedfrom."\n"); 
     711 
     712                        // using a timeout of 3 seconds should be enough to cover slow servers 
     713                        $client = new IXR_Client($pingback_server_url); 
     714                        $client->timeout = 3; 
     715                        $client->useragent .= ' -- WordPress/' . $wp_version; 
     716 
     717                        // when set to true, this outputs debug messages by itself 
     718                        $client->debug = false; 
     719 
     720                        if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto ) ) 
     721                                add_ping( $post_ID, $pagelinkedto ); 
     722                        else 
     723                                debug_fwrite($log, "Error.\n Fault code: ".$client->getErrorCode()." : ".$client->getErrorMessage()."\n"); 
     724                } 
     725        } 
     726 
     727        debug_fwrite($log, "\nEND: ".time()."\n****************************\n"); 
     728        debug_fclose($log); 
     729
     730 
     731function privacy_ping_filter( $sites ) { 
     732        global $current_blog; 
     733        if ( '0' != $current_blog->public ) 
     734                return $sites; 
     735        else 
     736                return ''; 
     737
     738 
     739// Send a Trackback 
     740function trackback($trackback_url, $title, $excerpt, $ID) { 
     741        global $wpdb, $wp_version; 
     742 
     743        if ( empty($trackback_url) ) 
     744                return; 
     745 
     746        $title = urlencode($title); 
     747        $excerpt = urlencode($excerpt); 
     748        $blog_name = urlencode(get_settings('blogname')); 
     749        $tb_url = $trackback_url; 
     750        $url = urlencode(get_permalink($ID)); 
     751        $query_string = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt"; 
     752        $trackback_url = parse_url($trackback_url); 
     753        $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?'.$trackback_url['query'] : '') . " HTTP/1.0\r\n"; 
     754        $http_request .= 'Host: '.$trackback_url['host']."\r\n"; 
     755        $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_settings('blog_charset')."\r\n"; 
     756        $http_request .= 'Content-Length: '.strlen($query_string)."\r\n"; 
     757        $http_request .= "User-Agent: WordPress/" . $wp_version; 
     758        $http_request .= "\r\n\r\n"; 
     759        $http_request .= $query_string; 
     760        if ( '' == $trackback_url['port'] ) 
     761                $trackback_url['port'] = 80; 
     762        $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4); 
     763        @fputs($fs, $http_request); 
     764/* 
     765        $debug_file = 'trackback.log'; 
     766        $fp = fopen($debug_file, 'a'); 
     767        fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n"); 
     768        while(!@feof($fs)) { 
     769                fwrite($fp, @fgets($fs, 4096)); 
     770        } 
     771        fwrite($fp, "\n\n"); 
     772        fclose($fp); 
     773*/ 
     774        @fclose($fs); 
     775 
     776        $tb_url = addslashes( $tb_url ); 
     777        $wpdb->query("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = '$ID'"); 
     778        return $wpdb->query("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '$tb_url', '')) WHERE ID = '$ID'"); 
     779
     780 
     781function weblog_ping($server = '', $path = '') { 
     782        global $wp_version; 
     783        include_once (ABSPATH . WPINC . '/class-IXR.php'); 
     784 
     785        // using a timeout of 3 seconds should be enough to cover slow servers 
     786        $client = new IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path)); 
     787        $client->timeout = 3; 
     788        $client->useragent .= ' -- WordPress/'.$wp_version; 
     789 
     790        // when set to true, this outputs debug messages by itself 
     791        $client->debug = false; 
     792        $home = trailingslashit( get_option('home') ); 
     793        if ( !$client->query('weblogUpdates.extendedPing', get_settings('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping 
     794                $client->query('weblogUpdates.ping', get_settings('blogname'), $home); 
    620795} 
    621796 
  • trunk/wp-includes/compat.php

    r559 r592  
    7474 * @author      Stephan Schmidt <schst@php.net> 
    7575 * @author      Aidan Lister <aidan@php.net> 
    76  * @version     $Revision: 3862
     76 * @version     $Revision: 3901
    7777 * @since       PHP 4.2.0 
    7878 * @require     PHP 4.0.0 (user_error) 
     
    112112   } 
    113113} 
     114 
     115if ( !function_exists('_') ) { 
     116        function _($string) { 
     117                return $string; 
     118        } 
     119} 
     120 
    114121?> 
  • trunk/wp-includes/default-filters.php

    r550 r592  
    128128add_action('do_pings', 'do_all_pings', 10, 1); 
    129129add_action('do_robots', 'do_robots'); 
     130add_action('sanitize_comment_cookies', 'sanitize_comment_cookies'); 
    130131?> 
  • trunk/wp-includes/functions.php

    r587 r592  
    22 
    33require_once(dirname(__FILE__).'/compat.php'); 
    4  
    5 if ( !function_exists('_') ) { 
    6         function _($string) { 
    7                 return $string; 
    8         } 
    9 } 
    104 
    115function mysql2date($dateformatstring, $mysqlstring, $translate = true) { 
     
    337331} 
    338332 
    339 function weblog_ping($server = '', $path = '') { 
    340         global $wp_version; 
    341         include_once (ABSPATH . WPINC . '/class-IXR.php'); 
    342  
    343         // using a timeout of 3 seconds should be enough to cover slow servers 
    344         $client = new IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path)); 
    345         $client->timeout = 3; 
    346         $client->useragent .= ' -- WordPress/'.$wp_version; 
    347  
    348         // when set to true, this outputs debug messages by itself 
    349         $client->debug = false; 
    350         $home = trailingslashit( get_option('home') ); 
    351         if ( !$client->query('weblogUpdates.extendedPing', get_settings('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping 
    352                 $client->query('weblogUpdates.ping', get_settings('blogname'), $home); 
    353 } 
    354  
    355 function generic_ping($post_id = 0) { 
    356         $services = get_settings('ping_sites'); 
    357         $services = preg_replace("|(\s)+|", '$1', $services); // Kill dupe lines 
    358         $services = trim($services); 
    359         if ( '' != $services ) { 
    360                 $services = explode("\n", $services); 
    361                 foreach ($services as $service) { 
    362                         weblog_ping($service); 
    363                 } 
    364         } 
    365  
    366         return $post_id; 
    367 } 
    368  
    369 // Send a Trackback 
    370 function trackback($trackback_url, $title, $excerpt, $ID) { 
    371         global $wpdb, $wp_version; 
    372  
    373         if ( empty($trackback_url) ) 
    374                 return; 
    375  
    376         $title = urlencode($title); 
    377         $excerpt = urlencode($excerpt); 
    378         $blog_name = urlencode(get_settings('blogname')); 
    379         $tb_url = $trackback_url; 
    380         $url = urlencode(get_permalink($ID)); 
    381         $query_string = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt"; 
    382         $trackback_url = parse_url($trackback_url); 
    383         $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?'.$trackback_url['query'] : '') . " HTTP/1.0\r\n"; 
    384         $http_request .= 'Host: '.$trackback_url['host']."\r\n"; 
    385         $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_settings('blog_charset')."\r\n"; 
    386         $http_request .= 'Content-Length: '.strlen($query_string)."\r\n"; 
    387         $http_request .= "User-Agent: WordPress/" . $wp_version; 
    388         $http_request .= "\r\n\r\n"; 
    389         $http_request .= $query_string; 
    390         if ( '' == $trackback_url['port'] ) 
    391                 $trackback_url['port'] = 80; 
    392         $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4); 
    393         @fputs($fs, $http_request); 
    394 /* 
    395         $debug_file = 'trackback.log'; 
    396         $fp = fopen($debug_file, 'a'); 
    397         fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n"); 
    398         while(!@feof($fs)) { 
    399                 fwrite($fp, @fgets($fs, 4096)); 
    400         } 
    401         fwrite($fp, "\n\n"); 
    402         fclose($fp); 
    403 */ 
    404         @fclose($fs); 
    405  
    406         $tb_url = addslashes( $tb_url ); 
    407         $wpdb->query("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = '$ID'"); 
    408         return $wpdb->query("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '$tb_url', '')) WHERE ID = '$ID'"); 
    409 } 
    410  
    411333function make_url_footnote($content) { 
    412334        preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches); 
     
    840762        global $wpdb; 
    841763        return $wpdb->num_queries; 
    842 } 
    843  
    844 function privacy_ping_filter( $sites ) { 
    845         global $current_blog; 
    846         if ( '0' != $current_blog->public ) 
    847                 return $sites; 
    848         else 
    849                 return ''; 
    850764} 
    851765 
     
    10921006} 
    10931007 
    1094 function do_trackbacks($post_id) { 
    1095         global $wpdb; 
    1096  
    1097         $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $post_id"); 
    1098         $to_ping = get_to_ping($post_id); 
    1099         $pinged  = get_pung($post_id); 
    1100         if ( empty($to_ping) ) { 
    1101                 $wpdb->query("UPDATE $wpdb->posts SET to_ping = '' WHERE ID = '$post_id'"); 
    1102                 return; 
    1103         } 
    1104  
    1105         if (empty($post->post_excerpt)) 
    1106                 $excerpt = apply_filters('the_content', $post->post_content); 
    1107         else 
    1108                 $excerpt = apply_filters('the_excerpt', $post->post_excerpt); 
    1109         $excerpt = str_replace(']]>', ']]&gt;', $excerpt); 
    1110         $excerpt = strip_tags($excerpt); 
    1111         if ( function_exists('mb_strcut') ) // For international trackbacks 
    1112         $excerpt = mb_strcut($excerpt, 0, 252, get_settings('blog_charset')) . '...'; 
    1113         else 
    1114                 $excerpt = substr($excerpt, 0, 252) . '...'; 
    1115  
    1116         $post_title = apply_filters('the_title', $post->post_title); 
    1117         $post_title = strip_tags($post_title); 
    1118  
    1119         if ($to_ping) : foreach ($to_ping as $tb_ping) : 
    1120                 $tb_ping = trim($tb_ping); 
    1121                 if ( !in_array($tb_ping, $pinged) ) { 
    1122                         trackback($tb_ping, $post_title, $excerpt, $post_id); 
    1123                         $pinged[] = $tb_ping; 
    1124                 } else { 
    1125                         $wpdb->query("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '$tb_ping', '')) WHERE ID = '$post_id'"); 
    1126                 } 
    1127         endforeach; endif; 
    1128 } 
    1129  
    1130 function do_all_pings() { 
    1131         global $wpdb; 
    1132  
    1133         // Do pingbacks 
    1134         while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { 
    1135                 $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';"); 
    1136                 pingback($ping->post_content, $ping->ID); 
    1137         } 
    1138          
    1139         // Do Enclosures 
    1140         while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { 
    1141                 $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';"); 
    1142                 do_enclose($enclosure->post_content, $enclosure->ID); 
    1143         } 
    1144  
    1145         // Do Trackbacks 
    1146         $trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'"); 
    1147         if ( is_array($trackbacks) ) { 
    1148                 foreach ( $trackbacks as $trackback ) { 
    1149                         do_trackbacks($trackback->ID); 
    1150                 } 
    1151         } 
    1152  
    1153         //Do Update Services/Generic Pings 
    1154         generic_ping(); 
    1155 } 
    1156  
    11571008function wp_proxy_check($ipnum) { 
    11581009        if ( get_option('open_proxy_check') && isset($ipnum) ) { 
  • trunk/wp-includes/post-template.php

    r559 r592  
    3535        if ( !empty($post->post_password) ) 
    3636                $title = sprintf(__('Protected: %s'), $title); 
     37        else if ( 'private' == $post->post_status ) 
     38                $title = sprintf(__('Private: %s'), $title); 
    3739 
    3840        return $title; 
  • trunk/wp-includes/post.php

    r559 r592  
    11181118// Attachment functions 
    11191119// 
     1120 
     1121function is_local_attachment($url) { 
     1122        if ( !strstr($url, get_bloginfo('home') ) ) 
     1123                return false; 
     1124        if ( strstr($url, get_bloginfo('home') . '/?attachment_id=') ) 
     1125                return true; 
     1126        if ( $id = url_to_postid($url) ) { 
     1127                $post = & get_post($id); 
     1128                if ( 'attachment' == $post->post_type ) 
     1129                        return true; 
     1130        } 
     1131        return false; 
     1132} 
    11201133 
    11211134function wp_insert_attachment($object, $file = false, $post_parent = 0) { 
  • trunk/wp-includes/query.php

    r587 r592  
    851851                        $where .= " AND (post_type = '$post_type' AND (post_status = 'publish'"; 
    852852 
    853                         if ( is_admin() ) { 
     853                        if ( is_admin() ) 
    854854                                $where .= " OR post_status = 'future' OR post_status = 'draft'"; 
    855855         
    856                                 if ( is_user_logged_in() ) { 
    857                                         if ( 'post' == $post_type ) 
    858                                                 $cap = 'edit_private_posts'; 
    859                                         else 
    860                                                 $cap = 'edit_private_pages'; 
    861  
    862                                         if ( current_user_can($cap) ) 
    863                                                 $where .= "OR post_status = 'private'"; 
    864                                         else 
    865                                         $where .= " OR post_author = $user_ID AND post_status = 'private'"; 
    866                                 } 
     856                        if ( is_user_logged_in() ) { 
     857                                if ( 'post' == $post_type ) 
     858                                        $cap = 'edit_private_posts'; 
     859                                else 
     860                                        $cap = 'edit_private_pages'; 
     861 
     862                                if ( current_user_can($cap) ) 
     863                                        $where .= " OR post_status = 'private'"; 
     864                                else 
     865                                $where .= " OR post_author = $user_ID AND post_status = 'private'"; 
    867866                        } 
    868867 
  • trunk/wp-settings.php

    r591 r592  
    259259$_SERVER = add_magic_quotes($_SERVER); 
    260260 
     261do_action('sanitize_comment_cookies'); 
     262 
    261263$wp_query   = new WP_Query(); 
    262264$wp_rewrite = new WP_Rewrite();