{NOSPAM_JS} Replacement Tag

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

{NOSPAM_JS} Replacement Tag

Post by flip-flop »

Hi at all,

my first RT for helping users by publishing there e-Mail-Adr. without SPAM.
This snippet based on a combination of PHP and JavaScript.
The RT {NOSPAM_JS:name@domain.tld:LinkText} uses PHP for including the following into your generated HTML.
<script type="text/javascript">setMailLink("domain","LinkText","tld","name");</script><a href="mailto:name@domain.tld">LinkText</a>

I recommend to use this RT in such a way: {NOSPAM_JS:name@domain.tld:LinkText} name(at)domain. tld
If the JS function at the browser is switched off, he will still see this address: name(at)domain. tld

Which is intercepted after input:
- LinkText may not be equal to the e-Mail-adr. -> generating the string e-Mail instead of the input
- A syntactically wrong address -> generating an errormessage

Expand this script to your needs.



German ---------------------
Hier mein überhaupt erster RT: E-Mail-Adresse for SPAMERN verstecken.
Diese Programmteile basieren auf einer Kombination aus PHP und JavaScript.
Der RT {NOSPAM_JS:name@domain.tld:LinkText} nutzt PHP um die folgenden Zeilen in den HTML-Text einzufügen:
<script type="text/javascript">setMailLink("domain","LinkText","tld","name");</script><a href="mailto:name@domain.tld">LinkText</a>

Ich empfehle den RT in folgender Weise zu nutzen: {NOSPAM_JS:name@domain.tld:LinkText} name(at)domain. tld
Wenn der User JS in seinem Browser abgeschaltet hat, sieht er immer noch diesen Eintrag: name(at)domain. tld

Was wird nach der Eingabe abgefangen:
- LinkText darf nicht gleich e-Mail Text sein -> sonst wird der Text "E-Mail" eingesetzt.
- Eine syntaktisch falsche e-Mail-Adr. -> Fehlermeldung

Aufruf: {NOSPAM_JS:name@domain.tld:LinkText}

Erweitert dieses Skript für eure Bedürfnisse.

Code: Select all

<?php
/********************************************
From:
http://www.phpwcms.de/forum/

REPTAG CODE: {NOSPAM_JS:name@domain.tld:LinkText}
Developer: brans (JS)
Developer: flip-flop (PHP)
phpWCMS Version: 1.2.6

modified: 	26.03.2006
last modified:	22.05.2006

Description:
Convert a mailadr. like info@domain.tld to a JS generated html-output.
Uses the following Java Script includet at phpwcms_template/inc_js/frontend.js
--------------------------------------
function setMailLink(Dn, Tx, En, An) {
	var MailText = An + "@" + Dn + "." + En;
	var ShowText = Tx;
	document.open();
	document.write("<a href=\"mailto:" + MailText + "\">" + ShowText + "</a>");
	document.close();
	} 
--------------------------------------

JS: Incomming parameter:
	- An: name is your emailname before the @
	- Dn: domain is your domain-name 
	- En: is the tld of your domain 
	- Tx: LinkText
-------------------------------------------------------------------------------

Installation:
		1. Put the JS above into phpwcms_template/inc_js/frontend.js file
		2. Put the code in frontend_render (for example in a file called reptag_NOSPAM_JS.php)
                
                {NOSPAM_JS:name@domain.tld:LinkText}
                where 
				- name@domain.tld ($1)
				- LinkText is the Text showing at your browser ($2)				

Mod version: none

Support:
http://www.phpwcms.de/forum/viewtopic.php?t=4819
http://www.phpwcms.de/forum/viewtopic.php?t=11339

********************************************/

// CODE

function no_spam_js ($mail_adr, $link_text='e-Mail') {
// A real e-Mail-adr. ?
	$re = "^[a-zA-Z0-9\#\.\_\=\+\~\-]+@([a-zA-Z0-9\-]+\.)+[a-zA-Z]{2,4}$"; 
	$erg = ereg($re,$mail_adr);
	if ($erg == true) {  // Yes it is a real e-Mail-adr. Let´s go
	
	  // LinkText equal Mail-Adr or empty? Yes= LinkText=e-Mail. 
	  if (($mail_adr == $link_text) or ($link_text == '')) {$link_text = 'e-Mail';}
	  // ===== Please don´t use real e-Mail as LinkText =======
	  
		$len = strlen($mail_adr);										// lenght of all
		$position 		= strpos($mail_adr, '@');						// where is the @
		$out_name 		= substr($mail_adr, 0, $position);				// separate name
		$mail_adr = substr($mail_adr, ($position+1), ($len-$position)); // all stuff behind @
		$position 		= strrpos($mail_adr, '.');						// find the first point from the right
		$out_domain 	= substr($mail_adr, 0, $position);				// separate domaian
		$out_tld = substr($mail_adr, ($position+1), (strlen($mail_adr))); // separate the tld

		// And create the output brick for brick
		$before = '<script type="text/javascript">setMailLink(';		// First JS string 
		$middle = "\"$out_domain\",\"$link_text\",\"$out_tld\",\"$out_name\"";
		$behind = ');</script>'; 										// Last JS string
		//	$str = "<script type=\"text/javascript\">setMailLink(\"$out_domain\",\"$link_text\",\"$out_tld\",\"$out_name\");</script>"; 

		return $before.$middle.$behind;  // Going away with the complete JS-string
		
	  } else {  // Error output: No real adr.
			$middle = '<B>Haven´t found a real e-mail-adr. Please try again!!</B>'; 
			return $middle;
		} 
}

// ------------------------------
  if( ! (strpos($content["all"],'{NOSPAM_JS:')===false)) { 
	$content["all"] = preg_replace('/\{NOSPAM_JS:(.*?):(.*?)\}/e','no_spam_js("$1","$2");', $content["all"]);
  } 
?>
Have fun :D

Knut
Last edited by flip-flop on Tue 5. Dec 2006, 14:32, edited 4 times in total.
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
Magnum
Posts: 91
Joined: Thu 12. Aug 2004, 00:56
Location: Berlin
Contact:

Post by Magnum »

schön schön, aber was tun wenn man spammails über einen e-mailformulargenerator erhält...was bei mir seit 2 wochen der fall ist...nirgends ist die mailadresse hinterlegt, nur im generator und ich erhalte nun ständig emails vom "Admin - Online Email Nachricht" in dieser befindet sich:

Online E-Mail Nachricht
--------------------------------------------------------------------
hashID: 4ddeb651b9f7f36770b78ccadb5650a6
name..: ****
mail..: eopta@eopta.org
info..: <a href=http://www.cfcl.com/twiki/pub/Main/NeoV ... s.html>buy cialis</a> <a href=http://www.cfcl.com/twiki/pub/Main/NeoV ... a.html>buy ****</a> buy cialis buy **** <a href=http://www.cfcl.com/twiki/pub/Main/NeoV ... html>cheap ****</a> cheap **** <a href=http://www.lavrsen.dk/twiki/pub/Main/Ne ... s.html>buy cialis</a> <a href=http://www.lavrsen.dk/twiki/pub/Main/Ne ... a.html>buy ****</a> buy cialis buy **** <a href=http://www.lavrsen.dk/twiki/pub/Main/Ne ... html>cheap ****</a> cheap ****
menu..: Allg. Fragen

====================================================================
phpwcms formmailer | Copyright (C) 2003


wie kann man sowas unterbinden???
ansonsten werde im üblichen html jetzt flipflop sein RT nutzen
Post Reply