* New Feature #0000341: New option "ascii" for spamProtectEmailAddresses (very cool...
authorIngmar Schlecht <ingmar.schlecht@typo3.org>
Mon, 28 Mar 2005 11:14:36 +0000 (11:14 +0000)
committerIngmar Schlecht <ingmar.schlecht@typo3.org>
Mon, 28 Mar 2005 11:14:36 +0000 (11:14 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@586 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/cms/tslib/class.tslib_content.php
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/cms/tslib/class.tslib_pagegen.php

index 1ad3840..fb04fc5 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
        * Fixed bug #0000890: fe_adminLib.inc procesSetFixed does not support userFunc_afterSave
        * Fixed bug #0000316: Backend typo3/template.php output spurious </body> tag for doctype xhtml_frames
        * Added two hooks to t3lib_userauthgroup for Sebastian Kurfuerst's ACL implementation
+       * New Feature #0000341: New option "ascii" for spamProtectEmailAddresses (very cool, because it doesn't need JavaScript! Thanks to user "Karsten" on bugs.typo3.org)
 
 2005-03-25  Michael Stucki  <michael@typo3.org>
 
index 37804b5..2b69f0b 100755 (executable)
@@ -4356,11 +4356,22 @@ class tslib_cObj {
                                $parts[0] = substr($textpieces[$i],0,$len);
                                $parts[1] = substr($textpieces[$i],$len);
                                $linktxt = ereg_replace('\?.*','',$parts[0]);
-                               if (!$GLOBALS['TSFE']->config['config']['jumpurl_enable'] || $GLOBALS['TSFE']->config['config']['jumpurl_mailto_disable'])      {
-                                       if ($GLOBALS['TSFE']->spamProtectEmailAddresses)        {
-                                               $mailToUrl = "javascript:linkTo_UnCryptMailto('".$GLOBALS['TSFE']->encryptEmail('mailto:'.$parts[0])."');";
-                                               $atLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']);
-                                               $linktxt = str_replace('@',$atLabel ? $atLabel : '(at)', $linktxt);
+                               if (!$GLOBALS['TSFE']->config['config']['jumpurl_enable'] || $GLOBALS['TSFE']->config['config']['jumpurl_mailto_disable']) {
+                                       if ($GLOBALS['TSFE']->spamProtectEmailAddresses) {
+                                               if ($GLOBALS['TSFE']->spamProtectEmailAddresses == 'ascii')     {
+                                                       $mailToUrl = $GLOBALS['TSFE']->encryptEmail('mailto:'.$parts[0]);
+                                               } else {
+                                                       $mailToUrl = "javascript:linkTo_UnCryptMailto('".$GLOBALS['TSFE']->encryptEmail('mailto:'.$parts[0])."');";
+                                               }
+                                               if ($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']) {
+                                                       $atLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']);
+                                                       $linktxt = str_replace('@',$atLabel?$atLabel:'(at)',$linktxt);
+                                               }
+                                               if ($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_lastDotSubst']) {
+                                                       $lastDotLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_lastDotSubst']);
+                                                       $lastDotLabel = $lastDotLabel ? $lastDotLabel : '(dot)';
+                                                       $linktxt = preg_replace('/\.([^\.]+)$/', $lastDotLabel.'$1', $linktxt);
+                                               }
                                        } else {
                                                $mailToUrl = 'mailto:'.$parts[0];
                                        }
@@ -4864,10 +4875,21 @@ class tslib_cObj {
                                if ($linktxt=='') $linktxt = $link_param;
                                if (!$GLOBALS['TSFE']->config['config']['jumpurl_enable'] || $GLOBALS['TSFE']->config['config']['jumpurl_mailto_disable'])      {
                                        $this->lastTypoLinkUrl = 'mailto:'.$link_param;
-                                       if ($GLOBALS['TSFE']->spamProtectEmailAddresses)        {
-                                               $this->lastTypoLinkUrl = "javascript:linkTo_UnCryptMailto('".$GLOBALS['TSFE']->encryptEmail($this->lastTypoLinkUrl)."');";
-                                               $atLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']);
-                                               $linktxt=str_replace('@',$atLabel?$atLabel:'(at)',$linktxt);
+                                       if ($GLOBALS['TSFE']->spamProtectEmailAddresses) {
+                                               if ($GLOBALS['TSFE']->spamProtectEmailAddresses == 'ascii')     {
+                                                       $this->lastTypoLinkUrl = $GLOBALS['TSFE']->encryptEmail($this->lastTypoLinkUrl);
+                                               } else {
+                                                       $this->lastTypoLinkUrl = "javascript:linkTo_UnCryptMailto('".$GLOBALS['TSFE']->encryptEmail($this->lastTypoLinkUrl)."');";
+                                               }
+                                               if ($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']) {
+                                                       $atLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']);
+                                                       $linktxt = str_replace('@',$atLabel?$atLabel:'(at)',$linktxt);
+                                               }
+                                               if ($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_lastDotSubst']) {
+                                                       $lastDotLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_lastDotSubst']);
+                                                       $lastDotLabel = $lastDotLabel ? $lastDotLabel : '(dot)';
+                                                       $linktxt = preg_replace('/\.([^\.]+)$/', $lastDotLabel.'$1', $linktxt);
+                                               }
                                        }
                                } else {
                                        $this->lastTypoLinkUrl = $GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode('mailto:'.$link_param).$GLOBALS['TSFE']->getMethodUrlIdToken;
@@ -5043,7 +5065,11 @@ class tslib_cObj {
                                $onClick="vHWin=window.open('".$GLOBALS['TSFE']->baseUrlWrap($finalTagParts['url'])."','FEopenLink','".$JSwindowParams."');vHWin.focus();return false;";
                                $res = '<a href="#" onclick="'.htmlspecialchars($onClick).'"'.($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
                        } else {
-                               $res = '<a href="'.htmlspecialchars($finalTagParts['url']).'"'.$finalTagParts['targetParams'].($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
+                               if ($GLOBALS['TSFE']->spamProtectEmailAddresses == 'ascii') {
+                                       $res = '<a href="'.$finalTagParts['url'].'"'.$finalTagParts['targetParams'].($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
+                               } else {
+                                       $res = '<a href="'.htmlspecialchars($finalTagParts['url']).'"'.$finalTagParts['targetParams'].($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
+                               }
                        }
 
                                // Call user function:
index 3e09822..f8d8cbe 100755 (executable)
@@ -3027,10 +3027,17 @@ if (version == "n3") {
         */
        function encryptEmail($string,$back=0)  {
                $out = '';
-               for ($a=0; $a<strlen($string); $a++)    {
-                       $charValue = ord(substr($string,$a,1));
-                       $charValue+= intval($this->spamProtectEmailAddresses)*($back?-1:1);
-                       $out.= chr($charValue);
+
+               if ($this->spamProtectEmailAddresses == 'ascii') {
+                       for ($a=0; $a<strlen($string); $a++) {
+                               $out .= '&#'.ord(substr($string, $a, 1)).';';
+                       }
+               } else  {
+                       for ($a=0; $a<strlen($string); $a++)    {
+                               $charValue = ord(substr($string,$a,1));
+                               $charValue+= intval($this->spamProtectEmailAddresses)*($back?-1:1);
+                               $out.= chr($charValue);
+                       }
                }
                return $out;
        }
index 74e4067..a11cb5f 100755 (executable)
@@ -133,9 +133,12 @@ class TSpagegen {
                        // Internal and External target defaults
                $GLOBALS['TSFE']->intTarget = ''.$GLOBALS['TSFE']->config['config']['intTarget'];
                $GLOBALS['TSFE']->extTarget = ''.$GLOBALS['TSFE']->config['config']['extTarget'];
-               $GLOBALS['TSFE']->spamProtectEmailAddresses = t3lib_div::intInRange($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses'],-5,5,0);
-               if ($GLOBALS['TSFE']->spamProtectEmailAddresses)        {
-                       $GLOBALS['TSFE']->additionalJavaScript['UnCryptMailto()']='
+               if ($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses'] == 'ascii') {
+                       $GLOBALS['TSFE']->spamProtectEmailAddresses = 'ascii';
+               } else {
+                       $GLOBALS['TSFE']->spamProtectEmailAddresses = t3lib_div::intInRange($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses'],-5,5,0);
+                       if ($GLOBALS['TSFE']->spamProtectEmailAddresses)        {
+                               $GLOBALS['TSFE']->additionalJavaScript['UnCryptMailto()']='
   // JS function for uncrypting spam-protected emails:
 function UnCryptMailto(s) {    //
        var n=0;
@@ -152,6 +155,7 @@ function linkTo_UnCryptMailto(s)    {       //
        location.href=UnCryptMailto(s);
 }
                ';
+                       }
                }