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.php

    r1792 r1794  
    735735
    736736function pingback($content, $post_ID) {
    737 
    738     global $wp_version;
     737    global $wp_version, $wpdb;
    739738    include_once (ABSPATH . WPINC . '/class-IXR.php');
    740739
    741740    // original code by Mort (http://mort.mine.nu:8080)
    742     $log = debug_fopen('./pingback.log', 'a');
     741    $log = debug_fopen(ABSPATH . '/pingback.log', 'a');
    743742    $post_links = array();
    744743    debug_fwrite($log, 'BEGIN '.date('YmdHis', time())."\n");
     744
     745    $pung = get_pung($post_ID);
    745746
    746747    // Variables
     
    748749    $gunk = '/#~:.?+=&%@!\-';
    749750    $punc = '.:?\-';
    750     $any = $ltrs.$gunk.$punc;
     751    $any = $ltrs . $gunk . $punc;
    751752
    752753    // Step 1
     
    769770    // We don't wanna ping first and second types, even if they have a valid <link/>
    770771
    771     foreach($post_links_temp[0] as $link_test){
    772         $test = parse_url($link_test);
    773         if (isset($test['query'])) {
    774             $post_links[] = $link_test;
    775         } elseif(($test['path'] != '/') && ($test['path'] != '')) {
    776             $post_links[] = $link_test;
    777         }
    778     }
     772    foreach($post_links_temp[0] as $link_test) :
     773        if ( !in_array($link_test, $pung) ) : // If we haven't pung it already
     774            $test = parse_url($link_test);
     775            if (isset($test['query']))
     776                $post_links[] = $link_test;
     777            elseif(($test['path'] != '/') && ($test['path'] != ''))
     778                $post_links[] = $link_test;
     779        endif;
     780    endforeach;
    779781
    780782    foreach ($post_links as $pagelinkedto){
    781 
    782783        debug_fwrite($log, "Processing -- $pagelinkedto\n");
    783784        $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048);
    784785
    785         if($pingback_server_url) {
    786 
     786        if ($pingback_server_url) {
    787787             // Now, the RPC call
    788             $method = 'pingback.ping';
    789             debug_fwrite($log, 'Page Linked To: '.$pagelinkedto."\n");
     788            debug_fwrite($log, "Page Linked To: $pagelinkedto \n");
    790789            debug_fwrite($log, 'Page Linked From: ');
    791790            $pagelinkedfrom = get_permalink($post_ID);
     
    795794            $client = new IXR_Client($pingback_server_url);
    796795            $client->timeout = 3;
    797             $client->useragent .= ' -- WordPress/'.$wp_version;
     796            $client->useragent .= ' -- WordPress/' . $wp_version;
    798797
    799798            // when set to true, this outputs debug messages by itself
    800799            $client->debug = false;
    801800            $client->query('pingback.ping', array($pagelinkedfrom, $pagelinkedto));
    802 
    803             if (!$client->query('pingback.ping', array($pagelinkedfrom, $pagelinkedto))) {
     801           
     802            if ( !$client->query('pingback.ping', array($pagelinkedfrom, $pagelinkedto) ) )
    804803                debug_fwrite($log, "Error.\n Fault code: ".$client->getErrorCode()." : ".$client->getErrorMessage()."\n");
    805             }
    806         }
    807     }
    808 
    809     debug_fwrite($log, "\nEND: ".time()."\n****************************\n\r");
     804            else
     805                add_ping( $post_ID, $pagelinkedto );
     806        }
     807    }
     808
     809    debug_fwrite($log, "\nEND: ".time()."\n****************************\n");
    810810    debug_fclose($log);
    811811}
     
    16081608
    16091609    // Get post-meta info
    1610     if ( $meta_list = $wpdb->get_results("
    1611             SELECT post_id,meta_key,meta_value
    1612             FROM $wpdb->postmeta
    1613             WHERE post_id IN($post_id_list)
    1614             ORDER BY post_id,meta_key
    1615         ", ARRAY_A) ) {
     1610    if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta  WHERE post_id IN($post_id_list) ORDER BY post_id, meta_key", ARRAY_A) ) {
    16161611       
    16171612        // Change from flat structure to hierarchical:
Note: See TracChangeset for help on using the changeset viewer.