function checkNoSpam($val) { return !bx_is_spam($val); }
function _isSpam($s) { return bx_is_spam($s); }
/** * Function will send the compose message ; * * @param : $sMessageSubject (string) - message's subject ; * @param : $sMessageBody (string) - message's body ; * @param : $vRecipientID (variant)- message's recipient ID or NickName; * @param : $aComposeSettings (array) - contain all needed settings for compose message ; * [ send_copy ] (bolean) - allow to send message to phisical recipient's email ; * [ notification ] (boolean) - allow to send notification to the recipient's email ; * [ send_copy_to_me ] (boolean) - allow to send message to phisical sender's email ; * @return : signaling information with Html ; */ function sendMessage($sMessageSubject, $sMessageBody, $vRecipientID, &$aComposeSettings, $isSimulateSending = false) { $sMessageSubject = process_db_input($sMessageSubject, BX_TAGS_STRIP); $sMessageSubjectCopy = $GLOBALS['MySQL']->unescape($sMessageSubject); $sMessageBody = process_db_input($sMessageBody, BX_TAGS_VALIDATE); $sCopyMessage = $GLOBALS['MySQL']->unescape($sMessageBody); if (!$isSimulateSending && (!$sMessageSubject || !$sMessageBody)) { $this->iSendMessageStatusCode = BX_MAILBOX_SEND_FAILED; return MsgBox(_t('_please_fill_next_fields_first')); } // init some needed variables ; $sReturnMessage = null; $sComposeUrl = BX_DOL_URL_ROOT . 'mail.php?mode=compose'; // try to define member's ID ; $iRecipientID = (int) getId($vRecipientID); if (!$iRecipientID) { $this->iSendMessageStatusCode = BX_MAILBOX_SEND_UNKNOWN_RECIPIENT; return MsgBox(_t('_Profile not found')); } $aRecipientInfo = getProfileInfo($iRecipientID); $oEmailTemplate = new BxDolEmailTemplates(); $bAllowToSend = true; $this->iSendMessageStatusCode = BX_MAILBOX_SEND_FAILED; // ** check permission for recipient member ; // Check if member is blocked ; $sQuery = "\n SELECT\n `ID`, `Profile`\n FROM\n `sys_block_list`\n WHERE\n `Profile` = {$this->aMailBoxSettings['member_id']}\n AND\n `ID` = '{$iRecipientID}'\n "; if (!isAdmin($this->aMailBoxSettings['member_id']) && db_arr($sQuery)) { $sReturnMessage = MsgBox(_t('_FAILED_TO_SEND_MESSAGE_BLOCK')); $this->iSendMessageStatusCode = BX_MAILBOX_SEND_BLOCKED; $bAllowToSend = false; } // antispam check ; $sQuery = "\n SELECT\n `ID`\n FROM\n `sys_messages`\n WHERE\n `Sender` = {$this->aMailBoxSettings['member_id']}\n AND\n date_add(`Date`, INTERVAL {$this->iWaitMinutes} MINUTE) > Now()\n "; if (db_arr($sQuery)) { $sReturnMessage = MsgBox(_t('_You have to wait for PERIOD minutes before you can write another message!', $this->iWaitMinutes, $sComposeUrl)); $this->iSendMessageStatusCode = BX_MAILBOX_SEND_WAIT; $bAllowToSend = false; } // additional antispam check ; if (bx_is_spam($sCopyMessage)) { $sReturnMessage = MsgBox(sprintf(_t("_sys_spam_detected"), BX_DOL_URL_ROOT . 'contact.php')); $this->iSendMessageStatusCode = BX_MAILBOX_SEND_FAILED; $bAllowToSend = false; } // check if member not active ; if ($aRecipientInfo['Status'] != 'Active') { $sReturnMessage = MsgBox(_t('_FAILED_TO_SEND_MESSAGE_NOT_ACTIVE', $sComposeUrl)); $this->iSendMessageStatusCode = BX_MAILBOX_SEND_RECIPIENT_NOT_ACTIVE; $bAllowToSend = false; } // chek membership level; if (!$this->isSendMessageAlowed($this->aMailBoxSettings['member_id'], $isSimulateSending ? false : true)) { $sReturnMessage = MsgBox(_t('_FAILED_TO_SEND_MESSAGE_MEMBERSHIP_DISALLOW')); $this->iSendMessageStatusCode = BX_MAILBOX_SEND_FAILED_MEMBERSHIP_DISALLOW; $bAllowToSend = false; } // ** allow to send message ; if (!$isSimulateSending && $bAllowToSend) { $sQuery = "\n INSERT INTO\n `sys_messages`\n SET\n `Sender` = {$this->aMailBoxSettings['member_id']},\n `Recipient` = {$iRecipientID},\n `Subject` = '{$sMessageSubject}',\n `Text` = '{$sMessageBody}',\n `Date` = NOW(),\n `New` = '1',\n `Type` = 'letter'\n "; if (db_res($sQuery)) { $sReturnMessage = MsgBox(_t('_MESSAGE_SENT', $sComposeUrl, getProfileLink($iRecipientID), $aRecipientInfo['NickName'])); $this->iSendMessageStatusCode = BX_MAILBOX_SEND_SUCCESS; //--- create system event bx_import('BxDolAlerts'); $aAlertData = array('msg_id' => db_last_id(), 'subject' => $sMessageSubjectCopy, 'body' => $sCopyMessage, 'send_copy' => $aComposeSettings['send_copy'], 'notification' => $aComposeSettings['notification'], 'send_copy_to_me' => $aComposeSettings['send_copy_to_me']); $oZ = new BxDolAlerts('profile', 'send_mail_internal', $this->aMailBoxSettings['member_id'], $iRecipientID, $aAlertData); $oZ->alert(); // ** check the additional parameters ; // send message to phisical recipient's email ; if ($aComposeSettings['send_copy']) { $aTemplate = $oEmailTemplate->getTemplate('t_Message', $iRecipientID); $aPlus = array(); $aPlus['MessageText'] = replace_full_uris($sCopyMessage); $aPlus['ProfileReference'] = getNickName($this->aMailBoxSettings['member_id']); $aPlus['ProfileUrl'] = getProfileLink($this->aMailBoxSettings['member_id']); sendMail($aRecipientInfo['Email'], $sMessageSubjectCopy, $aTemplate['Body'], $iRecipientID, $aPlus); } // send notification to the recipient's email ; if ($aComposeSettings['notification']) { $aTemplate = $oEmailTemplate->getTemplate('t_Compose', $iRecipientID); $aPlus['ProfileReference'] = getNickName($this->aMailBoxSettings['member_id']); $aPlus['ProfileUrl'] = getProfileLink($this->aMailBoxSettings['member_id']); sendMail($aRecipientInfo['Email'], $aTemplate['Subject'], $aTemplate['Body'], $iRecipientID, $aPlus); } // allow to send message to phisical sender's email; if ($aComposeSettings['send_copy_to_me']) { $aSenderInfo = getProfileInfo($this->aMailBoxSettings['member_id']); $aTemplate = $oEmailTemplate->getTemplate('t_MessageCopy', $this->aMailBoxSettings['member_id']); $aPlus['your subject here'] = $sMessageSubjectCopy; $aPlus['your message here'] = replace_full_uris($sCopyMessage); sendMail($aSenderInfo['Email'], $aTemplate['Subject'], $aTemplate['Body'], $this->aMailBoxSettings['member_id'], $aPlus); } } else { $sReturnMessage = MsgBox(_t('_FAILED_TO_SEND_MESSAGE')); $this->iSendMessageStatusCode = BX_MAILBOX_SEND_FAILED; } } return $sReturnMessage; }
/** * post new topic * * @param $p _post array */ function postNewTopicXML($p) { $sAccessDeniedCode = <<<EOF <html> <body> <script language="javascript" type="text/javascript"> if (window.parent.document.getElementById('tinyEditor')) window.parent.tinyMCE.execCommand('mceRemoveEditor', false, 'tinyEditor'); window.parent.document.f.accessDenied(); </script> </body> </html> EOF; $f = $this->fdb->getForum((int) $p['forum']); if (!$this->_checkUserPerm('', $f['forum_type'], 'post', (int) $p['forum']) || bx_is_spam($p['topic_text'])) { return $sAccessDeniedCode; } if ($p['topic_sticky'] == 'on' && !$this->_checkUserPerm('', '', 'sticky', (int) $p['forum'])) { return $sAccessDeniedCode; } // post mesage here $user = $this->_getLoginUserName(); prepare_to_db($p['topic_subject'], -1); prepare_to_db($p['topic_text'], 1); $topic_uri = $this->uriGenerate($p['topic_subject'], TF_FORUM_TOPIC, 'topic_uri'); $post_id = $this->fdb->newTopic((int) $p['forum'], $p['topic_subject'], $p['topic_text'], $p['topic_sticky'] == 'on', $user, $topic_uri); $this->_handleSignature($_POST, $user); $isUploadSuccess = $this->_handleUpload($p, $post_id); if (is_callable($this->onNewTopic)) { call_user_func_array($this->onNewTopic, array((int) $p['forum'], $p['topic_subject'], $p['topic_text'], $p['topic_sticky'] == 'on', $user, $topic_uri, $post_id)); } return <<<EOF <html> <body> <script language="javascript" type="text/javascript"> if (!{$isUploadSuccess}) window.parent.alert ('[L[Some or all files upload failed]]'); if (window.parent.document.getElementById('tinyEditor')) window.parent.tinyMCE.execCommand('mceRemoveEditor', false, 'tinyEditor'); window.parent.document.f.selectTopic('{$topic_uri}'); </script> </body> </html> EOF; }