Exemplo n.º 1
0
 function CleanUp()
 {
     global $DB;
     $days = COption::GetOptionInt("mail", "time_keep_log", B_MAIL_KEEP_LOG);
     $strSql = "DELETE FROM b_mail_log WHERE DATE_INSERT < DATE_ADD(now(), INTERVAL -" . intval($days) . " DAY)";
     $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     $mt = GetMicroTime();
     $dbr = $DB->Query("SELECT MS.ID FROM b_mail_message MS, b_mail_mailbox MB WHERE MS.MAILBOX_ID=MB.ID AND MB.MAX_KEEP_DAYS>0 AND MS.DATE_INSERT < DATE_ADD(now(), INTERVAL -MB.MAX_KEEP_DAYS DAY)");
     while ($ar = $dbr->Fetch()) {
         CMailMessage::Delete($ar["ID"]);
         if (GetMicroTime() - $mt > 10 * 1000) {
             break;
         }
     }
     return "CMailbox::CleanUp();";
 }
Exemplo n.º 2
0
	LocalRedirect("/bitrix/admin/mail_message_admin.php?lang=".LANG);
}


if($ID<=0 && $_REQUEST["MSG_ID"]!='')
	$dbr = CMailMessage::GetList(array(), array("MSG_ID"=>$_REQUEST["MSG_ID"]));
else
	$dbr = CMailMessage::GetByID($ID);

if($dbr_arr = $dbr->ExtractFields("str_")):


	$dbr_arr["SPAM_RATING"] = CMailMessage::GetSpamRating($ID, $dbr_arr);
	if($dbr_arr["NEW_MESSAGE"]=="Y")
		CMailMessage::Update($ID, Array("NEW_MESSAGE"=>"N"));

	if($_REQUEST['show']=='original' && COption::GetOptionString("mail", "save_src", B_MAIL_SAVE_SRC)=="Y")
	{
		echo "<pre>".nl2br(htmlspecialcharsbx($dbr_arr["FULL_TEXT"]))."</pre>";
		die();
	}

	$APPLICATION->SetTitle(GetMessage("MAIL_MSG_VIEW_TITLE"));
	require($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/prolog_admin_after.php");

	$aMenu = array(
		array(
			"ICON" => "btn_list",
			"TEXT"=>GetMessage("MAIL_MSG_VIEW_BACK_LINK"),
			"LINK"=>"mail_message_admin.php?lang=".LANG
Exemplo n.º 3
0
 function __DataHandler()
 {
     if (strpos($this->readBuffer, "\r\n.\r\n") === false) {
         return false;
     }
     $this->readBuffer = substr($this->readBuffer, 0, -5);
     $this->readBuffer = str_replace("\r\n..", "\r\n.", $this->readBuffer);
     // Добавление сообщения куда надо
     $message = $this->readBuffer;
     $this->arMsg["MSG"] = $message;
     $this->WriteToLog('[' . $this->arMsg["LOCAL_ID"] . '] Start processing mail...', 7);
     $p = strpos($message, "\r\n\r\n");
     if ($p > 0) {
         $message_header = substr($message, 0, $p);
         $message_text = substr($message, $p + 2);
         $arLocalTo = array();
         foreach ($this->arMsg["TO"] as $to) {
             if (is_array($this->arMsg["FOR_RELAY"]) && in_array($to, $this->arMsg["FOR_RELAY"])) {
                 $message_header_add = "Received: from " . $this->host . " by " . $this->server->arFields["SERVER"] . " with Bitrix SMTP Server \r\n" . "\t" . date("r") . "\r\n" . "\tfor <" . $to . ">; \r\n" . "Return-Path: <" . $this->arMsg["FROM"] . ">\r\n";
                 $subject = "";
                 $message_header_new = $message_header;
                 if (preg_match('/(Subject:\\s*([^\\r\\n]*\\r\\n(\\t[^\\r\\n]*\\r\\n)*))\\S/is', $message_header_new . "\r\nx", $reg)) {
                     $message_header_new = trim(str_replace($reg[1], "", $message_header_new . "\r\n"));
                     $subject = trim($reg[2]);
                 }
                 $r = bxmail($to, $subject, $message_text, $message_header_add . $message_header_new);
                 $this->WriteToLog('[' . $this->arMsg["LOCAL_ID"] . '] Relay message to ' . $to . ' (' . ($r ? 'OK' : 'FAILED') . ')', 7);
             } else {
                 $arLocalTo[] = $to;
             }
         }
         if (count($arLocalTo) > 0) {
             $message_header_add = "Received: from " . $this->host . " by " . $this->server->arFields["SERVER"] . " with Bitrix SMTP Server \r\n" . "\t" . date("r") . "\r\n" . "Return-Path: <" . $this->arMsg["FROM"] . ">\r\n" . "X-Original-Rcpt-to: " . implode(", ", $arLocalTo) . "\r\n";
             $this->WriteToLog('[' . $this->arMsg["LOCAL_ID"] . '] Message add: ' . $message_header_add . $message, 9);
             if ($this->server->arFields["CHARSET"] != '') {
                 $charset = $this->server->arFields["CHARSET"];
             } else {
                 $charset = $this->server->arFields["LANG_CHARSET"];
             }
             $message_id = CMailMessage::AddMessage($this->server->arFields["ID"], $message_header_add . $message, $charset);
             $this->WriteToLog('[' . $this->arMsg["LOCAL_ID"] . '] Message sent to ' . implode(", ", $arLocalTo) . ' (' . $message_id . ')', 7);
         }
         $this->Send('250', $message_id . ' Message accepted for delivery');
     } else {
         $this->Send('554', ' Bad message format');
     }
     $this->WriteToLog('[' . $this->arMsg["LOCAL_ID"] . '] End processing mail...', 7);
     $this->readBuffer = "";
     $this->__listenFunc = false;
     $this->arMsg = array('LOCAL_ID' => md5(uniqid()));
     $this->msgCount++;
     $this->server->msgCount++;
     return true;
 }
Exemplo n.º 4
0
while ($arRes = $rsData->NavNext(true, "f_")) {
    $row =& $lAdmin->AddRow($f_ID, $arRes);
    $str = "mail_filter_admin.php?lang=" . LANG . "&find_mailbox_id=" . $f_ID . "&set_filter=Y";
    $row->AddViewField("MAILBOX_NAME", $str);
    $row->AddCheckField("ACTIVE");
    $row->AddInputField("NAME", array("size" => "35"));
    $row->AddInputField("SERVER", array("size" => "35"));
    $arActions = array();
    $rules = CMailFilter::GetList(array(), array("MAILBOX_ID" => $f_ID), true);
    $res = $rules->Fetch();
    if ($arRes['USER_ID'] == 0) {
        $arActions[] = array("ICON" => "list", "TEXT" => GetMessage("MAIL_MBOX_ADM_RULES_LINK") . " (" . intval($res["CNT"]) . ")", "ACTION" => $lAdmin->ActionRedirect("mail_filter_admin.php?set_filter=Y&find_mailbox_id=" . $f_ID . "&lang=" . LANG));
        $arActions[] = array("ICON" => "add", "TEXT" => GetMessage("MAIL_MBOX_ADM_NEWRULE"), "ACTION" => $lAdmin->ActionRedirect("mail_filter_edit.php?MAILBOX_ID=" . $f_ID . "&lang=" . LANG));
        $arActions[] = array("SEPARATOR" => true);
        $arActions[] = array("ICON" => "list", "TEXT" => GetMessage("MAIL_MBOX_ADM_LOG"), "ACTION" => $lAdmin->ActionRedirect("mail_log.php?set_filter=Y&find_mailbox_id=" . $f_ID . "&lang=" . LANG));
        $msgs = CMailMessage::GetList(array(), array("MAILBOX_ID" => $f_ID), true);
        $res = $msgs->Fetch();
        $arActions[] = array("ICON" => "list", "TEXT" => GetMessage("MAIL_MBOX_ADM_MESSAGES") . " (" . intval($res["CNT_NEW"]) . " / " . intval($res["CNT"]) . ")", "ACTION" => $lAdmin->ActionRedirect("mail_message_admin.php?set_filter=Y&find_mailbox_id=" . $f_ID . "&lang=" . LANG));
        $arActions[] = array("SEPARATOR" => true);
    }
    $arActions[] = array("ICON" => "edit", "DEFAULT" => "Y", "TEXT" => GetMessage("MAIL_MBOX_ADM_CHANGE2"), "ACTION" => $lAdmin->ActionRedirect("mail_mailbox_edit.php?ID=" . $f_ID . "&lang=" . LANG));
    if ($MOD_RIGHT == "W") {
        $arActions[] = array("SEPARATOR" => true);
        $arActions[] = array("ICON" => "delete", "TEXT" => GetMessage("MAIL_MBOX_ADM_DELETE"), "ACTION" => "if(confirm('" . GetMessage('MAIL_MBOX_ADM_DEL_CONFIRM') . "')) " . $lAdmin->ActionDoGroup($f_ID, "delete"));
    }
    $row->AddActions($arActions);
}
// "подвал" списка
$lAdmin->AddFooter(array(array("title" => GetMessage("MAIN_ADMIN_LIST_SELECTED"), "value" => $rsData->SelectedRowsCount()), array("counter" => true, "title" => GetMessage("MAIN_ADMIN_LIST_CHECKED"), "value" => "0")));
if ($MOD_RIGHT == "W") {
    // показ добавление формы с кнопками
Exemplo n.º 5
0
 function UnMarkMessageAsSpam($messageID, $checkRights = "Y")
 {
     $err_mess = CAllTicket::err_mess() . "<br>Function: UnMarkMessageAsSpam<br>Line: ";
     global $DB, $USER;
     $messageID = intval($messageID);
     if ($messageID <= 0) {
         return;
     }
     $bAdmin = "N";
     $bSupportTeam = "N";
     if ($checkRights == "Y") {
         $bAdmin = CTicket::IsAdmin() ? "Y" : "N";
         $bSupportTeam = CTicket::IsSupportTeam() ? "Y" : "N";
     } else {
         $bAdmin = "Y";
         $bSupportTeam = "Y";
     }
     if (($bAdmin == "Y" || $bSupportTeam == "Y") && CModule::IncludeModule("mail")) {
         $rsMessage = CTicket::GetMessageByID($messageID, $checkRights);
         if ($arMessage = $rsMessage->Fetch()) {
             $arFields = array("IS_SPAM" => "null");
             $DB->Update("b_ticket_message", $arFields, "WHERE ID=" . $messageID, $err_mess . __LINE__);
             $email_id = intval($arMessage["EXTERNAL_ID"]);
             $header = $arMessage["EXTERNAL_FIELD_1"];
             $rsEmail = CMailMessage::GetByID($email_id);
             if ($rsEmail->Fetch()) {
                 CMailMessage::MarkAsSpam($email_id, false);
             } else {
                 CmailFilter::DeleteFromSpamBase($header . " \n\r " . $arMessage["MESSAGE"], true);
                 CmailFilter::MarkAsSpam($header . " \n\r " . $arMessage["MESSAGE"], false);
             }
         }
     }
 }
Exemplo n.º 6
0
	public static function FilterMessage($message_id, $event, $FILTER_ID=false)
	{
		$res = CMailMessage::GetByID($message_id);
		if($arFields = $res->Fetch())
			return CMailFilter::Filter($arFields, $event, $FILTER_ID);

		return false;
	}
Exemplo n.º 7
0
     } else {
         $str .= '<div class="mail-message-unread-notspam adm-list-mail-icon" title="' . GetMessage("MAIL_MSG_ADM_NOTREAD_NOTSPAM") . '"></div>';
     }
 } else {
     if ($f_NEW_MESSAGE != "Y") {
         $str .= '<div class="mail-message adm-list-mail-icon" title="' . GetMessage("MAIL_MSG_ADM_READ") . '"></div>';
     } else {
         $str .= '<div class="mail-message-unread adm-list-mail-icon" title="' . GetMessage("MAIL_MSG_ADM_NOTREAD") . '"></div>';
     }
 }
 $str .= '<a href="mail_message_view.php?lang=' . LANG . '&amp;ID=' . $f_ID . '">' . (strlen($f_SUBJECT) > 0 ? $f_SUBJECT : GetMessage("MAIL_MSG_ADM_NOSUBJ"));
 $row->AddViewField("SUBJECT", $str);
 $str = $f_MAILBOX_NAME . ' [<a title="' . GetMessage("MAIL_MSG_ADM_CHANGE_MBOX") . '" href="mail_mailbox_edit.php?ID=' . $f_MAILBOX_ID . '&lang=' . LANG . '">' . $f_MAILBOX_ID . '</a>]';
 $row->AddViewField("MAILBOX_NAME", $str);
 $row->AddViewField("MESSAGE_SIZE", CFile::FormatSize($f_MESSAGE_SIZE));
 $arRes["SPAM_RATING"] = CMailMessage::GetSpamRating($f_ID, $arRes);
 $str = Round($arRes["SPAM_RATING"], 2) . "%";
 $row->AddViewField("SPAM_RATING", $str);
 $arActions = array();
 $arActions[] = array("DEFAULT" => "Y", "TEXT" => GetMessage("MAIL_MSG_ADM_VIEW"), "ACTION" => $lAdmin->ActionRedirect('mail_message_view.php?lang=' . LANG . '&ID=' . $f_ID));
 if ($MOD_RIGHT == "W") {
     $arActions[] = array("SEPARATOR" => true);
     if ($f_SPAM != "Y") {
         $arActions[] = array("TEXT" => GetMessage("MAIL_MSG_ADM_PROC_ACT_SPAM"), "ACTION" => $lAdmin->ActionAjaxReload($APPLICATION->GetCurPage() . "?action=mark_as_spam&ID=" . $f_ID . "&lang=" . LANG . "&" . bitrix_sessid_get()));
     }
     if ($f_SPAM != "N") {
         $arActions[] = array("TEXT" => GetMessage("MAIL_MSG_ADM_PROC_ACT_NOTSPAM"), "ACTION" => $lAdmin->ActionAjaxReload($APPLICATION->GetCurPage() . "?action=mark_as_notspam&ID=" . $f_ID . "&lang=" . LANG . "&" . bitrix_sessid_get()));
     }
     if ($f_NEW_MESSAGE == "Y") {
         $arActions[] = array("TEXT" => GetMessage("MAIL_MSG_ADM_PROC_ACT_READ"), "ACTION" => $lAdmin->ActionAjaxReload($APPLICATION->GetCurPage() . "?action=mark_as_read&ID=" . $f_ID . "&lang=" . LANG . "&" . bitrix_sessid_get()));
     } else {
Exemplo n.º 8
0
function ForumSpamMessage($message, &$strErrorMessage, &$strOKMessage, $arAddParams = array())
{
    global $USER;
    $arError = array();
    $arOK = array();
    $arAddParams = !is_array($arAddParams) ? array($arAddParams) : $arAddParams;
    $arAddParams["PERMISSION"] = !empty($arAddParams["PERMISSION"]) ? $arAddParams["PERMISSION"] : false;
    $message = ForumDataToArray($message);
    if (empty($message)) {
        $arError[] = GetMessage("SPAM_NO_MESS");
    } else {
        foreach ($message as $MID) {
            if (!CForumMessage::CanUserDeleteMessage($MID, $USER->GetUserGroupArray(), $USER->GetID(), $arAddParams["PERMISSION"])) {
                $arError[] = GetMessage("SPAM_NO_PERMS") . "(MID=" . $MID . ")";
            } else {
                $arMessage = CForumMessage::GetByID($MID, array("FILTER" => "N"));
                if (CModule::IncludeModule("mail")) {
                    CMailMessage::MarkAsSpam($arMessage["XML_ID"], "Y");
                }
                if (CForumMessage::Delete($MID)) {
                    $arOK[] = GetMessage("SPAM_OK") . "(MID=" . $MID . ")";
                    CForumEventLog::Log("message", "spam", $MID, print_r($arMessage, true));
                } else {
                    $arError[] = GetMessage("SPAM_NO") . "(MID=" . $MID . ")";
                }
            }
        }
    }
    if (!empty($arError)) {
        $strErrorMessage .= implode(".\n", $arError) . ".\n";
    }
    if (!empty($arOK)) {
        $strOKMessage .= implode(".\n", $arOK) . ".\n";
    }
    return empty($arError) ? true : false;
}
Exemplo n.º 9
0
     } else {
         $str .= '<div class="mail-message-unread-notspam adm-list-mail-icon" title="' . GetMessage("MAIL_MSG_ADM_NOTREAD_NOTSPAM") . '"></div>';
     }
 } else {
     if ($arRes['NEW_MESSAGE'] != "Y") {
         $str .= '<div class="mail-message adm-list-mail-icon" title="' . GetMessage("MAIL_MSG_ADM_READ") . '"></div>';
     } else {
         $str .= '<div class="mail-message-unread adm-list-mail-icon" title="' . GetMessage("MAIL_MSG_ADM_NOTREAD") . '"></div>';
     }
 }
 $str .= '<a href="mail_message_view.php?lang=' . LANG . '&amp;ID=' . $arRes['ID'] . '">' . (strlen($arRes['SUBJECT']) > 0 ? $arRes['SUBJECT'] : GetMessage("MAIL_MSG_ADM_NOSUBJ"));
 $row->AddViewField("SUBJECT", $str);
 $str = $arRes['MAILBOX_NAME'] . ' [<a title="' . GetMessage("MAIL_MSG_ADM_CHANGE_MBOX") . '" href="mail_mailbox_edit.php?ID=' . $arRes['MAILBOX_ID'] . '&lang=' . LANG . '">' . $arRes['MAILBOX_ID'] . '</a>]';
 $row->AddViewField("MAILBOX_NAME", $str);
 $row->AddViewField("MESSAGE_SIZE", CFile::FormatSize($arRes['MESSAGE_SIZE']));
 $arRes["SPAM_RATING"] = CMailMessage::GetSpamRating($arRes['ID'], $arRes);
 $str = Round($arRes["SPAM_RATING"], 2) . "%";
 $row->AddViewField("SPAM_RATING", $str);
 $arActions = array();
 $arActions[] = array("DEFAULT" => "Y", "TEXT" => GetMessage("MAIL_MSG_ADM_VIEW"), "ACTION" => $lAdmin->ActionRedirect('mail_message_view.php?lang=' . LANG . '&ID=' . $arRes['ID']));
 if ($MOD_RIGHT == "W") {
     $arActions[] = array("SEPARATOR" => true);
     if ($arRes['SPAM'] != "Y") {
         $arActions[] = array("TEXT" => GetMessage("MAIL_MSG_ADM_PROC_ACT_SPAM"), "ACTION" => $lAdmin->ActionAjaxReload($APPLICATION->GetCurPage() . "?action=mark_as_spam&ID=" . $arRes['ID'] . "&lang=" . LANG . "&" . bitrix_sessid_get()));
     }
     if ($arRes['SPAM'] != "N") {
         $arActions[] = array("TEXT" => GetMessage("MAIL_MSG_ADM_PROC_ACT_NOTSPAM"), "ACTION" => $lAdmin->ActionAjaxReload($APPLICATION->GetCurPage() . "?action=mark_as_notspam&ID=" . $arRes['ID'] . "&lang=" . LANG . "&" . bitrix_sessid_get()));
     }
     if ($arRes['NEW_MESSAGE'] == "Y") {
         $arActions[] = array("TEXT" => GetMessage("MAIL_MSG_ADM_PROC_ACT_READ"), "ACTION" => $lAdmin->ActionAjaxReload($APPLICATION->GetCurPage() . "?action=mark_as_read&ID=" . $arRes['ID'] . "&lang=" . LANG . "&" . bitrix_sessid_get()));
     } else {