Diff -- /var/www/vhosts/3dshawn.com/admin.3dshawn.com/login.cgi
Diff

/var/www/vhosts/3dshawn.com/admin.3dshawn.com/login.cgi

added on local at 2026-06-22 16:44:16

Added
+101
lines
Removed
-0
lines
Context
0
unchanged
Blobs
from
to 56ec410dc6af
Restore this content →
Unified diff
Naive LCS-based line diff. Additions in emerald, deletions in rose. Both sides decompressed live from BLOB_STORE.
1#!/usr/bin/perl
2#======================================================================
3# Meta-Admin -- /login.cgi
4#
5# Sign-in only (single-operator console; no signup, no forgot-flow).
6# If Shawn ever forgets the password, reset directly via the
7# _set_password.pl helper or SQL.
8#
9# This page does NOT render the sidebar -- it's the pre-auth screen,
10# so we draw the brand mark + sign-in card centered on the backdrop.
11#======================================================================
12use strict;
13use warnings;
14use lib '/var/www/vhosts/3dshawn.com/admin.3dshawn.com';
15use CGI;
16use MODS::DBConnect;
17use MODS::Login;
18use MODS::MetaAdmin::Config;
19
20my $q = CGI->new;
21my $form = $q->Vars;
22my $auth = MODS::Login->new;
23my $cfg = MODS::MetaAdmin::Config->new;
24
25# Already signed in? -> home. Except when previewing the maintenance
26# overlay (?_preview_maintenance=1), so admins can see how it looks
27# without signing out.
28my $cur = $auth->login_verify;
29if ($cur && $cur->{user_id} && !$form->{_preview_maintenance}) {
30 print "Status: 302 Found\nLocation: /index.cgi\n\n"; exit;
31}
32
33my $op = $form->{op} || '';
34my $err = '';
35
36if ($op eq 'signin') {
37 my ($uid, $sid) = $auth->sign_in($form->{email} || '', $form->{password} || '');
38 if ($uid && $sid) {
39 print $auth->cookie_header($sid) . "\n";
40 print "Status: 302 Found\nLocation: /index.cgi\n\n"; exit;
41 }
42 $err = $sid; # the error message comes back in $sid slot on fail
43}
44
45my $brand_name = $cfg->settings('brand_name') || 'Meta-Admin';
46my $brand_tagline = $cfg->settings('brand_tagline') || 'One console. Every site.';
47my $assets_css = $cfg->settings('assets_css') || '/assets/css';
48
49my $err_h = $err; $err_h =~ s/</&lt;/g; $err_h =~ s/>/&gt;/g;
50# 'maintenance_locked' = friendly translated to the user-facing copy
51$err_h =~ s/^maintenance_locked$/Site is in maintenance mode. Only super-admins can sign in./;
52my $err_html = length($err_h) ? qq~<div class="banner danger">$err_h</div>~ : '';
53
54# Maintenance lockdown overlay (modal). Closeable with X / Esc; reappears
55# on next page load if site is still locked. Admin sign-in path stays
56# usable while the overlay is dismissed.
57my $maint_locked = int($cfg->settings('maintenance_locked') || 0);
58my $maint_html = '';
59if ($maint_locked || $form->{_preview_maintenance}) {
60 my $msg = $cfg->settings('maintenance_message') || '<p>Site is in maintenance mode.</p>';
61 $maint_html = qq~<div id="maint-overlay" style="position:fixed;inset:0;background:rgba(0,0,0,0.88);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);z-index:9999;display:flex;align-items:center;justify-content:center;padding:24px"><div style="position:relative;background:#0f0f0f;border:1px solid rgba(217,119,6,0.6);border-radius:12px;max-width:680px;width:100%;padding:48px 40px;box-shadow:0 30px 90px rgba(0,0,0,0.6),0 0 0 1px rgba(217,119,6,0.15)"><button type="button" aria-label="Close" onclick="document.getElementById('maint-overlay').style.display='none'" style="position:absolute;top:14px;right:14px;width:36px;height:36px;background:transparent;border:1px solid rgba(255,255,255,0.12);color:#aaa;font-size:22px;line-height:1;border-radius:8px;cursor:pointer">&times;</button>$msg</div><script>document.addEventListener('keydown',function(e){if(e.key==='Escape'){var o=document.getElementById('maint-overlay');if(o)o.style.display='none';}});</script></div>~;
62}
63
64print "Content-Type: text/html; charset=utf-8\nCache-Control: no-store\n\n";
65print <<"HTML";
66<!DOCTYPE html>
67<html lang="en">
68<head>
69<meta charset="utf-8">
70<meta name="viewport" content="width=device-width, initial-scale=1">
71<title>Sign in &middot; $brand_name</title>
72<link rel="stylesheet" href="$assets_css/meta.css?v=2">
73</head>
74<body style="display:block">
75<div style="min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px;position:relative;z-index:1">
76 <div style="width:100%;max-width:420px">
77 <div style="text-align:center;margin-bottom:28px">
78 <div class="brand-mark" style="margin:0 auto 14px;width:48px;height:48px;border-radius:12px;font-size:20px">M</div>
79 <div class="brand-name" style="font-size:22px">$brand_name</div>
80 <div class="brand-tag" style="margin-top:4px">$brand_tagline</div>
81 </div>
82 $maint_html
83 $err_html
84 <div class="module glow-magenta">
85 <div class="module-head"><div class="left"><div class="module-title">Sign in</div></div></div>
86 <div class="module-body">
87 <form method="POST" action="/login.cgi">
88 <input type="hidden" name="op" value="signin">
89 <label class="lbl"><span class="t">Email</span>
90 <input type="email" name="email" autocomplete="email" required></label>
91 <label class="lbl"><span class="t">Password</span>
92 <input type="password" name="password" autocomplete="current-password" required></label>
93 <button type="submit" class="btn btn-primary" style="width:100%;justify-content:center">Sign in</button>
94 </form>
95 </div>
96 </div>
97 </div>
98</div>
99</body>
100</html>
101HTML
Keyboard: j next diff k previous diff g top G bottom r restore c compile-check ? help