line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::RemoteGnokii; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
33586
|
use 5.014000; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
375
|
|
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
5
|
1
|
|
|
1
|
|
26
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
74
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.000_001'; |
7
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1694
|
use Config::Any; |
|
1
|
|
|
|
|
15979
|
|
|
1
|
|
|
|
|
47
|
|
10
|
1
|
|
|
1
|
|
2307
|
use File::Copy qw/move/; |
|
1
|
|
|
|
|
6969
|
|
|
1
|
|
|
|
|
185
|
|
11
|
1
|
|
|
1
|
|
2014
|
use File::Temp qw/tempfile/; |
|
1
|
|
|
|
|
31153
|
|
|
1
|
|
|
|
|
94
|
|
12
|
1
|
|
|
1
|
|
3800
|
use Plack::Request; |
|
1
|
|
|
|
|
102308
|
|
|
1
|
|
|
|
|
542
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $cfg; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub cfg ($){ |
17
|
0
|
0
|
|
0
|
0
|
|
unless ($cfg) { |
18
|
0
|
|
0
|
|
|
|
$cfg = Config::Any->load_stems({stems => [$ENV{RGCONFIG} // '/etc/rg'], use_ext => 1, flatten_to_hash => 1}); |
19
|
0
|
|
|
|
|
|
my @cfg = values %$cfg; |
20
|
0
|
|
|
|
|
|
$cfg = $cfg[0]; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
$cfg->{$_[0]} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub sendsms { |
27
|
0
|
|
|
0
|
0
|
|
my ($number, $text) = @_; |
28
|
0
|
|
|
|
|
|
my ($fh, $file) = tempfile 'smsXXXX', TMPDIR => 1; |
29
|
0
|
|
|
|
|
|
print $fh "$number\n$text"; |
30
|
0
|
|
|
|
|
|
close $fh; |
31
|
0
|
|
|
|
|
|
move $file, cfg 'spool'; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
################################################## |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub action { |
37
|
0
|
|
|
0
|
0
|
|
my ($number, $date, $text) = @_; |
38
|
0
|
|
|
|
|
|
my $password = cfg 'password'; |
39
|
0
|
|
|
|
|
|
sendsms cfg 'number', <
|
40
|
|
|
|
|
|
|
$password |
41
|
|
|
|
|
|
|
$number |
42
|
|
|
|
|
|
|
$date |
43
|
|
|
|
|
|
|
$text |
44
|
|
|
|
|
|
|
EOF |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub psgi { |
48
|
0
|
|
|
0
|
0
|
|
my $correct_password = cfg 'password'; |
49
|
|
|
|
|
|
|
sub { |
50
|
0
|
|
|
0
|
|
|
my $r = Plack::Request->new(shift); |
51
|
0
|
|
|
|
|
|
my @numbers = split ',', $r->param('numbers'); |
52
|
0
|
|
|
|
|
|
my $password = $r->param('password'); |
53
|
0
|
0
|
|
|
|
|
return [403, ['Content-Type', 'text/plain'], ['Bad password']] unless $password eq $correct_password; |
54
|
0
|
|
|
|
|
|
my $text = $r->param('text'); |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
sendsms $_, $text for @numbers |
57
|
|
|
|
|
|
|
} |
58
|
0
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
__END__ |