Show
Ignore:
Timestamp:
12/25/07 18:07:52 (5 years ago)
Author:
d0nut
Message:

release of version 0.1 - so many things are working :)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trackback/files/lib/util/TrackbackUtil.class.php

    r138 r141  
    11<?php 
    22// import seorewriter 
     3require_once(WCF_DIR.'lib/util/StringUtil.class.php'); 
    34require_once(WCF_DIR.'lib/page/PublicSEORewriter.class.php'); 
    45require_once(WCF_DIR.'lib/util/FileUtil.class.php'); 
     
    1213 */ 
    1314class TrackbackUtil { 
    14         protected static $agent = 'Woltlab Burning Board Trackback Mod'; 
     15        public static $agent = 'WBB Trackback Mod'; 
    1516        protected static $timeout_bytes = 51200; 
    1617 
     
    3940                 
    4041                // public seo rewriter use 
    41                 $row['url'] = $rewriter->publicParseThreadURLs($row['threadID'], ''); 
     42                $row['url'] = StringUtil::decodeHTML(FileUtil::addTrailingSlash(PAGE_URL).$rewriter->publicParseThreadURLs($row['threadID'], '')); 
    4243                 
    4344                return $row; 
     
    5455         */ 
    5556        public static function getRDF($postPermalink, $postID, $postTopic, $postPreview, $postUsername, $postTime) { 
    56                 $postPermalink = html_entity_decode($postPermalink); 
     57                $postPermalink = StringUtil::decodeHTML($postPermalink); 
    5758                $page_url = FileUtil::addTrailingSlash(PAGE_URL); 
    5859                return '<link rel="pingback" href="'.$page_url.'index.php?action=Pingback" /> 
     
    133134                // send pingbacks 
    134135                foreach($pingbacks as $pingbackurl) { 
    135                         self::send_pingback($alienurl, $pingbackurl, $page_title, $url); 
    136                         self::save_log($postID, $alienurl); 
     136                        if(self::send_pingback($alienurl, $pingbackurl, $url)) { 
     137                                self::save_log($postID, $alienurl); 
     138                        } 
    137139                } 
    138140 
    139141                // send trackbacks 
    140142                foreach($trackbacks as $trackbackurl) { 
    141                         self::send_trackback($trackbackurl, $page_title, $author, $url, $title, $excerpt); 
    142                         self::save_log($postID, $alienurl); 
     143                        if(self::send_trackback($trackbackurl, $page_title, $author, $url, $title, $excerpt)) { 
     144                                self::save_log($postID, $alienurl); 
     145                        } 
    143146                } 
    144147        } 
     
    247250                        } 
    248251                        $byte_count += strlen($line); 
    249                         if ( $byte_count > $timeout_bytes ) { 
     252                        if ( $byte_count > self::$timeout_bytes ) { 
    250253                                // It's no use going further, there probably isn't any pingback 
    251254                                // server to find in this file. (Prevents loading large files.) 
     
    293296         * @param pingbackurl -> the pingback url from the destination site 
    294297         * @param url -> the own url 
     298         * @return true if success 
    295299         */ 
    296300        protected static function send_pingback($alienurl, $pingbackurl, $url) { 
    297301                require_once(WBB_DIR.'lib/util/IXR.class.php'); 
     302                extract(parse_url($pingbackurl), EXTR_SKIP); 
     303                 
     304                if ( !isset($host) ) // Not an URL. This should never happen. 
     305                        return false; 
     306 
     307                $path  = ( !isset($path) ) ? '/'          : $path; 
     308                $path .= ( isset($query) ) ? '?' . $query : ''; 
     309                $port  = ( isset($port)  ) ? $port        : 80; 
    298310 
    299311                // using a timeout of 3 seconds should be enough to cover slow servers 
    300                 $client = new IXR_Client($pingbackurl); 
     312                $client = new IXR_Client($host, $path); 
    301313                $client->timeout = 3; 
    302314                $client->useragent = self::$agent; 
     
    306318 
    307319                // Already registered 
    308                 if ($client->query('pingback.ping', $url, $alienurl) || (isset($client->error->code) && 48 == $client->error->code)) { 
    309                         add_ping($post_ID, $alienurl); 
    310                 } 
     320                return $client->query('pingback.ping', $url, $alienurl) || (isset($client->error->code) && 48 == $client->error->code); 
    311321        } 
    312322 
     
    340350                @fputs($fs, $http_request); 
    341351                @fclose($fs); 
     352                 
     353                return $fs; 
    342354        } 
    343355