本文整理汇总了PHP中CEvent::ExtractMailFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CEvent::ExtractMailFields方法的具体用法?PHP CEvent::ExtractMailFields怎么用?PHP CEvent::ExtractMailFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEvent
的用法示例。
在下文中一共展示了CEvent::ExtractMailFields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CheckEvents
function CheckEvents()
{
if (defined("DisableEventsCheck") && DisableEventsCheck === true || defined("BX_CRONTAB_SUPPORT") && BX_CRONTAB_SUPPORT === true && BX_CRONTAB !== true) {
return;
}
$err_mess = CEvent::err_mess() . "<br>Function: CheckEvents<br>Line: ";
global $DB;
if (CACHED_b_event !== false && file_exists($_SERVER["DOCUMENT_ROOT"] . "/" . BX_ROOT . "/managed_cache/" . $DB->type . "/b_event")) {
return "";
}
$arCharset = array();
$DB->StartTransaction();
$DB->Query("SET LOCK_TIMEOUT 0", false, $err_mess . __LINE__);
$strSql = "\n\t\t\tSELECT TOP 5\n\t\t\t\tID,\n\t\t\t\tC_FIELDS,\n\t\t\t\tEVENT_NAME,\n\t\t\t\tMESSAGE_ID,\n\t\t\t\tLID,\n\t\t\t\t" . $DB->DateToCharFunction("DATE_INSERT") . " as DATE_INSERT_S,\n\t\t\t\tDUPLICATE\n\t\t\tFROM\n\t\t\t\tb_event\n\t\t\tWITH (TABLOCKX)\n\t\t\tWHERE\n\t\t\t\tSUCCESS_EXEC = 'N'\n\t\t\tORDER BY\n\t\t\t\tDATE_INSERT\n\t\t\t";
//echo "<pre>".$strSql."</pre>";
$rsMails = $DB->Query($strSql, true);
if (!$rsMails) {
$DB->Commit();
return;
}
$eol = CEvent::GetMailEOL();
$cnt = 0;
while ($arMail = $rsMails->Fetch()) {
$bWas = false;
// сайты письма
$site_id = "";
$arSites = explode(",", $arMail["LID"]);
$strSites = "";
foreach ($arSites as $site_id) {
$site_id = trim($site_id);
if (strlen($site_id) > 0) {
if ($strSites != "") {
$strSites .= ",";
}
$strSites .= "'" . $DB->ForSql($site_id, 2) . "'";
}
}
// если сайт определен
if (strlen($site_id) > 0) {
// кодировка письма
if (!in_array($site_id, array_keys($arCharset))) {
$strSql = "\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tCHARSET\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\tb_lang\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tLID = '" . $DB->ForSql($site_id, 2) . "'\n\t\t\t\t\t\t";
$rsSites = $DB->Query($strSql, false, $err_mess . __LINE__);
$arSite = $rsSites->Fetch();
$arCharset[$site_id] = $arSite["CHARSET"];
}
$charset = $arCharset[$site_id];
// шаблоны письма
$MESSAGE_ID = intval($arMail["MESSAGE_ID"]);
if ($MESSAGE_ID > 0) {
$strSql = "\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tM.ID,\n\t\t\t\t\t\t\tM.SUBJECT,\n\t\t\t\t\t\t\tM.MESSAGE,\n\t\t\t\t\t\t\tM.EMAIL_FROM,\n\t\t\t\t\t\t\tM.EMAIL_TO,\n\t\t\t\t\t\t\tM.BODY_TYPE,\n\t\t\t\t\t\t\tM.BCC\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\tb_event_message M\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tM.ID = {$MESSAGE_ID}\n\t\t\t\t\t\tand M.ACTIVE='Y'\n\t\t\t\t\t\t";
} else {
$strSql = "\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tM.ID,\n\t\t\t\t\t\t\tM.SUBJECT,\n\t\t\t\t\t\t\tM.MESSAGE,\n\t\t\t\t\t\t\tM.EMAIL_FROM,\n\t\t\t\t\t\t\tM.EMAIL_TO,\n\t\t\t\t\t\t\tM.BODY_TYPE,\n\t\t\t\t\t\t\tM.BCC\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\tb_event_message M\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tM.ACTIVE = 'Y'\n\t\t\t\t\t\t\tand M.EVENT_NAME = '" . $DB->ForSql($arMail["EVENT_NAME"]) . "'\n\t\t\t\t\t\t\tand exists(\n\t\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\t\t'x'\n\t\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\t\tb_event_message_site MS\n\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\tM.ID = MS.EVENT_MESSAGE_ID\n\t\t\t\t\t\t\t\t\tand MS.SITE_ID in (" . $strSites . ")\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t";
}
// поля письма
$arFields = CEvent::ExtractMailFields($arMail["C_FIELDS"]);
$bSuccess = false;
$bFail = false;
$rsTemplates = $DB->Query($strSql, false, $err_mess . __LINE__);
while ($arTemplate = $rsTemplates->Fetch()) {
// добавим из настроек сайта поля #SITE_NAME#, #SERVER_NAME#, #DEFAULT_EMAIL_FROM#
$strSql = "\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tMS.SITE_ID\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\tb_event_message_site MS\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tMS.EVENT_MESSAGE_ID = " . $arTemplate["ID"] . "\n\t\t\t\t\t\t\tand MS.SITE_ID IN (" . $strSites . ")\n\t\t\t\t\t\t";
$rsSites = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br>LINE: " . __LINE__);
if ($arSite = $rsSites->Fetch()) {
$arFields += CEvent::GetSiteFieldsArray($arSite["SITE_ID"]);
} else {
$arFields += CEvent::GetSiteFieldsArray(false);
}
$email_from = CEvent::ReplaceTemplate($arTemplate["EMAIL_FROM"], $arFields);
$email_to = CEvent::ReplaceTemplate($arTemplate["EMAIL_TO"], $arFields);
$message = CEvent::ReplaceTemplate($arTemplate["MESSAGE"], $arFields);
$subject = CEvent::ReplaceTemplate($arTemplate["SUBJECT"], $arFields);
$bcc = CEvent::ReplaceTemplate($arTemplate["BCC"], $arFields);
$email_from = trim($email_from, "\r\n");
$email_to = trim($email_to, "\r\n");
$subject = trim($subject, "\r\n");
$bcc = trim($bcc, "\r\n");
if (COption::GetOptionString("main", "convert_mail_header", "Y") == "Y") {
$email_from = CEvent::EncodeMimeString($email_from, $charset);
$email_to = CEvent::EncodeMimeString($email_to, $charset);
$subject = CEvent::EncodeMimeString($subject, $charset);
}
//если есть желающие получать всю почту, добавим их...
if ($arMail["DUPLICATE"] == "Y") {
$all_bcc = COption::GetOptionString("main", "all_bcc", "");
$bcc .= strlen($all_bcc) > 0 ? (strlen($bcc) > 0 ? "," : "") . $all_bcc : "";
}
if (COption::GetOptionString("main", "send_mid", "N") == "Y") {
$message .= ($arTemplate["BODY_TYPE"] == "html" ? "<br><br>" : "\n\n") . "MID #" . $arMail["ID"] . "." . $arTemplate["ID"] . " (" . $arMail["DATE_INSERT"] . ")\n";
}
$message = str_replace("\r\n", "\n", $message);
if (COption::GetOptionString("main", "CONVERT_UNIX_NEWLINE_2_WINDOWS", "N") == "Y") {
$message = str_replace("\n", "\r\n", $message);
}
$header = "";
if (COption::GetOptionString("main", "fill_to_mail", "N") == "Y") {
$header = "To: {$email_to}" . $eol;
}
$header = "From: {$email_from}" . $eol . $header . "Reply-To: {$email_from}" . $eol . "X-Priority: 3 (Normal)" . $eol . "X-MID: " . $arMail["ID"] . "." . $arTemplate["ID"] . " (" . $arMail["DATE_INSERT_S"] . ")" . $eol . "X-EVENT_NAME: " . $arMail["EVENT_NAME"] . $eol;
if (strpos($bcc, "@") !== false) {
//.........这里部分代码省略.........