Jump to content


Photo

Site links help


  • Please log in to reply
4 replies to this topic

#1 Johnnnnny1986

Johnnnnny1986
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 28 February 2006 - 01:22 PM

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

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 28 February 2006 - 01:25 PM

[!--quoteo(post=350192:date=Feb 28 2006, 08:22 AM:name=Johnnnnny)--][div class=\'quotetop\']QUOTE(Johnnnnny @ Feb 28 2006, 08:22 AM) View Post[/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!
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 Johnnnnny1986

Johnnnnny1986
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 28 February 2006 - 01:33 PM

[!--quoteo(post=350193:date=Feb 28 2006, 08:25 AM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ Feb 28 2006, 08:25 AM) View Post[/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

#4 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 28 February 2006 - 01:43 PM

[!--quoteo(post=350200:date=Feb 28 2006, 08:33 AM:name=Johnnnnny)--][div class=\'quotetop\']QUOTE(Johnnnnny @ Feb 28 2006, 08:33 AM) View Post[/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:
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);

You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#5 Johnnnnny1986

Johnnnnny1986
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 28 February 2006 - 01:49 PM

[!--quoteo(post=350207:date=Feb 28 2006, 08:43 AM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ Feb 28 2006, 08:43 AM) View Post[/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:
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);
[/quote]

Thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users