Subversion Repositories php_antispam

Compare Revisions

Regard whitespace Rev 5 → Rev 6

/trunk/examples/antispam-example.php
11,7 → 11,7
 
<?php
 
echo '<form action="'.$PHP_SELF.'">
echo '<form action="'.$_SERVER['PHP_SELF'].'">
E-Mail-Adresse: <input name="email" value="'.$_GET['email'].'"><br>
Linktext: <input name="linktext" value="'.$_GET['linktext'].'"><br>
Linktext verschlüsseln: <input type="checkbox" name="crypt_linktext" checked><br>
/trunk/examples/autofilter-example1.inc.php
4,6 → 4,8
// for ViaThinkSoft Sigma as filter plugin (modified $content)
// Use it for your website!
 
include __DIR__ . '/../v3.inc.php'; // AntiSpam v3
 
// CONFIGURATION
 
define('CFG_MAKE_MAIL_ADDRESSES_CLICKABLE', true);
10,10 → 12,6
 
// CODE
 
function secure_email_triv($email)
{
if (!function_exists('alas_js_crypt'))
{
function alas_js_crypt($text)
{
$tmp = '';
23,8 → 21,9
}
return $tmp;
}
}
 
function secure_email_triv($email)
{
$aus = '';
if ($email != '')
{
35,52 → 34,6
return $aus;
}
 
// PHP-AntiSpam-Funktion "secure_email", Version 3.02
// von Daniel Marschall [www.daniel-marschall.de]
 
function secure_email($email, $linktext, $crypt_linktext)
{
// No new lines to avoid a JavaScript error!
$linktext = str_replace("\r", ' ', $linktext);
$linktext = str_replace("\n", ' ', $linktext);
 
if (!function_exists('alas_js_crypt'))
{
function alas_js_crypt($text)
{
$tmp = '';
for ($i=0; $i<strlen($text); $i++)
{
$tmp .= 'document.write("&#'.ord(substr($text, $i, 1)).';");';
}
return $tmp;
}
}
 
if (!function_exists('alas_js_write'))
{
function alas_js_write($text)
{
$text = str_replace('\\', '\\\\', $text);
$text = str_replace('"', '\"', $text);
$text = str_replace('/', '\/', $text); // W3C Validation </a> -> <\/a>
return 'document.write("'.$text.'");';
}
}
 
$aus = '';
if ($email != '')
{
$aus .= '<script language="JavaScript" type="text/javascript"><!--'."\n";
$aus .= alas_js_write('<a href="');
$aus .= alas_js_crypt('mailto:'.$email);
$aus .= alas_js_write('">');
$aus .= $crypt_linktext ? alas_js_crypt($linktext) : alas_js_write($linktext);
$aus .= alas_js_write('</a>').'// --></script>';
}
return $aus;
}
 
function getAddrSpec() {
// Ref: http://www.iamcal.com/publish/articles/php/parsing_email/
 
111,21 → 64,17
 
// Step 1: Parse links and make them secure
 
if (!function_exists('link_cb_1')) {
function link_cb_1($a) {
$content = preg_replace_callback("/<a(.+?)mailto:($addr_spec)(.+?)>(.+?)<\/a>/sm",
function($a) {
$mailaddr = $a[2];
$linktext = $a[14]; // Letztes
 
return secure_email($mailaddr, $linktext, is_valid_email_address($linktext));
}
}
}, $content); // TODO! Kann Greedy werden!
 
$content = preg_replace_callback("/<a(.+?)mailto:($addr_spec)(.+?)>(.+?)<\/a>/sm", 'link_cb_1', $content); // TODO! Kann Greedy werden!
 
// Step 2: Find all further mail addresses, make then clickable and prevent spam bots
 
if (!function_exists('link_cb_2')) {
function link_cb_2($a) {
$content = preg_replace_callback("/($addr_spec)/sm", function($a) {
$mailaddr = $a[1]; // Letztes
 
if (CFG_MAKE_MAIL_ADDRESSES_CLICKABLE) {
133,14 → 82,13
} else {
return secure_email_triv($mailaddr);
}
}
}
}, $content);
 
$content = preg_replace_callback("/($addr_spec)/sm", 'link_cb_2', $content);
 
// Output
 
return $content;
}
 
if (isset($content)) {
$content = auto_secure_mail_addresses($content);
}
/trunk/examples/autofilter-example2.inc.php
12,10 → 12,6
 
// SOURCE: SIGMA 3.0 ANTISPAM FILTER
 
function secure_email_triv($email)
{
if (!function_exists('alas_js_crypt'))
{
function alas_js_crypt($text)
{
$tmp = '';
25,8 → 21,9
}
return $tmp;
}
}
 
function secure_email_triv($email)
{
$aus = '';
if ($email != '')
{
85,16 → 82,6
}
}
 
function link_cb_2($a) {
$mailaddr = $a[1]; // Letztes
 
if (CFG_MAKE_MAIL_ADDRESSES_CLICKABLE) {
return secure_email($mailaddr, $mailaddr, true, CFG_DEFAULT_CLASS);
} else {
return secure_email_triv($mailaddr);
}
}
 
function protect_mail_address_urls($content, $correct_missing_mailto = true) {
$t = new MailLinkProtector;
$t->correct_missing_mailto = $correct_missing_mailto;
122,8 → 109,16
$exclude_mail_chars_beginning = '\^°!"§$%&/()=\?´`}\]\[{\+*~\'#-_\.:,;';
$exclude_mail_chars_ending = $exclude_mail_chars_beginning;
 
$content = preg_replace_callback("@(?![$exclude_mail_chars_beginning])($addr_spec)(?<![$exclude_mail_chars_ending])@sm", 'link_cb_2', $content);
$content = preg_replace_callback("@(?![$exclude_mail_chars_beginning])($addr_spec)(?<![$exclude_mail_chars_ending])@sm", function($a) {
$mailaddr = $a[1]; // Letztes
 
if (CFG_MAKE_MAIL_ADDRESSES_CLICKABLE) {
return secure_email($mailaddr, $mailaddr, true, CFG_DEFAULT_CLASS);
} else {
return secure_email_triv($mailaddr);
}
}, $content);
 
// Output
 
return $content;