-# patch for http://kiwi.ms.mff.cuni.cz/%7Etom/programming/src/sendsms.tar.gz/sendsms.pl
-my $agent=LWP::UserAgent->new();
-$agent->agent("LaceMail $VERSION; contact=$SMScontact; ");
-my($request1,$response1); # for &send_cz_eurotel
-my($name,$value,$type,$disabled,$q2);
-
-# &send_cz_eurotel returns: error
-# BEGIN http://kiwi.ms.mff.cuni.cz/%7Etom/programming/src/sendsms.tar.gz/sendsms.pl
-sub parse_inputs
-{
- my ($resp) = @_;
- my @inputs;
- my $ct;
- my @c;
- $ct=$resp->content();
-
- @c=split '>', $ct;
- grep {
- if (/(<input|<select|<textarea)([^<>]*)(>|$)/i) {
- my $txt=$2, $name="", $value="", $type="x", $disabled=0;
- my $ipoc;
- if ($txt =~ /type="([^"]*)"/i) { $type=$1; }
- elsif ($txt =~ /type=([^" ]*)[ >]/i) { $type=$1; }
- if ($txt =~ /name="([^"]*)"/i) { $name=$1; }
- elsif ($txt =~ /name=([^" ]*)[ >]/i) { $name=$1; }
- if ($txt =~ /value="([^"]*)"/i) { $value=$1; }
- elsif ($txt =~ /value=([^" ]*)[ >]/i) { $value=$1; }
- if ($txt =~ /disabled/i) { $disabled=1; }
- if ($name ne "" && $type ne "" && $type ne "button" && ! $disabled)
- {
- $ipoc=$#inputs;
- $inputs[$ipoc+1][0]=$name;
- $inputs[$ipoc+1][1]=$value;
- }
- }
- 0; } @c;
- return @inputs;
-}
-
-sub make_query
-{
- my (@inputs) = @_;
-
- my $i;
- my $query = "";
-
- for ($i=0; $i<=$#inputs; $i++)
- {
- my($q1, $q2);
- if ($i>0) { $query="$query&"; }
- $q1=uri_escape($inputs[$i][0]);
- $q2=uri_escape($inputs[$i][1]);
- $query="$query$q1=$q2";
- }
-
- #change @ and space back
- $query=~ s/%20/+/g;
- $query=~ s/%40/@/g;
- return $query;
-}
-
-sub send_cz_eurotel
-{
- my ($id,$text,$mail,$directd) = @_;
- my $src_url = "http://www2.eurotel.cz/sms/index.html";
- my @inputs;
- my $query = "";
- my $cookie = HTTP::Cookies->new;
- my $pref;
-
- #check if correct number
- if (substr($id,0,5)!="00420") { return -1; }
- $pref=substr($id,5,3);
- if (!($pref eq "601" || $pref eq "602" || $pref eq "606" || $pref eq "607" || ($pref ge "720" && $pref le "729"))) { return -1; }
-
- #get form page, extract cookies
- $request1=new HTTP::Request('GET', "$src_url?n_pagestyle=new");
- $response1=$agent->request($request1);
- if ($response1->code != 200) { return -3; }
- $cookie->extract_cookies($response1);
-
- #parse the form
- @inputs=parse_inputs($response1);
-
- #fill the form
- $inputs[2][1]=substr($id,5,3);
- $inputs[3][1]=substr($id,8,6);
- $inputs[4][1]=$mail;
-
- #direct display
- $inputs[6][1]="sms";
- $inputs[6][1]="show" if ($directd>0);
-
- $inputs[7][1]=$text;
-
-# for ($i=0; $i<=$#inputs; $i++) { print "[$i] $inputs[$i][0] $inputs[$i][1]\n"; }
-
- #make query
- $query=make_query(@inputs);
-
- #POST the form
- my $header = new HTTP::Headers(
- 'Content-Length' => length($query),
- 'Content-Type' => 'application/x-www-form-urlencoded',
- 'Accept' => '*/*',
- 'Referer' => $src_url
- );
- my $request2 = new HTTP::Request('POST',$src_url, $header, $query);
- $cookie->add_cookie_header($request2);
- my $response2 = $agent->request($request2);
-
- if ($response2->code != 200) { return -3; }
-
- #check for success
- if ($response2->content() !~ /byla.*odesl.*na na SMS centrum/)
- {
- return -2;
- }
- return 0;
-}
-# END http://kiwi.ms.mff.cuni.cz/%7Etom/programming/src/sendsms.tar.gz/sendsms.pl
-