home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 February / chip-cd_2000_02.zip / 02 / software / shareware / watznew / hotmail.lib < prev    next >
Text File  |  1999-10-01  |  2KB  |  62 lines

  1. # -----------------------------------------------------------
  2. # HOTMAIL ROUTINES LIBRARY by A.I.Studio / Igor Afanasyev
  3. # -----------------------------------------------------------
  4.  
  5. require 'http.lib'; # WatzNew http routines library
  6.  
  7. # -----------------------------------------------------------
  8. sub CheckHotmailAccount {
  9. # -----------------------------------------------------------
  10.   ($Login,$Password) = @_;
  11.  
  12.   $c = &HttpGet('www.hotmail.com',80,'/',always);
  13.  
  14.   die "ERR: No redirection location provided" if ($c ne 302);
  15.  
  16.   # ok, redirecting to some internal hotmail url
  17.   ($HttpHeader =~ m/Location:[ ]*(.*?)\n/gi) && ($Location = $1); # we extract document location here
  18.   die "ERR: Can't find the address to redirect\n" if ($Location eq '');
  19.  
  20.   $Location =~ s/\/login/\/start/;
  21.   $ru = $Location;
  22.   $Location =~ s/\/start/\/dologin/;
  23.  
  24.   $c = &HttpPost(&SplitUrl($Location),"login=$Login&passwd=$Password&sec=no&curmbox=ACTIVE&js=no&_lang=&beta=$ru&ishotmail=1\n");
  25.  
  26.   while (($c == 301) || ($c == 302) || ($c == 303)) {
  27.     # ok, we logged in, redirecting to our page
  28.     ($HttpHeader =~ m/Location:[ ]*(.*?)\n/gi) && ($Location = $1); # we extract document location here
  29.     die "ERR: Can't find the address to redirect\n" if ($Location eq '');
  30.     $c = &HttpGet(&SplitUrl($Location));
  31.   }
  32.   
  33.   # no redirection information
  34.   print "INF: Loading complete\n";
  35.  
  36.   if ($HttpBody =~ m/we cannot.*?process your request/si) {
  37.     ($HttpBody =~ m/reason:.*?<b>(.*?)<\/b>/si) && ($Reason = $1);
  38.     die "ERR: Can't process request. Reason: $Reason\n";
  39.   }
  40.  
  41.   # getting first parameter ('X messages, Y new')
  42.   ($HttpBody =~ m/<!-- FILE: title.asp-->.*?<font size="2">(.*?) /si);
  43.   my $Amount = $1;
  44.   $Amount =~ s/[\n ]$//g;
  45.  
  46.   print "MSG: $Amount\n";
  47.  
  48.   my $MsgText = '';
  49.   my $count = 0;
  50.   # collecting new message 'from' and 'subject' fields and appending them to $MsgText
  51.   while ($HttpBody =~ m/alt="New".*?<td>.*?<td>.*?<a.*?>(.*?)<\/a>.*?<td>.*?<td> (.*?) /sgi) {
  52.     $MsgText .= "<LI>$2 <I>(from $1)</I>";
  53.     $count++;
  54.     print "INF: Retrieving message [$count]\n";
  55.   }
  56.  
  57.   print "MSG: $MsgText\n";
  58. } # end of sub
  59.  
  60. # -----------------------------------------------------------
  61.  
  62. 1; # return true