2 #Kyberia client... (Harvie 2oo9)
15 sub new
{ #constructor
16 my ($self, $kurl) = @_;
18 $browser = LWP
::UserAgent
->new( );
19 $browser->cookie_jar( {} );
20 $browser->timeout(15);
25 my ($self, $user, $pass) = @_;
26 my $response = $browser->post( $url,
30 'login_type' => 'name',
33 return $response->is_success;
37 my $response = $browser->post( $url,
41 return $response->is_success;
45 my ($self, $user, $message) = @_;
46 my $response = $browser->post( $url,
49 'mail_to_type' => 'name',
50 'mail_text' => $message,
53 return $response->is_success;
58 my $response = $browser->get("$url/id/$id/");
59 return $response->content;
63 my $response = $browser->get("$url/id/2176597/");
64 my @mails = split(/\n/, $response->content); $response = '';
65 shift(@mails); #remove CSV header
67 my ($MSG_ID, $FROM, $FROM_ID, $TO, $TO_ID, $TIME, $NEW, $TEXT) = split(/;/, $_, 8); #parse CSV
68 $TEXT =~ s/\\n/\n/g; decode_entities
($TEXT); #unescape message
69 print("#$MSG_ID $FROM --> $TO ($TIME)\n\n$TEXT\n---------------------------------\n");
71 return $response->is_success;
75 my $response = $browser->get("$url/ajax/check_new_mail.php");
76 my @mails = split(/;/, $response->content);
77 if($response->is_success) {
78 my $text = "You have $mails[0] unread mails, last from $mails[1].";
79 if($mails[0] < 1) { $text = "No unread mail, last mail from $mails[1]." }
80 return ($mails[0], $mails[1], $text);
This page took 1.274391 seconds and 4 git commands to generate.