Diff -- /var/www/vhosts/3dshawn.com/admin.3dshawn.com/MODS/MetaAdmin/Config.pm
Diff
/var/www/vhosts/3dshawn.com/admin.3dshawn.com/MODS/MetaAdmin/Config.pm
added on local at 2026-07-10 15:05:21
Added
+62
lines
Removed
-0
lines
Context
0
unchanged
Blobs
from
to d92bd109a3ee
to d92bd109a3ee
Unified diff
Naive LCS-based line diff. Additions in emerald, deletions in rose. Both sides decompressed live from BLOB_STORE.| 1 | package MODS::MetaAdmin::Config; | |
| 2 | #====================================================================== | |
| 3 | # Meta-Admin -- platform_settings reader with code-defaults fallback. | |
| 4 | # Mirrors the pattern in every other site's Config module so calls | |
| 5 | # like $cfg->settings('brand_name') Just Work. | |
| 6 | #====================================================================== | |
| 7 | use strict; | |
| 8 | use warnings; | |
| 9 | ||
| 10 | my %DEFAULTS = ( | |
| 11 | database_name => 'admin3dshawn', | |
| 12 | brand_name => 'Meta-Admin', | |
| 13 | brand_tagline => 'One console. Every site.', | |
| 14 | cookie_name => 'meta_session', | |
| 15 | session_minutes => 720, | |
| 16 | # Let's Encrypt cert provisioned 2026-07-09 -- Secure flag now safe. | |
| 17 | secure_cookies => 1, | |
| 18 | cookie_domain => '.admin.3dshawn.com', | |
| 19 | assets => '/assets', | |
| 20 | assets_css => '/assets/css', | |
| 21 | assets_images => '/assets/images', | |
| 22 | # AES key used to encrypt site_connections.db_pass_enc. Rotating | |
| 23 | # invalidates every saved site password (re-enter via /sites.cgi). | |
| 24 | site_conn_enc_key => 'aE7wQz5mLp2RvNxK8jHfYsT3uXbWcD1gC0iVnB-aJkOiPyDhRoSlFwUaKuTzM', | |
| 25 | ); | |
| 26 | ||
| 27 | my %_DB_CACHE; | |
| 28 | ||
| 29 | sub new { return bless({}, shift); } | |
| 30 | ||
| 31 | sub settings { | |
| 32 | my ($self, $key) = @_; | |
| 33 | return $DEFAULTS{database_name} if $key eq 'database_name'; | |
| 34 | ||
| 35 | return $_DB_CACHE{$key} if exists $_DB_CACHE{$key}; | |
| 36 | ||
| 37 | # DB lookup -- silent fail to code defaults if the table or | |
| 38 | # connection isn't ready. | |
| 39 | eval { | |
| 40 | require MODS::DBConnect; | |
| 41 | my $db = MODS::DBConnect->new; | |
| 42 | my $dbh = $db->db_connect(); | |
| 43 | if ($dbh) { | |
| 44 | my $key_q = $key; $key_q =~ s/'/''/g; | |
| 45 | my $sth = $dbh->prepare( | |
| 46 | "SELECT setting_value FROM platform_settings WHERE setting_key='$key_q' LIMIT 1" | |
| 47 | ); | |
| 48 | if ($sth && $sth->execute) { | |
| 49 | if (my $r = $sth->fetchrow_hashref) { | |
| 50 | $_DB_CACHE{$key} = $r->{setting_value}; | |
| 51 | } | |
| 52 | $sth->finish; # release cursor so db_disconnect is clean | |
| 53 | } | |
| 54 | $db->db_disconnect($dbh); | |
| 55 | } | |
| 56 | }; | |
| 57 | return $_DB_CACHE{$key} if exists $_DB_CACHE{$key}; | |
| 58 | ||
| 59 | return $DEFAULTS{$key}; | |
| 60 | } | |
| 61 | ||
| 62 | 1; |