예제 #1
0
 /**
  *   Send an email to the buyer
  *
  *   @param  string  $status     Order status (pending, paid, etc.)
  *   @param  string  $msg        Optional message to include with email
  */
 public function Notify($status = '', $gw_msg = '')
 {
     global $_CONF, $_PP_CONF, $_TABLES;
     // Check if we're supposed to send a notification
     if ($this->uid != 1 && $_PP_CONF['purch_email_user'] || $this->uid == 1 && $_PP_CONF['purch_email_anon']) {
         PAYPAL_debug("Sending email to " . $this->uid);
         // setup templates
         $message = new Template(PAYPAL_PI_PATH . '/templates');
         $message->set_file(array('subject' => 'purchase_email_subject.txt', 'msg_admin' => 'purchase_email_admin.txt', 'msg_user' => 'purchase_email_user.txt', 'msg_body' => 'purchase_email_body.txt'));
         // Add all the items to the message
         $total = (double) 0;
         // Track total purchase value
         $files = array();
         // Array of filenames, for attachments
         $num_format = "%5.2f";
         $item_total = 0;
         $have_physical = 0;
         // Assume no physical items.
         $dl_links = '';
         // Start with empty download links
         USES_paypal_class_product();
         foreach ($this->items as $id => $item) {
             if (!PAYPAL_is_plugin_item($item['product_id'])) {
                 $P = new Product($item['product_id']);
                 if ($P->prod_type & PP_PROD_PHYSICAL == PP_PROD_PHYSICAL) {
                     $have_physical = 1;
                 }
                 // Add the file to the filename array, if any. Download
                 // links are only included if the order status is 'paid'
                 $file = $P->file;
                 if (!empty($file) && $this->status == 'paid') {
                     $files[] = $file;
                     $dl_url = PAYPAL_URL . '/download.php?';
                     // There should always be a token, but fall back to the
                     // product ID if there isn't
                     if (!empty($item['token'])) {
                         $dl_url .= 'token=' . urlencode($item['token']);
                     } else {
                         $dl_url .= 'id=' . $item['item_number'];
                     }
                     $dl_links .= "<a href=\"{$dl_url}\">{$dl_url}</a><br />";
                 }
             }
             $ext = (double) $item['quantity'] * (double) $item['price'];
             $item_total += $ext;
             $item_descr = isset($item['description']) ? $item['description'] : $item['descrip'];
             //$message->set_block('message', 'ItemList', 'List');
             $opts = json_decode($item['options_text'], true);
             if ($opts) {
                 foreach ($opts as $opt_text) {
                     $options_text .= "&nbsp;&nbsp;--&nbsp;{$opt_text}<br />";
                 }
             }
             $message->set_block('msg_body', 'ItemList', 'List');
             $message->set_var(array('qty' => $item['quantity'], 'price' => sprintf($num_format, $item['price']), 'ext' => sprintf($num_format, $ext), 'name' => $item_descr, 'options_text' => $options_text));
             //PAYPAL_debug("Qty: {$item['quantity']} : Amount: {$item['price']} : Name: {$item['name']}", 'debug_ipn');
             $message->parse('List', 'ItemList', true);
         }
         // Determine if files will be attached to this message based on
         // global config and whether there are actually any files to
         // attach. Affects the 'files' flag in the email template and
         // which email function is used.
         if ((is_numeric($this->uid) && $this->uid != 1 && $_PP_CONF['purch_email_user_attach'] || (!is_numeric($this->uid) || $this->uid == 1) && $_PP_CONF['purch_email_anon_attach']) && count($files) > 0) {
             $do_send_attachments = true;
         } else {
             $do_send_attachments = false;
         }
         $total_amount = $item_total + $this->tax + $this->shipping + $this->handling;
         $user_name = COM_getDisplayName($this->uid);
         if ($this->billto_name == '') {
             $this->billto_name = $user_name;
         }
         $message->set_var(array('payment_gross' => sprintf($num_format, $total_amount), 'payment_items' => sprintf($num_format, $item_total), 'tax' => sprintf($num_format, $this->tax), 'shipping' => sprintf($num_format, $this->shipping), 'handling' => sprintf($num_format, $this->handling), 'payment_date' => $_PP_CONF['now']->toMySQL(true), 'payer_email' => $this->buyer_email, 'payer_name' => $this->billto_name, 'site_name' => $_CONF['site_name'], 'txn_id' => $this->pmt_txn_id, 'pi_url' => PAYPAL_URL, 'pi_admin_url' => PAYPAL_ADMIN_URL, 'dl_links' => $dl_links, 'files' => $do_send_attachments ? 'true' : '', 'buyer_uid' => $this->uid, 'user_name' => $user_name, 'gateway_name' => $this->pmt_method, 'pending' => $this->status == 'pending' ? 'true' : '', 'gw_msg' => $gw_msg, 'status' => $this->status, 'order_instr' => $this->instructions));
         // parse templates for subject/text
         $subject = trim($message->parse('output', 'subject'));
         $message->set_var('purchase_details', $message->parse('detail', 'msg_body'));
         $user_text = $message->parse('user_out', 'msg_user');
         $admin_text = $message->parse('admin_out', 'msg_admin');
         if ($this->buyer_email != '') {
             // if specified to mail attachment, do so, otherwise skip
             // attachment
             if ($do_send_attachments) {
                 // Make sure plugin functions are available
                 USES_paypal_functions();
                 PAYPAL_mailAttachment($this->buyer_email, $subject, $user_text, $_CONF['site_email'], true, 0, '', '', $files);
             } else {
                 // Otherwise send a standard notification
                 COM_emailNotification(array('to' => array($this->buyer_email), 'from' => $_CONF['site_mail'], 'htmlmessage' => $user_text, 'subject' => $subject));
             }
         }
         // Send a notification to the administrator, new purchases only
         if ($status == '') {
             if ($_PP_CONF['purch_email_admin'] == 2 || $have_physical && $_PP_CONF['purch_email_admin'] == 1) {
                 PAYPAL_debug('Sending email to Admin');
                 $email_addr = empty($_PP_CONF['admin_email_addr']) ? $_CONF['site_mail'] : $_PP_CONF['admin_email_addr'];
                 COM_emailNotification(array('to' => array($email_addr), 'from' => $_CONF['noreply_mail'], 'htmlmessage' => $admin_text, 'subject' => $subject));
             }
         }
     }
 }
예제 #2
0
/**
* User request for a new password - send email with a link and request id
*
* @param username string   name of user who requested the new password
* @param msg      int      index of message to display (if any)
* @return         string   form or meta redirect
*
*/
function requestpassword($username, $msg = 0)
{
    global $_CONF, $_TABLES, $LANG04;
    $retval = '';
    // no remote users!
    $username = DB_escapeString($username);
    $result = DB_query("SELECT uid,email,passwd,status FROM {$_TABLES['users']} WHERE username = '******' 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');
        }
        $reqid = substr(md5(uniqid(rand(), 1)), 1, 16);
        DB_change($_TABLES['users'], 'pwrequestid', "{$reqid}", 'uid', (int) $A['uid']);
        $T = new Template($_CONF['path_layout'] . 'email/');
        $T->set_file(array('html_msg' => 'mailtemplate_html.thtml', 'text_msg' => 'mailtemplate_text.thtml'));
        $T->set_block('html_msg', 'content', 'contentblock');
        $T->set_block('text_msg', 'contenttext', 'contenttextblock');
        $T->set_var('content_text', sprintf($LANG04[88], $username));
        $T->parse('contentblock', 'content', true);
        $T->parse('contenttextblock', 'contenttext', true);
        $T->set_var('url', $_CONF['site_url'] . '/users.php?mode=newpwd&uid=' . $A['uid'] . '&rid=' . $reqid);
        $T->set_var('button_text', $LANG04[91]);
        $T->parse('contentblock', 'content', true);
        $T->parse('contenttextblock', 'contenttext', true);
        $T->unset_var('button_text');
        $T->set_var('content_text', $LANG04[89]);
        $T->parse('contentblock', 'content', true);
        $T->parse('contenttextblock', 'contenttext', true);
        $T->set_var('site_url', $_CONF['site_url']);
        $T->set_var('site_name', $_CONF['site_name']);
        $T->set_var('title', $_CONF['site_name'] . ': ' . $LANG04[16]);
        $T->parse('output', 'html_msg');
        $mailhtml = $T->finish($T->get_var('output'));
        $T->parse('textoutput', 'text_msg');
        $mailtext = $T->finish($T->get_var('textoutput'));
        $msgData['htmlmessage'] = $mailhtml;
        $msgData['textmessage'] = $mailtext;
        $msgData['subject'] = $_CONF['site_name'] . ': ' . $LANG04[16];
        $msgData['from']['name'] = $_CONF['site_name'];
        $msgData['from']['email'] = $_CONF['noreply_mail'];
        $msgData['to']['email'] = $A['email'];
        $msgData['to']['name'] = $username;
        COM_emailNotification($msgData);
        COM_updateSpeedlimit('password');
        if ($msg) {
            echo COM_refresh($_CONF['site_url'] . "/index.php?msg={$msg}");
        } else {
            echo COM_refresh($_CONF['site_url'] . '/index.php');
        }
    } else {
        COM_updateSpeedlimit('password');
        echo COM_refresh($_CONF['site_url'] . '/users.php?mode=getpassword');
        exit;
    }
    return $retval;
}
예제 #3
0
/**
* Send new item notification emails
*
* @param    string  $type     plugin name or comment
* @param    string  $category category type (i.e.; for comment it would contain
                              filemgmt, article, etc.)
* @param    string  $track_id id of item being tracked
* @param    string  $post_id  id of new item posted (i.e.; comment id, media_id, etc.)
* @param    int     $post_uid user who posted item
* @return   boolean           true on succes, false on fail
* @since    glFusion v1.3.0
*
*/
function PLG_sendSubscriptionNotification($type, $category, $track_id, $post_id, $post_uid)
{
    global $_CONF, $_TABLES, $LANG04;
    USES_lib_html2text();
    $function = 'plugin_subscription_email_format_' . $type;
    if (function_exists($function)) {
        $args[1] = $category;
        $args[2] = $track_id;
        $args[3] = $post_id;
        $args[4] = $post_uid;
        list($htmlmsg, $textmsg, $imageData) = PLG_callFunctionForOnePlugin($function, $args);
    } else {
        COM_errorLog("PLG_sendSubscriptionNotification() - No plugin_subscription_email_format_ defined");
        return false;
    }
    if ($track_id == 0) {
        $sql = "SELECT {$_TABLES['subscriptions']}.uid,email,id FROM {$_TABLES['subscriptions']} LEFT JOIN {$_TABLES['users']} ON {$_TABLES['subscriptions']}.uid={$_TABLES['users']}.uid" . " WHERE {$_TABLES['users']}.status=" . USER_ACCOUNT_ACTIVE . " AND category='" . DB_escapeString($category) . "'" . " AND type='" . DB_escapeString($type) . "'";
    } else {
        $sql = "SELECT {$_TABLES['subscriptions']}.uid,email,id FROM {$_TABLES['subscriptions']} LEFT JOIN {$_TABLES['users']} ON {$_TABLES['subscriptions']}.uid={$_TABLES['users']}.uid" . " WHERE {$_TABLES['users']}.status=" . USER_ACCOUNT_ACTIVE . " AND category='" . DB_escapeString($category) . "'" . " AND id='" . DB_escapeString($track_id) . "'" . " AND type='" . DB_escapeString($type) . "'";
    }
    $result = DB_query($sql);
    $nrows = DB_numRows($result);
    $messageData = array();
    $messageData['subject'] = $LANG04[184];
    $messageData['from'] = $_CONF['noreply_mail'];
    $messageData['htmlmessage'] = $htmlmsg;
    $messageData['textmessage'] = $textmsg;
    if (is_array($imageData) && count($imageData) > 0) {
        $messageData['embeddedImage'] = $imageData;
    }
    $to = array();
    while (($S = DB_fetchArray($result)) != NULL) {
        if ($S['uid'] == $post_uid) {
            // skip author
            continue;
        }
        if ($S['id'] < 0) {
            // allows exclude records...
            continue;
        }
        $to[] = $S['email'];
    }
    $messageData['to'] = $to;
    COM_emailNotification($messageData);
    return true;
}
예제 #4
0
function MG_sendPostCard()
{
    global $MG_albums, $_MG_CONF, $_CONF, $_TABLES, $_USER, $LANG_MG00, $LANG_MG02, $LANG_MG03, $LANG_ACCESS, $_POST;
    global $LANG_DIRECTION, $LANG_CHARSET;
    $mid = COM_sanitizeID(COM_applyFilter($_POST['mid'], true));
    $toname = COM_applyFilter($_POST['toname']);
    $toemail = COM_applyFilter($_POST['toemail']);
    $fromname = COM_applyFilter($_POST['fromname']);
    $fromemail = COM_applyFilter($_POST['fromemail']);
    $subject = strip_tags(COM_checkWords($_POST['subject']));
    $message = htmlspecialchars(strip_tags(COM_checkWords($_POST['message'])));
    $ccself = isset($_POST['ccself']) ? 1 : 0;
    $errCount = 0;
    $msg = '';
    if (!COM_isEmail($toemail)) {
        $errCount++;
    }
    if (!COM_isEmail($fromemail)) {
        $errCount++;
    }
    if (empty($subject)) {
        $errCount++;
    }
    if (empty($message)) {
        $errCount++;
    }
    $captchaString = isset($_POST['captcha']) ? $_POST['captcha'] : '';
    $msg = PLG_itemPreSave('mediagallery', $captchaString);
    if ($msg != '') {
        $errCount++;
    }
    if ($errCount > 0) {
        return MG_editPostCard('edit', $mid, $msg);
    }
    $retval = '';
    $aid = DB_getItem($_TABLES['mg_media_albums'], 'album_id', 'media_id="' . DB_escapeString($mid) . '"');
    if ($MG_albums[$aid]->access == 0 || $MG_albums[$aid]->enable_postcard == 0 || COM_isAnonUser() && $MG_albums[$aid]->enable_postcard != 2) {
        $retval = MG_siteHeader();
        $retval .= COM_showMessageText($LANG_MG00['access_denied_msg'], $LANG_ACCESS['accessdenied'], true);
        $retval .= MG_siteFooter();
        echo $retval;
        exit;
    }
    $sql = "SELECT * FROM {$_TABLES['mg_media_albums']} as ma LEFT JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE m.media_id='" . DB_escapeString($mid) . "'";
    $result = DB_query($sql);
    $nRows = DB_numRows($result);
    if ($nRows < 1) {
        $retval = MG_siteHeader();
        $retval .= COM_showMessageText($LANG_MG00['access_denied_msg'], $LANG_ACCESS['accessdenied'], true);
        $retval .= MG_siteFooter();
        echo $retval;
        exit;
    }
    $M = DB_fetchArray($result);
    // trim the database
    $purgeDate = time() - $_MG_CONF['postcard_retention'] * 86400;
    DB_query("DELETE FROM {$_TABLES['mg_postcard']} WHERE pc_time < " . $purgeDate);
    // save this one in the database
    $newsubject = DB_escapeString($subject);
    $newmessage = DB_escapeString($message);
    $pcId = COM_makesid();
    $pc_time = time();
    if (COM_isAnonUser()) {
        $uid = 1;
    } else {
        $uid = (int) $_USER['uid'];
    }
    $sql = "INSERT INTO {$_TABLES['mg_postcard']} (pc_id,mid,to_name,to_email,from_name,from_email,subject,message,pc_time,uid) VALUES ('{$pcId}','" . DB_escapeString($mid) . "','" . DB_escapeString($toname) . "','" . DB_escapeString($toemail) . "','" . DB_escapeString($fromname) . "','" . DB_escapeString($fromemail) . "','{$newsubject}','{$newmessage}',{$pc_time},{$uid})";
    $result = DB_query($sql);
    if (DB_error()) {
        COM_errorLog("Media Gallery: Error saving postcard");
    }
    COM_clearSpeedlimit($_CONF['commentspeedlimit'], 'mgpostcard');
    $last = COM_checkSpeedlimit('mgpostcard');
    if ($last > 0) {
        $msg = sprintf($LANG_MG02['postcard_speedlimit'], $last);
        return MG_errorHandler($msg);
    }
    $alternate_link = $_MG_CONF['site_url'] . '/getcard.php?id=' . $pcId;
    // build the template...
    $T = new Template(MG_getTemplatePath($aid));
    $T->set_file('postcard', 'postcard.thtml');
    $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.jpg');
    if (empty($LANG_DIRECTION)) {
        // default to left-to-right
        $direction = 'ltr';
    } else {
        $direction = $LANG_DIRECTION;
    }
    if (empty($LANG_CHARSET)) {
        $charset = $_CONF['default_charset'];
        if (empty($charset)) {
            $charset = 'iso-8859-1';
        }
    } else {
        $charset = $LANG_CHARSET;
    }
    $T->set_var(array('s_form_action' => $_MG_CONF['site_url'] . '/postcard.php', 'direction' => $direction, 'charset' => $charset, 'mid' => $mid, 'media_title' => $M['media_title'], 'alt_media_title' => htmlspecialchars(strip_tags($M['media_title'])), 'media_description' => isset($M['media_description']) ? $M['media_description'] : '', 'media_url' => $_MG_CONF['site_url'] . '/media.php?s=' . $mid, 'media_image' => $_MG_CONF['mediaobjects_url'] . '/disp/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.jpg', 'site_url' => $_MG_CONF['site_url'] . '/', 'postcard_subject' => $subject, 'postcard_message' => nl2br($message), 'from_email' => $fromemail, 'site_name' => $_CONF['site_name'], 'site_slogan' => $_CONF['site_slogan'], 'to_name' => $toname, 'from_name' => $fromname, 'pc_id' => $pcId, 'lang_to_name' => $LANG_MG03['to_name'], 'lang_to_email' => $LANG_MG03['to_email'], 'lang_from_name' => $LANG_MG03['from_name'], 'lang_from_email' => $LANG_MG03['from_email'], 'lang_subject' => $LANG_MG03['subject'], 'lang_send' => $LANG_MG03['send'], 'lang_cancel' => $LANG_MG03['cancel'], 'lang_preview' => $LANG_MG03['preview'], 'lang_unable_view' => $LANG_MG03['unable_to_view_postcard'], 'lang_postcard_from' => $LANG_MG03['postcard_from'], 'lang_to' => $LANG_MG03['to'], 'lang_from' => $LANG_MG03['from'], 'lang_visit' => $LANG_MG03['visit']));
    $T->parse('output', 'postcard');
    $retval .= $T->finish($T->get_var('output'));
    $msgData['subject'] = htmlspecialchars($subject);
    $msgData['htmlmessage'] = $retval;
    $msgData['textmessage'] = sprintf($LANG_MG03['text_body_email'], $fromname, $alternate_link);
    $msgData['from']['email'] = $fromemail;
    $msgData['from']['name'] = $fromname;
    $msgData['to'][] = array('email' => $toemail, 'name' => $toname);
    if ($ccself) {
        $msgData['to'][] = array('email' => $fromemail, 'name' => $fromname);
    }
    foreach ($_MG_CONF['validExtensions'] as $tnext) {
        if (file_exists($_MG_CONF['path_mediaobjects'] . 'disp/' . $M['media_filename'][0] . '/' . $M['media_filename'] . $tnext)) {
            $msgData['embeddedImage'][] = array('file' => $_MG_CONF['path_mediaobjects'] . 'disp/' . $M['media_filename'][0] . '/' . $M['media_filename'] . $tnext, 'name' => "pc-image", 'filename' => $M['media_original_filename'], 'encoding' => 'base64', 'mime' => $M['mime_type']);
        }
    }
    $msgData['embeddedImage'][] = array('file' => MG_getImageFilePath('stamp.gif'), 'name' => "stamp", 'filename' => 'stamp.gif', 'encoding' => 'base64', 'mime' => 'image/gif');
    COM_emailNotification($msgData);
    $msgNo = 8;
    // update the sent post card database...Or maybe just log it in an error log?
    $logentry = $fromname . " sent a postcard to " . $toname . " (" . $toemail . ") using media id " . $mid;
    MG_postcardLog($logentry);
    COM_updateSpeedlimit('mgpostcard');
    header("Location: " . $_MG_CONF['site_url'] . '/media.php?msg=' . $msgNo . '&s=' . $mid);
    exit;
}
예제 #5
0
function FM_notifyAdmins($filename, $file_user_id, $description)
{
    global $LANG_DIRECTION, $LANG_CHARSET, $LANG_FM00, $_USER, $_FM_CONF, $_CONF, $_TABLES;
    $html = false;
    $altBody = '';
    $to = array();
    $body = '';
    $description = stripslashes($description);
    // already escaped for db
    if (empty($LANG_DIRECTION)) {
        // default to left-to-right
        $direction = 'ltr';
    } else {
        $direction = $LANG_DIRECTION;
    }
    if (empty($LANG_CHARSET)) {
        $charset = $_CONF['default_charset'];
        if (empty($charset)) {
            $charset = 'iso-8859-1';
        }
    } else {
        $charset = $LANG_CHARSET;
    }
    COM_clearSpeedlimit(300, 'fmnotify');
    $last = COM_checkSpeedlimit('fmnotify');
    if ($last == 0) {
        $html = true;
        $subject = $LANG_FM00['new_upload'] . $_CONF['site_name'];
        if (!isset($file_user_id) || $file_user_id < 2) {
            $uname = 'Anonymous';
        } else {
            $uname = DB_getItem($_TABLES['users'], 'username', 'uid=' . intval($file_user_id));
        }
        // build the template...
        $T = new Template($_CONF['path'] . 'plugins/filemgmt/templates');
        $T->set_file('email', 'notifyemail.thtml');
        $T->set_var(array('direction' => $direction, 'charset' => $charset, 'lang_new_upload' => $LANG_FM00['new_upload_body'], 'lang_details' => $LANG_FM00['details'], 'lang_filename' => $LANG_FM00['filename'], 'lang_uploaded_by' => $LANG_FM00['uploaded_by'], 'username' => $uname, 'filename' => $filename, 'description' => $description, 'url_moderate' => '<a href="' . $_CONF['site_admin_url'] . '/plugins/filemgmt/index.php?op=listNewDownloads">Click here to view</a>', 'site_name' => $_CONF['site_name'] . ' - ' . $_CONF['site_slogan'], 'site_url' => $_CONF['site_url']));
        $T->parse('output', 'email');
        $body .= $T->finish($T->get_var('output'));
        $altbody = $LANG_FM00['new_upload_body'] . $_CONF['site_name'];
        $altbody .= "\n\r\n\r";
        $altbody .= $LANG_FM00['details'];
        $altbody .= "\n\r";
        $altbody .= $LANG_FM00['filename'] . ' ' . $filename . "\n\r";
        $altbody .= "\n\r";
        $altbody .= $description . "\n\r";
        $altbody .= "\n\r";
        $altbody .= $LANG_FM00['uploaded_by'] . ' ' . $uname . "\n\r";
        $altbody .= "\n\r\n\r";
        $altbody .= $_CONF['site_name'] . "\n\r";
        $altbody .= $_CONF['site_url'] . "\n\r";
        $group_id = DB_getItem($_TABLES['groups'], 'grp_id', 'grp_name="filemgmt Admin"');
        $groups = FM_getGroupList($group_id);
        if (count($groups) == 0) {
            $groupList = '1';
        } else {
            $groupList = implode(',', $groups);
        }
        $sql = "SELECT DISTINCT {$_TABLES['users']}.uid,username,fullname,email " . "FROM {$_TABLES['group_assignments']},{$_TABLES['users']} " . "WHERE {$_TABLES['users']}.uid > 1 " . "AND {$_TABLES['users']}.uid = {$_TABLES['group_assignments']}.ug_uid " . "AND ({$_TABLES['group_assignments']}.ug_main_grp_id IN ({$groupList}))";
        $result = DB_query($sql);
        $nRows = DB_numRows($result);
        $toCount = 0;
        for ($i = 0; $i < $nRows; $i++) {
            $row = DB_fetchArray($result);
            if ($row['email'] != '') {
                COM_errorLog("FileMgmt Upload: Sending notification email to: " . $row['email'] . " - " . $row['username']);
                $toCount++;
                $to[] = array('email' => $row['email'], 'name' => $row['username']);
            }
        }
        if ($toCount > 0) {
            $msgData['htmlmessage'] = $body;
            $msgData['textmessage'] = $altBody;
            $msgData['subject'] = $subject;
            $msgData['from']['email'] = $_CONF['site_mail'];
            $msgData['from']['name'] = $_CONF['site_name'];
            $msgData['to'] = $to;
            COM_emailNotification($msgData);
        } else {
            COM_errorLog("FileMgmt Upload: Error - Did not find any administrators to email");
        }
        COM_updateSpeedlimit('fmnotify');
    }
    return true;
}
예제 #6
0
function _ff_chknotifications($forumid, $topicid, $userid, $type = 'topic')
{
    global $_TABLES, $LANG_GF01, $LANG_GF02, $_CONF, $_FF_CONF;
    $msgData = array();
    if (!$_FF_CONF['allow_notification']) {
        return;
    }
    $pid = DB_getItem($_TABLES['ff_topic'], 'pid', 'id=' . (int) $topicid);
    if ($pid == 0 || $pid == '') {
        $pid = $topicid;
    }
    $grp_id = DB_getItem($_TABLES['ff_forums'], 'grp_id', 'forum_id=' . (int) $forumid);
    if ($grp_id == 0 || $grp_id == '') {
        $grp_id = 1;
    }
    $sql = "SELECT * FROM {$_TABLES['subscriptions']} WHERE type='forum' AND ((category=" . (int) $forumid . " AND id=" . (int) $pid . ") OR (category=" . (int) $forumid . " AND id=0 )) GROUP BY uid";
    $sqlresult = DB_query($sql);
    $postername = COM_getDisplayName($userid);
    $nrows = DB_numRows($sqlresult);
    $messageBody = '';
    if ($nrows > 0) {
        // we have some subscription records, build the emails
        $topicrec = DB_query("SELECT subject,name,forum,last_reply_rec FROM {$_TABLES['ff_topic']} WHERE id=" . (int) $pid);
        $A = DB_fetchArray($topicrec);
        $forum_name = DB_getItem($_TABLES['ff_forums'], 'forum_name', "forum_id=" . (int) $forumid);
        if ($type == 'forum') {
            $digestSubject = $forum_name;
            $digestSubject .= ": ";
            $digestSubject .= $A['subject'];
            $messageBody .= sprintf($LANG_GF02['msg23a'], $A['subject'], $postername, $A['name'], $_CONF['site_name']);
            $last_reply_rec = DB_getItem($_TABLES['ff_forums'], 'last_post_rec', "forum_id=" . (int) $forumid);
        } else {
            if ($A['last_reply_rec'] != '' && $A['last_reply_rec'] != 0) {
                $last_reply_rec = $A['last_reply_rec'];
            } else {
                $last_reply_rec = $topicid;
            }
            $digestSubject = $forum_name;
            $digestSubject .= ": RE: ";
            $digestSubject .= $A['subject'];
            $messageBody .= sprintf($LANG_GF02['msg23b'], $A['subject'], $A['name'], $forum_name, $_CONF['site_name'], $_CONF['site_url'], $pid);
            //            $messageBody .= sprintf($LANG_GF02['msg23a'],$A['subject'],$postername, $A['name'],$_CONF['site_name']);
            $messageBody .= sprintf($LANG_GF02['msg23c'], $_CONF['site_url'], $pid, $last_reply_rec);
        }
        $messageBody .= $LANG_GF02['msg26'];
        $messageBody .= sprintf($LANG_GF02['msg27'], "{$_CONF['site_url']}/forum/notify.php");
        $messageBody .= "{$LANG_GF02['msg25']}{$_CONF['site_name']} {$LANG_GF01['ADMIN']}\n";
        list($digestMessage, $digestMessageText) = gfm_getoutput($last_reply_rec);
    } else {
        return;
    }
    $msgDataDigest['subject'] = $digestSubject;
    $msgDataDigest['from'] = $_CONF['noreply_mail'];
    $msgDataDigest['htmlmessage'] = $digestMessage;
    $msgDataDigest['textmessage'] = $digestMessageText;
    $toDigest = array();
    $msgDataNotify['subject'] = "{$_CONF['site_name']} {$LANG_GF02['msg22']}";
    $msgDataNotify['from'] = $_CONF['noreply_mail'];
    $msgDataNotify['textmessage'] = $messageBody;
    $toNotify = array();
    for ($i = 1; $i <= $nrows; $i++) {
        $N = DB_fetchArray($sqlresult);
        // Don't need to send a notification to the user that posted this message and users with NOTIFY disabled
        if ($N['uid'] > 1 and $N['uid'] != $userid) {
            // if the topic_id is 0 for this record - user has subscribed to complete forum. Check if they have opted out of this forum topic.
            if (DB_count($_TABLES['subscriptions'], array('type', 'uid', 'category', 'id'), array('forum', $N['uid'], $forumid, -$topicid)) == 0) {
                // Check if user does not want to receive multiple notifications for same topic and already has been notified
                $userNotifyOnceOption = DB_getItem($_TABLES['ff_userprefs'], 'notify_once', "uid=" . (int) $N['uid']);
                // Retrieve the log record for this user if it exists then check if user has viewed this topic yet
                // The logtime value may be 0 which indicates the user has not yet viewed the topic
                $lsql = DB_query("SELECT time FROM {$_TABLES['ff_log']} WHERE uid=" . (int) $N['uid'] . " AND forum=" . (int) $forumid . " AND topic=" . (int) $topicid);
                if (DB_numRows($lsql) == 1) {
                    $nologRecord = false;
                    list($logtime) = DB_fetchArray($lsql);
                } else {
                    $nologRecord = true;
                    $logtime = 0;
                }
                if ($userNotifyOnceOption == 0 or $userNotifyOnceOption == 1 and ($nologRecord or $logtime != 0)) {
                    $userrec = DB_query("SELECT username,email,status FROM {$_TABLES['users']} WHERE uid=" . (int) $N['uid']);
                    $B = DB_fetchArray($userrec);
                    if ($B['status'] == USER_ACCOUNT_ACTIVE && SEC_inGroup($grp_id, (int) $N['uid'])) {
                        if ($nologRecord and $userNotifyOnceOption == 1) {
                            DB_query("INSERT INTO {$_TABLES['ff_log']} (uid,forum,topic,time) VALUES (" . (int) $N['uid'] . ", " . (int) $forumid . ", " . (int) $topicid . ",'0') ");
                        }
                        $notifyfull = DB_getItem($_TABLES['ff_userprefs'], 'notify_full', "uid=" . (int) $N['uid']);
                        if ($notifyfull) {
                            $toDigest[] = $B['email'];
                        } else {
                            $toNotify[] = $B['email'];
                        }
                    } else {
                        // remove the watch entry since this user can no longer access the forum.
                        DB_query("DELETE FROM {$_TABLES['subscriptions']} WHERE type='forum' AND uid=" . $N['uid'] . " AND ((id=" . (int) $pid . ") OR ((category=" . (int) $forumid . ") AND (id=0) ))");
                    }
                }
            }
        }
    }
    $msgDataDigest['to'] = $toDigest;
    $msgDataNotify['to'] = $toNotify;
    COM_emailNotification($msgDataDigest);
    COM_emailNotification($msgDataNotify);
}
예제 #7
0
function MG_notifyModerators($aid)
{
    global $LANG_DIRECTION, $LANG_CHARSET, $_USER, $MG_albums, $_MG_CONF, $_CONF, $_TABLES, $LANG_MG01;
    $to = array();
    if ($MG_albums[$aid]->moderate != 1 || $MG_albums[0]->owner_id) {
        return true;
    }
    $body = '';
    $media_user_id = $_USER['uid'];
    if (empty($LANG_DIRECTION)) {
        // default to left-to-right
        $direction = 'ltr';
    } else {
        $direction = $LANG_DIRECTION;
    }
    if (empty($LANG_CHARSET)) {
        $charset = $_CONF['default_charset'];
        if (empty($charset)) {
            $charset = 'iso-8859-1';
        }
    } else {
        $charset = $LANG_CHARSET;
    }
    COM_clearSpeedlimit(600, 'mgnotify');
    $last = COM_checkSpeedlimit('mgnotify');
    if ($last == 0) {
        $subject = $LANG_MG01['new_upload_subject'] . $_CONF['site_name'];
        if (COM_isAnonUser()) {
            $uname = 'Anonymous';
        } else {
            $uname = DB_getItem($_TABLES['users'], 'username', 'uid=' . $media_user_id);
        }
        // build the template...
        $T = new Template(MG_getTemplatePath($aid));
        $T->set_file('email', 'modemail.thtml');
        $T->set_var(array('direction' => $direction, 'charset' => $charset, 'lang_new_upload' => $LANG_MG01['new_upload_body'], 'lang_details' => $LANG_MG01['details'], 'lang_album_title' => 'Album', 'lang_uploaded_by' => $LANG_MG01['uploaded_by'], 'username' => $uname, 'album_title' => strip_tags($MG_albums[$aid]->title), 'url_moderate' => '<a href="' . $_MG_CONF['site_url'] . '/admin.php?album_id=' . $aid . '&mode=moderate">Click here to view</a>', 'site_name' => $_CONF['site_name'] . ' - ' . $_CONF['site_slogan'], 'site_url' => $_CONF['site_url']));
        $T->parse('output', 'email');
        $body .= $T->finish($T->get_var('output'));
        $altbody = $LANG_MG01['new_upload_body'] . $MG_albums[$aid]->title;
        $altbody .= "\n\r\n\r";
        $altbody .= $LANG_MG01['details'];
        $altbody .= "\n\r";
        $altbody .= $LANG_MG01['uploaded_by'] . ' ' . $uname . "\n\r";
        $altbody .= "\n\r\n\r";
        $altbody .= $_CONF['site_name'] . "\n\r";
        $altbody .= $_CONF['site_url'] . "\n\r";
        $groups = MG_getGroupList($MG_albums[$aid]->mod_group_id);
        $groupList = implode(',', $groups);
        $sql = "SELECT DISTINCT {$_TABLES['users']}.uid,username,fullname,email " . "FROM {$_TABLES['group_assignments']},{$_TABLES['users']} " . "WHERE {$_TABLES['users']}.uid > 1 " . "AND {$_TABLES['users']}.uid = {$_TABLES['group_assignments']}.ug_uid " . "AND ({$_TABLES['group_assignments']}.ug_main_grp_id IN ({$groupList}))";
        $result = DB_query($sql);
        $nRows = DB_numRows($result);
        $toCount = 0;
        for ($i = 0; $i < $nRows; $i++) {
            $row = DB_fetchArray($result);
            if ($row['email'] != '') {
                if ($_MG_CONF['verbose']) {
                    COM_errorLog("MG Upload: Sending notification email to: " . $row['email'] . " - " . $row['username']);
                }
                $toCount++;
                $to[] = array('email' => $row['email'], 'name' => $row['username']);
            }
        }
        if ($toCount > 0) {
            $msgData['htmlmessage'] = $body;
            $msgData['textmessage'] = $altBody;
            $msgData['subject'] = $subject;
            $msgData['from']['email'] = $_CONF['site_mail'];
            $msgData['from']['name'] = $_CONF['site_name'];
            $msgData['to'] = $to;
            COM_emailNotification($msgData);
        } else {
            COM_errorLog("MG Upload: Error - Did not find any moderators to email");
        }
        COM_updateSpeedlimit('mgnotify');
    }
    return true;
}