Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Auto link URLs
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Auto link URLs

 Post Reply Post Reply Page  123>
Author
User123 View Drop Down
Newbie
Newbie


Joined: 11 March 2007
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote User123 Quote  Post ReplyReply Direct Link To This Post Topic: Auto link URLs
    Posted: 31 March 2007 at 6:58am
Unless I'm missing an option somewhere it appears that WebWiz does not auto detect URLs in posts and make them hyperlinks.  Is there a mod already to do this?  Just wanted to check before I embarked on adding this feature on my own Smile

TIA
Back to Top
User123 View Drop Down
Newbie
Newbie


Joined: 11 March 2007
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote User123 Quote  Post ReplyReply Direct Link To This Post Posted: 02 April 2007 at 5:52am
Well I guess no one has done this.  I've added this feature on my own to the functions_format_post.asp file.
Back to Top
wistex View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 30 August 2003
Location: United States
Status: Offline
Points: 877
Post Options Post Options   Thanks (0) Thanks(0)   Quote wistex Quote  Post ReplyReply Direct Link To This Post Posted: 02 April 2007 at 7:17am
I think IE automatically turns it into a link, but Firefox does not, if I recall.
Back to Top
User123 View Drop Down
Newbie
Newbie


Joined: 11 March 2007
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote User123 Quote  Post ReplyReply Direct Link To This Post Posted: 02 April 2007 at 10:09pm
Neither IE nor FF find URLs and make them clickable without add-ons.

If anyone wants it, here is my current code for converting URLs typed into messages without [ URL ] [ / URL ] tags.

As always, use at your own risk - it may not be fully debugged or handle every scenario.

This goes in the file functions\functions_format_post.asp at the end of the FormatForumCodes function right before the final return value assignment (FormatForumCodes = strMessage).


Edit: (4/17/07) See post below for current source code.


Edited by User123 - 17 April 2007 at 10:21am
Back to Top
freakyfred View Drop Down
Groupie
Groupie


Joined: 29 March 2007
Location: United Kingdom
Status: Offline
Points: 171
Post Options Post Options   Thanks (0) Thanks(0)   Quote freakyfred Quote  Post ReplyReply Direct Link To This Post Posted: 03 April 2007 at 11:17am
thanks mate. Good of you to share :)
Back to Top
User123 View Drop Down
Newbie
Newbie


Joined: 11 March 2007
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote User123 Quote  Post ReplyReply Direct Link To This Post Posted: 05 April 2007 at 4:44am
Well, if you used that piece of code above please copy it again and overwrite the previous code.  I was referencing the wrong variable in both preprocessing loops which would in some cases cause an infinite loop.  I also reversed the preprocessing steps (images first, then anchors) for better performance.
Back to Top
freakyfred View Drop Down
Groupie
Groupie


Joined: 29 March 2007
Location: United Kingdom
Status: Offline
Points: 171
Post Options Post Options   Thanks (0) Thanks(0)   Quote freakyfred Quote  Post ReplyReply Direct Link To This Post Posted: 11 April 2007 at 1:35pm
For some reason(not sure why) if you install this it will disrupt the flash tags.
Back to Top
User123 View Drop Down
Newbie
Newbie


Joined: 11 March 2007
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote User123 Quote  Post ReplyReply Direct Link To This Post Posted: 11 April 2007 at 4:41pm
Anything that uses URLs in it needs to be stripped before looking for un-coded URLs.  That's why the pre-processing loops remove img and anchor tags.  We don't allow Flash and other embedded objects on our forums so I hadn't accounted for that.

Assuming the Flash codes uses the "embed" tags to insert videos the following code should fix the problems:

    'CLAN MOD START - find uncoded URLs and turn into clickable URLs
    dim testMsg, testPos
    testMsg = strMessage
    'PRE-PROCESS STEPS (remove URLs which already have valid codes around them)
    'remove images
    lngStartPos = InStr(1, testMsg, "<img", 1)
    While lngStartPos > 0
        lngEndPos = Instr(lngStartPos, testMsg, ">", 1)
        if lngEndPos = 0 then
            lngEndPos = len(testMsg)+1
        else
            lngEndPos = lngEndPos + 1
        end if
        strMessageLink = Mid(testMsg,lngStartPos,lngEndPos-lngStartPos)
        testMsg = replace(testMsg, strMessageLink, "")
        lngStartPos = InStr(1, testMsg, "<img", 1)
    Wend
    'remove linked URLs
    lngStartPos = InStr(1, testMsg, "<a", 1)
    While lngStartPos > 0
        lngEndPos = Instr(lngStartPos, testMsg, "</a", 1)
        if lngEndPos = 0 then
            lngEndPos = len(testMsg)+1
        else
            lngEndPos = lngEndPos + 4
        end if
        strMessageLink = Mid(testMsg,lngStartPos,lngEndPos-lngStartPos)
        testMsg = replace(testMsg, strMessageLink, "")
        lngStartPos = InStr(1, testMsg, "<a", 1)
    Wend
    'remove Flash links
    lngStartPos = InStr(1, testMsg, "[flash", 1)
    While lngStartPos > 0
        lngEndPos = Instr(lngStartPos, testMsg, "[/flash", 1)
        if lngEndPos = 0 then
            lngEndPos = len(testMsg)+1
        else
            lngEndPos = lngEndPos + 8
        end if
        strMessageLink = Mid(testMsg,lngStartPos,lngEndPos-lngStartPos)
        testMsg = replace(testMsg, strMessageLink, "")
        lngStartPos = InStr(1, testMsg, "[flash", 1)
    Wend
    'look for uncoded URLs
    lngStartPos = InStr(1, testMsg, "http://", 1)
    if lngStartPos = 0 then lngStartPos = InStr(1, testMsg, "https://", 1)
    if lngStartPos = 0 then lngStartPos = InStr(1, testMsg, "ftp://", 1)
    if lngStartPos = 0 then lngStartPos = InStr(1, testMsg, "mailto:", 1)
    While lngStartPos > 0
        'determine full URL by finding the first "break" type character
        lngEndPos = Instr(lngStartPos, testMsg, " ", 1)
        testPos = Instr(lngStartPos, testMsg, "&nbsp;", 1)
        if lngEndPos = 0 or (testPos > 0 and testPos < lngEndPos) then lngEndPos = testPos
        testPos = Instr(lngStartPos, testMsg, VbCr)
        if lngEndPos = 0 or (testPos > 0 and testPos < lngEndPos) then lngEndPos = testPos
        testPos = Instr(lngStartPos, testMsg, "<", 1)
        if lngEndPos = 0 or (testPos > 0 and testPos < lngEndPos) then lngEndPos = testPos
        if lngEndPos = 0 then    'no break character found, assume end of message
            lngEndPos = len(testMsg)+1
        end if
        'extract link
        strMessageLink = Mid(testMsg,lngStartPos,lngEndPos-lngStartPos)
        'remove from test message so we don't process it again
        testMsg = replace(testMsg, strMessageLink, "")
        'turn into clickable URL in main message
        strMessage = replace(strMessage,strMessageLink, "<a href=""" & strMessageLink & """>" & strMessageLink & "</a>", 1, -1, 1)
        'look for next link
        lngStartPos = InStr(1, testMsg, "http://", 1)
        if lngStartPos = 0 then lngStartPos = InStr(1, testMsg, "https://", 1)
        if lngStartPos = 0 then lngStartPos = InStr(1, testMsg, "ftp://", 1)
        if lngStartPos = 0 then lngStartPos = InStr(1, testMsg, "mailto:", 1)
    wend
    'CLAN MOD END - find uncoded URLs and turn into clickable URLs



Edit: (4/18/07) Fixed bug in Flash tag processing


Edited by User123 - 18 April 2007 at 2:42pm
Back to Top
 Post Reply Post Reply Page  123>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.