version 1.80, 2002/12/19 23:55:55
|
version 1.88, 2003/02/02 21:54:11
|
Line 160 print "timee0=".time.br if $debug;
|
Line 160 print "timee0=".time.br if $debug;
|
sub printform |
sub printform |
{ |
{ |
|
|
my $submit=submit(-value=>'Поиск'); |
my $qnumber=(" "x10)."Выводить по ". textfield(-name=>'kvo', |
my $inputstring=textfield(-name=>'sstr', |
|
-default=>param('sstr')||'', |
|
-size=>30, |
|
-maxlength=>50); |
|
my $qnumber="Выводить по".br. textfield(-name=>'kvo', |
|
-default=>param('kvo')||'150', |
-default=>param('kvo')||'150', |
-size=>3, |
-size=>3, |
-maxlength=>5). br."вопросов"; |
-maxlength=>5)." вопросов"; |
|
my $sstr=param('sstr'); |
my @df=keys %searchin; |
my @df=keys %searchin; |
|
my %checked; |
@df=('Question', 'Answer') unless @df; |
@df=('Question', 'Answer') unless @df; |
|
$checked{lc $_}="checked" foreach @df; |
my $fields=checkbox_group('searchin',['Question','Answer','Comments','Authors','Sources'], [@df], |
my $fields=checkbox_group('searchin',['Question','Answer','Comments','Authors','Sources'], [@df], |
'false',\%rusfieldname); |
'false',\%rusfieldname); |
@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; |
|
my $all=param('all') && param('all') eq 'yes'; |
|
|
my $types=checkbox_group('type',['chgk','brain','igp','game','ehruditka','beskrylka'], [@df], |
$checked{'all'}=$all?"checked":""; |
'false',\%rusfieldname); |
$checked{'any'}=$all?"":"checked"; |
my $metod=radio_group(-name=>'metod',-values=>['old','rus'], |
$checked{lc param('metod')}="checked"; |
-default=>(param('metod')||'rus'), |
$checked{'russian'}=1 unless $checked{'russian'} || $checked{'old'}; |
-labels=>\%rusfieldname); |
|
my $all=radio_group(-name=>'all',-values=>['yes','no'], |
|
-default=>(param('all')||'no'), |
|
-labels=>{'yes'=>'Все','no'=>'Любое'}); |
|
|
|
################################################# |
################################################# |
return start_form(-method=>'get', |
return |
-action=>url, |
<<EOT |
-enctype=> |
<form method="get" enctype="application/x-www-form-urlencoded" |
"application/x-www-form-urlencoded" |
action="/znatoki/cgi-bin/db.cgi"> |
).br. |
<h2>Поиск в базе вопросов</h2> |
table(Tr |
|
( |
<input type="text" name="sstr" value="$sstr" size="30" maxlength="50"> |
td({-valign=>'TOP'},$inputstring.$submit.p."Метод: $metod".p."Слова: $all"), |
<input type="submit" value="Поиск"> $qnumber |
td({-valign=>'TOP'},(' 'x 8).'Поля:'), |
<p> |
td({-valign=>'TOP'},$fields), |
|
td({-valign=>'TOP'},(' 'x 1).'Типы:'), |
<table border="1" cellpadding=4 cellspacing=0> |
td({-valign=>'TOP'},$types), td(" "x5), |
<tr> |
td({-valign=>'TOP'},$qnumber) |
<th align="left" rowspan=3 width="20%"> Вариант поиска: |
) |
</td><td rowspan=2 colspan=2> |
) |
<input type="radio" $checked{'old'} name="metod" value="old"> Простой (старый) |
|
</td><td> |
#$fields. |
<input type="checkbox" $checked{'chgk'} name="type" value="chgk"> "Что? Где? Когда?" |
#$inputstring.$submit.br.$metod.$all |
</td><td><nobr> |
|
<input type="checkbox" $checked{'brain'} name="type" value="brain"> "Брейн-Ринг"</nobr> |
|
</td><td> |
|
<input type="checkbox" $checked{'igp'} name="type" value="igp"> "Интернет" |
|
</td> |
|
</tr><tr> |
|
<td> |
|
<input type="checkbox" $checked{'game'} name="type" value="game"> "Своя игра" |
|
</td><td> |
|
<input type="checkbox" $checked{'ehruditka'} name="type" value="ehruditka"> "Эрудитка" |
|
</td><td> |
|
<input type="checkbox" $checked{'beskrylka'} name="type" value="beskrylka"> "Бескрылка" |
|
</td> |
|
</tr><tr> |
|
<td colspan=5><input type="radio" $checked{'rus'} name="metod" value="rus"> Расширенный (с учетом грамматики, в вопросах всех типов) |
|
</td> |
|
</tr><tr> |
|
<th align="left">Искать: |
|
</td><td colspan=2> |
|
<input type="radio" $checked{'all'} name="all" value="yes">Все слова |
|
</td><td colspan=3> |
|
<input type="radio" $checked{'any'} name="all" value="no">Любое слово |
|
</td> |
|
</tr><tr> |
|
<th align="left">Поля для поиска: |
|
</td><td width="15%"> |
|
<input type="checkbox" name="searchin" value="Question" $checked{'question'}>Вопрос |
|
</td><td width="15%"> |
|
<input type="checkbox" name="searchin" value="Answer" $checked{'answer'}>Ответ<br> |
|
</td><td width="15%"> |
|
<input type="checkbox" name="searchin" value="Comments" $checked{'comments'}>Комментарии<br> |
|
</td><td width="15%"> |
|
<input type="checkbox" name="searchin" value="Authors" $checked{'authors'}>Автор<br> |
|
</td><td width="15%"> |
|
<input type="checkbox" name="searchin" value="Sources" $checked{'sources'}>Источник<br> |
|
</td> |
|
</tr> |
|
</table> |
|
</center> |
|
|
|
EOT |
.endform |
.endform |
.hr |
.hr |
|
|
Line 688 sub PrintList {
|
Line 723 sub PrintList {
|
sub PrintSearch { |
sub PrintSearch { |
my ($dbh, $sstr, $metod,$was) = @_; |
my ($dbh, $sstr, $metod,$was) = @_; |
my $t=time; |
my $t=time; |
print h2("Поиск в базе вопросов"); |
# print h2("Поиск в базе вопросов"); |
print printform; |
print printform; |
my @allnf; |
my @allnf; |
my @Questions; |
my @Questions; |
Line 1078 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 1103 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 1170 EOTT
|
Line 1204 EOTT
|
} |
} |
|
|
|
|
|
|
$output.="</span>" |
$output.="</span>" |
|
|
} |
} |
$output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p |
$output=~s/\(pic: ([^\)]*)\)/<p><img src="\/znatoki\/images\/db\/$1"><p>/g unless $text; |
if $answer>0 && !$text; |
my $qid=param('tour') ? (param('tour').".$Question{'Number'}" ): ''; |
|
|
|
$output.=br.a({href=> url."?metod=proxy& |
|
qid=$qid"}, 'Близкие вопросы').p |
|
if $answer>0 && !$text && $qid; |
return $output; |
return $output; |
} |
} |
|
|
Line 1338 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 1360 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 1585 MAIN:
|
Line 1632 MAIN:
|
setlocale(LC_CTYPE,'russian'); |
setlocale(LC_CTYPE,'russian'); |
my($i, $tour); |
my($i, $tour); |
my($text) = (param('text')) ? 1 : 0; |
my($text) = (param('text')) ? 1 : 0; |
|
if ($text) { |
|
print header('text/plain'); |
|
} 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', |
-vlink=>'#800020'); |
-vlink=>'#800020'); |
|
print "<style> |
|
td {font-size: x-small; font-family : sans-serif} |
|
th {font-size: x-small; font-family : sans-serif} |
|
</style>\n"; |
|
|
print &Include_virtual("../dimrub/db/reklama.html"); |
print &Include_virtual("../dimrub/db/reklama.html"); |
} |
} |
|
|
Line 1614 POSIX::setlocale( &POSIX::LC_ALL, $thisl
|
Line 1668 POSIX::setlocale( &POSIX::LC_ALL, $thisl
|
if ((uc 'а') ne 'А') {print "Koi8-r locale not installed!\n"}; |
if ((uc 'а') ne 'А') {print "Koi8-r locale not installed!\n"}; |
|
|
|
|
if ($text) { |
|
print header('text/plain'); |
|
} |
|
|
|
if (param('hideequal')) { |
if (param('hideequal')) { |
my ($sth)= $dbh -> prepare("select first, second FROM equalto"); |
my ($sth)= $dbh -> prepare("select first, second FROM equalto"); |
$sth -> execute; |
$sth -> execute; |
Line 1692 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 1774 function toggle(e) {
|
Line 1851 function toggle(e) {
|
</SCRIPT> |
</SCRIPT> |
EEE |
EEE |
; |
; |
print end_html; |
# print end_html; |
} |
} |
$dbh->disconnect; |
$dbh->disconnect; |
} |
} |