Jump to content


Photo

replace URLs in message.


  • Please log in to reply
4 replies to this topic

#1 StirCrazy

StirCrazy
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 10 September 2006 - 06:33 PM

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 :D

Thanks folks,

S.C>

#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 10 September 2006 - 06:47 PM

<?php

$url = parse_url($the_url);
if($url['host'] != 'example.com')
{
	// do stuff here
}
?>

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/m...n.parse-url.php

#3 StirCrazy

StirCrazy
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 10 September 2006 - 07:21 PM

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:-

$msg =

Hi there,

This is a private message from 'test user'.

Have a look at my profile @ http://www.thisdomain.com/myprofile

But I want to send you this spam link http://www.any-other-website.com

Regards,
Test User.



I want http://www.thisdomain.com/myprofile to be let thru (because it's on the same domain)
but
http://www.any-other-website.com to be blanked out.


S.C>

#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 11 September 2006 - 05:53 AM

Couldn't you just type the URL yourself or get it from a config file or form field or something?

#5 StirCrazy

StirCrazy
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 12 September 2006 - 12:38 AM

how do you mean?

still working on this.  I know this is possible - something similar is used in phpbb when 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>




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users