Plugin Directory

Changeset 178276


Ignore:
Timestamp:
11/30/2009 11:17:29 PM (16 years ago)
Author:
kirkpatrick
Message:

development 1.2.5

Location:
emoba-email-obfuscator-advanced/trunk
Files:
3 edited

Legend:

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

    r175627 r178276  
    11<?php
    22/*
    3 Plugin Name: emObA - Email Obfuscator Advanced
    4 Description: 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 "[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.)
    5 Version: 1.2
     3Plugin Name: emObA
     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;  href="mailto:" links are preserved but obfuscated; the special occurrence "[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.)
     5Version: 1.2.5
    66License: GPL
    77Author: Kim Kirkpatrick
     
    2727
    2828/****
    29 Option (at present, the only one):
    30 If CLICKPOP is true, hovering over the link "addr" changes it to "Click to email addr". (This switch has no effect if JavaScript is off.)
     29If CLICKPOP is true, hovering over the link "addr" changes it to "Click to email addr".  (This switch has no effect if JavaScript is off.)
    3130****/
    3231define ("CLICKPOP", false);
    3332
     33
     34/****
     35If BARE_TO_LINK is true, bare emails ([email protected]) will be converted to a link with visible "name" a ^ b c.  If false, there will be no link, but the email will appear in the glyph form.
     36(A problem with CDATA commenting being removed by WordPress (space forced into <! [CDATA and conversion of close to ]]&gt;) prevent the link from containing the glyph name.  The only workaraound I know of requires hacking WordPress.)
     37****/
     38define ("BARE_TO_LINK", true);
    3439
    3540
     
    4752You may want to change the alts or i18n them.
    4853
    49 If text rather than glyph is desired for the separators, replace with your versions of define( 'SEP_AT', ' [at] ' ); and define( 'SEP_DOT', ' [dot] ' );
    50 ****/
    51 define( 'SEP_AT',  '<img src="' . plugin_dir_url(__FILE__) . 'at-glyph.gif"  class="emoba-glyph" alt="at"  height="8" />' );
    52 define( 'SEP_DOT', '<img src="' . plugin_dir_url(__FILE__) . 'dot-glyph.gif" class="emoba-glyph" alt="dot" height="9" />' );
    53 
    54 
    55 /****
    56 This replaces "." with SEP_DOT and "@" with SEP_AT in $email
     54If text rather than glyph is desired for the separators,
     55replace with your versions of define( 'SEP_AT', ...) and define( 'SEP_DOT', ... );
     56****/
     57define( 'SEP_AT',  '<img src="' . plugin_dir_url(__FILE__) . 'at-glyph.gif"  alt="at"  class="emoba-glyph" />' );
     58define( 'SEP_DOT', '<img src="' . plugin_dir_url(__FILE__) . 'dot-glyph.gif" alt="dot" class="emoba-glyph" />' );
     59
     60
     61/****
     62This replaces "@" with SEP_AT and "." with SEP_DOT in $email
    5763****/
    5864function emoba_glyph_email($email) {
    5965  $email = str_replace('.', SEP_DOT, $email);
    60   $email = str_replace('@', SEP_AT, $email);
     66  $email = str_replace('@', SEP_AT , $email);
    6167  return '<span class="emoba-em">' . $email . '</span>';
    6268}
    6369
    64 /****
    65 This replaces "." and "@" with "-" in $email
    66 ****/
    67 function emoba_dash_email($email) {
    68   $email = str_replace('.', '-', $email);
    69   $email = str_replace('@', '-', $email);
     70
     71/****
     72This constructs a glyphed email address for use when JavaScript is not available
     73****/
     74function emoba_readable_mail($email="", $name="(Hover)" ) {
     75  $glyph_email = emoba_glyph_email($email);
     76  $addr = '<span class="emoba-pop">' . $name . '<span>&nbsp;&nbsp;';
     77  $addr .= $glyph_email . '&nbsp;&nbsp;</span></span>';
     78  return $addr;
     79}
     80
     81
     82/****
     83This replaces "@" and "." with " ^ " and " " in $email; used for bare (nameless) emails
     84****/
     85function emoba_textify_email($email) {
     86  $email = str_replace('@', ' ^ ', $email);
     87  $email = str_replace('.', ' ', $email);
    7088  return  $email ;
    7189}
     
    7391
    7492/****
    75 This is the email address seen when JavaScript is not available
    76 ****/
    77 function emoba_readable_mail($email="", $name="(Hover)" ) {
    78 
    79   $email = str_replace('.',
    80         '</span><span class="emoba-symbol">' . SEP_DOT . '</span><span class="emoba-em">',
    81          $email);
    82   $email = str_replace('@',
    83         '</span><span class="emoba-symbol">' . SEP_AT . '</span><span class="emoba-em">',
    84          $email);
    85   $addr = '<span class="emoba-pop">' . $name . '<span>&nbsp;&nbsp;<span class="emoba-em">';
    86   $addr .= $email . '</span>&nbsp;&nbsp;</span></span>';
    87   return $addr;
    88 }
    89 
    90 
    91 /****
    92 This is the RE expression for detecting email addresses. (The result found is returned as email=>result.)
     93This is the RE expression for detecting email addresses. (The result found is returned as $match[email].)
    9394****/
    9495define( "ADDR_PATTERN",
     
    125126if (true == CLICKPOP) {
    126127  $emoba_js .= <<<AJS
     128
    127129  var spanNode = document.createElement('span');
     130  spanNode.className = 'emoba-hover';
    128131  spanNode.innerHTML = 'Click to email ';
    129132  linkNode.appendChild(spanNode);
     
    132135}
    133136$emoba_js .= <<<AJS
    134   var tNode = document.createTextNode('$ename');
     137
     138  var tNode = document.createElement('span');
     139  tNode.innerHTML = '$ename';
    135140  linkNode.appendChild(tNode);
    136141  mailNode.parentNode.replaceChild(linkNode, mailNode);
     
    146151  a. as a link <a href="mailto:[email protected]">Name</a>
    147152  b. as a special email encoding [Name] [email protected]
    148   c. as a raw email [email protected]; the "Name" in this case is "A-B-C"
    149 2. Each of these creates a random-id <span> which includes the Name and pop-up email with graphics for @ and . (in case JavaScript is off), and inserts JavaScript.
     153  c. as a raw email [email protected] (The "Name" in this case is the email itself, textified or glyphed depending on BARE_TO_LINK.)
     1542. Each of these creates a random-id span which includes the Name and pop-up email with graphics for @ and . (in case JavaScript is off), and inserts JavaScript.
    1501553. The JavaScript (via emoba_addJScript()) replaces the <span> with the approriate <a> link.(with the address encoded).
    151 4. CSS (for class emoba-pop) creates the hover effect when JavaScript is turned off.
     1564. CSS (for classes emoba-pop, emoba-hover) creates the hover effect when JavaScript is turned off.
    152157****/
    153158
     
    157162
    158163  $content = preg_replace_callback(
    159     '|<a href="mailto:' .ADDR_PATTERN. '"[^>]*>(?P<name>[^<]+)</a>|i',
     164    '!<a href="mailto:' .ADDR_PATTERN. '"[^>]*>(?P<name>[^<]+)</a>!i',
    160165    create_function(
    161166      '$match',
     
    175180  $content = preg_replace("|mailto:".ADDR_PATTERN."|i", '$1', $content);
    176181
    177 // (2) Convert the special pattern [Name] [email protected] to email link <a href="mailto:[email protected] >Name</a>
    178 
    179   $content = preg_replace_callback(
    180     "/\[(?P<name>[^]]+)]([\s]|&nbsp;)*".ADDR_PATTERN."/i",
     182// (2) Convert the special pattern {Name} [email protected] to email link <a href="mailto:[email protected] >Name</a>
     183
     184  $content = preg_replace_callback(
     185    "!\[(?P<name>[^]]+)\]([\s]|&nbsp;)*".ADDR_PATTERN."!i",
    181186    create_function(
    182187      '$match',
     
    190195    $content );
    191196
    192 // (3) Convert any remaining addresses [email protected] to the link <a href="mailto:[email protected]">A-B-C</a>
    193 
    194   $content = preg_replace_callback(
    195     '|'.ADDR_PATTERN.'|i',
     197if (true == BARE_TO_LINK ) {
     198
     199// (3) Convert any remaining addresses [email protected] to the link <a href="mailto:[email protected]">A ^ B C</a>
     200
     201  $content = preg_replace_callback(
     202    '!'.ADDR_PATTERN.'!i',
    196203    create_function(
    197204      '$match',
    198205            '$em_email = $match[email];
    199             $em_name = emoba_dash_email($em_email);
     206            $em_name = emoba_textify_email($em_email);
    200207            $readable_email = emoba_glyph_email($em_email);
    201208            $id = "emoba-" . rand(1000, 9999);
     
    206213    $content );
    207214
     215}else{
     216
     217// (3) Convert any remaining addresses [email protected] to the glyphed form A [at] B [dot] C
     218
     219  $content = preg_replace_callback(
     220    '|'.ADDR_PATTERN.'|i',
     221    create_function(
     222      '$match',
     223            '$em_email = $match[email];
     224            $em_name = emoba_textify_email($em_email);
     225            $readable_email = emoba_glyph_email($em_email);
     226            $repaddr = $readable_email;
     227            return $repaddr;' ),
     228    $content );
     229
     230}
     231
    208232// We're through!
    209233  return $content;
     
    213237/****
    214238Finally, link emoba_replace() into WordPress filters
    215 ****/
     239******/
    216240add_filter('the_content', 'emoba_replace');
    217241add_filter('the_excerpt', 'emoba_replace');
    218 add_filter('comment_text', 'emoba_replace', 1); // must get there before the comment text filters do
     242add_filter('comment_text', 'emoba_replace', 1); // high priority, to get there before the comment text filters do
    219243add_filter('widget_text', 'emoba_replace');
    220244add_filter('author_email', 'emoba_replace');
    221245add_filter('comment_email', 'emoba_replace');
    222246
    223 
    224247?>
  • emoba-email-obfuscator-advanced/trunk/emoba_style.css

    r174395 r178276  
    1 /**************************
    2 + Email Obfuscator Popups
    3 ***************************/
     1/********************************
     2+ Email Obfuscator Popups v 1.2.5
     3*********************************/
    44.emoba-pop {
    55    color: #579;
    66}
    7 .emoba-pop span {
     7.emoba-pop span.emoba-hover {
    88    display: none;
    99}
    10 .emoba-pop:hover span {
     10.emoba-pop:hover span.emoba-hover {
    1111    display: inline;
    1212}
     
    1515    margin-right: 2px;
    1616}
    17 span.emoba-glyph {
     17.emoba-glyph {
     18  border-width:0;
     19  height: 7px;
    1820}
    1921span.emoba-em {
  • emoba-email-obfuscator-advanced/trunk/readme.txt

    r175856 r178276  
    77Tested up to: 2.8.6
    88Stable tag: 1.2
    9 Version: 1.2
     9Version: 1.2.5
    1010
    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 is seen 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 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>`)
     18 * standard email links (`<a href="mailto:[email protected]">Name</a>`)  
    1919
    20  * the special "easy to write" form  `[Name] [email protected]`
     20 * the special "easy to write" form  `[Name] [email protected]` 
    2121
    22  * a bare email address `[email protected]` (with or without "mailto:" in front of it)
     22 * a bare email address `[email protected]` (with or without "mailto:" in front of it)  
    2323
    24 These will appear as standard email links displaying "Name". A bare email will appear as a link `you-example-com` (punctuated with hyphens in place of @ and .), since there is no Name.
     24These will appear as standard email links displaying "Name". A bare email will appear as a link `you ^ example com` (punctuated with text in place of @ and .), since there is no Name.
    2525 
    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 ... />`).
     
    33331. Place the folder contained in the zip file into your wp-content/plugins directory.   
    3434
    35 2. From your wp-admin screen, activate the plugin Email Obfuscator Advanced.   
     352. From your wp-admin screen, activate the plugin emObA - Email Obfuscator Advanced.   
    3636
    3737
    3838== Changelog ==
    3939
    40  
    41 Ver 1.2  2009/11/19  Fixed repeat email bug: correctly treats identical repeat emails (of all types).  Now converts emails placed in text widgets (requires 2.3).  Fixed problem with multiple spaces in the special form  [name]   [email protected]
    42 Ver 1.1  2009/11/18  Fixed problem with operation in comments.   
    43 Ver 1.0  2009/11/16   
     40= 1.2.5 =
     412009/12/01  Cleaned up some code, improved JavaScript.  Introduced `BARE_TO_LINK`. Changed default textifying characters from dashes to hook and space.
     42= 1.2 =
     432009/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`.
     44= 1.1 =
     452009/11/18  Fixed problem with operation in comments.   
     46= 1.0 =
     472009/11/16   
    4448
    4549
     
    53571. The name?  obfuscate = obscurate = obnubilate < obliterate
    5458
     591. What does the constant `CLICKPOP` (defined at line 31 of emoba.php) do?
     60
     61  When `CLICKPOP` is defined true, hovering over "Name" changes the link to "Click to email Name".
     62
     631. What does the constant `BARE_TO_LINK` (defined at line 38 of emoba.php) 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. I don't like the hook and space you use in the textified emails!
     68
     69  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.) 
     70
    55711. What about styling and appearance?
    5672
    57  The following classes are used; they are defined in emoba_style.css.  You can add appearance styling, but the display: attributes must be left as shown in order that the hover popups work:
     73 The following css is used; it appears in emoba_style.css.  You can add appearance styling, but 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):
    5874 
    5975 `
    6076    .emoba-pop { }
    61     .emoba-pop span { display: none; }
    62     .emoba-pop:hover span { display: inline; }
    63     .emoba-glyph { }
     77    .emoba-pop span.emoba-hover { display: none; }
     78    .emoba-pop:hover span.emoba-hover { display: inline; }
     79    .emoba-glyph { border-width:0; height: 7px; }
    6480    .emoba-em { }
    6581
    6682 `
    67 
    68 1. What does the constant CLICKPOP (defined at line 37 of emoba.php) do?
    69 
    70   When CLICKPOP is defined true, hovering over "Name" changes the link to "Click to email Name".
    7183
    72841. How can I deal with emails in static files (header, footer, sidebar, etc)?
     
    7587 
    76881. What is the static html created for the email "Name" `<[email protected]>`?
    77 
    7889  `
    7990    <span id="emoba-nnnn">
    8091        <span class="emoba-pop">
    8192            Name
    82             <span>
     93            <span>  
    8394                <span class="emoba-em">
    8495                    A
    85                 </span>
    86                 <span class="emoba-symbol">
    87                     <img src="http://.../at-glyph.gif" class="emoba-glyph" alt="at" height="8" />
    88                 </span>
    89                 <span class="emoba-em">
     96                    <img src="http://.../at-glyph.gif" alt="at" class="emoba-glyph" />
    9097                    B
    91                 </span>
    92                 <span class="emoba-symbol">
    93                     <img src="http://.../dot-glyph.gif" class="emoba-glyph" alt="dot" height="9" />
    94                 </span>
    95                 <span class="emoba-em">
     98                    <img src="http://.../dot-glyph.gif" alt="dot" class="emoba-glyph" />
    9699                    C
    97                 </span>
     100                </span>  
    98101            </span>
    99102        </span>
    100103    </span>
     104    <script>...
    101105  `
    102106
    1031071. What is the HTML generated by the JavaScript? 
    104108
    105   With [hexified] the email [email protected] converted to %-hex characters:
    106 
    107   If CLICKPOP is false,
     109  If `CLICKPOP` is false,
    108110  `
    109     <a href="mailto:[hexified]" class="emoba-pop" title="Send email" >
    110         Name
     111    <a id="emoba-nnnn" class="emoba-pop" title="Send email" href="mailto:[hexified]" >
     112        <span>
     113            Name
     114        </span>
    111115    </a>
    112116  `
    113   If CLICKPOP is true,
     117  If `CLICKPOP` is true,
    114118  `
    115     <a href="mailto:[hexified]" class="emoba-pop" title="Send email" >
    116         <span class="emoba-pop">
     119    <a id="emoba-nnnn" class="emoba-pop" title="Send email" href="mailto:[hexified]" >
     120        <span class="emoba-hover">
    117121            Click to email
    118122        </span>
    119         Name
     123        <span>
     124            Name
     125        </span>
    120126    </a>
    121127  `
     128  where [hexified] means the email `[email protected]` converted to %-hex characters.
Note: See TracChangeset for help on using the changeset viewer.