[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/libraries/joomla/html/html/ -> email.php (source)

   1  <?php
   2  /**
   3  * @version        $Id: email.php 14998 2010-02-22 23:32:02Z ian $
   4  * @package        Joomla.Framework
   5  * @subpackage    HTML
   6  * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   7  * @license        GNU/GPL, see LICENSE.php
   8  * Joomla! is free software. This version may have been modified pursuant
   9  * to the GNU General Public License, and as distributed it includes or
  10  * is derivative of works licensed under the GNU General Public License or
  11  * other free or open source software licenses.
  12  * See COPYRIGHT.php for copyright notices and details.
  13  */
  14  defined('JPATH_BASE') or die();
  15  /**
  16   * Utility class for cloaking email adresses
  17   *
  18   * @static
  19   * @package     Joomla.Framework
  20   * @subpackage    HTML
  21   * @since        1.5
  22   */
  23  class JHTMLEmail
  24  {
  25      /**
  26      * Simple Javascript email Cloaker
  27      *
  28       * By default replaces an email with a mailto link with email cloacked
  29      */
  30  	function cloak( $mail, $mailto=1, $text='', $email=1, $prefix='mailto:', $suffix='', $attribs='' )
  31      {
  32          // convert text
  33          $mail             = JHTMLEmail::_convertEncoding( $mail );
  34          // split email by @ symbol
  35          $mail            = explode( '@', $mail );
  36          $mail_parts        = explode( '.', $mail[1] );
  37          // random number
  38          $rand            = rand( 1, 100000 );
  39          // obfuscate prefix
  40          $prefix = JHTMLEmail::_convertEncoding( $prefix );
  41  
  42          $replacement     = "\n <script language='JavaScript' type='text/javascript'>";
  43          $replacement     .= "\n <!--";
  44          $replacement     .= "\n var prefix = '$prefix';";
  45          $replacement    .= "\n var suffix = '$suffix';";
  46          $replacement    .= "\n var attribs = '$attribs';";
  47          $replacement     .= "\n var path = 'hr' + 'ef' + '=';";
  48          $replacement     .= "\n var addy". $rand ." = '". @$mail[0] ."' + '&#64;';";
  49          $replacement     .= "\n addy". $rand ." = addy". $rand ." + '". implode( "' + '&#46;' + '", $mail_parts ) ."';";
  50  
  51          if ( $mailto ) {
  52              // special handling when mail text is different from mail addy
  53              if ( $text ) {
  54                  if ( $email ) {
  55                      // convert text
  56                      $text             = JHTMLEmail::_convertEncoding( $text );
  57                      // split email by @ symbol
  58                      $text             = explode( '@', $text );
  59                      $text_parts        = explode( '.', $text[1] );
  60                      $replacement     .= "\n var addy_text". $rand ." = '". @$text[0] ."' + '&#64;' + '". implode( "' + '&#46;' + '", @$text_parts ) ."';";
  61                  } else {
  62                      $replacement     .= "\n var addy_text". $rand ." = '". $text ."';";
  63                  }
  64                  $replacement     .= "\n document.write( '<a ' + path + '\'' + prefix + addy". $rand ." + suffix + '\'' + attribs + '>' );";
  65                  $replacement     .= "\n document.write( addy_text". $rand ." );";
  66                  $replacement     .= "\n document.write( '<\/a>' );";
  67              } else {
  68                  $replacement     .= "\n document.write( '<a ' + path + '\'' + prefix + addy". $rand ." + suffix + '\'' + attribs + '>' );";
  69                  $replacement     .= "\n document.write( addy". $rand ." );";
  70                  $replacement     .= "\n document.write( '<\/a>' );";
  71              }
  72          } else {
  73              $replacement     .= "\n document.write( addy". $rand ." );";
  74          }
  75          $replacement     .= "\n //-->";
  76          $replacement     .= "\n </script>";
  77  
  78          // XHTML compliance `No Javascript` text handling
  79          $replacement     .= "<script language='JavaScript' type='text/javascript'>";
  80          $replacement     .= "\n <!--";
  81          $replacement     .= "\n document.write( '<span style=\'display: none;\'>' );";
  82          $replacement     .= "\n //-->";
  83          $replacement     .= "\n </script>";
  84          $replacement     .= JText::_('CLOAKING');
  85          $replacement     .= "\n <script language='JavaScript' type='text/javascript'>";
  86          $replacement     .= "\n <!--";
  87          $replacement     .= "\n document.write( '</' );";
  88          $replacement     .= "\n document.write( 'span>' );";
  89          $replacement     .= "\n //-->";
  90          $replacement     .= "\n </script>";
  91  
  92          return $replacement;
  93      }
  94  
  95  	function _convertEncoding( $text )
  96      {
  97          // replace vowels with character encoding
  98          $text     = str_replace( 'a', '&#97;', $text );
  99          $text     = str_replace( 'e', '&#101;', $text );
 100          $text     = str_replace( 'i', '&#105;', $text );
 101          $text     = str_replace( 'o', '&#111;', $text );
 102          $text    = str_replace( 'u', '&#117;', $text );
 103  
 104          return $text;
 105      }
 106  }
 107  
 108  


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1