View Full Version : Extract domains from string
01-18-2010, 05:21 PM
I have a forum script, and I would like get all the domains (array?) from a string and compare it against the current domain to prevent users from linking "off-site".
Now, this would mess with images offsite, so I was wondering if anybody would help me accomplish this with REGEX to comply with the bbcode
Please and thank you,
01-18-2010, 05:26 PM
Do you have any code already? if you have all the URL's already (by the forum code giving you them) all you need to do is use parse_url() and then get the domain from that
01-18-2010, 05:30 PM
Not really, when I stated Forum Script, I was referring to my purpose for needing this.
This is what I came up with I think, but it wouldn't work for the BBCode...
$url = preg_match('/http:\/\/\s+/', $message, $results);
The only other time I have seen this asked on the Web (after hours of searching Google & popular sites) is here
and it still wasn't solved. :(
Thanks for your time,
01-18-2010, 05:37 PM
what forum software are you using? There will probably already be a mod for this
01-18-2010, 05:38 PM
I made my own script, but the problem is extracting domain names from BBCode.
01-18-2010, 05:40 PM
Should work for you. It will return the domain in $results
01-18-2010, 05:43 PM
Thanks so much for your help. Would anybody mind implementing the BBCode
into this? I suck at REGEX. :(
01-18-2010, 05:53 PM
Try implementing this class
If that one doesn't work, try more "php bbcode class" googles and see what it brings up. Should find one that will do it
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.