Fixes
This commit is contained in:
parent
6ef1553a84
commit
b4463e7605
@ -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;
|
||||
}
|
||||
|
21
II/Get.pm
21
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
|
||||
= "<!DOCTYPE html><meta charset=utf8><body><h1>Новые сообщения</h1>\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
|
||||
|
@ -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;
|
||||
@ -23,15 +25,16 @@ sub send {
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user