Hi,

I have a website which is based purely on user-added content.  The
problem with this is that some areas allow users to use links in the
text, and it's difficult to ensure that they all have a decent knowledge
of attributes such as tartget="_new", etc etc.

So, I'd like a script that...

1. looks at $text for any link tags, and for each tag, does the following:

2. throws out everything except the HREF eg:
<A HREF="http://www.somesite.com"; target="_new">click</a> becomes 
http://www.somesite.com
<A HREF="javascript:something();"> becomes javascript:something();

3. prefixe the url with <A HREF="

4. establish if it's an internal or external link:  so how do we
establish if it's an external link? well it'd be easy if we just say
"anything begining with http:// is not relative", but because this
content is user-driven, I'd like to be a little safer, and say "anything
that begins with http://www.mysite.com OR http://mysite.com"; is an
external link.

5. if it's an external link, suffix the URL with " TARGET="_new">, or if
it's internal, suffix it with ">


Anyway, that'd be a great start.  From there, I might like to prex each
external link to go thru a program called out.php to log affiliate
activity, and I might like to retain onmouseover, onclick, onmouseout
etc etc properties in the tag, I might like to ensure a session ID is
found within each internal link, and stripped from each external link,
ensure that the <A> has a matching </A> etc etc, but the above would be
a great start.


Any help, especially with steps 1, 2 & 4, would be much appreciated.


Thanks in advance,

Justin French
http://indent.com.au
http://soundpimps.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to