-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththread.cgi
More file actions
65 lines (51 loc) · 1.38 KB
/
Copy paththread.cgi
File metadata and controls
65 lines (51 loc) · 1.38 KB
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
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use Digest::MD5 qw(md5_hex);
my $q = CGI->new;
my $bbs = $q->param('bbs');
my $title = $q->param('title');
my $name = $q->param('FROM') || '名無しさん';
my $mail = $q->param('mail') || '';
my $body = $q->param('MESSAGE') || '';
if (!$bbs || !$title || !$body) {
print "Content-Type: text/html; charset=UTF-8\n\n";
print "<html><body>入力が不足しています。</body></html>";
exit;
}
my $dir = "/var/www/html/";
my $datdir = "$dir/dat";
mkdir $datdir if !-d $datdir;
my $key = time();
my $dat = "$datdir/$key.dat";
my @t = localtime();
my $time = sprintf(
"%04d/%02d/%02d(%s) %02d:%02d:%02d",
$t[5]+1900, $t[4]+1, $t[3],
(qw(日 月 火 水 木 金 土))[$t[6]],
$t[2], $t[1], $t[0]
);
my $ip = $ENV{'REMOTE_ADDR'} || "0.0.0.0";
my ($sec,$min,$hour,$mday,$mon,$year) = localtime;
my $date = sprintf("%04d%02d%02d", $year + 1900, $mon + 1, $mday);
my $id = uc substr(md5_hex("$ip$date"), 0, 8);
my $timecol = "$time ID:$id";
my $firstline = join("<>",
1,
$name,
$mail,
$timecol,
$body,
$title,
""
) . "\n";
open my $fh, ">", $dat or die "Cannot write dat: $!";
print $fh $firstline;
close $fh;
my $subject = "$dir/subject.txt";
open my $sfh, ">>", $subject or die "Cannot write subject: $!";
print $sfh "$key.dat<>$title (1)\n";
close $sfh;
print "Status: 302 Found\n";
print "Location: index.htm\n\n";