當前位置: 首頁>>代碼示例>>PHP>>正文


PHP COM_formatEmailAddress函數代碼示例

本文整理匯總了PHP中COM_formatEmailAddress函數的典型用法代碼示例。如果您正苦於以下問題:PHP COM_formatEmailAddress函數的具體用法?PHP COM_formatEmailAddress怎麽用?PHP COM_formatEmailAddress使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了COM_formatEmailAddress函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: MG_approveSubmission

function MG_approveSubmission($media_id)
{
    global $_CONF, $_TABLES, $LANG_MG01;
    $mid = addslashes($media_id);
    $owner_uid = DB_getItem($_TABLES['mg_mediaqueue'], 'media_user_id', "media_id='" . $mid . "'");
    DB_delete($_TABLES['mg_mediaqueue'], 'media_id', $mid);
    $album_id = DB_getItem($_TABLES['mg_media_album_queue'], 'album_id', "media_id='" . $mid . "'");
    DB_save($_TABLES['mg_media_albums'], 'album_id, media_id, media_order', "{$album_id}, '{$mid}', 0");
    require_once $_CONF['path'] . 'plugins/mediagallery/include/sort.php';
    MG_SortMedia($album_id);
    DB_delete($_TABLES['mg_media_album_queue'], 'media_id', $mid);
    $sql = "SELECT media_filename, media_type " . "FROM {$_TABLES['mg_media']} WHERE media_id='" . $mid . "'";
    $result = DB_query($sql);
    list($media_filename, $media_type) = DB_fetchArray($result);
    $media_count = DB_getItem($_TABLES['mg_albums'], 'media_count', 'album_id=' . $album_id);
    $media_count++;
    DB_change($_TABLES['mg_albums'], 'media_count', $media_count, 'album_id', $album_id);
    MG_updateAlbumLastUpdate($album_id);
    $album_cover = DB_getItem($_TABLES['mg_albums'], 'album_cover', 'album_id=' . $album_id);
    if ($album_cover == -1 && $media_type == 0) {
        DB_change($_TABLES['mg_albums'], 'album_cover_filename', $media_filename, 'album_id', $album_id);
    }
    // email the owner / uploader that the item has been approved.
    COM_clearSpeedlimit(600, 'mgapprove');
    $last = COM_checkSpeedlimit('mgapprove');
    if ($last == 0) {
        $result2 = DB_query("SELECT username, fullname, email FROM {$_TABLES['users']} WHERE uid='" . $owner_uid . "'");
        list($username, $fullname, $email) = DB_fetchArray($result2);
        if ($email != '') {
            $subject = $LANG_MG01['upload_approved'];
            $body = $LANG_MG01['upload_approved'];
            $body .= '<br' . XHTML . '><br' . XHTML . '>';
            $body .= $LANG_MG01['thanks_submit'];
            $body .= '<br' . XHTML . '><br' . XHTML . '>';
            $body .= $_CONF['site_name'] . '<br' . XHTML . '>';
            $body .= $_CONF['site_url'] . '<br' . XHTML . '>';
            $to = array();
            $from = array();
            $to = COM_formatEmailAddress($username, $email);
            $from = COM_formatEmailAddress($_CONF['site_name'], $_CONF['site_mail']);
            if (!COM_mail($to, $subject, $body, $from, true)) {
                COM_errorLog("Media Gallery Error - Unable to send queue notification email");
            }
            COM_updateSpeedlimit('mgapprove');
        }
    }
    // PLG_itemSaved($media_id, 'mediagallery');
    // COM_rdfUpToDateCheck();
    // COM_olderStuff();
    return;
}
開發者ID:mistgrass,項目名稱:geeklog-ivywe,代碼行數:51,代碼來源:moderate.php

示例2: execute

 function execute($comment)
 {
     global $result, $_CONF, $_USER, $LANG_SX00, $_SPX_CONF;
     if (isset($_USER['uid']) && $_USER['uid'] > 1) {
         $uid = $_USER['uid'];
     } else {
         $uid = 1;
     }
     $uid .= '@' . $_SERVER['REMOTE_ADDR'];
     $msg = sprintf($LANG_SX00['emailmsg'], $_CONF['site_name'], $uid, $comment);
     // Add headers of the spam post to help track down the source.
     // Function 'getallheaders' is not available when PHP is running as
     // CGI. Print the HTTP_... headers from $_SERVER array instead then.
     $msg .= "\n\n" . $LANG_SX00['headers'] . "\n";
     if (function_exists('getallheaders')) {
         $headers = getallheaders();
         foreach ($headers as $key => $content) {
             if (strcasecmp($key, 'Cookie') != 0) {
                 $msg .= $key . ': ' . $content . "\n";
             }
         }
     } else {
         foreach ($_SERVER as $key => $content) {
             if (substr($key, 0, 4) == 'HTTP') {
                 if ($key != 'HTTP_COOKIE') {
                     $msg .= $key . ': ' . $content . "\n";
                 }
             }
         }
     }
     $subject = sprintf($LANG_SX00['emailsubject'], $_CONF['site_name']);
     if (empty($_SPX_CONF['notification_email'])) {
         $email_address = $_CONF['site_mail'];
     } else {
         $email_address = $_SPX_CONF['notification_email'];
     }
     $to = array();
     $to = COM_formatEmailAddress('', $email_address);
     COM_mail($to, $subject, $msg);
     $result = 8;
     SPAMX_log('Mail Sent to Admin');
     return 0;
 }
開發者ID:spacequad,項目名稱:glfusion,代碼行數:43,代碼來源:MailAdmin.Action.class.php

示例3: requesttoken

/**
* User request for a verification token - send email with a link and request id
*
* @param uid      int      userid of user who requested the new token
* @param msg      int      index of message to display (if any)
* @return         string   form or meta redirect
*
*/
function requesttoken($uid, $msg = 0)
{
    global $_CONF, $_SYSTEM, $_TABLES, $LANG04;
    if (!isset($_SYSTEM['verification_token_ttl'])) {
        $_SYSTEM['verification_token_ttl'] = 86400;
    }
    $retval = '';
    $uid = (int) $uid;
    $result = DB_query("SELECT uid,username,email,passwd,status FROM {$_TABLES['users']} WHERE uid = " . (int) $uid . " AND (account_type & " . LOCAL_USER . ")");
    $nrows = DB_numRows($result);
    if ($nrows == 1) {
        $A = DB_fetchArray($result);
        if ($_CONF['usersubmission'] == 1 && $A['status'] == USER_ACCOUNT_AWAITING_APPROVAL) {
            echo COM_refresh($_CONF['site_url'] . '/index.php?msg=48');
        }
        $verification_id = USER_createActivationToken($uid, $A['username']);
        $activation_link = $_CONF['site_url'] . '/users.php?mode=verify&vid=' . $verification_id . '&u=' . $uid;
        $mailtext = $LANG04[168] . $_CONF['site_name'] . ".\n\n";
        $mailtext .= $LANG04[170] . "\n\n";
        $mailtext .= "----------------------------\n";
        $mailtext .= $LANG04[2] . ': ' . $A['username'] . "\n";
        $mailtext .= $LANG04[171] . ': ' . $_CONF['site_url'] . "\n";
        $mailtext .= "----------------------------\n\n";
        $mailtext .= sprintf($LANG04[172], $_SYSTEM['verification_token_ttl'] / 3600) . "\n\n";
        $mailtext .= $activation_link . "\n\n";
        $mailtext .= $LANG04[173] . "\n\n";
        $mailtext .= $LANG04[174] . "\n\n";
        $mailtext .= "--\n";
        $mailtext .= $_CONF['site_name'] . "\n";
        $mailtext .= $_CONF['site_url'] . "\n";
        $subject = $_CONF['site_name'] . ': ' . $LANG04[16];
        if ($_CONF['site_mail'] !== $_CONF['noreply_mail']) {
            $mailfrom = $_CONF['noreply_mail'];
            global $LANG_LOGIN;
            $mailtext .= LB . LB . $LANG04[159];
        } else {
            $mailfrom = $_CONF['site_mail'];
        }
        $to = array();
        $to = COM_formatEmailAddress('', $A['email']);
        $from = array();
        $from = COM_formatEmailAddress('', $mailfrom);
        COM_mail($to, $subject, $mailtext, $from);
        COM_updateSpeedlimit('verifytoken');
        if ($msg) {
            echo COM_refresh($_CONF['site_url'] . "/index.php?msg={$msg}");
        } else {
            echo COM_refresh($_CONF['site_url'] . '/index.php');
        }
    } else {
        COM_updateSpeedlimit('verifytoken');
        echo COM_refresh($_CONF['site_url'] . '/users.php?mode=getnewtoken');
    }
    return $retval;
}
開發者ID:JohnToro,項目名稱:glfusion,代碼行數:63,代碼來源:users.php

示例4: send_messages

/**
* This function actually sends the messages to the specified group
*
* @param    array   $vars   Same as $_POST, holds all the email info
* @return   string          HTML with success or error message
*
*/
function send_messages($vars)
{
    global $_CONF, $_TABLES, $LANG31;
    require_once $_CONF['path_system'] . 'lib-user.php';
    $retval = '';
    if (empty($vars['fra']) or empty($vars['fraepost']) or empty($vars['subject']) or empty($vars['message']) or empty($vars['to_group']) or strpos($vars['fra'], '@') !== false) {
        $retval .= COM_showMessageText($LANG31[26]);
        return $retval;
    }
    $to_group = COM_applyFilter($vars['to_group'], true);
    if ($to_group > 0) {
        $group_name = DB_getItem($_TABLES['groups'], 'grp_name', "grp_id = {$to_group}");
        if (!SEC_inGroup($group_name)) {
            return COM_refresh($_CONF['site_admin_url'] . '/mail.php');
        }
    } else {
        return COM_refresh($_CONF['site_admin_url'] . '/mail.php');
    }
    // Urgent message!
    if (isset($vars['priority'])) {
        $priority = 1;
    } else {
        $priority = 0;
    }
    // If you want to send html mail
    if (isset($vars['html'])) {
        $html = true;
    } else {
        $html = false;
    }
    $groupList = implode(',', USER_getChildGroups($to_group));
    // and now mail it
    if (isset($vars['overstyr'])) {
        $sql = "SELECT DISTINCT username,fullname,email FROM {$_TABLES['users']},{$_TABLES['group_assignments']} WHERE uid > 1";
        $sql .= " AND {$_TABLES['users']}.status = 3 AND ((email IS NOT NULL) and (email != ''))";
        $sql .= " AND {$_TABLES['users']}.uid = ug_uid AND ug_main_grp_id IN ({$groupList})";
    } else {
        $sql = "SELECT DISTINCT username,fullname,email,emailfromadmin FROM {$_TABLES['users']},{$_TABLES['userprefs']},{$_TABLES['group_assignments']} WHERE {$_TABLES['users']}.uid > 1";
        $sql .= " AND {$_TABLES['users']}.status = 3 AND ((email IS NOT NULL) and (email != ''))";
        $sql .= " AND {$_TABLES['users']}.uid = {$_TABLES['userprefs']}.uid AND emailfromadmin = 1";
        $sql .= " AND ug_uid = {$_TABLES['users']}.uid AND ug_main_grp_id IN ({$groupList})";
    }
    $result = DB_query($sql);
    $nrows = DB_numRows($result);
    $from = COM_formatEmailAddress($vars['fra'], $vars['fraepost']);
    $subject = COM_stripslashes($vars['subject']);
    $message = COM_stripslashes($vars['message']);
    // Loop through and send the messages!
    $successes = array();
    $failures = array();
    for ($i = 0; $i < $nrows; $i++) {
        $A = DB_fetchArray($result);
        if (empty($A['fullname'])) {
            $to = COM_formatEmailAddress($A['username'], $A['email']);
        } else {
            $to = COM_formatEmailAddress($A['fullname'], $A['email']);
        }
        if (!COM_mail($to, $subject, $message, $from, $html, $priority)) {
            $failures[] = htmlspecialchars($to);
        } else {
            $successes[] = htmlspecialchars($to);
        }
    }
    $retval .= COM_startBlock($LANG31[1]);
    $failcount = count($failures);
    $successcount = count($successes);
    $mailresult = str_replace('<successcount>', $successcount, $LANG31[20]);
    $retval .= str_replace('<failcount>', $failcount, $mailresult);
    $retval .= '<h2>' . $LANG31[21] . '</h2>';
    for ($i = 0; $i < count($failures); $i++) {
        $retval .= current($failures) . '<br' . XHTML . '>';
        next($failures);
    }
    if (count($failures) == 0) {
        $retval .= $LANG31[23];
    }
    $retval .= '<h2>' . $LANG31[22] . '</h2>';
    for ($i = 0; $i < count($successes); $i++) {
        $retval .= current($successes) . '<br' . XHTML . '>';
        next($successes);
    }
    if (count($successes) == 0) {
        $retval .= $LANG31[24];
    }
    $retval .= COM_endBlock();
    return $retval;
}
開發者ID:hostellerie,項目名稱:nexpro,代碼行數:94,代碼來源:mail.php

示例5: CUSTOM_mail

/**
* Custom email function for creating an email message in ISO-2022-JP
*/
function CUSTOM_mail($to, $subject, $message, $from = '', $html = false, $priority = 0, $cc = '')
{
    global $_CONF, $LANG_CHARSET;
    static $mailobj;
    include_once 'Mail.php';
    include_once 'Mail/RFC822.php';
    if (defined('CUSTOM_MAIL_DEBUG')) {
        COM_errorLog('CUSTOM_mail: to=' . $to . ' subject=' . $subject);
    }
    // 餘分なヘッダを追加されないように改行コードを削除
    $to = substr($to, 0, strcspn($to, "\r\n"));
    $cc = substr($cc, 0, strcspn($cc, "\r\n"));
    $from = substr($from, 0, strcspn($from, "\r\n"));
    $subject = substr($subject, 0, strcspn($subject, "\r\n"));
    // Fromが空の場合は、サイト管理者のアドレスにする
    if (empty($from)) {
        $from = COM_formatEmailAddress($_CONF['site_name'], $_CONF['site_mail']);
    }
    // ヘッダをエスケープ(1.5.2では、この時點でエスケープ済み)
    // NOTE: version_compare(VERSION, '1.5.2')とすると、security releaseでは
    //       判定に失敗する
    preg_match("/^(\\d+\\.\\d+\\.\\d+).*\$/", VERSION, $match);
    if (version_compare($match[1], '1.5.2') < 0) {
        list($temp_to_comment, $temp_to_address) = CUSTOM_splitAddress($to);
        $to = CUSTOM_formatEmailAddress($temp_to_comment, $temp_to_address);
        list($temp_cc_comment, $temp_cc_address) = CUSTOM_splitAddress($cc);
        $cc = CUSTOM_formatEmailAddress($temp_cc_comment, $temp_cc_address);
        list($temp_from_comment, $temp_from_address) = CUSTOM_splitAddress($from);
        $from = CUSTOM_formatEmailAddress($temp_from_comment, $temp_from_address);
        $subject = CUSTOM_emailEscape($subject);
    }
    // 本文をエスケープ
    $message = CUSTOM_convertEncoding($message, CUSTOM_MAIL_ENCODING);
    $message = str_replace(array("\r\n", "\n", "\r"), CUSTOM_MAIL_BODY_LINEBREAK, $message);
    // メールオブジェクトを作成
    $method = $_CONF['mail_settings']['backend'];
    if (!isset($mailobj)) {
        if ($method === 'sendmail' or $method === 'smtp') {
            $mailobj =& Mail::factory($method, $_CONF['mail_settings']);
        } else {
            $mailobj =& Mail::factory($method);
        }
    }
    // ヘッダ組み立て
    $headers = array();
    $headers['From'] = $from;
    if ($method != 'mail') {
        $headers['To'] = $to;
    }
    if (!empty($cc)) {
        $headers['Cc'] = $cc;
    }
    $headers['Date'] = date('r');
    // RFC822 formatted date
    if ($method === 'smtp') {
        list($usec, $sec) = explode(' ', microtime());
        $m = substr($usec, 2, 5);
        $headers['Message-Id'] = '<' . date('YmdHis') . '.' . $m . '@' . $_CONF['mail_settings']['host'] . '>';
    }
    if ($html) {
        $headers['Content-Type'] = 'text/html; charset=' . CUSTOM_MAIL_ENCODING;
        $headers['Content-Transfer-Encoding'] = '8bit';
    } else {
        $headers['Content-Type'] = 'text/plain; charset=' . CUSTOM_MAIL_ENCODING;
    }
    $headers['Subject'] = $subject;
    if ($priority > 0) {
        $headers['X-Priority'] = $priority;
    }
    $headers['X-Mailer'] = 'Geeklog-' . VERSION . ' (' . CUSTOM_MAIL_ENCODING . ')';
    $retval = $mailobj->send($to, $headers, $message);
    if ($retval !== true) {
        COM_errorLog($retval->toString(), 1);
    }
    return $retval === true;
}
開發者ID:milk54,項目名稱:geeklog-japan,代碼行數:79,代碼來源:custom_mail_japanize.php

示例6: requesttoken

/**
* User request for a verification token - send email with a link and request id
*
* @param uid      int      userid of user who requested the new token
* @param msg      int      index of message to display (if any)
* @return         string   form or meta redirect
*
*/
function requesttoken($uid, $msg = 0)
{
    global $_CONF, $_SYSTEM, $_TABLES, $LANG04;
    if (!isset($_SYSTEM['verification_token_ttl'])) {
        $_SYSTEM['verification_token_ttl'] = 86400;
    }
    $retval = '';
    $uid = (int) $uid;
    $result = DB_query("SELECT uid,username,email,passwd,status FROM {$_TABLES['users']} WHERE uid = " . (int) $uid . " AND (account_type & " . LOCAL_USER . ")");
    $nrows = DB_numRows($result);
    if ($nrows == 1) {
        $A = DB_fetchArray($result);
        if ($_CONF['usersubmission'] == 1 && $A['status'] == USER_ACCOUNT_AWAITING_APPROVAL) {
            echo COM_refresh($_CONF['site_url'] . '/index.php?msg=48');
        }
        $verification_id = USER_createActivationToken($uid, $A['username']);
        $activation_link = $_CONF['site_url'] . '/users.php?mode=verify&vid=' . $verification_id . '&u=' . $uid;
        $T = new Template($_CONF['path_layout'] . 'email/');
        $T->set_file(array('html_msg' => 'newuser_template_html.thtml', 'text_msg' => 'newuser_template_text.thtml'));
        $T->set_var(array('url' => $_CONF['site_url'] . '/users.php?mode=verify&vid=' . $verification_id . '&u=' . $uid, 'lang_site_or_password' => $LANG04[171], 'site_link_url' => $_CONF['site_url'], 'lang_activation' => sprintf($LANG04[172], $_SYSTEM['verification_token_ttl'] / 3600), 'lang_button_text' => $LANG04[203], 'title' => $_CONF['site_name'] . ': ' . $LANG04[16], 'site_name' => $_CONF['site_name'], 'username' => $A['username']));
        $T->parse('output', 'html_msg');
        $mailhtml = $T->finish($T->get_var('output'));
        $T->parse('output', 'text_msg');
        $mailtext = $T->finish($T->get_var('output'));
        $msgData['htmlmessage'] = $mailhtml;
        $msgData['textmessage'] = $mailtext;
        $msgData['subject'] = $_CONF['site_name'] . ': ' . $LANG04[16];
        $to = array();
        $from = array();
        $from = COM_formatEmailAddress($_CONF['site_name'], $_CONF['noreply_mail']);
        $to = COM_formatEmailAddress('', $A['email']);
        COM_mail($to, $msgData['subject'], $msgData['htmlmessage'], $from, true, 0, '', $msgData['textmessage']);
        COM_updateSpeedlimit('verifytoken');
        if ($msg) {
            echo COM_refresh($_CONF['site_url'] . "/index.php?msg={$msg}");
        } else {
            echo COM_refresh($_CONF['site_url'] . '/index.php');
        }
    } else {
        COM_updateSpeedlimit('verifytoken');
        echo COM_refresh($_CONF['site_url'] . '/users.php?mode=getnewtoken');
    }
    return $retval;
}
開發者ID:spacequad,項目名稱:glfusion,代碼行數:52,代碼來源:users.php

示例7: COM_mail

/**
* Send an email.
*
* All emails sent by Geeklog are sent through this function.
*
* NOTE: Please note that using CC: will expose the email addresses of
*       all recipients. Use with care.
*
* @param    string      $to         recipients name and email address
* @param    string      $subject    subject of the email
* @param    string      $message    the text of the email
* @param    string      $from       (optional) sender of the the email
* @param    boolean     $html       (optional) true if to be sent as HTML email
* @param    int         $priority   (optional) add X-Priority header, if > 0
* @param    mixed       $optional   (optional) other headers or CC:
* @return   boolean                 true if successful,  otherwise false
*
*/
function COM_mail($to, $subject, $message, $from = '', $html = false, $priority = 0, $optional = null)
{
    global $_CONF;
    static $mailobj;
    if (empty($from)) {
        $from = COM_formatEmailAddress($_CONF['site_name'], $_CONF['site_mail']);
    }
    $to = substr($to, 0, strcspn($to, "\r\n"));
    if ($optional != null && !is_array($optional)) {
        $optional = substr($optional, 0, strcspn($optional, "\r\n"));
    }
    $from = substr($from, 0, strcspn($from, "\r\n"));
    $subject = substr($subject, 0, strcspn($subject, "\r\n"));
    $subject = COM_emailEscape($subject);
    if (function_exists('CUSTOM_mail')) {
        return CUSTOM_mail($to, $subject, $message, $from, $html, $priority, $optional);
    }
    include_once 'Mail.php';
    include_once 'Mail/RFC822.php';
    $method = $_CONF['mail_settings']['backend'];
    if (!isset($mailobj)) {
        if ($method == 'sendmail' || $method == 'smtp') {
            $mailobj =& Mail::factory($method, $_CONF['mail_settings']);
        } else {
            $method = 'mail';
            $mailobj =& Mail::factory($method);
        }
    }
    $charset = COM_getCharset();
    $headers = array();
    $headers['From'] = $from;
    if ($method != 'mail') {
        $headers['To'] = $to;
    }
    if ($optional != null && !is_array($optional) && !empty($optional)) {
        // assume old (optional) CC: header
        $headers['Cc'] = $optional;
    }
    $headers['Date'] = date('r');
    // RFC822 formatted date
    if ($method == 'smtp') {
        list($usec, $sec) = explode(' ', microtime());
        $m = substr($usec, 2, 5);
        $headers['Message-Id'] = '<' . date('YmdHis') . '.' . $m . '@' . $_CONF['mail_settings']['host'] . '>';
    }
    if ($html) {
        $headers['Content-Type'] = 'text/html; charset=' . $charset;
        $headers['Content-Transfer-Encoding'] = '8bit';
    } else {
        $headers['Content-Type'] = 'text/plain; charset=' . $charset;
    }
    $headers['Subject'] = $subject;
    if ($priority > 0) {
        $headers['X-Priority'] = $priority;
    }
    $headers['X-Mailer'] = 'Geeklog ' . VERSION;
    if (!empty($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['SERVER_ADDR']) && $_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) {
        $url = COM_getCurrentURL();
        if (substr($url, 0, strlen($_CONF['site_admin_url'])) != $_CONF['site_admin_url']) {
            $headers['X-Originating-IP'] = $_SERVER['REMOTE_ADDR'];
        }
    }
    // add optional headers last
    if ($optional != null && is_array($optional)) {
        foreach ($optional as $h => $v) {
            $headers[$h] = $v;
        }
    }
    $retval = $mailobj->send($to, $headers, $message);
    if ($retval !== true) {
        COM_errorLog($retval->toString(), 1);
    }
    return $retval === true ? true : false;
}
開發者ID:alxstuart,項目名稱:ajfs.me,代碼行數:92,代碼來源:lib-common.php

示例8: testFormatEmailAddress

 public function testFormatEmailAddress()
 {
     // Line 3133
     $email = COM_formatEmailAddress('John Doe', 'john.doe@example.com');
     $formattedEmail = 'John Doe <john.doe@example.com>';
     $this->assertEquals($formattedEmail, $email);
 }
開發者ID:mystralkk,項目名稱:geeklog,代碼行數:7,代碼來源:lib-commonTest.php

示例9: USER_sendReminders

/**
* This function used to send out reminders to users to access the site or account may be deleted
*
* @return   string          HTML with success or error message
*
*/
function USER_sendReminders()
{
    global $_CONF, $_TABLES, $LANG04, $LANG28;
    $msg = '';
    $user_list = array();
    if (isset($_POST['delitem'])) {
        $user_list = $_POST['delitem'];
    }
    $nusers = count($user_list);
    if (count($user_list) == 0) {
        $msg = $LANG28[79] . '<br/>';
    } else {
        $c = 0;
        if (isset($_POST['delitem']) and is_array($_POST['delitem'])) {
            foreach ($_POST['delitem'] as $delitem) {
                $uid = COM_applyFilter($delitem);
                $useremail = DB_getItem($_TABLES['users'], 'email', "uid = '{$uid}'");
                $username = DB_getItem($_TABLES['users'], 'username', "uid = '{$uid}'");
                $lastlogin = DB_getItem($_TABLES['userinfo'], 'lastlogin', "uid = '{$uid}'");
                $lasttime = COM_getUserDateTimeFormat($lastlogin);
                if (file_exists($_CONF['path_data'] . 'reminder_email.txt')) {
                    $template = new Template($_CONF['path_data']);
                    $template->set_file(array('mail' => 'reminder_email.txt'));
                    $template->set_var('site_url', $_CONF['site_url']);
                    $template->set_var('site_name', $_CONF['site_name']);
                    $template->set_var('site_slogan', $_CONF['site_slogan']);
                    $template->set_var('lang_username', $LANG04[2]);
                    $template->set_var('username', $username);
                    $template->set_var('name', COM_getDisplayName($uid));
                    $template->set_var('lastlogin', $lasttime[0]);
                    $template->parse('output', 'mail');
                    $mailtext = $template->get_var('output');
                } else {
                    if ($lastlogin == 0) {
                        $mailtext = $LANG28[83] . "\n\n";
                    } else {
                        $mailtext = sprintf($LANG28[82], $lasttime[0]) . "\n\n";
                    }
                    $mailtext .= sprintf($LANG28[84], $username) . "\n";
                    $mailtext .= sprintf($LANG28[85], $_CONF['site_url'] . '/users.php?mode=getpassword') . "\n\n";
                }
                $subject = sprintf($LANG28[81], $_CONF['site_name']);
                if ($_CONF['site_mail'] !== $_CONF['noreply_mail']) {
                    $mailfrom = $_CONF['noreply_mail'];
                    global $LANG_LOGIN;
                    $mailtext .= LB . LB . $LANG04[159];
                } else {
                    $mailfrom = $_CONF['site_mail'];
                }
                $to = array();
                $to = COM_formatEmailAddress($username, $useremail);
                $from = array();
                $from = COM_formatEmailAddress('', $mailfrom);
                if (COM_mail($to, $subject, $mailtext, $from)) {
                    DB_query("UPDATE {$_TABLES['users']} SET num_reminders=num_reminders+1 WHERE uid={$uid}");
                    $c++;
                } else {
                    COM_errorLog("Error attempting to send account reminder to user: {$username} ({$uid})");
                }
            }
        }
        COM_numberFormat($c);
        // just in case we have more than 999)..
        $msg .= "{$LANG28[80]}: {$c}<br/>\n";
    }
    return $msg;
}
開發者ID:spacequad,項目名稱:glfusion,代碼行數:73,代碼來源:user.php

示例10: USER_sendNotification

/**
* Send an email notification when a new user registers with the site.
*
* @param username string      User name of the new user
* @param email    string      Email address of the new user
* @param uid      int         User id of the new user
* @param mode     string      Mode user was added at.
*
*/
function USER_sendNotification($username, $email, $uid, $mode = 'inactive')
{
    global $_CONF, $_USER, $_TABLES, $LANG01, $LANG04, $LANG08, $LANG28, $LANG29;
    $dt = new Date('now', $_USER['tzid']);
    $mailbody = "{$LANG04['2']}: {$username}\n" . "{$LANG04['5']}: {$email}\n" . "{$LANG28['14']}: " . $dt->format($_CONF['date'], true) . "\n\n";
    if ($mode == 'inactive') {
        // user needs admin approval
        $mailbody .= "{$LANG01['10']} {$_CONF['site_admin_url']}/moderation.php\n\n";
    } else {
        // user has been created, or has activated themselves:
        $mailbody .= "{$LANG29['4']} {$_CONF['site_url']}/users.php?mode=profile&uid={$uid}\n\n";
    }
    $mailbody .= "\n------------------------------\n";
    $mailbody .= "\n{$LANG08['34']}\n";
    $mailbody .= "\n------------------------------\n";
    $mailsubject = $_CONF['site_name'] . ' ' . $LANG29[40];
    $to = array();
    $to = COM_formatEmailAddress('', $_CONF['site_mail']);
    COM_mail($to, $mailsubject, $mailbody);
}
開發者ID:NewRoute,項目名稱:glfusion,代碼行數:29,代碼來源:lib-user.php

示例11: CLASSIFIEDS_mailAd

/**
* Email ad to a friend
*
* @param    string  $ad        id of ad to email
* @param    string  $to         name of person / friend to email
* @param    string  $toemail    friend's email address
* @param    string  $from       name of person sending the email
* @param    string  $fromemail  sender's email address
* @param    string  $shortmsg   short intro text to send with the ad
* @return   string              Meta refresh
*
* Modification History
*
* Date        Author        Description
* ----        ------        -----------
* 4/17/01    Tony Bibbs    Code now allows anonymous users to send email
*                and it allows user to input a message as well
*                Thanks to Yngve Wassvik Bergheim for some of
*                this code
*
*/
function CLASSIFIEDS_mailAd($ad, $to, $toemail, $from, $fromemail, $shortmsg)
{
    global $_CONF, $_TABLES, $LANG01, $LANG08;
    // check for correct $_CONF permission
    if (COM_isAnonUser() && $_CONF['loginrequired'] == 1) {
        return $retval;
    }
    // check mail speedlimit
    COM_clearSpeedlimit($_CONF['speedlimit'], 'mail');
    if (COM_checkSpeedlimit('mail') > 0) {
        return $retval;
    }
    //Query ad
    $shortmsg = COM_stripslashes($shortmsg);
    $mailtext = sprintf($LANG08[23], $from, $fromemail) . LB;
    if (strlen($shortmsg) > 0) {
        $mailtext .= LB . sprintf($LANG08[28], $from) . $shortmsg . LB;
    }
    // just to make sure this isn't an attempt at spamming users ...
    $result = PLG_checkforSpam($mailtext, $_CONF['spamx']);
    if ($result > 0) {
        COM_updateSpeedlimit('mail');
        COM_displayMessageAndAbort($result, 'spamx', 403, 'Forbidden');
    }
    $mailtext .= '------------------------------------------------------------' . LB . LB . COM_undoSpecialChars($story->displayElements('title')) . LB . strftime($_CONF['date'], $story->DisplayElements('unixdate')) . LB;
    if ($_CONF['contributedbyline'] == 1) {
        $author = COM_getDisplayName($story->displayElements('uid'));
        $mailtext .= $LANG01[1] . ' ' . $author . LB;
    }
    $introtext = $story->DisplayElements('introtext');
    $bodytext = $story->DisplayElements('bodytext');
    $introtext = COM_undoSpecialChars(strip_tags($introtext));
    $bodytext = COM_undoSpecialChars(strip_tags($bodytext));
    $introtext = str_replace(array("\n\r", "\r"), LB, $introtext);
    $bodytext = str_replace(array("\n\r", "\r"), LB, $bodytext);
    $mailtext .= LB . $introtext;
    if (!empty($bodytext)) {
        $mailtext .= LB . LB . $bodytext;
    }
    $mailtext .= LB . LB . '------------------------------------------------------------' . LB;
    if ($story->DisplayElements('commentcode') == 0) {
        // comments allowed
        $mailtext .= $LANG08[24] . LB . COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid . '#comments');
    } else {
        // comments not allowed - just add the story's URL
        $mailtext .= $LANG08[33] . LB . COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid);
    }
    $mailto = COM_formatEmailAddress($to, $toemail);
    $mailfrom = COM_formatEmailAddress($from, $fromemail);
    $subject = 'Re: ' . COM_undoSpecialChars(strip_tags($story->DisplayElements('title')));
    $sent = COM_mail($mailto, $subject, $mailtext, $mailfrom);
    if ($sent && isset($_POST['cc']) && $_POST['cc'] == 'on') {
        $ccmessage = sprintf($LANG08[38], $to);
        $ccmessage .= "\n------------------------------------------------------------\n\n" . $mailtext;
        $sent = COM_mail($mailfrom, $subject, $ccmessage, $mailfrom);
    }
    COM_updateSpeedlimit('mail');
    return $retval;
}
開發者ID:Geeklog-Plugins,項目名稱:classifieds,代碼行數:80,代碼來源:lib-contact.php

示例12: fncsendmail

function fncsendmail($mode = "", $uidfrom = "", $uidto = "", $wkymlmguserflg = "")
{
    global $_CONF;
    global $_TABLES;
    global $LANG_ASSIST_ADMIN;
    require_once $_CONF['path_system'] . 'lib-user.php';
    //$html = true ;    // If you want to send html mail
    $html = false;
    // If you want to send html mail
    /// Loop through and send the messages!
    //log 出力モード設定 0:作成しない,1:ファイルに出力
    $logmode = 1;
    //$logfile = $_CONF['path_log'] . 'wkymlmguser.log';
    $logfile = $_CONF['path_log'] . 'assist_newsletter.log';
    $retval = '';
    $fromname = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_fromname'");
    $fromname = COM_stripslashes($fromname);
    $replyto = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_replyto'");
    $replyto = COM_stripslashes($replyto);
    $sprefix = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_sprefix'");
    $sprefix = COM_stripslashes($sprefix);
    $sid = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_sid'");
    $sid = COM_stripslashes($sid);
    $testto = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_testto'");
    $testto = COM_stripslashes($testto);
    $uidfrom = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_uidfrom'");
    $uidfrom = COM_stripslashes($uidfrom);
    $uidto = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_uidto'");
    $uidto = COM_stripslashes($uidto);
    //送信先環境
    $toenv = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_toenv'");
    $toenv = COM_stripslashes($toenv);
    //送信先グループ
    $selectgroup = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_selectgroup'");
    $selectgroup = COM_stripslashes($selectgroup);
    // 冒頭文 本文 introbody
    $introbody = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_introbody'");
    $introbody = COM_stripslashes($introbody);
    // ユーザの受信許可設定を無視して送る
    $overstyr = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_overstyr'");
    $overstyr = COM_stripslashes($overstyr);
    $from = COM_formatEmailAddress($fromname, $replyto);
    $subject = DB_getItem($_TABLES['stories'], "title", "sid='{$sid}'");
    $subject = $sprefix . $subject;
    if ($introbody == "1") {
        $message = DB_getItem($_TABLES['stories'], "bodytext", "sid='{$sid}'");
    } else {
        $message = DB_getItem($_TABLES['stories'], "introtext", "sid='{$sid}'");
    }
    $message = str_replace('<br' . XHTML . '>', LB, $message);
    $message = strip_tags($message);
    $failures = array();
    $successes = array();
    if ($mode == "test") {
        $message = $LANG_ASSIST_ADMIN['mail_test_message'] . LB . $message;
        $to = $testto;
        if (!COM_mail($to, $subject, $message, $from, $html, $priority)) {
            $failures[] = htmlspecialchars($to);
            $logentry = $LANG_ASSIST_ADMIN['mail_test_ng'] . $to;
            $dummy = LIB_OutLog($logentry, $logfile, $logmode);
        } else {
            $successes[] = htmlspecialchars($to);
            $logentry = $LANG_ASSIST_ADMIN['mail_test_ok'] . $to;
            $dummy = LIB_OutLog($logentry, $logfile, $logmode);
        }
        $retval = $logentry;
    } else {
        $sql = "SELECT DISTINCT t1.uid ,t1.email FROM ";
        //メルマガユーザか選択されたグループの登録ユーザか
        if ($selectgroup === "99999") {
            if ($wkymlmguserflg) {
                $sql .= $_TABLES['wkymlmguser'] . " AS t1 " . LB;
                $sql .= " where " . LB;
                if ($uidfrom != "0") {
                    $sql .= "  (t1.uid between " . $uidfrom . " and " . $uidto . ")" . LB;
                }
            } else {
                $err = "メルマガプラグインが有効ではありません";
                return $err;
            }
        } else {
            $groupList = implode(',', USER_getChildGroups($selectgroup));
            $sql .= "{$_TABLES['users']} AS t1 " . LB;
            $sql .= ",{$_TABLES['userprefs']} AS t2 " . LB;
            $sql .= ",{$_TABLES['group_assignments']} AS t3 " . LB;
            $sql .= " where " . LB;
            $sql .= " (t1.uid = t2.uid ) " . LB;
            $sql .= " AND (t1.uid >1)  " . LB;
            $sql .= " AND (t1.status =3)  " . LB;
            // ユーザの受信許可設定を無視して送る でなければ
            if ($overstyr != "1") {
                $sql .= " AND (t2.emailfromadmin =1) " . LB;
            }
            //指定グループ
            $sql .= " AND (t1.uid = t3.ug_uid) AND t3.ug_main_grp_id IN ({$groupList})" . LB;
            if ($uidfrom != "0") {
                $sql .= " AND (t1.uid between " . $uidfrom . " and " . $uidto . ")" . LB;
            }
        }
        //---
//.........這裏部分代碼省略.........
開發者ID:mistgrass,項目名稱:geeklog-ivywe,代碼行數:101,代碼來源:newsletter.php

示例13: MAIL_sendMessages

/**
* This function actually sends the messages to the specified group
*
* @param    array   $vars   Same as $_POST, holds all the email info
* @return   string          HTML with success or error message
*
*/
function MAIL_sendMessages($vars)
{
    global $_CONF, $_TABLES, $LANG31;
    USES_lib_user();
    $retval = '';
    $html = 0;
    $message = $vars['message'];
    if ($vars['postmode'] == 'html') {
        $html = true;
    }
    $usermode = (int) $vars['to_uid'] > 0 && (int) $vars['to_group'] == 0 ? true : false;
    if (empty($vars['fra']) or empty($vars['fraepost']) or empty($vars['subject']) or empty($message) or empty($vars['to_group']) && empty($vars['to_uid'])) {
        $retval .= COM_showMessageText($LANG31[26], $LANG31[1], true);
        $msg = htmlspecialchars($vars['message'], ENT_COMPAT, COM_getEncodingt());
        $subject = htmlspecialchars($vars['subject'], ENT_COMPAT, COM_getEncodingt());
        $fra = htmlspecialchars($vars['fra'], ENT_COMPAT, COM_getEncodingt());
        $fraepost = htmlspecialchars($vars['fraepost'], ENT_COMPAT, COM_getEncodingt());
        $retval .= MAIL_displayForm($vars['to_uid'], $vars['to_group'], $fra, $fraepost, $subject, $msg);
        return $retval;
    }
    // Urgent message!
    if (isset($vars['priority'])) {
        $priority = 1;
    } else {
        $priority = 0;
    }
    $toUsers = array();
    if ($usermode) {
        $result = DB_query("SELECT email,username FROM {$_TABLES['users']} WHERE uid=" . (int) COM_applyFilter($vars['to_uid'], true));
        if (DB_numRows($result) > 0) {
            list($email, $username) = DB_fetchArray($result);
            $toUsers[] = COM_formatEmailAddress($username, $email);
        }
    } else {
        $groupList = implode(',', USER_getChildGroups((int) COM_applyFilter($vars['to_group'], true)));
        // and now mail it
        if (isset($vars['overstyr'])) {
            $sql = "SELECT DISTINCT username,fullname,email FROM {$_TABLES['users']},{$_TABLES['group_assignments']} WHERE uid > 1";
            $sql .= " AND {$_TABLES['users']}.status = 3 AND ((email is not null) and (email != ''))";
            $sql .= " AND {$_TABLES['users']}.uid = ug_uid AND ug_main_grp_id IN ({$groupList})";
        } else {
            $sql = "SELECT DISTINCT username,fullname,email,emailfromadmin FROM {$_TABLES['users']},{$_TABLES['userprefs']},{$_TABLES['group_assignments']} WHERE {$_TABLES['users']}.uid > 1";
            $sql .= " AND {$_TABLES['users']}.status = 3 AND ((email is not null) and (email != ''))";
            $sql .= " AND {$_TABLES['users']}.uid = {$_TABLES['userprefs']}.uid AND emailfromadmin = 1";
            $sql .= " AND ug_uid = {$_TABLES['users']}.uid AND ug_main_grp_id IN ({$groupList})";
        }
        $result = DB_query($sql);
        $nrows = DB_numRows($result);
        for ($i = 0; $i < $nrows; $i++) {
            $A = DB_fetchArray($result);
            if (empty($A['fullname'])) {
                $toUsers[] = COM_formatEmailAddress($A['username'], $A['email']);
            } else {
                $toUsers[] = COM_formatEmailAddress($A['fullname'], $A['email']);
            }
        }
    }
    $from = array();
    $from = COM_formatEmailAddress($vars['fra'], $vars['fraepost']);
    $subject = $vars['subject'];
    // Loop through and send the messages!
    $successes = array();
    $failures = array();
    foreach ($toUsers as $to) {
        if (defined('DEMO_MODE')) {
            $successes[] = htmlspecialchars($to[0]);
        } else {
            if (!COM_mail($to, $subject, $message, $from, $html, $priority)) {
                $failures[] = htmlspecialchars($to[0]);
            } else {
                $successes[] = htmlspecialchars($to[0]);
            }
        }
    }
    $retval .= COM_startBlock($LANG31[1]);
    $failcount = count($failures);
    $successcount = count($successes);
    $mailresult = str_replace('<successcount>', $successcount, $LANG31[20]);
    $retval .= str_replace('<failcount>', $failcount, $mailresult);
    $retval .= '<h2>' . $LANG31[21] . '</h2>';
    for ($i = 0; $i < count($failures); $i++) {
        $retval .= current($failures) . '<br/>';
        next($failures);
    }
    if (count($failures) == 0) {
        $retval .= $LANG31[23];
    }
    $retval .= '<h2>' . $LANG31[22] . '</h2>';
    for ($i = 0; $i < count($successes); $i++) {
        $retval .= current($successes) . '<br/>';
        next($successes);
    }
    if (count($successes) == 0) {
//.........這裏部分代碼省略.........
開發者ID:spacequad,項目名稱:glfusion,代碼行數:101,代碼來源:mail.php

示例14: mailstory


//.........這裏部分代碼省略.........
    $dt = new Date('now', $_USER['tzid']);
    $storyurl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid);
    if ($_CONF['url_rewrite']) {
        $retURL = $storyurl . '?msg=85';
    } else {
        $retURL = $storyurl . '&amp;msg=85';
    }
    // check for correct $_CONF permission
    if (COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['emailstoryloginrequired'] == 1)) {
        echo COM_refresh($retURL);
        exit;
    }
    // check if emailing of stories is disabled
    if ($_CONF['hideemailicon'] == 1) {
        echo COM_refresh($retURL);
        exit;
    }
    // check mail speedlimit
    COM_clearSpeedlimit($_CONF['speedlimit'], 'mail');
    if (COM_checkSpeedlimit('mail') > 0) {
        echo COM_refresh($retURL);
        exit;
    }
    $filter = sanitizer::getInstance();
    if ($html) {
        $filter->setPostmode('html');
    } else {
        $filter->setPostmode('text');
    }
    $allowedElements = $filter->makeAllowedElements($_CONF['htmlfilter_default']);
    $filter->setAllowedElements($allowedElements);
    $filter->setCensorData(true);
    $filter->setReplaceTags(true);
    $filter->setNamespace('glfusion', 'mail_story');
    $sql = "SELECT uid,title,introtext,bodytext,commentcode,UNIX_TIMESTAMP(date) AS day,postmode FROM {$_TABLES['stories']} WHERE sid = '" . DB_escapeString($sid) . "'" . COM_getTopicSql('AND') . COM_getPermSql('AND');
    $result = DB_query($sql);
    if (DB_numRows($result) == 0) {
        return COM_refresh($_CONF['site_url'] . '/index.php');
    }
    $A = DB_fetchArray($result);
    $mailtext = sprintf($LANG08[23], $from, $fromemail) . LB;
    if (strlen($shortmsg) > 0) {
        if ($html) {
            $shortmsg = $filter->filterHTML($shortmsg);
        }
        $mailtext .= LB . sprintf($LANG08[28], $from) . $shortmsg . LB;
    }
    // just to make sure this isn't an attempt at spamming users ...
    $result = PLG_checkforSpam($mailtext, $_CONF['spamx']);
    if ($result > 0) {
        COM_updateSpeedlimit('mail');
        COM_displayMessageAndAbort($result, 'spamx', 403, 'Forbidden');
    }
    $dt->setTimestamp($A['day']);
    if ($html) {
        $mailtext .= '<p>------------------------------------------------------------</p>' . '<p>' . COM_undoSpecialChars($A['title']) . '</p>' . '<p>' . $dt->format($_CONF['date'], true) . '</p>';
    } else {
        $mailtext .= '------------------------------------------------------------' . LB . LB . COM_undoSpecialChars($A['title']) . LB . $dt->format($_CONF['date'], true) . LB;
    }
    if ($_CONF['contributedbyline'] == 1) {
        $author = COM_getDisplayName($A['uid']);
        $mailtext .= $LANG01[1] . ' ' . $author . LB;
    }
    if ($html) {
        $mailtext .= '<p>' . $filter->displayText($A['introtext']) . '<br />' . $filter->displayText($A['bodytext']) . '</p>' . '<p>------------------------------------------------------------</p>';
    } else {
        $mailtext .= $filter->displayText($A['introtext']) . LB . $filter->displayText($A['bodytext']) . LB . LB . '------------------------------------------------------------' . LB;
    }
    if ($A['commentcode'] == 0) {
        // comments allowed
        $mailtext .= $LANG08[24] . LB . COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid . '#comments');
    } else {
        // comments not allowed - just add the story's URL
        $mailtext .= $LANG08[33] . LB . COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid);
    }
    $mailto = array();
    $mailfrom = array();
    $mailto = COM_formatEmailAddress($to, $toemail);
    $mailfrom = COM_formatEmailAddress($from, $fromemail);
    $subject = COM_undoSpecialChars(strip_tags('Re: ' . $A['title']));
    $rc = COM_mail($mailto, $subject, $mailtext, $mailfrom, $html);
    COM_updateSpeedlimit('mail');
    if ($rc) {
        if ($_CONF['url_rewrite']) {
            $retval = COM_refresh($storyurl . '?msg=27');
        } else {
            $retval = COM_refresh($storyurl . '&amp;msg=27');
        }
    } else {
        // Increment numemails counter for story
        DB_query("UPDATE {$_TABLES['stories']} SET numemails = numemails + 1 WHERE sid = '" . DB_escapeString($sid) . "'");
        if ($_CONF['url_rewrite']) {
            $retval = COM_refresh($storyurl . '?msg=26');
        } else {
            $retval = COM_refresh($storyurl . '&amp;msg=26');
        }
    }
    echo COM_refresh($retval);
    exit;
}
開發者ID:NewRoute,項目名稱:glfusion,代碼行數:101,代碼來源:profiles.php

示例15: COM_emailUserTopics


//.........這裏部分代碼省略.........
        $trows = DB_numRows($tresult);
        if ($trows == 0) {
            // this user doesn't seem to have access to any topics ...
            continue;
        }
        $TIDS = array();
        for ($i = 0; $i < $trows; $i++) {
            $T = DB_fetchArray($tresult);
            $TIDS[] = $T['tid'];
        }
        if (!empty($U['etids'])) {
            $ETIDS = explode(' ', $U['etids']);
            $TIDS = array_intersect($TIDS, $ETIDS);
        }
        if (sizeof($TIDS) > 0) {
            $commonsql .= " AND (tid IN ('" . implode("','", $TIDS) . "'))";
        }
        $commonsql .= COM_getPermSQL('AND', $U['uuid']);
        $commonsql .= ' ORDER BY featured DESC, date DESC';
        $storysql .= $commonsql;
        $stories = DB_query($storysql);
        $nsrows = DB_numRows($stories);
        if ($nsrows == 0) {
            // If no new stories where pulled for this user, continue with next
            continue;
        }
        $T = new Template($_CONF['path_layout']);
        $T->set_file(array('message' => 'digest.thtml', 'story' => 'digest_story.thtml'));
        $TT = new Template($_CONF['path_layout']);
        $TT->set_file(array('message' => 'digest_text.thtml', 'story' => 'digest_story_text.thtml'));
        $T->set_var('week_date', strftime($_CONF['shortdate'], time()));
        $TT->set_var('week_date', strftime($_CONF['shortdate'], time()));
        $T->set_var('site_name', $_CONF['site_name']);
        $TT->set_var('site_name', $_CONF['site_name']);
        $T->set_var('remove_msg', sprintf($LANG08[36], $_CONF['site_name'], $_CONF['site_url']));
        $TT->set_var('remove_msg', sprintf($LANG08[37], $_CONF['site_name'], $_CONF['site_url']));
        for ($y = 0; $y < $nsrows; $y++) {
            // Loop through stories building the requested email message
            $S = DB_fetchArray($stories);
            $story = new Story();
            $args = array('sid' => $S['sid'], 'mode' => 'view');
            $output = STORY_LOADED_OK;
            $result = PLG_invokeService('story', 'get', $args, $output, $svc_msg);
            if ($result == PLG_RET_OK) {
                /* loadFromArray cannot be used, since it overwrites the timestamp */
                reset($story->_dbFields);
                while (list($fieldname, $save) = each($story->_dbFields)) {
                    $varname = '_' . $fieldname;
                    if (array_key_exists($fieldname, $output)) {
                        $story->{$varname} = $output[$fieldname];
                    }
                }
                $story->_username = $output['username'];
                $story->_fullname = $output['fullname'];
            }
            $story_url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $S['sid']);
            $title = COM_undoSpecialChars($S['title']);
            if ($_CONF['contributedbyline'] == 1) {
                if (empty($authors[$S['uid']])) {
                    $storyauthor = COM_getDisplayName($S['uid']);
                    $authors[$S['uid']] = $storyauthor;
                } else {
                    $storyauthor = $authors[$S['uid']];
                }
            }
            $dt = new Date($S['day'], $_USER['tzid']);
            $story_date = $dt->format($_CONF['date'], true);
            if ($_CONF['emailstorieslength'] > 0) {
                $storytext = COM_undoSpecialChars(strip_tags(PLG_replaceTags($S['introtext'], 'glfusion', 'story')));
                $storytext_text = COM_undoSpecialChars(strip_tags(PLG_replaceTags($S['introtext'], 'glfusion', 'story')));
                if ($_CONF['emailstorieslength'] > 1) {
                    $storytext = COM_truncate($storytext, $_CONF['emailstorieslength'], '...');
                    $storytext_text = COM_truncate($storytext_text, $_CONF['emailstorieslength'], '...');
                }
            } else {
                $storytext = '';
                $storytext_text = '';
            }
            $T->set_var('story_introtext', $storytext);
            $TT->set_var('story_introtext', $storytext_text);
            $T->set_var(array('story_url' => $story_url, 'story_title' => $title, 'story_author' => $storyauthor, 'story_date' => $story_date, 'story_text' => $storytext));
            $T->parse('digest_stories', 'story', true);
            $TT->set_var(array('story_url' => $story_url, 'story_title' => $title, 'story_author' => $storyauthor, 'story_date' => $story_date, 'story_text' => $storytext_text));
            $TT->parse('digest_stories', 'story', true);
        }
        $T->parse('digest', 'message', true);
        $TT->parse('digest', 'message', true);
        $mailtext = $T->finish($T->get_var('digest'));
        $mailtext_text = $TT->finish($TT->get_var('digest'));
        $mailfrom = $_CONF['noreply_mail'];
        $mailtext .= LB . LB . $LANG04[159];
        $mailtext_text .= LB . LB . $LANG04[159];
        $to = array();
        $from = array();
        $from = COM_formatEmailAddress('', $mailfrom);
        $to = COM_formatEmailAddress($U['username'], $U['email']);
        COM_mail($to, $subject, $mailtext, $from, 1, 0, '', $mailtext_text);
    }
    DB_query("UPDATE {$_TABLES['vars']} SET value = NOW() WHERE name = 'lastemailedstories'");
}
開發者ID:NewRoute,項目名稱:glfusion,代碼行數:101,代碼來源:lib-common.php


注:本文中的COM_formatEmailAddress函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。