Exemple #1
0
 /**
  * Tests the JHtmlEmail::cloak method.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function testCloak()
 {
     $this->assertThat(JHtmlEmail::cloak('*****@*****.**'), $this->StringContains(".innerHTML += '<a ' + path + '\\'' + prefix + ':' + addy"), 'Cloak e-mail with mailto link');
     $this->assertThat(JHtmlEmail::cloak('*****@*****.**', false), $this->StringContains("var path = 'hr' + 'ef' + '=';"), 'Cloak e-mail with no mailto link');
     $this->assertThat(JHtmlEmail::cloak('*****@*****.**', true, '*****@*****.**'), $this->StringContains("var addy_text"), 'Cloak e-mail with mailto link and separate e-mail address text');
     $this->assertThat(JHtmlEmail::cloak('*****@*****.**', true, 'Joomla! Administrator', false), $this->StringContains("var addy_text"), 'Cloak e-mail with mailto link and separate non-e-mail address text');
 }
 /**
  * Tests the JHtmlEmail::cloak method.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function testCloak()
 {
     $this->assertThat(JHtmlEmail::cloak('*****@*****.**'), $this->StringContains('<span id="cloak'), 'Cloak email with mailto link');
     $this->assertThat(JHtmlEmail::cloak('*****@*****.**', false), $this->StringContains('<span id="cloak'), 'Cloak email with no mailto link');
     $this->assertThat(JHtmlEmail::cloak('*****@*****.**', true, '*****@*****.**'), $this->StringContains('<span id="cloak'), 'Cloak email with mailto link and separate email address text');
     $this->assertThat(JHtmlEmail::cloak('*****@*****.**', true, 'Joomla! Administrator', false), $this->StringContains('<span id="cloak'), 'Cloak email with mailto link and separate non-email address text');
 }
Exemple #3
0
 /**
  * Simple Javascript email Cloaker
  *
  * By default replaces an email with a mailto link with email cloaked
  *
  * @param  string   $mail    The -mail address to cloak.
  * @param  boolean  $mailto  True if text and mailing address differ
  * @param  string   $text    Text for the link
  * @param  boolean  $email   True if text is an e-mail address
  *
  * @return  string  The cloaked email.
  *
  * @since   11.1
  */
 public static function cloak($mail, $mailto = 1, $text = '', $email = 1)
 {
     // Convert text
     $mail = JHtmlEmail::_convertEncoding($mail);
     // Split email by @ symbol
     $mail = explode('@', $mail);
     $mail_parts = explode('.', $mail[1]);
     // Random number
     $rand = rand(1, 100000);
     $replacement = "\n <script type='text/javascript'>";
     $replacement .= "\n <!--";
     $replacement .= "\n var prefix = '&#109;a' + 'i&#108;' + '&#116;o';";
     $replacement .= "\n var path = 'hr' + 'ef' + '=';";
     $replacement .= "\n var addy" . $rand . " = '" . @$mail[0] . "' + '&#64;';";
     $replacement .= "\n addy" . $rand . " = addy" . $rand . " + '" . implode("' + '&#46;' + '", $mail_parts) . "';";
     if ($mailto) {
         // Special handling when mail text is different from mail address
         if ($text) {
             if ($email) {
                 // Convert text
                 $text = JHtmlEmail::_convertEncoding($text);
                 // Split email by @ symbol
                 $text = explode('@', $text);
                 $text_parts = explode('.', $text[1]);
                 $replacement .= "\n var addy_text" . $rand . " = '" . @$text[0] . "' + '&#64;' + '" . implode("' + '&#46;' + '", @$text_parts) . "';";
             } else {
                 $replacement .= "\n var addy_text" . $rand . " = '" . $text . "';";
             }
             $replacement .= "\n document.write('<a ' + path + '\\'' + prefix + ':' + addy" . $rand . " + '\\'>');";
             $replacement .= "\n document.write(addy_text" . $rand . ");";
             $replacement .= "\n document.write('<\\/a>');";
         } else {
             $replacement .= "\n document.write('<a ' + path + '\\'' + prefix + ':' + addy" . $rand . " + '\\'>');";
             $replacement .= "\n document.write(addy" . $rand . ");";
             $replacement .= "\n document.write('<\\/a>');";
         }
     } else {
         $replacement .= "\n document.write(addy" . $rand . ");";
     }
     $replacement .= "\n //-->";
     $replacement .= '\\n </script>';
     // XHTML compliance no Javascript text handling
     $replacement .= "<script type='text/javascript'>";
     $replacement .= "\n <!--";
     $replacement .= "\n document.write('<span style=\\'display: none;\\'>');";
     $replacement .= "\n //-->";
     $replacement .= "\n </script>";
     $replacement .= JText::_('JLIB_HTML_CLOAKING');
     $replacement .= "\n <script type='text/javascript'>";
     $replacement .= "\n <!--";
     $replacement .= "\n document.write('</');";
     $replacement .= "\n document.write('span>');";
     $replacement .= "\n //-->";
     $replacement .= "\n </script>";
     return $replacement;
 }