Kod: Zaznacz cały
#!/usr/bin/perl
###########################################################################
# Copyright (C) 2008 by Bender88 #
# [email] #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the #
# Free Software Foundation, Inc., #
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
###########################################################################
#Ustaw login i hasło !!
$login = '*******';
$pass = '*******';
#Początek skryptu
#use warnings;
use HTTP::Request::Common;
use HTTP::Cookies;
use LWP::UserAgent;
use Crypt::SSLeay;
use File::Basename;
# Funkcja do debugowania, wyjście z programu z logowaniem do pliku
# param: komunikat_wyjscia, zapisz_do_loga
sub smf_is_wrong{
open(LOG, '>'.dirname($0).'/lastlog.txt');
if( exists($_[1]) ){
print LOG 'Error:'.$_[0]."\n".$_[1];
}
else{
print LOG $_[0];
}
close(LOG);
print $_[0];
exit;
}
$cookie = HTTP::Cookies->new(
file => 'cookie.txt',
autosave => 1,
);
$ua = LWP::UserAgent->new();
$ua->agent('Mozilla/5.0');
$ua->cookie_jar($cookie);
#logowanie
$loginUrl = 'https://www.orange.pl/portal/map/map/signin?_DARGS=/gear/static/home/login.jsp.loginFormId';
$req = POST $loginUrl, [
'_dyncharset'=>'UTF-8',
'/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL'=>'http://www.orange.pl/portal/map/map/signin',
'_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL'=>' ',
'/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL'=>'http://www.orange.pl/portal/map/map/pim',
'_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL'=>' ',
'/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login'=>$login,
'_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login'=>' ',
'/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password'=>$pass,
'_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password'=>' ',
'/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.x'=>0,
'/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.y'=>0,
'/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login'=>' ',
'_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login'=>' ',
'_DARGS' => '/gear/static/signIn.jsp',
];
push @{ $ua->requests_redirectable }, 'POST';
$req->referer ('http://www.orange.pl/portal/map/map/signin');
$res = $ua->request($req);
if ( !($res->is_success) ){
smf_is_wrong( 'Problem z połączeniem do strony logowania' );
}
if ( $res->content !~ /witaj/ ){
smf_is_wrong( 'Problem z logowaniem', $res->content );
}
#pobieranie strony ze stanem pakietów
$req = GET 'https://www.orange.pl/portal/ecare/packages';
$wait = 0; #czy czekać
$try = 0; #bywają problemy, więc 3 próby
do{
if( $wait ){ sleep 5; }
$res = $ua->request($req);
if( !$res->is_success ){
smf_is_wrong( 'Problem z połączeniem do strony ze stanem pakietów' );
}
if( $res->content !~ m/podstawowe/ && ($try++ > 3) ){
smf_is_wrong( 'Brak informacji o pakietach', $res->content );
}
}while( $wait = ($res->content =~ 'Twoje dane dane są właśnie wczytywane') );
#pobieranie daty ( troche to porypane w perlu :/ )
($sec,$min,$hour,$day,$month,$year) = (localtime(time))[0,1,2,3,4,5];
if( length(++$month) == 1 ){
$month = '0'.$month;
}
if( length($day) == 1 ){
$day = '0'.$day;
}
if( length($min) == 1 ){
$min = '0'.$min;
}
if( length($sec) == 1 ){
$sec = '0'.$sec;
}
$date = $day.'-'.$month.'-'.($year+1900).' '.$hour.':'.$min.':'.$sec;
#składanie treści z dostępnych danych
print 'Dostępne środki Orange ('.$date.")\n";
$inside = '</div>\s<div\ class="cell2">\s</div>\s<div\ class="cell3">\s(\d{1,2}\.\d{1,2}\.\d{4}\ \(\d{1,2}\ dni\)\ )?</div>\s<div\ class="cell4">\s';
$RegStanKonta = 'stan\ konta'.$inside.'(\d{1,4},\d{2}\ zł)';
if( $res->content =~ m/$RegStanKonta/ && ($2 !~ '0,00') ){
print 'Stan Konta: '.$2."\n";
}
$RegMaszGadane = 'Pakiet\ minut\ z\ POPGadane'.$inside.'(\d{1,4},\d{2})\szł';
if( $res->content =~ m/$RegMaszGadane/ && ($2 !~ '0,00') ){
print 'Pakiet minut z POPGadane: '.$2."\n";
}
$RegGroszSms = 'Grosz za SMS'.$inside.'(\d{1,4}) SMS';
if( $res->content =~ m/$RegGroszSms/ && ( $2 != 0 ) ){
print 'Smsy po groszu: '.$2.'. Ważne do: '.$1."\n";
}
$RegPromocyjne = 'środki\ promocyjne'.$inside.'(\d{1,4},\d{2}\ zł)';
if( $res->content =~ m/$RegPromocyjne/ && ($2 !~ '0,00') ){
print 'Środki promocyjne: '.$2."\n";
}
Kod: Zaznacz cały
${execi 3600 ~/.conky/orange.pl}
Kod: Zaznacz cały
Dostępne środki Orange (26-11-2008 23:23:16)
Kod: Zaznacz cały
alucard@alucard-desktop:~/.conky$ ./orange.pl
Day too big - 30949 > 24855
Sec too small - 30949 < 74752
Sec too big - 30949 > 11647
Dostępne środki Orange (26-11-2008 23:25:06)
Czy zna ktoś z was sposób na obejście tego buga?
Jeśli to cos pomoże, moje Ubu to 8.04.