Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

anonym.to - URL redirection hack

edited January 2009 in Vanilla 1.0 Help
(Disclaimer: This is a rather small "hack", probably does not really qualify as an addon.)

I run a small private board, which is meant to be kept private. Here is something I came up with to hide the referer in URLs as people click a link from the board.

1)
(Using the default theme "vanilla", I copied the file "comments.php" from "/themes" to "/themes/vanilla".

2)
Then I went looking for a line where the "Body" of a comment is attached to the HTML container.
The line looks like this:
$CommentList .= '<div class="CommentBody" id="CommentBody_'.$Comment->CommentID.'">'; $CommentList .= $Comment->Body.' </div> </li>';

3)
I changed this line to:
$CommentList .= '<div class="CommentBody" id="CommentBody_'.$Comment->CommentID.'">'; $CommentList .= preg_replace_callback( "/href=\"http:\/\/(.*)\"/", create_function( '$matches', ' if (!is_array($matches) || (is_array($matches) && count($matches) == 0)) { return \'\'; } if (strstr($matches[0], \'http://anonym.to\')) { return $matches[0]; } if (strstr($matches[0], $Configuration[\'BASE_URL\'])) { return $matches[0]; } $str = str_replace(\'href="\', \'\', $matches[0]); $str = str_replace(\'"\', \'\', $str); $str = \'href="http://anonym.to/?\' . urlencode($str) . \'"\'; return $str; ' ), ), $Comment->Body ); $CommentList .= ' </div> </li>';

(Please note: The first line is just for reference and remains unchanged.)

This seems to be working with the latest vanilla (as of yesterday 1.0), I also have the following extensions installed: Attachment, Audioscrobbelerizer, CommentRemoval, Flickerizer, HTMLFormatter, New Applicants, Participate Threads, Quicktags and RSS2Feed.

I guess you can (ab)use this hack to do all sorts of things, like adding a frame to outgoing links, click tracking and so on.

Errata #1: Small bugfix.
Errata #2: Fixed so redirection is only applied to external links and not to attachments.

Cheers,
Till

Comments

  • this doesn't work for me - can someone tell me if there's something simple missing from the code (like a semi colon, or an else, etc) :D ty!
Sign In or Register to comment.