| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/ |
|---|
| 4 | * CC-BY License - http://creativecommons.org/licenses/by/3.0/ |
|---|
| 5 | * |
|---|
| 6 | * @defgroup DolphinCore Dolphin Core |
|---|
| 7 | * @{ |
|---|
| 8 | */ |
|---|
| 9 | |
|---|
| 10 | require_once('./inc/header.inc.php'); |
|---|
| 11 | require_once(BX_DIRECTORY_PATH_INC . "params.inc.php"); |
|---|
| 12 | require_once(BX_DIRECTORY_PATH_INC . "design.inc.php"); |
|---|
| 13 | |
|---|
| 14 | bx_import('BxDolLanguages'); |
|---|
| 15 | |
|---|
| 16 | if (isset($_POST['ID'])) { // login form is submitted |
|---|
| 17 | |
|---|
| 18 | bx_import ('BxDolForm'); |
|---|
| 19 | $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login'); |
|---|
| 20 | |
|---|
| 21 | bx_alert('profile', 'before_login', 0, 0, array('form' => $oForm)); |
|---|
| 22 | |
|---|
| 23 | $oForm->initChecker(); |
|---|
| 24 | $oForm->setRole(bx_get('role')); |
|---|
| 25 | $bLoginSuccess = $oForm->isSubmittedAndValid(); |
|---|
| 26 | |
|---|
| 27 | $bAjxMode = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') ? true : false; |
|---|
| 28 | if ($bAjxMode) { |
|---|
| 29 | |
|---|
| 30 | header( 'Content-type: text/html; charset=utf-8' ); |
|---|
| 31 | echo $bLoginSuccess ? 'OK' : $oForm->getLoginError(); |
|---|
| 32 | exit; |
|---|
| 33 | |
|---|
| 34 | } elseif ($bLoginSuccess) { |
|---|
| 35 | |
|---|
| 36 | bx_import('BxDolAccount'); |
|---|
| 37 | $oAccount = BxDolAccount::getInstance($oForm->getCleanValue('ID')); |
|---|
| 38 | $aAccount = bx_login($oAccount->id(), ($oForm->getCleanValue('rememberMe') ? true : false)); |
|---|
| 39 | |
|---|
| 40 | // Storing IP Address // TODO: move somewhere |
|---|
| 41 | if (getParam('enable_member_store_ip') == 'on') { |
|---|
| 42 | $iCurLongIP = sprintf("%u", ip2long(getVisitorIP())); |
|---|
| 43 | db_res("INSERT INTO `sys_ip_members_visits` SET `MemberID` = '{$aAccount['id']}', `From`='{$iCurLongIP}', `DateTime`=NOW()"); |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | $sUrlRelocate = $oForm->getCleanValue('relocate'); |
|---|
| 47 | if (!$sUrlRelocate || BX_DOL_URL_ROOT == $sUrlRelocate || basename($sUrlRelocate) == 'join.php' || 0 != strncmp($sUrlRelocate, BX_DOL_URL_ROOT, strlen(BX_DOL_URL_ROOT))) |
|---|
| 48 | $sUrlRelocate = BX_DOL_ROLE_ADMIN == $oForm->getRole() ? BX_DOL_URL_STUDIO . 'launcher.php' : BX_DOL_URL_ROOT . 'member.php'; |
|---|
| 49 | |
|---|
| 50 | bx_import('BxDolTemplate'); |
|---|
| 51 | BxDolTemplate::getInstance()->setPageNameIndex (BX_PAGE_TRANSITION); |
|---|
| 52 | BxDolTemplate::getInstance()->setPageHeader (_t('_Please Wait')); |
|---|
| 53 | BxDolTemplate::getInstance()->setPageContent ('page_main_code', MsgBox(_t('_Please Wait'))); |
|---|
| 54 | BxDolTemplate::getInstance()->setPageContent ('url_relocate', bx_html_attribute($sUrlRelocate, BX_ESCAPE_STR_QUOTE)); |
|---|
| 55 | |
|---|
| 56 | BxDolTemplate::getInstance()->getPageCode(); |
|---|
| 57 | exit; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | bx_require_authentication(); |
|---|
| 63 | |
|---|
| 64 | bx_import('BxDolPermalinks'); |
|---|
| 65 | header('Location: ' . BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=account-settings-info')); |
|---|
| 66 | |
|---|
| 67 | /** @} */ |
|---|
| 68 | |
|---|