diff --git a/public/s/js/admin.js b/public/s/js/admin.js index 0f1dd7f..46fedf5 100644 --- a/public/s/js/admin.js +++ b/public/s/js/admin.js @@ -82,7 +82,7 @@ const flash = ({ type, msg }) => { [...document.querySelectorAll("#tags > .badge")].forEach(tag => tag.parentElement.removeChild(tag)); _tags.reverse().forEach(tag => { const a = document.createElement("a"); - a.href = `/admin/test?tag=${tag.tag.replace(/\s/g, "%20")}`; + a.href = `/admin/test?tag=${tag.tag.replace(/\s/g, "+")}`; a.target = "_blank"; a.style = "color: inherit !important"; a.innerText = tag.tag; diff --git a/src/inc/routes/admin.mjs b/src/inc/routes/admin.mjs index 595f7c3..e12742e 100644 --- a/src/inc/routes/admin.mjs +++ b/src/inc/routes/admin.mjs @@ -46,7 +46,8 @@ router.post(/^\/login(\/)?$/, async (req, res) => { session: lib.md5(session), browser: req.headers["user-agent"], created_at: stamp, - last_used: stamp + last_used: stamp, + last_action: "/login" }); return res.writeHead(301, { @@ -87,8 +88,15 @@ router.get(/^\/login\/test$/, async (req, res) => { }); router.get(/^\/admin(\/)?$/, auth, async (req, res) => { // frontpage + const totals = await sql("items") + .select( + sql.raw("(select count(*) from items) total"), + sql.raw("sum(if(ifnull(tags_assign.item_id, 0) = 0, 1, 0)) untagged"), + sql.raw("sum(if(ifnull(tags_assign.item_id, 1) = 1, 0, 1)) tagged")) + .leftJoin("tags_assign", "tags_assign.item_id", "items.id"); + res.reply({ - body: tpl.render("views/admin", {}, req) + body: tpl.render("views/admin", { totals: totals[0] }, req) }); }); @@ -98,15 +106,30 @@ router.get(/^\/admin\/sessions(\/)?$/, auth, async (req, res) => { .select("user_sessions.*", "user.user") .orderBy("user.id"); + const totals = await sql("items") + .select( + sql.raw("(select count(*) from items) total"), + sql.raw("sum(if(ifnull(tags_assign.item_id, 0) = 0, 1, 0)) untagged"), + sql.raw("sum(if(ifnull(tags_assign.item_id, 1) = 1, 0, 1)) tagged")) + .leftJoin("tags_assign", "tags_assign.item_id", "items.id"); + res.reply({ body: tpl.render("views/admin_sessions", { - sessions: rows + sessions: rows, + totals: totals[0] }, req) }); }); router.get(/^\/admin\/test(\/)?$/, auth, async (req, res) => { let ret; + const totals = await sql("items") + .select( + sql.raw("(select count(*) from items) total"), + sql.raw("sum(if(ifnull(tags_assign.item_id, 0) = 0, 1, 0)) untagged"), + sql.raw("sum(if(ifnull(tags_assign.item_id, 1) = 1, 0, 1)) tagged")) + .leftJoin("tags_assign", "tags_assign.item_id", "items.id"); + if(Object.keys(req.url.qs).length > 0) { const tag = req.url.qs.tag; @@ -121,7 +144,8 @@ router.get(/^\/admin\/test(\/)?$/, auth, async (req, res) => { res.reply({ body: tpl.render("views/admin_search", { - result: ret + result: ret, + totals: totals[0] }, req) }); }); diff --git a/src/inc/routes/apiv2.mjs b/src/inc/routes/apiv2.mjs index b587095..2caf9f9 100644 --- a/src/inc/routes/apiv2.mjs +++ b/src/inc/routes/apiv2.mjs @@ -172,7 +172,7 @@ router.post(/^\/api\/v2\/admin\/tags\/delete$/, auth, async (req, res) => { q = q.andWhere("prefix", `${req.session.user}@webinterface`); const reply = !!(await q); - await cleanTags(); + //await cleanTags(); return res.reply({ body: JSON.stringify({ success: reply, diff --git a/src/inc/routes/index.mjs b/src/inc/routes/index.mjs index 5c0b5fe..92e9876 100644 --- a/src/inc/routes/index.mjs +++ b/src/inc/routes/index.mjs @@ -13,7 +13,12 @@ const allowedMimes = [ "audio", "image", "video", "%" ]; router.get(/^\/(audio\/?|image\/?|video\/?)?(p\/\d+)?$/, async (req, res) => { const tmpmime = (allowedMimes.filter(n => req.url.split[0].startsWith(n))[0] ? req.url.split[0] : ""); const mime = tmpmime + "%"; - const total = (await sql("items").where("mime", "like", mime).count("* as total"))[0].total; + + const total = ( + await sql("items") + .where("mime", "like", mime) + .count("* as total") + )[0].total; const pages = +Math.ceil(total / cfg.websrv.eps); const page = Math.min(pages, +req.url.split[tmpmime.length > 0 ? 2 : 1] || 1); diff --git a/src/websrv.mjs b/src/websrv.mjs index 63ba8ec..6cd7018 100644 --- a/src/websrv.mjs +++ b/src/websrv.mjs @@ -65,7 +65,12 @@ import router from "./inc/router.mjs"; if(user.length > 0) { req.session = user[0]; - await sql("user_sessions").update("last_used", (Date.now() / 1e3)).where("id", user[0].sess_id); + let q = sql("user_sessions") + .update("last_used", (Date.now() / 1e3)) + .where("id", user[0].sess_id); + if(!req.url.pathname.match(/^\/(s|b|t|ca)/)) + q = q.update("last_action", req.url.pathname) + await q; } else { // delete session return res.writeHead(301, { @@ -85,7 +90,7 @@ import router from "./inc/router.mjs"; if(r = router.routes.getRoute(req.url.pathname, req.method)) { if(r.meddlware) { - const tmp = r.meddlware(req, req); + const tmp = r.meddlware(req, res); if(tmp.redirect) return res.redirect(tmp.redirect); if(!tmp.success) diff --git a/views/about.html b/views/about.html index 3792aec..7c2e71e 100644 --- a/views/about.html +++ b/views/about.html @@ -46,8 +46,8 @@
Theme plopper (If theme is selected the default f0ck sheme will appear for a small amount of time until the custom stylesheet is applied) - ETA: Christmas™
Magical video seeker (If you hold mouseclick for too long on the video timeline and drag to a specific position it will go crazy, don't!) - ETA: Christmas™
Cookies: Yes, we set 1 cookie for your prefered stylesheet, for the _cfduid cookie please see https://blog.cloudflare.com/deprecating-cfduid-cookie/
-Logs: No for Tor - Yes for cloudflare and cloudflare probably sells your soul to the devil, however our webserver doesn't log cloudflare connecting to our webserver, if you want to lurk without being flared by the cloud, see the above tor section my man
+Cookies: Yes, we set 1 cookie for your prefered stylesheet, this is a optional cookie and not required for the site to function, simply cosmetics, you can block this cookie and the site will still work as intended and will default to the default f0ck theme called "f0ck"
+Logs:No for Tor - Yes for cloudflare and cloudflare probably sells your soul to the devil, however our webserver doesn't log cloudflare connecting to our webserver, if you want to lurk without being flared by the cloud, see the above tor section my man
But let me tell you something about internet "privacy". At first you need to understand what it means to have "privacy", for me as a human the word privacy means that I am by myself, private not observable by others, on the internet this concept does not work, in real life you might lock your door and then no one can enter the normal way to your room and you have some good old fashioned privacy, but on the internet various applications on your computer including extensions for your browser might make connections without you knowing or even giving consent if you knew, most applications send heartbeats, store information, read files on your computer, they might even process the gained data with or without you knowing or consenting to any of it, you probably accepted in good faith the ToS of many services without ever reading them, in the end it's up to you if you give a shit about your privacy, btw a VPN wont help if you still got all the tracking cookies and shit in your browser, they will just add 1+1 and you are identified again. My honest advice for anyone who seeks total privacy without bullshit, disconnect from the internet, remove the internet from your life, it's a bulletproof solution! With that being said, have a good day!
{{include main/footer}} diff --git a/views/admin_sessions.html b/views/admin_sessions.html index 9921880..3f05312 100644 --- a/views/admin_sessions.html +++ b/views/admin_sessions.html @@ -7,6 +7,7 @@