1#!/usr/local/bin/perl
2
3require './filemin-lib.pl';
4
5&ReadParse();
6
7get_paths();
8
9my $recursive;
10
11if   ( $in{'recursive'} eq 'true' ) { $recursive = '-R'; }
12else                                { $recursive = ''; }
13
14my @errors;
15if ( !$in{'label'} ) {
16    push @errors, "$text{'attr_label_error'}";
17}
18
19my $label = quotemeta("$in{'label'}");
20$label =~ s/\\-/-/g;
21$label =~ s/\\+//g;
22$label =~ tr/a-zA-Z\-\+ //dc;
23
24if ( scalar(@errors) > 0 ) {
25    print_errors(@errors);
26}
27else {
28    foreach my $file ( split( /\0/, $in{'name'} ) ) {
29        $file =~ s/\.\.//g;
30        $file = &simplify_path($file);
31        if (
32            system_logged(
33                "chattr $recursive " . $label . " " . quotemeta("$cwd/$file")
34            ) != 0
35          )
36        {
37            push @errors,
38              ( html_escape($file) . " - $text{'attr_label_error_proc'}: $?" );
39        }
40    }
41
42    if ( scalar(@errors) > 0 ) {
43        print_errors(@errors);
44    }
45    else {
46	&redirect("index.cgi?path=".&urlize($path));
47    }
48}
49