⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class.phpmailer.php

📁 一个通用的php网站的会员系统和通行证系统
💻 PHP
📖 第 1 页 / 共 4 页
字号:
        $x = 0;        switch (strtolower($position)) {        case 'phrase':            if (!preg_match('/[\200-\377]/', $str)) {                // Can't use addslashes as we don't know what value has magic_quotes_sybase.                $encoded = addcslashes($str, "\0..\37\177\\\"");                if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str))                    return ($encoded);                else                   return ("\"$encoded\"");            }            $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);            break;        case 'comment':            $x = preg_match_all('/[()"]/', $str, $matches);            // Fall-through        case 'text':        default:            $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);            break;        }        if ($x == 0)            return ($str);        $maxlen = 75 - 7 - strlen($this->CharSet);        // Try to select the encoding which should produce the shortest output        if (strlen($str)/3 < $x) {            $encoding = 'B';            $encoded = base64_encode($str);            $maxlen -= $maxlen % 4;            $encoded = trim(chunk_split($encoded, $maxlen, "\n"));        } else {            $encoding = 'Q';            $encoded = $this->EncodeQ($str, $position);            $encoded = $this->WrapText($encoded, $maxlen, true);            $encoded = str_replace("=".$this->LE, "\n", trim($encoded));        }        $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);        $encoded = trim(str_replace("\n", $this->LE, $encoded));        return $encoded;    }    /**     * Encode string to quoted-printable.     *     * @access private     *     * @param string $str String     *     * @return string     */    function EncodeQP ($str)    {        $encoded = $this->FixEOL($str);        if (substr($encoded, -(strlen($this->LE))) != $this->LE)            $encoded .= $this->LE;        // Replace every high ascii, control and = characters        $encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e',                  "'='.sprintf('%02X', ord('\\1'))", $encoded);        // Replace every spaces and tabs when it's the last character on a line        $encoded = preg_replace("/([\011\040])".$this->LE."/e",                  "'='.sprintf('%02X', ord('\\1')).'".$this->LE."'", $encoded);        // Maximum line length of 76 characters before CRLF (74 + space + '=')        $encoded = $this->WrapText($encoded, 74, true);        return $encoded;    }    /**     * Encode string to q encoding.     *     * @access private     *     * @param string $str      String     * @param string $position Position     *     * @return string     */    function EncodeQ ($str, $position = "text")    {        // There should not be any EOL in the string        $encoded = preg_replace("[\r\n]", "", $str);        switch (strtolower($position)) {        case "phrase":            $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);            break;        case "comment":            $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);        case "text":        default:            // Replace every high ascii, control =, ? and _ characters            $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',                  "'='.sprintf('%02X', ord('\\1'))", $encoded);            break;        }        // Replace every spaces to _ (more readable than =20)        $encoded = str_replace(" ", "_", $encoded);        return $encoded;    }    /**     * Adds a string or binary attachment (non-filesystem) to the list.     * This method can be used to attach ascii or binary data,     * such as a BLOB record from a database.     *     * @param string $string   String attachment data.     * @param string $filename Name of the attachment.     * @param string $encoding File encoding (see $Encoding).     * @param string $type     File extension (MIME) type.     *     * @return void     */    function AddStringAttachment($string, $filename, $encoding = "base64",                                 $type = "application/octet-stream")    {        // Append to $attachment array        $cur = count($this->attachment);        $this->attachment[$cur][0] = $string;        $this->attachment[$cur][1] = $filename;        $this->attachment[$cur][2] = $filename;        $this->attachment[$cur][3] = $encoding;        $this->attachment[$cur][4] = $type;        $this->attachment[$cur][5] = true; // isString        $this->attachment[$cur][6] = "attachment";        $this->attachment[$cur][7] = 0;    }    /**     * Adds an embedded attachment.  This can include images, sounds, and     * just about any other document.  Make sure to set the $type to an     * image type.  For JPEG images use "image/jpeg" and for GIF images     * use "image/gif".     *     * @param string $path     Path to the attachment.     * @param string $cid      Content ID of the attachment.  Use this to identify     *                         the Id for accessing the image in an HTML form.     * @param string $name     Overrides the attachment name.     * @param string $encoding File encoding (see $Encoding).     * @param string $type     File extension (MIME) type.     *     * @return bool     */    function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64",                              $type = "application/octet-stream")    {        if (!@is_file($path)) {            $this->SetError($this->Lang("file_access") . $path);            return false;        }        $filename = basename($path);        if ($name == "") {            $name = $filename;        }        // Append to $attachment array        $cur = count($this->attachment);        $this->attachment[$cur][0] = $path;        $this->attachment[$cur][1] = $filename;        $this->attachment[$cur][2] = $name;        $this->attachment[$cur][3] = $encoding;        $this->attachment[$cur][4] = $type;        $this->attachment[$cur][5] = false; // isStringAttachment        $this->attachment[$cur][6] = "inline";        $this->attachment[$cur][7] = $cid;        return true;    }    /**     * Returns true if an inline attachment is present.     *     * @access private     * @return bool     */    function InlineImageExists()    {        $result = false;        for ($i = 0; $i < count($this->attachment); $i++)        {            if ($this->attachment[$i][6] == "inline") {                $result = true;                break;            }        }        return $result;    }    /////////////////////////////////////////////////    // MESSAGE RESET METHODS    /////////////////////////////////////////////////    /**     * Clears all recipients assigned in the TO array.  Returns void.     *     * @return void     */    function ClearAddresses()    {        $this->to = array();    }    /**     * Clears all recipients assigned in the CC array.  Returns void.     *     * @return void     */    function ClearCCs()    {        $this->cc = array();    }    /**     * Clears all recipients assigned in the BCC array.  Returns void.     *     * @return void     */    function ClearBCCs()    {        $this->bcc = array();    }    /**     * Clears all recipients assigned in the ReplyTo array.  Returns void.     *     * @return void     */    function ClearReplyTos()    {        $this->ReplyTo = array();    }    /**     * Clears all recipients assigned in the TO, CC and BCC     * array.  Returns void.     *     * @return void     */    function ClearAllRecipients()    {        $this->to  = array();        $this->cc  = array();        $this->bcc = array();    }    /**     * Clears all previously set filesystem, string, and binary     * attachments.  Returns void.     *     * @return void     */    function ClearAttachments()    {        $this->attachment = array();    }    /**     * Clears all custom headers.  Returns void.     *     * @return void     */    function ClearCustomHeaders()    {        $this->CustomHeader = array();    }    /////////////////////////////////////////////////    // MISCELLANEOUS METHODS    /////////////////////////////////////////////////    /**     * Adds the error message to the error container.     * Returns void.     *     * @access private     *     * @param string $msg Message string     *     * @return void     */    function SetError($msg)    {        $this->error_count++;        $this->ErrorInfo = $msg;    }    /**     * Returns the proper RFC 822 formatted date.     *     * @access private     * @return string     */    function RFCDate()    {        $tz     = date("Z");        $tzs    = ($tz < 0) ? "-" : "+";        $tz     = abs($tz);        $tz     = intval($tz/3600)*100 + ($tz%3600)/60;        $result = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);        return $result;    }    /**     * Returns the appropriate server variable.  Should work with both     * PHP 4.1.0+ as well as older versions.  Returns an empty string     * if nothing is found.     *     * @access private     *     * @param string $varName Var name     *     * @return mixed     */    function ServerVar($varName)    {        global $HTTP_SERVER_VARS;        global $HTTP_ENV_VARS;        if (!isset($_SERVER)) {            $_SERVER = $HTTP_SERVER_VARS;            if (!isset($_SERVER["REMOTE_ADDR"])) {                $_SERVER = $HTTP_ENV_VARS; // must be Apache            }        }        if (isset($_SERVER[$varName])) {            return $_SERVER[$varName];        } else {            return "";        }    }    /**     * Returns the server hostname or 'localhost.localdomain' if unknown.     *     * @access private     * @return string     */    function ServerHostname()    {        if ($this->Hostname != "")            $result = $this->Hostname;        elseif ($this->ServerVar('SERVER_NAME') != "")            $result = $this->ServerVar('SERVER_NAME');        else            $result = "localhost.localdomain";        return $result;    }    /**     * Returns a message in the appropriate language.     *     * @access private     *     * @param string $key Language key     *     * @return string     */    function Lang($key)    {        if (count($this->language) < 1)            $this->SetLanguage("en"); // set the default language        if (isset($this->language[$key]))            return $this->language[$key];        else            return "Language string failed to load: " . $key;    }    /**     * Returns true if an error occurred.     *     * @return bool     */    function IsError()    {        return ($this->error_count > 0);    }    /**     * Changes every end of line from CR or LF to CRLF.     *     * @access private     *     * @param string $str String to fix     *     * @return string     */    function FixEOL($str)    {        $str = str_replace("\r\n", "\n", $str);        $str = str_replace("\r", "\n", $str);        $str = str_replace("\n", $this->LE, $str);        return $str;    }    /**     * Adds a custom header.     *     * @param array $custom_header Array with custom header     *     * @return void     */    function AddCustomHeader($custom_header)    {        $this->CustomHeader[] = explode(":", $custom_header, 2);    }}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -