/src/system/application/libraries/qdmail.php
PHP | 4120 lines | 3564 code | 216 blank | 340 comment | 530 complexity | e2ec42afa2bdbd6048c4784be5743f2f MD5 | raw file
Possible License(s): GPL-2.0
Large files files are truncated, but you can click here to view the full file
- <?php
- /**
- * Qdmail ver 1.2.6b
- * E-Mail for multibyte charset
- *
- * PHP versions 4 and 5 (PHP4.3 upper)
- *
- * Copyright 2008, Spok in japan , tokyo
- * hal456.net/qdmail : http://hal456.net/qdmail/
- * & CPA-LAB/Technical : http://www.cpa-lab.com/tech/
- * Licensed under The MIT License License
- *
- * @copyright Copyright 2008, Spok.
- * @link http://hal456.net/qdmail/
- * @version 1.2.6b
- * @lastmodified 2008-10-23
- * @license http://www.opensource.org/licenses/mit-license.php The MIT License
- *
- * Qdmail is sending e-mail library for multibyte language ,
- * easy , quickly , usefull , and you can specify deeply the details.
- * Copyright (C) 2008 spok
- */
- //-------------------------------------------
- // For CakePHP , extended 'Object' Class ,
- // if including in CakePHP Component .
- // At normal PHP Script or another Framework ,
- // 'QdmailBranch' means Dummy Base Class .
- //-------------------------------------------
- if (!defined('QD_DS')) {
- define('QD_DS', DIRECTORY_SEPARATOR);
- }
-
- if ( defined('CAKE_CORE_INCLUDE_PATH') || defined('CAKE')) {
- class QdmailBranch extends Object{
- }
- }else{
- class QdmailBranch{
- }
- }
-
- if( !function_exists( 'qd_send_mail' ) ){
-
- function qd_send_mail( $type , $to = null, $subject = null , $content = null , $other_header = array() , $attach = null, $debug = 0 ){
- $type_org = $type;
-
- $mail = Qdmail::getInstance();
- $mail->debug = $debug;
- if(!is_array($type)){
- $type = array('TYPE'=>$type);
- }
- list( $type , $link ) = $mail->keyUpper($type);
- $option = array();
- $return = array();
- $type = array_change_key_case( $type , CASE_UPPER ) ;
- $option = (isset($type['OPTION']) && is_array($type['OPTION'])) ? $type['OPTION'] : array(); $return = (isset($type['RETURN']) && is_array($type['RETURN'])) ? $type['RETURN'] : array();
- if(isset($type['SMTP'])){
- $option = array_merge($option,array('SMTP'=>true,'smtpServer'=>$type['SMTP']));
- }
- $type = isset($type['TYPE']) ? $type['TYPE']:'text';
- $_type=array('TEXT'=>'Text','HTML'=>'Html','DECO'=>'Deco' ,'DECOTEMPLATE'=>'DecoTemplate');
- $easy_method = isset($_type[strtoupper($type)]) ? 'easy'.$_type[strtoupper($type)]:'_';
-
- if(!method_exists($mail,$easy_method)){
- $mail -> errorGather('Illegal type \''.$type.'\'',__LINE__);
- return false;
- }
-
- $ret = $mail->{$easy_method}( $to , $subject , $content , $other_header , $attach , $option );
-
- foreach($return as $method => $value ){
- if(method_exists($mail,$method)){
- $type_org[$link['RETURN']][$method] = $mail -> {$method}($value);
- }
- }
- if(0!==count($return)){
- $type_org[$link['RETURN']]['qd_send_mail'] = $ret;
- $ret = $type_org;
- }
-
- return $ret;
- }
- }
-
- class QdmailBase extends QdmailBranch{
-
- //----------------------------
- // Default Language
- // If you do not Japanese
- // Please change this propaty for your Language and Encoding
- //----------------------------
- var $lang_def = "ja";
- var $encoding_def = "utf-8";
- var $detect_def = array('ASCII','JIS','UTF-8','EUC-JP','SJIS');
- var $mb_parameter_stack = null;
- var $united_charset = null;
- var $mime_encode_max = 75;
- //------------------------
- // Time Zone , Message Id
- //------------------------
- var $time_zone = null; // '+0900' in Japan
- var $message_id = true;
- var $salt = 'qdmail';
- var $message_id_right = null;
- //----------------------------
- // Line Feed Character & kana
- //----------------------------
- var $LFC = "\r\n";// Notice: CRLF ,If you failed, change to "\n"
- var $LFC_Qmail = null;
- var $is_qmail = null;
- var $language = 'ja';
- var $kana = false; // kana header
- //----------
- // sysytem
- //----------
- var $kana_content_relation = false;
- var $name = 'Qdmail';
- var $version = '1.2.6b';
- var $xmailer = 'PHP-Qdmail';
- var $license = 'The_MIT_License';
- //--------------------
- // charset , encoding
- //--------------------
- var $charset_header = 'iso-2022-jp';
- var $charset_content = 'iso-2022-jp';
- var $charset_attach_filename = 'iso-2022-jp';
- var $content_transfer_enc_text = '7bit';
- var $content_transfer_enc_html = '7bit';
- var $detect_order = false;
- // var $detect_order = "iso-2022-jp,eucJP-win,UTF-8,SJIS-win,jis,ASCII";
- var $qdmail_system_charset = 'utf-8';
- var $force_change_charset = false;
- var $corres_charset = array(
- 'HEADER'=>'charset_header',
- 'BODY'=>'charset_content',
- 'ATTACH'=>'charset_attach_filename',
- 'TEXT'=>'content_transfer_enc_text',
- 'HTML'=>'content_transfer_enc_html',
- 'DETECT'=>'detect_order',
- 'SYSTEM'=>'qdmail_system_charset',
- ) ;
- //--------------------------
- // for address
- //--------------------------
- var $varidate_address_regex = '/[^@]+@[^@]+/';
- var $allow_blank_header = false;
- var $addr_many = array(
- 'TO' => true,
- 'CC' => true,
- 'BCC' => true,
- 'FROM' => false,
- 'REPLYTO'=> false
- );
- var $addr_head_name = array(
- 'TO' => 'To',
- 'CC' => 'Cc',
- 'BCC' => 'Bcc',
- 'FROM' => 'From',
- 'REPLYTO'=>'Reply-To'
- );
- var $header_must =array( 'TO' , 'FROM' , 'SUBJECT' );
- var $body_empty_allow = false;
- var $tokey = array(
- '_ADDR' => 'mail',
- '_NAME' => 'name',
- );
- //--------------
- // content_id
- //--------------
- var $content_id_include_attach_path = false ;
- var $content_id_only_filename = true ;
- //---------------
- // Once mode
- //---------------
- var $body_structure = array();
- var $body_build_once = false;
- var $body_already_build = false;
- var $attach_build_once = true;
- var $attach_already_build = false;
- //------------------------------
- // simple replace
- //------------------------------
- var $simple_replace = false;
- var $replace = array();
- var $replace_with_to_priority= true;
- var $replace_def = array();
- // simple replace command prefix
- var $rep_prefix = null;
- //---------
- // wordwrap
- //---------
- var $wordwrap_allow = false;
- var $wrap_prohibit_allow = false;
- var $wordwrap_length= 45 ;
- // inteligent wordwrap
- // false is that the word exist in the line ,
- // true is that the word must be the beginning of a line
- var $wrap_except = array(
- 'http://'=>false,
- 'code'=>true,
- );
- var $wrap_prohibit_top=',.;:–?!‼、。.))]}}〕〉》」』】〙〗〟’”»ヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎ‐〜?!';
- var $wrap_prohibit_end='(([{{〔〈《「『【〘〖‘“« ';
- var $wrap_prohibit = array();
- // multibyte wordwrap , by wordcount or by wordwidth
- var $wrap_width = true;
- // multibyte wordwidth compare by ascii
- var $mb_strwidth_magni = 2;
- //------------------
- // To Separate mode
- //------------------
- var $to_separate = false ;
- //----------------------------
- // html mail
- //----------------------------
- var $is_html = null ;
- var $auto_both = true ; // text & html
- var $inline_mode = false;
- var $deco_kind = null ; // number of $this->deco_def
- var $auto_deco_judge= false;
- var $no_inline_attach_structure = 0;
- var $deco_def_default = 0;
- var $deco_def =array(
- array(
- 'OPTION_NAME' => array( 'MHTML' , 'INLINE' , 'PC' ),
- 'STRUCTURE' => 1,
- '_CHARSET' => 'iso-2022-jp' ,
- 'ENC_TEXT' => '7bit',
- 'ENC_HTML' => 'QUOTED-PRINTABLE',
- 'HTML_EXTERNAL' => false,
- 'DISPOSITION' => true,
- ),
- array(
- 'OPTION_NAME' => array( 'DC' , 'DOCOMO' ),
- 'STRUCTURE' => 2,
- '_CHARSET' => 'iso-2022-jp',
- 'ENC_TEXT' => '7bit',
- 'ENC_HTML' => 'QUOTED-PRINTABLE',
- 'HTML_EXTERNAL' => array('this','stripCrlf'),
- 'DISPOSITION' => false,
- ),
- array(
- 'OPTION_NAME' => array( 'AU' ,'EZ', 'EZWEB'),
- 'STRUCTURE' => 3,
- '_CHARSET' => 'iso-2022-jp',
- 'ENC_TEXT' => '7bit',
- 'ENC_HTML' => 'QUOTED-PRINTABLE',
- 'HTML_EXTERNAL' => array('this','stripCrlf'),
- 'DISPOSITION' => true,
- ),
- array(
- 'OPTION_NAME' => array( 'SB' , 'SOFTBANK' ),
- 'STRUCTURE' => 4,
- '_CHARSET' => 'iso-2022-jp',
- 'ENC_TEXT' => '7bit',
- 'ENC_HTML' => 'QUOTED-PRINTABLE',
- 'HTML_EXTERNAL' => array('this','stripCrlf') ,
- 'DISPOSITION' => true ,
- ),
- array(
- 'OPTION_NAME' => array( 'EM','EMOBILE' ,'EMNET'),
- 'STRUCTURE' => 2,
- '_CHARSET' => 'iso-2022-jp',
- 'ENC_TEXT' => '7bit',
- 'ENC_HTML' => 'QUOTED-PRINTABLE',
- 'HTML_EXTERNAL' => array('this','stripCrlf') ,
- 'DISPOSITION' => true ,
- ),
- array(
- 'OPTION_NAME' => array( 'WL','WILLCOM' ,'POCKET'),
- 'STRUCTURE' => 2,
- '_CHARSET' => 'iso-2022-jp',
- 'ENC_TEXT' => '7bit',
- 'ENC_HTML' => 'QUOTED-PRINTABLE',
- 'HTML_EXTERNAL' => array('this','stripCrlf') ,
- 'DISPOSITION' => true ,
- ),
- array(
- 'OPTION_NAME' => array( 'TEMPLATE_DC' , 'TEMPLATE_DOCOMO' ,'TPL_DC'),
- 'STRUCTURE' => 5,
- '_CHARSET' => 'Shift_JIS',
- 'ENC_TEXT' => '8bit',
- 'ENC_HTML' => '8bit',
- 'HTML_EXTERNAL' => array('this','stripCrlf'),
- 'DISPOSITION' => false,
- 'BOUNDARY' => 'mime9DC9bdary',
- 'TOP' => array('Decomail-Template'),
- 'CID_PREFIX' => 'img_',
- 'CID_NUM_COL' => 3,
- ),
- array(
- 'OPTION_NAME' => array( 'TEMPLATE_AU','TPL_AU' ,'TPL_AU_2_0'),
- 'STRUCTURE' => 6,
- '_CHARSET' => 'iso-2022-jp',
- 'ENC_TEXT' => '7bit',
- 'ENC_HTML' => '7bit',
- 'HTML_EXTERNAL' => array('this','stripCrlf'),
- 'DISPOSITION' => false,
- 'BOUNDARY' => '--=_KDDI_NEXT_PART_0000',
- 'TOP' => array('KDDI_HTML_MAIL_2_0'),
- 'CID_PREFIX' => 'img_cid_',
- 'CID_NUM_COL' => 3,
- ),
- array(
- 'OPTION_NAME' => array( 'TEMPLATE_AU_1_0','TPL_AU_1_0' ,'TPL_AU_1_0'),
- 'STRUCTURE' => 6,
- '_CHARSET' => 'iso-2022-jp',
- 'ENC_TEXT' => '7bit',
- 'ENC_HTML' => '7bit',
- 'HTML_EXTERNAL' => array('this','stripCrlf'),
- 'DISPOSITION' => false,
- 'BOUNDARY' => '--=_KDDI_NEXT_PART_0000',
- 'TOP' => array('KDDI_HTML_MAIL_1_0'),
- 'CID_PREFIX' => 'img_cid_',
- 'CID_NUM_COL' => 3,
- ),
- array(
- 'OPTION_NAME' => array( 'TEMPLATE_SB','TPL_SB' ),
- 'STRUCTURE' => 5,
- '_CHARSET' => 'Shift_JIS',
- 'ENC_TEXT' => '8bit',
- 'ENC_HTML' => '8bit',
- 'HTML_EXTERNAL' => array('this','stripCrlf'),
- 'DISPOSITION' => false,
- 'BOUNDARY' => 'aremejkj15a14',
- 'TOP' => array('HTMLMail-Template-Version:1.0',
- 'HTMLMail-Template-Title:HTMLMail-Template',
- ''
- ),
- 'CID_PREFIX' => '',
- 'CID_NUM_COL' => 2,
- 'CID_AFTER' => '@areme.jp',
- ),
- );
-
- var $structure =array(
- // no inline attachment
- 0 => array(
- 'multipart/mixed' => array(
- 'multipart/alternative'=>array(
- 'html' => 1,
- 'plain' => 1,
- 'OMIT' => true,
- ),
- 'image' => 'BOTH', // Available Inline
- 'OMIT' => true,
- ),
- 'OMIT' => true,
- ),
- // PC inline HTML
- 1 => array(
- 'multipart/mixed' => array(
- 'multipart/alternative'=>array(
- 'multipart/related' => array(
- 'html' => 1,
- 'image' => 'INLINE',
- 'OMIT' => true,
- ),
- 'plain' => 1,
- 'OMIT' => true,
- ),
- 'image' => 'NOT_INLINE', // not inline
- 'OMIT' => true,
- ),
- 'OMIT' => true,
- ),
- 2 => array(
- 'multipart/mixed' => array(
- 'multipart/related'=>array(
- 'multipart/alternative' => array(
- 'plain' => 1,
- 'html' => 1,
- 'OMIT' => false,
- ),
- 'image' => 'INLINE',
- 'OMIT' => false,
- ),
- 'OMIT' => false,
- 'image' => 'NOT_INLINE',
- ),
- 'OMIT' => false,
- ),
- 3 => array(
- 'multipart/mixed' => array(
- 'multipart/alternative' => array(
- 'plain' => 1,
- 'html' => 1,
- 'OMIT' => false,
- ),
- 'image' => 'BOTH',
- 'OMIT' => false,
- ),
- 'OMIT' => false,
- ),
- 4 => array(
- 'multipart/related'=>array(
- 'multipart/alternative' => array(
- 'plain' => 1,
- 'html' => 1,
- 'OMIT' => false,
- ),
- 'image' => 'INLINE',
- 'OMIT' => false,
- ),
- 'image' => 'NOT_INLINE',
- 'OMIT' => false,
- ),
- 5 => array(
- 'multipart/related'=>array(
- 'plain' => 1,
- 'html' => 1,
- 'image' => 'INLINE',
- 'OMIT' => false,
- ),
- 'OMIT' => false,
- ),
- 6 => array(
- 'multipart/mixed'=>array(
- 'plain' => 1,
- 'html' => 1,
- 'image' => 'INLINE',
- 'OMIT' => false,
- ),
- 'OMIT' => false,
- ),
- );
- var $deco_judge = array(
- 'docomo.ne.jp' => 'DC',
- 'softbank.ne.jp' => 'SB',
- 'i.softbank.ne.jp' => 'SB',
- 'disney.ne.jp' => 'SB',
- 'vodafone.ne.jp' => 'SB',
- 'ezweb.ne.jp' => 'AU',
- 'emnet.ne.jp' => 'EM',
- 'pdx.ne.jp' => 'WL',
- 'gmail.com' => 'DC',
- );
-
- //------------------
- // using address and content
- //------------------
- var $to = array() ;
- var $from = array() ;
- var $cc = array() ;
- var $bcc = array() ;
- var $done = array() ;
- var $undone = array() ;
- var $replyto = array() ;
- var $recipient = array() ;
- var $allways_bcc = null ;
- var $header = array() ;
- var $other_header = array() ;
- var $header_content_type = array();
- var $content = array(
- 'TEXT'=>array(
- 'CONTENT' => null,
- 'LENGTH' => null,
- '_CHARSET' => null,
- 'ENC' => null,
- '_ORG_CHARSET' => null,
- ),
- 'HTML'=>array(
- 'CONTENT' => null,
- 'ORG_CONTENT' => null,
- 'LENGTH' => null,
- '_CHARSET' => null,
- 'ENC' => null,
- '_ORG_CHARSET' => null,
- ),
- );
- var $header_for_mailfunction_to;
- var $header_for_mailfunction_subject;
- var $header_for_mailfunction_other;
- var $content_for_mailfunction;
- var $header_for_smtp_array;
- var $content_all_for_smtp;
- var $header_for_smtp;
- //--------------
- // attachament
- //--------------
- var $attach = array();
- var $attach_path = null;
- var $auto_ext = true ; // mimetypes
- var $content_id_fix = false;
- //------------------------
- // Mailer
- //-------------------------
- var $mailer = 'mail';
- //------------------------
- // Sendmail
- //-------------------------
- var $sendmail = false ;
- var $sendmail_path = null;
- //------------------------
- // SMTP
- //-------------------------
- var $smtp = false ;
- var $smtp_object = null;
- var $smtp_loglevel_link = false;
- var $smtp_server = array(
- 'host' => null ,
- 'port' => 25 ,
- 'from' => null,
- 'user' => null,
- 'pass' => null,
- 'protocol' => null,
- 'pop_host' => null,
- 'pop_user' => null,
- 'pop_pass' => null,
- );
- //------------------------
- // render Mode
- //------------------------
- var $render_mode = false;
- var $size = array();
- //------------------------
- // Priority
- //------------------------
- var $priority = null;
- var $priority_def =array(
- 'X-Priority' => array( 'HIGH' => 1 , 'NORMAL' => 3 , 'LOW' =>5 ),
- 'X-MsMail-Priotiry' => array( 'HIGH'=>'High' , 'NORMAL'=>'Normal' , 'LOW'=>'Low' ),
- 'Priotiry' => array( 'HIGH'=>'urgent' , 'NORMAL' => 'normal' , 'LOW'=> 'non-urgent' ),
- 'Importance' => array( 'HIGH' =>'High' , 'NORMAL'=>'Normal' ,'LOW' =>'Low' ),
- );
- //------------------------
- // signed
- //------------------------
- var $sign = false;
- var $smime = false;
- var $pgp = false;
- var $private_key_file = 'private.pem';
- var $certificate_file = 'cert.pem';
- var $certificate_pass = null;
- var $certificate_file_path = null;
- var $certificate_temp_path = null;
- var $certificate_file_path_win = 'c:\cert';
- var $certificate_temp_path_win = 'c:\temp';
- var $certificate_file_path_unix = '/user/local/cert';
- var $certificate_temp_path_unix = '/tmp';
- //------------------------
- // etc
- //------------------------
- var $temporary_path = null;
- var $simple_attach = false;
- var $keep_parameter = array(false);
- var $mta_option = null ;
- var $is_create = false;
- var $address_validation_method = array('this','validateAddr');
- var $boundary_base_degit= 2 ;
- var $stack_construct = null ;
- var $start_time = null;
- var $framework = null;
- //-------------------------------
- // logs
- // 0 is nolog,
- // 1 is simple(Message 'Success' & recipt e-mail@address ),
- // 2 is including header data,
- // 3 is including fulldata,
- //------------------------------
- var $log_level = 0 ;
- var $log_level_max = 3 ;
- var $log_path = './';
- var $log_filename = 'qdmail.log';
- var $log_append = 'a' ;
- var $log_dateformat = 'Y-m-d H:i:s';
- var $log_LFC = "\n";
- // -------------------------------
- // error & error logs
- // 0 is nolog,
- // 1 is simple,
- // 2 is including header data,
- // 3 is inc fulldata
- //--------------------------------
- var $error = array();
- var $error_stack = array();
- var $error_display = true;
- var $errorlog_level = 0 ;
- var $errorlog_level_max = 3 ;
- var $errorlog_path = './';
- var $errorlog_filename= 'qbmail_error.log';
- var $errorlog_append= 'a' ;
- var $ignore_error = false ;
- //----------------
- // debug
- // 0 is no debug mode & really sending ,
- // 1 is showing header&body & really sending ,
- // 2 is no sending & showing header&body and some vars
- //----------------
- var $debug = 0 ;
- var $debug_report = false;
- var $debug_report_path = './';
- var $debug_echo_charset= true;
-
- //****************************************************
- // Methods
- //****************************************************
- //--------------------------------
- // constructor set error display
- // $charset_def = null,
- // $error_display = true
- // $mail -> (&) new Qdmail( Charset , Encoding , DetectOrder , error_display );
- //--------------------------------
-
- function __construct( $param = null ){
- $this->stack_construct = $param ;
- if( !empty( $param[0] ) && !empty( $param[1] ) ){
- $this->charset( $param[0] , $param[1] );
- }elseif( !empty( $param[0] ) ){
- $this->charset( $param[0] );
- }
- if( !empty( $param[2] ) ){
- $this->detect_order = $param[1];
- }
- if( false !== $this->detect_order ){
- $this->qd_detect_order( $this->detect_order );
- }
- if( !empty( $param[3] ) ){
- $this->error_display = $param[2];
- }
-
- if(is_null($this->LFC)){
- $this->LFC = chr(13) . chr(10);
- }
-
- if(is_null($this->LFC_Qmail)){
- $this->LFC_Qmail = chr(10);
- }
-
- if($this->isQmail()){
- $this->LFC = $this->LFC_Qmail;
- }
- $this->optionNameLink();
- $this->wordwrapProhibitConstruct();
- $this->sendmail_path = ini_get("sendmail_path");
- }
-
- function & getInstance(){
- static $instance = array();
-
- if( isset($instance[0]) && is_object($instance[0]) ){
- $keep = $instance[0]->keep_parameter;
-
- if( is_string($keep[0]) ){
- $stack = array();
- foreach($keep as $method){
- if( !is_string( $method ) || !method_exists( $instance[0] , $method ) ){
- continue;
- }
- $stack[$method] = $instance[0]->{$method}();
- }
- $instance[0] -> reset();
- foreach($stack as $method => $value){
- $instance[0]->{$method}($value);
- }
- }elseif( true !== $keep[0] ){
- $instance[0] -> reset();
- }
-
- return $instance[0];
- }
- $instance[0] = new Qdmail();
- return $instance[0];
- }
- //--------------------------
- // Decoration Mail Template
- //--------------------------
- function makeDecoTemplate( $deco_kind , $content ){
-
- if(false===($this->deco_kind=$this->decoSelect( $deco_kind ))){
- return $this->errorGather('Illegal Decoration Kind \''.$deco_kind.'\'',__LINE__);
- }
-
- $DECO = new QdDeco;
- $DECO -> template($content);
- $DECO -> decode();
- $content = $DECO -> get('HTML');
- $attach = $DECO -> get('ATTACH');
- $this -> renderMode( true );
- $this -> to('dummy@example.com');
- $this -> from('dummy@example.com');
- $this -> subject('dummy_subject');
- $this->body = null;
- $this->after_id = null;
- $this->content_id_fix = true;
- $this->is_html = 'HTML';
- $count = 0;
-
- $content = $this->qd_convert_encoding($content,'utf-8',$this->qd_detect_encoding($content));
- $content=preg_replace('/\r?\n/','',$content);
-
- foreach($attach as $key => $att){
- if( empty( $attach[$key]['CONTENT-ID'] ) ){
- continue;
- }
-
- $aft = isset($this->deco_def[$this->deco_kind]['CID_AFTER']) ? $this->deco_def[$this->deco_kind]['CID_AFTER']:'';
- $prefix = isset($this->deco_def[$this->deco_kind]['CID_PREFIX']) ? $this->deco_def[$this->deco_kind]['CID_PREFIX']:'';
- $col_num = isset($this->deco_def[$this->deco_kind]['CID_NUM_COL']) ? $this->deco_def[$this->deco_kind]['CID_NUM_COL']:3;
- $ct = '00'.$count++;
- $start = (strlen($ct)-$col_num) < 0 ? 0:strlen($ct)-$col_num;
- $end = strlen($ct)-$start;
- $new_cid = $prefix
- . substr($ct,$start,$end)
- . $aft;
- $content=preg_replace('/<\s*IMG\s+SRC\s*=\s*"cid:'.$attach[$key]['CONTENT-ID'].'"/is','<IMG SRC="cid:'.$new_cid.'"',$content);
- $attach[$key]['CONTENT-ID'] = $new_cid;
- }
- $this->html( $content , null , null , 'utf-8' );
- if( 0 < count($attach) ){
- $this->attach( $attach );
- }
- $this->createMail(
- $this->deco_def[$this->deco_kind]['BOUNDARY'],
- true
- );
-
- $header = '';
- foreach($this->deco_def[$this->deco_kind]['TOP'] as $line){
- $header .= $line .$this->LFC;
- }
- $header .= 'MIME-Version: 1.0' . $this->LFC
- . 'Content-type: ' . key($this->structure[$this->deco_def[$this->deco_kind]['STRUCTURE']])
- . '; boundary="'.$this->deco_def[$this->deco_kind]['BOUNDARY'] . '"'
- . $this->LFC;
- return $header . $this->LFC . $this -> smtpDataBody() . $this->LFC ;
- }
-
- //-------------------
- // Easy Base
- //-------------------
- function easy( $type , $to , $subject , $content , $other_header = array() , $attach = null ){
- if(is_null($other_header)){
- $other_header=array();
- }
-
- $this->resetHeaderBody();
-
- $option_return = array();
- if( is_array($type) ){
- $type = array_change_key_case( $type , CASE_UPPER );
- if( isset( $type['SMTP'] ) ){
- $this->smtp( true );
- $this->smtpServer( $type['SMTP'] );
- }
- if(isset( $type['OPTION'] )){
- $type['OPTION'] = array_change_key_case( $type['OPTION'] , CASE_UPPER );
- foreach($type['OPTION'] as $method => $param ){
- if(method_exists($this,$method)){
- $option_return[$method] = $this->{$method}($param);
- }
- }
- }
- $type = isset( $type['TYPE'] ) ? $type['TYPE'] : 'TEXT' ;
- }
-
- if( (empty($to) && ( !empty($subject) || !empty($content) ))){
- return $this->errorGather('Parameter Specified Error',__LINE__);
- }elseif( empty($to) ){
- return $option_return;
- }
-
- if( 'TEXT' == strtoupper( $type ) || 'HTML' == strtoupper( $type ) ){
- $type=strtolower( $type );
- }else{
- $this->error[]='Illegal spcify \'type\' in '.$type.' .'.__LINE__;
- return $this->errorGather();
- }
- $to = is_string($to) ? array($to) : $to ;
- $other_header = is_string($other_header) ? array('From' => $other_header) : $other_header ;
-
- list($other_header_temp , $link ) = $this->keyUpper( $other_header );
-
- if(!isset($other_header_temp['FROM'])){
- $fromAddr = null;
- if( isset($other_header[0]) ){
- $fromAddr = $other_header[0];
- unset($other_header[0]);
- }
- $fromName = null;
- if(isset($other_header[1])){
- $fromName = $other_header[1];
- unset($other_header[1]);
- }
- if(!empty($fromAddr)){
- $other_header = array_merge( $other_header,array('FROM'=>array( $fromAddr , $fromName )));
- }
- }
-
- $other_header = array_merge(array('TO'=>$to),$other_header);
- $section = array('TO'=>'to','CC'=>'cc','BCC'=>'bcc','REPLY-TO'=>'replyto','FROM'=>'from');
- list($other_header_temp , $link ) = $this->keyUpper( $other_header );
-
- foreach($other_header_temp as $key => $other_head){
- if(isset($section[$key])){
- $method = $section[$key];
- $this -> {$method}( $other_head , null );
- }else{
- $this -> addHeader( $link[$key] , $other_head );
- }
- }
-
- $this->subject( $subject );
- $this->{$type}( $content );
- if( isset( $attach ) ){
- $this->attach( $attach , $add = false , $this->inline_mode );
- }
-
- return $this->send();
- }
-
- function easyText( $to , $subject , $content , $other_header = array() , $attach = null , $option = array() ){
- return $this->easy( array('TYPE'=>'text','OPTION'=>$option) , $to , $subject , $content , $other_header , $attach );
- }
-
- function easyHtml( $to , $subject , $content , $other_header = array() , $attach = null , $option = array() ){
- return $this->easy( array('TYPE'=>'html','OPTION'=>$option) , $to , $subject , $content , $other_header , $attach );
- }
-
- function easyReplace( $to , $subject , $content , $other_header = array() , $attach = null , $option = array() ){
- $this->simpleReplace( true );
- $type = 'text';
- if(0!==count($option)){
- $option = array_change_key_case( $option , CASE_UPPER );
- $type = ( 'HTML' === strtoupper( $option['TYPE']) ) ? 'html' : $type ;
- }
- $this->easy( array('TYPE'=>$type,'OPTION'=>$option) , $to , $subject , $content , $other_header , $attach );
- }
-
- function easyDeco( $to , $subject , $content , $other_header = array() , $attach = null , $option = array() ){
- if( isset( $attach ) ){
- $this->inline_mode=true;
- }
- $this->autoDecoJudge( true );
- $this->toSeparate( true );
-
- return $this->easy( array('TYPE'=>'html','OPTION'=>$option) , $to , $subject , $content , $other_header , $attach );
- }
- function easyDecoTemplate( $to , $subject , $template , $other_header = array() , $attach = null , $option = array() ){
- if(is_null($attach)){
- $attach = array();
- }
- $DECO = new QdDeco;
- $DECO -> template($template);
- $DECO -> decode();
- $content = $DECO -> get('HTML');
- $text = $DECO -> get('PLAIN');
- if(!empty($text)){
- $this->text($text);
- }
- $att = $DECO ->get('ATTACH');
- $attach = array_merge($att,$attach);
- return $this->easyDeco( $to , $subject , $content , $other_header , $attach , $option );
- }
-
- function easyDecoRep( $to , $subject , $content , $other_header = array() , $attach = null , $option = array() ){
- $this->simpleReplace( true );
- return $this->easyDeco($to , $subject , $content , $attach , $option , $option);
- }
-
- function easyOption( $to , $subject = null , $content = null , $other_header = array() , $attach = null , $option = array() ){
-
- if(!is_array($to)){
- $option = array( $to => $subject );
- }else{
- $option = $to;
- }
- return $this->easy( array('TYPE'=>'option','OPTION'=>$option) , $to , $subject , $content , $other_header , $attach );
- }
-
- /*
- * Notice: Before use $this->optionNameLink(); by Constractor
- */
- //
- //---------------------------------------
- // something change mode
- //---------------------------------------
- // Keys must lowercase , because of PHP4's
- var $property_type = array(
- 'auto_both' => 'bool' ,
- 'to_separate' => 'bool' ,
- 'simple_replace' => 'bool' ,
- 'auto_deco_judge' => 'bool' ,
- 'auto_ext' => 'bool' ,
- 'body_empty_allow' => 'bool' ,
- 'ignore_error' => 'bool' ,
- 'wrap_width' => 'bool' ,
- 'wordwrap_allow' => 'bool' ,
- 'wrap_prohibit_allow'=> 'bool' ,
- 'force_change_charset' => 'bool' ,
- 'error_display' => 'bool' ,
- 'sendmail' => 'bool' ,
- 'smtp' => 'bool' ,
- 'smtp_loglevel_link'=> 'bool' ,
- 'inline_mode' => 'bool' ,
- 'replace_with_to_priority'=> 'bool' ,
- 'attach_build_once' => 'bool' ,
- 'body_build_once' => 'bool' ,
- 'kana' => 'bool' ,
- 'render_mode' => 'bool' ,
- 'smime' => 'bool' ,
- 'pgp' => 'bool' ,
- 'simple_attach' => 'bool' ,
- 'message_id' => 'bool' ,
- 'allow_blank_header'=> 'bool' ,
- 'sign' => 'string' ,
- 'keep_parameter' => 'array' ,
- 'attach_path' => 'string' ,
- 'mta_option' => 'string' ,
- 'rep_prefix' => 'string' ,
- 'log_path' => 'string' ,
- 'errorlog_path' => 'string' ,
- 'log_filename' => 'string' ,
- 'errorlog_filename' => 'string' ,
- 'allways_bcc' => 'string' ,
- 'wrap_prohibit_top' => 'string' ,
- 'wrap_prohibit_end' => 'string' ,
- 'framework' => 'string' ,
- 'priority' => 'string' ,
- 'certificate_file' => 'string' ,
- 'certificate_file_path' => 'string' ,
- 'certificate_temp_path' => 'string' ,
- 'time_zone' => 'string' ,
- 'private_key_file' => 'string' ,
- 'certificate_pass' => 'string' ,
- 'message_id_right' => 'string' ,
- 'sendmail_path' => 'string' ,
- 'temporary_path' => 'string' ,
- 'united_charset' => 'string' ,
- 'varidate_address_regex'=> 'string' ,
- 'mb_strwidth_magni' => 'numeric' ,
- 'log_dateformat' => 'numeric' ,
- 'log_level' => 'numeric' ,
- 'errorlog_level' => 'numeric' ,
- 'mime_encode_max' => 'numeric' ,
- 'smtp_server' => 'array' ,
- 'address_validation_method'=> 'array',
- );
- var $method_property = array();
-
- function optionNameLink(){
- foreach($this->property_type as $prop => $type ){
- $method_low = strtolower( str_replace( '_' , '' , $prop ) );
- $this->method_property[$method_low] = $prop;
- }
- }
- function option( $option , $line = null , $min = null , $max = null ){
- $ret = array();
- if( !is_null( $line ) ){
- $line = '-' . $line ;
- }
- if(!is_array($option)){
- return $this->errorSpecify( __FUNCTION__, __LINE__ );
- }
- foreach( $option as $key => $value ){
- if( !isset( $this->method_property[strtolower($key)] ) ){
- return $this->errorSpecify( __FUNCTION__ . '-' .$key , __LINE__ . $line );
- }
- $property_name = $this->method_property[strtolower($key)];
- if( is_null( $value ) ){
- $ret[] = $this->{$property_name} ;
- continue ;
- }
- $err = false;
- switch( $this->property_type[$property_name] ){
- case 'bool':
- if( is_bool( $value ) ){
- $this->{$property_name} = $value ;
- $ret[0] = true ;
- }else{
- return $this->errorSpecify( __FUNCTION__ . '-' .$key , __LINE__ . $line );
- }
- break;
- case 'string':
- if( '' === $value ){
- $this->{$property_name} = null ;
- $ret[0] = true ;
- break ;
- }
- if( is_string( $value ) ){
- $this->{$property_name} = $value ;
- $ret[0] = true ;
- }else{
- return $this->errorSpecify( __FUNCTION__ . '-' .$key , __LINE__ . $line );
- }
- break;
- case 'numeric':
- if( !is_numeric( $value ) || ( isset( $min ) && ( $value < $min ) ) || ( isset( $max ) && ( $value > $max ) ) ){
- return $this->errorSpecify( __FUNCTION__ . '-' .$key , __LINE__ . $line );
- }else{
- $this->{$property_name} = $value ;
-
- $ret[0] = true ;
- }
- break;
- case 'array':
- if( !is_array( $value ) ){
- $value = array( $value );
- }
- if( true===$min ){
- $this->{$property_name} = array_merge( $this->{$property_name} , $value );
- }else{
- $this->{$property_name} = $value ;
- }
- $ret[0] = true ;
- if( true === $max ){
- $this->{$property_name} = array_change_key_case( $this->{$property_name} , CASE_UPPER );
- }
- break;
-
- default:
- return $this->errorSpecify( __FUNCTION__ . '-' .$key , __LINE__ . $line );
- break;
- }
- }
- if( 0 === count( $ret ) ){
- return $this->errorSpecify( __FUNCTION__ , __LINE__ );
- }elseif( 1 === count( $ret ) ){
- return array_shift( $ret );
- }else{
- return $ret ;
- }
- }
-
- function autoBoth( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function toSeparate( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function simpleReplace( $bool = null ){
- $this->toSeparate( $bool );
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function autoDecoJudge( $bool = null ){
- $this->attachBuildOnce( !$bool );
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function autoExt( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function bodyEmptyAllow( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function ignoreError( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function forceChangeCharset( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function errorDisplay( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function sendmail( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function smtp( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function smtpLoglevelLink( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function inlineMode( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function replaceWithToPriority( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function attachBuildOnce( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function bodyBuildOnce( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function kana( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function keepParameter( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function renderMode( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function simpleAttach( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function messageId( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function allowBlankHeader( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function smime( $bool = null ){
- $fg = $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- if(!extension_loaded ( 'openssl' )){
- $this->smime = false;
- if(!$bool){
- return false;
- }
- }
- return $fg;
- }
- function pgp( $bool = null ){
- // future
- return true;
- }
- function sign( $string = null ){
- if(false===$string){
- $this->smime = false;
- $this->pgp = false;
- $this->sign = false;
- return true;
- }
- if(empty($string)){
- return $this->sign;
- }
- $string = strtoupper($string);
- if('S/MIME'==$string){
- $this->smime(true);
- }elseif('PGP'==$string){
- $this->pgp(true);
- }else{
- return false;
- }
- $fg = $this->option( array( __FUNCTION__ => $string ) ,__LINE__);
- return $fg;
- }
- function size( $kind = null ){
-
- if(empty($this->header_for_smtp)){
- $stack = $this->render_mode;
- $this->render_mode = true;
- $fg = $this->send();
- $this->render_mode = $stack;
- }
-
- $this->size['ALL'] = strlen( bin2hex( $this->header_for_smtp . $this->LFC . $this->content_for_mailfunction )) / 2;
- $this->size['HEADER'] = strlen( bin2hex( $this->header_for_smtp )) / 2;
- $this->size['BODY'] = strlen( bin2hex( $this->content_for_mailfunction )) / 2;
-
- if(is_null($kind)){
- return $this->size;
- }
- $kind = strtoupper( $kind );
- if(isset($this->size[$kind])){
- return $this->size[$kind];
- }
- return false;
- }
- function sizeAll(){
- return $this->size('ALL');
- }
- function sizeHeader(){
- return $this->size('HEADER');
- }
- function sizeBody(){
- return $this->size('BODY');
- }
- function smtpData(){
- if(empty($this->header_for_smtp)){
- $stack = $this->render_mode;
- $this->render_mode = true;
- $fg = $this->send();
- $this->render_mode = $stack;
- }
- return $this->header_for_smtp . $this->LFC . $this->content_for_mailfunction ;
- }
- function smtpDataBody(){
- if(empty($this->content_for_mailfunction)){
- $stack = $this->render_mode;
- $this->render_mode = true;
- $fg = $this->send();
- $this->render_mode = $stack;
- }
- return $this->content_for_mailfunction ;
- }
- function isQmail(){
- if(!is_null($this->is_qmail)){
- return $this->is_qmail;
- }
- $this->is_qmail = false;
- $ret = ini_get ( 'sendmail_path' );
- if(false !== strpos($ret,'qmail')){
- $this->is_qmail = true;
- }
- $sendmail_path = ini_get('sendmail_path');
- if(false !== @system($sendmail_path.' -d0.1 < /dev/null > /dev/null',$ret)){
- if(is_array($ret)){
- $ret = reset($ret);
- }
- $code = (int) substr($ret,0,3);
- if( 100 === $code || 111 === $code){
- $this->is_qmail = true;
- }
- }
-
- return $this->is_qmail ;
- }
- function lineFeed( $LFC = null ){
- if(is_null($LFC)){
- return $this->LFC;
- }
- if(preg_match('/[\r|\n|\r\n]/is',$LFC)){
- $this->LFC = $LFC;
- return true;
- }else{
- return false;
- }
- }
- function isWin(){
- return false!==strpos(PHP_OS,'WIN');
- }
- //---------------------------------------
- // something change mode
- //---------------------------------------
- function whichTextHtml( $which ){
- $which = strtoupper( $which );
- if( 'TEXT' == $which ){
- $this->is_html='TEXT';
- }elseif( 'HTML' == $which ){
- $this->is_html='HTML';
- }elseif( 'BOTH' == $which ){
- $this->is_html='BOTH';
- }
- }
-
- function allwaysBcc( $option = null ){
- if( is_null( $option ) ){
- return $this->allways_bcc ;
- }
- if( $this->option( array( __FUNCTION__ => $option ) ,__LINE__) ){
- $fg = $this->extractAddr( $this->allways_bcc ) ;
- }
- if( $this->errorGather() && $fg && !empty($this->allways_bcc) ){
- return true ;
- }else{
- $this->allways_bcc = array();
- return false ;
- }
- }
- function priority( $option = null ){
- $fg=$this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- $priority = strtoupper($option);
- if(empty($priority)){
- return $fg;
- }
- $kind = array('HIGH'=>1,'NORMAL'=>1,'LOW'=>1);
- if( !isset( $kind[$priority] ) ){
- return $this->errorGather('Illegal Priority Name \''.$option.'\'',__LINE__);
- }
- foreach($this->priority_def as $header_name => $values){
- $this->addHeader($header_name,$values[$priority]);
- }
- return $this->errorGather();
- }
- function certificatePass( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function certificateFilePath( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function certificateTempPath( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function certificateFile( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function privateKeyFile( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function framework( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function attachPath( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function timeZone( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function messageIdRight( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function mtaOption( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function unitedCharset( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function varidateAddressRegex( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function sendmailPath( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function temporaryPath( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function logPath( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function errorlogPath( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function logDateFormat( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function logFilename( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function errorlogFilename( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function logLevel( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__, 0 , $this->log_level_max );
- }
- function errorlogLevel( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__, 0 , $this->errorlog_level_max );
- }
- function mimeEncodeMax( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- }
- function smtpServer( $array = null ){
- return $this->option( array( __FUNCTION__ => $array ) ,__LINE__, true , true );
- }
- function addressValidationMethod( $array = null ){
- return $this->option( array( __FUNCTION__ => $array ) ,__LINE__, false , true );
- }
- //------------------
- //version
- //------------------
- function version(){
- return $this->version;
- }
- //------------------
- //mb_ wrapper
- //------------------
- function qd_detect_encoding( $word ){
- if(!is_null($this->united_charset)){
- return $this->united_charset;
- }else{
- return mb_detect_encoding( $word , mb_detect_order() , true );
- }
- }
- function qd_convert_encoding( $word , $target_chrset , $org_charset = null ){
-
- if(empty($org_charset)){
- $org_charset = $this->qd_detect_encoding( $word );
- }
- if(empty($org_charset)){
- return $word;
- }
- if( strtoupper( $target_chrset ) === strtoupper( $org_charset ) ){
- return $word;
- }
- if('ASCII'===strtoupper( $target_chrset ) || 'ASCII'===strtoupper( $org_charset )){
- return $word;
- }
- return mb_convert_encoding( $word , $target_chrset , $org_charset );
- }
- function qd_detect_order( $param=null ){
- if(is_null($param)){
- return mb_detect_order();
- }else{
- return mb_detect_order( $param );
- }
- }
- //-----------------------------------------
- // Address and Name Keys change Opiton
- //-----------------------------------------
- function addressField( $addr = null , $name = null ){
- if( is_null($addr) && is_null($name) ){
- return array( $this->tokey['_ADDR'] , $this->tokey['_NAME'] );
- }
- if( !is_null($addr) && is_array($addr) && 1 < count($addr) ){
- $_addr = array_shift( $addr ) ;
- $name = array_shift( $addr ) ;
- $addr = $_addr;
- }
- if( (!is_null($addr) && !is_string( $addr )) || !is_null($name) && !is_string($name) ){
- return $this->errorGather('Specify Error in addressField',__LINE__);
- }
- $addr = is_null( $addr ) ? $this->tokey['_ADDR'] : $addr ;
- $name = is_null( $name ) ? $this->tokey['_NAME'] : $name ;
- $this->tokey = array(
- '_ADDR' => $addr,
- '_NAME' => $name,
- );
- return true;
- }
- //-----------------------------------------------------------
- // Wordwrap Opiton
- // array( 'except word' => beginning flag )
- // if beginning flag is true , beginning of a line is target
- // if beginning flag is true , the word in line is target
- //-----------------------------------------------------------
- function wordwrapProhibitConstruct(){
- $ret = $this->strToArrayKey( $this->wrap_prohibit_top , true );
- $ret2 = $this->strToArrayKey( $this->wrap_prohibit_end , false );
- $this->wrap_prohibit = array_merge( $ret , $ret2 );
- }
- function strToArrayKey( $word , $value ){
- $ret = array();
- $enc = $this->qd_detect_encoding( $word );
- $length = mb_strlen( $word , $enc );
- for( $i=0 ; $i < $length ; $i++ ){
- $ret[ mb_substr( $word , $i , 1 , $enc ) ] = $value;
- }
- return $ret;
- }
- function wordwrapAllow( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function wrapProhibitAllow( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function wrapProhibitEnd( $option = null ){
- $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- $this->wordwrapProhibitConstruct();
- return $this->errorGather();
- }
- function wrapProhibitTop( $option = null ){
- $this->option( array( __FUNCTION__ => $option ) ,__LINE__);
- $this->wordwrapProhibitConstruct();
- return $this->errorGather();
- }
- function wrapWidth( $bool = null ){
- return $this->option( array( __FUNCTION__ => $bool ) ,__LINE__);
- }
- function wordwrapLength( $length = null ){
- if( is_null( $length ) ){
- return $this->wordwrap_length;
- }
- if( !is_numeric( $length ) || ( is_numeric( $length ) && $length < 1 ) ){
- return $this->errorGather('Wordwrap error , length is illegal' ,__LINE__) ;
- }
- $this->wordwrap_length = $length;
- return $this->errorGather() ;
- }
- function mbStrwidthMagni( $option = null ){
- return $this->option( array( __FUNCTION__ => $option ) ,__LINE__, 0 , 10 );
- }
- function wrapExcept( $array = null ){
- if( null === $array ){
- return $this->wrap_except;
- }
- if( is_string( $array ) || is_numeric( $array ) ){
- $this->wrap_except = array( $array =>false );//default false
- }
- if( is_array( $array ) ){
- if( 0 === count( $array ) ){
- $this->wrap_except = array();
- return $this->errorGather() ;
- }
- foreach( $array as $key => $value){
- if( !is_bool( $value ) ){
- $array[$key] = empty( $value ) ? false:true;
- }else{
- $array[$key] = $value ;
- }
- }
- $this->wrap_except = $array;
- return $this->errorGather() ;
- }
- return $this->errorSpecify(__FUNCTION__,__LINE__);
- }
- //------------------------------------------
- // Charset Option
- //------------------------------------------
- function charsetHeader( $charset = null ){
- if(is_null($charset)){
- return $this->charset_header ;
- }
- $stack = $this->charset();
- $stack['HEADER'] = $charset;
- return $this->charset( $stack );
- }
- function charsetAttach( $charset = null ){
- if(is_null($charset)){
- return $this->charset_attach_filename ;
- }
- $stack = $this->charset();
- $stack['HEADER'] = $charset;
- return $this->charset( $stack );
- }
- function charsetBody( $charset = null , $enc = null ){
- if( is_null($charset) && is_null($enc) ){
- return array($this->charset_content , $this->content_transfer_enc_text , content_transfer_enc_html) ;
- }
- if(is_array($charset)){
- $enc = isset($charset[1]) ? $charset[1]:null;
- $charset = $charset[0];
- }
- $stack = $this->charset();
- if( !is_null($charset) ){
- $stack['BODY'] = $charset;
- }
- if( !is_null($enc) ){
- $stack['HTML'] = $stack['TEXT'] = $enc;
- }
- return $this->charset( $stack );
- }
- function charset( $array = null , $op = null ){
- if( is_null( $array ) && is_null( $op ) ){
- foreach( $this->corres_charset as $key => $value ){
- $ret[$key] = $this->{$value} ;
- }
- return $ret;
- }
- if( !is_null($op) && is_string($op) ){
-
- $this->content_transfer_enc_text = $op ;
- $this->content_transfer_enc_html = $op ;
-
- return $this->charset( $array );
- }elseif(!is_null($op) && !is_string($op)){
- return $this->errorSpecify( __FUNCTION__ , __LINE__ );
- }
- if( is_array( $array ) ){
- if( 2===count($array) && isset($array[0]) && isset($array[1])){
- return $this->charset($array[0],$array[1]);
- }
- $array = array_change_key_case( $array , CASE_UPPER );
- foreach( $array as $key => $value ){
- if(isset($this->corres_charset[$key])){
- if( is_string($this->corres_charset[$key]) ){
- $this->{$this->corres_charset[$key]} = $value;
- }else{
- return $this->errorSpecify( __FUNCTION__ , __LINE__ );
- }
- }
- }
- }elseif( is_string($array) ){
- $this->charset_header = $this->charset_content = $this->charset_attach_filename = $array;
- }else{
- return $this->errorSpecify( __FUNCTION__ , __LINE__ );
- }
- return $this->errorGather() ;
- }
- function encoding( $enc = null ){
- if(is_null($enc)){
- return $this->corres_charset['TEXT'];
- }
- $this->corres_charset['TEXT'] = $this->corres_charset['HTML'] = $enc;
- return true;
- }
- //--------------------------
- // set Mutibye Parameter
- //--------------------------
- function setMbParameter( $lang = null , $internal_enc = null , $detect = null ){
-
- if(is_array($lang)){
- mb_language( $lang[0] ) ;
- mb_internal_encoding( $lang[1] ) ;
- $this->qd_detect_order( $lang[2] );
- }elseif( 'STACK'===strtoupper($lang) ){
- $this->mb_parameter_stack = array(mb_language(),mb_internal_encoding(),$this->qd_detect_order());
- mb_language( $this->lang_def );
- mb_internal_encoding( $this->encoding_def );
- $this->qd_detect_order( $this->detect_def );
- }else{
- if( !is_null( $lang ) ){
- mb_language( $lang ) ;
- }
- if( !is_null( $internal_enc ) ){
- mb_internal_encoding( $internal_enc ) ;
- }
- if( !is_null( $detect ) ){
- $this->qd_detect_order( $detect );
- }
- }
- }
- //--------------------------------
- // Decorationable HTML Mail Opiton
- // ( Inline HTML , MHTML )
- // See $this->deco_def Property
- //--------------------------------
- // Change decoration default along to each career
- function decoDef( $value = null ){
- if( is_null( $value ) ){
- return $this->deco_def_default;
- }
- $this->deco_def_default = $value ;
- return $this->errorGather() ;
- }
- // fix Decoration Pattern by STRING means CareerName
- function decoFix( $cari = null ){
- if(is_null($cari)){
- return $this->deco_kind;
- }
- $this->deco_kind = $this->decoSelect( $cari );
- return true;
- }
- function decoSelect( $deco_kind = null ){
- if( is_null( $deco_kind ) ){
- return $this->deco_def_default;//$this->deco_judge
- }
- $deco_kind = strtoupper( $deco_kind );
- $ret = false ;
- foreach( $this->deco_def as $key => $def ){
- if( in_array( $deco_kind , $def['OPTION_NAME'] ) ){
- $ret = $key ;
- $this->inline_mode = true;
- }
- }
- return $ret;
- }
-
- // Change Decoration Pattern by E-mail Address
- function decoJudge( $addr_array ){
- $addr=$addr_array[$this->tokey['_ADDR']];
- $start = strrpos( $addr , '@');
- if(empty($start)){
- retu…
Large files files are truncated, but you can click here to view the full file