mirror of
https://github.com/hyzendust/hyzendust.github.io.git
synced 2026-07-01 07:22:17 +02:00
Fix: admin warning messages
This commit is contained in:
@@ -9,6 +9,6 @@ All updates
|
||||
</button>
|
||||
<button class=rss-subscribe__item data-rss-url=https://freedoms4.org/blog/index.xml>
|
||||
Blog posts</button></div></div></div></div><nav class="menu language"><ul class="menu__list language__list"><li class=menu__item><a class=menu__link href=/>Home</a></li><li class=menu__item><a class=menu__link href=/blog/>Blog</a></li><li class=menu__item><a class=menu__link href=/services/>Services</a></li><li class=menu__item><a class=menu__link href=/uninotes/>UniNotes</a></li><li class=menu__item><a class=menu__link href=/contact/>Contact</a></li></ul></nav></header><main class=main><div id=admin-gate style=display:none><p>You do not have permission to access this page.</p></div><div id=admin-panel style=display:none><h1>User Management</h1><label class=admin-search for=admin-user-search><span class=admin-search__label>Search users</span>
|
||||
<input id=admin-user-search class=admin-search__input type=search placeholder="Search by username or email" autocomplete=off></label><div id=admin-msg class=auth-message style=display:none aria-live=polite></div><div id=admin-table-wrap></div></div><script>(function(){var r="https://backend.freedoms4.org/admin.php",l=localStorage.getItem("f4_username"),u=document.getElementById("admin-gate"),d=document.getElementById("admin-panel"),s=document.getElementById("admin-msg"),e=document.getElementById("admin-table-wrap"),a=document.getElementById("admin-user-search"),t=[];if(l!=="hyzen"){u.style.display="";return}d.style.display="";function i(e,t){s.textContent=e,s.className="auth-message auth-message--"+t,s.style.display="block",setTimeout(function(){s.style.display="none"},3e3)}function n(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function h(s){if(!s.length){e.innerHTML="<p>No matching users found.</p>";return}var a='<table class="admin-table"><tbody><tr class="admin-table__header"><th>#</th><th>Username</th><th>Email</th><th>Joined</th><th>Status</th><th>Actions</th></tr>';function l(e){var s=new Date(e.created_at).toLocaleDateString(),t=e.blocked===!0||e.blocked==="t"||e.blocked==="1",o=t?'<span class="admin-badge admin-badge--blocked">Blocked</span>':'<span class="admin-badge admin-badge--active">Active</span>',i=t?'<button class="admin-btn admin-btn--unblock" data-id="'+e.id+'" data-action="unblock_user">Unblock</button>':'<button class="admin-btn admin-btn--block" data-id="'+e.id+'" data-action="block_user">Block</button>',a='<button class="admin-btn admin-btn--delete" data-id="'+e.id+'" data-username="'+n(e.username)+'" data-action="delete_user">Delete Records</button>';return'<tr id="user-row-'+e.id+'"><td>'+e.id+"</td><td>"+n(e.username)+"</td><td>"+n(e.email)+"</td><td>"+s+"</td><td>"+o+'</td><td class="admin-actions">'+i+" "+a+"</td></tr>"}s.forEach(function(e){a+=l(e)}),a+="</tbody></table>",e.innerHTML=a,e.querySelectorAll("[data-action]").forEach(function(e){e.addEventListener("click",function(){var n=e.dataset.action,s=parseInt(e.dataset.id,10),a=e.dataset.username||"";if(n==="delete_user"){if(!confirm('Permanently delete user "'+a+'"? This cannot be undone.'))return}else if(n==="block_user"&&!confirm("This will permanently delete the user's email history and cannot be undone"))return;e.disabled=!0,fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({action:n,user_id:s})}).then(function(e){return e.json()}).then(function(a){a.success?n==="delete_user"?(t=t.filter(function(e){return Number(e.id)!==s}),o(),i("User deleted.","success")):c():(i(a.message||"Action failed.","error"),e.disabled=!1)}).catch(function(){i("Network error.","error"),e.disabled=!1})})})}function c(){e.innerHTML="<p>Loading…</p>",fetch(r+"?action=list_users",{credentials:"include"}).then(function(e){return e.json()}).then(function(s){s.success?(t=s.users,o()):e.innerHTML='<p class="admin-error">'+n(s.message||"Failed to load users.")+"</p>"}).catch(function(){e.innerHTML='<p class="admin-error">Network error.</p>'})}function o(){var e=a.value.trim().toLowerCase(),n=t.filter(function(t){return t.username!==l&&(!e||String(t.username).toLowerCase().includes(e)||String(t.email).toLowerCase().includes(e))});h(n)}a.addEventListener("input",o),c()})()</script></main><footer class=footer><p class=footer__copyright-notice>© <a href=https://freedoms4.org>freedoms4.org</a>
|
||||
<input id=admin-user-search class=admin-search__input type=search placeholder="Search by username or email" autocomplete=off></label><div id=admin-msg class=auth-message style=display:none aria-live=polite></div><div id=admin-table-wrap></div></div><script>(function(){var r="https://backend.freedoms4.org/admin.php",l=localStorage.getItem("f4_username"),u=document.getElementById("admin-gate"),d=document.getElementById("admin-panel"),s=document.getElementById("admin-msg"),e=document.getElementById("admin-table-wrap"),a=document.getElementById("admin-user-search"),t=[];if(l!=="hyzen"){u.style.display="";return}d.style.display="";function i(e,t){s.textContent=e,s.className="auth-message auth-message--"+t,s.style.display="block",setTimeout(function(){s.style.display="none"},3e3)}function n(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function h(s){if(!s.length){e.innerHTML="<p>No matching users found.</p>";return}var a='<table class="admin-table"><tbody><tr class="admin-table__header"><th>#</th><th>Username</th><th>Email</th><th>Joined</th><th>Status</th><th>Actions</th></tr>';function l(e){var s=new Date(e.created_at).toLocaleDateString(),t=e.blocked===!0||e.blocked==="t"||e.blocked==="1",o=t?'<span class="admin-badge admin-badge--blocked">Blocked</span>':'<span class="admin-badge admin-badge--active">Active</span>',i=t?'<button class="admin-btn admin-btn--unblock" data-id="'+e.id+'" data-action="unblock_user">Unblock</button>':'<button class="admin-btn admin-btn--block" data-id="'+e.id+'" data-action="block_user">Block</button>',a='<button class="admin-btn admin-btn--delete" data-id="'+e.id+'" data-username="'+n(e.username)+'" data-action="delete_user">Delete Records</button>';return'<tr id="user-row-'+e.id+'"><td>'+e.id+"</td><td>"+n(e.username)+"</td><td>"+n(e.email)+"</td><td>"+s+"</td><td>"+o+'</td><td class="admin-actions">'+i+" "+a+"</td></tr>"}s.forEach(function(e){a+=l(e)}),a+="</tbody></table>",e.innerHTML=a,e.querySelectorAll("[data-action]").forEach(function(e){e.addEventListener("click",function(){var n=e.dataset.action,s=parseInt(e.dataset.id,10),a=e.dataset.username||"";if(n==="delete_user"){if(!confirm("Permanently delete user "+a+"? This cannot be undone."))return}else if(n==="block_user"&&!confirm("This will permanently delete the user's email history and cannot be undone."))return;e.disabled=!0,fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({action:n,user_id:s})}).then(function(e){return e.json()}).then(function(a){a.success?n==="delete_user"?(t=t.filter(function(e){return Number(e.id)!==s}),o(),i("User deleted.","success")):c():(i(a.message||"Action failed.","error"),e.disabled=!1)}).catch(function(){i("Network error.","error"),e.disabled=!1})})})}function c(){e.innerHTML="<p>Loading…</p>",fetch(r+"?action=list_users",{credentials:"include"}).then(function(e){return e.json()}).then(function(s){s.success?(t=s.users,o()):e.innerHTML='<p class="admin-error">'+n(s.message||"Failed to load users.")+"</p>"}).catch(function(){e.innerHTML='<p class="admin-error">Network error.</p>'})}function o(){var e=a.value.trim().toLowerCase(),n=t.filter(function(t){return t.username!==l&&(!e||String(t.username).toLowerCase().includes(e)||String(t.email).toLowerCase().includes(e))});h(n)}a.addEventListener("input",o),c()})()</script></main><footer class=footer><p class=footer__copyright-notice>© <a href=https://freedoms4.org>freedoms4.org</a>
|
||||
<a href=/terms/>Terms and Conditions</a> <a href=/privacy/>Privacy Policy</a>
|
||||
<a href=/changelog/>Changelog</a></p><p class=footer__theme-info>Built with <a href=https://gohugo.io>Hugo</a> and based on <a href=https://github.com/CyrusYip/hugo-theme-yue>Yue</a> theme</p></footer><script>(function(){document.querySelectorAll(".menu__item").forEach(function(e){var t=e.querySelector("a");t&&t.getAttribute("href")==="/uninotes/"&&e.classList.add("menu__item--uninotes")})})()</script><script>(function(){var e=document.getElementById("theme-toggle");if(!e)return;function t(){var e=localStorage.getItem("theme");return e?e:window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function n(e){document.documentElement.setAttribute("data-theme",e),localStorage.setItem("theme",e)}n(t()),e.addEventListener("click",function(){var e=document.documentElement.getAttribute("data-theme")||t();n(e==="dark"?"light":"dark")})})()</script><script>(function(){var t="https://backend.freedoms4.org/auth.php",e=localStorage.getItem("f4_username");if(!e)return;function n(e){var t,n,o,i,a,c,r=document.querySelector(".brand__auth");r&&!r.querySelector(".brand__auth-user")&&(r.classList.add("brand__auth--loggedin"),t=document.createElement("div"),t.className="brand__auth-user",n=document.createElement("button"),n.className="brand__auth-user-btn",n.setAttribute("aria-label","Account menu"),c=document.createElement("span"),c.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="12" height="12" fill="currentColor"><path d="M12 12c2.7 0 4.8-2.1 4.8-4.8S14.7 2.4 12 2.4 7.2 4.5 7.2 7.2 9.3 12 12 12zm0 2.4c-3.2 0-9.6 1.6-9.6 4.8v2.4h19.2v-2.4c0-3.2-6.4-4.8-9.6-4.8z"/></svg>',n.appendChild(c.firstChild),n.appendChild(document.createTextNode(" "+e)),o=document.createElement("div"),o.className="brand__auth-user-dropdown",i=document.createElement("button"),i.className="brand__auth-user-logout",i.textContent="Log Out",i.addEventListener("click",s),e==="hyzen"&&(a=document.createElement("a"),a.className="brand__auth-user-admin",a.href="/admin/",a.textContent="User Management",o.appendChild(a)),o.appendChild(i),o.appendChild(i),t.appendChild(n),t.appendChild(o),r.appendChild(t),n.addEventListener("click",function(e){e.stopPropagation(),t.classList.toggle("is-open")}),document.addEventListener("click",function(){t.classList.remove("is-open")}))}function s(){fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({action:"logout"})}).finally(function(){localStorage.removeItem("f4_username"),localStorage.removeItem("f4_login_time"),localStorage.removeItem("f4_session_fails"),window.location.reload()})}n(e)})()</script><script>(function(){var t,e=document.querySelector(".rss-subscribe");if(!e)return;t=e.querySelector(".rss-subscribe__btn"),t.addEventListener("click",function(t){t.stopPropagation(),e.classList.toggle("is-open")}),document.addEventListener("click",function(t){e.contains(t.target)||e.classList.remove("is-open")}),e.querySelectorAll(".rss-subscribe__item").forEach(function(t){t.addEventListener("click",function(n){n.stopPropagation();var s,o=t.getAttribute("data-rss-url"),a=t.textContent;function i(){t.textContent="Copied!",setTimeout(function(){t.textContent=a,e.classList.remove("is-open")},1200)}try{s=document.createElement("textarea"),s.value=o,s.style.cssText="position:fixed;top:0;left:0;opacity:0;pointer-events:none;",document.body.appendChild(s),s.focus(),s.select(),document.execCommand("copy"),document.body.removeChild(s),i()}catch{navigator.clipboard&&navigator.clipboard.writeText(o).then(i).catch(function(){t.textContent=o})}})})})()</script><script src=/js/session-check.js></script></body></html>
|
||||
Reference in New Issue
Block a user