Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-11-2002, 01:25 PM
full time kille's Avatar
Novice Webmaster
 
Join Date: Dec 2001
Location: m'sia
Posts: 51
Rep Power: 87
full time kille is on a distinguished road
how to make function that automatically parse url

like this board, if we write some url that started with http:// its automatically parse that url..

so i wanna make it like that but using asp.. I know how to parse smilies.. it like this

PHP Code:
Replace(MESSAGE,":(","<img src=""images/emoticons/frown.gif"" border=""0"" width=""15"" height=""15"" alt=""frown"">"
i tried to make it, but i still dont get it.. so anyone expert here.. can you explain how to make it to me ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-11-2002, 11:46 PM
kpyew's Avatar
Senior Webmaster
 
Join Date: Jul 2001
Location: KL, Malaysia
Posts: 277
Rep Power: 95
kpyew is on a distinguished road
Send a message via ICQ to kpyew
This is a quick hack for parsing url. You should be able to improve on this and come up with a function that does what you want... Share with us on your progress

Thanks.

PHP Code:
<%
    
str "Here you are [url]http://kong.com[/url] ssss sss"
    
loc1 InStr(str"http://")
    
loc2 InStr(loc1str" ")
    
    if (
loc1 > -1) and (loc2 > -1) and (loc1 loc2then
        url 
Mid(strloc1loc2-loc1)
        
first_part Mid(str1loc1-1)
        
second_part Mid(strloc2len(str))
    elseif(
loc1 > -1) and (loc1 len(str)) then
        loc2 
len(str)
        
        
url Mid(strloc1loc2-loc1+1)
        
first_part Mid(str1loc1-1)
        
second_part ""        
    
end if
    
    
response.write first_part "<a href=" url ">" url "</a>" second_part
%> 
__________________
webmaster @ http://kongtechnology.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-11-2002, 11:49 PM
kpyew's Avatar
Senior Webmaster
 
Join Date: Jul 2001
Location: KL, Malaysia
Posts: 277
Rep Power: 95
kpyew is on a distinguished road
Send a message via ICQ to kpyew
Beware.... this board actually parsed some of my codes (the url) above... so, you need to modify a bit if you wanted to test it.
__________________
webmaster @ http://kongtechnology.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-11-2002, 07:26 AM
full time kille's Avatar
Novice Webmaster
 
Join Date: Dec 2001
Location: m'sia
Posts: 51
Rep Power: 87
full time kille is on a distinguished road
thanx dude !

actually i had break in snitz forum function to find a solution.. but the code is so complicated and hard to me to understand (i'm still a beginner).. it also long too..

but your code is so simple and its just a few lines..

p/s: you're my master !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-11-2002, 10:15 AM
kpyew's Avatar
Senior Webmaster
 
Join Date: Jul 2001
Location: KL, Malaysia
Posts: 277
Rep Power: 95
kpyew is on a distinguished road
Send a message via ICQ to kpyew
I guess you will need to make my code into a function or something and let it run through your MESSAGE repeatedly to parse all occurences of urls (Currently, it only parse the first occurence).

Can you paste the Snitz forum function here to share with us??

Thanks.
__________________
webmaster @ http://kongtechnology.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 08-11-2002, 08:57 AM
full time kille's Avatar
Novice Webmaster
 
Join Date: Dec 2001
Location: m'sia
Posts: 51
Rep Power: 87
full time kille is on a distinguished road
actually this snitzs function using javascript to..

vbscript:
[php]function chkUrls(fString, fTestTag, fType)

Dim strArray
Dim Counter
Dim strTempString

strTempString = fString
if Instr(1, fString, fTestTag) > 0 then
strArray = Split(fString, fTestTag, -1)
strTempString = strArray(0)
for counter = 1 to UBound(strArray)
if ((strArray(counter-1) = "" or len(strArray(counter-1)) < 5) and strArray(counter)<> "") then
strTempString = strTempString & edit_hrefs("" & fTestTag & strArray(counter), fType)
elseif ((UCase(right(strArray(counter-1),6)) <> "HREF=""") and (UCase(right(strArray(counter-1),5)) <> "[url]") and (UCase(right(strArray(counter-1),6)) <> "[url=""") and (UCase(right(strArray(counter-1),7)) <> "FILE:///") and (UCase(right(strArray(counter-1),7)) <> "HTTP://") and (UCase(right(strArray(counter-1),8)) <> "HTTPS://") and (UCase(right(strArray(counter-1),5)) <> "SRC=""") and (UCase(right(strArray(counter-1),5)) <> "SRC=""") and strArray(counter)<> "") then
strTempString = strTempString & edit_hrefs("" & fTestTag & strArray(counter), fType)
else
strTempString = strTempString & fTestTag & strArray(counter)
end if
next
end if

chkUrls = strTempString

end function[/php]

javascript:
PHP Code:
function edit_hrefs(s_htmltype){
    
s_str = new String(s_html);
    if (
type == 1) {
         
s_str s_str.replace(/b(http://[w+.]+[w+.:/_?=&-#\%\~\;\,\$\!\+\*]+)/gi,
          
"<a href=\"$1\" target=\"_blank\">$1<\/a>");
    } 
    if (
type == 2) {

        
s_str s_str.replace(/b(https://[w+.]+[w+.:/_?=&-#\%\~\;\,\$\!\+\*]+)/gi,
          
"<a href=\"$1\" target=\"_blank\">$1<\/a>");
    }
    if (
type == 3) {
        
s_str s_str.replace(/b(file:///w:[w+/w+.:/_?=&-#\%\~\;\,\$\!\+\*]+)/gi,
          
"<a href=\"$1\" target=\"_blank\">$1<\/a>");
    }
    if (
type == 4) {

        
s_str s_str.replace(/b(www.[w+.:/_?=&-#\%\~\;\,\$\!\+\*]+)/gi,
           
"<a href=\"http://$1\" target=\"_blank\">$1</a>");
    }
    if (
type == 5) {
        
s_str s_str.replace(/b([w+-#\%\.\_\,\$\!\+\*]+@[\w+\.?\-\'\#\%\~\_\.\;\,\$\!\+\*]*)/gi,
           
"<a href=\"mailto\:$1\">$1</a>");
    }
    if (
type == 6) {
         
s_str s_str.replace(/b(ftp://[w+.]+[w+.:/_?=&-#\%\~\;\,\$\!\+\*]+)/gi,
          
"<a href=\"$1\" target=\"_blank\">$1<\/a>");
    } 
    return 
s_str;

and..
PHP Code:
fString ChkUrls(fString,"http://"1)
    
fString ChkUrls(fString,"https://"2)
    
fString ChkUrls(fString,"file:///"3)
    
fString ChkUrls(fString,"www."4)
    
fString ChkUrls(fString,"mailto:",5
i think this is all of it.. i've test it and it work !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 08-11-2002, 05:59 PM
kpyew's Avatar
Senior Webmaster
 
Join Date: Jul 2001
Location: KL, Malaysia
Posts: 277
Rep Power: 95
kpyew is on a distinguished road
Send a message via ICQ to kpyew
Ha... we should be able to convert that javascript into ASP or other server side code. I will try when I am free.
__________________
webmaster @ http://kongtechnology.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
make link exchange function in wordpress Rezats Website Programming 3 05-09-2005 01:03 AM
Parse error therion Website Programming 25 20-05-2004 02:41 PM
print function ardella Website Programming 2 13-05-2004 12:50 AM
stripslashes() function for JSP? lcf Website Programming 3 21-04-2004 10:06 PM
How to make "Tell a friends" & "Newsletter" session function? brutalasia Website Design 10 12-06-2003 09:16 AM


All times are GMT +8. The time now is 10:56 AM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61