Changeset 198952
- Timestamp:
- 01/28/2010 06:03:35 AM (16 years ago)
- Location:
- emoba-email-obfuscator-advanced/tags/1.3
- Files:
-
- 2 edited
-
emoba.php (modified) (8 diffs)
-
readme.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
emoba-email-obfuscator-advanced/tags/1.3/emoba.php
r198867 r198952 2 2 /* 3 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 "[EMAIL Name [email protected]]" is recognized and results in a link on "Name". Without JavaScript, hoveringpops up the email with graphic glyphs for "@" and ".". (Based on eMob Email Obfuscator 1.1 by Billy Halsey.)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, 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.) 5 5 Version: 1.3 6 6 License: GPL … … 25 25 */ 26 26 27 /**** 28 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]. 29 Regardless of the value of LEGACY, the new form `[EMAIL Name | [email protected]]` will be converted. 30 ****/ 31 define ("LEGACY", false); 32 27 33 28 34 /**** 29 35 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.) 30 36 ****/ 31 define ("CLICKPOP", true);37 define ("CLICKPOP", false); 32 38 33 39 … … 74 80 function emoba_readable_email($email="", $name="(Hover)" ) { 75 81 $glyph_email = emoba_glyph_email($email); 76 $addr = '<span class="emoba-pop">' . $name . '<span> '; 82 $addr = '<span class="emoba-pop">' . $name . '<span '; 83 // $addr .= ((true == CLICKPOP)? 'class="emoba-hover"' : ''); 84 $addr .= '> '; 77 85 $addr .= $glyph_email . ' </span></span>'; 78 86 return $addr; … … 81 89 82 90 /**** 83 This replaces "@" and "." with " ^ " and " " in $email; used for bare (nameless) emails91 This replaces "@" and "." with " ^ " and " " in $email; used for bare (nameless) emails 84 92 ****/ 85 93 function emoba_textify_email($email) { 86 $email = str_replace('@', ' ^', $email);87 $email = str_replace('.', ' ', $email);94 $email = str_replace('@', ' ^ ', $email); 95 $email = str_replace('.', ' , ', $email); 88 96 return $email ; 89 97 } … … 180 188 181 189 182 // // legacy (2) Convert the special pattern [Name] [email protected] to email link <a href="mailto:[email protected] >Name</a>183 190 // (2) Convert the special pattern [EMAIL Name | [email protected]] to email link <a href="mailto:[email protected] >Name</a> 184 191 185 192 $content = preg_replace_callback( 186 // legacy '!\[([^]]+)\](?:[\s]| )*'.EMAIL.'!', // [Name] [email protected] 187 '!\[EMAIL(?:[\s]| )+([^|]+)(?:(?:[\s]| )*[|](?:[\s]| )*)'.EMAIL.'(?:[\s]| )*]!', // [EMAIL Name | [email protected] ] 193 '!\[EMAIL(?:[\s]| )+([^|]+)(?:(?:[\s]| )*[|](?:[\s]| )*)'.EMAIL.'(?:[\s]| )*]!', 188 194 create_function( 189 195 '$match', … … 197 203 $content ); 198 204 199 200 if (true == BARE_TO_LINK ) { 205 if ( 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]| )*'.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 225 if ( true == BARE_TO_LINK ) { 201 226 202 227 // (3) Convert any remaining addresses [email protected] to the link <a href="mailto:[email protected]">A ^ B C</a> … … 209 234 $em_name = emoba_glyph_email($em_email); // This line throws xhtml validation error -- glyphed link 210 235 //$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"; 215 239 $repaddr .= emoba_addJScript($em_email, $em_name, $id); 216 240 return $repaddr;' ), … … 226 250 '$match', 227 251 '$em_email = $match[1]; 228 $readable_email = emoba_glyph_email($em_email); // Display glyphed email address229 //$readable_email = emoba_textify_email($em_email); // Display A ^ B C for address252 //$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 230 254 return $readable_email;' ), 231 255 $content ); -
emoba-email-obfuscator-advanced/tags/1.3/readme.txt
r198867 r198952 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 appears in 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 (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. 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>`), allowing (but ignoring) a ttributes in addition to href, and allowingextended 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=...) 19 19 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) 21 21 22 22 * a bare email address `[email protected]` (with or without "mailto:" in front of it) … … 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 ... />`). 27 27 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 JavaScriptwith graphics representing `@` and `.`, so even a fairly smart spambot will not be led easily to the address.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 html with graphics representing `@` and `.`, so even a fairly smart spambot will not be led easily to the address. 29 29 30 30 … … 37 37 38 38 == 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. 39 emoBA 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 40 41 41 42 == Changelog == 42 43 43 44 = 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.45 2010/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. 45 46 = 1.2 = 46 47 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`. … … 60 61 1. The name? obfuscate = obscurate = obnubilate < obliterate 61 62 62 1. What does the constant `CLICKPOP` (defined at line 31 of emoba.php) do? 63 1. 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 67 1. 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 72 1. What does the constant `CLICKPOP` (defined at line 37 of emoba.php; default=false) do? 63 73 64 74 When `CLICKPOP` is defined true, hovering over "Name" changes the link to "Click to email Name". 65 75 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! 76 1. I don't like the hook and comma you use in the textified emails! 71 77 72 78 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.) … … 74 80 1. What about styling and appearance? 75 81 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). 77 83 78 84 ` … … 87 93 1. How can I deal with emails in static files (header, footer, sidebar, etc)? 88 94 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. (ButemObA 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.) 90 96 91 97 1. What is the static html created for the email "Name" `<[email protected]>`?
Note: See TracChangeset
for help on using the changeset viewer.