line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#Copyright (c) 2001 Giulio Motta. 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::GsmboxIT; |
9
|
1
|
|
|
1
|
|
520
|
use Telephone::Number; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
180
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
@EXPORT = qw(); |
13
|
|
|
|
|
|
|
@EXPORT_OK = qw(@PREFIXES _send MAXLENGTH); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
@PREFIXES = (Telephone::Number->new('39', [ |
16
|
|
|
|
|
|
|
qw(333 334 335 338 339 330 336 337 360 368 340 347 348 349 328 329 380 388 389) |
17
|
|
|
|
|
|
|
], undef) |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$VERSION = '1.00'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub MAXLENGTH () {120} # maximum message length |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub hnd_error { |
25
|
0
|
|
|
0
|
0
|
|
$_ = shift; |
26
|
0
|
|
|
|
|
|
$WWW::SMS::Error = "Failed at step $_ of module GsmboxIT.pm\n"; |
27
|
0
|
|
|
|
|
|
return 0; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _send { |
31
|
0
|
|
|
0
|
|
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
1
|
|
5
|
use HTTP::Request::Common qw(GET POST); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
43
|
|
34
|
1
|
|
|
1
|
|
4
|
use HTTP::Cookies; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
35
|
1
|
|
|
1
|
|
4
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
371
|
|
36
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
$self->{smstext} = substr($self->{smstext}, 0, MAXLENGTH - 1) if (length($self->{smstext})>MAXLENGTH); |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
40
|
0
|
|
|
|
|
|
$ua->agent('Mozilla/5.0'); |
41
|
0
|
0
|
|
|
|
|
$ua->proxy('http', $self->{proxy}) if ($self->{proxy}); |
42
|
0
|
|
|
|
|
|
$ua->cookie_jar(HTTP::Cookies->new( |
43
|
|
|
|
|
|
|
file => $self->{cookie_jar}, |
44
|
|
|
|
|
|
|
autosave => 1 |
45
|
|
|
|
|
|
|
) |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
#STEP 1 |
49
|
0
|
|
|
|
|
|
my $step = 1; |
50
|
0
|
|
|
|
|
|
my $req = POST 'http://it.gsmbox.com/freesms/preview.gsmbox', |
51
|
|
|
|
|
|
|
[ |
52
|
|
|
|
|
|
|
messaggio => $self->{smstext}, |
53
|
|
|
|
|
|
|
country => 'it', |
54
|
|
|
|
|
|
|
prefisso => $self->{prefix}, |
55
|
|
|
|
|
|
|
telefono => $self->{telnum}, |
56
|
|
|
|
|
|
|
]; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $file = $ua->simple_request($req)->as_string; |
59
|
0
|
0
|
|
|
|
|
($file =~ //) || (return &hnd_error($step)); |
60
|
0
|
|
|
|
|
|
$hidname = $1; |
61
|
0
|
|
|
|
|
|
$hidval = $2; |
62
|
|
|
|
|
|
|
#STEP 1 |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#STEP 2 |
65
|
0
|
|
|
|
|
|
$step++; |
66
|
0
|
|
|
|
|
|
$req = POST 'http://it.gsmbox.com/freesms/conf_invio.gsmbox', |
67
|
|
|
|
|
|
|
[ |
68
|
|
|
|
|
|
|
sponsor_id => '0', |
69
|
|
|
|
|
|
|
messaggio => $self->{smstext}, |
70
|
|
|
|
|
|
|
telefono => $self->{telnum}, |
71
|
|
|
|
|
|
|
prefisso => $self->{prefix}, |
72
|
|
|
|
|
|
|
country => $self->{it}, |
73
|
|
|
|
|
|
|
$hidname => $hidval, |
74
|
|
|
|
|
|
|
]; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
$file = $ua->simple_request($req)->as_string; |
77
|
0
|
0
|
|
|
|
|
($file !~ /BATTERIA IN CARICA/i) || (return &hnd_error($step)); |
78
|
|
|
|
|
|
|
#STEP 2 |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |