Skip to main content
CafeWebmaster

Main navigation

  • Tools
    • MD5 converter
    • SHA1 converter
    • Base64 encode
    • Base64 decode
    • HTML entities encode
    • HTML entities decode
    • Raw url encode
    • Raw url decode
    • UTF8 encode
    • UTF8 decode
    • Unix Time to Human Date converter
    • Remove duplicate lines
    • Sort text lines
    • Backwards - Mirrored Text
    • PiRaTe tExT
    • Your IP Address & Hostname
  • Forums
  • Free PHP Scripts
    • Image watermark with PHP
    • Page generation time with PHP
  • CSS
    • CSS hidden left menu
    • CSS horizontal menu
  • Free Fonts
  • Image Editors
  • Tutorials
    • Check password strength / safety with PHP and Regex
    • Cómo hacer que su sitio web popular!
    • How2 make a website popular
    • How2 secure your website
    • Kennwort Sicherheit mit PHP und Regex Prüfen
    • Page generation time and http-referrers with php
    • Redirect webpages with HTML, PHP, .htaccess, Java+Script, CGI-Perl, ASP.NET and ColdFusion
  • New
User account menu
  • Log in

Breadcrumb

  1. Home

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

By n8coder, 11 November, 2012

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


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 "

E-Mail Addresse of $comment_posters_name is: $comment_posters_mail

";
} else {

echo "

E-Mail Addresse of $comment_posters_name({$comment_posters_mail2}...) is just for < a href=\"/user/register\">registered users< /a> available!

";
}
}
?>

  • Log in to post comments
CafeWebmaster.com(CW) is a free online community for webdevelopers and beginners. Anybody can share their code, articles, tips, tutorials, code-examples or other webdesign related material on the site. Newbies can submit their questions and reply to existing questions. CW does not guarantee or warrant reliability of code, data and information published on the site. Use the site on your own risk. The site takes no responsibility of direct or indirect loss or any kind of harm to its users. The site also doesn't take responsibility of infected files or source code with any kind of infection or viruses, worms, spywares, malwares, trojan horses. CW reserves the right to edit, move, or delete any of content for any reason.