line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#Copyright (c) 2001 Dmitry Dmitriev. All rights reserved. |
4
|
|
|
|
|
|
|
#http://www-sms.sourceforge.net/ |
5
|
|
|
|
|
|
|
#This program is free software; you can redistribute it and/or |
6
|
|
|
|
|
|
|
#modify it under the same terms as Perl itself. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package WWW::SMS::MTS; |
9
|
1
|
|
|
1
|
|
688
|
use Telephone::Number; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
221
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
@EXPORT = qw(); |
13
|
|
|
|
|
|
|
@EXPORT_OK = qw(@PREFIXES _send MAXLENGTH); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
@PREFIXES = (Telephone::Number->new('7', [ |
16
|
|
|
|
|
|
|
qw(095 902 910) |
17
|
|
|
|
|
|
|
], undef) |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$VERSION = '1.03'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub MAXLENGTH () {155} # maximum message length |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub hnd_error { |
25
|
0
|
|
|
0
|
0
|
|
$_ = shift; |
26
|
0
|
|
|
|
|
|
$WWW::SMS::Error = "Failed at step $_ of module MTS.pm\n"; |
27
|
0
|
|
|
|
|
|
return 0; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _send { |
31
|
0
|
|
|
0
|
|
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# now useless with @PREFIXES |
34
|
|
|
|
|
|
|
#if ( $self->{intpref} ne '7' ) { |
35
|
|
|
|
|
|
|
# $WWW::SMS::Error = "Int. prefix $self->{intpref} not supported by MTS gateway\n"; |
36
|
|
|
|
|
|
|
# return 0;} |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
1
|
|
7
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
39
|
1
|
|
|
1
|
|
6
|
use HTTP::Request::Common qw(GET POST); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
560
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
$self->{smstext} = substr($self->{smstext}, 0, MAXLENGTH - 1) if (length($self->{smstext})>MAXLENGTH); |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
46
|
0
|
|
|
|
|
|
$ua->agent('Mozilla/5.0'); |
47
|
0
|
0
|
|
|
|
|
$ua->proxy('http', $self->{proxy}) if ($self->{proxy}); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#STEP 1 |
51
|
0
|
|
|
|
|
|
my $step = 1; |
52
|
|
|
|
|
|
|
### define SMS expiration date |
53
|
0
|
|
|
|
|
|
my ($day,$mon,$year)=(localtime time)[3,4,5]; |
54
|
0
|
0
|
|
|
|
|
if ($day > 27) {$day=2;$mon++; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
if ($mon > 11) {$mon=0;$year++} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else {$day+=2;} |
58
|
0
|
|
|
|
|
|
$year=1900+$year; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$req = POST 'http://www.mtsgsm.com/sms/sent.html', |
61
|
|
|
|
|
|
|
[ Posted => '1', |
62
|
|
|
|
|
|
|
To => $self->{intpref} . $self->{prefix} . $self->{telnum}, |
63
|
|
|
|
|
|
|
Msg => $self->{smstext}, |
64
|
|
|
|
|
|
|
count => length($self->{smstext}), |
65
|
|
|
|
|
|
|
SMSHour => '23', |
66
|
|
|
|
|
|
|
SMSMinute => '59', |
67
|
|
|
|
|
|
|
SMSDay => $day, |
68
|
|
|
|
|
|
|
SMSMonth => $mon, |
69
|
|
|
|
|
|
|
SMSYear => $year |
70
|
|
|
|
|
|
|
]; |
71
|
0
|
|
|
|
|
|
my $file=$req->content; |
72
|
0
|
|
|
|
|
|
$req = GET 'http://www.mtsgsm.com/sms/sent.html?'.$file; |
73
|
0
|
|
|
|
|
|
$req->content_type('application/x-www-form-urlencoded'); |
74
|
0
|
|
|
|
|
|
$req->referer('http://www.mtsgsm.com/sms'); |
75
|
0
|
|
|
|
|
|
$res = $ua->request($req); |
76
|
0
|
0
|
|
|
|
|
$res->is_success() || (return &hnd_error($step)); |
77
|
|
|
|
|
|
|
#STEP 1 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#STEP 2 |
80
|
0
|
|
|
|
|
|
$step++; |
81
|
0
|
0
|
|
|
|
|
($res->content =~ /(÷ÁÛÅ ÓÏÏÂÝÅÎÉÅ ÏÔÐÒÁ×ÌÅÎÏ|Âàøå ñîîáùåíèå îòïðàâëåíî|Message sent)<\/b>/) |
82
|
|
|
|
|
|
|
|| (return &hnd_error($step)); |
83
|
|
|
|
|
|
|
#STEP 2 |
84
|
0
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
1; |