| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | #Copyright (c) 2001 Giulio Motta. All rights reserved. | 
| 2 |  |  |  |  |  |  | #http://www-sms.sourceforge.net/ | 
| 3 |  |  |  |  |  |  | #This program is free software; you can redistribute it and/or | 
| 4 |  |  |  |  |  |  | #modify it under the same terms as Perl itself. | 
| 5 |  |  |  |  |  |  | # | 
| 6 |  |  |  |  |  |  | # web2sms.loop.de does only send to german Viag Interkom users, but that is all I need. | 
| 7 |  |  |  |  |  |  | # Note that $debug=1 will stress the step parameter of hnd_error a lot. | 
| 8 |  |  |  |  |  |  | # Thu Jun 27 20:12:01 CEST 2002, Juergen Weigert, jw@netvision.de | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | package WWW::SMS::LoopDE; | 
| 11 | 1 |  |  | 1 |  | 623 | use Telephone::Number; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 176 |  | 
| 12 |  |  |  |  |  |  | require Exporter; | 
| 13 |  |  |  |  |  |  | @ISA = qw(Exporter); | 
| 14 |  |  |  |  |  |  | @EXPORT = qw(); | 
| 15 |  |  |  |  |  |  | @EXPORT_OK = qw(@PREFIXES _send MAXLENGTH); | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | @PREFIXES = (Telephone::Number->new('49', [ qw(179 176) ], undef)); | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | $VERSION = '1.00'; | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | sub MAXLENGTH () {120} # maximum message length | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | sub hnd_error { | 
| 24 | 0 |  |  | 0 | 0 |  | $_ = shift; | 
| 25 | 0 |  |  |  |  |  | $WWW::SMS::Error = "Failed at step $_ of module LoopDE.pm"; | 
| 26 | 0 |  |  |  |  |  | return 0; | 
| 27 |  |  |  |  |  |  | } | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | sub _send { | 
| 30 | 0 |  |  | 0 |  |  | my $self = shift; | 
| 31 |  |  |  |  |  |  |  | 
| 32 | 1 |  |  | 1 |  | 6 | use HTTP::Request::Common qw(GET POST); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 64 |  | 
| 33 | 1 |  |  | 1 |  | 6 | use HTTP::Cookies; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 25 |  | 
| 34 | 1 |  |  | 1 |  | 5 | use LWP::UserAgent; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 512 |  | 
| 35 |  |  |  |  |  |  |  | 
| 36 | 0 |  |  |  |  |  | my $debug = 0; | 
| 37 |  |  |  |  |  |  |  | 
| 38 | 0 | 0 |  |  |  |  | $self->{smstext} = substr($self->{smstext}, 0, MAXLENGTH - 1) if (length($self->{smstext})>MAXLENGTH); | 
| 39 |  |  |  |  |  |  |  | 
| 40 | 0 |  |  |  |  |  | my $ua = LWP::UserAgent->new; | 
| 41 | 0 |  |  |  |  |  | $ua->agent('Mozilla/5.0'); | 
| 42 | 0 | 0 |  |  |  |  | $ua->proxy('http', $self->{proxy}) if ($self->{proxy}); | 
| 43 | 0 |  |  |  |  |  | $ua->cookie_jar(HTTP::Cookies->new( | 
| 44 |  |  |  |  |  |  | file => $self->{cookie_jar}, | 
| 45 |  |  |  |  |  |  | autosave => 1 | 
| 46 |  |  |  |  |  |  | ) | 
| 47 |  |  |  |  |  |  | ); | 
| 48 |  |  |  |  |  |  |  | 
| 49 | 0 |  |  |  |  |  | my $step = 1; | 
| 50 |  |  |  |  |  |  | #STEP 1		----------- give me your cookie! | 
| 51 | 0 |  |  |  |  |  | my $req = GET 'http://web2sms.loop.de/sms_eingabe.asp'; | 
| 52 | 0 |  |  |  |  |  | my $file = $ua->request($req)->as_string; | 
| 53 | 0 | 0 |  |  |  |  | return &hnd_error($debug ? "$step ($file)" : $step) unless $file =~ m{sms_agbs.asp}i; | 
|  |  | 0 |  |  |  |  |  | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | #STEP 2		----------- give me another cookie | 
| 56 | 0 |  |  |  |  |  | $step++; | 
| 57 | 0 |  |  |  |  |  | $req = POST 'http://web2sms.loop.de/sms_agbs.asp', | 
| 58 |  |  |  |  |  |  | [ | 
| 59 |  |  |  |  |  |  | MessageText => $self->{smstext}, | 
| 60 |  |  |  |  |  |  | prefix => $self->{intpref} . $self->{prefix}, | 
| 61 |  |  |  |  |  |  | MSISDN => $self->{telnum}, | 
| 62 |  |  |  |  |  |  | num => (MAXLENGTH - length($self->{smstext})) , | 
| 63 |  |  |  |  |  |  | gen_b_senden.x => int(rand(80)), | 
| 64 |  |  |  |  |  |  | gen_b_senden.y => int(rand(14)), | 
| 65 |  |  |  |  |  |  | SUBMIT => 'Absenden' | 
| 66 |  |  |  |  |  |  | ]; | 
| 67 |  |  |  |  |  |  |  | 
| 68 | 0 |  |  |  |  |  | $file = $ua->request($req)->as_string; | 
| 69 | 0 | 0 |  |  |  |  | return &hnd_error($debug ? "$step ($self->{prefix}, ($file)" : $step) | 
|  |  | 0 |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | unless $file =~ m{b_akzeptieren.gif"\s.*alt="akzeptieren"\s}; | 
| 71 |  |  |  |  |  |  | #STEP 2 | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | #STEP 3		----------- now we fire and forget | 
| 74 | 0 |  |  |  |  |  | $step++; | 
| 75 | 0 |  |  |  |  |  | $req = POST 'http://web2sms.loop.de/sms_process.asp', | 
| 76 |  |  |  |  |  |  | [ | 
| 77 |  |  |  |  |  |  | MessageText => $self->{smstext}, | 
| 78 |  |  |  |  |  |  | MSISDN => $self->{intpref} . $self->{prefix} . $self->{telnum}, | 
| 79 |  |  |  |  |  |  | gen_b_akzeptieren.'.x' => int(rand(80)), | 
| 80 |  |  |  |  |  |  | gen_b_akzeptieren.'.y' => int(rand(14)), | 
| 81 |  |  |  |  |  |  | ]; | 
| 82 |  |  |  |  |  |  |  | 
| 83 | 0 |  |  |  |  |  | $file = $ua->simple_request($req)->as_string; | 
| 84 | 0 | 0 |  |  |  |  | return &hnd_error($debug ? "$step ($file)" : $step) unless $file =~ m{sms_result.asp}i; | 
|  |  | 0 |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | #STEP 3 | 
| 86 |  |  |  |  |  |  |  | 
| 87 | 0 |  |  |  |  |  | 1; | 
| 88 |  |  |  |  |  |  | } | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | 1; |