StirCrazy Posted September 10, 2006 Share Posted September 10, 2006 Is there a simple way to preg_replace none local URLs in a variable.I want to parse $msg and replace any URLs with ####### that don't originate from $mydomain.If you can help you'll get my eternal love n devotion :DThanks folks,S.C> Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted September 10, 2006 Share Posted September 10, 2006 [code]<?php$url = parse_url($the_url);if($url['host'] != 'example.com'){ // do stuff here}?>[/code]I'm not sure what you mean, but this does what I think you mean.You might wan't to read this: http://www.php.net/manual/en/function.parse-url.php Quote Link to comment Share on other sites More sharing options...
StirCrazy Posted September 10, 2006 Author Share Posted September 10, 2006 Cheers Daniel ~ having a look now. Think that function just spits up urls (but reading now so not sure)What I wat to do is:-[b]$msg =[/b][quote]Hi there,This is a private message from 'test user'.Have a look at my profile @ http://www.thisdomain.com/myprofileBut I want to send you this spam link http://www.any-other-website.comRegards,Test User.[/quote]I want [i]http://www.thisdomain.com/myprofile[/i] to be let thru (because it's on the same domain)but[i]http://www.any-other-website.com[/i] to be blanked out.S.C> Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted September 11, 2006 Share Posted September 11, 2006 Couldn't you just type the URL yourself or get it from a config file or form field or something? Quote Link to comment Share on other sites More sharing options...
StirCrazy Posted September 12, 2006 Author Share Posted September 12, 2006 how do you mean?still working on this. I know this is possible - something similar is used in phpbb when [url][/url] tags are automatically put round links. Could use the same principle to identify and check links before choosing to blank out urls or not.S.C> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.