View Single Post
  #6 (permalink)  
Old 08-11-2002, 08:57 AM
full time kille's Avatar
full time kille full time kille is offline
Novice Webmaster
 
Join Date: Dec 2001
Location: m'sia
Posts: 51
Rep Power: 88
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 !
Reply With Quote