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

O Operator
Diff

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

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

Added
+0
lines
Removed
-0
lines
Context
101
unchanged
Blobs
from 56ec410dc6af
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.
11#!/usr/bin/perl
22#======================================================================
33# Meta-Admin -- /login.cgi
44#
55# Sign-in only (single-operator console; no signup, no forgot-flow).
66# If Shawn ever forgets the password, reset directly via the
77# _set_password.pl helper or SQL.
88#
99# This page does NOT render the sidebar -- it's the pre-auth screen,
1010# so we draw the brand mark + sign-in card centered on the backdrop.
1111#======================================================================
1212use strict;
1313use warnings;
1414use lib '/var/www/vhosts/3dshawn.com/admin.3dshawn.com';
1515use CGI;
1616use MODS::DBConnect;
1717use MODS::Login;
1818use MODS::MetaAdmin::Config;
1919
2020my $q = CGI->new;
2121my $form = $q->Vars;
2222my $auth = MODS::Login->new;
2323my $cfg = MODS::MetaAdmin::Config->new;
2424
2525# Already signed in? -> home. Except when previewing the maintenance
2626# overlay (?_preview_maintenance=1), so admins can see how it looks
2727# without signing out.
2828my $cur = $auth->login_verify;
2929if ($cur && $cur->{user_id} && !$form->{_preview_maintenance}) {
3030 print "Status: 302 Found\nLocation: /index.cgi\n\n"; exit;
3131}
3232
3333my $op = $form->{op} || '';
3434my $err = '';
3535
3636if ($op eq 'signin') {
3737 my ($uid, $sid) = $auth->sign_in($form->{email} || '', $form->{password} || '');
3838 if ($uid && $sid) {
3939 print $auth->cookie_header($sid) . "\n";
4040 print "Status: 302 Found\nLocation: /index.cgi\n\n"; exit;
4141 }
4242 $err = $sid; # the error message comes back in $sid slot on fail
4343}
4444
4545my $brand_name = $cfg->settings('brand_name') || 'Meta-Admin';
4646my $brand_tagline = $cfg->settings('brand_tagline') || 'One console. Every site.';
4747my $assets_css = $cfg->settings('assets_css') || '/assets/css';
4848
4949my $err_h = $err; $err_h =~ s/</&lt;/g; $err_h =~ s/>/&gt;/g;
5050# 'maintenance_locked' = friendly translated to the user-facing copy
5151$err_h =~ s/^maintenance_locked$/Site is in maintenance mode. Only super-admins can sign in./;
5252my $err_html = length($err_h) ? qq~<div class="banner danger">$err_h</div>~ : '';
5353
5454# Maintenance lockdown overlay (modal). Closeable with X / Esc; reappears
5555# on next page load if site is still locked. Admin sign-in path stays
5656# usable while the overlay is dismissed.
5757my $maint_locked = int($cfg->settings('maintenance_locked') || 0);
5858my $maint_html = '';
5959if ($maint_locked || $form->{_preview_maintenance}) {
6060 my $msg = $cfg->settings('maintenance_message') || '<p>Site is in maintenance mode.</p>';
6161 $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>~;
6262}
6363
6464print "Content-Type: text/html; charset=utf-8\nCache-Control: no-store\n\n";
6565print <<"HTML";
6666<!DOCTYPE html>
6767<html lang="en">
6868<head>
6969<meta charset="utf-8">
7070<meta name="viewport" content="width=device-width, initial-scale=1">
7171<title>Sign in &middot; $brand_name</title>
7272<link rel="stylesheet" href="$assets_css/meta.css?v=2">
7373</head>
7474<body style="display:block">
7575<div style="min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px;position:relative;z-index:1">
7676 <div style="width:100%;max-width:420px">
7777 <div style="text-align:center;margin-bottom:28px">
7878 <div class="brand-mark" style="margin:0 auto 14px;width:48px;height:48px;border-radius:12px;font-size:20px">M</div>
7979 <div class="brand-name" style="font-size:22px">$brand_name</div>
8080 <div class="brand-tag" style="margin-top:4px">$brand_tagline</div>
8181 </div>
8282 $maint_html
8383 $err_html
8484 <div class="module glow-magenta">
8585 <div class="module-head"><div class="left"><div class="module-title">Sign in</div></div></div>
8686 <div class="module-body">
8787 <form method="POST" action="/login.cgi">
8888 <input type="hidden" name="op" value="signin">
8989 <label class="lbl"><span class="t">Email</span>
9090 <input type="email" name="email" autocomplete="email" required></label>
9191 <label class="lbl"><span class="t">Password</span>
9292 <input type="password" name="password" autocomplete="current-password" required></label>
9393 <button type="submit" class="btn btn-primary" style="width:100%;justify-content:center">Sign in</button>
9494 </form>
9595 </div>
9696 </div>
9797 </div>
9898</div>
9999</body>
100100</html>
101101HTML