[Popcon-commits] cvs commit to popularity-contest by pere

pere at cvs.alioth.debian.org pere at cvs.alioth.debian.org
Wed Jul 20 09:50:00 UTC 2005


Update of /cvsroot/popcon/popularity-contest
In directory haydn:/tmp/cvs-serv21013

Modified Files:
	popcon-submit.cgi 
Log Message:
Add support in popcon-submit.cgi to save directly to disk instead of sending emails.

Index: popcon-submit.cgi
===================================================================
RCS file: /cvsroot/popcon/popularity-contest/popcon-submit.cgi,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- popcon-submit.cgi	20 Jul 2005 07:48:39 -0000	1.3
+++ popcon-submit.cgi	20 Jul 2005 09:49:58 -0000	1.4
@@ -17,6 +17,10 @@
 
 my $email='survey at popcon.debian.org';
 
+my $directsave = 0; # Enable to store on disk instead of sending an email
+my $basedir   = "/var/lib/popcon";
+my $uploaddir = "$basedir/popcon-data/";
+
 $ENV{PATH}="";
 
 print "Content-Type: text/plain\n\n";
@@ -69,15 +73,31 @@
     @entry = <GZIP>;
 }
 
-open POPCON, "|/usr/lib/sendmail -oi $email" or die "sendmail";
-print POPCON <<"EOF";
+my ($id1, $id2) =
+    $entry[0] =~ m/POPULARITY-CONTEST-0 .+ ID:(\S\S)(\S+) /;
+if ($id1) {
+    if ($directsave) {
+	-d $uploaddir || mkdir $uploaddir;
+	my $dir = "$uploaddir/$id1";
+	-d $dir || mkdir $dir;
+	open(POPCON, ">$dir/$id1$id2") || die "Unable to write to '$dir/$id1$id2'";
+	print POPCON @entry;
+	close POPCON;
+    } else {
+	open POPCON, "|/usr/lib/sendmail -oi $email" or die "sendmail";
+	print POPCON <<"EOF";
 To: $email
 Subject: popularity-contest submission
 
 EOF
-print POPCON @entry;
-close POPCON;
-
-print "Thanks for your submission to Debian Popularity-Contest!\n";
-print "DEBIAN POPCON HTTP-POST OK\n";
+        print POPCON @entry;
+	close POPCON;
+    }
+}
+if ($id1) {
+    print "Thanks for your submission to Debian Popularity-Contest!\n";
+    print "DEBIAN POPCON HTTP-POST OK\n";
+} else {
+    print "The submission to Debian Popularity-Contest!\n";
+}
 exit 0;




More information about the Popcon-commits mailing list