RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

[NEED HELP/SCRIPT] Automatic HTML Link maker

Nott32

Wanderer
[NEED HELP/SCRIPT] Automatic HTML Link maker

I have a script that will feed all the latest news posted in a specified topic of my phpBB forum but it does not automatically parse links. Is there a easy to use add on for my website that will automatically parse any links that have http://... in them? It needs to be easy to add to my website and does not need to have anything to do with phpBB.
 

mordero

Knight
this will parse most http:// links, but im sure i forgot some characters to check. Also it doesnt really check if the links are actuall links, just if they look like a link.
example:
PHP:
$string = "so whats up in the house. here is a link http://www.google.com/ http://www.mordero.com";
$string = preg_replace( "@(http://[a-zA-z0-9\.]*[/a-zA-z0-9\.?=&%~]*)@i", '<a href="\1">\1</a>', $string );
print $string;

would output

Code:
[SIZE=2]so whats up in the house. here is a link [/SIZE][SIZE=2][COLOR=#008000]<a [/COLOR][/SIZE][SIZE=2][COLOR=#008000]href[/COLOR][/SIZE][SIZE=2]=[/SIZE][SIZE=2][COLOR=#0000f0]"http://www.google.com/"[/COLOR][/SIZE][SIZE=2][COLOR=#008000]>[/COLOR][/SIZE][SIZE=2]http://www.google.com/[/SIZE][SIZE=2][COLOR=#008000]</a>[/COLOR][/SIZE][SIZE=2][COLOR=#008000]<a [/COLOR][/SIZE][SIZE=2][COLOR=#008000]href[/COLOR][/SIZE][SIZE=2]=[/SIZE][SIZE=2][COLOR=#0000f0]"http://www.mordero.com"[/COLOR][/SIZE][SIZE=2][COLOR=#008000]>[/COLOR][/SIZE][SIZE=2]http://www.mordero.com[/SIZE][SIZE=2][COLOR=#008000]</a>[/COLOR][/SIZE]
 

mordero

Knight
yep no problem :) and you might want to test that against some more URLs that you can think of and make sure it works and if not just tell me what they are and ill adjust it.
 

Nott32

Wanderer
Yea I noticed that the script will parse anythig withe the [url.][/url.] but not straight links, the script worked perfect I may use this on other scripts (credit where due).
 

Nott32

Wanderer
I meant the news script, your script worked well but it kept messing up my images...like the img code..
 

mordero

Knight
ahhhh ok, well give me an example of the stuff you want it to look in and replace links in and ill see what i can do
 
Top