Jump to content

Archived

This topic is now archived and is closed to further replies.

StirCrazy

replace URLs in message.

Recommended Posts

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>

Share this post


Link to post
Share on other sites
[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

Share this post


Link to post
Share on other sites
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/myprofile

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

Regards,
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>

Share this post


Link to post
Share on other sites
Couldn't you just type the URL yourself or get it from a config file or form field or something?

Share this post


Link to post
Share on other sites
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>

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.