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

O Operator
Diff

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

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

Added
+40
lines
Removed
-0
lines
Context
0
unchanged
Blobs
from
to f0a44a1113a6
Restore this content →
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 $cgi = CGI->new; my $db = MODS::DBConnect->new; my $tpl = MODS::Template->new;
5$|=1;
6my $dbh = $db->db_connect or die "DB connect failed\n";
7
8if (($ENV{REQUEST_METHOD} || '') eq 'POST' && $cgi->param('save')) {
9 my $q_name = $dbh->quote($cgi->param('scan_name') || '');
10 my $q_path = $dbh->quote($cgi->param('scan_path') || '');
11 my $q_ig = $dbh->quote($cgi->param('ignore_list') || '.git/,node_modules/,*.log,*.tmp,.DS_Store');
12 my $q_ft = $dbh->quote($cgi->param('file_type_filter') || '');
13 my $status = $cgi->param('status') ? 1 : 0;
14 $db->db_readwrite($dbh, qq~
15 INSERT INTO FILE_MONITOR_SETTINGS
16 (scan_name, scan_path, ignore_list, file_type_filter, status, server_id)
17 VALUES ($q_name, $q_path, $q_ig, $q_ft, $status, 1)
18 ~, __FILE__, __LINE__);
19 print "Status: 302 Found\nLocation: /file_monitors.cgi?saved=1\n\n"; exit;
20}
21
22print "Content-Type: text/html; charset=utf-8\nCache-Control: no-cache\n\n";
23my @rows = $db->db_readwrite_multiple($dbh, q~
24 SELECT file_monitor_list_id AS id, scan_name, scan_path, ignore_list, file_type_filter,
25 status, DATE_FORMAT(last_scanned, '%b %d %H:%i') AS last_h
26 FROM FILE_MONITOR_SETTINGS ORDER BY file_monitor_list_id ASC
27~, __FILE__, __LINE__);
28foreach my $r (@rows) {
29 $r->{status_pill} = $r->{status} ? 'pill-ok' : 'pill-mute';
30 $r->{status_lbl} = $r->{status} ? 'ACTIVE' : 'DISABLED';
31 $r->{ignore_preview} = $r->{ignore_list} ? substr($r->{ignore_list}, 0, 50) . (length($r->{ignore_list}) > 50 ? '...' : '') : '';
32}
33$db->db_disconnect($dbh);
34
35my @body = $tpl->template('file_monitors.html',
36 { rows => \@rows, has_rows => scalar(@rows) ? 1 : 0, total => scalar @rows });
37MODS::PageWrapper->new->wrapper(
38 page_title => 'File monitors', page_key => 'file_monitors',
39 body_html => join('', @body), userinfo => { display_name => 'Operator' },
40);