Ignore:
Timestamp:
Mar 7, 2014, 3:22:34 PM (10 years ago)
Author:
plg
Message:

compatibility 2.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Piwecard/include/piwecard.class.php

    r25071 r27594  
    467467                }
    468468        }
     469
     470  /**
     471   * Encodes a string using Q form if required (RFC2045)
     472   * mail headers MUST contain only US-ASCII characters
     473   *
     474   * This function was in Piwigo core include/functions_mail.inc.php, but
     475   * was removed from version 2.6.
     476   */
     477  function encode_mime_header($str)
     478  {
     479    $x = preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
     480    if ($x==0)
     481    {
     482      return $str;
     483    }
     484    // Replace every high ascii, control =, ? and _ characters
     485    $str = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
     486                        "'='.sprintf('%02X', ord('\\1'))", $str);
     487   
     488    // Replace every spaces to _ (more readable than =20)
     489    $str = str_replace(" ", "_", $str);
     490   
     491    global $lang_info;
     492    return '=?'.get_pwg_charset().'?Q?'.$str.'?=';
     493  }
    469494       
    470495        /**
     
    478503               
    479504                $from = '"'.$email_infos['from_name'].'" <'.$email_infos['from_email'].'>';
    480                 $subject = encode_mime_header(trim(preg_replace('#[\n\r]+#s', '', $email_infos['subject'])));
     505                $subject = $this->encode_mime_header(trim(preg_replace('#[\n\r]+#s', '', $email_infos['subject'])));
    481506                $boundary = '_----------='.md5(uniqid(mt_rand()));
    482507
Note: See TracChangeset for help on using the changeset viewer.