Login | ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/php_antispam/trunk/v3.inc.php
Revision: 2
Committed: Thu May 2 10:15:53 2019 UTC (9 months, 4 weeks ago) by daniel-marschall
File size: 1359 byte(s)
Log Message:
Initial release to SVN

File Contents

# Content
1 <?php
2
3 // PHP-AntiSpam-Funktion "secure_email", Version 3.05 of 2018-07-20
4 // von Daniel Marschall [www.daniel-marschall.de]
5
6 function secure_email($email, $linktext, $crypt_linktext)
7 {
8 // No new lines to avoid a JavaScript error!
9 $linktext = str_replace("\r", ' ', $linktext);
10 $linktext = str_replace("\n", ' ', $linktext);
11
12 if (!function_exists('alas_js_crypt'))
13 {
14 function alas_js_crypt($text)
15 {
16 $tmp = '';
17 for ($i=0; $i<strlen($text); $i++)
18 {
19 $tmp .= 'document.write("&#'.ord(substr($text, $i, 1)).';");';
20 }
21 return $tmp;
22 }
23 }
24
25 if (!function_exists('alas_js_write'))
26 {
27 function alas_js_write($text)
28 {
29 $text = str_replace('\\', '\\\\', $text);
30 $text = str_replace('"', '\"', $text);
31 $text = str_replace('/', '\/', $text); // W3C Validation </a> -> <\/a>
32 return 'document.write("'.$text.'");';
33 }
34 }
35
36 $aus = '';
37 if ($email != '')
38 {
39 $aus .= '<script><!--'."\n"; // type="text/javascript" is not necessary in HTML5
40 $aus .= alas_js_write('<a href="');
41 $aus .= alas_js_crypt('mailto:'.$email);
42 $aus .= alas_js_write('">');
43 $aus .= $crypt_linktext ? alas_js_crypt($linktext) : alas_js_write($linktext);
44 $aus .= alas_js_write('</a>').'// --></script>';
45 }
46
47 return $aus.'<noscript>Please enable JavaScript to display this email address.</noscript>';
48 }