Diff -- /var/www/vhosts/3dshawn.com/site1/settings.cgi

O Operator
Diff

/var/www/vhosts/3dshawn.com/site1/settings.cgi

added on local at 2026-07-10 18:57:31

Added
+43
lines
Removed
-0
lines
Context
0
unchanged
Blobs
from
to c8439e2627a2
Unified diff
Naive LCS-based line diff. Additions in emerald, deletions in rose. Both sides decompressed live from BLOB_STORE.
1#!/usr/bin/perl
2use strict; use warnings; use CGI ();
3use MODS::Config; use MODS::DBConnect; use MODS::Template; use MODS::PageWrapper;
4my $cfg = MODS::Config->new; my $db = MODS::DBConnect->new; my $tpl = MODS::Template->new;
5$|=1; print "Content-Type: text/html; charset=utf-8\nCache-Control: no-cache\n\n";
6
7# The config file is read-only from the UI (managed by installer + admin).
8# We show its resolved values for confirmation + host statistics.
9my $all = $cfg->all;
10
11# Blob store stats
12my $dbh = $db->db_connect or die "DB connect failed\n";
13my $blob_stats = $db->db_readwrite($dbh, q~
14 SELECT COUNT(*) AS blob_ct,
15 COALESCE(SUM(size_uncompressed), 0) AS bytes_uncomp,
16 COALESCE(SUM(size_compressed), 0) AS bytes_comp,
17 COALESCE(SUM(ref_count), 0) AS total_refs
18 FROM BLOB_STORE
19~, __FILE__, __LINE__);
20$db->db_disconnect($dbh);
21
22my @cfg_rows;
23foreach my $k (sort keys %$all) {
24 my $v = $all->{$k} // '';
25 # Redact secrets
26 $v = length($v) > 4 ? '***' . substr($v, -4) : '****'
27 if $k =~ /pass(word)?|secret|hmac|smtp_password/i && length $v;
28 push @cfg_rows, { key => $k, value => $v };
29}
30
31my $tvars = {
32 cfg_rows => \@cfg_rows,
33 blob_ct => ($blob_stats && $blob_stats->{blob_ct}) || 0,
34 bytes_uncomp => ($blob_stats && $blob_stats->{bytes_uncomp}) || 0,
35 bytes_comp => ($blob_stats && $blob_stats->{bytes_comp}) || 0,
36 total_refs => ($blob_stats && $blob_stats->{total_refs}) || 0,
37 ratio => (($blob_stats && $blob_stats->{bytes_uncomp}) ? sprintf('%.1fx', $blob_stats->{bytes_uncomp} / ($blob_stats->{bytes_comp} || 1)) : '-'),
38};
39my @body = $tpl->template('settings.html', $tvars);
40MODS::PageWrapper->new->wrapper(
41 page_title => 'Settings', page_key => 'settings',
42 body_html => join('', @body), userinfo => { display_name => 'Operator' },
43);