--- db/prgsrc/db.cgi 2000/10/20 04:06:54 1.6 +++ db/prgsrc/db.cgi 2000/10/23 01:23:35 1.9 @@ -9,7 +9,8 @@ use POSIX qw(locale_h); my ($PWD) = `pwd`; chomp $PWD; my ($SRCPATH) = "$PWD/../dimrub/src"; -my ($ZIP) = "/usr/bin/zip"; +my ($ZIP) = "/home/piataev/bin/zip"; +my $DUMPFILE = /tmp/dump.sql my ($SENDMAIL) = "/usr/sbin/sendmail"; my ($TMSECS) = 30*24*60*60; my (%RevMonths) = @@ -480,7 +481,7 @@ sub Get12Random { WHERE QuestionId=$q"); $sth->execute; $t = ($sth->fetchrow)[0]; - } until !$chosen{$q} && $t =~ /$type/; + } until !$chosen{$q} && $type =~ /[$t]/; $chosen{$q} = 'y'; push @questions, $q; } @@ -603,16 +604,18 @@ MAIN: } if (param('rand')) { - my ($type, $qnum) = ('þ', 12); - $type = 'â' if (param('brain')); + my ($type, $qnum) = ('', 12); + $type .= 'â' if (param('brain')); + $type .= 'þ' if (param('chgk')); $qnum = param('qnum') if (param('qnum') =~ /^\d+$/); + $qnum = 0 if (!$type); if (param('email') && -x $SENDMAIL && open(F, "| $SENDMAIL -t -n")) { my ($Email) = param('email'); my ($mime_type) = $text ? "plain" : "html"; print F < 'application/x-zip-compressed; name="db.zip"', - -'Content-Disposition' => 'attachment; filename="db.zip"' - ); - $tour = (param('tour')) ? param('tour') : 0; - my (@files) = &PrintArchive($dbh, $tour); - open F, "$ZIP -j - $SRCPATH/COPYRIGHT @files |"; - print (); - close F; - $dbh->disconnect; - exit; + print header( + -'Content-Type' => 'application/x-zip-compressed; name="db.zip"', + -'Content-Disposition' => 'attachment; filename="db.zip"' + ); + $tour = (param('tour')) ? param('tour') : 0; + my (@files) = &PrintArchive($dbh, $tour); + open F, "$ZIP -j - $SRCPATH/COPYRIGHT @files |"; + print (); + close F; + $dbh->disconnect; + exit; + } elsif (param('sqldump')) { + print header( + -'Content-Type' => 'application/x-zip-compressed; name="dump.zip"', + -'Content-Disposition' => 'attachment; filename="dump.zip"' + ); + if (! -f $DUMPFILE) { + `mysqldump -u piataev chgk > $DUMPFILE`; + } + open F, "$ZIP -j - $DUMPFILE |"; + print (); + close F; + $dbh->disconnect; + exit; + } else { $tour = (param('tour')) ? param('tour') : 0; if ($tour !~ /^[0-9]*$/) {