Plugin Directory

Changeset 198952


Ignore:
Timestamp:
01/28/2010 06:03:35 AM (16 years ago)
Author:
kirkpatrick
Message:
 
Location:
emoba-email-obfuscator-advanced/tags/1.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • emoba-email-obfuscator-advanced/tags/1.3/emoba.php

    r198867 r198952  
    22/*
    33Plugin Name: emObA
    4 Description: emObA - Email Obfuscator Advanced -- Scans pages, posts, comments for email addresses and creates mailto links which are difficult for 'bot harvesters to find. Typing [email protected] results in a "A-B-C" link;  href="mailto:" links are preserved but obfuscated; the special occurrence "[EMAIL Name [email protected]]"  is recognized and results in a link on "Name".  Without JavaScript, hovering pops up the email with graphic glyphs for "@" and ".".  (Based on eMob Email Obfuscator 1.1 by Billy Halsey.)
     4Description: emObA - Email Obfuscator Advanced -- Scans pages, posts, comments for email addresses and creates mailto links which are difficult for 'bot harvesters to find. Typing [email protected] results in a "A@B.C" link, with grahic representations of "@"and "."; html anchor links with href="mailto:" are obfuscated; the special occurrence "[EMAIL Name | [email protected]]"  is recognized and results in an obfuscated link on "Name".  Without JavaScript, hovering pops up the email with graphic glyphs for "@" and ".".  (Based on eMob Email Obfuscator 1.1 by Billy Halsey.)
    55Version: 1.3
    66License: GPL
     
    2525*/
    2626
     27/****
     28If LEGACY is true, the old "simple" form `[Name] [email protected]` will be converted to an email link. This can be turned off to avoid problems with WordPress shortcuts, in which case the email will be treated as bare, preceded by [Name].
     29Regardless of the value of LEGACY, the new form `[EMAIL Name | [email protected]]` will be converted.
     30****/
     31define ("LEGACY", false);
     32
    2733
    2834/****
    2935If CLICKPOP is true, hovering over the link "addr" changes it to "Click to email addr".  (This switch has no effect if JavaScript is off.)
    3036****/
    31 define ("CLICKPOP", true);
     37define ("CLICKPOP", false);
    3238
    3339
     
    7480function emoba_readable_email($email="", $name="(Hover)" ) {
    7581  $glyph_email = emoba_glyph_email($email);
    76   $addr = '<span class="emoba-pop">' . $name . '<span>&nbsp;&nbsp;';
     82  $addr = '<span class="emoba-pop">' . $name . '<span ';
     83//  $addr .= ((true == CLICKPOP)? 'class="emoba-hover"' : '');
     84  $addr .= '>&nbsp;&nbsp;';
    7785  $addr .= $glyph_email . '&nbsp;&nbsp;</span></span>';
    7886  return $addr;
     
    8189
    8290/****
    83 This replaces "@" and "." with " ^ " and " " in $email; used for bare (nameless) emails
     91This replaces "@" and "." with " ^ " and "  " in $email; used for bare (nameless) emails
    8492****/
    8593function emoba_textify_email($email) {
    86   $email = str_replace('@', ' ^ ', $email);
    87   $email = str_replace('.', ' ', $email);
     94  $email = str_replace('@', '&nbsp;^&nbsp;', $email);
     95  $email = str_replace('.', '&nbsp;,&nbsp;', $email);
    8896  return  $email ;
    8997}
     
    180188
    181189
    182 // // legacy (2) Convert the special pattern [Name] [email protected] to email link <a href="mailto:[email protected] >Name</a>
    183190// (2) Convert the special pattern [EMAIL Name | [email protected]] to email link <a href="mailto:[email protected] >Name</a>
    184191
    185192  $content = preg_replace_callback(
    186 // legacy    '!\[([^]]+)\](?:[\s]|&nbsp;)*'.EMAIL.'!',   // [Name] [email protected]
    187     '!\[EMAIL(?:[\s]|&nbsp;)+([^|]+)(?:(?:[\s]|&nbsp;)*[|](?:[\s]|&nbsp;)*)'.EMAIL.'(?:[\s]|&nbsp;)*]!', // [EMAIL Name | [email protected] ]
     193    '!\[EMAIL(?:[\s]|&nbsp;)+([^|]+)(?:(?:[\s]|&nbsp;)*[|](?:[\s]|&nbsp;)*)'.EMAIL.'(?:[\s]|&nbsp;)*]!',
    188194    create_function(
    189195      '$match',
     
    197203    $content );
    198204
    199 
    200 if (true == BARE_TO_LINK ) {
     205if ( true == LEGACY ) {
     206
     207// (2') (Legacy) Convert the special pattern [Name] [email protected] to email link <a href="mailto:[email protected] >Name</a>
     208
     209  $content = preg_replace_callback(
     210    '!\[([^]]+)\](?:[\s]|&nbsp;)*'.EMAIL.'!',
     211    create_function(
     212      '$match',
     213            '$em_email = $match[2];
     214            $em_name = $match[1];
     215            $id = "emoba-" . rand(1000, 9999);
     216            $repaddr = "<span id=\"$id\">";
     217            $repaddr .= emoba_readable_email($em_email, $em_name). "</span>\n";
     218            $repaddr .= emoba_addJScript($em_email, $em_name, $id);
     219            return $repaddr;' ),
     220    $content );
     221
     222}
     223
     224
     225if ( true == BARE_TO_LINK ) {
    201226
    202227// (3) Convert any remaining addresses [email protected] to the link <a href="mailto:[email protected]">A ^ B C</a>
     
    209234            $em_name = emoba_glyph_email($em_email);  // This line throws xhtml validation error -- glyphed link
    210235      //$em_name = emoba_textify_email($em_email);  // Use this line instead, to avoid validation error -- text link
    211             $readable_email = emoba_glyph_email($em_email);
    212             $id = "emoba-" . rand(1000, 9999);
    213             $repaddr = "<span id=\"$id\">";
    214             $repaddr .= $readable_email . "</span>\n";
     236            $id = "emoba-" . rand(1000, 9999);
     237            $repaddr = "<span id=\"$id\">";
     238            $repaddr .= emoba_glyph_email($em_email) . "</span>\n";
    215239            $repaddr .= emoba_addJScript($em_email, $em_name, $id);
    216240            return $repaddr;' ),
     
    226250      '$match',
    227251            '$em_email = $match[1];
    228             $readable_email = emoba_glyph_email($em_email);    // Display glyphed email address
    229           //$readable_email = emoba_textify_email($em_email);  // Display A ^ B C for address
     252            //$readable_email = emoba_glyph_email($em_email);    // Display glyphed email address
     253          $readable_email = emoba_textify_email($em_email);  // Display A ^ B C for address
    230254            return $readable_email;' ),
    231255    $content );
  • emoba-email-obfuscator-advanced/tags/1.3/readme.txt

    r198867 r198952  
    1111== Description ==
    1212
    13 This plugin effectively and automatically makes it very difficult for spambots to harvest email addresses from your WordPress-powered blog. Email addresses may be placed in posts, comments, and pages, plain, as html links, or in a special "easy email" form, and they are automatically protected by emObA. All email addresses appearing on your blog will appear on the screen as active links to normal, valid, and correct email addresses (the actual email appears in the status bar when hovering), but to spambots they will have no recognizable features. 
     13This plugin effectively and automatically makes it very difficult for spambots to harvest email addresses from your WordPress-powered blog. Email addresses may be placed in posts, comments, and pages, plain, as html links, or in a special "easy email" form, and they are automatically protected by emObA. All email addresses appearing on your blog will appear on the screen (if JavaScript is enabled) as active links to normal, valid, and correct email addresses (the actual email appears in the status bar when hovering), but to spambots they will have no recognizable features. 
    1414
    1515
    1616It recognizes, and produces obfuscated active (click-to-send) email links for,
    1717
    18  * standard email links (`<a href="mailto:[email protected]">Name</a>`), allowing (but ignoring) attributes in addition to href, and allowing extended mailto: syntax (eg, ?subject=...) 
     18 * standard email links (`<a href="mailto:[email protected]">Name</a>`), allowing (but ignoring) additional attributes both before and after the href attribute, and allowing the extended mailto: syntax (eg, ?subject=...) 
    1919
    20  * the special "easy to write" form  `[EMAIL Name | [email protected]]` (this is changed from the earlier versions' much more fragile `[Name] [email protected]`
     20 * the special "easy to write" form  `[EMAIL Name | [email protected]]` (changed from the earlier versions' much more fragile `[Name] [email protected]`, which remains available via the LEGACY flag
    2121
    2222 * a bare email address `[email protected]` (with or without "mailto:" in front of it) 
     
    2626This is accomplished with a combination of WordPress filter hooks and JavaScript. If the browser is JavaScript-enabled, visitors to the site will see active email address links. If JavaScript is not enabled, hovering over the "link" will bring up a popup showing the email in human-readable form, eg `you [@] example [.] com`.  The [@] and [.] are  graphic images, not text, so the parts of the address are separated by lengthy runs of html (`<img ... />`).
    2727
    28 The email addresses occur in the HTML source only in a well-hidden encoding.  The email address is converted to hexadecimal and appears only as the value of a JavaScript variable.  That encoded email is separated in the JavaScript from the telltale `mailto:` to further confuse spambots.  The no-JavaScript popup address is encoded in the JavaScript with graphics representing `@` and `.`, so even a fairly smart spambot will not be led easily to the address.
     28The email addresses occur in the HTML source only in a well-hidden encoding.  The email address is converted to hexadecimal and appears only as the value of a JavaScript variable.  That encoded email is separated in the JavaScript from the telltale `mailto:` to further confuse spambots.  The no-JavaScript popup address is encoded in the html with graphics representing `@` and `.`, so even a fairly smart spambot will not be led easily to the address.
    2929
    3030
     
    3737
    3838== Upgrade notice ==
    39 emoBA 1.2 contains a serious bug affecting some PHP installations, probably 2.8.6 original and earlier, in which no link data is displayed (perhaps leading to no visible display of the email link). This has been fixed.
     39emoBA 1.2 contains a serious bug when served using certain PHP versions, probably 5.2.6 and earlier, in which no link data is displayed (perhaps leading to no visible display of the email link). This has been fixed in 1.3.
     40
    4041
    4142== Changelog ==
    4243
    4344= 1.3 =
    44 2010/01/27  Fixed problem causing link not to be displayed -- may occur under PHP 5.2.6 and older (named-subpattern bug in preg_replace_callback). Changed "easy to write" email tag to  `[EMAIL Name | [email protected]]`; the old form remains in the code, and can be recovered by commenting-uncomment. Introduced `BARE_TO_LINK` choice. Changed default textifying characters from dashes to hook and space. Conversion of the email anchor allows (but ignores) other attributes besides href, and allows extended mailto: syntax (eg, ?subject=...). Cleaned up code, JavaScript.
     452010/01/27  Fixed problem causing link not to be displayed -- may occur under PHP 5.2.6 and older (due to the named-subpattern bug in preg_replace_callback). Added "easy to write" email tag to  `[EMAIL Name | [email protected]]`.  Conversion of the email anchor allows (but ignores) other attributes besides href, and allows extended mailto: syntax (eg, ?subject=...). Introduced `BARE_TO_LINK` choice. Changed default textifying characters from dashes to hook and comma. Cleaned up code, JavaScript.
    4546= 1.2 =
    46472009/11/19  Fixed repeat email bug: correctly treats identical repeat emails (of all types).  Now converts emails placed in text widgets (requires WP 2.3).  Fixed problem with multiple spaces in the special form  [name]   [email protected] .  Introduced `CLICKPOP`.
     
    60611. The name?  obfuscate = obscurate = obnubilate < obliterate
    6162
    62 1. What does the constant `CLICKPOP` (defined at line 31 of emoba.php) do?
     631. What does the constant `BARE_TO_LINK` (defined at line 41 of emoba.php; default=true) do?
     64
     65  When `BARE_TO_LINK` is defined true, a bare email (`[email protected]`) will appear as a link; if false, it will appear as a glyphed address, but will not be an active link.
     66 
     671. What does the constant `LEGACY` (defined at line 31 of emoba.php; default=false) do?
     68
     69  If LEGACY is true, the old "simple" form `[Name] [email protected]` will be converted to an email link. This can be turned off to avoid problems with WordPress shortcuts, in which case the email will be treated as bare, preceded by [Name]. 
     70  Regardless of the value of LEGACY, the new form `[EMAIL Name | [email protected]]` will be converted.
     71
     721. What does the constant `CLICKPOP` (defined at line 37 of emoba.php; default=false) do?
    6373
    6474  When `CLICKPOP` is defined true, hovering over "Name" changes the link to "Click to email Name".
    6575
    66 1. What does the constant `BARE_TO_LINK` (defined at line 38 of emoba.php) do?
    67 
    68   When `BARE_TO_LINK` is defined true, a bare email (`[email protected]`) will appear as a link; if false, it will appear as a glyphed address, but will not be an active link.
    69 
    70 1. I don't like the hook and space you use in the textified emails!
     761. I don't like the hook and comma you use in the textified emails!
    7177
    7278  These can be edited to whatever text you want at lines 86 and 87 of emoba.php, in the function `emoba_textify_email()`.  (Just be careful not to lose the quotes.) 
     
    74801. What about styling and appearance?
    7581
    76  The following css is used; it appears in emoba_style.css.  You can add appearance styling; the display: attribute values must be left as shown in order that the hover popups work, and the emoba-glyph attributes are necessary for workable appearance (the height may be adjusted):
     82 The css file is emoba_style.css. You can add appearance styling to the various classes. However, the display: attribute values must be left as shown in order that the hover popups work, and the emoba-glyph attributes are necessary for workable appearance (the height may be adjusted).
    7783 
    7884 `
     
    87931. How can I deal with emails in static files (header, footer, sidebar, etc)?
    8894
    89   Simplest way: Put the email in a page; look at source from browser, and copy the resulting html source of that email (`<span id=emoba-nnnn">...</span>`, and also the `<script>...</script>` below it) to the template.  (But emObA works in text widgets directly.)
     95  Simplest way: Put the email in a page. Open the page in a browser, and copy the html source of that email (`<span id=emoba-nnnn">...</span>`, and also the `<script>...</script>` below it) to the template.  (Note: emObA works in text widgets directly.)
    9096 
    91971. What is the static html created for the email "Name" `<[email protected]>`?
Note: See TracChangeset for help on using the changeset viewer.