<<<<<<< HEAD =======
<<<<<<< HEAD
<<<<<<< HEAD
Logo

CWP | User

Sign in to manage your hosting account

Recover password

© 2026 The Kinsmen — CWP Control Panel

======= // ── Theme toggle ────────────────────────────────────────── function toggleTheme() { const html = document.documentElement; html.classList.toggle("dark"); localStorage.setItem( "cwp-theme", html.classList.contains("dark") ? "dark" : "light", ); } (function () { const saved = localStorage.getItem("cwp-theme"); if (saved === "light") document.documentElement.classList.remove("dark"); else document.documentElement.classList.add("dark"); })(); // ── Password eye toggle ─────────────────────────────────── function togglePassword() { const p = document.getElementById("password"); const e = document.getElementById("pwd-eye"); if (p.type === "password") { p.type = "text"; e.className = "fas fa-eye-slash text-sm"; } else { p.type = "password"; e.className = "fas fa-eye text-sm"; } } // ── Toastr helper (matches old noti_bubble exactly) ─────── function noti_bubble(title, msj, type, bar, button, timer, repeat) { toastr.options = { closeButton: button, progressBar: bar, showMethod: "slideDown", preventDuplicates: repeat, timeOut: timer, }; if (type === "success") toastr.success(title, msj); if (type === "error") toastr.error(title, msj); if (type === "info") toastr.info(title, msj); if (type === "warning") toastr.warning(title, msj); } // ── Show/hide panels ────────────────────────────────────── function forgout(sw) { if (sw === 0) { $("#login").fadeOut("fast", function () { $("#lost-pass").fadeIn("fast"); }); } else if (sw === 1) { $("#lost-pass").fadeOut("fast", function () { $("#login").fadeIn("fast"); }); } return false; } // ── Email validator ─────────────────────────────────────── function validateEmail(email) { return /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test( email, ); } // ── Main login (original CWP validate flow) ─────────────── function valite() { if ($("#username").val() === "root") { noti_bubble( "User root Invalid..!", "", "error", false, false, "3000", true, ); return false; } if ($("#username").val() === "" || $("#password").val() === "") { noti_bubble( "All data is required", "", "error", false, false, "3000", true, ); return false; } $("#btnsubmit").prop("disabled", true).addClass("disabled"); $("#btn_icon").removeClass("hidden"); $("#btn_arrow").addClass("hidden"); $("#btn_title").text("Please wait!"); var pass = Base64.encode($("#password").val()); var userN = $("#username").val().trim(); var sessioning = $("#sessioning").is(":checked") ? 1 : 0; $.ajaxSetup({ headers: { csrftoken: "499b95eea599df1950b335b8b4e3ea8b" } }); $.ajax({ type: "POST", url: "/login/index.php?acc=validate", data: "username=" + userN + "&password=" + pass + "&sessioning=" + sessioning + "&userlang=", complete: function (datos) { var obj; try { obj = JSON.parse(datos.responseText); } catch (e) { // Reset button $("#btnsubmit").prop("disabled", false).removeClass("disabled"); $("#btn_icon").addClass("hidden"); $("#btn_arrow").removeClass("hidden"); $("#btn_title").text("Login"); noti_bubble( "All data is required", "", "error", false, false, "3000", true, ); return; } if (obj.error) { $("#btnsubmit").prop("disabled", false).removeClass("disabled"); $("#btn_icon").addClass("hidden"); $("#btn_arrow").removeClass("hidden"); $("#btn_title").text("Login"); if (obj.error === "locked") { noti_bubble( "User locked", "", "error", false, false, "3000", true, ); } else { noti_bubble(obj.error, "", "error", false, false, "3000", true); } return false; } else if (obj.token) { // Success — redirect via form submit $("#login").fadeOut("fast", function () { $("#logged_message").removeClass("hidden").show(); }); $("#token").val(obj.token); $("#password").val(""); $("#formloginon").attr("action", "/" + userN + "/"); $("#formloginon").submit(); return false; } else if (obj.twofa) { // Show 2FA panel $("#login-form-wrap form").hide(); $("#twofa").show(); $("#btn_icon").addClass("hidden"); $("#btn_arrow").removeClass("hidden"); $("#btn_title").text("Login"); $("#btnsubmit").prop("disabled", false).removeClass("disabled"); setTimeout(function () { $("#f2acode").focus(); }, 100); return false; } }, }); return false; } // ── 2FA submit ──────────────────────────────────────────── $("#btn-f2acode").click(function () { var $btn = $(this); var btnHtml = $btn.html(); $.ajaxSetup({ headers: { csrftoken: "499b95eea599df1950b335b8b4e3ea8b" } }); $btn.prop("disabled", true).addClass("disabled"); $btn.html( ' Submit', ); $.ajax({ type: "POST", url: "/login/index.php?acc=f2acode", data: "code=" + $("#f2acode").val() + "&username=" + $("#username").val(), complete: function (datos) { var obj; try { obj = JSON.parse(datos.responseText); } catch (e) { obj = {}; } if (obj.error) { noti_bubble( "incorrect access..!", "", "error", false, false, "3000", true, ); $btn.prop("disabled", false).removeClass("disabled"); $btn.html(btnHtml); } else if (obj.token) { $("#login").fadeOut("fast", function () { $("#twofa").hide(); $("#logged_message").removeClass("hidden").show(); }); $("#token").val(obj.token); $("#password").val(""); $("#formloginon").attr( "action", "/" + $("#username").val() + "/", ); $("#formloginon").submit(); } }, }); }); // ── Lost password ───────────────────────────────────────── function lostpass(elem) { $.ajaxSetup({ headers: { csrftoken: "499b95eea599df1950b335b8b4e3ea8b" } }); let valid = true; if ($("#lost-user").val() === "") { $("#lost-user").css("border-color", "#ef4444"); valid = false; } if (!validateEmail($("#lost-email").val())) { $("#lost-email").css("border-color", "#ef4444"); valid = false; } if (!valid) { noti_bubble( "Please complete all required fields.", "", "error", false, false, "3000", true, ); return false; } $("#btnsendcode") .prop("disabled", true) .addClass("disabled") .text("Validating..."); $.ajax({ type: "POST", url: "/login/index.php?acc=lostpass", data: "username=" + $("#lost-user").val() + "&email=" + $("#lost-email").val(), complete: function (datos) { if (datos.responseText == 0) { noti_bubble( "Invalid username & email combination..", "", "error", false, false, "3000", true, ); } else if (datos.responseText == 1) { $("#lost-pass").fadeOut("fast", function () { $("#recover_pass").removeClass("hidden").show(); }); noti_bubble( "A message with instructions has been sent.", "", "success", false, false, "3000", true, ); } else { noti_bubble( "Something went wrong, please try again.", "", "error", false, false, "3000", true, ); } $("#btnsendcode") .prop("disabled", false) .removeClass("disabled") .html( ' Send new password', ); return false; }, }); return false; } // ── Cookie check (runs on load, required by CWP) ────────── function cookie() { $.ajaxSetup({ headers: { csrftoken: "499b95eea599df1950b335b8b4e3ea8b" } }); $.ajax({ type: "POST", url: "/login/index.php?acc=cookie", complete: function (datos) { if (datos.responseText !== "") { // window.location = datos.responseText; } }, }); } // ── Enter key on 2FA input ──────────────────────────────── $("#f2acode").on("keypress", function (e) { if (e.which === 13) $("#btn-f2acode").click(); }); // ── Enter key on login form ─────────────────────────────── $("#username, #password").on("keypress", function (e) { if (e.which === 13) valite(); }); // ── Base64 (same as original) ───────────────────────────── var Base64 = { _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", encode: function (input) { var output = "", chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0; input = Base64._utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output += this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); } return output; }, decode: function (input) { var output = "", chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output += String.fromCharCode(chr1); if (enc3 !== 64) output += String.fromCharCode(chr2); if (enc4 !== 64) output += String.fromCharCode(chr3); } return Base64._utf8_decode(output); }, _utf8_encode: function (string) { string = string.replace(/\r\n/g, "\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if (c > 127 && c < 2048) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, _utf8_decode: function (utftext) { var string = "", i = 0, c = 0, c2 = 0, c3 = 0; while (i < utftext.length) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if (c > 191 && c < 224) { c2 = utftext.charCodeAt(i + 1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i + 1); c3 = utftext.charCodeAt(i + 2); string += String.fromCharCode( ((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63), ); i += 3; } } return string; }, }; cookie(); >>>>>>> f0932fd (minor update v1.0.1)