/** * Clean database by deleting some expired data */ protected function cleanDatabase() { // clean expired membership levels bx_import('BxDolAcl'); $oAcl = BxDolAcl::getInstance(); $iDeleteMemLevels = $oAcl ? $oAcl->maintenance() : 0; //--- Clean sessions ---// bx_import('BxDolSession'); $oSession = BxDolSession::getInstance(); $iSessions = $oSession ? $oSession->maintenance() : 0; // clean old views bx_import('BxDolView'); $iDeletedViews = BxDolView::maintenance(); // clean storage engine expired private file tokens bx_import('BxDolStorage'); $iDeletedExpiredTokens = BxDolStorage::pruning(); // clean outdated transcoded images bx_import('BxDolImageTranscoder'); $iDeletedTranscodedImages = BxDolImageTranscoder::pruning(); // clean expired keys bx_import('BxDolKey'); $oKey = BxDolKey::getInstance(); $iDeletedKeys = $oKey ? $oKey->prune() : 0; // clean old votes bx_import('BxDolVote'); $iDeletedVotes = BxDolVote::maintenance(); echo _t('_sys_pruning_db', $iDeleteMemLevels, $iSessions, $iDeletedViews, $iDeletedVotes, $iDeletedKeys, $iDeletedExpiredTokens, $iDeletedTranscodedImages); }
protected function _processAccountAdded($oAlert) { $sKeyCode = $this->_oModule->_oConfig->getKeyCode(); $sKey = BxDolSession::getInstance()->getUnsetValue($sKeyCode); if ($sKey === false) { return; } $oKeys = BxDolKey::getInstance(); if ($oKeys && $oKeys->isKeyExists($sKey)) { $oKeys->removeKey($sKey); } return; }
/** * 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; }
/** * Check if key exists */ function checkCodeExist($s) { $oKey = BxDolKey::getInstance(); return $oKey && $oKey->isKeyExists(trim($s)); }
/** * 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); }