line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
|
|
|
|
|
|
# option -w == warnings ON |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# CVS related code |
5
|
|
|
|
|
|
|
# $Id: Everyday.pm,v 1.8 2003/03/20 00:10:24 eim Exp $ |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
############################################################################# |
8
|
|
|
|
|
|
|
# # |
9
|
|
|
|
|
|
|
# IMPORTANT NOTE # |
10
|
|
|
|
|
|
|
# # |
11
|
|
|
|
|
|
|
# !!! THE AUTHOR IS ==NOT== RESPONSIBLE FOR ANY USE OF THIS PROGRAM !!! # |
12
|
|
|
|
|
|
|
# # |
13
|
|
|
|
|
|
|
# GPL LICENSE # |
14
|
|
|
|
|
|
|
# # |
15
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify # |
16
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by # |
17
|
|
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or # |
18
|
|
|
|
|
|
|
# (at your option) any later version. # |
19
|
|
|
|
|
|
|
# # |
20
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, # |
21
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of # |
22
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
23
|
|
|
|
|
|
|
# GNU General Public License for more details. # |
24
|
|
|
|
|
|
|
# # |
25
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License # |
26
|
|
|
|
|
|
|
# along with this program; if not, write to the Free Software # |
27
|
|
|
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, # |
28
|
|
|
|
|
|
|
# MA 02111-1307 USA # |
29
|
|
|
|
|
|
|
# # |
30
|
|
|
|
|
|
|
############################################################################# |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#////////////////////////////////////////# |
34
|
|
|
|
|
|
|
# A B O U T T H I S P A C K A G E # |
35
|
|
|
|
|
|
|
#////////////////////////////////////////# |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# This is a module for www.everyday.com you must have a valid user account |
38
|
|
|
|
|
|
|
# at www.everyday.com which will provide you with login and password. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Furthermore www.everyday.com allows you to send 10 SMS messages per day, |
41
|
|
|
|
|
|
|
# and to stress much more his users there are so called "pepites" which you |
42
|
|
|
|
|
|
|
# need to send SMS message, no idea how to get them, read on their site. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# I've done some test and it seems that www.everyday.com doesn't |
45
|
|
|
|
|
|
|
# support proxies so don't use a proxy here, SMS delivering will fail. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Note that $debug=1 will print out all the HTML source code of the portal |
48
|
|
|
|
|
|
|
# the best thing you can do is to redirect the debugging output to a file. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Doc note: The Perl LWP (libwww-perl) documentation is avaiable in your |
51
|
|
|
|
|
|
|
# local perldoc repository, see: % perldoc lwpcook it's always usefull. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# This packages was written by: Ivo Mario |
54
|
|
|
|
|
|
|
# and was last modified: $Date: 2003/03/20 00:10:24 $ |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#////////////////////////////////////////# |
58
|
|
|
|
|
|
|
# L I B S A N D C O N F I G S # |
59
|
|
|
|
|
|
|
#////////////////////////////////////////# |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# name of this package |
62
|
|
|
|
|
|
|
package WWW::SMS::Everyday; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# other modules we need |
65
|
1
|
|
|
1
|
|
740
|
use Telephone::Number; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
202
|
|
66
|
|
|
|
|
|
|
require Exporter; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# definitions |
69
|
|
|
|
|
|
|
$VERSION = '1.00'; |
70
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
71
|
|
|
|
|
|
|
@EXPORT = qw(); |
72
|
|
|
|
|
|
|
@EXPORT_OK = qw(@PREFIXES _send MAXLENGTH); |
73
|
|
|
|
|
|
|
@PREFIXES = (Telephone::Number->new('39', [ |
74
|
|
|
|
|
|
|
qw(320 328 329 330 333 334 335 336 337 338 339 360 368 340 347 348 349 380 388 389) |
75
|
|
|
|
|
|
|
], undef) |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#////////////////////////////////////////# |
80
|
|
|
|
|
|
|
# S U B R O U T I N E S # |
81
|
|
|
|
|
|
|
#////////////////////////////////////////# |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# subroutine to define max message length |
84
|
|
|
|
|
|
|
sub MAXLENGTH () {127} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# subroutine to handle errors |
88
|
|
|
|
|
|
|
sub hnd_error { |
89
|
0
|
|
|
0
|
0
|
|
$_ = shift; |
90
|
0
|
|
|
|
|
|
$WWW::SMS::Error = "Failed at step $_ of module Everyday.pm\n"; |
91
|
0
|
|
|
|
|
|
return 0; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# subroutine to send SMS |
96
|
|
|
|
|
|
|
sub _send { |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# external libraries |
99
|
1
|
|
|
1
|
|
6
|
use HTTP::Request::Common qw(GET POST); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
100
|
1
|
|
|
1
|
|
5
|
use LWP::UserAgent; # the LWP user agent |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
101
|
1
|
|
|
1
|
|
4
|
use HTTP::Cookies; # cookie support in LWP |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
504
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# private vars |
104
|
0
|
|
|
0
|
|
|
my $self = shift; # no idea actually |
105
|
0
|
|
|
|
|
|
my $debug = 0; # enable debug |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# check if message is too long |
108
|
0
|
0
|
|
|
|
|
if (length($self->{smstext})>MAXLENGTH) { |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# cut the message |
111
|
0
|
|
|
|
|
|
$self->{smstext} = substr($self->{smstext}, 0, MAXLENGTH - 1); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# create user agent object |
115
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# user agent properties |
118
|
0
|
|
|
|
|
|
$ua->agent('Mozilla/5.0'); |
119
|
0
|
0
|
|
|
|
|
$ua->proxy('http', $self->{proxy}) if ($self->{proxy}); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# user agent cookie settings |
122
|
0
|
|
|
|
|
|
$ua->cookie_jar(HTTP::Cookies->new( |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
file => $self->{cookie_jar}, # saves to lwpcookies.txt |
125
|
|
|
|
|
|
|
autosave => 1 # save automaticly |
126
|
|
|
|
|
|
|
) |
127
|
|
|
|
|
|
|
); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# ============================================================ |
131
|
|
|
|
|
|
|
# STEP 1 |
132
|
|
|
|
|
|
|
# We just connect to bypass the browser check and get a cookie |
133
|
|
|
|
|
|
|
# ============================================================ |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
my $step = 1; # define the step |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# First of all we need to set this cookie in order |
138
|
|
|
|
|
|
|
# to pass everday's javascript browser detection, it does his job. |
139
|
0
|
|
|
|
|
|
$ua->cookie_jar->set_cookie('0', 'BrowserDetect', 'passed', "/", ".everyday.com"); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# define the LWP request |
142
|
0
|
|
|
|
|
|
my $req = GET 'http://www.everyday.com/login.phtml'; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# execute the LWP request |
145
|
0
|
|
|
|
|
|
my $file = $ua->request($req)->as_string; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# if we are in debugging mode |
148
|
0
|
0
|
|
|
|
|
if ($debug) { |
149
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
print "\n\n#####################\n"; # print debug title |
151
|
0
|
|
|
|
|
|
print "# DEBUG FOR STEP: $step #\n"; # print debug title |
152
|
0
|
|
|
|
|
|
print "#####################\n\n"; # print debug title |
153
|
0
|
|
|
|
|
|
print $file; # print debug infos |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# check if we arrived on the everyday startpage |
157
|
|
|
|
|
|
|
# if not so, well... report an error and exit ! |
158
|
0
|
0
|
|
|
|
|
return &hnd_error($debug ? "$step ($file)" : $step) |
|
|
0
|
|
|
|
|
|
159
|
|
|
|
|
|
|
unless $file =~ m{}i; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# ===================================================== |
163
|
|
|
|
|
|
|
# STEP 2 |
164
|
|
|
|
|
|
|
# Ok folks, once fetched the cookie it's time to log in |
165
|
|
|
|
|
|
|
# ===================================================== |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
$step++; # increment to next step |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
# define the LWP request |
170
|
0
|
|
|
|
|
|
$req = POST 'http://www.everyday.com/login.phtml', |
171
|
|
|
|
|
|
|
[ |
172
|
|
|
|
|
|
|
login_username => $self->{username}, |
173
|
|
|
|
|
|
|
login_password => $self->{passwd} |
174
|
|
|
|
|
|
|
]; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# execute the LWP request |
177
|
0
|
|
|
|
|
|
$file = $ua->request($req)->as_string; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# if we are in debugging mode |
180
|
0
|
0
|
|
|
|
|
if ($debug) { |
181
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
|
print "\n\n#####################\n"; # print debug title |
183
|
0
|
|
|
|
|
|
print "# DEBUG FOR STEP: $step #\n"; # print debug title |
184
|
0
|
|
|
|
|
|
print "#####################\n\n"; # print debug title |
185
|
0
|
|
|
|
|
|
print $file; # print debug infos |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
# check if we successfully logged in, |
189
|
|
|
|
|
|
|
# if not so, report an error and exiti ! |
190
|
0
|
0
|
|
|
|
|
return &hnd_error($debug ? "$step ($file)" : $step) |
|
|
0
|
|
|
|
|
|
191
|
|
|
|
|
|
|
unless $file =~ m{path=/; domain=.everyday.com}i; |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
# ============================================== |
195
|
|
|
|
|
|
|
# STEP 3 |
196
|
|
|
|
|
|
|
# Let's finaly send the SMS message, jope dooo ! |
197
|
|
|
|
|
|
|
# ============================================== |
198
|
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
|
$step++; # increment to next step |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
# define the LWP request |
202
|
0
|
|
|
|
|
|
$req = POST 'http://sms.everyday.com/index.phtml', |
203
|
|
|
|
|
|
|
[ |
204
|
|
|
|
|
|
|
gsmnumber => $self->{intpref} . $self->{prefix} . $self->{telnum}, |
205
|
|
|
|
|
|
|
message => $self->{smstext}, |
206
|
|
|
|
|
|
|
send_sms => 1, |
207
|
|
|
|
|
|
|
]; |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
# execute the LWP request |
210
|
0
|
|
|
|
|
|
$file = $ua->simple_request($req)->as_string; |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
# if we are in debugging mode |
213
|
0
|
0
|
|
|
|
|
if ($debug) { |
214
|
|
|
|
|
|
|
|
215
|
0
|
|
|
|
|
|
print "\n\n#####################\n"; # print debug title |
216
|
0
|
|
|
|
|
|
print "# DEBUG FOR STEP: $step #\n"; # print debug title |
217
|
0
|
|
|
|
|
|
print "#####################\n\n"; # print debug title |
218
|
0
|
|
|
|
|
|
print $file; # print debug infos |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
0
|
0
|
0
|
|
|
|
return &hnd_error($debug ? "$step ($file)" : $step) |
|
|
0
|
|
|
|
|
|
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
# This is not the best check we can do but |
224
|
|
|
|
|
|
|
# it should work for international everyday sites |
225
|
|
|
|
|
|
|
# unless $file =~ m{Everyday.com - SMS}i; |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
unless ( |
228
|
|
|
|
|
|
|
$file =~ /SMS inviato!/ |
229
|
|
|
|
|
|
|
|| $file =~ /a smistarlo/ |
230
|
|
|
|
|
|
|
); |
231
|
|
|
|
|
|
|
|
232
|
0
|
|
|
|
|
|
1; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
1; |