Subversion Repositories php_antispam

Rev

Rev 3 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 5
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
// PHP-AntiSpam-Funktion "secure_email", Version 3.05 of 2018-07-20
3
// PHP-AntiSpam-Funktion "secure_email", Version 3.06 of 2022-01-09
4
// von Daniel Marschall [www.daniel-marschall.de]
4
// by Daniel Marschall [www.daniel-marschall.de], ViaThinkSoft
-
 
5
// License: Apache 2.0 License
5
 
6
 
6
if (!function_exists('alas_js_crypt'))
7
if (!function_exists('alas_js_crypt'))
7
{
8
{
8
        function alas_js_crypt($text)
9
        function alas_js_crypt($text)
9
        {
10
        {
Line 25... Line 26...
25
                $text = str_replace('/', '\/', $text); // W3C Validation </a> -> <\/a>
26
                $text = str_replace('/', '\/', $text); // W3C Validation </a> -> <\/a>
26
                return 'document.write("'.$text.'");';
27
                return 'document.write("'.$text.'");';
27
        }
28
        }
28
}
29
}
29
 
30
 
30
function secure_email($email, $linktext, $crypt_linktext)
31
function secure_email($email, $linktext, $crypt_linktext, $css_class='')
31
{
32
{
32
        // No new lines to avoid a JavaScript error!
33
        // No new lines to avoid a JavaScript error!
33
        $linktext = str_replace("\r", ' ', $linktext);
34
        $linktext = str_replace("\r", ' ', $linktext);
34
        $linktext = str_replace("\n", ' ', $linktext);
35
        $linktext = str_replace("\n", ' ', $linktext);
35
 
36
 
36
        $aus = '';
37
        $aus = '';
37
        if ($email != '')
38
        if ($email != '')
38
        {
39
        {
39
                $aus .= '<script><!--'."\n"; // type="text/javascript" is not necessary in HTML5
40
                $aus .= '<script><!--'."\n"; // type="text/javascript" is not necessary in HTML5
-
 
41
                $aus .= alas_js_write('<a ');
-
 
42
                if ($css_class != '') $aus .= alas_js_write('class="'.$css_class.'" ');
40
                $aus .= alas_js_write('<a href="');
43
                $aus .= alas_js_write('href="');
41
                $aus .= alas_js_crypt('mailto:'.$email);
44
                $aus .= alas_js_crypt('mailto:'.$email);
42
                $aus .= alas_js_write('">');
45
                $aus .= alas_js_write('">');
43
                $aus .= $crypt_linktext ? alas_js_crypt($linktext) : alas_js_write($linktext);
46
                $aus .= $crypt_linktext ? alas_js_crypt($linktext) : alas_js_write($linktext);
44
                $aus .= alas_js_write('</a>').'// --></script>';
47
                $aus .= alas_js_write('</a>').'// --></script>';
45
        }
48
        }