Ignore:
Timestamp:
Jan 4, 2014 3:25:57 AM (10 years ago)
Author:
anonymous
Message:

Improved the truncate() function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Email.inc.php

    r424 r454  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    2828 * @author  Quinn Comendant <quinn@strangecode.com>
    2929 * @version 1.0
    30  * 
    31  
     30 *
     31
    3232// Example.
    3333$email = new Email(array(
     
    5050}
    5151
    52  * 
     52 *
    5353 */
    5454class Email {
     
    6161        'headers' => null,
    6262        'regex' => null,
    63        
     63
    6464        // A single carriage return (\n) should terminate lines for locally injected mail.
    6565        // A carriage return + line-feed (\r\n) should be used if sending mail directly with SMTP.
    6666        'crlf' => "\n",
    67        
     67
    6868        // RFC 2822 says line length MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF.
    6969        // http://mailformat.dan.info/body/linelength.html
     
    120120    {
    121121        $app =& App::getInstance();
    122    
     122
    123123        if (isset($params) && is_array($params)) {
    124124            // Enforce valid email addresses.
     
    147147    {
    148148        $app =& App::getInstance();
    149    
     149
    150150        if (isset($this->_params[$param])) {
    151151            return $this->_params[$param];
     
    167167    {
    168168        $app =& App::getInstance();
    169    
     169
    170170        // Load file, using include_path.
    171171        if (!$this->_template = file_get_contents($template, true)) {
     
    191191    {
    192192        $app =& App::getInstance();
    193    
     193
    194194        if ('' == trim($string)) {
    195195            $app->logMsg(sprintf('Empty string provided.', null), LOG_ERR, __FILE__, __LINE__);
     
    215215    {
    216216        $app =& App::getInstance();
    217    
     217
    218218        // Ensure template exists.
    219219        if (!isset($this->_template)) {
     
    285285        $final_body = isset($this->_template_replaced) ? $this->_template_replaced : $this->_template;
    286286        if (false !== $this->getParam('wrap')) {
    287             $final_body = wordwrap($final_body, $this->getParam('line_length'), $this->getParam('crlf'));           
     287            $final_body = wordwrap($final_body, $this->getParam('line_length'), $this->getParam('crlf'));
    288288        }
    289289
     
    320320            $envelope_sender_header = sprintf('-f %s', $envelope_sender_address);
    321321        } else {
    322             $envelope_sender_header = '';           
     322            $envelope_sender_header = '';
    323323        }
    324324
     
    331331        }
    332332
    333         // Send email without 5th parameter if safemode is enabled. 
     333        // Send email without 5th parameter if safemode is enabled.
    334334        if (ini_get('safe_mode')) {
    335335            $ret = mb_send_mail($final_to, $this->_params['subject'], $final_body, $final_headers);
     
    337337            $ret = mb_send_mail($final_to, $this->_params['subject'], $final_body, $final_headers, $envelope_sender_header);
    338338        }
    339        
     339
    340340        // Ensure message was successfully accepted for delivery.
    341341        if ($ret) {
     
    345345            $app->logMsg(sprintf('Email failure with parameters: %s, %s, %s, %s', $final_to, $this->_params['subject'], str_replace("\r\n", '\r\n', $final_headers), $envelope_sender_header), LOG_NOTICE, __FILE__, __LINE__);
    346346            return false;
    347         } 
     347        }
    348348    }
    349349
     
    366366    {
    367367        $app =& App::getInstance();
    368    
     368
    369369        // If an array, check values recursively.
    370370        if (is_array($email)) {
Note: See TracChangeset for help on using the changeset viewer.