protected function finish() { bx_alert('system', 'pruning', 0); if (!($sOutput = ob_get_clean())) { return; } $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('t_Pruning', array('pruning_output' => $sOutput, 'site_title' => getParam('site_title')), 0, 0); if ($aTemplate) { sendMail(getParam('site_email'), $aTemplate['Subject'], $aTemplate['Body'], 0, array(), BX_EMAIL_NOTIFY); } }
/** * Check text for spam. * First it check if IP is whitelisted(or under cron execution or user is admin) - for whitelisted IPs check for spam isn't performed, * then it checks URLs found in text for DNSURI black lists (@see BxAntispamDNSURIBlacklists), * then it checks text in Akismet service (@see BxAntispamAkismet). * It can send report if spam is found or tries to inform caller to block the content (depending on configuration). * * @param $sContent content to check for spam * @param $sIp IP address of content poster * @param $isStripSlashes slashes parameter: * BX_SLASHES_AUTO - automatically detect magic_quotes_gpc setting * BX_SLASHES_NO_ACTION - do not perform any action with slashes * @return true if spam detected and content shouln't be recorded, false if content should be processed as usual. */ public function serviceIsSpam($sContent, $sIp = '', $isStripSlashes = BX_SLASHES_AUTO) { if (defined('BX_DOL_CRON_EXECUTE') || isAdmin()) { return false; } if ($this->serviceIsIpWhitelisted($sIp)) { return false; } if (get_magic_quotes_gpc() && $isStripSlashes == BX_SLASHES_AUTO) { $sContent = stripslashes($sContent); } $bRet = false; if ('on' == $this->_oConfig->getAntispamOption('uridnsbl_enable')) { $oDNSURIBlacklists = bx_instance('BxAntispamDNSURIBlacklists', array(), $this->_aModule); if ($oDNSURIBlacklists->isSpam($sContent)) { $oDNSURIBlacklists->onPositiveDetection($sContent); $bRet = true; } } if (!$bRet && 'on' == $this->_oConfig->getAntispamOption('akismet_enable')) { $oAkismet = bx_instance('BxAntispamAkismet', array(), $this->_aModule); if ($oAkismet->isSpam($sContent)) { $oAkismet->onPositiveDetection($sContent); $bRet = true; } } if ($bRet && 'on' == $this->_oConfig->getAntispamOption('antispam_report')) { $oProfile = BxDolProfile::getInstance(); $aPlus = array('SpammerUrl' => $oProfile->getUrl(), 'SpammerNickName' => $oProfile->getDisplayName(), 'Page' => htmlspecialchars_adv($_SERVER['PHP_SELF']), 'Get' => print_r($_GET, true), 'Post' => print_r($_POST, true), 'SpamContent' => htmlspecialchars_adv($sContent)); bx_import('BxDolEmailTemplates'); $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('bx_antispam_spam_report', $aPlus); if (!$aTemplate) { trigger_error('Email template or translation missing: bx_antispam_spam_report', E_USER_ERROR); } sendMail(getParam('site_email'), $aTemplate['Subject'], $aTemplate['Body']); } if ($bRet && 'on' == $this->_oConfig->getAntispamOption('antispam_block')) { return true; } return false; }
/** * SERVICE METHODS */ public function serviceGetBlockForm() { $aDefaultFields = array('name', 'email', 'subject', 'body', 'do_submit'); $mixedAllowed = $this->isAllowedContact(); if ($mixedAllowed !== true) { return array('content' => MsgBox($mixedAllowed)); } $sResult = ''; bx_import('BxDolForm'); $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject('form_contact'), $this->_oConfig->getObject('form_display_contact_send'), $this->_oTemplate); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $iId = $oForm->insert(array('uri' => $oForm->generateUri(), 'date' => time())); if ($iId !== false) { $sCustomFields = ''; $aCustomFields = array(); foreach ($oForm->aInputs as $aInput) { if (in_array($aInput['name'], $aDefaultFields)) { continue; } $aCustomFields[$aInput['name']] = bx_process_output($oForm->getCleanValue($aInput['name'])); $sCustomFields .= $aInput['caption'] . ': ' . $aCustomFields[$aInput['name']] . '<br />'; } $aTemplateKeys = array('SenderName' => bx_process_output($oForm->getCleanValue('name')), 'SenderEmail' => bx_process_output($oForm->getCleanValue('email')), 'MessageSubject' => bx_process_output($oForm->getCleanValue('subject')), 'MessageBody' => bx_process_output(nl2br($oForm->getCleanValue('body')), BX_DATA_TEXT_MULTILINE), 'CustomFields' => $sCustomFields); $aTemplateKeys = array_merge($aTemplateKeys, $aCustomFields); bx_import('BxDolEmailTemplates'); $aMessage = BxDolEmailTemplates::getInstance()->parseTemplate('bx_contact_contact_form_message', $aTemplateKeys); $sResult = ''; $sRecipientEmail = $this->_oConfig->getEmail(); if (sendMail($sRecipientEmail, $aMessage['Subject'], $aMessage['Body'], 0, array(), BX_EMAIL_SYSTEM)) { $this->onContact(); $sResult = '_ADM_PROFILE_SEND_MSG'; } else { $sResult = '_Email sent failed'; } $sResult = MsgBox(_t($sResult)); } } return array('content' => $sResult . $oForm->getCode()); }
/** * Check all pending for uninstallation modules and uninstall them if no pending for deletion files are found */ public static function checkModulesPendingUninstall() { $a = BxDolModuleQuery::getInstance()->getModules(); foreach ($a as $aModule) { // after we make sure that all pending for deletion files are deleted if (!$aModule['pending_uninstall'] || BxDolStorage::isQueuedFilesForDeletion($aModule['name'])) { continue; } // remove pending uninstall flag self::setModulePendingUninstall($aModule['uri'], false); // perform uninstallation $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aModule['path'], 'uninstall'); // send email nofitication $aTemplateKeys = array('Module' => $aModule['title'], 'Result' => _t('_Success'), 'Message' => ''); if ($aResult['code'] > 0) { $aTemplateKeys['Result'] = _t('_Failed'); $aTemplateKeys['Message'] = $aResult['message']; } $aMessage = BxDolEmailTemplates::getInstance()->parseTemplate('t_DelayedModuleUninstall', $aTemplateKeys); sendMail(getParam('site_email'), $aMessage['Subject'], $aMessage['Body'], 0, array(), BX_EMAIL_SYSTEM); } }
protected function _sendNotificationEmail($iCmtId, $iCmtParentId) { $aCmt = $this->getCommentRow($iCmtId); $aCmtParent = $this->getCommentRow($iCmtParentId); if (empty($aCmt) || !is_array($aCmt) || empty($aCmtParent) || !is_array($aCmtParent) || (int) $aCmt['cmt_author_id'] == (int) $aCmtParent['cmt_author_id']) { return; } $oProfile = $this->_getAuthorObject($aCmtParent['cmt_author_id']); if ($oProfile instanceof BxDolProfileUndefined) { return; } $iAccount = $oProfile->getAccountId(); $aAccount = BxDolAccount::getInstance($iAccount)->getInfo(); $aPlus = array(); $aPlus['reply_text'] = bx_process_output($aCmt['cmt_text']); $aPlus['comment_url'] = sprintf('%scmts.php?sys=%s&id=%d&cmt_id=%d', BX_DOL_URL_ROOT, $this->_sSystem, $this->_iId, $iCmtParentId); $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('t_CommentReplied', $aPlus); return $aTemplate && sendMail($aAccount['email'], $aTemplate['Subject'], $aTemplate['Body']); }
function getExpirationLetter($iProfileId, $sLevelName, $iLevelExpireDays) { $iProfileId = (int) $iProfileId; if (!$iProfileId) { return false; } $oProfileQuery = BxDolProfileQuery::getInstance(); $sProfileEmail = $oProfileQuery->getEmailById($iProfileId); $aPlus = array('membership_name' => $sLevelName, 'expire_days' => $iLevelExpireDays); $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('t_MemExpiration', $aPlus, 0, $iProfileId); $iResult = $aTemplate && sendMail($sProfileEmail, $aTemplate['Subject'], $aTemplate['Body'], $iProfileId, $aPlus); return !empty($iResult); }
/** * Reset password procedure */ public function resetPassword() { $sKey = bx_process_input(bx_get('key')); // get link to forgot password page for error message $sUrlForgotPassword = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=forgot-password'); // check if key exists $oKey = BxDolKey::getInstance(); if (!$oKey || !$oKey->isKeyExists($sKey)) { return _t("_sys_txt_reset_pasword_error_occured", $sUrlForgotPassword); } // check if key data exists $aData = $oKey->getKeyData($sKey); if (!isset($aData['email'])) { return _t("_sys_txt_reset_pasword_error_occured", $sUrlForgotPassword); } // check if account with such email exists $iAccountId = $this->_oAccountQuery->getIdByEmail($aData['email']); if (!$iAccountId) { return _t("_sys_txt_reset_pasword_error_occured", $sUrlForgotPassword); } // generate new password $sPassword = $this->generateUserNewPwd($iAccountId); // remove key $oKey->removeKey($sKey); // send email with new password and display result message $aPlus = array('password' => $sPassword); $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('t_PasswordReset', $aPlus, $iAccountId); if ($aTemplate && sendMail($aData['email'], $aTemplate['Subject'], $aTemplate['Body'], 0, $aPlus, BX_EMAIL_SYSTEM)) { return _t("_sys_txt_reset_pasword_email_sent", $sPassword); } else { return _t("_sys_txt_reset_pasword_email_send_failed", $sPassword); } }
public function invite($sType, $sEmails, $sText, $mixedLimit = false, $oForm = null) { $iProfileId = $this->getProfileId(); $iAccountId = $this->getAccountId($iProfileId); $oKeys = BxDolKey::getInstance(); if (!$oKeys || !in_array($sType, array(BX_INV_TYPE_FROM_MEMBER, BX_INV_TYPE_FROM_SYSTEM))) { return false; } $iKeyLifetime = $this->_oConfig->getKeyLifetime(); $sEmailTemplate = ''; switch ($sType) { case BX_INV_TYPE_FROM_MEMBER: $sEmailTemplate = 'bx_invites_invite_form_message'; break; case BX_INV_TYPE_FROM_SYSTEM: $sEmailTemplate = 'bx_invites_invite_by_request_message'; break; } if (empty($oForm)) { $oForm = $this->getFormObjectInvite(); } $aMessage = BxDolEmailTemplates::getInstance()->parseTemplate($sEmailTemplate, array('text' => $sText), $iAccountId, $iProfileId); $iSent = 0; $iDate = time(); $aEmails = preg_split("/[\\s\n,;]+/", $sEmails); if (is_array($aEmails) && !empty($aEmails)) { foreach ($aEmails as $sEmail) { if ($mixedLimit !== false && (int) $mixedLimit <= 0) { break; } $sEmail = trim($sEmail); if (empty($sEmail)) { continue; } $sKey = $oKeys->getNewKey(false, $iKeyLifetime); if (sendMail($sEmail, $aMessage['Subject'], $aMessage['Body'], 0, array('join_url' => $this->getJoinLink($sKey)), BX_EMAIL_SYSTEM)) { $oForm->insert(array('account_id' => $iAccountId, 'profile_id' => $iProfileId, 'key' => $sKey, 'email' => $sEmail, 'date' => $iDate)); $this->onInvite($iAccountId, $iProfileId); $iSent += 1; if ($mixedLimit !== false) { $mixedLimit -= 1; } } } } return $iSent; }
/** * Send email function * * @param $sRecipientEmail - Email where email should be send * @param $sMailSubject - subject of the message * @param $sMailBody - Body of the message * @param $iRecipientID - ID of recipient profile * @param $aPlus - Array of additional information * @param $iEmailType - email message type: BX_EMAIL_SYSTEM, BX_EMAIL_NOTIFY or BX_EMAIL_MASS * @return true if message was send or false otherwise */ function sendMail($sRecipientEmail, $sMailSubject, $sMailBody, $iRecipientID = 0, $aPlus = array(), $iEmailType = BX_EMAIL_NOTIFY, $sEmailFlag = 'html', $isDisableAlert = false) { // make sure that recipient's email is valid and message isn't empty if (!$sMailBody || !$sRecipientEmail || preg_match('/\\(2\\)$/', $sRecipientEmail)) { return false; } // get recipient account bx_import('BxDolAccount'); $oAccount = BxDolAccount::getInstance($sRecipientEmail); $aAccountInfo = $oAccount ? $oAccount->getInfo() : false; // don't send bulk emails if user didn't subscribed to site news or email is unconfirmed if ($aAccountInfo && BX_EMAIL_MASS == $iEmailType && (!$aAccountInfo['email_confirmed'] || !$aAccountInfo['receive_news'])) { return false; } // don't send email notifications if user didn't subscribed to notifications or email is unconfirmed if ($aAccountInfo && BX_EMAIL_NOTIFY == $iEmailType && (!$aAccountInfo['email_confirmed'] || !$aAccountInfo['receive_updates'])) { return false; } // if profile id is provided - get profile's info $aRecipientInfo = false; if ($iRecipientID) { bx_import('BxDolProfile'); $oProfile = BxDolProfile::getInstance($iRecipientID); if ($oProfile) { $aRecipientInfo = $oProfile->getInfo(); } } // get site vars $sEmailNotify = getParam('site_email_notify'); $sSiteTitle = getParam('site_title'); // add unsubscribe link if (empty($aPlus['unsubscribe'])) { $aPlus['unsubscribe'] = ''; if ($oAccount && (BX_EMAIL_MASS == $iEmailType || BX_EMAIL_NOTIFY == $iEmailType)) { $aPlus['unsubscribe'] = ($sLink = $oAccount->getUnsubscribeLink($iEmailType)) ? '<a href="' . BX_DOL_URL_ROOT . $sLink . '">' . _t('_sys_et_txt_unsubscribe') . '</a>' : ''; } } // parse template if ($aPlus || $iRecipientID) { if (!is_array($aPlus)) { $aPlus = array(); } bx_import('BxDolEmailTemplates'); $oEmailTemplates = BxDolEmailTemplates::getInstance(); $sMailSubject = $oEmailTemplates->parseContent($sMailSubject, $aPlus, $iRecipientID); $sMailBody = $oEmailTemplates->parseContent($sMailBody, $aPlus, $iRecipientID); } // email message headers $sMailHeader = "From: =?UTF-8?B?" . base64_encode($sSiteTitle) . "?= <{$sEmailNotify}>"; $sMailParameters = "-f{$sEmailNotify}"; $sMailSubject = '=?UTF-8?B?' . base64_encode($sMailSubject) . '?='; $sMailHeader = "MIME-Version: 1.0\r\n" . $sMailHeader; // build data for alert handler $bResult = null; $aAlert = array('email' => $sRecipientEmail, 'subject' => $sMailSubject, 'body' => $sMailBody, 'header' => $sMailHeader, 'params' => $sMailParameters, 'recipient' => $aRecipientInfo, 'html' => 'html' == $sEmailFlag ? true : false, 'override_result' => &$bResult); // system alert if (!$isDisableAlert) { bx_alert('system', 'before_send_mail', isset($aRecipientInfo['ID']) ? $aRecipientInfo['ID'] : 0, '', $aAlert); if ($bResult !== null) { return $bResult; } unset($aAlert['override_result']); } // send mail if ('html' == $sEmailFlag) { $sMailHeader = "Content-type: text/html; charset=UTF-8\r\n" . $sMailHeader; $iSendingResult = mail($sRecipientEmail, $sMailSubject, $sMailBody, $sMailHeader, $sMailParameters); } else { $sMailHeader = "Content-type: text/plain; charset=UTF-8\r\n" . $sMailHeader; $sMailBody = html2txt($sMailBody); $iSendingResult = mail($sRecipientEmail, $sMailSubject, html2txt($sMailBody), $sMailHeader, $sMailParameters); } // system alert if (!$isDisableAlert) { bx_alert('system', 'send_mail', isset($aRecipientInfo['ID']) ? $aRecipientInfo['ID'] : 0, '', $aAlert); } return $iSendingResult; }
/** * Send "confirmation" email */ public function sendConfirmationEmail($iAccountId = false) { $sEmail = $this->getEmail($iAccountId); bx_import('BxDolKey'); $oKey = BxDolKey::getInstance(); $sConfirmationCode = $oKey->getNewKey(array('account_id' => $iAccountId)); bx_import('BxDolPermalinks'); $sConfirmationLink = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=confirm-email') . '&code=' . urlencode($sConfirmationCode); $aPlus = array(); $aPlus['email'] = $sEmail; $aPlus['conf_code'] = $sConfirmationCode; $aPlus['conf_link'] = $sConfirmationLink; $aPlus['conf_form_link'] = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=confirm-email'); bx_import('BxDolEmailTemplates'); $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('t_Confirmation', $aPlus); return $aTemplate && sendMail($sEmail, $aTemplate['Subject'], $aTemplate['Body'], 0, array(), BX_EMAIL_SYSTEM); }
public function onPaymentReceived(&$aData, $fAmount) { $sProfileId = $aData['recurring_payment_id']; $aAccount = $this->_oModule->_oDb->getAccount(array('type' => 'profile_id', 'value' => $sProfileId)); if (!empty($aAccount) && is_array($aAccount)) { $sTransaction = bx_process_input($aData['txn_id']); $iWhen = strtotime($aData['payment_date']); $iPaidUntil = strtotime($aData['next_payment_date']); $sActStatus = $sPmtType = ''; if ($aData['period_type'] == BX_SITES_PP_PERIOD_TRIAL) { $sActStatus = BX_SITES_ACCOUNT_STATUS_TRIAL; $sPmtType = BX_SITES_TRANSACTION_TRIAL; $this->_oModule->_oDb->updateOwner(array('trials' => $aAccount['owner_trials'] + 1), array('id' => $aAccount['owner_id'])); } else { if ($aData['period_type'] == BX_SITES_PP_PERIOD_REGULAR) { $sActStatus = BX_SITES_ACCOUNT_STATUS_ACTIVE; $sPmtType = BX_SITES_TRANSACTION_REGULAR; } } $this->_oModule->_oDb->insertPaymentHistory(array('account_id' => $aAccount['id'], 'type' => $sPmtType, 'transaction' => $sTransaction, 'amount' => $fAmount, 'when' => $iWhen, 'when_next' => $iPaidUntil)); $this->_oModule->_oDb->updateAccount(array('paid' => $iPaidUntil, 'status' => $sActStatus), array('id' => $aAccount['id'])); $aTemplate = array(); $sFirstName = bx_process_input($aData['first_name']); $sLastName = bx_process_input($aData['last_name']); /*--- Site was created and paid ---*/ if ($aAccount['status'] == BX_SITES_ACCOUNT_STATUS_PENDING && in_array($sActStatus, array(BX_SITES_ACCOUNT_STATUS_TRIAL, BX_SITES_ACCOUNT_STATUS_ACTIVE))) { bx_import('BxDolPermalinks'); $oPermalinks = BxDolPermalinks::getInstance(); bx_import('BxDolEmailTemplates'); $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('bx_sites_site_created_and_paid', array('RealName' => $sFirstName . (!empty($sFirstName) && !empty($sLastName) ? ' ' . $sLastName : ''), 'Domain' => $this->_oModule->getDomain($aAccount['domain']), 'Email' => $aAccount['email'], 'Amount' => $fAmount . ' ' . $this->_oModule->_oConfig->getCurrencyCode(), 'Status' => _t('_bx_sites_txt_status_' . $sActStatus), 'NextPaymentDate' => bx_time_js($iPaidUntil), 'DetailsFormUrl' => BX_DOL_URL_ROOT . $oPermalinks->permalink('page.php?i=site-edit&sid=' . $aAccount['pd_profile_sid']))); } else { bx_import('BxDolEmailTemplates'); $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('bx_sites_payment_received', array('RealName' => $sFirstName . (!empty($sFirstName) && !empty($sLastName) ? ' ' . $sLastName : ''), 'Amount' => $fAmount . ' ' . $this->_oModule->_oConfig->getCurrencyCode(), 'NextPaymentDate' => bx_time_js($iPaidUntil))); } if (!empty($aTemplate)) { sendMail($aAccount['email'], $aTemplate['Subject'], $aTemplate['Body']); $sLog = "---\n"; $sLog .= "--- Send Email Notification: {date}\n"; $sLog .= "--- Email: " . $aAccount['email'] . "\n"; $sLog .= "--- Subject: " . $aTemplate['Subject'] . "\n"; $sLog .= "--- Body: " . $aTemplate['Body'] . "\n"; $sLog .= "---\n"; $this->_logEmail($sLog); } } }