diff options
author | Yorhel <git@yorhel.nl> | 2021-06-28 11:13:18 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2021-06-28 11:13:18 +0200 |
commit | 823536f5ef4eaaa629888aa829e07877a4aa44b6 (patch) | |
tree | 003f7aa03c819817b7d0f9fbc6de1d709cf2fdf9 /lib/VNWeb/Misc | |
parent | a2794afdc01d464c1e4a2046fd6c6c9ae862afca (diff) |
Add a few global lockdown modes
Diffstat (limited to 'lib/VNWeb/Misc')
-rw-r--r-- | lib/VNWeb/Misc/Lockdown.pm | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/VNWeb/Misc/Lockdown.pm b/lib/VNWeb/Misc/Lockdown.pm new file mode 100644 index 00000000..94408b1e --- /dev/null +++ b/lib/VNWeb/Misc/Lockdown.pm @@ -0,0 +1,54 @@ +package VNWeb::Misc::Lockdown; + +use VNWeb::Prelude; + +TUWF::get '/lockdown', sub { + return tuwf->resDenied if !auth->isMod; + + sub chk_ { + my($name, $lbl) = @_; + label_ sub { + input_ type => 'checkbox', name => $name, global_settings->{$name} ? (checked => 'checked') : (); + txt_ $lbl; + }; + br_; + } + + framework_ title => 'Database lockdown', sub { + div_ class => 'mainbox', sub { + h1_ 'Database lockdown'; + + p_ sub { + txt_ 'This form provides a sledghehammer approach to dealing with + targeted vandalism or spam attacks on the site. The goal of + these options is to put the website in a temporary lockdown + while waiting for Yorhel to wake up or while a better solution + is being worked on.'; + br_; + txt_ 'Moderators can keep using the site as usual regardless of these settings.'; + }; + + form_ action => '/lockdown', method => 'post', style => 'margin: 20px', sub { + chk_ lockdown_registration => ' Disable account creation.'; + chk_ lockdown_edit => ' Disable database editing globally. Also disables image and tag voting.'; + chk_ lockdown_board => ' Disable forum and review posting globally.'; + input_ type => 'submit', name => 'submit', class => 'submit', value => 'Submit'; + }; + }; + }; +}; + + +TUWF::post '/lockdown', sub { + return auth->resDenied if !auth->isMod || !samesite; + my $frm = tuwf->validate(post => + lockdown_registration => { anybool => 1 }, + lockdown_edit => { anybool => 1 }, + lockdown_board => { anybool => 1 }, + )->data; + tuwf->dbExeci('UPDATE global_settings SET', $frm); + auth->audit(0, 'lockdown', JSON::XS->new->encode($frm)); + tuwf->resRedirect('/lockdown', 'post'); +}; + +1; |