Source for file trackback.php
Documentation is available at trackback.php
* This file handles trackback requests
* This file is part of Quam Plures - {@link http://quamplures.net/}
* See also {@link https://launchpad.net/quam-plures}.
* @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
* @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
* Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
* {@internal License choice
* - If you have received this file as part of a package, please find the license.txt file in
* the same folder or the closest folder above for complete license terms.
* - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
* then you must choose one of the following licenses before using the file:
* - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
* - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
* {@internal Open Source relicensing agreement:
* Daniel HAHLER grants Francois PLANQUE the right to license
* Daniel HAHLER's contributions to this file and the b2evolution project
* under any OSI approved OSS license (http://www.opensource.org/licenses/).
* {@internal Below is a list of authors who have contributed to design/coding of this file: }}
* @author blueyed: Daniel HAHLER
* @author fplanque: Francois PLANQUE
require_once dirname(__FILE__ ). '/../qp_config/_config.php';
require_once $inc_path. '_main.inc.php';
* Send a trackback response and exits.
* @param integer Error code
* @param string Error message
echo '<?xml version="1.0" encoding="'. $io_charset. '"?'. ">\n";
echo "<error>$error</error>\n";
echo "<message>$error_message</message>\n";
// statuses allowed for acting on:
$show_statuses = array( 'published', 'protected', 'private' );
param( 'tb_id', 'integer' );
param( 'url', 'string' );
param( 'title', 'string' );
param( 'excerpt', 'html' );
param( 'blog_name', 'string' );
{ // No parameter for ID, get if from URL:
$path_elements = explode( '/', $ReqPath, 30 );
$tb_id = intval( $path_elements[count($path_elements)- 1] );
if( ! empty($_GET['__mode']) )
{ // some MT extension (AFAIK), that we do not support
@header('Content-Type: text/xml');
if( !( $commented_Item = & $ItemCache->get_by_ID( $tb_id, false ) ) )
if( !( $Blog = & $commented_Item->get_Blog() ) )
if( ! $Blog->get('allowtrackbacks') )
trackback_response( 1, 'Sorry, this weblog does not allow you to trackback its posts.' ); // exits
// Commented out again, because it's comment specific: if( ! $commented_Item->can_comment( NULL ) )
// "BeforeTrackbackInsert" should be hooked instead!
if( $commented_Item->comment_status != 'open' )
$Messages->add( T_('Supplied URL is invalid: '). $error, 'error' );
if( $Messages->count('error') )
$title = (strlen($title) > 255) ? substr($title, 0, 252). '...' : $title;
$excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252). '...' : $excerpt;
$blog_name = (strlen($blog_name) > 255) ? substr($blog_name, 0, 252). '...' : $blog_name;
$comment .= '<strong>'. $title. '</strong>';
{ // comment should not be empty!
$Messages->add( T_('Please do not send empty comment'), 'error' );
* @global Comment Trackback object
$Comment->set( 'type', 'trackback' );
$Comment->set_Item( $commented_Item );
$Comment->set( 'author', $blog_name );
$Comment->set( 'author_url', $url );
$Comment->set( 'author_IP', $Hit->IP );
$Comment->set( 'date', date('Y-m-d H:i:s', $localtimenow ) );
$Comment->set( 'content', $comment );
// Assign default status for new comments:
$Comment->set( 'status', $commented_Item->Blog->get_setting('new_feedback_status') );
// Trigger event, which may add a message of category "error":
$Plugins->trigger_event( 'BeforeTrackbackInsert', array( 'Comment' => & $Comment ) );
if( $errstring = $Messages->get_string( 'Cannot insert trackback, please correct these errors:', '' ) )
// tblue> Note: the spec at <http://www.sixapart.com/pronet/docs/trackback_spec>
// only shows error code 1 in the example response
// and we also only check for code 1 in TB answers.
// Record trackback into DB:
// Exit silently! Wz don't want to give an easy tool to try and pass the filters.
* ----------------------------
* New trackback notification:
* ----------------------------
// TODO: dh> this should only send published feedback probably and should also use "outbound_notifications_mode"
$Comment->send_email_notifications();
// Trigger event: a Plugin should cleanup any temporary data here..
// fp>> WARNING: won't be called if trackback gets deleted by antispam
$Plugins->trigger_event( 'AfterTrackbackInsert', array( 'Comment' => & $Comment ) );
// fp>TODO: warn about moderation
|