version 1.85, 2003/01/27 12:55:55
|
version 1.88, 2003/02/02 21:54:11
|
Line 174 sub printform
|
Line 174 sub printform
|
@df=param('type'); |
@df=param('type'); |
@df=('chgk','brain','igp','game','ehruditka','beskrylka') unless @df; |
@df=('chgk','brain','igp','game','ehruditka','beskrylka') unless @df; |
$checked{lc $_}="checked" foreach @df; |
$checked{lc $_}="checked" foreach @df; |
$checked{'all'}=param('all')?"checked":""; |
my $all=param('all') && param('all') eq 'yes'; |
$checked{'any'}=param('all')?"":"checked"; |
|
|
$checked{'all'}=$all?"checked":""; |
|
$checked{'any'}=$all?"":"checked"; |
$checked{lc param('metod')}="checked"; |
$checked{lc param('metod')}="checked"; |
$checked{'russian'}=1 unless $checked{'russian'} || $checked{'old'}; |
$checked{'russian'}=1 unless $checked{'russian'} || $checked{'old'}; |
|
|
Line 184 return
|
Line 186 return
|
<<EOT |
<<EOT |
<form method="get" enctype="application/x-www-form-urlencoded" |
<form method="get" enctype="application/x-www-form-urlencoded" |
action="/znatoki/cgi-bin/db.cgi"> |
action="/znatoki/cgi-bin/db.cgi"> |
<h2>Поиск в базе данных</h2> |
<h2>Поиск в базе вопросов</h2> |
|
|
<input type="text" name="sstr" value=$sstr size="30" maxlength="50"> |
<input type="text" name="sstr" value="$sstr" size="30" maxlength="50"> |
<input type="submit" value="Поиск"> $qnumber |
<input type="submit" value="Поиск"> $qnumber |
<p> |
<p> |
|
|
Line 211 action="/znatoki/cgi-bin/db.cgi">
|
Line 213 action="/znatoki/cgi-bin/db.cgi">
|
<input type="checkbox" $checked{'beskrylka'} name="type" value="beskrylka"> "Бескрылка" |
<input type="checkbox" $checked{'beskrylka'} name="type" value="beskrylka"> "Бескрылка" |
</td> |
</td> |
</tr><tr> |
</tr><tr> |
<td colspan=5><input type="radio" $checked{'russian'} name="metod" value="rus"> Расширенный (с учетом грамматики, в вопросах всех типов) |
<td colspan=5><input type="radio" $checked{'rus'} name="metod" value="rus"> Расширенный (с учетом грамматики, в вопросах всех типов) |
</td> |
</td> |
</tr><tr> |
</tr><tr> |
<th align="left">Искать: |
<th align="left">Искать: |
Line 1111 sub PrintQuestion {
|
Line 1113 sub PrintQuestion {
|
my (%Tour) = GetTournament($dbh, $Question{'ParentId'}); |
my (%Tour) = GetTournament($dbh, $Question{'ParentId'}); |
my (%Tournament) = GetTournament($dbh, $Tour{'ParentId'}); |
my (%Tournament) = GetTournament($dbh, $Tour{'ParentId'}); |
my $fname=$Tournament{'FileName'}; |
my $fname=$Tournament{'FileName'}; |
#return "" if $fname=~/mgp0203/; |
|
$fname=~s/\.txt//; |
$fname=~s/\.txt//; |
$titles .= |
$titles .= |
dd(img({src=>"/icons/folder.open.gif"}) . " " . |
dd(img({src=>"/icons/folder.open.gif"}) . " " . |
Line 1136 sub PrintQuestion {
|
Line 1137 sub PrintQuestion {
|
if ($Question{'Authors'} ) { |
if ($Question{'Authors'} ) { |
my $q=$Question{'Authors'}; |
my $q=$Question{'Authors'}; |
###АВТОРА!! |
###АВТОРА!! |
my $sth=$dbh->prepare("select Authors.Id,Name, Surname, Nicks from Authors, A2Q |
my $sth=$dbh->prepare("select Authors.CharId,Name, Surname, Nicks from Authors, A2Q |
where Authors.Id=Author And Question=$Id"); |
where Authors.Id=Author And Question=$Id"); |
$sth->execute; |
$sth->execute; |
my ($AuthorId,$Name, $Surname,$other,$Nicks); |
my ($AuthorId,$Name, $Surname,$other,$Nicks); |
if (!$text) { |
if (!$text) { |
while ((($AuthorId,$Name, $Surname,$Nicks)=$sth->fetchrow),$AuthorId) |
while ((($AuthorId,$Name, $Surname,$Nicks)=$sth->fetchrow),$AuthorId) |
{ |
{ |
my ($firstletter)=$Name=~m/^./g; |
my ($firstletter)=$Name=~m/^./g; |
$Name=~s/\./\\\./g; |
$Name=~s/\./\\\./g; |
my $sha="(?:$Name\\s+$Surname)|(?:$Surname\\s+$Name)|(?:$firstletter\\.\\s*$Surname)|(?:$Surname\\s+$firstletter\\.)|(?:$Surname)|(?:$Name)"; |
my $sha="(?:$Name\\s+$Surname)|(?:$Surname\\s+$Name)|(?:$firstletter\\.\\s*$Surname)|(?:$Surname\\s+$firstletter\\.)|(?:$Surname)|(?:$Name)"; |
if ($Nicks) |
if ($Nicks) |
Line 1208 $output.="</span>"
|
Line 1209 $output.="</span>"
|
|
|
} |
} |
$output=~s/\(pic: ([^\)]*)\)/<p><img src="\/znatoki\/images\/db\/$1"><p>/g unless $text; |
$output=~s/\(pic: ([^\)]*)\)/<p><img src="\/znatoki\/images\/db\/$1"><p>/g unless $text; |
$output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p |
my $qid=param('tour') ? (param('tour').".$Question{'Number'}" ): ''; |
if $answer>0 && !$text; |
|
|
$output.=br.a({href=> url."?metod=proxy& |
|
qid=$qid"}, 'Близкие вопросы').p |
|
if $answer>0 && !$text && $qid; |
return $output; |
return $output; |
} |
} |
|
|
Line 1373 sub PrintQOfAuthor
|
Line 1377 sub PrintQOfAuthor
|
{ |
{ |
|
|
my ($dbh, $id) = @_; |
my ($dbh, $id) = @_; |
$id=$dbh->quote($id); |
unless ($id=~/^\d+$/) { |
|
$id=$dbh->quote($id); |
|
my $sth = $dbh->prepare("SELECT Id FROM Authors WHERE CharId=$id"); |
|
$sth->execute; |
|
($id)=$sth->fetchrow; |
|
$sth->finish; |
|
} |
|
$id=$dbh->quote($id); |
|
|
my $sth = $dbh->prepare("SELECT Name, Surname FROM Authors WHERE Id=$id"); |
my $sth = $dbh->prepare("SELECT Name, Surname FROM Authors WHERE Id=$id"); |
$sth->execute; |
$sth->execute; |
my ($name,$surname)=$sth->fetchrow; |
my ($name,$surname)=$sth->fetchrow; |
Line 1395 sub PrintQOfAuthor
|
Line 1407 sub PrintQOfAuthor
|
} else { |
} else { |
$suffix = 'я'; |
$suffix = 'я'; |
} |
} |
print h2("Поиск в базе вопросов"); |
# print h2("Поиск в базе вопросов"); |
print printform; |
print printform; |
print p({align=>"center"}, "Автор ".strong("$name $surname. ") |
print p({align=>"center"}, "Автор ".strong("$name $surname. ") |
. " : $hits попадани$suffix."); |
. " : $hits попадани$suffix."); |
Line 1624 MAIN:
|
Line 1636 MAIN:
|
print header('text/plain'); |
print header('text/plain'); |
} else {print header;} |
} else {print header;} |
|
|
|
|
my($dbh) = DBI->connect("DBI:mysql:chgk", "piataev", "") |
my($dbh) = DBI->connect("DBI:mysql:chgk", "piataev", "") |
or do { |
or do { |
print h1("Временные проблемы") . "База данных временно не |
print h1("Временные проблемы") . "База вопросов временно не |
работает. Заходите попозже."; |
работает. Заходите попозже."; |
print &Include_virtual("../dimrub/db/reklama.html"); |
print &Include_virtual("../dimrub/db/reklama.html"); |
print end_html; |
print end_html; |
die "Can't connect to DB chgk\n"; |
die "Can't connect to DB chgk\n"; |
}; |
}; |
if (!param('comp') and !param('sqldump') and !$text) { |
if (!param('comp') and !param('sqldump') and !$text) { |
print header; |
|
print start_html(-"title"=>'Database of the questions', |
print start_html(-"title"=>'Database of the questions', |
-author=>'dimrub@icomverse.com', |
-author=>'dimrub@icomverse.com', |
-bgcolor=>'#fff0e0', |
-bgcolor=>'#fff0e0', |
Line 1732 EOT
|
Line 1742 EOT
|
} |
} |
elsif (param('qid')) { |
elsif (param('qid')) { |
my $qid=param('qid'); |
my $qid=param('qid'); |
|
if ($qid !~ /^[0-9]*$/) { |
|
my ($fname,$t,$n)= split /\./ , $qid; |
|
$n=$t,$t='' unless $n; |
|
if ($n) |
|
{ |
|
$sth = $dbh->prepare( |
|
"SELECT t2.Id FROM Tournaments as t1, |
|
Tournaments as t2 |
|
WHERE t1.FileName = '$fname.txt' |
|
AND t1.Id=t2.ParentId AND t2.Number=$t"); |
|
} |
|
else |
|
{ |
|
$sth = $dbh->prepare("SELECT Id FROM Tournaments |
|
WHERE FileName = '$fname.txt'"); |
|
} |
|
$sth->execute; |
|
$tour = ($sth->fetchrow)[0]; |
|
$sth->finish; |
|
$sth = $dbh->prepare( |
|
"SELECT QuestionId FROM |
|
Questions |
|
WHERE ParentId=$tour AND |
|
Questions.Number=$n"); |
|
$sth->execute; |
|
$qid = ($sth->fetchrow)[0]; |
|
} |
my $query="SELECT Question, Answer from Questions where QuestionId=$qid"; |
my $query="SELECT Question, Answer from Questions where QuestionId=$qid"; |
print $query if $printqueries; |
print $query if $printqueries; |
my $sth=$dbh->prepare($query); |
my $sth=$dbh->prepare($query); |
Line 1814 function toggle(e) {
|
Line 1851 function toggle(e) {
|
</SCRIPT> |
</SCRIPT> |
EEE |
EEE |
; |
; |
print end_html; |
# print end_html; |
} |
} |
$dbh->disconnect; |
$dbh->disconnect; |
} |
} |