/** * Привязать телефон к аккаунту. */ function SafetyPhoneNow() { session_start(); return; // #0019588 $aRes = array('success' => false); if (trim($_POST['phone']) == '') { $aRes['error'] = iconv('CP1251', 'UTF-8', 'Вы должны ввести номер телефона'); } else { $users = new users(); $sPhone = change_q(stripslashes($_POST['phone']), true); $aPhone = $users->CheckSafetyPhone($sPhone); if ($aPhone['error_flag'] == 1) { $aRes['error'] = iconv('CP1251', 'UTF-8', $aPhone['alert'][2]); } elseif (isset($_SESSION['uid'])) { $sPhoneOnly = $_POST['phone_only'] == 't' ? 't' : 'f'; if ($users->updateSafetyPhone($_SESSION['uid'], $sPhone, $sPhoneOnly)) { $aRes['success'] = true; } } } echo json_encode($aRes); }
function unauthCodeSMS($code) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/sms_gate_a1.php'; $objResponse = new xajaxResponse(); $uid = get_uid(); $reqv = sbr_meta::getUserReqvs($uid); $ureqv = $reqv[$reqv['form_type']]; $sms_gate = new sms_gate_a1($ureqv['mob_phone']); $info = $sms_gate->getInfoSend(); if ($info['data'] == $code) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/users.php'; $user = new users(); sbr_meta::authMobPhone($uid, false); sbr_meta::safetyMobPhone($uid, false); $user->updateSafetyPhone($uid, false); $html = '<a href="javascript:void(0)" class="b-button b-button_rectangle_color_transparent b-button_margtop_-2" data-send="safety"><span class="b-button__b1"><span class="b-button__b2"><span class="b-button__txt">Активировать</span></span></span></a>'; if ($_SESSION['is_verify'] != 't') { $mobphone = "\$('safety_mob_phone').removeClass('b-combo__input_disabled'); \$('safety_mob_phone').getElement('input').set('disabled', false);"; } else { $mobphone = ''; } $objResponse->script("\$('auth_popup').set('html', '').hide();\n \$\$('.c_sms_main').set('html', '{$html}');\n \$\$('.safety_phone_checks').each( function(el) {\n \$(el).getElements('input[type=checkbox]').set('disabled', true).set('checked', false);\n });\n {$mobphone}\n \$('safety_status').set('html', 'выключена');\n \$('safety_status').addClass('b-layout__txt_color_c10600').removeClass('b-layout__txt_color_6bb336');\n bindLinkActivateAuth();\n "); return $objResponse; } }
} break; case "save_safety": require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/sbr.php"; $post_safety_phone = true; $uid = get_uid(false); $code = __paramInit('int', null, 'smscode'); $phone = $ureqv['mob_phone']; $user = new users(); $only_phone = __paramInit('string', NULL, 'only_phone', 'f'); $finance_safety_phone = __paramInit('string', NULL, 'finance_safety_phone', 'f'); if (($o_only_phone == 't' || $reqv['is_safety_mob'] == 't') && $code == $_SESSION['send_sms_code'] && $phone == $_SESSION['send_sms_phone']) { $safety_complete = true; $o_only_phone = $only_phone; $reqv['is_safety_mob'] = $finance_safety_phone; $user->updateSafetyPhone($uid, $only_phone == 't' ? true : false); sbr_meta::safetyMobPhone($uid, $finance_safety_phone == 't' ? true : false); unset($_SESSION['send_sms_code'], $_SESSION['send_sms_phone']); } elseif ($o_only_phone == 't' && $o_only_phone != $only_phone || $reqv['is_safety_mob'] == 't' && $reqv['is_safety_mob'] != $finance_safety_phone) { $error_phone['code'] = true; } // Включение, без проверки СМС if ($o_only_phone == 'f' && $only_phone == 't' && !$safety_complete) { $o_only_phone = 't'; $user->updateSafetyPhone($uid, true); } if ($reqv['is_safety_mob'] == 'f' && $finance_safety_phone == 't' && !$safety_complete) { $reqv['is_safety_mob'] = 't'; sbr_meta::safetyMobPhone($uid, true); } break;
function checkCode($phone, $code, $type = "bind") { $objResponse = new xajaxResponse(); $success = 0; $reqv = sbr_meta::getUserReqvs(get_uid(false)); $ureqv = $reqv[$reqv['form_type']]; $uid = get_uid(false); if ($type == 'unbind') { $phone = $ureqv['mob_phone']; } $error = false; if ($code == $_SESSION['send_sms_code'] && $phone == $_SESSION['send_sms_phone']) { unset($_SESSION['send_sms_code'], $_SESSION['send_sms_phone']); $user = new users(); $ureqv['mob_phone'] = $phone; $save_reqv['mob_phone'] = $phone; if ($type == 'bind') { if (!($text_error = sbr_meta::setUserReqv($uid, $reqv['rez_type'], $reqv['form_type'], $save_reqv))) { sbr_meta::authMobPhone($uid, true); $reqv['is_activate_mob'] = 't'; unset($_SESSION["unbind_phone_action"]); unset($_SESSION['send_sms_time']); $success = 2; } else { $error = current($text_error); // Телефон забит } } else { if ($type == 'unbind') { // Сбрасываем все $phone = ''; $save_reqv['mob_phone'] = ''; $ureqv['mob_phone'] = ''; sbr_meta::setUserReqv($uid, $reqv['rez_type'], $reqv['form_type'], $save_reqv); // Удаляем телефон sbr_meta::authMobPhone($uid, false); sbr_meta::safetyMobPhone($uid, false); $user->updateSafetyPhone($uid, false); $reqv['is_activate_mob'] = 'f'; $_SESSION["unbind_phone_action"] = true; $success = 3; } } } else { $error = 'Неправильный код'; } switch ($success) { case 2: //Прицепили телефон $objResponse->script("\$('safety_status')" . ".set('text', 'включена')" . ".removeClass('b-layout__txt_color_c10600')" . ".addClass('b-layout__txt_color_6db335');"); $objResponse->script("\$('mob_phone_text').set('html', " . "'<a href=\"javascript:void(0)\" onclick=\"User_Phone.unbindStart();\" " . "class=\"b-layout__link b-layout__link_fontsize_11 b-layout__link_bordbot_dot_0f71c8\">Отвязать</a>')"); $objResponse->script("\$('mob_phone_text').removeClass('b-layout__txt_hide')"); $objResponse->script("\$('mob_code_block').addClass('b-layout__txt_hide');"); $objResponse->script("\$('buttons_step1').addClass('b-layout__txt_hide');"); $objResponse->script("\$('buttons_step2').removeClass('b-layout__txt_hide');"); break; case 3: //Отцепили телефон $objResponse->script("\$('safety_status')" . ".set('text', 'выключена')" . ".removeClass('b-layout__txt_color_6db335')" . ".addClass('b-layout__txt_color_c10600');"); $objResponse->script("\$('mob_phone_text').set('text', 'без пробелов и дефиса')"); $objResponse->script("\$('sms_sent_ok').addClass('b-layout__txt_hide');"); $objResponse->script("\$('smscode').set('value', '');"); $objResponse->script("\$('buttons_step1').removeClass('b-layout__txt_hide');"); $objResponse->script("\$('buttons_step3').addClass('b-layout__txt_hide');"); break; case 0: default: $objResponse->script("\$('smscode').getParent().addClass('b-combo__input_error');"); } if ($error) { $objResponse->script("\$('sms_error').set('html', '{$error}').removeClass('b-layout__txt_hide');"); } else { $objResponse->script("\$('sms_error').addClass('b-layout__txt_hide');"); } $objResponse->script("shadow_center();"); return $objResponse; }