From b4463e760539a5c8ecb0b0661108c73a4b012eda Mon Sep 17 00:00:00 2001 From: "Difrex(Denis Zheleztsov)" Date: Tue, 17 Jun 2014 14:13:53 +0400 Subject: [PATCH] Fixes --- II/Enc.pm | 3 ++- II/Get.pm | 21 +++++++++++++-------- II/Send.pm | 15 +++++++++------ ii.sql | Bin 1793024 -> 1793024 bytes 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/II/Enc.pm b/II/Enc.pm index 6622713..5c0aed0 100644 --- a/II/Enc.pm +++ b/II/Enc.pm @@ -22,7 +22,8 @@ sub decrypt { my ( $self, $base64 ) = @_; # Decrypt message - my $dec = `echo "$base64" | base64 -d`; + my $dec = decode_base64($base64); + # my $dec = `echo "$base64" | base64 -d`; return $dec; } diff --git a/II/Get.pm b/II/Get.pm index 4a8bbc3..a2ffd96 100644 --- a/II/Get.pm +++ b/II/Get.pm @@ -36,6 +36,7 @@ sub get_echo { my $msgs; my $base64; + my @messages_hash; foreach my $echo (@$echoareas) { # Get echo message hashes @@ -60,7 +61,7 @@ sub get_echo { # Write new echo message $db->write_echo(%e_write); - + $msgs .= $_ . "\n"; push( @new, $echo_hash ); } } @@ -95,12 +96,15 @@ sub get_echo { $count++; } - # Populate $msgs and $base64 + # Populate hash while (<@msg_con>) { my @message = split /:/, $_; if ( defined( $message[1] ) ) { - $msgs .= $message[0] . "\n"; - $base64 .= $message[1] . "\n"; + my $h = { + hash => $message[0], + base64 => $message[1], + }; + push( @messages_hash, $h ); } } } @@ -108,15 +112,15 @@ sub get_echo { my $new_messages = "

Новые сообщения

\n"; if ( defined($msgs) ) { - my @msg_list = split /\n/, $base64; # Begin transaction print localtime() . ": writing messages\n"; $db->begin(); - while (<@msg_list>) { - my $mes_hash = $_; - my $text = II::Enc->decrypt($mes_hash); + my $c = 0; + while ( $c < @messages_hash ) { + my $mes_hash = $messages_hash[$c]->{hash}; + my $text = II::Enc->decrypt( $messages_hash[$c]->{base64} ); open my $m, "<", \$text or die "Cannot open message: $!\n"; @@ -154,6 +158,7 @@ sub get_echo { # Write message to DB $db->write(%data); + $c++; } # Commit transaction diff --git a/II/Send.pm b/II/Send.pm index 6b8e6ea..9dd3929 100644 --- a/II/Send.pm +++ b/II/Send.pm @@ -8,10 +8,12 @@ use Data::Dumper; sub new { my $class = shift; + my $db = II::DB->new(); my $self = { _config => shift, _echo => shift, _base64 => shift, + _db => $db, }; bless $self, $class; @@ -19,22 +21,23 @@ sub new { } sub send { - my ($self, $hash) = @_; + my ( $self, $hash ) = @_; my $config = $self->{_config}; my $echo = $self->{_echo}; my $base64 = $self->{_base64}; + my $db = $self->{_db}; # Push message to server my $host = $config->{host}; my $auth = $config->{key}; $host .= "u/point"; my $ua = LWP::UserAgent->new(); - my $response = $ua->post( $host, { 'pauth' => $auth, 'tmsg' => $base64 } ); + my $response + = $ua->post( $host, { 'pauth' => $auth, 'tmsg' => $base64 } ); - my $db = II::DB->new(); - if ($response->{_rc} == 200) { - $db->update_out($hash); - } + if ( $response->{_rc} == 200 ) { + $db->update_out($hash); + } } 1; diff --git a/ii.sql b/ii.sql index 78d1ccbbfda01821f7c26dc956db7154e93a57e7..76e49402e876c0db554471c2649c8153b3e76fbc 100644 GIT binary patch delta 5310 zcmZYCcbF7K8VBI2u9-%b1r|^jU6E)&R8Yi(3MNEBL@^)+Fd!xr1k;_~py;7@B;%MP z=0uW31;qd+RFXNOqL@xF2b6o~o_qMmKi;kCo|*2d@B8)4vtwotA2WOSsElN;4^ZyZyrZ1~VoqmCOkbX51##>VRUSRL067`JwCtY14gOH=yA%R&gh za1t*wk0*GE7kG@vL&(}0>zU205Moc`qs(9?Q<+|VZ$xe9#&??D!QI?dZaK2H>tT~k z%UsQsT*YTx!9*spf(eZ0a{kS~7{@=Utn^YYVJsJwZyH%!SGvITZ~UEeIFGX##c0lA z1ZQ#v$8Z9}IgS%Ko?{uw5C(HPr*ev-_Aw6QHS-&|g%Vac{~|PA%Di?DV}3K z3wV*|LnxAKWxfdQ&6n^hm7OdNAr*|v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