OK so maybe this may be of use to others but... what i want to do is intercept all outbound links in a forum (SMF) and change the links to go through a jump page first: -
SMF handles the censored word filter as follows (Seems as good a place as any, unless we dive in to display.php instead??)
In load.php: -
// Replace all vulgar words with respective proper words. (substring or whole words..)
function &censorText(&$text)
{
global $modSettings, $options, $settings, $txt;
static $censor_vulgar = null, $censor_proper;
if ((!empty($options['show_no_censored']) && $settings['allow_no_censored']) || empty($modSettings['censor_vulgar']))
return $text;
// If they haven't yet been loaded, load them.
if ($censor_vulgar == null)
{
$censor_vulgar = explode("\n", $modSettings['censor_vulgar']);
$censor_proper = explode("\n", $modSettings['censor_proper']);
// Quote them for use in regular expressions.
for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++)
{
$censor_vulgar[$i] = strtr(preg_quote($censor_vulgar[$i], '/'), array('\\\\\\*' => '[*]', '\\*' => '[^\s]*?', '&' => '&'));
$censor_vulgar[$i] = (empty($modSettings['censorWholeWord']) ? '/' . $censor_vulgar[$i] . '/' : '/(?<=^|\W)' . $censor_vulgar[$i] . '(?=$|\W)/') . (empty($modSettings['censorIgnoreCase']) ? '' : 'i') . ((empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8' ? 'u' : '');
if (strpos($censor_vulgar[$i], '\'') !== false)
{
$censor_proper[count($censor_vulgar)] = $censor_proper[$i];
$censor_vulgar[count($censor_vulgar)] = strtr($censor_vulgar[$i], array('\'' => '''));
}
}
}
// Censoring isn't so very complicated :P.
$text = preg_replace($censor_vulgar, $censor_proper, $text);
return $text;
}
So what i want to do is also change all outbounds to
www.forum.com/outbound?link=originalURLCensored words filter as it stands cant do this so we have to step in and add some code to match urls then swap out
Perhaps along the lines of: -
(Excuse the following bollocks)
preg_match_all('/<a href="(.+?)" title=\"(.+?)" target=\"_blank\">/', $text, $fixedtext);
then add the forum.com/outbound?link= to the front and return $text
?? or am i making no sense?