Lange
Легенда
Всем доброго времени суток. Возникла необходимость мода редирект ссылок. Нашёл мод который мне нужен, но он под старую версию TP. Прощу помощи адаптации под новую версию.
Файлы:
go.php
robots.txt
bbcode.php найти:
Заменить на это:
bbcode.tpl найти:
Заменить на это:
Файлы:
go.php
PHP:
<?php
header('Location: '.urldecode($_GET['url']));
?>
Код:
User-agent: *
Disallow: /go.php
bbcode.php найти:
PHP:
function make_clickable ($text)
{
global $bb_cfg;
$url_regexp = "#
(?<![\"'=])
\b
(
(https?://|ftp://|www\.|ftp\.)
[\w\#!$%&~/.\-;:=?@\[\]+]+
)
(?![\"']|\[/url|\[/img|</a)
(?=[,!]?\s|[\)<!])
#xi";
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);
// pad it with a space so we can match things at the start of the 1st line.
$ret = " $text ";
if ($bb_cfg['parse_ed2k_links'])
{
// ed2k file links (Meithar):
// ed2k://|file|fileName|fileSize|fileHash|(optional params)|(optional params)|etc|
$ret = preg_replace_callback("#\b(ed2k://\|file\|([^\\/\|:<>\*\?\"]+?)\|(\d+?)\|([a-f0-9]{32})\|(.*?)/?)(?![\"'])(?=([,\.]*?[\s<\[])|[,\.]*?$)#i", "ed2k_link_callback", $ret);
// ed2k server links:
// ed2k://|server|serverIP|serverPort
$ret = preg_replace("#\b(ed2k://\|server\|([\d\.]+?)\|(\d+?)\|/?)\B#i", "<a href=\"\\1\" class=\"postLink\">\\2:\\3</a>", $ret);
}
// hide passkey
$ret = preg_replace('#\?'. $bb_cfg['passkey_key'] .'=[a-zA-Z0-9]{'. BT_AUTH_KEY_LENGTH .'}&#', '?passkey&', $ret);
// hide sid
$ret = preg_replace('#([\?&;])sid=[a-zA-Z0-9]{'. SID_LENGTH .'}#', '$1sid', $ret);
// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
// xxxx can only be alpha characters.
// yyyy is anything up to the first space, newline, comma, double quote or <
# $ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" class=\"postLink\">\\2</a>", $ret);
$ret = preg_replace_callback($url_regexp, 'make_url_clickable_callback', $ret);
// matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
// zzzz is optional.. will contain everything up to the first space, newline,
// comma, double quote or <.
# $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" class=\"postLink\">\\2</a>", $ret);
// matches an email@domain type address at the start of a line, or after a space.
// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
$ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\" class=\"postLink\">\\2@\\3</a>", $ret);
// Remove our padding..
$ret = substr(substr($ret, 0, -1), 1);
return($ret);
}
/**
* Nathan Codding - Feb 6, 2001
* Reverses the effects of make_clickable(), for use in editpost.
* - Does not distinguish between "www.xxxx.yyyy" and "http://aaaa.bbbb" type URLs.
*
*/
function undo_make_clickable($text)
{
$text = preg_replace("#<!-- BBCode auto-link start --><a href=\"(.*?)\">.*?</a><!-- BBCode auto-link end -->#i", "\\1", $text);
$text = preg_replace("#<!-- BBcode auto-mailto start --><a href=\"mailto:(.*?)\">.*?</a><!-- BBCode auto-mailto end -->#i", "\\1", $text);
return $text;
}
Заменить на это:
PHP:
function make_clickable ($text)
{
global $bb_cfg;
$url_regexp = "#
(?<![\"'=])
\b
(
(https?://|ftp://|www\.|ftp\.)
[\w\#!$%&~/.\-;:=?@\[\]+]+
)
(?![\"']|\[/url|\[/img|</a)
(?=[,!]?\s|[\)<!])
#xi";
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);
// pad it with a space so we can match things at the start of the 1st line.
$ret = ' ' . $text;
if ($bb_cfg['parse_ed2k_links'])
{
// ed2k file links (Meithar):
// ed2k://|file|fileName|fileSize|fileHash|(optional params)|(optional params)|etc|
$ret = preg_replace_callback("#\b(ed2k://\|file\|([^\\/\|:<>\*\?\"]+?)\|(\d+?)\|([a-f0-9]{32})\|(.*?)/?)(?![\"'])(?=([,\.]*?[\s<\[])|[,\.]*?$)#i", "ed2k_link_callback", $ret);
// ed2k server links:
// ed2k://|server|serverIP|serverPort
$ret = preg_replace("#\b(ed2k://\|server\|([\d\.]+?)\|(\d+?)\|/?)\B#i", "<a href=\"\\1\" class=\"postLink\">\\2:\\3</a>", $ret);
}
// hide passkey
$ret = preg_replace('#\?'. $bb_cfg['passkey_key'] .'=[a-zA-Z0-9]{'. BT_AUTH_KEY_LENGTH .'}&#', '?passkey&', $ret);
// hide sid
$ret = preg_replace('#([\?&;])sid=[a-zA-Z0-9]{'. SID_LENGTH .'}#', '$1sid', $ret);
// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
// xxxx can only be alpha characters.
// yyyy is anything up to the first space, newline, comma, double quote or <
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://site.ru/go.php?url=\\2\" target=\"_blank\" rel=\"nofollow\" class=\"postLink\">\\2</a>", $ret);
// matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
// zzzz is optional.. will contain everything up to the first space, newline,
// comma, double quote or <.
$ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://site.ru/go.php?url=http://\\2\" target=\"_blank\" rel=\"nofollow\" class=\"postLink\">\\2</a>", $ret);
// matches an email@domain type address at the start of a line, or after a space.
// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
$ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
// Remove our padding..
$ret = substr($ret, 1);
return($ret);
}
/**
* Nathan Codding - Feb 6, 2001
* Reverses the effects of make_clickable(), for use in editpost.
* - Does not distinguish between "www.xxxx.yyyy" and "http://aaaa.bbbb" type URLs.
*
*/
function undo_make_clickable($text)
{
$text = preg_replace("#<!-- BBCode auto-link start --><a href=\"http://site.ru/go.php?url=(.*?)\" target=\"_blank\">.*?</a><!-- BBCode auto-link end -->#i", "\\1", $text);
$text = preg_replace("#<!-- BBcode auto-mailto start --><a href=\"mailto:(.*?)\">.*?</a><!-- BBCode auto-mailto end -->#i", "\\1", $text);
return $text;
}
bbcode.tpl найти:
HTML:
<!-- BEGIN url --><a href="{URL}" class="postLink">{DESCRIPTION}</a><!-- END url -->
Заменить на это:
HTML:
<!-- BEGIN url --><a href="http://site.ru/go.php?url={URL}" {NOFOLLOW} target="_blank" class="postlink">{DESCRIPTION}</a><!-- END url -->