function onPostReply($aTopic, $sPostText, $sUser) { $oProfile = new BxDolProfile($sUser); $iProfileId = $oProfile->getID(); if (BX_ORCA_INTEGRATION == 'dolphin' && !isAdmin($iProfileId)) { defineForumActions(); $iActionId = BX_FORUM_PUBLIC_POST; if (isset($aTopic['forum_type']) && 'private' == $aTopic['forum_type']) { $iActionId = BX_FORUM_PRIVATE_POST; } checkAction($iProfileId, $iActionId, true); // perform action } $aPlusOriginal = array('PosterUrl' => $iProfileId ? getProfileLink($iProfileId) : 'javascript:void(0);', 'PosterNickName' => $iProfileId ? getNickName($iProfileId) : $sUser, 'TopicTitle' => $aTopic['topic_title'], 'ReplyText' => $sPostText); $oEmailTemplate = new BxDolEmailTemplates(); $aTemplate = $oEmailTemplate->getTemplate('bx_forum_notifier'); $fdb = new DbForum(); $a = $fdb->getSubscribersToTopic($aTopic['topic_id']); foreach ($a as $r) { if ($r['user'] == $sUser) { continue; } $oRecipient = new BxDolProfile($r['user']); $aRecipient = getProfileInfo($oRecipient->_iProfileID); $aPlus = array_merge(array('Recipient' => ' ' . getNickName($aRecipient['ID'])), $aPlusOriginal); sendMail(trim($aRecipient['Email']), $aTemplate['Subject'], $aTemplate['Body'], '', $aPlus); } forumAlert('reply', $aTopic['topic_id'], $iProfileId); }
function _checkProfileMatch($iProfileId, $sAction) { $aProfile = getProfileInfo($iProfileId); if ($aProfile['Status'] == 'Active' && ($aProfile['UpdateMatch'] || $sAction == 'join')) { $oDb = new BxDolDb(); // clear field "UpdateMatch" $oDb->query("UPDATE `Profiles` SET `UpdateMatch` = 0 WHERE `ID`= {$iProfileId}"); // clear cache $oDb->query("DELETE FROM `sys_profiles_match`"); // get send mails $aSendMails = $oDb->getRow("SELECT `profiles_match` FROM `sys_profiles_match_mails` WHERE `profile_id` = {$iProfileId}"); $aSend = !empty($aSendMails) ? unserialize($aSendMails['profiles_match']) : array(); $aProfiles = getMatchProfiles($iProfileId); foreach ($aProfiles as $iProfId) { if (!isset($aSend[(int) $iProfId])) { $oEmailTemplate = new BxDolEmailTemplates(); $aMessage = $oEmailTemplate->parseTemplate('t_CupidMail', array('StrID' => $iProfId, 'MatchProfileLink' => getProfileLink($iProfileId)), $iProfId); $aProfile = getProfileInfo($iProfId); if (!empty($aProfile) && $aProfile['Status'] == 'Active') { $oDb->query("INSERT INTO `sys_sbs_queue`(`email`, `subject`, `body`) VALUES('" . $aProfile['Email'] . "', '" . process_db_input($aMessage['subject'], BX_TAGS_NO_ACTION, BX_SLASHES_NO_ACTION) . "', '" . process_db_input($aMessage['body'], BX_TAGS_NO_ACTION, BX_SLASHES_NO_ACTION) . "')"); } $aSend[(int) $iProfId] = 0; } } if (empty($aSendMails)) { $oDb->query("INSERT INTO `sys_profiles_match_mails`(`profile_id`, `profiles_match`) VALUES({$iProfileId}, '" . serialize($aSend) . "')"); } else { $oDb->query("UPDATE `sys_profiles_match_mails` SET `profiles_match` = '" . serialize($aSend) . "' WHERE `profile_id` = {$iProfileId}"); } } }
/** * send "tell a friend" email */ function SendTellFriend($iSenderID = 0) { global $profileID; $sRecipient = clear_xss($_POST['friends_emails']); $sSenderName = clear_xss($_POST['name']); $sSenderEmail = clear_xss($_POST['email']); if (strlen(trim($sRecipient)) <= 0) { return 0; } if (strlen(trim($sSenderEmail)) <= 0) { return 0; } $sLinkAdd = $iSenderID > 0 ? 'idFriend=' . $iSenderID : ''; $rEmailTemplate = new BxDolEmailTemplates(); if ($profileID) { $aTemplate = $rEmailTemplate->getTemplate('t_TellFriendProfile', $profileID); $Link = getProfileLink($profileID, $sLinkAdd); } else { $aTemplate = $rEmailTemplate->getTemplate('t_TellFriend'); $Link = BX_DOL_URL_ROOT; if (strlen($sLinkAdd) > 0) { $Link .= '?' . $sLinkAdd; } } $aPlus = array('Link' => $Link, 'FromName' => $sSenderName); return sendMail($sRecipient, $aTemplate['Subject'], $aTemplate['Body'], '', $aPlus); }
/** * send "tell a friend" email */ function SendTellFriend($iSenderID = 0) { global $profileID; $sSenderEmail = clear_xss(bx_get('sender_email')); if (strlen(trim($sSenderEmail)) <= 0) { return 0; } $sSenderName = clear_xss(bx_get('sender_name')); $sSenderLink = $iSenderID != 0 ? getProfileLink($iSenderID) : BX_DOL_URL_ROOT; $sRecipientEmail = clear_xss(bx_get('recipient_email')); if (strlen(trim($sRecipientEmail)) <= 0) { return 0; } $sLinkAdd = $iSenderID > 0 ? 'idFriend=' . $iSenderID : ''; $rEmailTemplate = new BxDolEmailTemplates(); if ($profileID) { $aTemplate = $rEmailTemplate->getTemplate('t_TellFriendProfile', getLoggedId()); $Link = getProfileLink($profileID, $sLinkAdd); } else { $aTemplate = $rEmailTemplate->getTemplate('t_TellFriend', getLoggedId()); $Link = BX_DOL_URL_ROOT; if (strlen($sLinkAdd) > 0) { $Link .= '?' . $sLinkAdd; } } return sendMail($sRecipientEmail, $aTemplate['Subject'], $aTemplate['Body'], '', array('Link' => $Link, 'SenderName' => $sSenderName, 'SenderLink' => $sSenderLink)); }
function processing() { $oModules = new BxDolModuleDb(); $aModules = $oModules->getModules(); $aResult = array(); foreach ($aModules as $aModule) { $aCheckInfo = BxDolInstallerUi::checkForUpdates($aModule); if (isset($aCheckInfo['version'])) { $aResult[] = _t('_adm_txt_modules_update_text_ext', $aModule['title'], $aCheckInfo['version']); } } if (empty($aResult)) { return; } $aAdmins = $GLOBALS['MySQL']->getAll("SELECT * FROM `Profiles` WHERE `Role`&" . BX_DOL_ROLE_ADMIN . "<>0 AND `EmailNotify`='1'"); if (empty($aAdmins)) { return; } $oEmailTemplate = new BxDolEmailTemplates(); $sMessage = implode('<br />', $aResult); foreach ($aAdmins as $aAdmin) { $aTemplate = $oEmailTemplate->getTemplate('t_ModulesUpdates', $aAdmin['ID']); sendMail($aAdmin['Email'], $aTemplate['Subject'], $aTemplate['Body'], $aAdmin['ID'], array('MessageText' => $sMessage)); } }
/** * page code function */ function PageCompPageMainCode($iID, $sConfCode) { global $site; $ID = (int) $iID; $ConfCode = clear_xss($sConfCode); $p_arr = getProfileInfo($ID); if (!$p_arr) { $_page['header'] = _t("_Error"); $_page['header_text'] = _t("_Profile Not found"); return MsgBox(_t('_Profile Not found Ex')); } $aCode = array('message_status' => '', 'message_info' => '', 'bx_if:form' => array('condition' => false, 'content' => array('form' => '')), 'bx_if:next' => array('condtion' => false, 'content' => array('next_url' => ''))); if ($p_arr['Status'] == 'Unconfirmed') { $ConfCodeReal = base64_encode(base64_encode(crypt($p_arr[Email], CRYPT_EXT_DES ? "secret_co" : "se"))); if (strcmp($ConfCode, $ConfCodeReal) != 0) { $aForm = array('form_attrs' => array('action' => BX_DOL_URL_ROOT . 'profile_activate.php', 'method' => 'post', 'name' => 'form_change_status'), 'inputs' => array('conf_id' => array('type' => 'hidden', 'name' => 'ConfID', 'value' => $ID), 'conf_code' => array('type' => 'text', 'name' => 'ConfCode', 'value' => '', 'caption' => _t("_Confirmation code")), 'submit' => array('type' => 'submit', 'name' => 'submit', 'value' => _t("_Submit")))); $oForm = new BxTemplFormView($aForm); $aCode['message_status'] = _t("_Profile activation failed"); $aCode['message_info'] = _t("_EMAIL_CONF_FAILED_EX"); $aCode['bx_if:form']['condition'] = true; $aCode['bx_if:form']['content']['form'] = $oForm->getCode(); } else { $aCode['bx_if:next']['condition'] = true; $aCode['bx_if:next']['content']['next_url'] = BX_DOL_URL_ROOT . 'member.php'; $send_act_mail = false; if (getParam('autoApproval_ifJoin') == 'on' && !(getParam('sys_dnsbl_enable') && 'approval' == getParam('sys_dnsbl_behaviour') && bx_is_ip_dns_blacklisted('', 'join'))) { $status = 'Active'; $send_act_mail = true; $aCode['message_info'] = _t("_PROFILE_CONFIRM"); } else { $status = 'Approval'; $aCode['message_info'] = _t("_EMAIL_CONF_SUCCEEDED", $site['title']); } $update = bx_admin_profile_change_status($ID, $status, $send_act_mail); // Promotional membership if (getParam('enable_promotion_membership') == 'on') { $memership_days = getParam('promotion_membership_days'); setMembership($p_arr['ID'], MEMBERSHIP_ID_PROMOTION, $memership_days, true); } // check couple profile; if ($p_arr['Couple']) { $update = bx_admin_profile_change_status($p_arr['Couple'], $status); //Promotional membership if (getParam('enable_promotion_membership') == 'on') { $memership_days = getParam('promotion_membership_days'); setMembership($p_arr['Couple'], MEMBERSHIP_ID_PROMOTION, $memership_days, true); } } if (getParam('newusernotify')) { $oEmailTemplates = new BxDolEmailTemplates(); $aTemplate = $oEmailTemplates->getTemplate('t_UserConfirmed', $p_arr['ID']); sendMail($site['email_notify'], $aTemplate['Subject'], $aTemplate['Body'], $p_arr['ID']); } } } else { $aCode['message_info'] = _t('_ALREADY_ACTIVATED'); } return $GLOBALS['oSysTemplate']->parseHtmlByName('profile_activate.html', $aCode); }
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); } }
function onPostReply($aTopic, $sPostText, $sUser) { $oProfile = new BxDolProfile($sUser); $aPlusOriginal = array('PosterUrl' => $oProfile->_iProfileID ? getProfileLink($oProfile->_iProfileID) : 'javascript:void(0);', 'PosterNickName' => $sUser, 'TopicTitle' => $aTopic['topic_title'], 'ReplyText' => $sPostText); $oEmailTemplate = new BxDolEmailTemplates(); $aTemplate = $oEmailTemplate->getTemplate('bx_forum_notifier'); $fdb = new DbForum(); $a = $fdb->getSubscribersToTopic($aTopic['topic_id']); foreach ($a as $r) { if ($r['user'] == $sUser) { continue; } $oRecipient = new BxDolProfile($r['user']); $aRecipient = getProfileInfo($oRecipient->_iProfileID); $aPlus = array_merge(array('Recipient' => ' ' . $aRecipient['NickName']), $aPlusOriginal); sendMail(trim($aRecipient['Email']), $aTemplate['Subject'], $aTemplate['Body'], '', $aPlus); } $oAlert = new BxDolAlerts('bx_forum', 'reply', $aTopic['topic_id']); $oAlert->alert(); }
/** * 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); } }
/** * 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); } }
/** * Send virtual kiss */ function MemberSendVKiss($member, $recipient, $isCheckVisitorGreeting = true) { global $logged; // Check if recipient is active if ('Active' != $recipient['Status']) { return 7; } // block members if ($recipient['ID'] && $member['ID'] && isBlocked((int) $recipient['ID'], (int) $member['ID'])) { return 24; } // Get sender info $sender = getProfileInfo($member['ID']); // Send email notification $rEmailTemplate = new BxDolEmailTemplates(); if ($logged['member'] || !$isCheckVisitorGreeting) { $aTemplate = $rEmailTemplate->getTemplate('t_VKiss', $_COOKIE['memberID']); } else { $aTemplate = $rEmailTemplate->getTemplate('t_VKiss_visitor'); } $sConfCode = urlencode(base64_encode(base64_encode(crypt($recipient['ID'], CRYPT_EXT_DES ? "vkiss_sec" : "vk")))); // parse the email template ; $sProfileLink = $sender ? '<a href="' . getProfileLink($member['ID']) . '">' . getNickName($sender['ID']) . '</a>' : '<b>' . _t("_Visitor") . '</b>'; $sKissLink = $sender ? '<a href="' . BX_DOL_URL_ROOT . 'greet.php?fullpage=1&sendto=' . $member['ID'] . '&from=' . $recipient['ID'] . '&ConfCode=' . $sConfCode . '">' . BX_DOL_URL_ROOT . 'greet.php?sendto=' . $member['ID'] . '&from=' . $recipient['ID'] . '&ConfCode=' . $sConfCode . '</a>' : '<a href="' . BX_DOL_URL_ROOT . 'communicator.php">' . BX_DOL_URL_ROOT . 'communicator.php</a>'; $aRepl = array('<ConfCode>' => $sConfCode, '<ProfileReference>' => $sProfileLink, '<VKissLink>' => $sKissLink, '<RealName>' => getNickName($recipient['ID']), '<SiteName>' => BX_DOL_URL_ROOT); $aTemplate['Body'] = str_replace(array_keys($aRepl), array_values($aRepl), $aTemplate['Body']); $mail_ret = sendMail($recipient['Email'], $aTemplate['Subject'], $aTemplate['Body'], $recipient['ID']); // Send message into the member's site personal mailbox; $aTemplate['Subject'] = process_db_input($aTemplate['Subject'], BX_TAGS_NO_ACTION); $aTemplate['Body'] = process_db_input($aTemplate['Body'], BX_TAGS_NO_ACTION); $sender['ID'] = !$sender['ID'] ? 0 : $sender['ID']; $sQuery = "\n INSERT INTO\n `sys_messages`\n SET\n `Date` = NOW(),\n `Sender` = '{$sender['ID']}',\n `Recipient` = '{$recipient['ID']}',\n `Subject` = '{$aTemplate['Subject']}',\n `Text` = '{$aTemplate['Body']}',\n `New` = '1',\n `Type` = 'greeting'\n "; db_res($sQuery); if (!$mail_ret) { return 10; } // Insert kiss into database $kiss_arr = db_arr("SELECT `ID` FROM `sys_greetings` WHERE `ID` = {$member['ID']} AND `Profile` = {$recipient['ID']} LIMIT 1", 0); if (!$kiss_arr) { $result = db_res("INSERT INTO `sys_greetings` ( `ID`, `Profile`, `Number`, `When`, `New` ) VALUES ( {$member['ID']}, {$recipient['ID']}, 1, NOW(), '1' )", 0); } else { $result = db_res("UPDATE `sys_greetings` SET `Number` = `Number` + 1, `New` = '1' WHERE `ID` = {$member['ID']} AND `Profile` = {$recipient['ID']}", 0); } if (!$result) { return 1; } // If success then perform actions checkAction($member['ID'], ACTION_ID_SEND_VKISS, true); $oAlert = new BxDolAlerts('greeting', 'add', 0, $member['ID'], array('Recipient' => $recipient['ID'])); $oAlert->alert(); return 0; }
/** * Perform change of status with clearing profile(s) cache and sending mail about activation * * @param mixed $mixedIds - array of IDs or single int ID of profile(s) * @param string $sStatus - given status * @param boolean $bSendActMail - send email about activation or not (works with 'Active' status only * @return boolean - TRUE on success / FALSE on failure */ function bx_admin_profile_change_status($mixedIds, $sStatus, $bSendActMail = FALSE) { if (!$mixedIds || is_array($mixedIds) && empty($mixedIds)) { return FALSE; } if (!is_array($mixedIds)) { $mixedIds = array((int) $mixedIds); } $sStatus = strip_tags($sStatus); $oEmailTemplate = new BxDolEmailTemplates(); foreach ($mixedIds as $iId) { $iId = (int) $iId; if (!$GLOBALS['MySQL']->query("UPDATE `Profiles` SET `Status` = '{$sStatus}' WHERE `ID` = {$iId}")) { break; } createUserDataFile($iId); reparseObjTags('profile', $iId); if ($sStatus == 'Active' && $bSendActMail) { if (BxDolModule::getInstance('BxWmapModule')) { BxDolService::call('wmap', 'response_entry_add', array('profiles', $iId)); } $aProfile = getProfileInfo($iId); $aMail = $oEmailTemplate->parseTemplate('t_Activation', array(), $iId); sendMail($aProfile['Email'], $aMail['subject'], $aMail['body'], $iId, array(), 'html', FALSE, TRUE); } $oAlert = new BxDolAlerts('profile', 'change_status', $iId, 0, array('status' => $sStatus)); $oAlert->alert(); } return TRUE; }
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; }
function sendUnregisterUserNotify($aMember) { if (empty($aMember) || !is_array($aMember)) { return false; } $oEmailTemplates = new BxDolEmailTemplates(); $aTemplate = $oEmailTemplates->parseTemplate('t_UserUnregistered', array('NickName' => $aMember['NickName'], 'Email' => $aMember['Email'])); return sendMail($GLOBALS['site']['email'], $aTemplate['subject'], $aTemplate['body']); }
/** * spam checking function * @param $s content to check for spam * @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 */ function bx_is_spam($val, $isStripSlashes = BX_SLASHES_AUTO) { if (defined('BX_DOL_CRON_EXECUTE')) { return false; } if (isAdmin()) { return false; } if (bx_is_ip_whitelisted()) { return false; } if (get_magic_quotes_gpc() && $isStripSlashes == BX_SLASHES_AUTO) { $val = stripslashes($val); } $bRet = false; if ('on' == getParam('sys_uridnsbl_enable')) { $oBxDolDNSURIBlacklists = bx_instance('BxDolDNSURIBlacklists'); if ($oBxDolDNSURIBlacklists->isSpam($val)) { $oBxDolDNSURIBlacklists->onPositiveDetection($val); $bRet = true; } } if ('on' == getParam('sys_akismet_enable')) { $oBxDolAkismet = bx_instance('BxDolAkismet'); if ($oBxDolAkismet->isSpam($val)) { $oBxDolAkismet->onPositiveDetection($val); $bRet = true; } } if ($bRet && 'on' == getParam('sys_antispam_report')) { bx_import('BxDolEmailTemplates'); $oEmailTemplates = new BxDolEmailTemplates(); $aTemplate = $oEmailTemplates->getTemplate('t_SpamReportAuto', 0); $iProfileId = getLoggedId(); $aPlus = array('SpammerUrl' => getProfileLink($iProfileId), 'SpammerNickName' => getNickName($iProfileId), 'Page' => htmlspecialchars_adv($_SERVER['PHP_SELF']), 'Get' => print_r($_GET, true), 'SpamContent' => htmlspecialchars_adv($val)); sendMail($GLOBALS['site']['email'], $aTemplate['Subject'], $aTemplate['Body'], '', $aPlus); } if ($bRet && 'on' == getParam('sys_antispam_block')) { return true; } return false; }
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); }
function sendFileInfo($sEmail, $sMessage, $sUrl, $sType = 'share') { $aUser = getProfileInfo($this->_iProfileId); $sUrl = urldecode($sUrl); $aPlus = array('MediaType' => _t('_' . $this->_oConfig->getMainPrefix() . '_single'), 'MediaUrl' => $sUrl, 'SenderNickName' => $aUser ? getNickName($aUser['ID']) : _t("_Visitor"), 'UserExplanation' => $sMessage); bx_import('BxDolEmailTemplates'); $rEmailTemplate = new BxDolEmailTemplates(); $sSubject = 't_' . $this->_oConfig->getMainPrefix() . '_' . $sType; $aEmails = explode(",", $sEmail); foreach ($aEmails as $sMail) { $aTemplate = $rEmailTemplate->getTemplate($sSubject); $sMail = trim($sMail); if (sendMail($sMail, $aTemplate['Subject'], $aTemplate['Body'], '', $aPlus)) { return true; } } return false; }
/** * Generate second paid page * * @param $iAdvertisementID ID of Advertisement * @return HTML presentation of data */ function ActionBuySendMailAdvertisement($iAdvertisementID) { global $site; $iSellerId = (int) bx_get('IDSeller'); $sRetHtml = _t('_WARNING'); if ($this->_iVisitorID > 0) { $aSqlResStr = $this->_oDb->getAdInfo($iAdvertisementID); $aSqlSellerRes = getProfileInfo($iSellerId); $aSqlMemberRes = getProfileInfo($this->_iVisitorID); if ($aSqlResStr) { $sCustDetails = $aSqlResStr['CustomFieldName1'] != NULL && $aSqlResStr['CustomFieldValue1'] ? "{$aSqlResStr['Unit1']} {$aSqlResStr['CustomFieldValue1']}" : ''; $sPowDol = _t('_powered_by_Dolphin'); $sBuyMsg2 = _t('_bx_ads_BuyMsg2'); $sBuyDet1 = _t('_bx_ads_BuyDetails1'); $sReturnBackC = _t('_bx_ads_Back'); bx_import('BxDolEmailTemplates'); $rEmailTemplate = new BxDolEmailTemplates(); $aTemplate = $rEmailTemplate->getTemplate('t_BuyNow', $this->_iVisitorID); $aTemplateS = $rEmailTemplate->getTemplate('t_BuyNowS', $this->_iVisitorID); // Send email notification $sMessageB = $aTemplate['Body']; $sMessageS = $aTemplateS['Body']; $sSubject = $aTemplate['Subject']; $sSubjectS = $aTemplateS['Subject']; $aPlus = array(); $aPlus['Subject'] = $aSqlResStr['Subject']; $aPlus['NickName'] = getNickName($aSqlSellerRes['ID']); $aPlus['EmailS'] = $aSqlSellerRes['Email']; $aPlus['NickNameB'] = getNickName($aSqlMemberRes['ID']); $aPlus['EmailB'] = $aSqlMemberRes['Email']; $aPlus['sCustDetails'] = $sCustDetails; $sGenUrl = $this->genUrl($iAdvertisementID, $aSqlResStr['EntryUri']); $aPlus['ShowAdvLnk'] = $sGenUrl; $aPlus['sPowDol'] = $sPowDol; $aPlus['site_email'] = $site['email']; $sRetHtml = ''; $aPlus['Who'] = 'buyer'; $aPlus['String1'] = _t('_bx_ads_you_have_purchased_an_item'); sendMail($aSqlMemberRes['Email'], $sSubject, $sMessageB, $aSqlSellerRes['ID'], $aPlus, 'html'); $aPlus['Who'] = 'seller'; $aPlus['String1'] = _t('_bx_ads_someone_wants_to_purchase'); if (sendMail($aSqlSellerRes['Email'], $sSubjectS, $sMessageS, $aSqlSellerRes['ID'], $aPlus, 'html')) { $sRetHtml .= MsgBox(_t('_Email was successfully sent')); bx_import('BxDolAlerts'); $oZ = new BxDolAlerts('ads', 'buy', $iAdvertisementID, $this->_iVisitorID); $oZ->alert(); } $sBoxContent = <<<EOF <div> <b>{$sBuyMsg2}</b> </div><br/> <div> <b>{$sBuyDet1}</b> {$sCustDetails} </div><br/> <div> <a class="bx-btn" href="{$sGenUrl}">{$sReturnBackC}</a> <div class="clear_both"></div> </div> EOF; $sRetHtml .= DesignBoxContent($aSqlResStr['Subject'], $sBoxContent, 11); } } return $sRetHtml; }
/** * Create new profile; * * @param : $aProfileInfo (array) - some profile's information; * @see : $this -> aFacebookProfileFields; * * @param : $sAlternativeName (string) - profiles alternative nickname; * @return : error string or error or profile info array on success */ function _createProfileRaw($aProfileInfo, $sAlternativeName = '', $isAutoFriends = true, $isSetLoggedIn = true) { //print_r($aProfileInfo); exit; $sCountry = ''; $sCity = ''; //-- join by invite only --// if (getParam('reg_by_inv_only') == 'on' && (!isset($_COOKIE['idFriend']) || getID($_COOKIE['idFriend']) == 0)) { return _t('_registration by invitation only'); } //-- // process the date of birth; if (isset($aProfileInfo['birthday'])) { $aProfileInfo['birthday'] = isset($aProfileInfo['birthday']) ? date('Y-m-d', strtotime($aProfileInfo['birthday'])) : ''; } // generate new password for profile; //$sNewPassword = genRndPwd(); //$sPasswordSalt = genRndSalt(); //$aProfileInfo['password'] = encryptUserPwd($sNewPassword,$sPasswordSalt); $aProfileInfo['password'] = md5(""); //-- define user's country and city --// $aLocation = array(); if (isset($aProfileInfo['location']['name'])) { $aLocation = $aProfileInfo['location']['name']; } else { if (isset($aProfileInfo['hometown']['name'])) { $aLocation = $aProfileInfo['hometown']['name']; } } $sCity = ""; $sCountry = ""; if ($aLocation) { $aCountryInfo = explode(',', $aLocation); $sCountry = $this->_oDb->getCountryCode(trim($aCountryInfo[1])); $sCity = trim($aCountryInfo[0]); //set default country name, especially for American brothers if ($sCity && !$sCountry) { $sCountry = $this->_oConfig->sDefaultCountryCode; } } //-- //try define the user's email $sEmail = !empty($aProfileInfo['email']) ? $aProfileInfo['email'] : $aProfileInfo['proxied_email']; //print_r($sEmail);exit; //check email if ($this->_oDb->isEmailExisting($sEmail)) { return _t('_bx_facebook_error_email'); } //ini_set("display_errors", "1"); //print_r($aProfileInfo); exit; //-- fill array with all needed values --// $aProfileFields = array('FacebookProfile' => $aProfileInfo['id'], 'NickName' => $aProfileInfo['nick_name'] . $sAlternativeName, 'Email' => $sEmail, 'Sex' => isset($aProfileInfo['gender']) ? $aProfileInfo['gender'] : '', 'DateOfBirth' => isset($aProfileInfo['birthday']) ? $aProfileInfo['birthday'] : '', 'Password' => isset($aProfileInfo['password']) ? $aProfileInfo['password'] : '', 'FirstName' => isset($aProfileInfo['first_name']) ? $aProfileInfo['first_name'] : '', 'LastName' => isset($aProfileInfo['last_name']) ? $aProfileInfo['last_name'] : '', 'DescriptionMe' => isset($aProfileInfo['bio']) ? $aProfileInfo['bio'] : '', 'Interests' => isset($aProfileInfo['interests']) ? $aProfileInfo['interests'] : '', 'Religion' => isset($aProfileInfo['religion']) ? $aProfileInfo['religion'] : '', 'Country' => $sCountry, 'City' => $sCity); //-- $aEdirectoryProfileFields = array('facebook_uid' => $aProfileInfo['id'], 'nickname' => $aProfileInfo['nick_name'] . $sAlternativeName, 'personal_message' => isset($aProfileInfo['bio']) ? $aProfileInfo['bio'] : '', 'facebook_image' => isset($aProfileInfo['picture']) ? $aProfileInfo['picture'] : '', 'facebook_image_width' => '100', 'facebook_image_height' => '100', 'location' => $sCity); $thisusername = $aProfileInfo['first_name'] . $aProfileInfo['last_name']; //$thisusername = utf8_encode ( $thisusername ); $aAccountFields = array('facebook_username' => "facebook::" . $thisusername . "_" . $aProfileInfo['id'], 'username' => "facebook::" . $thisusername . "_" . $aProfileInfo['id'], 'has_profile' => 'y', 'active' => 'y', 'foreignaccount' => 'y', 'foreignaccount_done' => 'y', 'password' => isset($aProfileInfo['password']) ? $aProfileInfo['password'] : '', 'updated' => date('Y-m-d H:i:s'), 'entered' => date('Y-m-d H:i:s'), 'agree_tou' => '1'); $aAccountProfileContactFields = array('username' => "facebook::" . $thisusername . "_" . $aProfileInfo['id'], 'has_profile' => 'y', 'nickname' => $aProfileInfo['first_name'] . " " . $aProfileInfo['last_name'], 'first_name' => isset($aProfileInfo['first_name']) ? $aProfileInfo['first_name'] : '', 'last_name' => isset($aProfileInfo['last_name']) ? $aProfileInfo['last_name'] : '', 'facebook_image_width' => '100', 'facebook_image_height' => '100'); $aContactFields = array('email' => $sEmail, 'first_name' => isset($aProfileInfo['first_name']) ? $aProfileInfo['first_name'] : '', 'last_name' => isset($aProfileInfo['last_name']) ? $aProfileInfo['last_name'] : '', 'country' => $sCountry, 'city' => $sCity); bx_import('BxDolStopForumSpam'); $oBxDolStopForumSpam = new BxDolStopForumSpam(); if (2 == getParam('ipBlacklistMode') && bx_is_ip_blocked()) { return _t('_Sorry, your IP been banned'); } elseif ('on' == getParam('sys_dnsbl_enable') && 'block' == getParam('sys_dnsbl_behaviour') && bx_is_ip_dns_blacklisted('', 'join facebook') || $oBxDolStopForumSpam->isSpammer(array('email' => $aProfileFields['Email'], 'ip' => getVisitorIP(false)), 'join facebook')) { return sprintf(_t('_sys_spam_detected'), BX_DOL_URL_ROOT . 'contact.php'); } // check fields existence; foreach ($aProfileFields as $sKey => $mValue) { if (!$this->_oDb->isFieldExist($sKey)) { // (field not existence) remove from array; unset($aProfileFields[$sKey]); } } //-- add some system values --// $aProfileFields['Role'] = BX_DOL_ROLE_MEMBER; $aProfileFields['DateReg'] = date('Y-m-d H:i:s'); // set current date; $aProfileFields['Salt'] = $sPasswordSalt; //-- //check redirect page if ('join' == $this->_oConfig->sRedirectPage) { return array('profile_info_fb' => $aProfileInfo, 'profile_fields' => $aProfileFields, 'join_page_redirect' => true); } // create new profile; $iProfileId = $this->_oDb->createProfile($aProfileFields); $this->_oDb->EdirctorycreateProfile($aAccountFields, $aEdirectoryProfileFields, $aContactFields, $aAccountProfileContactFields); $oProfileFields = new BxDolProfilesController(); //remember FB uid for created member $this->_oDb->saveFbUid($iProfileId, $aProfileInfo['id']); // check profile status; if (getParam('autoApproval_ifNoConfEmail') == 'on') { if (getParam('autoApproval_ifJoin') == 'on') { $sProfileStatus = 'Active'; if (!empty($aProfileInfo['email'])) { $oProfileFields->sendActivationMail($iProfileId); } } else { $sProfileStatus = 'Approval'; if (!empty($aProfileInfo['email'])) { $oProfileFields->sendApprovalMail($iProfileId); } } } else { if (!empty($aProfileInfo['email'])) { $oProfileFields->sendConfMail($iProfileId); $sProfileStatus = 'Unconfirmed'; } else { if (getParam('autoApproval_ifJoin') == 'on') { $sProfileStatus = 'Active'; } else { $sProfileStatus = 'Approval'; } } } // update profile's status; $this->_oDb->updateProfileStatus($iProfileId, $sProfileStatus); $oProfileFields->createProfileCache($iProfileId); if (!empty($aProfileInfo['email'])) { //-- send email notification --// $oEmailTemplate = new BxDolEmailTemplates(); $aTemplate = $oEmailTemplate->getTemplate('t_fb_connect_password_generated'); $aNewProfileInfo = getProfileInfo($iProfileId); $aPlus = array('NickName' => getNickName($aNewProfileInfo['ID']), 'NewPassword' => $sNewPassword); sendMail($aNewProfileInfo['Email'], $aTemplate['Subject'], $aTemplate['Body'], '', $aPlus); } //-- bx_member_ip_store($iProfileId); if (BxDolModule::getInstance('BxWmapModule')) { BxDolService::call('wmap', 'response_entry_add', array('profiles', $iProfileId)); } // create system event $oZ = new BxDolAlerts('profile', 'join', $iProfileId); $oZ->alert(); // auto-friend members if they are already friends on Facebook if ($isAutoFriends) { $this->_makeFriends($iProfileId); } // set logged if ($isSetLoggedIn) { $aProfile = getProfileInfo($iProfileId); $this->setLogged($iProfileId, $aProfile['Password'], '', false); } return array('profile_info_fb' => $aProfileInfo, 'profile_id' => $iProfileId); }
function _notifyEmail($sEmailTemplateName, $iRecipient, $aDataEntry) { if (!($aProfile = getProfileInfo($iRecipient))) { return false; } bx_import('BxDolEmailTemplates'); $oEmailTemplate = new BxDolEmailTemplates(); if (!$oEmailTemplate) { return false; } $aTemplate = $oEmailTemplate->getTemplate($sEmailTemplateName); $aTemplateVars = array('EntryTitle' => $aDataEntry[$this->_oDb->_sFieldTitle], 'EntryUrl' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aDataEntry[$this->_oDb->_sFieldUri]); return sendMail($aProfile['Email'], $aTemplate['Subject'], $aTemplate['Body'], $aProfile['ID'], $aTemplateVars); }
/** * Create new profile; * * @param : $aProfileInfo (array) - remote profile's information; * * @param : $sAlternativeName (string) - profiles alternative nickname; * @return : error string or error or profile info array on success */ function _createProfileRaw($aProfileInfo, $sAlternativeName = '', $isAutoFriends = true, $isSetLoggedIn = true) { $sCountry = ''; $sCity = ''; // join by invite only if (getParam('reg_by_inv_only') == 'on' && (!isset($_COOKIE['idFriend']) || getID($_COOKIE['idFriend']) == 0)) { return _t('_registration by invitation only'); } // convert fields $aProfileFields = $this->_convertRemoteFields($aProfileInfo, $sAlternativeName); if (empty($aProfileFields['Email'])) { return _t('_Incorrect Email'); } // antispam check bx_import('BxDolStopForumSpam'); $oBxDolStopForumSpam = new BxDolStopForumSpam(); if (2 == getParam('ipBlacklistMode') && bx_is_ip_blocked()) { return _t('_Sorry, your IP been banned'); } elseif ('on' == getParam('sys_dnsbl_enable') && 'block' == getParam('sys_dnsbl_behaviour') && bx_is_ip_dns_blacklisted('', 'join oauth') || $oBxDolStopForumSpam->isSpammer(array('email' => $aProfileFields['Email'], 'ip' => getVisitorIP(false)), 'join oauth')) { return sprintf(_t('_sys_spam_detected'), BX_DOL_URL_ROOT . 'contact.php'); } // check fields existence; foreach ($aProfileFields as $sKey => $mValue) { if (!$this->_oDb->isFieldExist($sKey)) { // (field not existence) remove from array; unset($aProfileFields[$sKey]); } } // add some system values $sNewPassword = genRndPwd(); $sPasswordSalt = genRndSalt(); $aProfileFields['Password'] = encryptUserPwd($sNewPassword, $sPasswordSalt); $aProfileFields['Role'] = BX_DOL_ROLE_MEMBER; $aProfileFields['DateReg'] = date('Y-m-d H:i:s'); // set current date; $aProfileFields['Salt'] = $sPasswordSalt; // set default privacy bx_import('BxDolPrivacyQuery'); $oPrivacy = new BxDolPrivacyQuery(); $aProfileFields['allow_view_to'] = $oPrivacy->getDefaultValueModule('profile', 'view_block'); // check if user with the same email already exists $iExistingProfileId = $this->_oDb->isEmailExisting($aProfileFields['Email']); // check redirect page if ('join' == $this->_oConfig->sRedirectPage && !$iExistingProfileId) { return array('remote_profile_info' => $aProfileInfo, 'profile_fields' => $aProfileFields, 'join_page_redirect' => true); } // create new profile if ($iExistingProfileId) { $iProfileId = $iExistingProfileId; } else { $iProfileId = $this->_oDb->createProfile($aProfileFields); } $oProfileFields = new BxDolProfilesController(); // remember remote profile id for created member $this->_oDb->saveRemoteId($iProfileId, $aProfileInfo['id']); // check profile status; if (!$iExistingProfileId) { if (getParam('autoApproval_ifNoConfEmail') == 'on') { if (getParam('autoApproval_ifJoin') == 'on') { $sProfileStatus = 'Active'; if (!empty($aProfileInfo['email'])) { $oProfileFields->sendActivationMail($iProfileId); } } else { $sProfileStatus = 'Approval'; if (!empty($aProfileInfo['email'])) { $oProfileFields->sendApprovalMail($iProfileId); } } } else { if (!empty($aProfileInfo['email'])) { $oProfileFields->sendConfMail($iProfileId); $sProfileStatus = 'Unconfirmed'; } else { if (getParam('autoApproval_ifJoin') == 'on') { $sProfileStatus = 'Active'; } else { $sProfileStatus = 'Approval'; } } } // update profile's status; $this->_oDb->updateProfileStatus($iProfileId, $sProfileStatus); $oProfileFields->createProfileCache($iProfileId); // send email notification if (!empty($aProfileInfo['email'])) { $oEmailTemplate = new BxDolEmailTemplates(); $aTemplate = $oEmailTemplate->getTemplate($this->_oConfig->sEmailTemplatePasswordGenerated, $iProfileId); $aNewProfileInfo = getProfileInfo($iProfileId); $aPlus = array('NickName' => getNickName($aNewProfileInfo['ID']), 'NewPassword' => $sNewPassword); sendMail($aNewProfileInfo['Email'], $aTemplate['Subject'], $aTemplate['Body'], '', $aPlus); } // update location if (BxDolModule::getInstance('BxWmapModule')) { BxDolService::call('wmap', 'response_entry_add', array('profiles', $iProfileId)); } // create system event $oZ = new BxDolAlerts('profile', 'join', $iProfileId); $oZ->alert(); } // store IP bx_member_ip_store($iProfileId); // auto-friend members if they are already friends on remote site if ($isAutoFriends && method_exists($this, '_makeFriends')) { $this->_makeFriends($iProfileId); } // set logged if ($isSetLoggedIn) { $aProfile = getProfileInfo($iProfileId); $this->setLogged($iProfileId, $aProfile['Password'], '', false); } return array('remote_profile_info' => $aProfileInfo, 'profile_id' => $iProfileId, 'existing_profile' => $iExistingProfileId ? true : false); }
/** * Set a membership for a member * * @param int $iMemberId - member that is going to get the membership * @param int $iMembershipId - membership that is going to be assigned to the member * if $iMembershipId == MEMBERSHIP_ID_STANDARD then $days * and $bStartsNow parameters are not used, so Standard * membership is always set immediately and `forever` * * @param int $days - number of days to set membership for * if 0, then the membership is set forever * * @param boolean $bStartsNow - if true, the membership will start immediately; * if false, the membership will start after the current * membership expires * * @return boolean - true in case of success, false in case of failure * * */ function setMembership($iMemberId, $iMembershipId, $iDays = 0, $bStartsNow = false, $sTransactionId = '', $isSendMail = true) { $iMemberId = (int) $iMemberId; $iMembershipId = (int) $iMembershipId; $iDays = (int) $iDays; $bStartsNow = $bStartsNow ? true : false; $SECONDS_IN_DAY = 86400; if (!$iMemberId) { $iMemberId = -1; } if (empty($sTransactionId)) { $sTransactionId = 'NULL'; } //check if member exists $aProfileInfo = getProfileInfo($iMemberId); if (!$aProfileInfo) { return false; } //check if membership exists $iRes = (int) db_value("SELECT COUNT(`ID`) FROM `sys_acl_levels` WHERE `ID`='" . $iMembershipId . "' LIMIT 1"); if ($iRes != 1) { return false; } if ($iMembershipId == MEMBERSHIP_ID_NON_MEMBER) { return false; } $aMembershipCurrent = getMemberMembershipInfo($iMemberId); $aMembershipLatest = getMemberMembershipInfo_latest($iMemberId); /** * Setting Standard membership level */ if ($iMembershipId == MEMBERSHIP_ID_STANDARD) { if ($aMembershipCurrent['ID'] == MEMBERSHIP_ID_STANDARD) { return true; } //delete any present and future memberships $res = db_res("DELETE FROM `sys_acl_levels_members` WHERE `IDMember`='" . $iMemberId . "' AND (`DateExpires` IS NULL OR `DateExpires`>NOW())"); if (db_affected_rows($res) <= 0) { return false; } } if ($iDays < 0) { return false; } $iDateStarts = time(); if (!$bStartsNow) { /** * make the membership starts after the latest membership expires * or return false if latest membership isn't Standard and is lifetime membership */ if (!is_null($aMembershipLatest['DateExpires'])) { $iDateStarts = $aMembershipLatest['DateExpires']; } else { if (is_null($aMembershipLatest['DateExpires']) && $aMembershipLatest['ID'] != MEMBERSHIP_ID_STANDARD) { return false; } } } else { // delete previous profile's membership level and actions traces db_res("DELETE FROM `sys_acl_levels_members` WHERE `IDMember`='" . $iMemberId . "'"); clearActionsTracksForMember($iMemberId); } /** * set lifetime membership if 0 days is used. */ $iDateExpires = $iDays != 0 ? (int) $iDateStarts + $iDays * $SECONDS_IN_DAY : 'NULL'; $res = db_res("INSERT `sys_acl_levels_members` (`IDMember`, `IDLevel`, `DateStarts`, `DateExpires`, `TransactionID`) VALUES ('" . $iMemberId . "', '" . $iMembershipId . "', FROM_UNIXTIME(" . $iDateStarts . "), FROM_UNIXTIME(" . $iDateExpires . "), '" . $sTransactionId . "')"); if (db_affected_rows($res) <= 0) { return false; } //Set Membership Alert bx_import('BxDolAlerts'); $oZ = new BxDolAlerts('profile', 'set_membership', '', $iMemberId, array('mlevel' => $iMembershipId, 'days' => $iDays, 'starts_now' => $bStartsNow, 'txn_id' => $sTransactionId)); $oZ->alert(); //Notify user about changed membership level bx_import('BxDolEmailTemplates'); $oEmailTemplate = new BxDolEmailTemplates(); $aTemplate = $oEmailTemplate->getTemplate('t_MemChanged', $iMemberId); $aMembershipInfo = getMembershipInfo($iMembershipId); $aTemplateVars = array('MembershipLevel' => $aMembershipInfo['Name']); if ($isSendMail) { sendMail($aProfileInfo['Email'], $aTemplate['Subject'], $aTemplate['Body'], $iMemberId, $aTemplateVars); } //Notify admin about changed user's membership level $aTemplate = $oEmailTemplate->parseTemplate('t_UserMemChanged', $aTemplateVars, $iMemberId); sendMail($GLOBALS['site']['email'], $aTemplate['Subject'], $aTemplate['Body']); return true; }
// --------------- page variables and login $_page['name_index'] = 1; $logged['member'] = member_auth(0, false); $_page['header'] = _t("_Forgot password?"); $_page['header_text'] = _t("_Password retrieval", $site['title']); // --------------- page components $_ni = $_page['name_index']; $aForm = array('form_attrs' => array('name' => 'forgot_form', 'action' => BX_DOL_URL_ROOT . 'forgot.php', 'method' => 'post'), 'params' => array('db' => array('submit_name' => 'do_submit'), 'checker_helper' => 'BxDolForgotCheckerHelper'), 'inputs' => array(array('type' => 'email', 'name' => 'Email', 'caption' => _t('_My Email'), 'value' => isset($_POST['Email']) ? $_POST['Email'] : '', 'required' => true, 'checker' => array('func' => 'email', 'error' => _t('_Incorrect Email'))), array('type' => 'captcha', 'name' => 'captcha', 'caption' => _t('_Enter Captcha'), 'required' => true, 'checker' => array('func' => 'captcha', 'error' => _t('_Incorrect Captcha'))), array('type' => 'submit', 'name' => 'do_submit', 'value' => _t("_Retrieve my information")))); $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { // Check if entered email is in the base $sEmail = process_db_input($_POST['Email'], BX_TAGS_STRIP); $memb_arr = db_arr("SELECT `ID` FROM `Profiles` WHERE `Email` = '{$sEmail}'"); $recipient = $sEmail; $rEmailTemplate = new BxDolEmailTemplates(); $aTemplate = $rEmailTemplate->getTemplate('t_Forgot', $memb_arr['ID']); $aPlus['Password'] = generateUserNewPwd($memb_arr['ID']); $aProfile = getProfileInfo($memb_arr['ID']); $mail_ret = sendMail($recipient, $aTemplate['Subject'], $aTemplate['Body'], $memb_arr['ID'], $aPlus, 'html', false, true); // create system event require_once BX_DIRECTORY_PATH_CLASSES . 'BxDolAlerts.php'; $oZ = new BxDolAlerts('profile', 'password_restore', $memb_arr['ID']); $oZ->alert(); $_page['header'] = _t("_Recognized"); $_page['header_text'] = _t("_RECOGNIZED", $site['title']); if ($mail_ret) { $action_result = _t("_MEMBER_RECOGNIZED_MAIL_SENT", $site['url'], $site['title']); } else { $action_result = _t("_MEMBER_RECOGNIZED_MAIL_NOT_SENT", $site['title']); }
/** * Function will set status as `accepted` for friend request ; * * @param : $sTableName (string) - DB table's name ; * @param : $iMemberID (integer) - member's ID ; */ function _acceptFriendInvite($sTableName, $iMemberID) { $sTableName = process_db_input($sTableName, BX_TAGS_NO_ACTION, BX_SLASHES_NO_ACTION); $iMemberID = (int) $iMemberID; $sQuery = "\n UPDATE\n `{$sTableName}`\n SET\n `Check` = 1\n WHERE\n `ID` = {$iMemberID}\n AND\n `Profile` = {$this->aCommunicatorSettings['member_id']}\n "; // send system alert db_res($sQuery); $oZ = new BxDolAlerts('friend', 'accept', $iMemberID, $this->aCommunicatorSettings['member_id']); $oZ->alert(); //-- send email notification --// $oEmailTemplate = new BxDolEmailTemplates(); $aTemplate = $oEmailTemplate->getTemplate('t_FriendRequestAccepted', $iMemberID); $aRecipient = getProfileInfo($iMemberID); // assing all necessary data $aPlus = array('Recipient' => getNickName($aRecipient['ID']), 'SenderLink' => getProfileLink($this->aCommunicatorSettings['member_id']), 'Sender' => getNickName($this->aCommunicatorSettings['member_id'])); // send notification sendMail($aRecipient['Email'], $aTemplate['Subject'], $aTemplate['Body'], '', $aPlus); //-- }
function PreviewMessage() { $oEmailTemplate = new BxDolEmailTemplates(); $aMessage = $oEmailTemplate->parseTemplate('t_AdminEmail', array('MessageText' => process_pass_data($_POST['body']))); return DesignBoxContent(_t('_Preview'), $aMessage['body'], 11); }
/** * 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; }
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 MemberFreeEmail($recipientID, $profile) { global $site; $anon_mode = getParam('anon_mode'); $recipientID = (int) $recipientID; $aRecipientArr = db_arr("SELECT `Email` FROM `Profiles` WHERE `ID` = '{$recipientID}' AND `Status` = 'Active'", 0); if (isBlocked($profile['ID'], $recipientID)) { return 25; } if (!db_arr("SELECT `ID` FROM `Profiles` WHERE `ID` = '{$profile['ID']}' AND `Status` = 'Active'", 0)) { return 7; } if ($anon_mode) { return 20; } $rEmailTemplate = new BxDolEmailTemplates(); $aTemplate = $rEmailTemplate->getTemplate('t_FreeEmail', $recipientID); if ($recipientID) { $recipient = $aRecipientArr['Email']; } else { if ($_GET['Email']) { $recipient = $_GET['Email']; } else { return 45; } } $contact_info = "Email: {$profile['Email']}"; if (strlen($profile['Phone'])) { $contact_info .= "\nPhone: {$profile['Phone']}"; } if (strlen($profile['HomeAddress'])) { $contact_info .= "\nHomeAddress: {$profile['HomeAddress']}"; } if (strlen($profile['HomePage'])) { $contact_info .= "\nHomePage: {$profile['HomePage']}"; } if (strlen($profile['IcqUIN'])) { $contact_info .= "\nICQ: {$profile['IcqUIN']}"; } $aPlus = array(); $aPlus['profileContactInfo'] = $contact_info; $aPlus['profileNickName'] = getNickName($profile['ID']); $aPlus['profileID'] = $profile['ID']; $mail_ret = sendMail($aRecipientArr['Email'], $aTemplate['Subject'], $aTemplate['Body'], $recipientID, $aPlus, 'html', false, true); if ($mail_ret) { checkAction($memberID, ACTION_ID_GET_EMAIL, true); } else { return 10; } return 0; }