mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:38 +01:00
new function activate_links to change url's into links and automaticaly create spam-saver mailto addresses
This commit is contained in:
parent
b074cbf924
commit
d99afd7a11
@ -46,6 +46,32 @@
|
|||||||
$this->phpgwapi_js_url = $GLOBALS['phpgw_info']['server']['webserver_url'].'/phpgwapi/js';
|
$this->phpgwapi_js_url = $GLOBALS['phpgw_info']['server']['webserver_url'].'/phpgwapi/js';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function activate_links($content)
|
||||||
|
{
|
||||||
|
// spamsaver emailaddress
|
||||||
|
$result = preg_replace('/mailto:([a-z0-9._-]+)@([a-z0-9_-]+)\.([a-z0-9._-]+)/i',
|
||||||
|
'<a href="#" onclick="document.location=\'mai\'+\'lto:\\1\'+unescape(\'%40\')+\'\\2.\\3\'; return false;">\\1 AT \\2 DOT \\3</a>',
|
||||||
|
$content);
|
||||||
|
|
||||||
|
// First match things beginning with http:// (or other protocols)
|
||||||
|
$NotAnchor = '(?<!"|href=|href\s=\s|href=\s|href\s=)';
|
||||||
|
$Protocol = '(http|ftp|https):\/\/';
|
||||||
|
$Domain = '([\w]+.[\w]+)';
|
||||||
|
$Subdir = '([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?';
|
||||||
|
$Expr = '/' . $NotAnchor . $Protocol . $Domain . $Subdir . '/i';
|
||||||
|
|
||||||
|
$result = preg_replace( $Expr, "<a href=\"$0\" target=\"_blank\">$2$3</a>", $result );
|
||||||
|
|
||||||
|
// Now match things beginning with www.
|
||||||
|
$NotAnchor = '(?<!"|href=|href\s=\s|href=\s|href\s=)';
|
||||||
|
$NotHTTP = '(?<!:\/\/)';
|
||||||
|
$Domain = 'www(.[\w]+)';
|
||||||
|
$Subdir = '([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?';
|
||||||
|
$Expr = '/' . $NotAnchor . $NotHTTP . $Domain . $Subdir . '/i';
|
||||||
|
|
||||||
|
return preg_replace( $Expr, "<a href=\"http://$0\" target=\"_blank\">$0</a>", $result );
|
||||||
|
}
|
||||||
|
|
||||||
function htmlspecialchars($str)
|
function htmlspecialchars($str)
|
||||||
{
|
{
|
||||||
return htmlspecialchars($str,ENT_COMPAT,$this->charset);
|
return htmlspecialchars($str,ENT_COMPAT,$this->charset);
|
||||||
|
Loading…
Reference in New Issue
Block a user