imapsync/paypal_reply/paypal_build_reply
Nick Bebout 02322d6ed1 1.404
2011-03-12 02:45:06 +00:00

131 lines
2.7 KiB
Perl
Executable file

#!/usr/bin/perl
# $Id: paypal_build_reply,v 1.10 2011/02/02 22:31:41 gilles Exp gilles $
use warnings;
use strict;
my ($msg_id_file, $msg_id);
my ($amount, $name, $email);
my (
$paypal_line, $paypal_info,
$buyer, $description,
$url_source, $url_exe, $url, $release,
);
$msg_id_file = $ARGV[1];
$msg_id = firstline($msg_id_file);
while(<>) {
next if ( ! /^(.*Num.+ro de transaction :.*)$/ );
$paypal_line = $1;
$paypal_info = "===== Paypal id =====\n$paypal_line\n";
last;
}
while(<>) {
next if ( ! /^Vous avez re.*paiement d'un montant de (.*) de la part de (.*) \((.*)\)/);
($amount, $name, $email) = ($1, $2, $3);
last;
}
$url_source = firstline('/g/var/paypal_reply/url_source');
$url_exe = firstline('/g/var/paypal_reply/url_exe');
$release = firstline('/g/var/paypal_reply/url_release');
#print "[$amount] [$name] [$email] [$paypal_line]\n";
while(<>) {
next if ( ! /^Acheteur/ );
$buyer .= "===== Acheteur =====\n";
last;
}
while(<>) {
$buyer .= $_ if ( ! /^Instructions/ );
last if ( /^Instructions/ );
}
while(<>) {
next if ( ! /^Description :(.*)/ );
$description = "===== Details =====\n";
$description .= $_;
last;
}
while(<>) {
$description .= $_;
last if ( /^Paiement envoy/ );
}
my $address = 'gilles.lamiral@laposte.net';
my $address2 = 'gilles@lamiral.info';
my $rcstag = '$Id: paypal_build_reply,v 1.10 2011/02/02 22:31:41 gilles Exp gilles $';
my $message = <<EOM
X-Comment: $rcstag
In-Reply-To: $msg_id
From: Gilles LAMIRAL <$address>
To: <$email>
Bcc: Gilles LAMIRAL <$address>, <$address2>
Subject: [imapsync download] imapsync release $release [$email]
Hello $name,
You will find the latest imapsync source code release $release at the following link:
$url_source
You will find the latest imapsync.exe binary release $release at the following link:
$url_exe
Next imapsync releases will be available for one year without extra payment.
Just keep this message and ask for the new links.
(I will build an automatic subscription tool later)
I thank you for buying and using imapsync,
I wish you successful transfers!
$paypal_info
$buyer
$description
==== Vendeur ====
Gilles LAMIRAL
4 La Billais
35580 Baulon
FRANCE
Tel: +33 951 84 42 42
Mob: +33 620 79 76 06
Fax: +33 956 84 42 42
email: $address
--
Au revoir, 09 51 84 42 42
Gilles Lamiral. France, Baulon (35580) 06 20 79 76 06
EOM
;
=pod
=cut
print $message;
#print "[$amount] [$name] [$email] [$paypal_line]\n";
sub firstline {
# extract the first line of a file (without \n)
my($file) = @_;
my $line = "";
open FILE, $file or die("error [$file]: $! ");
chomp($line = <FILE>);
close FILE;
$line = ($line) ? $line: "error !EMPTY! [$file]";
return $line;
}