A TrackBack is a comment, except when it’s spam

A TrackBack at Sam Ruby’s that may or may not be spam, but sure looks like it to me, together with my increasingly crabby assessment of the results of TrackBack autodiscovery (I would hate it even if it didn’t have a bug that leads to multiple pinging, since “a TrackBack is a comment”, but not every link is a comment) made me think that it would be handy to have the “new TrackBack ping” notification email, usually a joyous thing, include a link to edit (and thus delete pings from) the entry or category that was pinged. Fortunately, it’s an easy hack, although the added bits are spread out a bit, so I’ll give you the whole “if we are sending email” bit to replace.

You’ll need to edit {your MT directory}/lib/MT/App/Trackback.pm, down around line 214 if you haven’t done any other hacking in it. New bits are highlighted, so you can see what mischief I’m getting up to:

MT 2.51 Version:

    if ($blog->email_new_pings) {
        require MT::Mail;
        my($author, $what, $editlink);
        my $path = MT::ConfigMgr->instance->CGIPath;
        $path .= '/' unless $path =~ m!/$!;
        if ($entry) {
            $author = $entry->author;
            $what = "entry " . $entry->id . " (" . $entry->title . ")";
            $editlink = $path . "mt.cgi?__mode=view&_type=entry&id=" .
             $entry->id . "&blog_id=" . $blog->id;
        } elsif ($cat) {
            require MT::Author;
            $author = MT::Author->load($cat->created_by);
            $what = "category " . $cat->id . " (" . $cat->label . ")";
            $editlink = $path . "mt.cgi?__mode=tb_cat_pings&blog_id=" .
             $blog->id . "&category_id=" . $cat->id;
        }
        if ($author && $author->email) {
            my %head = ( To => $author->email,
                         From => $author->email,
                         Subject =>
                             '[' . $blog->name . '] New TrackBack Ping to ' .
                             $what );
            MT::Mail->send(\%head, <<BODY);
A new TrackBack ping has been sent to your blog, on the
$what.
IP Address: @{[ $ping->ip ]} URL: @{[ $ping->source_url ]} Ping Title: @{[ $ping->title ]} Weblog: @{[ $ping->blog_name ]}
Excerpt: @{[ $ping->excerpt ]}
Edit at $editlink BODY } }

MT 2.6 Version:

    if ($blog->email_new_pings) {
        require MT::Mail;
        my($author, $subj, $body, $editlink);
        my $path = MT::ConfigMgr->instance->CGIPath;
        $path .= '/' unless $path =~ m!/$!;
        if ($entry) {
            $author = $entry->author;
            $subj = $app->translate('New TrackBack Ping to Entry [_1] ([_2])',
                $entry->id, $entry->title);
            $editlink = $path . "mt.cgi?__mode=view&_type=entry&id=" .
             $entry->id . "&blog_id=" . $blog->id;
            $body = $app->translate('A new TrackBack ping has been sent to your weblog, on the entry [_1] ([_2])', $entry->id, $entry->title);
        } elsif ($cat) {
            require MT::Author;
            $author = MT::Author->load($cat->created_by);
            $subj = $app->translate('New TrackBack Ping to Category [_1] ([_2])',
                $cat->id, $cat->label);
            $editlink = $path . "mt.cgi?__mode=tb_cat_pings&blog_id=" .
             $blog->id . "&category_id=" . $cat->id;
            $body = $app->translate('A new TrackBack ping has been sent to your weblog, on the category [_1] ([_2])', $cat->id, $cat->label);
        }
        if ($author && $author->email) {
            my %head = ( To => $author->email,
                         From => $author->email,
                         Subject => '[' . $blog->name . '] ' . $subj );
            my $charset = $app->{cfg}->PublishCharset || 'iso-8859-1';
            $head{'Content-Type'} = qq(text/plain; charset="$charset");
            require Text::Wrap;
            $Text::Wrap::cols = 72;
            $body = Text::Wrap::wrap('', '', $body) . "\n\n" .
                 $app->translate('IP Address:') . ' ' . $ping->ip . "\n" .
                 $app->translate('URL:') . ' ' . $ping->source_url . "\n" .
                 $app->translate('Title:') . ' ' . $ping->title . "\n" .
                 $app->translate('Weblog:') . ' ' . $ping->blog_name . "\n\n" .
                 $app->translate('Excerpt:') . "\n" . $ping->excerpt . "\n\n" .
                 "Edit at " . $editlink;
                 
            MT::Mail->send(\%head, $body);
        }
    }

I wish I could say something like “Enjoy!”, but, at least it’s better than clicking your way through from the main menu when you need to use it.

6 Comments

Comment by Dirk #
2004-01-10 10:32:21

Spamming defense is getting very technical.

 
Trackback by Sam Ruby #
2003-02-08 05:43:44

Spam Updates

OK, now that I have verified that spamAssasin is working correctly on my mail to blog interface, I’m adding one line: if title.find(’*****SPAM*****’)==0: return Also, as Phil has already pointed out, I’m also getting getting TrackBack spam. My incl

 
Trackback by Sam Ruby #
2003-02-09 07:38:42

Trackback policy

True, but this provides an interesting example of how I approach problems and protocols. Wen you look it it, even though the end results apears to be much different, the fundamentals we both are applying are basically the same. Phil identified this tr

 
Trackback by A young man's Weblog #
2003-02-12 08:42:10

Watch out for spam pinging

Is a Trackback spam? Is a Trackback collector in danger?

 
Trackback by Neil's World #
2003-06-13 01:10:50

Trackback Hack

I came across this hack on phil ringnalda dot com. It adds more functionality to the trackback notification emails, so that there is a link to the entry edit screen – the idea being that it is easier to remove unwanted pings.

 
2004-10-27 03:25:54

MT finess

som jag lagt till är möjlighet att i trackbackmailet klicka på redigeringslänken direkt och inte först måsta logga in i…

 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <del datetime="" cite=""> <dd> <dl> <dt> <em> <i> <ins datetime="" cite=""> <kbd> <li> <ol> <p> <pre> <q cite=""> <samp> <strong> <sub> <sup> <ul> in your comment.