--- db/prgsrc/db.cgi 2000/10/23 01:24:59 1.10 +++ db/prgsrc/db.cgi 2000/10/24 17:59:25 1.11 @@ -10,7 +10,7 @@ my ($PWD) = `pwd`; chomp $PWD; my ($SRCPATH) = "$PWD/../dimrub/src"; my ($ZIP) = "/home/piataev/bin/zip"; -my $DUMPFILE = "/tmp/dump.sql"; +my $DUMPFILE = "/tmp/chgkdump"; my ($SENDMAIL) = "/usr/sbin/sendmail"; my ($TMSECS) = 30*24*60*60; my (%RevMonths) = @@ -474,18 +474,18 @@ sub Get12Random { my (%chosen); srand; - for ($i = 0; $i < $num; $i++) { - do { - $q = int(rand($qnum)); - $sth = $dbh->prepare("SELECT Type FROM Questions + for ($i = 0; $i < $num; $i++) { + do { + $q = int(rand($qnum)); + $sth = $dbh->prepare("SELECT Type FROM Questions WHERE QuestionId=$q"); - $sth->execute; - $t = ($sth->fetchrow)[0]; - } until !$chosen{$q} && $type =~ /[$t]/; - $chosen{$q} = 'y'; - push @questions, $q; - } - return @questions; + $sth->execute; + $t = ($sth->fetchrow)[0]; + } until !$chosen{$q} && $t && $type =~ /[$t]/; + $chosen{$q} = 'y'; + push @questions, $q; + } + return @questions; } sub Include_virtual { @@ -590,7 +590,7 @@ MAIN: print end_html; die "Can't connect to DB chgk\n"; }; - if (!param('comp') and !$text) { + if (!param('comp') and !param('sqldump') and !$text) { print header; print start_html(-"title"=>'Database of the questions', -author=>'dimrub@icomverse.com', @@ -651,9 +651,6 @@ EOT -'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;