« Tracの改良b2evolutionにモブログ機能付加 »

comment keyによるtrackback spam撃退

2006/07/30

  16:01:59 by , Categories: b2evolution

Link: http://blogs.da-cha.jp/momokuri.php/2006/07/19/b2evolutiona_strackback_spama_e_c

trackback spamを撃退する改造の変更点は、次のようになる。

b2evocore/_class_item.phpを以下のように修正。



/**
* Template function: displays url to use to trackback this item
*
* {@internal Item::trackback_url(-) }}
*/
function trackback_url()
{
global $htsrv_url, $Settings;
// -- add date key
$trackback_datekey=gmdate("dmy");

if( $Settings->get('links_extrapath') )
{
echo "$htsrv_url/trackback.php/$trackback_datekey$this->ID";
}
else
{
echo "$htsrv_url/trackback.php?tb_id=$this->ID&tb_key=$trackback_datekey";
}
}

つづいて、htsrv/trackback.phpを修正。


param( 'tb_id', 'integer' );
param( 'url', 'string' );
param( 'title', 'string' );
param( 'excerpt', 'html' );
param( 'blog_name', 'string' );
param( 'tb_key', 'integer' );


if(empty($tb_id))
{ // No parameter for ID, get if from URL:
$path_elements = explode( '/', $ReqPath, 30 );
$tb_id = intval(substr( $path_elements[count($path_elements)-1] ,6) );
}

if (empty($tb_key))
{
// No parameter for ID, get if from URL:
$path_elements = explode( '/', $ReqPath, 30 );
$tb_key = intval(substr( $path_elements[count($path_elements)-1] ,0, 6) );
}

if ((strlen(''.$tb_id)) && (empty($HTTP_GET_VARS['__mode'])) && (strlen(''.$url)) && (strlen(''.$tb_key)))

{
@header('Content-Type: text/xml');

$comment_post_ID = $tb_id;
$postdata = get_postdata($comment_post_ID);
$blog = $postdata['Blog'];
$blogparams = get_blogparams_by_ID( $blog );

if( !get_bloginfo('allowtrackbacks', $blogparams) )
{
trackback_response(1, 'Sorry, this weblog does not allow you to trackback its posts.');
}

if( $tb_key != gmdate("dmy") )
{
debug_log('tb_key is differed');
trackback_response(1, 'Sorry, this weblog does not allow you to trackback its posts.');
}


Trackback address for this post

Trackback URL (right click and copy shortcut/link location)

1 trackback

ももくりめも -  ソース読みの毎日

引越し
自分のサイトにBLOGを立ち上げたので、 そちらに引っ越したいと思います。 Momokuri’s Memo - Code readers daily [Japanese] 日本語、英語同時更新を何故か目指しています。 引っ越しした新し…

2006/08/10 @ 12:12

This post has 1 feedback awaiting moderation...


Form is loading...