/** * 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); }
function response(&$o) { if ($o->sUnit == 'system') { switch ($o->sAction) { case 'join_after_payment': $this->oModule->processJoinAfterPayment($o); break; } } if ($o->sUnit == 'profile') { switch ($o->sAction) { case 'logout': //delete facebook's session cookie $this->oModule->oFacebook->destroySession(); break; case 'join': bx_import('BxDolSession'); $oSession = BxDolSession::getInstance(); $iFacebookProfileUid = $oSession->getValue($this->oModule->_oConfig->sFacebookSessionUid); if ($iFacebookProfileUid) { $oSession->unsetValue($this->oModule->_oConfig->sFacebookSessionUid); //save Fb's uid $this->oModule->_oDb->saveFbUid($o->iObject, $iFacebookProfileUid); //Auto-friend members if they are already friends on Facebook $this->oModule->_makeFriends($o->iObject); } break; case 'delete': //remove Fb account $this->oModule->_oDb->deleteFbUid($o->iObject); break; default: } } }
function response(&$o) { if ($o->sUnit == 'system') { switch ($o->sAction) { case 'join_after_payment': $this->oModule->processJoinAfterPayment($o); break; } } if ($o->sUnit == 'profile') { switch ($o->sAction) { case 'join': bx_import('BxDolSession'); $oSession = BxDolSession::getInstance(); $iRemoteProfileId = $oSession->getValue($this->oModule->_oConfig->sSessionUid); if ($iRemoteProfileId) { $oSession->unsetValue($this->oModule->_oConfig->sSessionUid); // save remote profile id $this->oModule->_oDb->saveRemoteId($o->iObject, $iRemoteProfileId); } break; case 'delete': // remove remote account $this->oModule->_oDb->deleteRemoteAccount($o->iObject); break; } } }
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; }
public function serviceGetLiveUpdatesComments($sSystem, $iContentId, $iProfileId, $iCount = 0) { $oCmts = BxDolCmts::getObjectInstance($sSystem, $iContentId); if (!$oCmts || !$oCmts->isEnabled()) { return false; } $sKey = $oCmts->getNotificationId(); bx_import('BxDolSession'); if ((int) BxDolSession::getInstance()->getValue($sKey) == 1) { return false; } $iCountNew = $oCmts->getCommentsCount($iContentId, -1, BX_CMT_FILTER_OTHERS); if ($iCountNew <= $iCount) { return false; } return array('count' => $iCountNew, 'method' => $oCmts->getJsObjectName() . '.showLiveUpdate(oData)', 'data' => array('code' => $oCmts->getNotification($iCount, $iCountNew))); }
/** * Overwtire the method of parent class. * * @param BxDolAlerts $oAlert an instance of alert. */ public function response($oAlert) { if ($oAlert->sUnit != 'account' || !in_array($oAlert->sAction, array('login'))) { return; } $sDomain = BxDolSession::getInstance()->getUnsetValue('bx_sites_domain'); if ($sDomain === false) { return; } $iAccountId = $this->_oModule->_oDb->insertAccount(array('owner_id' => $oAlert->iObject, 'domain' => $sDomain, 'created' => time(), 'status' => BX_SITES_ACCOUNT_STATUS_UNCONFIRMED)); if (!$iAccountId) { return; } $oAccount = $this->_oModule->getObject('Account'); $oAccount->onAccountCreated($iAccountId); $sUrl = $this->_oModule->startSubscription($iAccountId); header('Location: ' . $sUrl); exit; }
public function response($o) { if ($o->sUnit == 'profile') { switch ($o->sAction) { case 'delete': // remove remote account $this->oModule->_oDb->deleteRemoteAccount($o->iObject); break; case 'add': // add remote account and local profile association bx_import('BxDolSession'); $oSession = BxDolSession::getInstance(); $iRemoteProfileId = $oSession->getValue($this->oModule->_oConfig->sSessionUid); if ($iRemoteProfileId) { $oSession->unsetValue($this->oModule->_oConfig->sSessionUid); $this->oModule->_oDb->saveRemoteId($o->iObject, $iRemoteProfileId); } break; } } }
function response(&$o) { if ($o->sUnit == 'profile') { switch ($o->sAction) { case 'logout': $aCookies = array('user', 'session_key', 'expires', 'ss'); foreach ($aCookies as $sName) { $sCookieName = $this->oModule->_oConfig->mApiKey . '_' . $sName; if (isset($_COOKIE[$sCookieName])) { setcookie($sCookieName, '', time() - 96 * 3600, '/'); unset($_COOKIE[$sCookieName]); } } setcookie($this->oModule->_oConfig->mApiKey, '', time() - 96 * 3600, '/'); unset($_COOKIE[$this->oModule->_oConfig->mApiKey]); break; case 'join': bx_import('BxDolSession'); $oSession = BxDolSession::getInstance(); $iFacebookProfileUid = $oSession->getValue($this->oModule->_oConfig->sFacebookSessionUid); if ($iFacebookProfileUid) { $oSession->unsetValue($this->oModule->_oConfig->sFacebookSessionUid); //save Fb's uid $this->oModule->_oDb->saveFbUid($o->iObject, $iFacebookProfileUid); //Auto-friend members if they are already friends on Facebook $this->oModule->_makeFriends($o->iObject); } break; case 'delete': //remove Fb account $this->oModule->_oDb->deleteFbUid($o->iObject); break; default: } } }
function init(&$oDb) { $this->_oDb =& $oDb; $this->_oSession = BxDolSession::getInstance(); $this->_bEnabled = getParam('bx_sctr_enable') == 'on'; }
/** * get join page * * @param $aProfileFields array * @param $iFacebookUserId integer * @return void */ function _getJoinPage($aProfileFields, $iFacebookUserId) { bx_import('BxDolSession'); $oSession = BxDolSession::getInstance(); $oSession->setValue($this->_oConfig->sFacebookSessionUid, $iFacebookUserId); bx_import("BxDolJoinProcessor"); $GLOBALS['oSysTemplate']->addJsTranslation('_Errors in join form'); $GLOBALS['oSysTemplate']->addJs(array('join.js', 'jquery.form.js')); $oJoin = new BxDolJoinProcessor(); //process recived fields foreach ($aProfileFields as $sFieldName => $sValue) { $oJoin->aValues[0][$sFieldName] = $sValue; } $this->_oTemplate->getPage(_t('_JOIN_H'), $oJoin->process()); exit; }
/** * Get join page * * @param $aProfileFields array * @param $iRemoteProfileId remote profile id * @return void */ function _getJoinPage($aProfileFields, $iRemoteProfileId) { bx_import('BxDolSession'); $oSession = BxDolSession::getInstance(); $oSession->setValue($this->_oConfig->sSessionUid, $iRemoteProfileId); bx_import("BxDolJoinProcessor"); $GLOBALS['oSysTemplate']->addJs(array('join.js', 'jquery.form.min.js')); $oJoin = new BxDolJoinProcessor(); // process received fields foreach ($aProfileFields as $sFieldName => $sValue) { $oJoin->aValues[0][$sFieldName] = $sValue; } $this->_oTemplate->getPage(_t('_JOIN_H'), $this->_oTemplate->parseHtmlByName('default_padding.html', array('content' => $oJoin->process()))); exit; }
/** * Get join page * * @param $aProfileFields array * @param $iRemoteProfileId remote profile id * @return void */ function _getJoinPage($aProfileFields, $iRemoteProfileId) { bx_import('BxDolSession'); $oSession = BxDolSession::getInstance(); $oSession->setValue($this->_oConfig->sSessionUid, $iRemoteProfileId); $oPage = BxDolPage::getObjectInstanceByURI('create-account'); BxBaseAccountForms::$PROFILE_FIELDS = $aProfileFields; $this->_oTemplate->getPage(false, $oPage->getCode()); }
function checkCaptcha($s) { // init captcha object bx_import('BxDolCaptcha'); $oCaptcha = BxDolCaptcha::getObjectInstance(); if (!$oCaptcha) { return false; } // try to get "cached" value bx_import('BxDolSession'); $oSession = BxDolSession::getInstance(); $sSessKey = 'captcha-' . $oCaptcha->getUserResponse(); if ($iSessVal = $oSession->getValue($sSessKey)) { $oSession->setValue($sSessKey, --$iSessVal); return true; } // perform captcha check if (!$oCaptcha->check()) { return false; } // "cache" success result (need for repeated AJAX submittions, since origonal captcha can't perform duplicate checking) bx_import('BxDolSession'); $oSession = BxDolSession::getInstance(); $oSession->setValue($sSessKey, 3); return true; }
public static function getCsrfTokenTime() { $oSession = BxDolSession::getInstance(); return $oSession->getValue('csrf_token_time'); }
***************************************************************************/ require_once '../inc/header.inc.php'; require_once BX_DIRECTORY_PATH_INC . 'profiles.inc.php'; require_once BX_DIRECTORY_PATH_INC . 'images.inc.php'; ob_start(); $chars = array("a", "b", "c", "d", "e", "f", "h", "i", "k", "m", "n", "o", "r", "s", "t", "u", "v", "w", "x", "z", "2", "3", "4", "5", "6", "7", "8", "9"); /* $chars = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J", "k","K","L","m","M","n","N","o","p","P","q","Q","r","R","s","S","t","T", "u","U","v","V","w","W","x","X","y","Y","z","Z","2","3","4","5","6","7","8","9"); */ $textstr = ''; for ($i = 0, $length = 6; $i < $length; $i++) { $textstr .= $chars[rand(0, count($chars) - 1)]; } $hashtext = md5($textstr); bx_import('BxDolSession'); $oSession = BxDolSession::getInstance(); $oSession->setValue('strSec', $hashtext); if (produceSecurityImage($textstr, $hashtext) != IMAGE_ERROR_SUCCESS) { // output header header("Content-Type: image/gif"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); // output error image @readfile($dir['profileImage'] . 'simg_error.gif'); } ob_end_flush();
/** * Logout user by removing cookies */ function bx_logout($bNotify = true) { if ($bNotify && isMember()) { bx_alert('account', 'logout', (int) $_COOKIE['memberID']); } $aUrl = parse_url(BX_DOL_URL_ROOT); $sPath = isset($aUrl['path']) && !empty($aUrl['path']) ? $aUrl['path'] : '/'; setcookie('memberID', '', time() - 96 * 3600, $sPath); setcookie('memberPassword', '', time() - 96 * 3600, $sPath); unset($_COOKIE['memberID']); unset($_COOKIE['memberPassword']); bx_import('BxDolSession'); BxDolSession::getInstance()->destroy(); }
/** * Perform neccessary checking on join form * @return empty string - if join is allowed and shoulb be processed as usual, non-empty string - if join form need to be replaced with this code */ public function serviceAccountAddFormCheck() { if (!$this->_oConfig->isRegistrationByInvitation()) { return ''; } $oSession = BxDolSession::getInstance(); $sKeyCode = $this->_oConfig->getKeyCode(); if (bx_get($sKeyCode) !== false) { $sKey = bx_process_input(bx_get($sKeyCode)); $oKeys = BxDolKey::getInstance(); if ($oKeys && $oKeys->isKeyExists($sKey)) { $oSession->setValue($sKeyCode, $sKey); } } $sKey = $oSession->getValue($sKeyCode); if ($sKey === false) { return $this->_oTemplate->getBlockRequest(); } return ''; }
protected function _setUserChoice($sDp, $sBpType, $sBpFilter) { if (!isLogged()) { return; } $iUserId = $this->_getAuthorId(); $oSession = BxDolSession::getInstance(); if (!empty($sDp)) { $oSession->setValue($this->_sDpSessionKey . $iUserId, $sDp); } if (!empty($sBpType)) { $oSession->setValue($this->_sBpSessionKeyType . $iUserId, $sBpType); } if (!empty($sBpFilter)) { $oSession->setValue($this->_sBpSessionKeyFilter . $iUserId, $sBpFilter); } }
protected function _getIndex() { bx_import('BxDolSession'); $oSession = BxDolSession::getInstance(); $iIndex = (int) $oSession->getValue($this->_sSessionKey); $oSession->setValue($this->_sSessionKey, $iIndex + 1); return $iIndex; }
static function getAuthorizedClient() { return (int) BxDolSession::getInstance()->getValue('sys_oauth_authorized_user'); }
protected function setItems($sItems) { $oSession = BxDolSession::getInstance(); $oSession->setValue($this->sSessionKey, $sItems); }
function checkCaptcha($mValue) { bx_import('BxDolSession'); $oSession = BxDolSession::getInstance(); $mixedValue = $oSession->getValue('strSec'); return $mixedValue !== false && $mixedValue === md5($mValue); }
function clean_database() { $db_clean_vkiss = (int) getParam("db_clean_vkiss"); $db_clean_profiles = (int) getParam("db_clean_profiles"); $db_clean_msg = (int) getParam("db_clean_msg"); $db_clean_visits = (int) getParam("db_clean_members_visits"); $db_clean_banners_info = (int) getParam("db_clean_banners_info"); //clear from `sys_banners_shows` if (db_res("DELETE FROM `sys_banners_shows` WHERE `Date` < UNIX_TIMESTAMP( NOW() - INTERVAL {$db_clean_banners_info} DAY )")) { db_res("OPTIMIZE TABLE `sys_banners_shows`"); } //clear from `sys_banners_clicks` if (db_res("DELETE FROM `sys_banners_clicks` WHERE `Date` < UNIX_TIMESTAMP( NOW() - INTERVAL {$db_clean_banners_info} DAY )")) { db_res("OPTIMIZE TABLE `sys_banners_clicks`"); } // clear from `sys_messages` if (db_res("DELETE FROM `sys_messages` WHERE FIND_IN_SET('sender', `Trash`) AND FIND_IN_SET('recipient', `Trash`)")) { db_res("OPTIMIZE TABLE `sys_messages`"); } //clear from `sys_ip_members_visits` if (db_res("DELETE FROM `sys_ip_members_visits` WHERE `DateTime` < NOW() - INTERVAL {$db_clean_visits} DAY")) { db_res("OPTIMIZE TABLE `sys_ip_members_visits`"); } // clear ban table if (db_res("DELETE FROM `sys_admin_ban_list` WHERE `DateTime` + INTERVAL `Time` SECOND < NOW()")) { db_res("OPTIMIZE TABLE `sys_admin_ban_list`"); } // profile_delete if ($db_clean_profiles > 0) { $res = db_res("SELECT `ID` FROM `Profiles` WHERE (`DateLastNav` < NOW() - INTERVAL {$db_clean_profiles} DAY) AND (`Couple` > `ID` OR `Couple` = 0)"); if ($res) { $db_clean_profiles_num = mysql_num_rows($res); while ($arr = mysql_fetch_array($res)) { profile_delete($arr['ID']); } db_res("OPTIMIZE TABLE `Profiles`"); } } if ($db_clean_vkiss > 0) { $res = db_res("DELETE FROM `sys_greetings` WHERE `When` < NOW() - INTERVAL {$db_clean_vkiss} DAY"); if ($res) { $db_clean_vkiss_num = db_affected_rows(); db_res("OPTIMIZE TABLE `sys_greetings`"); } } if ($db_clean_msg > 0) { $res = db_res("DELETE FROM `sys_messages` WHERE `Date` < NOW() - INTERVAL {$db_clean_msg} DAY"); if ($res) { $db_clean_msg_num = db_affected_rows(); db_res("OPTIMIZE TABLE `sys_messages`"); } } //--- Clean sessions ---// bx_import('BxDolSession'); $oSession = BxDolSession::getInstance(); $iSessions = $oSession->oDb->deleteExpired(); // clean expired ip bans bx_import('BxDolAdminIpBlockList'); $oBxDolAdminIpBlockList = new BxDolAdminIpBlockList(); $iIps = $oBxDolAdminIpBlockList->deleteExpired(); // clean old views bx_import('BxDolViews'); $oBxViews = new BxDolViews('', 0); $iDeletedViews = $oBxViews->maintenance(); // clean old votes bx_import('BxDolVoting'); $oBxVotes = new BxDolVoting('', 0); $iDeletedVotes = $oBxVotes->maintenance(); echo "\n- Database cleaning -\n"; echo "Deleted profiles: {$db_clean_profiles_num}\n"; echo "Deleted virtual kisses: {$db_clean_vkiss_num}\n"; echo "Deleted messages: {$db_clean_msg_num}\n"; echo "Deleted sessions: {$iSessions}\n"; echo "Deleted records from ip block list: {$iIps}\n"; echo "Deleted views: {$iDeletedViews}\n"; echo "Deleted votes: {$iDeletedVotes}\n"; }
function bx_logout($bNotify = true) { if ($bNotify && isMember()) { require_once BX_DIRECTORY_PATH_CLASSES . 'BxDolAlerts.php'; $oZ = new BxDolAlerts('profile', 'logout', (int) $_COOKIE['memberID']); $oZ->alert(); } $aUrl = parse_url($GLOBALS['site']['url']); $sPath = isset($aUrl['path']) && !empty($aUrl['path']) ? $aUrl['path'] : '/'; setcookie('memberID', '', time() - 96 * 3600, $sPath); setcookie('memberPassword', '', time() - 96 * 3600, $sPath); unset($_COOKIE['memberID']); unset($_COOKIE['memberPassword']); bx_import('BxDolSession'); BxDolSession::getInstance()->destroy(); if (ini_get('session.use_cookies')) { $aParams = session_get_cookie_params(); setcookie(session_name(), '', time() - 96 * 3600, $aParams['path'], $aParams['domain'], $aParams['secure'], $aParams['httponly']); } if (version_compare(PHP_VERSION, '5.4.0') >= 0 && PHP_SESSION_ACTIVE == session_status()) { session_destroy(); } }
function getPageMainCode() { $oTemplate = BxDolStudioTemplate::getInstance(); $oTemplate->addJs(array('jquery.form.min.js')); $oTemplate->addCss(array('splash.css')); $oForm = new BxDolSplashForm($oTemplate); $oForm->initChecker(); if ($oForm->isSubmittedAndNotValid()) { $oForm->_echoResultJson(array('err' => $oForm->getNotValid()), true); exit; } if ($oForm->isSubmittedAndValid()) { $sDomainKey = 'domain'; $sDomainValue = $oForm->getCleanValue($sDomainKey); if (!BxDolRequest::serviceExists('bx_sites', 'is_used')) { $oForm->_echoResultJson(array('msg' => _t('_sys_splash_err_service_not_available')), true); exit; } if (BxDolService::call('bx_sites', 'is_used', array($sDomainValue))) { $oForm->_echoResultJson(array('err' => array($sDomainKey => _t('_sys_splash_err_domain_is_used'))), true); exit; } bx_import('BxDolSession'); BxDolSession::getInstance()->setValue('bx_sites_domain', $sDomainValue); bx_import('BxDolPermalinks'); $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=create-account'); $oForm->_echoResultJson(array('eval' => 'window.open(\'' . $sUrl . '\', \'_self\');'), true); exit; } return $oTemplate->parseHtmlByName('splash.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode())); }
protected function _getCsrfToken() { $oSession = BxDolSession::getInstance(); return $oSession->getValue('bx_tricon_csrf_token'); }
protected function processServerError($aResult) { $iCode = $aResult[$this->sErrorCode]; $sMessage = $aResult[$this->sErrorMessage]; switch ($iCode) { case '8': case '16': case '32': case '64': case '256': case '1024': case '2048': bx_import('BxDolSession'); $this->oSession = BxDolSession::getInstance(); $this->oSession->unsetValue('sys_oauth_token'); $this->oSession->unsetValue('sys_oauth_secret'); $this->oSession->unsetValue('sys_oauth_authorized'); $this->oSession->unsetValue('sys_oauth_authorized_user'); break; } return $sMessage; }
/** * * Private Methods of Common Usage * */ function _onProfileJoin($iProfileId) { $oSession = BxDolSession::getInstance(); $iPendingId = (int) $oSession->getValue($this->_sSessionKeyPending); if (empty($iProfileId) || empty($iPendingId)) { return; } $aPending = $this->_oDb->getPending(array('type' => 'id', 'id' => $iPendingId)); if (empty($aPending) || isset($aPending['client_id']) && (int) $aPending['client_id'] != 0) { return; } if (!$this->_oDb->updatePending($iPendingId, array('client_id' => $iProfileId))) { return; } $this->_oCart->updateInfo($iPendingId); $oSession->unsetValue($this->_sSessionKeyPending); }