-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscandir_main.cgi
executable file
·89 lines (70 loc) · 2.64 KB
/
scandir_main.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/perl
# Copyright (C) 2003-2019
# Emmanuel Saracco <emmanuel@esaracco.fr>
#
# GNU GENERAL PUBLIC LICENSE
require './clamav-lib.pl';
&clamav_check_acl ('directories_check_view');
&ReadParse ();
my ($_success, $_error, $_info) = ('', '', '');
my $scandir = (defined($in{'next'}) && $in{'what'} ne '');
# delete files if requested
if (defined($in{'delete'}) &&
&clamav_get_acl ('directories_check_delete') == 1)
{
while (my ($k, $v) = each (%in))
{
if ($k =~ /infected_file/ &&
$v =~ /virus|spam|badh|banned/ && &is_secure ($v))
{
unlink ($v);
}
}
$_success = $text{'FILES_DELETED'};
}
&clamav_header ($text{'LINK_SCANDIR'});
print qq(<form method="POST" action="$scriptname">);
print qq(<p>$text{'SCANDIR_DESCRIPTION'}</p>);
if (defined($in{'next'}) && (! -d $in{'what'} || !&is_secure ($in{'what'})))
{
$_error = $text{'MSG_CLAMSCAN_BAD_SCAN_DIR'};
$scandir = 0;
}
if (defined($in{'next'}) && $in{'move'} eq 'on' &&
(! -d $in{'move_path'} || !&is_secure ($in{'move_path'})))
{
$_error = $text{'MSG_CLAMSCAN_BAD_MOVE_DIR'};
$scandir = 0;
}
printf qq(<input type="text" name="what" value="%s">), &html_escape ($in{'what'});
print &file_chooser_button('what', 1, 0);
if (&clamav_has_clamscan !~ /clamdscan/)
{
$checked = ($in{'recursive'} eq 'on') ? ' checked="checked"' : '';
print qq(<p/><p><input id="recursive" type="checkbox" name="recursive" value="on"$checked /> );
print qq(<label for="recursive">$text{'CHECK_SUB'}</label></p>);
}
else
{
print qq(<input type="hidden" name="recursive" value=""/>);
}
$checked = ($in{'infected'} eq 'on') ? ' checked="checked"' : '';
print qq(<p><input id="infected" type="checkbox" name="infected" value="on"$checked> );
print qq(<label for="infected">$text{'SHOW_INFECTED_ONLY'}</label></p>);
$checked = ($in{'move'} eq 'on') ? ' checked="checked"' : '';
print qq(<p><input id="move" type="checkbox" name="move" value="on"$checked> );
printf qq(<label for="move">$text{'MOVE_INFECTED_FILES'}</label> <span style="white-space:nowrap"><input type="text" name="move_path" value="%s">), &html_escape ($in{'move_path'});
print &file_chooser_button('move_path', 1, 0);
print qq(</span></p>);
print qq(<p/><div><button type="submit" name="next" class="btn btn-success ui_form_end_submit"><i class="fa fa-fw fa-search"></i> <span>$text{'CHECK_DIR'}</span></button></div>);
if ($scandir == 1)
{
print qq(<hr>);
($_info, $_error) = &clamav_scandir ($in{'what'},
($in{'recursive'} eq 'on'),
($in{'infected'} eq 'on'),
(($in{'move'} eq 'on')) ? $in{'move_path'} : ''
);
}
print qq(</form>);
&clamav_footer ('', $text{'RETURN_INDEX_MODULE'}, $_success, $_error, $_info);