Source for file MailHide.php
Documentation is available at MailHide.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* This file is part of the PEAR Services_ReCaptcha package.
* LICENSE: This source file is subject to the MIT license that is available
* through the world-wide-web at the following URI:
* http://opensource.org/licenses/mit-license.php
* @package Services_ReCaptcha
* @author David Jean Louis <izi@php.net>
* @copyright 2008-2009 David Jean Louis
* @license http://opensource.org/licenses/mit-license.php MIT License
* @link http://pear.php.net/package/Services_ReCaptcha
* @link http://recaptcha.net/apidocs/mailhide/
* @since File available since release 0.1.0
require_once 'Services/ReCaptcha/Base.php';
* PHP5 interface to the reCATCHA MailHide API.
* reCAPTCHA Mailhide helps you protect your inbox by asking people to solve a
* reCAPTCHA before they can view your email address.
* To obtain an encryption key, you can go to the
* {@link http://mailhide.recaptcha.net/apikey key generation service}.
* This will compute a "public key", which much like a username identifies who
* you are to the MailHide server, and a "private key" which allows you to
* encrypt email addresses.
* @package Services_ReCaptcha
* @author David Jean Louis <izi@php.net>
* @copyright 2008-2009 David Jean Louis
* @license http://opensource.org/licenses/mit-license.php MIT License
* @version Release: @package_version@
* @link http://pear.php.net/package/Services_ReCaptcha
* @link http://recaptcha.net/apidocs/mailhide/
* @since Class available since release 0.1.0
* @example examples/example-03.php Services_ReCaptcha_MailHide example
* Url of the reCATCHA MailHide API.
public $apiURL = 'http://mailhide.recaptcha.net/d';
* Options to customize the apparence of the generated HTML and the
* corresponding popup window.
* - mask_text: string, the chars that will be displayed in the email
* - link_text: string, the text of the link;
* - link_title: string, the title (tooltip) of the link;
* - popup_width: integer, the popup width in pixels;
* - popup_height: integer, the popup height in pixels.
* @see Services_ReCaptcha_Base::getOption()
* @see Services_ReCaptcha_Base::setOption()
* @see Services_ReCaptcha_Base::getOptions()
* @see Services_ReCaptcha_Base::setOptions()
'link_title' => 'Reveal this e-mail address',
* The email address you want to "hide".
* @see Services_ReCaptcha_MailHide::getEmail()
* @see Services_ReCaptcha_MailHide::setEmail()
* Constructor, you must pass a valid public and private API key.
* Additionally, you can pass the email you want to hide, and an array of
* @param string $pubKey The public API key (mandatory)
* @param string $privKey The private API key (mandatory)
* @param string $email The email to hide (optional)
* @param array $options An array of options (optional)
* @see Services_ReCaptcha_MailHide::$email
* @see Services_ReCaptcha_MailHide::$options
public function __construct($pubKey, $privKey, $email = null ,
// check that mcrypt is available
* Returns the URL of the mailhide popup.
* @return string The mailhide popup URL
$padLength = $bsize - (strlen($email) % $bsize);
$cypher = MCRYPT_RIJNDAEL_128;
$yv = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
$encEmail = mcrypt_encrypt ($cypher, $key, $data, $mode, $yv);
* Returns the HTML code snippet that will hide your email.
* Instead of this method you can use the __toString() magic method to get
* the HTML code, for example:
* require_once 'Services/ReCaptcha/MailHide.php';
* $mailhide = new Services_ReCaptcha_MailHide(
* // both are equivalents:
* $html = $mailhide->getHTML();
* $html = (string) $mailhide;
* @return string The HTML code
* @see Services_ReCaptcha_Base::__toString()
if ($this->options['link_text'] === null ) {
$leftPartLength = strlen($emailParts[0 ]);
if ($leftPartLength <= 4 ) {
$emailParts[0 ] = substr($emailParts[0 ], 0 , 1 );
} else if ($leftPartLength <= 6 ) {
$emailParts[0 ] = substr($emailParts[0 ], 0 , 3 );
$emailParts[0 ] = substr($emailParts[0 ], 0 , 4 );
'%s<a href="%s" onclick="window.open(\'%s\', \'\', ' .
'\'toolbar=0,scrollbars=0,location=0,statusbar=0,' .
'menubar=0,resizable=0,width=%s,height=%s\'); return false;" ' .
* Returns the email to "hide".
* @return string The email to hide
* @see Services_ReCaptcha_MailHide::$email
* Sets the email to "hide" and returns the current
* Services_ReCaptcha_MailHide instance.
* @param string $email The email to hide
* @return Services_ReCaptcha_MailHide
* @see Services_ReCaptcha_MailHide::$email
Documentation generated on Mon, 11 Mar 2019 15:43:39 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|