Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Link redirections

I want to pass all external links posted on the vanilla forum through a php file which would redirect visitors to that link after recording the click

Currently, i have Vanilla version 2.0.18.8 & for example, http://www.xyz.com opens that xyz website

I want all extrnal links to have this "http://www.mywebsite.com/go.php=" prefixed before all external links which would make the link look like 'http://www.mywebsite.com/go.php=http://www.xyz.com'

How do i modify the core in such a way that outgoing links are passed through that script? Which file should i edit?

Tagged:

Comments

  • Options
    hgtonighthgtonight ∞ · New MVP

    There are a couple ways of doing this. This is how I would do it.

    I would attach some javascript with my theme hooks file. Did you have a library in mind that you want to use? You would definitely want to encode the url that you are passing as a var via post.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    Hi @hgtonight I'd like to achieve the same system as the OP and I'm wondering what's the best way to do this ?

    thanks !

  • Options
    hgtonighthgtonight ∞ · New MVP

    My previous suggestion of a JS solution would be okay, since there is no easy way to override the Gdn_Format::Links($Mixed) method without redefining the entire class.

    Use the trusted domains list (C('Garden.TrustedDomains')) and jQuery to automatically encode the Url of anchor tags that are not relative or in the list. This obviously requires the client to have JS enabled for the tracking to occur.

    You could overwrite the Gdn_Format class with your custom handling of links and then this would all be done server side (meaning no need for JS).

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    Hi @hgtonight,

    Thank you. I definitely want it to be server-side.

    I saw that links like Youtube are automatically embedded so maybe I can do something similar: detecting all link and rewrite them with website.com/r.php?url=encoded&member=john

    I'll take a look at the Gdn_Format class, thanks again !

Sign In or Register to comment.