Changeset 150
- Timestamp:
- 12/30/07 13:08:48 (5 years ago)
- Location:
- trackback
- Files:
-
- 1 added
- 5 modified
-
files/icon/trackbackActive.png (added)
-
files/lib/system/event/listener/ThreadPageTrackbackListener.class.php (modified) (1 diff)
-
files/lib/util/AkismetUtil.class.php (modified) (2 diffs)
-
files/lib/util/TrackbackUtil.class.php (modified) (14 diffs)
-
package.xml (modified) (4 diffs)
-
templates/postTrackback.tpl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trackback/files/lib/system/event/listener/ThreadPageTrackbackListener.class.php
r138 r150 29 29 excerpt, 30 30 url, 31 blog_name 31 blog_name, 32 UNIX_TIMESTAMP(time) AS time 32 33 FROM wbb".WBB_N."_trackback 33 34 WHERE postID IN (".$eventObj->postList->postIDs."); "; -
trackback/files/lib/util/AkismetUtil.class.php
r1 r150 32 32 * <b>Usage:</b> 33 33 * <code> 34 * $akismet = new Akismet(' http://www.example.com/blog/', 'aoeu1aoue');34 * $akismet = new Akismet('aoeu1aoue', 'http://www.example.com/blog/'); 35 35 * $akismet->setCommentAuthor($name); 36 36 * $akismet->setCommentAuthorEmail($email); … … 77 77 /** 78 78 * @throws Exception An exception is thrown if your API key is invalid. 79 * @param string $blogURL The URL of your blog. 79 80 * @param string Your WordPress API key. 80 * @param string $blogURL The URL of your blog.81 81 */ 82 82 public function __construct($blogURL, $wordPressAPIKey) -
trackback/files/lib/util/TrackbackUtil.class.php
r149 r150 18 18 /** 19 19 * fetchs necessery postdata 20 * @param postIDs 21 * @return array20 * @param postIDs int[] list of postids with possible trackback data 21 * @return mixed[] including all threaddata + threadurl 22 22 */ 23 23 public static function getPost($postIDs) { … … 46 46 47 47 /** 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 55 55 */ 56 56 public static function getRDF($postPermalink, $postID, $postTopic, $postPreview, $postUsername, $postTime) { 57 57 $postPermalink = StringUtil::decodeHTML($postPermalink); 58 58 $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); 59 62 return '<link rel="pingback" href="'.$page_url.'index.php?action=Pingback" /> 60 63 <!-- … … 65 68 rdf:about="'.$postPermalink.'" 66 69 dc:identifier="'.$postPermalink.'" 67 trackback:ping=" index.php?action=Trackback&postID='.$postID.'"70 trackback:ping="'.$page_url.'index.php?action=Trackback&postID='.$postID.'" 68 71 dc:title="'.$postTopic.'" 69 72 dc:subject="TrackBack" … … 77 80 /** 78 81 * 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 85 88 */ 86 89 public static function save($postID, $postURL, $title, $excerpt, $url, $blog_name) { 87 90 // akismet check spam 88 91 $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); 89 99 90 100 // insert trackback data … … 97 107 url, 98 108 blog_name, 109 time, 99 110 isSpam 100 111 ) VALUES ( … … 105 116 '".escapeString($url)."', 106 117 '".escapeString($blog_name)."', 107 $isSpam 118 NOW(), 119 ".intval($isSpam)." 108 120 );"; 109 121 … … 113 125 /** 114 126 * 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 122 134 */ 123 135 public static function trackAndPing($postID, $alienurl, $page_title, $author, $url, $title, $excerpt) { … … 149 161 /** 150 162 * 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 155 168 */ 156 169 protected static function isSpam($title, $excerpt, $url, $blog_name) { 157 170 if(AKISMET_API_KEY == '') 158 return true;171 return false; 159 172 160 173 // WCF includes 161 174 require_once(WCF_DIR.'lib/util/AkismetUtil.class.php'); 162 175 163 $akismet = new AkismetUtil(AKISMET_API_KEY, PAGE_URL);176 $akismet = new AkismetUtil(AKISMET_API_KEY, PAGE_URL); 164 177 $akismet->setCommentType('trackback'); 165 178 $akismet->setPermalink($myurl); //absolute … … 175 188 /** 176 189 * 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) 180 193 */ 181 194 protected static function discover_pingback_uri($url, &$contents) { … … 262 275 /** 263 276 * 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) 267 280 */ 268 281 protected static function discover_trackback_uri($contents, $url) { … … 293 306 /** 294 307 * Send a Pingback 295 * @param alienurl -> the main url from the destination site296 * @param pingbackurl -> the pingback url from the destination site297 * @param url -> theown url298 * @return true if success308 * @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 299 312 */ 300 313 protected static function send_pingback($alienurl, $pingbackurl, $url) { … … 323 336 /** 324 337 * 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 331 345 */ 332 346 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); 335 349 $title = urlencode($title); 336 350 $excerpt = urlencode($excerpt); 337 351 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}"; 339 353 340 354 $parse = parse_url($trackbackurl); … … 356 370 /** 357 371 * saves log 358 * @param postID 359 * @param alienURL 372 * @param postID int postID 373 * @param alienURL string alienURL 360 374 */ 361 375 protected static function save_log($postID, $alienurl) { … … 371 385 );"; 372 386 373 @WBBCore::getDB()->sendQuery($sql); 387 @WBBCore::getDB()->sendQuery($sql); // ignore error messages... 374 388 } 375 389 } -
trackback/package.xml
r149 r150 6 6 <packagedescription>Allows sending and receiving from track- and pingbacks.</packagedescription> 7 7 <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> 9 9 <date>DATE</date> 10 10 <plugin>com.woltlab.wbb</plugin> … … 36 36 </instructions> 37 37 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 38 44 <instructions type="update" fromversion="0.1.1"> 39 45 <files>files.tar</files> … … 42 48 <languages languagecode="de-informal">de-informal.xml</languages> 43 49 <languages languagecode="en">en.xml</languages> 50 <sql>update.sql</sql> 44 51 </instructions> 45 52 … … 50 57 <languages languagecode="de-informal">de-informal.xml</languages> 51 58 <languages languagecode="en">en.xml</languages> 59 <sql>update.sql</sql> 52 60 </instructions> 53 61 </package> -
trackback/templates/postTrackback.tpl
r138 r150 1 1 {assign var="trackbackPostID" value=$post->getID()} 2 2 {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> 4 4 {/if} 5 5 {if $postTrackbacks[$trackbackPostID]|isset} … … 10 10 {foreach from=$postTrackbacks[$trackbackPostID] item=trackback} 11 11 <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> 13 13 <li>{$trackback.excerpt}</li> 14 14 </ul></li>
