Changeset 150

Show
Ignore:
Timestamp:
12/30/07 13:08:48 (5 years ago)
Author:
d0nut
Message:
  • added documentation
  • added time to incoming trackbacks
  • shortended rdf-description to 255 chars
  • encoded incoming trackback-data to html entities (XSS secure)
  • added icon for active trackbacks
Location:
trackback
Files:
1 added
5 modified

Legend:

Unmodified
Added
Removed
  • trackback/files/lib/system/event/listener/ThreadPageTrackbackListener.class.php

    r138 r150  
    2929                                                excerpt,  
    3030                                                url,  
    31                                                 blog_name 
     31                                                blog_name, 
     32                                                UNIX_TIMESTAMP(time) AS time 
    3233                                FROM            wbb".WBB_N."_trackback 
    3334                                WHERE           postID IN (".$eventObj->postList->postIDs."); "; 
  • trackback/files/lib/util/AkismetUtil.class.php

    r1 r150  
    3232 *  <b>Usage:</b> 
    3333 *  <code> 
    34  *    $akismet = new Akismet('http://www.example.com/blog/', 'aoeu1aoue'); 
     34 *    $akismet = new Akismet('aoeu1aoue', 'http://www.example.com/blog/'); 
    3535 *    $akismet->setCommentAuthor($name); 
    3636 *    $akismet->setCommentAuthorEmail($email); 
     
    7777        /** 
    7878         *      @throws Exception       An exception is thrown if your API key is invalid. 
     79         *      @param  string  $blogURL                        The URL of your blog. 
    7980         *      @param  string  Your WordPress API key. 
    80          *      @param  string  $blogURL                        The URL of your blog. 
    8181         */ 
    8282        public function __construct($blogURL, $wordPressAPIKey) 
  • trackback/files/lib/util/TrackbackUtil.class.php

    r149 r150  
    1818        /** 
    1919         * fetchs necessery postdata 
    20          * @param postIDs 
    21          * @return array 
     20         * @param postIDs       int[]           list of postids with possible trackback data 
     21         * @return              mixed[]         including all threaddata + threadurl 
    2222         */ 
    2323        public static function getPost($postIDs) { 
     
    4646         
    4747        /** 
    48          * 
    49          * @param postPermalink 
    50          * @param postID 
    51          * @param postTopic 
    52          * @param postPreview 
    53          * @param postUsername 
    54          * @param postTime 
     48         * returns rdf string 
     49         * @param postPermalink         string          permalink 
     50         * @param postID                int             postid 
     51         * @param postTopic             string          posttopic 
     52         * @param postPreview           string          postpreview 
     53         * @param postUsername          string          postusername 
     54         * @param postTime              int             posttime as unix timestamp 
    5555         */ 
    5656        public static function getRDF($postPermalink, $postID, $postTopic, $postPreview, $postUsername, $postTime) { 
    5757                $postPermalink = StringUtil::decodeHTML($postPermalink); 
    5858                $page_url = FileUtil::addTrailingSlash(PAGE_URL); 
     59                $postPreview = str_replace(array("\n","\r"), ' ', $postPreview); 
     60                $postPreview = str_replace(array("    ","   ","  "), ' ', $postPreview); 
     61                $postPreview = substr($postPreview, 0, 255); 
    5962                return '<link rel="pingback" href="'.$page_url.'index.php?action=Pingback" /> 
    6063<!-- 
     
    6568        rdf:about="'.$postPermalink.'" 
    6669        dc:identifier="'.$postPermalink.'" 
    67         trackback:ping="index.php?action=Trackback&postID='.$postID.'" 
     70        trackback:ping="'.$page_url.'index.php?action=Trackback&postID='.$postID.'" 
    6871        dc:title="'.$postTopic.'" 
    6972        dc:subject="TrackBack" 
     
    7780        /** 
    7881         * saves incoming ping/trackback 
    79          * @param postID 
    80          * @param postURL 
    81          * @param title 
    82          * @param excerpt 
    83          * @param url 
    84          * @param blog_name 
     82         * @param postID                int             postid 
     83         * @param postURL               string          post-/thread-url 
     84         * @param title                 string          title 
     85         * @param excerpt               string          excerpt 
     86         * @param url                   string          url 
     87         * @param blog_name             string          blog_name 
    8588         */ 
    8689        public static function save($postID, $postURL, $title, $excerpt, $url, $blog_name) { 
    8790                // akismet check spam 
    8891                $isSpam = self::isSpam($title, $excerpt, $url, $blog_name); 
     92                 
     93                // escape html characters 
     94                $postURL = StringUtil::encodeHTML($postURL); 
     95                $title = StringUtil::encodeHTML($title); 
     96                $excerpt = StringUtil::encodeHTML($excerpt); 
     97                $url = StringUtil::encodeHTML($url); 
     98                $blog_name = StringUtil::encodeHTML($blog_name); 
    8999         
    90100                // insert trackback data 
     
    97107                                        url,  
    98108                                        blog_name, 
     109                                        time, 
    99110                                        isSpam 
    100111                        ) VALUES ( 
     
    105116                                        '".escapeString($url)."', 
    106117                                        '".escapeString($blog_name)."', 
    107                                         $isSpam 
     118                                        NOW(), 
     119                                        ".intval($isSpam)." 
    108120                        );"; 
    109121 
     
    113125        /** 
    114126         * does track and ping operations on alien urls 
    115          * @param postID 
    116          * @param alienurl 
    117          * @param page_title 
    118          * @param author 
    119          * @param url 
    120          * @param title 
    121          * @param excerpt 
     127         * @param postID                int             postid 
     128         * @param alienurl              string          url in content - ping and trackback here 
     129         * @param page_title            string          own forum title 
     130         * @param author                string          own author 
     131         * @param url                   string          own url 
     132         * @param title                 string          own post title 
     133         * @param excerpt               string          own excerpt 
    122134         */ 
    123135        public static function trackAndPing($postID, $alienurl, $page_title, $author, $url, $title, $excerpt) { 
     
    149161        /** 
    150162         * akismet check 
    151          * @param title 
    152          * @param excerpt 
    153          * @param url 
    154          * @param blog_name 
     163         * @param title                 string          incoming title 
     164         * @param excerpt               string          incoming excerpt 
     165         * @param url                   string          incoming url 
     166         * @param blog_name             string          incoming blog_name 
     167         * @return                      boolean         true, if spam 
    155168         */      
    156169        protected static function isSpam($title, $excerpt, $url, $blog_name) { 
    157170                if(AKISMET_API_KEY == '') 
    158                         return true; 
     171                        return false; 
    159172                 
    160173                // WCF includes 
    161174                require_once(WCF_DIR.'lib/util/AkismetUtil.class.php'); 
    162175 
    163                 $akismet = new AkismetUtil(AKISMET_API_KEY,PAGE_URL); 
     176                $akismet = new AkismetUtil(AKISMET_API_KEY, PAGE_URL); 
    164177                $akismet->setCommentType('trackback'); 
    165178                $akismet->setPermalink($myurl); //absolute 
     
    175188        /** 
    176189         * discover pingback uri 
    177          * @param url 
    178          * @param contents (reference) 
    179          * @return pingbacks 
     190         * @param url                   string          the alien url 
     191         * @param contents (reference)  string          empty variable - but the content of the alien url will be returned here 
     192         * @return pingbacks            string[]        the pingbacks of the alien url (should be just one) 
    180193         */ 
    181194        protected static function discover_pingback_uri($url, &$contents) { 
     
    262275        /** 
    263276         * discover trackback uri 
    264          * @param contents 
    265          * @param url 
    266          * @return trackbacks 
     277         * @param contents              string          html content to parse 
     278         * @param url                   string          the url, which should allow trackback:ping 
     279         * @return trackbacks           string[]        the trackbacks of the alien url (should be just one) 
    267280         */ 
    268281        protected static function discover_trackback_uri($contents, $url) { 
     
    293306        /** 
    294307         * Send a Pingback 
    295          * @param alienurl -> the main url from the destination site 
    296          * @param pingbackurl -> the pingback url from the destination site 
    297          * @param url -> the own url 
    298          * @return true if success 
     308         * @param alienurl              string          the url, we want to ping 
     309         * @param pingbackurl           string          the pingback url from the destination site (e.g. xmlrpc.php) 
     310         * @param url                   string          our own url 
     311         * @return                      boolean         true if success 
    299312         */ 
    300313        protected static function send_pingback($alienurl, $pingbackurl, $url) { 
     
    323336        /** 
    324337         * Send a Trackback 
    325          * @param trackbackurl 
    326          * @param page_title 
    327          * @param author 
    328          * @param url 
    329          * @param title 
    330          * @param excerpt 
     338         * @param trackbackurl          string          the url, we want to trackback 
     339         * @param page_title            string          own forum title 
     340         * @param author                string          own author (ignored) 
     341         * @param url                   string          own url 
     342         * @param title                 string          own post title 
     343         * @param excerpt               string          own excerpt 
     344         * @return                      resource        pointer on socket 
    331345         */ 
    332346        protected static function send_trackback($trackbackurl, $page_title, $author, $url, $title, $excerpt) { 
    333                 $blog_name = urlencode($page_title); 
    334                 $author = urlencode($author); 
     347                $blog_title = urlencode($page_title); 
     348                $url = urlencode($url); 
    335349                $title = urlencode($title); 
    336350                $excerpt = urlencode($excerpt); 
    337351 
    338                 $query_string = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt"; 
     352                $query_string = "title={$title}&url={$url}&blog_name={$blog_title}&excerpt={$excerpt}"; 
    339353 
    340354                $parse = parse_url($trackbackurl); 
     
    356370        /** 
    357371         * saves log 
    358          * @param postID 
    359          * @param alienURL 
     372         * @param postID                int             postID 
     373         * @param alienURL              string          alienURL 
    360374         */ 
    361375        protected static function save_log($postID, $alienurl) { 
     
    371385                        );"; 
    372386 
    373                 @WBBCore::getDB()->sendQuery($sql); 
     387                @WBBCore::getDB()->sendQuery($sql); // ignore error messages... 
    374388        } 
    375389}  
  • trackback/package.xml

    r149 r150  
    66                <packagedescription>Allows sending and receiving from track- and pingbacks.</packagedescription> 
    77                <packagedescription languagecode="de">Das Plugin erlaubt das Senden und Empfangen von Track- und Pingbacks.</packagedescription> 
    8                 <version>0.1.2</version> 
     8                <version>0.1.3</version> 
    99                <date>DATE</date> 
    1010                <plugin>com.woltlab.wbb</plugin> 
     
    3636        </instructions> 
    3737         
     38        <instructions type="update" fromversion="0.1.2"> 
     39                <files>files.tar</files> 
     40                <templates>templates.tar</templates> 
     41                <sql>update.sql</sql> 
     42        </instructions> 
     43         
    3844        <instructions type="update" fromversion="0.1.1"> 
    3945                <files>files.tar</files> 
     
    4248                <languages languagecode="de-informal">de-informal.xml</languages> 
    4349                <languages languagecode="en">en.xml</languages> 
     50                <sql>update.sql</sql> 
    4451        </instructions> 
    4552         
     
    5057                <languages languagecode="de-informal">de-informal.xml</languages> 
    5158                <languages languagecode="en">en.xml</languages> 
     59                <sql>update.sql</sql> 
    5260        </instructions> 
    5361</package> 
  • trackback/templates/postTrackback.tpl

    r138 r150  
    11{assign var="trackbackPostID" value=$post->getID()} 
    22{if $hasTrackbacks[$trackbackPostID]|isset} 
    3         {lang}wbb.thread.post.trackback.active{/lang} 
     3        <h3 style="background-image:url('{@RELATIVE_WBB_DIR}icon/trackbackActive.png');background-repeat:no-repeat;background-position:left bottom;padding-left:20px">{lang}wbb.thread.post.trackback.active{/lang}</h3> 
    44{/if} 
    55{if $postTrackbacks[$trackbackPostID]|isset} 
     
    1010        {foreach from=$postTrackbacks[$trackbackPostID] item=trackback} 
    1111                <li><ul style="list-style-type: none;margin:2px;padding:2px"> 
    12                 <li><a href="{$trackback.url}">{$trackback.title}</a></li> 
     12                <li><a href="{$trackback.url}">{$trackback.title}</a> {'d.m.Y H:i'|gmdate:$trackback.time}</li> 
    1313                <li>{$trackback.excerpt}</li> 
    1414                </ul></li>