| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: Omnitel.pm,v 1.1 2003/03/21 00:10:44 eim Exp $ |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
############################################################################# |
|
6
|
|
|
|
|
|
|
# # |
|
7
|
|
|
|
|
|
|
# IMPORTANT NOTE # |
|
8
|
|
|
|
|
|
|
# # |
|
9
|
|
|
|
|
|
|
# !!! THE AUTHOR IS ==NOT== RESPONSIBLE FOR ANY USE OF THIS PROGRAM !!! # |
|
10
|
|
|
|
|
|
|
# # |
|
11
|
|
|
|
|
|
|
# GPL LICENSE # |
|
12
|
|
|
|
|
|
|
# # |
|
13
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify # |
|
14
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by # |
|
15
|
|
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or # |
|
16
|
|
|
|
|
|
|
# (at your option) any later version. # |
|
17
|
|
|
|
|
|
|
# # |
|
18
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, # |
|
19
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of # |
|
20
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
|
21
|
|
|
|
|
|
|
# GNU General Public License for more details. # |
|
22
|
|
|
|
|
|
|
# # |
|
23
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License # |
|
24
|
|
|
|
|
|
|
# along with this program; if not, write to the Free Software # |
|
25
|
|
|
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, # |
|
26
|
|
|
|
|
|
|
# MA 02111-1307 USA # |
|
27
|
|
|
|
|
|
|
# # |
|
28
|
|
|
|
|
|
|
############################################################################# |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# |
|
31
|
|
|
|
|
|
|
# ABOUT THIS MODULE |
|
32
|
|
|
|
|
|
|
# |
|
33
|
|
|
|
|
|
|
# This WWW-SMS module provides an interface to the Omnitel SMS gateway |
|
34
|
|
|
|
|
|
|
# available over at http://www.omnitel.it, all is done in two steps: |
|
35
|
|
|
|
|
|
|
# |
|
36
|
|
|
|
|
|
|
# STEP 1 Authenticate and login. |
|
37
|
|
|
|
|
|
|
# STEP 2 Send the SMS message. |
|
38
|
|
|
|
|
|
|
# |
|
39
|
|
|
|
|
|
|
# Here is a list af all the Italian operators supported by this gateway: |
|
40
|
|
|
|
|
|
|
# |
|
41
|
|
|
|
|
|
|
# OMNITEL |
|
42
|
|
|
|
|
|
|
# 340, 347, 348, 349 |
|
43
|
|
|
|
|
|
|
# |
|
44
|
|
|
|
|
|
|
# The maximal length of each message is 1200 chars, this is quite cool. |
|
45
|
|
|
|
|
|
|
# |
|
46
|
|
|
|
|
|
|
# Note that $debug=1 will print out all the HTML source code of the portal |
|
47
|
|
|
|
|
|
|
# the best thing you can do is to redirect the debugging output to a file. |
|
48
|
|
|
|
|
|
|
# |
|
49
|
|
|
|
|
|
|
# Doc note: The Perl LWP (libwww-perl) documentation is avaiable in your |
|
50
|
|
|
|
|
|
|
# local perldoc repository, see: % perldoc lwpcook it's always usefull. |
|
51
|
|
|
|
|
|
|
# |
|
52
|
|
|
|
|
|
|
# This packages was written by: Ivo Mario |
|
53
|
|
|
|
|
|
|
# and was last modified: $Date: 2003/03/21 00:10:44 $ |
|
54
|
|
|
|
|
|
|
# |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# |
|
58
|
|
|
|
|
|
|
# LIBS AND CONFIGS |
|
59
|
|
|
|
|
|
|
# |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
package WWW::SMS::Omnitel; |
|
62
|
1
|
|
|
1
|
|
613
|
use Telephone::Number; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
236
|
|
|
63
|
|
|
|
|
|
|
require Exporter; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$VERSION = '1.00'; |
|
66
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
67
|
|
|
|
|
|
|
@EXPORT = qw(); |
|
68
|
|
|
|
|
|
|
@EXPORT_OK = qw(@PREFIXES _send MAXLENGTH); |
|
69
|
|
|
|
|
|
|
@PREFIXES = (Telephone::Number->new('39', [ |
|
70
|
|
|
|
|
|
|
qw(340 347 348 349) |
|
71
|
|
|
|
|
|
|
], undef) |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# |
|
76
|
|
|
|
|
|
|
# SUBROUTINES |
|
77
|
|
|
|
|
|
|
# |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# |
|
80
|
|
|
|
|
|
|
# Message max length defintion. |
|
81
|
|
|
|
|
|
|
# |
|
82
|
|
|
|
|
|
|
sub MAXLENGTH () {1200} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# |
|
85
|
|
|
|
|
|
|
# Error handling functions. |
|
86
|
|
|
|
|
|
|
# |
|
87
|
|
|
|
|
|
|
sub hnd_error { |
|
88
|
0
|
|
|
0
|
0
|
|
$_ = shift; |
|
89
|
0
|
|
|
|
|
|
$WWW::SMS::Error = "Failed at step $_ of module Omnitel.pm\n"; |
|
90
|
0
|
|
|
|
|
|
return 0; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# |
|
94
|
|
|
|
|
|
|
# Operations to send the SMS message. |
|
95
|
|
|
|
|
|
|
# |
|
96
|
|
|
|
|
|
|
sub _send { |
|
97
|
|
|
|
|
|
|
|
|
98
|
1
|
|
|
1
|
|
3047
|
use HTTP::Request::Common qw(GET POST); # the base LWP stuff |
|
|
1
|
|
|
|
|
58533
|
|
|
|
1
|
|
|
|
|
103
|
|
|
99
|
1
|
|
|
1
|
|
2185
|
use LWP::UserAgent; # the LWP user agent |
|
|
1
|
|
|
|
|
60135
|
|
|
|
1
|
|
|
|
|
37
|
|
|
100
|
1
|
|
|
1
|
|
950
|
use HTTP::Cookies; # cookie support in LWP |
|
|
1
|
|
|
|
|
7644
|
|
|
|
1
|
|
|
|
|
363
|
|
|
101
|
0
|
|
|
0
|
|
|
my $self = shift; # shift the self array |
|
102
|
0
|
|
|
|
|
|
my $debug = 0; # debug option |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# cut message if it's too long |
|
105
|
0
|
0
|
|
|
|
|
if (length($self->{smstext})>MAXLENGTH) { |
|
106
|
0
|
|
|
|
|
|
$self->{smstext} = substr($self->{smstext}, 0, MAXLENGTH - 1); |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; # create user agent object |
|
110
|
0
|
|
|
|
|
|
$ua->agent('Mozilla/5.0'); # user agent properties |
|
111
|
0
|
0
|
|
|
|
|
$ua->proxy('http', $self->{proxy}) if ($self->{proxy}); # proxy settings if available |
|
112
|
0
|
|
|
|
|
|
$ua->cookie_jar(HTTP::Cookies->new( # user agent cookie settings |
|
113
|
|
|
|
|
|
|
file => $self->{cookie_jar}, # saves to lwpcookies.txt |
|
114
|
|
|
|
|
|
|
autosave => 1 # save automaticly |
|
115
|
|
|
|
|
|
|
) |
|
116
|
|
|
|
|
|
|
); |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# |
|
119
|
|
|
|
|
|
|
# STEP 1 |
|
120
|
|
|
|
|
|
|
# |
|
121
|
|
|
|
|
|
|
# Let's authenticate and login, cookies are optional, sessions are serverside. |
|
122
|
|
|
|
|
|
|
# |
|
123
|
0
|
|
|
|
|
|
my $step = 1; |
|
124
|
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
$req = POST 'http://www.areaprivati.190.it/_mem_bin/verifpwd.asp', |
|
126
|
|
|
|
|
|
|
[ |
|
127
|
|
|
|
|
|
|
ApriPopUp => '0', |
|
128
|
|
|
|
|
|
|
username => $self->{username}, |
|
129
|
|
|
|
|
|
|
password => $self->{passwd}, |
|
130
|
|
|
|
|
|
|
URL => '', |
|
131
|
|
|
|
|
|
|
HomePage => 'NO', |
|
132
|
|
|
|
|
|
|
'19A' => 'YES' |
|
133
|
|
|
|
|
|
|
]; |
|
134
|
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
$file = $ua->request($req)->as_string; |
|
136
|
|
|
|
|
|
|
|
|
137
|
0
|
0
|
|
|
|
|
if ($debug) { |
|
138
|
0
|
|
|
|
|
|
print "\n\n#####################\n"; |
|
139
|
0
|
|
|
|
|
|
print "# DEBUG FOR STEP: $step #\n"; |
|
140
|
0
|
|
|
|
|
|
print "#####################\n\n"; |
|
141
|
0
|
|
|
|
|
|
print $file; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
0
|
0
|
|
|
|
|
return &hnd_error($debug ? "$step ($file)" : $step) |
|
|
|
0
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
unless $file =~ /exch.vodafoneomnitel.it/; |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# |
|
148
|
|
|
|
|
|
|
# STEP 2 |
|
149
|
|
|
|
|
|
|
# |
|
150
|
|
|
|
|
|
|
# Now let's send the SMS message, folks. Here wo go, woheeeee! |
|
151
|
|
|
|
|
|
|
# |
|
152
|
0
|
|
|
|
|
|
$step++; |
|
153
|
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
$req = POST 'http://freesms.190.it/190personal/sms_hp_send.asp', |
|
155
|
|
|
|
|
|
|
[ |
|
156
|
|
|
|
|
|
|
num => $self->{prefix} . $self->{telnum}, |
|
157
|
|
|
|
|
|
|
msg => $self->{smstext}, |
|
158
|
|
|
|
|
|
|
Prov => 1 |
|
159
|
|
|
|
|
|
|
]; |
|
160
|
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
$file = $ua->simple_request($req)->as_string; |
|
162
|
|
|
|
|
|
|
|
|
163
|
0
|
0
|
|
|
|
|
if ($debug) { |
|
164
|
0
|
|
|
|
|
|
print "\n\n#####################\n"; |
|
165
|
0
|
|
|
|
|
|
print "# DEBUG FOR STEP: $step #\n"; |
|
166
|
0
|
|
|
|
|
|
print "#####################\n\n"; |
|
167
|
0
|
|
|
|
|
|
print $file; |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
0
|
0
|
|
|
|
|
return &hnd_error($debug ? "$step ($file)" : $step) |
|
|
|
0
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
unless $file =~ /SMS_HP_SendOk.asp\?nsms=/; |
|
172
|
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
1; |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
1; |