Размер файла: 1.34Kb
<?php
FUNCTION LINKS_FILTER($url){
$re = '/["*|><){},+!`(^%]/';
$subst = NULL;
RETURN PREG_REPLACE($re, $subst, $url);
}
FUNCTION LINKS2($arr) {
IF (PREG_MATCH('#^'.SCHEME.PREG_QUOTE(HTTP_HOST).'#', $arr[2]) || !PREG_MATCH('#://#', $arr[2])){
RETURN '<a href="'.LINKS_FILTER($arr[1]).'">'.LINKS_FILTER($arr[2]).'</a>';
}ELSE{
RETURN '<a href="/?get=url&data='.BASE64_ENCODE(HTML_ENTITY_DECODE(LINKS_FILTER($arr[1]))).'">'.LINKS_FILTER($arr[2]).'</a>';
}
}
FUNCTION LINKS3($arr)
{
IF (PREG_MATCH('#^'.SCHEME.PREG_QUOTE(HTTP_HOST).'#', $arr[1])){
RETURN '<a href="'.LINKS_FILTER($arr[1]).'">'.LINKS_FILTER($arr[1]).'</a>';
}ELSE{
RETURN '<a href="/?get=url&data='.BASE64_ENCODE(HTML_ENTITY_DECODE(LINKS_FILTER($arr[1]))).'">'.LINKS_FILTER($arr[1]).'</a>';
}
}
FUNCTION LINKS($msg) {
$pt = "/\[a href=((?!javascript:|data:|document.cookie).+)\](.+)\[\/a\]/isU";
IF (PREG_MATCH($pt, $msg)){
$msg = PREG_REPLACE_CALLBACK($pt, 'LINKS2', $msg);
}ELSE{
IF (STRPOS($msg, 'style') === FALSE && STRPOS($msg, 'img') === FALSE && STRPOS($msg, 'src') === FALSE){
$msg = PREG_REPLACE_CALLBACK('/(?!img)((?:http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(?:\/\S*)?)/', 'LINKS3', $msg);
}
}
RETURN $msg;
}