-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile.pl
executable file
·45 lines (37 loc) · 852 Bytes
/
file.pl
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
#!perl -w
$|=1;
no warnings 'uninitialized';
use lib 'mods';
use F;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $cgi = new CGI;
my $FILE = $cgi->param('file');
my $CONTENT = $cgi->param('content');
my $READ = $cgi->param('read');
# Output mode
use html;
my $O = html->new;
my $name = substr $FILE, rindex($FILE,'/')+1;
my $path = $FILE.'/';
print "content-type:text/html\n\n";
if (defined $cgi->param('content'))
{
$CONTENT =~ s/<div><br><\/div>/\n/gi;
$CONTENT =~ s/<div>/\n/gi;
$CONTENT =~ s/<br>/\n/gi;
$CONTENT =~ s/<[^>]+>//g;
$CONTENT =~ s/\ \;/ /g;
open (my $F, '>'.$path.$name.'.txt') or die $!;
print $F $CONTENT;
close $F;
print $O->content($path.$name.'.txt', 0, 1);
}
elsif ($READ)
{
my $r = '';
open (my $F, $path.$name.'.txt') or die $!;
while (<$F>) { $r .= $_; }
close $F;
print $r ? $r : '(empty)';
}