| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package SMS::Send::CZ::Smsmidlet; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: SMS::Send driver for SMSMidlet - Czech Republic |
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
12987
|
use warnings; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
52
|
|
|
8
|
2
|
|
|
2
|
|
6
|
use strict; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
31
|
|
|
9
|
2
|
|
|
2
|
|
6
|
use Carp; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
140
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = "1.000"; |
|
12
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
|
13
|
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
1093
|
use LWP::UserAgent; |
|
|
2
|
|
|
|
|
58705
|
|
|
|
2
|
|
|
|
|
44
|
|
|
15
|
2
|
|
|
2
|
|
8
|
use URI::Escape; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
111
|
|
|
16
|
2
|
|
|
2
|
|
1488
|
use DateTime qw(); |
|
|
2
|
|
|
|
|
166512
|
|
|
|
2
|
|
|
|
|
59
|
|
|
17
|
2
|
|
|
2
|
|
10
|
use base 'SMS::Send::Driver'; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
467
|
|
|
18
|
2
|
|
|
2
|
|
231
|
use Digest::MD5 qw(md5 md5_hex); |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
83
|
|
|
19
|
2
|
|
|
2
|
|
793
|
use Log::LogLite; |
|
|
2
|
|
|
|
|
18835
|
|
|
|
2
|
|
|
|
|
43
|
|
|
20
|
2
|
|
|
2
|
|
1016
|
use Data::Dumper; |
|
|
2
|
|
|
|
|
8654
|
|
|
|
2
|
|
|
|
|
878
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
|
23
|
1
|
|
|
1
|
1
|
52
|
my $class = shift; |
|
24
|
1
|
|
|
|
|
2
|
my %params = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
1
|
my $LOG_FILE = "/var/log/smsmidlet.log"; |
|
27
|
1
|
|
|
|
|
1
|
my $ERROR_LOG_LEVEL = 6; |
|
28
|
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
243
|
open HANDLE, ">>$LOG_FILE"; |
|
30
|
1
|
|
|
|
|
7
|
close HANDLE; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Create our LWP::UserAgent object |
|
33
|
1
|
|
|
|
|
8
|
my $ua = LWP::UserAgent->new; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Create the object, saving any private params for later |
|
36
|
|
|
|
|
|
|
my $self = bless { |
|
37
|
|
|
|
|
|
|
ua => $ua, |
|
38
|
|
|
|
|
|
|
login => $params{_login}, |
|
39
|
|
|
|
|
|
|
password => $params{_password}, |
|
40
|
1
|
50
|
|
|
|
1991
|
private => \%params, |
|
41
|
|
|
|
|
|
|
log => (-w $LOG_FILE) ? new Log::LogLite($LOG_FILE, $ERROR_LOG_LEVEL) : 0 |
|
42
|
|
|
|
|
|
|
}, $class; |
|
43
|
1
|
|
|
|
|
139
|
$self->log("Driver Smsmidlet created", 4); |
|
44
|
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
188
|
$self; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub log { |
|
49
|
3
|
|
|
3
|
1
|
3
|
my ($self, $msg, $level) = @_; |
|
50
|
|
|
|
|
|
|
|
|
51
|
3
|
50
|
|
|
|
12
|
if ($self->{'log'}) { |
|
52
|
3
|
|
|
|
|
8
|
$self->{'log'}->write($msg, $level); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub send_sms { |
|
57
|
1
|
|
|
1
|
1
|
697
|
my ($self, %args) = @_; |
|
58
|
1
|
|
|
|
|
2
|
my $url = 'https://smsmidlet.com/http'; |
|
59
|
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
3
|
$self->log("TEXT: " . $args{'text'} . ", TO: " . $args{'to'}, 4); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my %params = ( |
|
63
|
|
|
|
|
|
|
'number' => $args{'to'} || '', |
|
64
|
|
|
|
|
|
|
'data' => $args{'text'} || '', |
|
65
|
|
|
|
|
|
|
'username' => $self->{'login'}, |
|
66
|
1
|
|
50
|
|
|
145
|
'password' => $self->{'password'}, |
|
|
|
|
50
|
|
|
|
|
|
67
|
|
|
|
|
|
|
'action' => 'sendsmsall' |
|
68
|
|
|
|
|
|
|
); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# cleanup |
|
71
|
1
|
|
|
|
|
2
|
$params{'number'} =~ s{\D}{}g; # remove non-digits |
|
72
|
1
|
50
|
|
|
|
3
|
if (length($params{'number'}) == 9) { |
|
73
|
1
|
|
|
|
|
2
|
$params{'number'} = '420' . $params{'number'}; |
|
74
|
1
|
|
|
|
|
3
|
$self->log("Auto-prefix: " . $args{'to'} . " => " . $params{'number'}, 4); |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# send away |
|
78
|
1
|
|
|
|
|
121
|
my $uri = join( '&', map { $_ . '=' . uri_escape_utf8( $params{ $_ } ) } keys %params ); |
|
|
5
|
|
|
|
|
65
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
14
|
my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 }); |
|
81
|
1
|
|
|
|
|
112
|
$ua->protocols_allowed( ['https'] ); |
|
82
|
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
29
|
my $res = $ua->get($url . "?" . $uri); |
|
84
|
|
|
|
|
|
|
|
|
85
|
1
|
50
|
|
|
|
8695
|
if( $res->{'_rc'} == 200 ) { |
|
86
|
0
|
|
|
|
|
0
|
$params{'password'} = "------"; # hide password in logs |
|
87
|
0
|
|
|
|
|
0
|
my $successLog = $url . "?" . join( '&', map { $_ . '=' . uri_escape_utf8( $params{ $_ } ) } keys %params ); |
|
|
0
|
|
|
|
|
0
|
|
|
88
|
0
|
|
|
|
|
0
|
$self->log("HTTP SUCCESS: " . $successLog, 4); |
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
0
|
|
|
|
0
|
if ($res->{'_content'} =~ /(\d+)<\/stat>([^<]+)<\/info>/) { |
|
91
|
0
|
|
|
|
|
0
|
my $stat = $1; |
|
92
|
0
|
|
|
|
|
0
|
my $info = $2; |
|
93
|
0
|
|
|
|
|
0
|
my $logMsg; |
|
94
|
0
|
|
|
|
|
0
|
my $result = 0; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
SWITCH: { |
|
97
|
0
|
0
|
|
|
|
0
|
if ($stat == 1) { $logMsg = "SMS #" . $info . " sent"; $result = 1; last SWITCH; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
98
|
0
|
0
|
|
|
|
0
|
if ($stat == 11) { $logMsg = "SMS #" . $info . " deferred, re-sending in 1 minute"; $result = 1; last SWITCH; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
99
|
0
|
|
|
|
|
0
|
$logMsg = "SMS processing error #" . $stat . ": " . $info; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
0
|
$self->log($logMsg, 4); |
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
0
|
return $result; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
else { |
|
108
|
1
|
|
|
|
|
30
|
return 0; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__END__ |