Changeset 178276
- Timestamp:
- 11/30/2009 11:17:29 PM (16 years ago)
- Location:
- emoba-email-obfuscator-advanced/trunk
- Files:
-
- 3 edited
-
emoba.php (modified) (12 diffs)
-
emoba_style.css (modified) (2 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
emoba-email-obfuscator-advanced/trunk/emoba.php
r175627 r178276 1 1 <?php 2 2 /* 3 Plugin Name: emObA - Email Obfuscator Advanced4 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 3 Plugin 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 "[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.5 6 6 License: GPL 7 7 Author: Kim Kirkpatrick … … 27 27 28 28 /**** 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.) 29 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.) 31 30 ****/ 32 31 define ("CLICKPOP", false); 33 32 33 34 /**** 35 If 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 ]]>) prevent the link from containing the glyph name. The only workaraound I know of requires hacking WordPress.) 37 ****/ 38 define ("BARE_TO_LINK", true); 34 39 35 40 … … 47 52 You may want to change the alts or i18n them. 48 53 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 54 If text rather than glyph is desired for the separators, 55 replace with your versions of define( 'SEP_AT', ...) and define( 'SEP_DOT', ... ); 56 ****/ 57 define( 'SEP_AT', '<img src="' . plugin_dir_url(__FILE__) . 'at-glyph.gif" alt="at" class="emoba-glyph" />' ); 58 define( 'SEP_DOT', '<img src="' . plugin_dir_url(__FILE__) . 'dot-glyph.gif" alt="dot" class="emoba-glyph" />' ); 59 60 61 /**** 62 This replaces "@" with SEP_AT and "." with SEP_DOT in $email 57 63 ****/ 58 64 function emoba_glyph_email($email) { 59 65 $email = str_replace('.', SEP_DOT, $email); 60 $email = str_replace('@', SEP_AT , $email);66 $email = str_replace('@', SEP_AT , $email); 61 67 return '<span class="emoba-em">' . $email . '</span>'; 62 68 } 63 69 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 /**** 72 This constructs a glyphed email address for use when JavaScript is not available 73 ****/ 74 function emoba_readable_mail($email="", $name="(Hover)" ) { 75 $glyph_email = emoba_glyph_email($email); 76 $addr = '<span class="emoba-pop">' . $name . '<span> '; 77 $addr .= $glyph_email . ' </span></span>'; 78 return $addr; 79 } 80 81 82 /**** 83 This replaces "@" and "." with " ^ " and " " in $email; used for bare (nameless) emails 84 ****/ 85 function emoba_textify_email($email) { 86 $email = str_replace('@', ' ^ ', $email); 87 $email = str_replace('.', ' ', $email); 70 88 return $email ; 71 89 } … … 73 91 74 92 /**** 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> <span class="emoba-em">'; 86 $addr .= $email . '</span> </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.) 93 This is the RE expression for detecting email addresses. (The result found is returned as $match[email].) 93 94 ****/ 94 95 define( "ADDR_PATTERN", … … 125 126 if (true == CLICKPOP) { 126 127 $emoba_js .= <<<AJS 128 127 129 var spanNode = document.createElement('span'); 130 spanNode.className = 'emoba-hover'; 128 131 spanNode.innerHTML = 'Click to email '; 129 132 linkNode.appendChild(spanNode); … … 132 135 } 133 136 $emoba_js .= <<<AJS 134 var tNode = document.createTextNode('$ename'); 137 138 var tNode = document.createElement('span'); 139 tNode.innerHTML = '$ename'; 135 140 linkNode.appendChild(tNode); 136 141 mailNode.parentNode.replaceChild(linkNode, mailNode); … … 146 151 a. as a link <a href="mailto:[email protected]">Name</a> 147 152 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.) 154 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. 150 155 3. 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.156 4. CSS (for classes emoba-pop, emoba-hover) creates the hover effect when JavaScript is turned off. 152 157 ****/ 153 158 … … 157 162 158 163 $content = preg_replace_callback( 159 ' |<a href="mailto:' .ADDR_PATTERN. '"[^>]*>(?P<name>[^<]+)</a>|i',164 '!<a href="mailto:' .ADDR_PATTERN. '"[^>]*>(?P<name>[^<]+)</a>!i', 160 165 create_function( 161 166 '$match', … … 175 180 $content = preg_replace("|mailto:".ADDR_PATTERN."|i", '$1', $content); 176 181 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]| )*".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]| )*".ADDR_PATTERN."!i", 181 186 create_function( 182 187 '$match', … … 190 195 $content ); 191 196 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', 197 if (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', 196 203 create_function( 197 204 '$match', 198 205 '$em_email = $match[email]; 199 $em_name = emoba_ dash_email($em_email);206 $em_name = emoba_textify_email($em_email); 200 207 $readable_email = emoba_glyph_email($em_email); 201 208 $id = "emoba-" . rand(1000, 9999); … … 206 213 $content ); 207 214 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 208 232 // We're through! 209 233 return $content; … … 213 237 /**** 214 238 Finally, link emoba_replace() into WordPress filters 215 **** /239 ******/ 216 240 add_filter('the_content', 'emoba_replace'); 217 241 add_filter('the_excerpt', 'emoba_replace'); 218 add_filter('comment_text', 'emoba_replace', 1); // mustget there before the comment text filters do242 add_filter('comment_text', 'emoba_replace', 1); // high priority, to get there before the comment text filters do 219 243 add_filter('widget_text', 'emoba_replace'); 220 244 add_filter('author_email', 'emoba_replace'); 221 245 add_filter('comment_email', 'emoba_replace'); 222 246 223 224 247 ?> -
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 *********************************/ 4 4 .emoba-pop { 5 5 color: #579; 6 6 } 7 .emoba-pop span {7 .emoba-pop span.emoba-hover { 8 8 display: none; 9 9 } 10 .emoba-pop:hover span {10 .emoba-pop:hover span.emoba-hover { 11 11 display: inline; 12 12 } … … 15 15 margin-right: 2px; 16 16 } 17 span.emoba-glyph { 17 .emoba-glyph { 18 border-width:0; 19 height: 7px; 18 20 } 19 21 span.emoba-em { -
emoba-email-obfuscator-advanced/trunk/readme.txt
r175856 r178276 7 7 Tested up to: 2.8.6 8 8 Stable tag: 1.2 9 Version: 1.2 9 Version: 1.2.5 10 10 11 11 == Description == 12 12 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 seenin the status bar when hovering), but to spambots they will have no recognizable features.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. 14 14 15 15 16 16 It recognizes, and produces obfuscated active (click-to-send) email links for, 17 17 18 * standard email links (`<a href="mailto:[email protected]">Name</a>`) 18 * standard email links (`<a href="mailto:[email protected]">Name</a>`) 19 19 20 * the special "easy to write" form `[Name] [email protected]` 20 * the special "easy to write" form `[Name] [email protected]` 21 21 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) 23 23 24 These will appear as standard email links displaying "Name". A bare email will appear as a link `you -example-com` (punctuated with hyphensin place of @ and .), since there is no Name.24 These 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. 25 25 26 26 This 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 ... />`). … … 33 33 1. Place the folder contained in the zip file into your wp-content/plugins directory. 34 34 35 2. From your wp-admin screen, activate the plugin Email Obfuscator Advanced.35 2. From your wp-admin screen, activate the plugin emObA - Email Obfuscator Advanced. 36 36 37 37 38 38 == Changelog == 39 39 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 = 41 2009/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 = 43 2009/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 = 45 2009/11/18 Fixed problem with operation in comments. 46 = 1.0 = 47 2009/11/16 44 48 45 49 … … 53 57 1. The name? obfuscate = obscurate = obnubilate < obliterate 54 58 59 1. 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 63 1. 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 67 1. 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 55 71 1. What about styling and appearance? 56 72 57 The following c lasses 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): 58 74 59 75 ` 60 76 .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; } 64 80 .emoba-em { } 65 81 66 82 ` 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".71 83 72 84 1. How can I deal with emails in static files (header, footer, sidebar, etc)? … … 75 87 76 88 1. What is the static html created for the email "Name" `<[email protected]>`? 77 78 89 ` 79 90 <span id="emoba-nnnn"> 80 91 <span class="emoba-pop"> 81 92 Name 82 <span> 93 <span> 83 94 <span class="emoba-em"> 84 95 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" /> 90 97 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" /> 96 99 C 97 </span> 100 </span> 98 101 </span> 99 102 </span> 100 103 </span> 104 <script>... 101 105 ` 102 106 103 107 1. What is the HTML generated by the JavaScript? 104 108 105 With [hexified] the email [email protected] converted to %-hex characters: 106 107 If CLICKPOP is false, 109 If `CLICKPOP` is false, 108 110 ` 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> 111 115 </a> 112 116 ` 113 If CLICKPOPis true,117 If `CLICKPOP` is true, 114 118 ` 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"> 117 121 Click to email 118 122 </span> 119 Name 123 <span> 124 Name 125 </span> 120 126 </a> 121 127 ` 128 where [hexified] means the email `[email protected]` converted to %-hex characters.
Note: See TracChangeset
for help on using the changeset viewer.