2005-12-17, 09:57 PM
Hi,
I've made a small modification for my own forum and I thought it would be nice to share it. It's meant for passing all urls in postings (excluding email urls) to an external script.
The intention is to effectively disable passing the thread page as referral URL to the external site for privacy or other reasons. Of course a referrer is still passed but it will be the general url of the redirect script, not the exact url of the forum page the link was on.
The URL from the post will be added to the end of the redirect URL (i.e. it will be the last parameter).
You can use some public redirect URL or make the script yourself. Just make sure then that you use a meta redirect (html) instead of a 302 Location redirect HTTP-header, because the latter still passes the original referral URL!
Now the details: it's a change in handling the [url]-tag and involves a new setting under General Configuration.
First, the changed code in functions_post.php. Lookup function doshorturl:
Setting Title : Redirection URL
Description : Enables redirection on all URLs (except email URLs) in posts. URLs will be passed on to the URL you specify here. Leave empty to revert to default (direct linking).
Setting name : redirurl
Setting type : text
Value : (empty or your URL)
Display order : 11
Group : General Configuration (9)
I've made a small modification for my own forum and I thought it would be nice to share it. It's meant for passing all urls in postings (excluding email urls) to an external script.
The intention is to effectively disable passing the thread page as referral URL to the external site for privacy or other reasons. Of course a referrer is still passed but it will be the general url of the redirect script, not the exact url of the forum page the link was on.
The URL from the post will be added to the end of the redirect URL (i.e. it will be the last parameter).
You can use some public redirect URL or make the script yourself. Just make sure then that you use a meta redirect (html) instead of a 302 Location redirect HTTP-header, because the latter still passes the original referral URL!
Now the details: it's a change in handling the [url]-tag and involves a new setting under General Configuration.
First, the changed code in functions_post.php. Lookup function doshorturl:
function doshorturl($url, $name="")
{
//************* added the following line
global $settings; // 17-12-2005 Eegee Mod to use Redirection URL setting
$fullurl = $url;
// attempt to make a bit of sense out of their url if they dont type it properly
if(strpos($url, "www.") === 0)
{
$fullurl = "http://".$fullurl;
}
if(strpos($url, "ftp.") === 0)
{
$fullurl = "ftp://".$fullurl;
}
if(strpos($fullurl, "://") === false)
{
$fullurl = "http://".$fullurl;
}
if(!$name)
{
$name = $url;
}
$name = stripslashes($name);
$url = stripslashes($url);
$fullurl = stripslashes($fullurl);
if($name == $url)
{
if(strlen($url) > 55)
{
$name = substr($url, 0, 40)."...".substr($url, -10);
}
}
//************* added the following 5 lines
// 17-12-2005 Eegee Mod to use Redirection URL
if (isset($settings['redirurl']))
if (trim($settings['redirurl']) != '')
$fullurl = $settings['redirurl'] . rawurlencode($fullurl);
// EOMod
$link = "<a href=\"$fullurl\" target=\"_blank\">$name</a>";
return $link;
}
Second, you need to enter a new setting in the Admin CP, Board settings, Add new setting with the following properties:Setting Title : Redirection URL
Description : Enables redirection on all URLs (except email URLs) in posts. URLs will be passed on to the URL you specify here. Leave empty to revert to default (direct linking).
Setting name : redirurl
Setting type : text
Value : (empty or your URL)
Display order : 11
Group : General Configuration (9)