Browse Source

steam auth

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

13
index.html

@ -208,8 +208,8 @@ transition: background-image 1s;" id="main_container">
<br>
<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">
<a href=# onclick="document.getElementById('Tab_Profile_Button').click();">
<h3>Чтоб увидить цены, сначала введи профиль (>ТЫК<)</h3>
<a href=# onclick="document.getElementById('Header_CurrentUser').click();">
<h3>Чтоб увидить цены, сначала авторизируйся через стим</h3>
</a>
</div>
<!---->
@ -251,8 +251,9 @@ transition: background-image 1s;" id="main_container">
</div>
<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">
<h2>Проверь свой профиль на фактах!</h2>
<h6>На этой странице после ввода твоего профиля, появится вся твоя статистика на фактах, наличие банов и их история, а так-же возможность купить випку!</h6>
<h2>Проверь профиль на фактах!</h2>
<h6>На этой странице после ввода профиля, появится вся статистика на фактах, наличие банов и их история.</h6>
<h6>Если авторизоваться, то сразу будет твой профиль</h6>
<form id="formProfileSectionInput" action="#check">
<div class="row justify-content-center">
<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"
integrity="sha384-VHvPCCyXqtD5DqJeNxl2dtTyhF78xXNXdkwX1CZeRusQfRKp+tA7hAShOK/B/fQ2"
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/Player_API.js?version=1.75"></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.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/BackgroundSlides.js?version=9.6"></script>
</body>

7
site_content/js/API.js

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

195
site_content/js/Player_API.js

@ -1,34 +1,36 @@
$(async function() {
$(async function () {
await CheckCurrentUser();
})
async function CheckCurrentUser(){
if(!check_cookie_name("steam64")){return;}
await fetch("https://tf2.pblr-nyk.pro/player_api/v1/current_user", {credentials:"same-origin", headers: {'Cache-Control':'no-cache'}})
.then(response => response.json())
.then(response => {
if("error" in response) {
console.log(response.error);
} else {
var current_user = document.getElementById("Header_CurrentUser");
var current_ban = document.getElementById("Header_CurrentBan");
var logout = document.getElementById("Header_Logout");
current_user.href = "#";
if (response.ban) {
current_user.innerHTML = `Привет ${response.steam_data.nickname}! У меня хорошие новости!`
current_ban.innerHTML = "У тебя БАН! (нажми чтоб посмотреть его)";
async function CheckCurrentUser() {
if (!check_cookie_name("steam64")) { return; }
await fetch("https://tf2.pblr-nyk.pro/player_api/v1/current_user", { credentials: "same-origin", headers: { 'Cache-Control': 'no-cache' } })
.then(response => response.json())
.then(response => {
if ("error" in response) {
console.log(response.error);
} else {
current_user.innerHTML = `Привет ${response.steam_data.nickname}!`
var current_user = document.getElementById("Header_CurrentUser");
var current_ban = document.getElementById("Header_CurrentBan");
var logout = document.getElementById("Header_Logout");
current_user.href = "#";
if (response.ban) {
current_user.innerHTML = `Привет ${response.steam_data.nickname}! У меня хорошие новости!`;
current_ban.innerHTML = "У тебя БАН! (нажми чтоб посмотреть его)";
} else {
current_user.innerHTML = `Привет ${response.steam_data.nickname}!`;
}
logout.innerHTML = ` (нажми чтоб выйти)`;
document.getElementById("profile_stats").insertAdjacentHTML("beforeend", FillPlayerInfo(response));
ReconstructVipSection(response);
}
logout.innerHTML = ` (нажми чтоб выйти)`
}
})
})
}
function check_cookie_name(name) {
var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
if (match && match[2] != "None") {return true;}
else {return false;}
if (match && match[2] != "None") { return true; }
else { return false; }
}
let captcha_error_div = `<div class="col" id="ModalCaptchaErrorText"><h6 style="color: red;" id="captcha_error">пук</h6></div>`
@ -36,18 +38,18 @@ let ProfileLinkError_div = `<div class="col" id="ProfileLinkIsNotFull"><h6 style
console.log("puk");
//buttonCheckProfile
$('#check_captcha_close_button').click(async function(ev) {
$('#check_captcha_close_button').click(async function (ev) {
ev.preventDefault();
$('#CaptchaModalHandler').modal('hide');
});
document.getElementById("check_profile_submit_button").addEventListener("keypress", async function(ev){
document.getElementById("check_profile_submit_button").addEventListener("keypress", async function (ev) {
ev.preventDefault();
console.log(ev.key);
return false;
});
$('#check_profile_submit_button').click(async function(ev) {
$('#check_profile_submit_button').click(async function (ev) {
//ev.preventDefault();
console.log("check profile button presed");
if (document.getElementById("ProfileLinkIsNotFull")) {
@ -55,7 +57,7 @@ $('#check_profile_submit_button').click(async function(ev) {
}
if (!document.forms["formProfileSectionInput"].steamurl.value.startsWith("https://")) {
document.getElementById("formProfileSectionInputHelpText").insertAdjacentHTML("beforeend",ProfileLinkError_div);
document.getElementById("formProfileSectionInputHelpText").insertAdjacentHTML("beforeend", ProfileLinkError_div);
//document.getElementById("profile").innerHTML = "Долбаеб введи ссылку на профиль!";
} else {
$('#CaptchaModalHandler').modal('show');
@ -63,34 +65,38 @@ $('#check_profile_submit_button').click(async function(ev) {
return false;
});
async function RefreshCaptcha() {
await fetch("https://tf2.pblr-nyk.pro/player_api/v1/captcha", { method: 'POST' })
.then(response => response.json())
.then(response => {
console.log("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;
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;
await RefreshCaptcha();
async function RefreshCaptcha() {
await fetch("https://tf2.pblr-nyk.pro/player_api/v1/captcha", {method:'POST'})
.then(response => response.json())
.then(response => {
console.log("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;
});
}
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) {
//ev.preventDefault();
if ($('#ModalCaptchaErrorText')) { $('#ModalCaptchaErrorText').remove();}
if ($('#ModalCaptchaErrorText')) { $('#ModalCaptchaErrorText').remove(); }
await CheckAndFill(ev);
return false;
});
async function CheckAndFill(event) {
if(form_captcha.captcha.value.length == 0){
if(!document.getElementById("captcha_error")){
document.getElementById("InvalidCaptchaTextArea").insertAdjacentHTML("beforeend",captcha_error_div);
if (form_captcha.captcha.value.length == 0) {
if (!document.getElementById("captcha_error")) {
document.getElementById("InvalidCaptchaTextArea").insertAdjacentHTML("beforeend", captcha_error_div);
}
document.getElementById("captcha_error").innerHTML = "Капчу введи!";
return;
@ -98,7 +104,7 @@ $(document).on("show.bs.modal", "#CaptchaModalHandler", async function () {
$("#check_captcha_close_button").prop("disabled", true);
$("#check_captcha_submit_button").prop("disabled", true);
if(document.getElementById("current_profile")){
if (document.getElementById("current_profile")) {
document.getElementById("current_profile").remove();
}
console.log(new Date());
@ -110,8 +116,8 @@ $(document).on("show.bs.modal", "#CaptchaModalHandler", async function () {
/////////////////////////////////////////////////////////
if ("error" in response) {
console.log(`id: ${captcha_id} error: ${response}`);
if(!document.getElementById("captcha_error")){
document.getElementById("InvalidCaptchaTextArea").insertAdjacentHTML("beforeend",captcha_error_div);
if (!document.getElementById("captcha_error")) {
document.getElementById("InvalidCaptchaTextArea").insertAdjacentHTML("beforeend", captcha_error_div);
}
if (response.error == "incorrect captcha") {
document.getElementById("captcha_error").innerHTML = "Капча невалидна, попробуй снова!";
@ -120,32 +126,33 @@ $(document).on("show.bs.modal", "#CaptchaModalHandler", async function () {
}
RefreshCaptcha();
} else if ("detail" in response) {
if(!document.getElementById("captcha_error")){
document.getElementById("InvalidCaptchaTextArea").insertAdjacentHTML("beforeend",captcha_error_div);
if (!document.getElementById("captcha_error")) {
document.getElementById("InvalidCaptchaTextArea").insertAdjacentHTML("beforeend", captcha_error_div);
}
document.getElementById("captcha_error").innerHTML = "Ошибка: " + response.detail[0].msg;
RefreshCaptcha();
} else {
console.log(response);
document.getElementById("profile_stats").insertAdjacentHTML("beforeend",FillPlayerInfo(response));
ReconstructVipSection(response);
document.getElementById("profile_stats").insertAdjacentHTML("beforeend", FillPlayerInfo(response));
//ReconstructVipSection(response);
$('#check_captcha_close_button').click();
}
form_captcha.captcha.value = '';
});
}});
});
}
});
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);
}
function FillPlayerInfo(data) {
let player_ban_div = "";
if(data.ban) {
if (data.ban) {
let player_ban_length;
if (data.ban.ban_length > 0){
if (data.ban.ban_length > 0) {
let player_ban_end = new Date((new Date(data.ban.timestamp)).getTime() + (data.ban.ban_length * 60 * 1000)).toLocaleString();
player_ban_length = `<p class="current-profile-text">Дата окончания: </p><p class="current-profile-text">${player_ban_end}</p>`
} else {
@ -179,23 +186,23 @@ function FillPlayerInfo(data) {
let player_permition_div;
let player_permition_length = "";
let player_permition_continue = `(купить)`;
if(data.permition) {
if (data.permition) {
let player_permition_status;
if (data.permition.status == "VIP"){
if (data.permition.status == "VIP") {
let player_permition_end_date = `бесконечны`;
let player_permition_end_date_color_status = `current-profile-text-color-normal`;
if(data.permition.amount){
if (data.permition.amount) {
player_permition_continue = `(продлить)`;
let date = CalculateVipEndDate(data.permition);// new Date((data.permition["UNIX_TIMESTAMP(`reg_date`)"] + data.permition.amount) * 1000);
player_permition_end_date = date.toLocaleString();
document.getElementById("Modal_SelectPayMethod_CheckVIP_EndDate").innerHTML = `До: ${player_permition_end_date}`;
if(date.getTime() - new Date().getTime() > 604800000){
if (date.getTime() - new Date().getTime() > 604800000) {
player_permition_end_date_color_status = `current-profile-text-color-normal`;
} else if (date.getTime() - new Date().getTime() > 259200000){
} else if (date.getTime() - new Date().getTime() > 259200000) {
player_permition_end_date_color_status = `current-profile-text-color-maybe`;
} else {
player_permition_end_date_color_status = `current-profile-text-color-alarm`;
@ -212,7 +219,7 @@ function FillPlayerInfo(data) {
<p class="current-profile-text current-profile-bigtext">Имеется </p><a href="#" onclick="document.getElementById('Tab_VIP_Button').click();" class="current-profile-text current-profile-bigtext ${player_permition_end_date_color_status}">${player_permition_continue}</a>
`
} else {
player_permition_status = `
<p class="current-profile-text current-profile-bigtext">Статус ${data.permition.status}: </p>
@ -256,14 +263,14 @@ function FillPlayerInfo(data) {
<p class="current-profile-text">zavod_3 - 1 день 2:19:13</p>
</div>
*/
if(data.gametime){
if (data.gametime) {
player_statistic_div = `<div id="statistic_section">
<hr>
<p class="current-profile-text current-profile-bigtext">Статистика карт</p>
`;
for(const srv in data.gametime) {
for(const map_name in data.gametime[srv]){
for (const srv in data.gametime) {
for (const map_name in data.gametime[srv]) {
//<a href="${data.ban.admin_info.steam_url}" target="_blank" class="current-profile-text"><img style="height: 1.0rem;" class="rounded-1" src="site_content/images/logo/steam.png"></a>
//<img style="height: 1.0rem;" class="rounded-1" src="${return_last_api_response().servers[srv].preview}">
let map = map_name.replace("workshop/", "").split(".ugc", 1)[0];
@ -310,9 +317,9 @@ function FillPlayerInfo(data) {
return player_data_div;
}
function UNIX2FACTI_TIME(u_time){
function UNIX2FACTI_TIME(u_time) {
const divmod = (x, y) => [Math.floor(x / y), x % y];
let s = divmod(u_time, 60)[1];
let m = divmod(u_time, 60)[0];
let h = divmod(m, 60)[0];
@ -321,50 +328,50 @@ function UNIX2FACTI_TIME(u_time){
h = divmod(h, 24)[1];
//бля простите я тупой
if(!s&!m&!h&!d){
if (!s & !m & !h & !d) {
return "не играл";
}
let time = `${h>9?h:'0'+h}:${m>9?m:'0'+m}:${s>9?s:'0'+s}`;
let time = `${h > 9 ? h : '0' + h}:${m > 9 ? m : '0' + m}:${s > 9 ? s : '0' + s}`;
if (!d) {
return time;
} else if (d<2){
} else if (d < 2) {
return `${d} день ${time}`;
} else {
return `${d} дней ${time}`;
}
}
function ReconstructVipSection(data){
$('#Modal_SelectPayMethod_Close').click(async function(ev) {
function ReconstructVipSection(data) {
$('#Modal_SelectPayMethod_Close').click(async function (ev) {
ev.preventDefault();
$('#Modal_SelectPayMethod').modal('hide');
});
$('#Modal_SelectPayMethod_CheckVIP').click(async function(ev) {
$('#Modal_SelectPayMethod_CheckVIP').click(async function (ev) {
ev.preventDefault();
await fetch("https://tf2.pblr-nyk.pro/player_api/v1/player/permitions?steam_url=" + document.forms["formProfileSectionInput"].steamurl.value)
.then(response => response.json())
.then(response => {
if(response.permition){
document.getElementById("Modal_SelectPayMethod_CheckVIP_Status").innerHTML = "(имеется)";
document.getElementById("Modal_SelectPayMethod_CheckVIP_Status").style += "color: green;";
if(response.permition.amount){
document.getElementById("Modal_SelectPayMethod_CheckVIP_EndDate").innerHTML = `До: ${CalculateVipEndDate(response.permition).toLocaleString()}`;
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 => {
if (response.permition) {
document.getElementById("Modal_SelectPayMethod_CheckVIP_Status").innerHTML = "(имеется)";
document.getElementById("Modal_SelectPayMethod_CheckVIP_Status").style += "color: green;";
if (response.permition.amount) {
document.getElementById("Modal_SelectPayMethod_CheckVIP_EndDate").innerHTML = `До: ${CalculateVipEndDate(response.permition).toLocaleString()}`;
} else {
document.getElementById("Modal_SelectPayMethod_CheckVIP_EndDate").innerHTML = `бесконечность не предел`;
}
} else {
document.getElementById("Modal_SelectPayMethod_CheckVIP_EndDate").innerHTML = `бесконечность не предел`;
document.getElementById("Modal_SelectPayMethod_CheckVIP_Status").innerHTML = "(отсутствует)";
document.getElementById("Modal_SelectPayMethod_CheckVIP_Status").style += "color: red;";
document.getElementById("Modal_SelectPayMethod_CheckVIP_EndDate").innerHTML = `Время проверки: ${new Date().toLocaleString()}`;
}
} else {
document.getElementById("Modal_SelectPayMethod_CheckVIP_Status").innerHTML = "(отсутствует)";
document.getElementById("Modal_SelectPayMethod_CheckVIP_Status").style += "color: red;";
document.getElementById("Modal_SelectPayMethod_CheckVIP_EndDate").innerHTML = `Время проверки: ${new Date().toLocaleString()}`;
}
});
});
});
//document.getElementById("Section_VIP_check_profile")?document.getElementById("Section_VIP_check_profile").remove():null;
while(document.getElementById("Section_VIP_buttons").firstChild) {
while (document.getElementById("Section_VIP_buttons").firstChild) {
document.getElementById("Section_VIP_buttons").lastChild.remove();
}
@ -380,10 +387,10 @@ function ReconstructVipSection(data){
["VIP (1 месяц)", 150, "1 ключ", "site_content/images/vip/VIP_1_MOUNTH.jpg", "month"],
["VIP (1 неделя)", 75, "20 рефов", "site_content/images/vip/VIP_7_DAYS.jpg", "seven_day"],
["VIP (1 день)", 20, "5 рефов", "site_content/images/vip/VIP_1_DAY.jpg", "day"]
);
);
let vip_select;
for(const select in price_array) {
for (const select in price_array) {
vip_select = `
<div class="col">
<div class="card">
@ -401,9 +408,9 @@ function ReconstructVipSection(data){
</div>
`
document.getElementById("Section_VIP_buttons").insertAdjacentHTML("beforeend", vip_select);
$(`#Section_VIP_buttons_${price_array[select][4]}`).click(async function(ev) {
$(`#Section_VIP_buttons_${price_array[select][4]}`).click(async function (ev) {
ev.preventDefault();
document.getElementById('Modal_SelectPayMethod_QIWI_Button').href = QIWI_TRADE.replace("(AMOUNT)", price_array[select][1]).replace("(COMMENT)",data.steamids.steam2.replace(":","%3A"));
document.getElementById('Modal_SelectPayMethod_QIWI_Button').href = QIWI_TRADE.replace("(AMOUNT)", price_array[select][1]).replace("(COMMENT)", data.steamids.steam2.replace(":", "%3A"));
document.getElementById('Modal_SelectPayMethod_QIWI_Value').innerHTML = `${price_array[select][1]} Рублей`;
document.getElementById('Modal_SelectPayMethod_STEAM_Button').href = STEAM_TRADE;
document.getElementById('Modal_SelectPayMethod_STEAM_Value').innerHTML = price_array[select][2];
@ -449,13 +456,13 @@ $('#Section_VIP_buttons_month').click(async function(ev) {
let konami_code = "";
let activated = false;
document.addEventListener('keypress', (event) => {
if(activated){return;}
if (activated) { return; }
konami_code += event.key;
if(konami_code.length == 6 || event.key == "-"){
if(konami_code == "nigger"){
if (konami_code.length == 6 || event.key == "-") {
if (konami_code == "nigger") {
activated = true;
document.getElementById("Tab_About").href="#SecretEgg";
document.getElementById("Tab_About").href = "#SecretEgg";
$('.nav-pills a[href="#SecretEgg"]').tab('show');
(new Audio("site_content/sounds/sunboy-ledi-night-16.mp3")).play();
document.getElementById("Nav_MenuButtons").remove()

Loading…
Cancel
Save