Changeset 41


Ignore:
Timestamp:
Dec 17, 2005 9:11:26 AM (19 years ago)
Author:
scdev
Message:

${1}

Location:
trunk/lib
Files:
4 edited

Legend:

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

    r40 r41  
    119119        'log_to_sms_address' => null,
    120120       
    121         // The from address used for system emails.
    122         'envelope_sender_address' => '',
    123    
    124121        // A key for calculating simple cryptographic signatures. Set using as an environment variables in the httpd.conf with 'SetEnv SIGNING_KEY <key>'.
    125122        'signing_key' => 'aae6abd6209d82a691a9f96384a7634a',
     
    314311        // and is used whenever a URL need be used to the current site.
    315312        // Not available on cli scripts obviously.
    316         if (isset($_SERVER['HTTP_HOST']) && '' != $_SERVER['HTTP_HOST'] && '' != $this->getParam('site_url')) {
     313        if (isset($_SERVER['HTTP_HOST']) && '' != $_SERVER['HTTP_HOST'] && '' == $this->getParam('site_url')) {
    317314            $this->setParam(array('site_url' => sprintf('%s://%s', ('on' == getenv('HTTPS') ? 'https' : 'http'), getenv('HTTP_HOST'))));
    318315        }
     
    323320        }
    324321       
    325         // Used as the fifth parameter to mail() to set the return address for sent messages. Requires safe_mode off.
    326         if ('' != $this->getParam('site_email') && !$this->getParam('envelope_sender_address')) {
    327             $this->setParam(array('envelope_sender_address' => '-f ' . $this->getParam('site_email')));
    328         }
    329 
    330322        // Character set. This should also be printed in the html header template.
    331323        header('Content-type: text/html; charset=' . $this->getParam('character_set'));
     
    496488            $subject = sprintf('[%s %s] %s', getenv('HTTP_HOST'), $event['type'], $message);
    497489            $email_msg = sprintf("A %s log event occured on %s\n\n", $event['type'], getenv('HTTP_HOST'));
    498             $headers = "From: codebase@strangecode.com\r\n";
     490            $headers = "From: codebase@strangecode.com";
    499491            foreach ($event as $k=>$v) {
    500492                $email_msg .= sprintf("%-11s%s\n", $k, $v);
     
    506498        if ($this->getParam('log_sms_priority') && $priority <= $this->getParam('log_sms_priority')) {
    507499            $subject = sprintf('[%s %s]', getenv('HTTP_HOST'), $priority);
    508             $sms_msg = sprintf('%s:%s %s', basename($file), $line, $event['message']);
    509             $headers = "From: codebase@strangecode.com\r\n";
     500            $sms_msg = sprintf('%s [%s:%s]', $event['message'], basename($file), $line);
     501            $headers = "From: codebase@strangecode.com";
    510502            mail($this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com');
    511503        }
  • trunk/lib/Auth_SQL.inc.php

    r40 r41  
    757757        // Update password query.
    758758        $this->setPassword($user_id, $password);
    759        
    760         // Subject for email. Do not use double-quote marks inside.
    761         $email_subject = sprintf('%s password change', App::getParam('site_name'));
    762        
    763         // Body for email. Do not touch lines with 'EOF'.
     759
     760        // Body for email.
    764761        $email_body = <<<EOF
    765 Hello %s,
    766 
    767 Your password at %s has been reset. %s
     762Hello {NAME},
     763
     764Your password at {SITE_NAME} has been reset. {REASON}
    768765Your new login information is:
    769766
    770 USERNAME: %s
    771 PASSWORD: %s
    772 
    773 If you have any questions or concerns please reply to this email or go the the address below.
     767USERNAME: {USERNAME}
     768PASSWORD: {PASSWORD}
     769
     770If you have any questions or concerns please reply to this email or visit the website below.
    774771
    775772Thank you,
    776 %s
    777 %s
     773{SITE_NAME}
     774{SITE_URL}/
    778775
    779776EOF;
    780         $email_body = wordwrap(sprintf($email_body,
    781             $user_data[$this->_params['db_username_column']],
    782             App::getParam('site_name'),
    783             $reason,
    784             $user_data[$this->_params['db_username_column']],
    785             $password,
    786             App::getParam('site_name'),
    787             App::getParam('site_url')
     777
     778        $email = new Email(array(
     779            'to' => $user_data['email'],
     780            'from' => sprintf('%s <%s>', App::getParam('site_name'), App::getParam('site_email')),
     781            'subject' => sprintf('%s password change', App::getParam('site_name'))
    788782        ));
    789 
    790         // Email the user with the new account information.
    791         mail($user_data['email'], $email_subject, $email_body, sprintf("From: %s <%s>\r\n", App::getParam('site_name'), App::getParam('site_email')), App::getParam('envelope_sender_address'));
     783        $email->setString($email_body);
     784        $email->replace(array(
     785            'site_name' => App::getParam('site_name'),
     786            'site_url' => App::getParam('site_url'),
     787            'name' => ('' != $user_data['first_name'] . $user_data['last_name'] ? $user_data['first_name'] . ' ' . $user_data['last_name'] : $user_data[$this->_params['db_username_column']]),
     788            'username' => $user_data[$this->_params['db_username_column']],
     789            'password' => $password,
     790            'reason' => $reason,
     791        ));
     792        $email->send();
    792793   
    793794        return array(
  • trunk/lib/Email.inc.php

    r40 r41  
    1616));
    1717$email->setTemplate('email_registration_confirm.ihtml');
     18// $email->setString('Or you can pass your message body as a string, also with {VARIABLES}.');
    1819$email->replace(array(
    1920    'site_name' => App::getParam('site_name'),
     
    153154    {
    154155        // Load file, using include_path.
    155         if ('' == $string) {
     156        if ('' == trim($string)) {
    156157            App::logMsg(sprintf('Empty string provided.', null), LOG_ERR, __FILE__, __LINE__);
    157158            $this->_template_replaced = null;
    158159            return false;
    159160        } else {
    160             $_template = $string;
     161            $this->_template = $string;
    161162            // This could be a new template, so reset the _template_replaced.
    162163            $this->_template_replaced = null;
     
    244245        // Ensure all placeholders have been replaced. Find anything with {...} characters.
    245246        if (preg_match('/({[^}]+})/', $final_body, $unreplaced_match)) {
    246             App::logMsg(sprintf('Cannot send email. Variables left unreplaced in template: %s', (isset($unreplaced_match) ? $unreplaced_match[1] : '')), LOG_ERR, __FILE__, __LINE__);
     247            App::logMsg(sprintf('Cannot send email. Variables left unreplaced in template: %s', (isset($unreplaced_match[1]) ? $unreplaced_match[1] : '')), LOG_ERR, __FILE__, __LINE__);
    247248            return false;
    248249        }
  • trunk/lib/Utilities.inc.php

    r40 r41  
    516516    }
    517517    if (isset($_POST[$var])) {
    518         return dispelMagicQuotes($_POST[$var]);
     518        return trim(dispelMagicQuotes($_POST[$var]));
    519519    } else if (isset($_GET[$var])) {
    520         return dispelMagicQuotes($_GET[$var]);
     520        return trim(dispelMagicQuotes($_GET[$var]));
    521521    } else {
    522522        return $default;
     
    526526{
    527527    if (is_null($var)) {
    528         return dispelMagicQuotes($_POST);
     528        return trim(dispelMagicQuotes($_POST));
    529529    }
    530530    if (isset($_POST[$var])) {
    531         return dispelMagicQuotes($_POST[$var]);
     531        return trim(dispelMagicQuotes($_POST[$var]));
    532532    } else {
    533533        return $default;
     
    537537{
    538538    if (is_null($var)) {
    539         return dispelMagicQuotes($_GET);
     539        return trim(dispelMagicQuotes($_GET));
    540540    }
    541541    if (isset($_GET[$var])) {
    542         return dispelMagicQuotes($_GET[$var]);
     542        return trim(dispelMagicQuotes($_GET[$var]));
    543543    } else {
    544544        return $default;
Note: See TracChangeset for help on using the changeset viewer.