Johnnnnny1986 Posted February 28, 2006 Share Posted February 28, 2006 Ok im having problems stoping site links being posted on my wap site im using php 4 and i can only manage to stop certain links i want to stop all i use this code to stop one link$gbvalues=str_replace('http://www.site.co.uk','<img src="image/hatespammers.gif" alt="(hatespammers)',$gbvalues);and that replaces the link with my hate spammers icon. But it only stops [a href=\"http://www.site.co.uk\" target=\"_blank\"]http://www.site.co.uk[/a] from being put up in the forums. Please help thanks in advanced Quote Link to comment https://forums.phpfreaks.com/topic/3745-site-links-help/ Share on other sites More sharing options...
obsidian Posted February 28, 2006 Share Posted February 28, 2006 [!--quoteo(post=350192:date=Feb 28 2006, 08:22 AM:name=Johnnnnny)--][div class=\'quotetop\']QUOTE(Johnnnnny @ Feb 28 2006, 08:22 AM) [snapback]350192[/snapback][/div][div class=\'quotemain\'][!--quotec--]Ok im having problems stoping site links being posted on my wap site im using php 4 and i can only manage to stop certain links i want to stop all i use this code to stop one link$gbvalues=str_replace('http://www.site.co.uk','<img src="image/hatespammers.gif" alt="(hatespammers)',$gbvalues);and that replaces the link with my hate spammers icon. But it only stops [a href=\"http://www.site.co.uk\" target=\"_blank\"]http://www.site.co.uk[/a] from being put up in the forums. Please help thanks in advanced[/quote]welcome to the forums! i hope you find a great deal of help here as i have. let's back up a step... in your forums, do you allow HTML to be entered? if so, you may just be able to run strip_tags() with a list of exceptions that you want to allow. that way, if you strip out all <a> tags, you'll get rid of all links. if you're not using HTML, if you can explain what text one has to write to produce a link, we can help you come up with a regex or pattern match to find and remove all links from a given set of text.good luck! Quote Link to comment https://forums.phpfreaks.com/topic/3745-site-links-help/#findComment-12985 Share on other sites More sharing options...
Johnnnnny1986 Posted February 28, 2006 Author Share Posted February 28, 2006 [!--quoteo(post=350193:date=Feb 28 2006, 08:25 AM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ Feb 28 2006, 08:25 AM) [snapback]350193[/snapback][/div][div class=\'quotemain\'][!--quotec--]welcome to the forums! i hope you find a great deal of help here as i have. let's back up a step... in your forums, do you allow HTML to be entered? if so, you may just be able to run strip_tags() with a list of exceptions that you want to allow. that way, if you strip out all <a> tags, you'll get rid of all links. if you're not using HTML, if you can explain what text one has to write to produce a link, we can help you come up with a regex or pattern match to find and remove all links from a given set of text.good luck![/quote]thanks ill have a look at that put could you tell me how i can set the site to become src="image/hatespammers.gif" alt="(hatespammers)' please Quote Link to comment https://forums.phpfreaks.com/topic/3745-site-links-help/#findComment-12992 Share on other sites More sharing options...
obsidian Posted February 28, 2006 Share Posted February 28, 2006 [!--quoteo(post=350200:date=Feb 28 2006, 08:33 AM:name=Johnnnnny)--][div class=\'quotetop\']QUOTE(Johnnnnny @ Feb 28 2006, 08:33 AM) [snapback]350200[/snapback][/div][div class=\'quotemain\'][!--quotec--]thanks ill have a look at that put could you tell me how i can set the site to become src="image/hatespammers.gif" alt="(hatespammers)' please[/quote]well, if you want to replace ALL links in a block of text with that image, i would probably do something like this:[code]function dieSpammers($String) { $find = "|\<a(.+?)\>(.+?)\</a\>|i"; $replace = "<img src=\"image/hatespammers.gif\" alt=\"(hatespammers)\" />"; $String = preg_replace($find, $replace, $String); return $String;}echo dieSpammers($myText);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/3745-site-links-help/#findComment-12998 Share on other sites More sharing options...
Johnnnnny1986 Posted February 28, 2006 Author Share Posted February 28, 2006 [!--quoteo(post=350207:date=Feb 28 2006, 08:43 AM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ Feb 28 2006, 08:43 AM) [snapback]350207[/snapback][/div][div class=\'quotemain\'][!--quotec--]well, if you want to replace ALL links in a block of text with that image, i would probably do something like this:[code]function dieSpammers($String) { $find = "|\<a(.+?)\>(.+?)\</a\>|i"; $replace = "<img src=\"image/hatespammers.gif\" alt=\"(hatespammers)\" />"; $String = preg_replace($find, $replace, $String); return $String;}echo dieSpammers($myText);[/code][/quote]Thanks Quote Link to comment https://forums.phpfreaks.com/topic/3745-site-links-help/#findComment-13000 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.