Browse Source

steam auth

master
gsd 3 years ago
parent
commit
9c56fa5a41
  1. 13
      index.html
  2. 7
      site_content/js/API.js
  3. 37
      site_content/js/Player_API.js

13
index.html

@ -208,8 +208,8 @@ transition: background-image 1s;" id="main_container">
<br> <br>
<div class="row row-cols-3 justify-content-center" id="Section_VIP_buttons"> <div class="row row-cols-3 justify-content-center" id="Section_VIP_buttons">
<div class="col-8 justify-content-center" id="Section_VIP_check_profile"> <div class="col-8 justify-content-center" id="Section_VIP_check_profile">
<a href=# onclick="document.getElementById('Tab_Profile_Button').click();"> <a href=# onclick="document.getElementById('Header_CurrentUser').click();">
<h3>Чтоб увидить цены, сначала введи профиль (>ТЫК<)</h3> <h3>Чтоб увидить цены, сначала авторизируйся через стим</h3>
</a> </a>
</div> </div>
<!----> <!---->
@ -251,8 +251,9 @@ transition: background-image 1s;" id="main_container">
</div> </div>
<div class="row row-cols-1 justify-content-center" id="profile_list"> <div class="row row-cols-1 justify-content-center" id="profile_list">
<div class="col-6 text-center rounded border border-dark p-4" style="background-color: #E2EFDE;" id="profile_check"> <div class="col-6 text-center rounded border border-dark p-4" style="background-color: #E2EFDE;" id="profile_check">
<h2>Проверь свой профиль на фактах!</h2> <h2>Проверь профиль на фактах!</h2>
<h6>На этой странице после ввода твоего профиля, появится вся твоя статистика на фактах, наличие банов и их история, а так-же возможность купить випку!</h6> <h6>На этой странице после ввода профиля, появится вся статистика на фактах, наличие банов и их история.</h6>
<h6>Если авторизоваться, то сразу будет твой профиль</h6>
<form id="formProfileSectionInput" action="#check"> <form id="formProfileSectionInput" action="#check">
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-4"> <div class="col-4">
@ -501,8 +502,8 @@ transition: background-image 1s;" id="main_container">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
integrity="sha384-VHvPCCyXqtD5DqJeNxl2dtTyhF78xXNXdkwX1CZeRusQfRKp+tA7hAShOK/B/fQ2" integrity="sha384-VHvPCCyXqtD5DqJeNxl2dtTyhF78xXNXdkwX1CZeRusQfRKp+tA7hAShOK/B/fQ2"
crossorigin="anonymous"></script> crossorigin="anonymous"></script>
<script type="text/javascript" src="site_content/js/API.js?version=6.66v4"></script> <script type="text/javascript" src="site_content/js/API.js?version=6.66v5"></script>
<script type="text/javascript" src="site_content/js/Player_API.js?version=1.75"></script> <script type="text/javascript" src="site_content/js/Player_API.js?version=1.76"></script>
<script type="text/javascript" src="site_content/js/VIP_API.js?version=1.3"></script> <script type="text/javascript" src="site_content/js/VIP_API.js?version=1.3"></script>
<script type="text/javascript" src="site_content/js/BackgroundSlides.js?version=9.6"></script> <script type="text/javascript" src="site_content/js/BackgroundSlides.js?version=9.6"></script>
</body> </body>

7
site_content/js/API.js

@ -19,11 +19,12 @@
</div> </div>
</div> </div>
*/ */
const Keys = { Enter: 13 };
$(async function() { $(async function() {
$(document).on("keypress", "input", function (e) { $(document).on("keypress", "input", function (e) {
var code = e.keyCode || e.which; var code = e.keyCode || e.which;
if (code == 13) { if (code === Keys.Enter) {
e.preventDefault(); e.preventDefault();
return false; return false;
} }
@ -35,6 +36,7 @@ $(async function() {
await RequestAPI(); await RequestAPI();
if(window.location.href.endsWith("#RulesSection")){ if(window.location.href.endsWith("#RulesSection")){
// trigger event click
document.getElementById('Rules_Button').click(); document.getElementById('Rules_Button').click();
} }
@ -76,7 +78,7 @@ let invalid_captcha = `
<h1 style="color: red">ДЯДЯ ТЫ ДУРАЧЕК, КАПЧА НЕПРАВИЛЬНАЯ, ЖМИ СНОВА НА КНОПКУ</h1> <h1 style="color: red">ДЯДЯ ТЫ ДУРАЧЕК, КАПЧА НЕПРАВИЛЬНАЯ, ЖМИ СНОВА НА КНОПКУ</h1>
</div> </div>
` `
// use templates
function generate_server_card_div(data){ function generate_server_card_div(data){
return ` return `
<div class="col-auto justify-content-center align-self-center" style="padding: 1rem;"> <div class="col-auto justify-content-center align-self-center" style="padding: 1rem;">
@ -116,6 +118,7 @@ async function RequestAPI() {
.then(res => res.json()) .then(res => res.json())
.then(res => { .then(res => {
FillServices(res); FillServices(res);
// $('#current_players').text(res.servers.statistic.player_now)
document.getElementById("current_players").innerHTML = res.servers.statistic.player_now; document.getElementById("current_players").innerHTML = res.servers.statistic.player_now;
document.getElementById("max_per_day").innerHTML = res.servers.statistic.player_max; document.getElementById("max_per_day").innerHTML = res.servers.statistic.player_max;
document.getElementById("servers_works").innerHTML = res.servers.statistic.working_servers + '/' + res.servers.statistic.total_servers; document.getElementById("servers_works").innerHTML = res.servers.statistic.working_servers + '/' + res.servers.statistic.total_servers;

37
site_content/js/Player_API.js

@ -15,12 +15,14 @@ async function CheckCurrentUser(){
var logout = document.getElementById("Header_Logout"); var logout = document.getElementById("Header_Logout");
current_user.href = "#"; current_user.href = "#";
if (response.ban) { if (response.ban) {
current_user.innerHTML = `Привет ${response.steam_data.nickname}! У меня хорошие новости!` current_user.innerHTML = `Привет ${response.steam_data.nickname}! У меня хорошие новости!`;
current_ban.innerHTML = "У тебя БАН! (нажми чтоб посмотреть его)"; current_ban.innerHTML = "У тебя БАН! (нажми чтоб посмотреть его)";
} else { } else {
current_user.innerHTML = `Привет ${response.steam_data.nickname}!` current_user.innerHTML = `Привет ${response.steam_data.nickname}!`;
} }
logout.innerHTML = ` (нажми чтоб выйти)` logout.innerHTML = ` (нажми чтоб выйти)`;
document.getElementById("profile_stats").insertAdjacentHTML("beforeend", FillPlayerInfo(response));
ReconstructVipSection(response);
} }
}) })
} }
@ -63,23 +65,27 @@ $('#check_profile_submit_button').click(async function(ev) {
return false; return false;
}); });
$(document).on("show.bs.modal", "#CaptchaModalHandler", async function () {
console.log("setup captcha modal");
let form_url = document.forms["formProfileSectionInput"];
let form_captcha = document.forms["formCaptchaHandler"];
let captcha_id;
await RefreshCaptcha();
async function RefreshCaptcha() { async function RefreshCaptcha() {
await fetch("https://tf2.pblr-nyk.pro/player_api/v1/captcha", { method: 'POST' }) await fetch("https://tf2.pblr-nyk.pro/player_api/v1/captcha", { method: 'POST' })
.then(response => response.json()) .then(response => response.json())
.then(response => { .then(response => {
console.log("captcha id: " + response.id); console.log("captcha id: " + response.id);
captcha_id = response.id; // captcha_id = response.id;
form_captcha.captcha_img.src = "https://tf2.pblr-nyk.pro/player_api/v1/captcha?id=" + response.id; // form_captcha.captcha_img.src = "https://tf2.pblr-nyk.pro/player_api/v1/captcha?id=" + response.id;
return response.id;
}); });
} }
$(document).on("show.bs.modal", "#CaptchaModalHandler", async function () {
console.log("setup captcha modal");
let form_url = document.forms["formProfileSectionInput"];
let form_captcha = document.forms["formCaptchaHandler"];
let captcha_id;
const captchaId = await RefreshCaptcha();
captcha_id = captchaId;
form_captcha.captcha_img.src = "https://tf2.pblr-nyk.pro/player_api/v1/captcha?id=" + captchaId;
$('#check_captcha_submit_button').click(async function (ev) { $('#check_captcha_submit_button').click(async function (ev) {
//ev.preventDefault(); //ev.preventDefault();
if ($('#ModalCaptchaErrorText')) { $('#ModalCaptchaErrorText').remove(); } if ($('#ModalCaptchaErrorText')) { $('#ModalCaptchaErrorText').remove(); }
@ -128,12 +134,13 @@ $(document).on("show.bs.modal", "#CaptchaModalHandler", async function () {
} else { } else {
console.log(response); console.log(response);
document.getElementById("profile_stats").insertAdjacentHTML("beforeend", FillPlayerInfo(response)); document.getElementById("profile_stats").insertAdjacentHTML("beforeend", FillPlayerInfo(response));
ReconstructVipSection(response); //ReconstructVipSection(response);
$('#check_captcha_close_button').click(); $('#check_captcha_close_button').click();
} }
form_captcha.captcha.value = ''; form_captcha.captcha.value = '';
}); });
}}); }
});
function CalculateVipEndDate(permition) { function CalculateVipEndDate(permition) {
return new Date((permition["UNIX_TIMESTAMP(`reg_date`)"] + permition.amount) * 1000); return new Date((permition["UNIX_TIMESTAMP(`reg_date`)"] + permition.amount) * 1000);
@ -344,7 +351,7 @@ function ReconstructVipSection(data){
$('#Modal_SelectPayMethod_CheckVIP').click(async function (ev) { $('#Modal_SelectPayMethod_CheckVIP').click(async function (ev) {
ev.preventDefault(); ev.preventDefault();
await fetch("https://tf2.pblr-nyk.pro/player_api/v1/player/permitions?steam_url=" + document.forms["formProfileSectionInput"].steamurl.value) await fetch("https://tf2.pblr-nyk.pro/player_api/v1/player/permitions?steam_url=" + document.forms["formProfileSectionInput"].steamurl.value, { credentials: "same-origin", headers: { 'Cache-Control': 'no-cache' } })
.then(response => response.json()) .then(response => response.json())
.then(response => { .then(response => {
if (response.permition) { if (response.permition) {

Loading…
Cancel
Save