Display E-Mail Adresse of anonym visitors in Drupal-comments securely

Submitted by n8coder on Sun, 11/11/2012 - 20:12

Visitors post comments and they live sometimes their contact information like email address to get feedback. If you display e-mail spambots will catch them before other visitors. If you dont display, other visitors cannot send feedback. What is the secure anti-spam solution?

Here is what I did:

- email adresse of comment-poster will just partly shown to other anonym visitors (and with a tip to register to see full email)
- email adresse of comment-poster will shown to other registered visitors fully

To do that I need to change Druplas core comment-module and add a couple of php lines.

public_html/modules/comment/comment.tpl.php

  <div class="submitted">
    <?php print $submitted ?>
<?php
       
if($comment->mail) {
           
$comment_posters_name = str_replace("Guest ", "", $comment->name);
           
$comment_posters_mail = $comment->mail;
           
$comment_posters_mail2 = preg_replace("#(.*@..)(.*)#sim", "$1", $comment_posters_mail);
               
            if(
$user->uid){
                echo
"<p><b>E-Mail Addresse of  <u>$comment_posters_name</u> is: $comment_posters_mail</b></p>";
            } else {

                echo "<p><b>E-Mail Addresse of  <u>$comment_posters_name</u>({$comment_posters_mail2}...) is just for < a href="/user/register">registered users< /a> available!</b></p>";
            }
        }
   
?>
  </div>

Add new comment