mirror of
https://github.com/imapsync/imapsync.git
synced 2025-07-22 18:25:54 +02:00
160 lines
3.4 KiB
Perl
Executable file
160 lines
3.4 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
# $Id: paypal_build_reply,v 1.12 2011/03/23 18:31:52 gilles Exp gilles $
|
|
|
|
use warnings;
|
|
use strict;
|
|
use Getopt::Long;
|
|
|
|
my ($msg_id_file, $msg_id);
|
|
my ($amount, $name, $email);
|
|
my (
|
|
$paypal_line, $paypal_info,
|
|
$buyer, $description,
|
|
$url_source, $url_exe, $url, $release,
|
|
);
|
|
|
|
my $help ;
|
|
my $debug ;
|
|
|
|
my $numopt = scalar(@ARGV);
|
|
my $opt_ret = GetOptions(
|
|
"help" => \$help,
|
|
"debug!" => \$debug,
|
|
);
|
|
|
|
usage() and exit if ($help or ! $numopt) ;
|
|
|
|
$msg_id_file = $ARGV[1];
|
|
$msg_id = firstline($msg_id_file);
|
|
|
|
$debug and print "Hi!\n" ;
|
|
|
|
while(<>) {
|
|
next if ( ! /^(.*Num.+ro de transaction.*)$/ );
|
|
$paypal_line = $1;
|
|
$paypal_info = "===== Paypal id =====\n$paypal_line\n";
|
|
$debug and print "$paypal_info" ;
|
|
last;
|
|
}
|
|
while(<>) {
|
|
if ( /^Vous avez re.*paiement d'un montant de (.*) de la part de (.*) \((.*)\)/) {
|
|
($amount, $name, $email) = ($1, $2, $3);
|
|
last;
|
|
}
|
|
if ( /^Vous avez re.*paiement d'un montant de (.*) de la part de (.*)/) {
|
|
($amount, $name, $email) = ($1, "", $2);
|
|
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(<>) {
|
|
if ( /^Acheteur/ ) {
|
|
$buyer .= "===== Acheteur =====\n";
|
|
last;
|
|
}
|
|
if ( /^Informations sur l'acheteur/ ) {
|
|
$buyer .= "===== Acheteur =====\n";
|
|
chomp( $name = <> );
|
|
$buyer .= "$name\n" ;
|
|
last;
|
|
}
|
|
}
|
|
|
|
while(<>) {
|
|
$buyer .= $_ if ( ! /^-----------------------------------/ );
|
|
last if ( /^-----------------------------------/ );
|
|
}
|
|
|
|
|
|
while(<>) {
|
|
next if ( ! /^Description :(.*)/ );
|
|
$description = "===== Details =====\n";
|
|
$description .= $_;
|
|
last;
|
|
}
|
|
|
|
while(<>) {
|
|
$debug and print "LINE:$_" ;
|
|
$description .= $_;
|
|
last if ( /^Paiement envoy/ );
|
|
last if ( /^N.*d'avis de r.*ception/ );
|
|
}
|
|
|
|
|
|
my $address = 'gilles.lamiral@laposte.net';
|
|
my $address2 = 'gilles@lamiral.info';
|
|
my $rcstag = '$Id: paypal_build_reply,v 1.12 2011/03/23 18:31:52 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
|
|
|
|
You will receive an invoice soon.
|
|
|
|
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;
|
|
}
|