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