[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 #!/usr/bin/perl 2 3 # Copyright (C) 2003 Jean-Louis BERGAMO <jlb@j1b.org> 4 # 5 # This program is free software; you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation; either version 2 of the License, or 8 # (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program; if not, write to the Free Software 17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19 # Ce script va lire les adresse contenu dans le repertoire donne en 20 # argument, et va rajouter ou supprimer ces adresses des listes qu'on 21 # lui a donne en argument (ou qu'il recupere dans la table des 22 # constantes) 23 24 use DBI; 25 use strict; 26 # get the command line option 27 use Getopt::Long; 28 29 # command line option hash table 30 my %optctl=(); 31 # get command line options 32 GetOptions(\%optctl,"help!","dir=s"); 33 if (defined $optctl{'help'}){ 34 &usage(); 35 } 36 my $dir=$optctl{'dir'}||&usage(); 37 my @lists=(); 38 my @emails=(); 39 40 opendir(DIR, $dir) || die "can't opendir $dir: $!"; 41 @lists=grep { /^[^.]/ && -d "$dir/$_" } readdir(DIR); 42 closedir DIR; 43 print join(',',@lists),"\n"; 44 45 foreach my $list (@lists){ 46 my $subdir='subscribe'; 47 if(opendir(DIR, "$dir/$list/$subdir")){ 48 @emails=grep { /^[^.].+\@/ && -f "$dir/$list/$subdir/$_" } readdir(DIR); 49 closedir DIR; 50 } 51 if (@emails){ 52 foreach my $mail(@emails){ 53 print "register $mail: echo $mail | /usr/sbin/add_members -n - $list\n"; 54 if (system("echo $mail | /usr/sbin/add_members -n - $list")){ 55 warn "can't execute echo $mail | /usr/sbin/add_members -n - $list : $!\n"; 56 }else{ 57 unlink("$dir/$list/$subdir/$mail"); 58 } 59 } 60 } 61 @emails=(); 62 $subdir='unsubscribe'; 63 if(opendir(DIR, "$dir/$list/$subdir")){ 64 @emails=grep { /^[^.].+\@/ && -f "$dir/$list/$subdir/$_" } readdir(DIR); 65 closedir DIR; 66 } 67 if (@emails){ 68 foreach my $mail(@emails){ 69 print "unsubscribe $mail : /usr/sbin/remove_members $list $mail\n"; 70 if (system("/usr/sbin/remove_members $list $mail")){ 71 warn "can't execute /usr/sbin/remove_members $list $mail : $!\n"; 72 }else{ 73 unlink("$dir/$list/$subdir/$mail"); 74 } 75 } 76 } 77 } 78 exit; 79 80 sub usage{ 81 print "$0 [--help] --dir=directory \n"; 82 print " directory is the directory where email are stored."; 83 print ""; 84 exit (1); 85 } 86
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |