both examples posted on mailing list nuke abook files. Nice.
[squirrelmail.git] / contrib / flat2sql.pl
index 75bf2fa7c7804fd8a76c05e3879c44651a191460..2b02e4e65b98605398068d9ea86d5807a910db8f 100755 (executable)
@@ -1,10 +1,10 @@
 #!/usr/bin/perl
-
-# flat2sql.pl v1.0
-# 
-# Copyright (c) 2002,  Michael Blandford and Tal Yardeni
+#
+# Copyright (c) 2002, Michael Blandford and Tal Yardeni
+# Copyright (c) 2005, The SquirrelMail Project Team
 #
 # This script is licensed under GPL.
+# $Id$
 ##### Conf Section #####
 
 $data_dir = "/var/local/squirrelmail/data";
@@ -20,11 +20,10 @@ use Getopt::Long;
 
 &Usage if ( defined $opts{h} or defined $opts{help} );
 
-unless ( defined $opts{abook} or defined $opts{pref} or
-         defined $opts{sig}) {
-       $opts{abook}=TRUE;
-       $opts{pref}=TRUE;
-        $opts{sig}=TRUE;
+unless ( defined $opts{abook} or defined $opts{pref} or defined $opts{sig}) {
+    $opts{abook}=TRUE;
+    $opts{pref}=TRUE;
+    $opts{sig}=TRUE;
 }
 
 # Override the data directory if passed as an argument
@@ -66,7 +65,7 @@ sub abook {
   print "DELETE FROM $db.$abook_table WHERE owner = '$username;\n"
     if ( defined $opts{delete} );
 
-  open(ABOOK, ">$data_dir/$filename") or 
+  open(ABOOK, "<$data_dir/$filename") or 
     die "FILE READ ERROR: Could not open $filename!!\n";
 
   while (my $line = <ABOOK> ) {