html - PHP - remove http/www from message (except for the host domain) to disable clickable links -


i have simple message board, let's say: mywebsite.com, allows users post messages. board makes links clickable, ie. when posts starts with:

http://, https://, www., http://www., https://www. 

then script automatically makes them links (ie. adds href.. tag).

the problem - there spam. idea automatically remove above http|s/www these don't become 'clickable links.' however, want allow posters link pages within site, ie. not remove http|s/www when message contains link/s mywebsite.com.

my idea create 2 arrays:

$removeparts = array('http://', 'https://', 'www.', 'http://www.', 'https://www.');  $keepparts = array('http://mywebsite.com', 'http://www.mywebsite.com', 'www.mywebsite.com', 'http://mywebsite.com', 'https://www.mywebsite.com', 'https://mywebsite.com'); 

but don't know how use them correctly (probably str_replace work somehow).

below example of $message before posting , after posting:

$message before:

hello world, http://mywebsite/about learned lot. found on http://www.bing.com, https://google.com/search , on www.spamwebsite.com/refid=spammer2.

$message after:

hello world, http://mywebsite.com/about learned lot. found on bing.com, google.com/search , on spamwebsite.com/refid=spammer2.


please note user enters clear text post form, script should work clear text (not href etc.).

$url = "http://mywebsite/about"; $parse = parse_url($url);  if($parse["host"] == "mywebsite")     echo "my site, let's mark link"; 

more info: http://php.net/manual/en/function.parse-url.php


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -