Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for phpPlatonLib/Platon/Platon.php between version 1.27 and 1.28

version 1.27, 2004/12/13 10:23:54 version 1.28, 2004/12/27 21:17:22
Line 24 
Line 24 
  * @access      public   * @access      public
  */   */
   
 /* $Platon: phpPlatonLib/Platon/Platon.php,v 1.26 2004/12/12 21:50:18 nepto Exp $ */  /* $Platon: phpPlatonLib/Platon/Platon.php,v 1.27 2004/12/13 10:23:54 nepto Exp $ */
   
 class Platon  class Platon
 {  {
Line 603  class Platon
Line 603  class Platon
      * @param   string  $email  e-mail address       * @param   string  $email  e-mail address
      * @param   string  $mode   url            - does URL escaping       * @param   string  $mode   url            - does URL escaping
      *                          html           - does HTML escaping       *                          html           - does HTML escaping
        *                          url_and_html   - does URL & HTML escaping
        *                          mailto         - prepends "mailto:" and escapes
      *                          hypertext_link - creates hypertext link       *                          hypertext_link - creates hypertext link
      * @param   string  $attr   when creating hypertext link, additional       * @param   string  $attr   when creating hypertext link, additional
      *                          attributes may be added       *                          attributes may be added
Line 610  class Platon
Line 612  class Platon
      */       */
     function escape_email($email, $mode = 'hypertext_link', $attr = '')/* {{{ */      function escape_email($email, $mode = 'hypertext_link', $attr = '')/* {{{ */
     {      {
         /* Code borrowed from Smarty template engine;  
            Smarty-2.1.0/plugins/modifier.escape.php file */  
   
         $ret = '';          $ret = '';
         switch ($mode) {          switch ($mode) {
               case 'url_and_html':
               case 'url_html':
             case 'url':              case 'url':
                 // escape every character into hex                  // escape every character into hex
                 for ($x = 0; $x < strlen($email); $x++) {                  for ($x = 0; $x < strlen($email); $x++) {
                     $ret .= '%' . bin2hex($email[$x]);                      $ret .= '%' . bin2hex($email[$x]);
                 }                  }
                 break;                  if ($mode == 'url') {
                       break;
                   }
                   $email = $ret;
                   $ret   = '';
                   // ... and continue with HTML escaping
             case 'html':              case 'html':
                 for ($x = 0; $x < strlen($email); $x++) {                  for ($x = 0; $x < strlen($email); $x++) {
                     $ret .= (ord($email[$x]) > 127                      $ret .= (ord($email[$x]) > 127
                             ? $email[$x] : '&#x'.bin2hex($email[$x]).';');                              ? $email[$x] : '&#x'.bin2hex($email[$x]).';');
                 }                  }
                 break;                  break;
               case 'mailto':
                   $ret  = '&#x6d;&#x61;&#x69;&#x6c;&#x74;&#x6f;&#x3a;';// mailto:
                   $ret .= Platon::escape_email($email, 'url_and_html');
                   break;
             default:              default:
             case 'hypertext_link':              case 'hypertext_link':
                 is_array($attr) && $attr = join(' ', $attr);                  is_array($attr) && $attr = join(' ', $attr);
                 $attr != '' && $attr .= ' ';                  $attr != '' && $attr .= ' ';
                 $ret = '<a '.$attr.'href="mailto:'                  $ret = sprintf('<a %shref="%s">%s</a>', $attr,
                     . Platon::escape_email($email, 'url') . '">'                          Platon::escape_email($email, 'mailto'),
                     . Platon::escape_email($email, 'html') . '</a>';                          Platon::escape_email($email, 'html'));
                 break;                  break;
         }          }
         return $ret;          return $ret;

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top