Coder Social home page Coder Social logo

blowbackagency / emailobfuscation Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 9.0 86 KB

ProcessWire Email Obfuscation module for email addresses with 64 base crypting.

Home Page: https://modules.processwire.com/modules/email-obfuscation/

JavaScript 11.54% PHP 88.46%
email-obfuscator processwire

emailobfuscation's Introduction

ProcessWire Email Obfuscation (EMO)

Email Obfuscation module for email addresses with 64 base crypting

This module finds all plaintext emails and email links from the document and replaces them with noscript elements with configurable replace text. All the addresses are encoded to 64 base strings and stored in noscript data attributes. Then on client side we decode these strings back to their original state.

Install

ProcessWire installation

Install this module using standard install procedure in ProcessWire.

Using Composer

composer require blowback/emailobfuscation

Options

After install you can find some configurable options on module admin page.

Replace text string

Transliterable text string used as a replace to obfuscated email address.

Obfuscation mode

There is three modes available for this module to handle obfuscation.

  1. Obfuscate manually by using $sanitizer->emo($str) method.
  2. Obfuscate automatically at selected templates/pages.
  3. Obfuscate automatically but exclude selected templates/pages (default).

JavaScript loading method

  1. Load file manually.
  2. Load file to $config->scripts array.
  3. Append automatically to page as external script (default).
  4. Append automatically to page as inline script.

Force mailto

By enabling force mailto option all email addresses are rendered as mailto links regardless of their original state.

Fixed encrypt key

When enabled encryption key is locked and does not change. By default encryption key updates on every session. Fixed key is required when you cache obfuscated AJAX output for more than session lifetime.

Debug

Appends debug data to HTML and console output.

Selected Templates / Pages

List of selected templates/pages that are used to include or exclude at automatic obfuscation.

Thanks

This ProcessWire module originates from MODX Evolution plugin.

License

MIT License

emailobfuscation's People

Contributors

rolandtoth avatar roope avatar sekru1 avatar timohausmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

emailobfuscation's Issues

PHP 8.1 deprecation warning

PHP 8 and PHP 8.1 throws a deprecation warning:
is_nan(): Passing null to parameter #1 ($num) of type float is deprecated in EmailObfuscation.module on line 247 and 248.
Changing line 240 from
$c2 = $c3 = null;
to
$c2 = $c3 = 0;
seems to fix it.

saving config notice

I get this notice everytime I save the module config page.

Notice: Undefined variable: selector in /home/www-data/domain/site/modules/EmailObfuscation/EmailObfuscation.module on line 252

nested rendering of pages

I'm using this module on a large complex site. I use widgets to render with $page->render() in templates.

The obfuscation doesn't completely work in those, it parses them but the javascript array inserted at the bottom is empty. So it shows the "Enable Javascript..."

I figured that when I exclude those template that get rendered inside another page, and the obfuscation starts working again.

I tried to find out why it wouldn't work when using the $page->render() inside another template to render another page (partial) it doesn't work, but I'm not seeing it.

Any idea how to make it work without adding them to the exclude templates?

Spans should be removed

If I have an email

<a href="mailto:[email protected]">Mail</a>

It will be replaced by

<span id="emo_email_1" class="emo_email">Mail</span>

and finally javascript will change this to:

<span id="emo_email_1" class="emo_email">
<a href="mailto:[email protected]">Mail</a>
</span>

In my opinion the span should be replaced by <a href="" ...>
So their should not be a span in the final output.

It should be enough to change https://github.com/BlowbackDesign/emo/blob/master/emo.js#L41 to
elem.outerHTML = decrypt_string(i);

array_key_exists() expects parameter 2 to be array / Line 352

I get the following error message when I view a page with an email address:
PHP Warning: array_key_exists() expects parameter 2 to be array, null given in ..../site\modules\EmailObfuscation\EmailObfuscation.module:352

No selected Templates and no selected Pages in module config.

PHP 8, compatiblity, TypeError, int + string, incl. Fix

PHP 8.1.21, PW 3.0.221 dev

Uncaught TypeError: Unsupported operand types: int + string in /site/modules/EmailObfuscation/EmailObfuscation.module:444

$this->debugTime += Debug::timer($time);

Seems to get solved by typecasting it.

$this->debugTime += (int)Debug::timer($time);

If you can confirm this, it would nice to adapt this for a coming release.

PW 2.x not supported

The module breaks PW v2.x installations when upgrading from earlier versions of the module, due the presence of namespace ProcessWire at the top of the module file.

Suggest either remove the namespace declaration or require PW v3 in getModuleInfo() and update the compatibility statement in the modules directory.

PHP 7.4 deprecated warning (curly braces)

Hi
Just added your module on a PHP 7.4 installation.
There are some deprecated Infos:

Deprecated: Array and string offset access syntax with curly braces is deprecated in /site/modules/EmailObfuscation/EmailObfuscation.module on line 239

Replacing the curly braces with squares in the base64 function should fix this:

/**
 * custom base 64 encoding
 *
 */
private function base64($data)
{
	$out = '';
	$key = $this->getKey();
	for($i = 0; $i < strlen($data); ) {
		$c1 = ord($data[$i++]);
		$c2 = $c3 = NULL;
		if($i < strlen($data)) $c2 = ord($data[$i++]);
		if($i < strlen($data)) $c3 = ord($data[$i++]);
		$e1 = $c1 >> 2;
		$e2 = (($c1 & 3) << 4) + ($c2 >> 4);
		$e3 = (($c2 & 15) << 2) + ($c3 >> 6);
		$e4 = $c3 & 63;
		if(is_nan($c2)) $e3 = $e4 = 64;
		else if(is_nan($c3)) $e4 = 64;
		$out .= $key[$e1] . $key[$e2] . $key[$e3] . $key[$e4];
	}
	return $out;
}

Anyway, thanks for this great module!

PHP 8.2 deprecation warning

Hi,
While upgrading a bunch of PW installations, I have noticed the following PHP warning. Do you have any plans for PHP 8 support? PHP 8.1.10 and PHP 8.2.4 throw a deprecation warning:

Deprecated: is_nan(): Passing null to parameter #1 ($num) of type float is deprecated in /site/assets/cache/FileCompiler/site/modules/EmailObfuscation/EmailObfuscation.module on line 247

Keep up your great work ๐Ÿ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.