public function serviceLoginForm($sParams = '', $sForceRelocate = '') { if (isLogged()) { return false; } // get all auth types $aAuthTypes = BxDolDb::getInstance()->fromCache('sys_objects_auths', 'getAll', 'SELECT * FROM `sys_objects_auths`'); // define additional auth types if ($aAuthTypes) { $aAddInputEl[''] = _t('_Basic'); // procces all additional menu's items foreach ($aAuthTypes as $iKey => $aItems) { $aAddInputEl[$aItems['Link']] = _t($aItems['Title']); } $aAuthTypes = array('type' => 'select', 'caption' => _t('_Auth type'), 'values' => $aAddInputEl, 'value' => '', 'attrs' => array('onchange' => 'if (this.value) { location.href = "' . BX_DOL_URL_ROOT . '" + this.value }')); } else { $aAuthTypes = array('type' => 'hidden'); } $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login'); $sCustomHtmlBefore = ''; $sCustomHtmlAfter = ''; bx_alert('profile', 'show_login_form', 0, 0, array('oForm' => $oForm, 'sParams' => &$sParams, 'sCustomHtmlBefore' => &$sCustomHtmlBefore, 'sCustomHtmlAfter' => &$sCustomHtmlAfter, 'aAuthTypes' => &$aAuthTypes)); if ($sForceRelocate && 0 === mb_stripos($sForceRelocate, BX_DOL_URL_ROOT)) { $oForm->aInputs['relocate']['value'] = $sForceRelocate; } elseif ('homepage' == $sForceRelocate) { $oForm->aInputs['relocate']['value'] = BX_DOL_URL_ROOT; } $sFormCode = $oForm->getCode(); $sJoinText = ''; if (strpos($sParams, 'no_join_text') === false) { $sJoinText = '<hr class="bx-def-hr bx-def-margin-sec-topbottom" /><div>' . _t('_sys_txt_login_description', BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=create-account')) . '</div>'; } BxDolTemplate::getInstance()->addJs(array('jquery.form.min.js')); return $sCustomHtmlBefore . $sFormCode . $sCustomHtmlAfter . $sJoinText; }
/** * Get page code with automatic caching, adding necessary css/js files and system template vars. * @return string. */ public function getCode() { if (bx_get('dynamic') && ($iBlockId = (int) bx_get('pageBlock'))) { if (!$this->_isVisiblePage($this->_aObject)) { header('HTTP/1.0 403 Forbidden'); exit; } bx_alert('system', 'page_output_block', 0, false, array('page_name' => $this->_sObject, 'page_object' => $this, 'page_query' => $this->_oQuery, 'block_id' => (int) $iBlockId)); header('Content-type:text/html;charset=utf-8'); echo $this->_getBlockOnlyCode($iBlockId); exit; } if (!$this->_isVisiblePage($this->_aObject)) { return $this->_getPageAccessDeniedMsg(); } $this->_addJsCss(); $this->_addSysTemplateVars(); $this->_selectMenu(); if (!getParam('sys_page_cache_enable') || !$this->_aObject['cache_lifetime']) { return $this->_getPageCode(); } $oCache = $this->_getPageCacheObject(); $sKey = $this->_getPageCacheKey(); $mixedRet = $oCache->getData($sKey, $this->_aObject['cache_lifetime']); if ($mixedRet !== null) { return $mixedRet; } else { $sPageCode = $this->_getPageCode(); $oCache->setData($sKey, $sPageCode, $this->_aObject['cache_lifetime']); } bx_alert('system', 'page_output', 0, false, array('page_name' => $this->_sObject, 'page_object' => $this, 'page_query' => $this->_oQuery, 'page_code' => &$sPageCode)); return $sPageCode; }
public function serviceLoginForm($sParams = '', $sForceRelocate = '') { if (isLogged()) { return false; } // get all auth types $aAuthTypes = BxDolDb::getInstance()->fromCache('sys_objects_auths', 'getAll', 'SELECT * FROM `sys_objects_auths`'); $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login'); $sCustomHtmlBefore = ''; $sCustomHtmlAfter = ''; bx_alert('profile', 'show_login_form', 0, 0, array('oForm' => $oForm, 'sParams' => &$sParams, 'sCustomHtmlBefore' => &$sCustomHtmlBefore, 'sCustomHtmlAfter' => &$sCustomHtmlAfter, 'aAuthTypes' => &$aAuthTypes)); if ($sForceRelocate && 0 === mb_stripos($sForceRelocate, BX_DOL_URL_ROOT)) { $oForm->aInputs['relocate']['value'] = $sForceRelocate; } elseif ('homepage' == $sForceRelocate) { $oForm->aInputs['relocate']['value'] = BX_DOL_URL_ROOT; } $sFormCode = $oForm->getCode(); $sJoinText = ''; if (strpos($sParams, 'no_join_text') === false) { $sJoinText = '<hr class="bx-def-hr bx-def-margin-sec-topbottom" /><div class="bx-def-font-align-center">' . _t('_sys_txt_login_description', BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=create-account')) . '</div>'; } BxDolTemplate::getInstance()->addJs(array('jquery.form.min.js')); $sAuth = $this->serviceMemberAuthCode($aAuthTypes); return $sCustomHtmlBefore . $sAuth . $sFormCode . $sCustomHtmlAfter . $sJoinText; }
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 isValid() { if (!parent::isValid()) { return false; } $sErrorMsg = ''; bx_alert('account', 'check_join', 0, false, array('error_msg' => &$sErrorMsg, 'email' => $this->getCleanValue('email'), 'approve' => &$this->_bSetPendingApproval)); if ($sErrorMsg) { $this->_setCustomError($sErrorMsg); } return $sErrorMsg ? false : true; }
public function deleteData($iContentId, $aContentInfo = false, $oProfile = null, $oForm = null) { $CNF =& $this->_oModule->_oConfig->CNF; if ($sErrorMsg = $this->_oModule->deleteConvoForever($iContentId)) { return $sErrorMsg; } if ($sResult = $this->onDataDeleteAfter($aContentInfo[$CNF['FIELD_ID']], $aContentInfo, $oProfile)) { return $sResult; } // create an alert bx_alert($this->_oModule->getName(), 'deleted', $aContentInfo[$CNF['FIELD_ID']]); return ''; }
public function insert($aValsToAdd = array(), $isIgnore = false) { $aValsToAdd['last_reply_timestamp'] = time(); $aValsToAdd['last_reply_profile_id'] = bx_get_logged_profile_id(); $bSaveToDrafts = bx_get('draft_save'); $iContentId = bx_get('draft_id'); $bDraft = $iContentId ? BX_CNV_FOLDER_DRAFTS == $this->_oModule->_oDb->getConversationFolder($iContentId, bx_get_logged_profile_id()) : false; if ($iContentId) { if (!$bDraft) { return 0; } if (!parent::update($iContentId, $aValsToAdd, $isIgnore)) { return 0; } } else { $iContentId = parent::insert($aValsToAdd, $isIgnore); if (!$iContentId) { return 0; } } if ($bSaveToDrafts) { if (!$bDraft) { $this->_oModule->_oDb->conversationToFolder($iContentId, BX_CNV_FOLDER_DRAFTS, bx_get_logged_profile_id(), 0); } // draft is saved via ajax call only, upon successfull draft saving content id is returned echo $iContentId; exit; } else { bx_import('BxDolProfile'); // check for spam $bSpam = false; bx_alert('system', 'check_spam', 0, getLoggedId(), array('is_spam' => &$bSpam, 'content' => $this->getCleanValue('text'), 'where' => $this->MODULE)); $iFolder = $bSpam ? BX_CNV_FOLDER_SPAM : BX_CNV_FOLDER_INBOX; // place conversation to "inbox" (or "spam" - in case of spam) folder $aRecipients = array_unique(array_merge($this->getCleanValue('recipients'), array(bx_get_logged_profile_id())), SORT_NUMERIC); foreach ($aRecipients as $iProfile) { $oProfile = BxDolProfile::getInstance($iProfile); if (!$oProfile) { continue; } if ($bDraft && $oProfile->id() == bx_get_logged_profile_id()) { $this->_oModule->_oDb->moveConvo($iContentId, $oProfile->id(), $iFolder); } else { $this->_oModule->_oDb->conversationToFolder($iContentId, $iFolder, $oProfile->id(), $oProfile->id() == bx_get_logged_profile_id() ? 0 : -1); } } } return $iContentId; }
public function onProfileCreated($sProfileId, $sToken) { if (empty($sProfileId) || empty($sToken)) { return; } $sSid = encryptUserPwd($sProfileId, genRndSalt()); $this->_oModule->_oDb->updatePaymentDetails(array('profile_id' => $sProfileId, 'profile_sid' => $sSid), array('token' => $sToken)); $aAccount = $this->_oModule->_oDb->getAccount(array('type' => 'profile_id', 'value' => $sProfileId)); if (!empty($aAccount) && is_array($aAccount)) { $this->_oModule->_oDb->updateAccount(array('status' => BX_SITES_ACCOUNT_STATUS_PENDING), array('id' => $aAccount['id'])); // perform action $this->_oModule->isAllowedAdd(true); // alert bx_alert($this->_oModule->getName(), 'added', $aAccount['id']); } }
protected function onDataAddAfter($iContentId) { $CNF =& $this->_oModule->_oConfig->CNF; // add account and content association $iProfileId = BxDolProfile::add(BX_PROFILE_ACTION_MANUAL, getLoggedId(), $iContentId, BX_PROFILE_STATUS_PENDING, $this->_oModule->getName()); $oProfile = BxDolProfile::getInstance($iProfileId); // approve profile if auto-approval is enabled and profile status is 'pending' $sStatus = $oProfile->getStatus(); $isAutoApprove = getParam($CNF['PARAM_AUTOAPPROVAL']) ? true : false; if ($sStatus == BX_PROFILE_STATUS_PENDING && $isAutoApprove) { $oProfile->approve(BX_PROFILE_ACTION_AUTO); } // set created profile some default membership bx_import('BxDolAcl'); $iAclLevel = isAdmin() ? MEMBERSHIP_ID_ADMINISTRATOR : getParam($CNF['PARAM_DEFAULT_ACL_LEVEL']); BxDolAcl::getInstance()->setMembership($iProfileId, $iAclLevel, 0, true); // alert bx_alert($this->_oModule->getName(), 'added', $iContentId); // switch context to the created profile bx_import('BxDolAccount'); $oAccount = BxDolAccount::getInstance(); $oAccount->updateProfileContext($iProfileId); return ''; }
protected function _editAccountForm($iAccountId, $sDisplayName) { $oAccount = BxDolAccount::getInstance($iAccountId); $aAccountInfo = $oAccount ? $oAccount->getInfo() : false; if (!$aAccountInfo) { return MsgBox(_t('_sys_txt_error_account_is_not_defined')); } // check access if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = BxDolAccount::isAllowedEdit($this->_iProfileId, $aAccountInfo))) { return MsgBox($sMsg); } // check and display form $oForm = BxDolForm::getObjectInstance('sys_account', $sDisplayName); if (!$oForm) { return MsgBox(_t('_sys_txt_error_occured')); } if (!$oForm->isSubmitted()) { unset($aAccountInfo['password']); } $oForm->initChecker($aAccountInfo); if (!$oForm->isSubmittedAndValid()) { return $oForm->getCode(); } $aTrackTextFieldsChanges = array(); // track text fields changes, not-null(for example empty array) - means track, null - means don't track // update email and email setting in DB if (!$oForm->update($aAccountInfo['id'], array(), $aTrackTextFieldsChanges)) { if (!$oForm->isValid()) { return $oForm->getCode(); } else { return MsgBox(_t('_sys_txt_error_account_update')); } } // check if email was changed if (!empty($aTrackTextFieldsChanges['changed_fields']) && in_array('email', $aTrackTextFieldsChanges['changed_fields'])) { $oAccount->updateEmailConfirmed(false); } // mark email as unconfirmed // check if password was changed if ($oForm->getCleanValue('password')) { // relogin with new password bx_logout(); bx_login($aAccountInfo['id']); } // check if other text info was changed - if auto-appproval is off $isAutoApprove = $oForm->isSetPendingApproval() ? false : true; if (!$isAutoApprove) { bx_import('BxDolProfile'); $oProfile = BxDolProfile::getInstanceAccountProfile($aAccountInfo['id']); // get profile associated with account, not current porfile $aProfileInfo = $oProfile->getInfo(); unset($aTrackTextFieldsChanges['changed_fields']['email']); // email confirmation is automatic and separate, don't need to deactivate whole profile if email is changed if (BX_PROFILE_STATUS_ACTIVE == $aProfileInfo['status'] && !empty($aTrackTextFieldsChanges['changed_fields'])) { $oProfile->disapprove(BX_PROFILE_ACTION_AUTO); } // change profile to 'pending' only if some text fields were changed and profile is active } // create an alert bx_alert('account', 'edited', $aAccountInfo['id'], $aAccountInfo['id'], array('display' => $sDisplayName)); // display result message $sMsg = MsgBox(_t('_sys_txt_data_successfully_submitted')); return $sMsg . $oForm->getCode(); }
public function deleteDataForm($iContentId, $sDisplay = false) { $CNF =& $this->_oModule->_oConfig->CNF; if (false === $sDisplay) { $sDisplay = $CNF['OBJECT_FORM_ENTRY_DISPLAY_DELETE']; } // get content data and profile info list($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId); if (!$aContentInfo) { return MsgBox(_t('_sys_txt_error_entry_is_not_defined')); } // check access if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedDelete($aContentInfo))) { return MsgBox($sMsg); } // check and display form $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $sDisplay); if (!$oForm) { return MsgBox(_t('_sys_txt_error_occured')); } $oForm->initChecker($aContentInfo); if (!$oForm->isSubmittedAndValid()) { return $oForm->getCode(); } if (!$oForm->delete($aContentInfo[$CNF['FIELD_ID']], $aContentInfo)) { return MsgBox(_t('_sys_txt_error_entry_delete')); } $sResult = $this->onDataDeleteAfter($aContentInfo[$CNF['FIELD_ID']], $aContentInfo, $oProfile); if ($sResult) { return $sResult; } // perform action $this->_oModule->checkAllowedDelete($aContentInfo, true); // create an alert bx_alert($this->_oModule->getName(), 'deleted', $aContentInfo[$CNF['FIELD_ID']]); // redirect bx_import('BxDolPermalinks'); $this->_redirectAndExit($CNF['URL_HOME'], true, array('account_id' => $oProfile->getAccountId(), 'profile_id' => $oProfile->id())); }
/** * @return delete data html */ public function deleteDataForm($aAccount, $sDisplay = 'bx_sites_site_delete') { $sMsg = $this->_oModule->isAllowedDelete($aAccount); if ($sMsg !== CHECK_ACTION_RESULT_ALLOWED) { return MsgBox($sMsg); } // check and display form $oForm = BxDolForm::getObjectInstance('bx_sites', $sDisplay); if (!$oForm) { return MsgBox(_t('_sys_txt_error_occured')); } $oForm->initChecker($aAccount); if (!$oForm->isSubmittedAndValid()) { return $oForm->getCode(); } if (!$oForm->delete($aAccount['id'], $aAccount)) { return MsgBox(_t('_bx_sites_txt_err_site_delete')); } //delete payment details and history if (!empty($aAccount['id'])) { $this->_oModule->_oDb->deletePaymentDetails(array('account_id' => $aAccount['id'])); $this->_oModule->_oDb->deletePaymentHistory(array('account_id' => $aAccount['id'])); } // cancel subscription if (!empty($aAccount['pd_profile_id'])) { bx_import('Paypal', $this->_oModule->_aModule); $oPaypal = new BxSitesPaypal($this->_oModule); $oPaypal->performAction($aAccount['pd_profile_id']); } // perform action $this->_oModule->isAllowedDelete($aAccount, true); // create an alert bx_alert($this->_oModule->getName(), 'deleted', $aAccount['id']); // redirect $this->_redirectAndExit('page.php?i=sites-home'); }
public function disable($aParams) { $bHtmlResponce = isset($aParams['html_response']) && (bool) $aParams['html_response']; $aModule = $this->oDb->getModuleByUri($this->_aConfig['home_uri']); //--- Check whether the module is installed ---// if (empty($aModule) || !is_array($aModule)) { return array('message' => _t('_adm_err_modules_module_not_installed'), 'result' => false); } //--- Check whether the module is already disabled ---// if ((int) $aModule['enabled'] == 0) { return array('message' => _t('_adm_err_modules_already_disabled'), 'result' => false); } $aResult = array(); bx_alert('system', 'before_disable', 0, false, array('config' => $this->_aConfig, 'result' => &$aResult)); if ($aResult && !$aResult['result']) { return $aResult; } //--- Check for dependent modules ---// $bDependent = false; $aDependents = $this->oDb->getDependent($this->_aConfig['home_uri']); if (is_array($aDependents) && !empty($aDependents)) { $bDependent = true; $sMessage = '<br />' . _t('_adm_err_modules_wrong_dependency_disable') . '<br />'; foreach ($aDependents as $aDependent) { $sMessage .= $aDependent['title'] . '<br />'; } } if ($bDependent) { return array('message' => $this->_displayResult('check_dependencies', false, $sMessage, $bHtmlResponce), 'result' => false); } $aResult = $this->_perform('disable', $aParams); if ($aResult['result']) { $this->oDb->disableModuleByUri($aModule['uri']); $this->oDb->cleanMemory('sys_modules_' . $aModule['uri']); $this->oDb->cleanMemory('sys_modules_' . $aModule['id']); $this->oDb->cleanMemory('sys_modules'); if (!empty($this->_aConfig['disable_success'])) { $this->_perform('disable_success', $aParams); } } else { if (!empty($this->_aConfig['disable_failed'])) { $this->_perform('disable_failed', $aParams); } } bx_alert('system', 'disable', 0, false, array('config' => $this->_aConfig, 'result' => &$aResult)); return $aResult; }
/** * Generate new password. */ protected function generateUserNewPwd($iAccountId) { $sPwd = genRndPwd(); $sSalt = genRndSalt(); $sPasswordHash = encryptUserPwd($sPwd, $sSalt); $this->_oAccountQuery->updatePassword($sPasswordHash, $sSalt, $iAccountId); bx_alert('account', 'edit', $iAccountId, $iAccountId, array('action' => 'forgot_password')); return $sPwd; }
/** * Check unencrypted password * @return empty string on success or error string on error */ function bx_check_password($sLogin, $sPassword, $iRole = BX_DOL_ROLE_MEMBER) { bx_import('BxDolAccount'); $oAccount = BxDolAccount::getInstance($sLogin); if (!$oAccount) { bx_import('BxDolLanguages'); return _t("_sys_txt_login_error"); } $aAccountInfo = $oAccount->getInfo(); $sPassCheck = encryptUserPwd($sPassword, $aAccountInfo['salt']); if ($sErrorMsg = bx_check_login($aAccountInfo['id'], $sPassCheck, $iRole)) { return $sErrorMsg; } // Admin can always login even if he is blocked/banned/suspended/etc if (isAdmin($aAccountInfo['id'])) { return ''; } $sErrorMsg = ''; bx_alert('account', 'check_login', $aAccountInfo['id'], false, array('error_msg' => &$sErrorMsg)); return $sErrorMsg; }
/** * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/ * CC-BY License - http://creativecommons.org/licenses/by/3.0/ * * @defgroup DolphinCore Dolphin Core * @{ */ require_once './inc/header.inc.php'; require_once BX_DIRECTORY_PATH_INC . "design.inc.php"; bx_import('BxDolLanguages'); if (isset($_POST['ID'])) { // login form is submitted bx_import('BxDolForm'); $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login'); bx_alert('account', 'before_login', 0, 0, array('form' => $oForm)); $oForm->initChecker(); $oForm->setRole(bx_get('role')); $bLoginSuccess = $oForm->isSubmittedAndValid(); $bAjxMode = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ? true : false; if ($bAjxMode) { header('Content-type: text/html; charset=utf-8'); echo $bLoginSuccess ? 'OK' : $oForm->getLoginError(); exit; } elseif ($bLoginSuccess) { bx_import('BxDolAccount'); $oAccount = BxDolAccount::getInstance($oForm->getCleanValue('ID')); $aAccount = bx_login($oAccount->id(), $oForm->getCleanValue('rememberMe') ? true : false); $sUrlRelocate = $oForm->getCleanValue('relocate'); if (!$sUrlRelocate || 0 != strncmp($sUrlRelocate, BX_DOL_URL_ROOT, strlen(BX_DOL_URL_ROOT))) { $sUrlRelocate = BX_DOL_ROLE_ADMIN == $oForm->getRole() ? BX_DOL_URL_STUDIO . 'launcher.php' : BX_DOL_URL_ROOT . 'member.php';
public static function checkIsSpam($val) { $bSpam = false; bx_alert('system', 'check_spam', 0, getLoggedId(), array('is_spam' => &$bSpam, 'content' => $val, 'where' => 'form')); return $bSpam; }
public function onDataAddAfter($iAccountId, $iContentId) { if ($s = parent::onDataAddAfter($iAccountId, $iContentId)) { return $s; } $CNF =& $this->_oModule->_oConfig->CNF; if (!($aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId))) { return MsgBox(_t('_sys_txt_error_occured')); } // alert $aParams = array('object_author_id' => $aContentInfo[$CNF['FIELD_AUTHOR']]); if (isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']])) { $aParams['privacy_view'] = $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]; } bx_alert($this->_oModule->getName(), 'added', $iContentId, false, $aParams); return ''; }
/** * Remove permalink from link. * @param $sLink - relative or absoulte URL. * @param $isStripBaseUrl - strip site prefix (absolute URL) automatically (enabled by default) * @return - relative UNpermalinked URL if it was detected or relative URL if URL withing the site or unchanged URL otherwise. */ function unpermalink($sLink, $isStripBaseUrl = true) { if ($isStripBaseUrl && 0 == strncmp($sLink, BX_DOL_URL_ROOT, strlen(BX_DOL_URL_ROOT))) { $sLink = substr($sLink, strlen(BX_DOL_URL_ROOT)); } $sRet = null; bx_alert('system', 'unpermalink', 0, 0, array('link' => $sLink, 'return_data' => &$sRet)); if (null !== $sRet) { return $sRet; } foreach ($this->aPrefixesPermalink as $sKey => $iLength) { if (strncmp($sLink, $sKey, $iLength) !== 0) { continue; } $sPage = substr($sLink, $iLength); return $this->aLinksPermalink[$sKey]['standard'] . $sPage; } return isset($this->aLinksPermalink[$sLink]) ? $this->aLinksPermalink[$sLink]['standard'] : $sLink; }
function serviceSend($sRecipientEmail, $sMailSubject, $sMailBody, $sMailHeader, $sMailParameters, $isHtml, $aRecipientInfo = array()) { $iRet = true; if ($sRecipientEmail) { $mail = new PHPMailer(true); if ('on' == getParam('bx_smtp_on')) { $mail->IsSMTP(); } //$mail->SMTPDebug = 2; $mail->CharSet = 'utf8'; // smtp server auth or not $mail->SMTPAuth = 'on' == getParam('bx_smtp_auth') ? true : false; // from settings, smtp server secure ssl/tls $sParamSecure = getParam('bx_smtp_secure'); if ('SSL' == $sParamSecure || 'TLS' == $sParamSecure) { $mail->SMTPSecure = strtolower($sParamSecure); } // from settings, smtp server $sParamHost = getParam('bx_smtp_host'); if ($sParamHost) { $mail->Host = $sParamHost; } // smtp port 25, 465 $sParamPort = getParam('bx_smtp_port'); if ((int) $sParamPort > 0) { $mail->Port = $sParamPort; } // from settings, username and passord of smtp server $mail->Username = getParam('bx_smtp_username'); $mail->Password = getParam('bx_smtp_password'); $sParamSender = trim(getParam('bx_smtp_from_email')); if ($sParamSender) { $mail->From = $sParamSender; } else { $mail->From = getParam('site_email_notify'); } // get site name or some other name as sender's name $mail->FromName = getParam('bx_smtp_from_name'); $mail->Subject = $sMailSubject; if ($isHtml) { $mail->Body = $sMailBody; $mail->AltBody = $isHtml ? strip_tags($sMailBody) : $sMailBody; } else { $mail->Body = $sMailBody; } $mail->WordWrap = 50; // set word wrap $mail->AddAddress($sRecipientEmail); // get attachments from attach directory if ('on' == getParam('bx_smtp_send_attachments')) { if ($h = opendir(BX_DIRECTORY_PATH_MODULES . "boonex/smtpmailer/data/attach/")) { while (false !== ($sFile = readdir($h))) { if ($sFile == "." || $sFile == ".." || $sFile[0] == ".") { continue; } $mail->AddAttachment(BX_DIRECTORY_PATH_MODULES . "boonex/smtpmailer/data/attach/" . $sFile, $sFile); } closedir($h); } } $mail->IsHTML($isHtml ? true : false); try { $mail->Send(); } catch (phpmailerException $e) { $iRet = false; $this->log("Mailer Error ({$sRecipientEmail}): " . $e->getMessage()); } } //--- create system event [begin] $aAlertData = array('email' => $sRecipientEmail, 'subject' => $sMailSubject, 'body' => $sMailBody, 'header' => $sMailHeader, 'params' => $sMailParameters, 'recipient' => $aRecipientInfo, 'html' => $isHtml); bx_alert('profile', 'send_mail', $aRecipientInfo ? $aRecipientInfo['ID'] : 0, '', $aAlertData); //--- create system event [ end ] return $iRet; }
protected function changeStatus($sStatus, $sAlertActionName, $iAction, $iProfileId = 0) { if (!$iProfileId) { $iProfileId = $this->_iProfileID; } // get account and profile objects $oProfile = BxDolProfile::getInstance($iProfileId); $oAccount = $oProfile->getAccountObject(); if (!$oProfile || !$oAccount) { return false; } // change status if (!$this->_oQuery->changeStatus($iProfileId, $sStatus)) { return false; } // alert about status changing bx_alert('profile', $sAlertActionName, $iProfileId, false, array('action' => $iAction)); // send email to member about status change sendMailTemplate('t_ChangeStatus' . ucfirst($sStatus), $oAccount->id(), $iProfileId, array('status' => $sStatus), BX_EMAIL_SYSTEM); return true; }
protected function onDataAddAfter($iContentId) { $CNF =& $this->_oModule->_oConfig->CNF; if (!($aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId))) { return MsgBox(_t('_sys_txt_error_occured')); } if (!empty($CNF['OBJECT_METATAGS'])) { bx_import('BxDolMetatags'); $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']); $oMetatags->keywordsAdd($aContentInfo[$CNF['FIELD_ID']], $aContentInfo[$CNF['FIELD_TEXT']]); $oMetatags->locationsAddFromForm($aContentInfo[$CNF['FIELD_ID']], $CNF['FIELD_LOCATION_PREFIX']); } // alert bx_import('BxDolPrivacy'); $aParams = isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]) ? array('privacy_view' => $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]) : array(); bx_alert($this->_oModule->getName(), 'added', $iContentId, false, $aParams); return ''; }
/** * Delete profile. */ function delete($iAccountId = false) { $ID = (int) $iAccountId ? (int) $iAccountId : $this->_iAccountID; $aAccountInfo = $this->_oQuery->getInfoById($ID); if (!$aAccountInfo) { return false; } // create system event before deletion $isStopDeletion = false; bx_alert('account', 'before_delete', $ID, 0, array('stop_deletion' => &$isStopDeletion)); if ($isStopDeletion) { return false; } bx_import('BxDolAccountQuery'); $oAccountQuery = BxDolAccountQuery::getInstance(); bx_import('BxDolProfile'); $oProfileQuery = BxDolProfileQuery::getInstance(); $aProfiles = $oProfileQuery->getProfilesByAccount($ID); foreach ($aProfiles as $iProfileId => $aRow) { $oProfile = BxDolProfile::getInstance($iProfileId); if (!$oProfile) { continue; } $oProfile->delete(false, true); } // delete profile if (!$oAccountQuery->delete($ID)) { return false; } // create system event bx_alert('account', 'delete', $ID); // unset class instance to prevent creating the instance again $this->_iAccountID = 0; $sClass = get_class($this) . '_' . $ID; unset($GLOBALS['bxDolClasses'][$sClass]); return true; }
/** * Create new profile; * * @param : $aProfileInfo (array) - remote profile's information; * * @param : $sAlternativeName (string) - profiles alternative nickname; * @return : error string or error or request invite form or profile info array on success */ function _createProfileRaw($aProfileInfo, $sAlternativeName = '', $isAutoFriends = true, $isSetLoggedIn = true) { // join by invite only if (BxDolRequest::serviceExists('bx_invites', 'account_add_form_check') && ($sCode = BxDolService::call('bx_invites', 'account_add_form_check'))) { return $sCode; } // convert fields to unique format $aFieldsProfile = $aFieldsAccount = $this->_convertRemoteFields($aProfileInfo, $sAlternativeName); if (empty($aFieldsProfile['email'])) { return _t('_Incorrect Email'); } // prepare fields for particular module $aFieldsAccount = BxDolService::call('system', 'prepare_fields', array($aFieldsAccount)); $aFieldsProfile = BxDolService::call($this->_oConfig->sProfilesModule, 'prepare_fields', array($aFieldsProfile)); // check fields existence in Account $oFormHelperAccount = BxDolService::call('system', 'forms_helper'); $oFormAccount = $oFormHelperAccount->getObjectFormAdd(); foreach ($aFieldsAccount as $sKey => $mValue) { if (!$oFormAccount->isFieldExist($sKey)) { unset($aFieldsAccount[$sKey]); } } // check fields existence in Profile if ('system' != $this->_oConfig->sProfilesModule && ($oFormHelperProfile = BxDolService::call($this->_oConfig->sProfilesModule, 'forms_helper'))) { $oFormProfile = $oFormHelperProfile->getObjectFormAdd(); foreach ($aFieldsProfile as $sKey => $mValue) { if (!$oFormProfile->isFieldExist($sKey)) { unset($aFieldsProfile[$sKey]); } } } // antispam check $sErrorMsg = ''; $bSetPendingApproval = false; bx_alert('account', 'check_join', 0, false, array('error_msg' => &$sErrorMsg, 'email' => $aFieldsAccount['email'], 'approve' => &$bSetPendingApproval)); if ($sErrorMsg) { return $sErrorMsg; } // check if user with the same email already exists $oExistingAccount = BxDolAccount::getInstance($aFieldsAccount['email']); // check redirect page if ('join' == $this->_oConfig->sRedirectPage && !$oExistingAccount) { return array('remote_profile_info' => $aProfileInfo, 'profile_fields' => $aFieldsAccount, 'join_page_redirect' => true); } // create new profile if ($oExistingAccount) { if (!($oExistingProfile = BxDolProfile::getInstanceByAccount($oExistingAccount->id()))) { return _t('_sys_txt_error_account_creation'); } $iProfileId = $oExistingProfile->id(); $this->setLogged($iProfileId); } else { // create account $aFieldsAccount['password'] = genRndPwd(); $aFieldsAccount['email_confirmed'] = $this->_oConfig->isAlwaysConfirmEmail; if (!($iAccountId = $oFormAccount->insert($aFieldsAccount))) { return _t('_sys_txt_error_account_creation'); } $isSetPendingApproval = $this->_oConfig->isAlwaysAutoApprove ? false : !(bool) getParam('sys_account_autoapproval'); $iAccountProfileId = $oFormHelperAccount->onAccountCreated($iAccountId, $isSetPendingApproval, BX_PROFILE_ACTION_EXTERNAL); // create profile if (isset($oFormProfile) && $oFormProfile) { $aFieldsProfile['picture'] = $this->_processImage($aFieldsProfile, $iAccountProfileId, $oFormHelperProfile); if (!($iContentId = $oFormProfile->insert($aFieldsProfile))) { return _t('_sys_txt_error_account_creation'); } $oFormHelperProfile->setAutoApproval($oFormHelperProfile->isAutoApproval() ? true : $this->_oConfig->isAlwaysAutoApprove); if ($sErrorMsg = $oFormHelperProfile->onDataAddAfter($iAccountId, $iContentId)) { return $sErrorMsg; } $oProfile = BxDolProfile::getInstanceByAccount($iAccountId); $iProfileId = $oProfile->id(); } else { $iProfileId = $iAccountProfileId; } // send email with password sendMailTemplate($this->_oConfig->sEmailTemplatePasswordGenerated, $iAccountId, $iProfileId, array('password' => $aFieldsAccount['password']), BX_EMAIL_SYSTEM); } // remember remote profile id for created member $this->_oDb->saveRemoteId($iProfileId, $aProfileInfo['id']); // auto-friend members if they are already friends on remote site if ($isAutoFriends && method_exists($this, '_makeFriends')) { $this->_makeFriends($iProfileId); } return array('remote_profile_info' => $aProfileInfo, 'profile_id' => $iProfileId, 'existing_profile' => $oExistingAccount ? true : false); }
/** * Delete data entry * @param $iContentId entry id * @param $oForm optional content info array * @param $aContentInfo optional content info array * @param $oProfile optional content author profile * @return error string on error or empty string on success */ public function deleteData($iContentId, $aContentInfo = false, $oProfile = null, $oForm = null) { $CNF =& $this->_oModule->_oConfig->CNF; if (!$aContentInfo || !$oProfile) { list($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId); } if (!$aContentInfo) { return _t('_sys_txt_error_entry_is_not_defined'); } if (!$oForm) { $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_DELETE'], $this->_oModule->_oTemplate); } if (!$oForm->delete($aContentInfo[$CNF['FIELD_ID']], $aContentInfo)) { return _t('_sys_txt_error_entry_delete'); } if ($sResult = $this->onDataDeleteAfter($aContentInfo[$CNF['FIELD_ID']], $aContentInfo, $oProfile)) { return $sResult; } // create an alert bx_alert($this->_oModule->getName(), 'deleted', $aContentInfo[$CNF['FIELD_ID']]); return ''; }
/** * Add permanent messages which are displayed on every page. */ protected function _addPermanentMessages() { // add account & profile related permament messages if (isLogged()) { $oAccount = BxDolAccount::getInstance(); if ($oAccount) { $oAccount->addInformerPermanentMessages($this); } $oProfile = BxDolProfile::getInstance(); if ($oProfile) { $oProfile->addInformerPermanentMessages($this); } } // add permament messages from modules bx_alert('system', 'informer_permament_messages', 0, false, array('informer' => $this)); }
function onFileDeleted($aFileInfo, $iProfileId) { // TODO: update site quota if (!$this->_oDb->updateStorageObjectQuota(-$aFileInfo['size'], -1)) { $this->setErrorCode(BX_DOL_STORAGE_ERR_DB); return false; } if (!$this->_oDb->updateUserQuota($aFileInfo['profile_id'], -$aFileInfo['size'], -1)) { $this->setErrorCode(BX_DOL_STORAGE_ERR_DB); return false; } $this->setErrorCode(BX_DOL_STORAGE_ERR_OK); $bRet = true; bx_alert($this->_aObject['object'], 'file_deleted', $aFileInfo['id'], $iProfileId, array('file_info' => $aFileInfo, 'return_value' => &$bRet)); return $bRet; }
/** * 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; }
/** * Remove connection. * @param $iInitiator initiator of the connection * @param $iContent connected content or other profile id in case of friends * @return true - if connection was removed, false - if connection isn't exist or error occured */ public function removeConnection($iInitiator, $iContent) { if (!($aConnection = $this->_oQuery->getConnection((int) $iInitiator, (int) $iContent))) { // connection doesn't exist return false; } if (!$this->_oQuery->removeConnection((int) $iInitiator, (int) $iContent)) { return false; } bx_alert($this->_sObject, 'connection_removed', 0, getLoggedId(), array('initiator' => (int) $iInitiator, 'content' => (int) $iContent, 'mutual' => isset($aConnection['mutual']) ? $aConnection['mutual'] : 0, 'object' => $this)); return true; }
protected function onDataAddAfter($iContentId) { $CNF =& $this->_oModule->_oConfig->CNF; if (!($aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId))) { return MsgBox(_t('_sys_txt_error_occured')); } // alert bx_import('BxDolPrivacy'); $aParams = isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]) ? array('privacy_view' => $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]) : array(); bx_alert($this->_oModule->getName(), 'added', $iContentId, false, $aParams); return ''; }