Author Topic: Deter comment spam  (Read 6949 times)

0 Members and 1 Guest are viewing this topic.

Offline Bugfixed

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • Lavinya
Deter comment spam
« on: January 20, 2006, 11:56:01 AM »
add comment spammers  adding rel="nofollow" tag  ??? . e.g details.php, image desc., comment. without mywebsite.

similar mod http://www.phpbb.com/phpBB/viewtopic.php?t=259827
<?php echo 'Hello, World!'; ?>

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Deter comment spam
« Reply #1 on: January 20, 2006, 02:08:53 PM »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Bugfixed

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • Lavinya
Re: Deter comment spam
« Reply #2 on: January 20, 2006, 02:32:20 PM »
thanks V@no for reply .

no no.

otomatic added user comment and image desc. add "nofollow" tag . :( for 4images.

example.

<a href="http://www.4homepages.de" rel="nofollow" target="_blank">http://www.4homepages.de</a>
<?php echo 'Hello, World!'; ?>

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Deter comment spam
« Reply #3 on: January 20, 2006, 03:03:21 PM »
You can try replace in includes/functions.php:
Code: [Select]
  $text = str_replace("\\'", "'", $text);
  return replace_badwords($text);
}
With this code:
Code: [Select]
  $text = preg_replace("#(<a href=(\"|')(.*)://(.*)(\"|')(.*)>(.*)</a>)#siUe", "nofollow(\"\\1\",'\\4')", $text);

  $text = str_replace("\\'", "'", $text);
  return replace_badwords($text);
}
function nofollow($text, $url)
{
  $url = str_replace("\\", "/", $url);
  $url = strtolower(substr($url,0,(strlen($url)-strlen(strrchr($url,"/")))));
  if ($url == $_SERVER['SERVER_NAME'] || $url == $_SERVER['SERVER_ADDR']) return $text;
  $text = preg_replace("#<a href=(\"|')(.*)://(.*)(\"|')(.*)>(.*)</a>#iU", "<a href=\\1\\2://\\3\\4\\5 rel=\"nofollow\">\\6</a>", $text);
  return $text;
}
Its quiet dirty fix, and it affects all links that being sent through format_text() function (not only comments)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Bugfixed

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • Lavinya
Re: Deter comment spam
« Reply #4 on: January 20, 2006, 04:15:38 PM »
thanks for your kind.

I added your code. it is successful.

Recent:

1. it is adding "nofollow" tag to other websites and mywebsite in image desc. (it must not add it to url of mysite)

2. it is adding "nofollow" tag to other websites not adding mywebsite. (There is no problem user comment)

if you answer i will be happy .
<?php echo 'Hello, World!'; ?>

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Deter comment spam
« Reply #5 on: January 21, 2006, 05:50:53 AM »
Well, it adds rel="nofollow" tag to EVERY links that being displayed on the page, EXEPT for links that point to the same domain as the page itself.
For example if site located on http://example.com/4images then links like http://example.com/blah/blah/so/on.html will not get nofollow tag (same domain), but links like http://google.com or http://subdomain.example.com will get the tag (different domains).
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Bugfixed

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • Lavinya
Re: Deter comment spam
« Reply #6 on: January 21, 2006, 04:49:48 PM »
thanks for kind. i see.

thanks for your kind.

I added your code. it is successful.

Recent:

1. it is adding "nofollow" tag to other websites and mywebsite in image desc. (it must not add it to url of mysite)

2. it is adding "nofollow" tag to other websites not adding mywebsite. (There is no problem user comment)

if you answer i will be happy .

i meaned, it must not add "nofollow" to url of mysite but it must add "nofollow" other website link on 1. section.
is it posiable? re thanks.
<?php echo 'Hello, World!'; ?>

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Deter comment spam
« Reply #7 on: January 21, 2006, 05:33:44 PM »
Thats how it works. Its not much of modifications for you to wait 1 day for an answer instead of just test it yourself :P ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)