Welcome to Geeklog, Anonymous Sunday, November 10 2024 @ 06:51 pm EST
Geeklog Forums
Clickable links in forum
Status: offline
romantaran
Forum User
Junior
Registered: 03/19/05
Posts: 34
Location:Russia
How to make clickable links in forum messages? I.e. how to automatically add "a href" tag to hyperlinks?
32
22
Quote
Status: offline
romantaran
Forum User
Junior
Registered: 03/19/05
Posts: 34
Location:Russia
Well, I know how to do it.
Open /plugins/forum/functions.inc
Find function forum_xchsmilies
Add following code before "return $message;"
$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\">$0</a>", $message );
$NotAnchor = '(?<!"|href=|href\s=\s|href=\s|href\s=)';
$NotHTTP = '(?<!:\/\/)';
$Domain = 'www(.[\w]+)';
$Subdir = '([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?';
$Expr = '/' . $NotAnchor . $NotHTTP . $Domain . $Subdir . '/i';
$message = preg_replace( $Expr, "<a href=\"http://$0\" target=\"_blank\">$0</a>", $Result );
That's all!
Open /plugins/forum/functions.inc
Find function forum_xchsmilies
Add following code before "return $message;"
Text Formatted Code
$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\">$0</a>", $message );
$NotAnchor = '(?<!"|href=|href\s=\s|href=\s|href\s=)';
$NotHTTP = '(?<!:\/\/)';
$Domain = 'www(.[\w]+)';
$Subdir = '([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?';
$Expr = '/' . $NotAnchor . $NotHTTP . $Domain . $Subdir . '/i';
$message = preg_replace( $Expr, "<a href=\"http://$0\" target=\"_blank\">$0</a>", $Result );
That's all!
19
20
Quote
All times are EST. The time is now 06:51 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content