-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.cgi
executable file
·52 lines (47 loc) · 1.05 KB
/
check.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
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use CGI;
my $q = CGI->new;
my $check_subs = {
# execute cgi
execute_cgi => sub {
return '';
},
# able to write db.
able_to_write_db => sub {
mkdir './db', 755;
my $check_file = './db/check.db';
my $res = open my $f, '>>', $check_file;
unless ($res) {
return 'database directory is not writable. ./db/';
}
close $f;
unlink $check_file;
return '';
},
# db_initialized
db_initialized => sub {
if (!-f './db/1.db') {
return 'not initialized';
}
},
};
my $sub = $check_subs->{$q->param('m')};
if (! $sub) {
print "Status: 500 invalid request\n";
print "Content-Type: text/html\n\n";
print "invalid request";
die "invalid request\n";
}
my $result = $sub->();
if ($result) {
print "Status: 500 check error\n";
print "Content-Type: text/html\n\n";
print $result;
die "check error: $result\n";
}
# ok
print "Content-Type: text/html\n\n";
print "ok";