version 1.88, 2003/02/02 21:54:11
|
version 1.91, 2003/02/21 19:39:46
|
Line 8 use POSIX qw(locale_h);
|
Line 8 use POSIX qw(locale_h);
|
use locale; |
use locale; |
open STDERR, ">/var/tmp/errors1"; |
open STDERR, ">/var/tmp/errors1"; |
my $newsurl='http://news.chgk.info/'; |
my $newsurl='http://news.chgk.info/'; |
|
my ($proxyptext,$proxysstr); |
my $printqueries=0; |
my $printqueries=0; |
my %forbidden=(); |
my %forbidden=(); |
my $debug=0; #added by R7 |
my $debug=0; #added by R7 |
if (param('debug')) {$debug=1; $printqueries=1} |
if (param('debug')) {$debug=1; $printqueries=1} |
*STDERR=*STDOUT if $debug; |
*STDERR=*STDOUT if $debug; |
|
my $thislocale; |
|
if ($^O =~ /win/i) { |
|
$thislocale = "Russian_Russia.20866"; |
|
} else { |
|
$thislocale = "ru_RU.KOI8-R"; |
|
} |
|
POSIX::setlocale( &POSIX::LC_ALL, $thislocale ); |
|
|
|
if ((uc 'Á') ne 'á') {print STDERR "Koi8-r locale not installed!\n"}; |
|
|
my %fieldname= (0,'Question', 1, 'Answer', 2, 'Comments', 3, 'Authors', 4, 'Sources'); |
my %fieldname= (0,'Question', 1, 'Answer', 2, 'Comments', 3, 'Authors', 4, 'Sources'); |
my %rusfieldname=('Question','÷ÏÐÒÏÓ', 'Answer', 'ïÔ×ÅÔ', |
my %rusfieldname=('Question','÷ÏÐÒÏÓ', 'Answer', 'ïÔ×ÅÔ', |
'Comments', 'ëÏÍÍÅÎÔÁÒÉÉ', 'Authors', 'á×ÔÏÒ', |
'Comments', 'ëÏÍÍÅÎÔÁÒÉÉ', 'Authors', 'á×ÔÏÒ', |
Line 30 my %metodchar=('rus',1,'old',2);
|
Line 41 my %metodchar=('rus',1,'old',2);
|
|
|
|
|
|
|
my $thislocale; |
|
|
|
$searchin{$_}=1 foreach param('searchin'); |
$searchin{$_}=1 foreach param('searchin'); |
my %TypeName=('children'=>'ä', 'game'=>'ñ', 'igp'=>'é', |
my %TypeName=('children'=>'ä', 'game'=>'ñ', 'igp'=>'é', |
Line 145 sub GetTours {
|
Line 155 sub GetTours {
|
sub count |
sub count |
{ |
{ |
my ($dbh,$word)=@_; |
my ($dbh,$word)=@_; |
print "timeb=".time.br if $debug; |
|
$word=$dbh->quote(uc $word); |
$word=$dbh->quote(uc $word); |
my $query="SELECT number from nests,nf where $word=w1 AND w2=nf.id"; |
my $query="SELECT number from nests,nf where $word=w1 AND w2=nf.id"; |
my $sth=$dbh->prepare($query); |
my $sth=$dbh->prepare($query); |
$sth->execute; |
$sth->execute; |
my @a=$sth->fetchrow; |
my @a=$sth->fetchrow; |
print "timee0=".time.br if $debug; |
|
$sth->finish; |
$sth->finish; |
$a[0]||0; |
$a[0]||0; |
} |
} |
Line 246 EOT
|
Line 254 EOT
|
} |
} |
|
|
sub proxy |
sub proxy |
{ |
{ |
#print "time0=".time.br if $debug; |
|
my ($dbh,$ptext,$allnf)=@_; |
my ($dbh,$ptext,$allnf)=@_; |
|
my $sstr=makeproxysstr($dbh,$ptext,$allnf); |
|
return russearch($dbh,$sstr,0,$allnf); |
|
} |
|
|
|
sub makeproxysstr { |
|
my ($dbh,$ptext)=@_; |
my $text=$$ptext; |
my $text=$$ptext; |
$text=~tr/£³/Åå/; |
$text=~tr/£³/Åå/; |
$text=~s/(${RLrl})p(${RLrl})/$1p$2/gom; |
$text=~s/(${RLrl})p(${RLrl})/$1p$2/gom; |
Line 274 sub proxy
|
Line 287 sub proxy
|
|
|
$good{$words[$_]}=0 foreach 16..$#words; |
$good{$words[$_]}=0 foreach 16..$#words; |
|
|
# foreach (@list) |
|
# { |
|
# if ($good{$_}) |
|
# { |
|
# $good{$_}=0; |
|
# $sstr.=" $_"; |
|
# } |
|
# } |
|
$sstr.=" $_" foreach grep {$good{$_}} @list; |
$sstr.=" $_" foreach grep {$good{$_}} @list; |
print "time05=".time.br if $debug; |
|
$$ptext=$sstr; |
$$ptext=$sstr; |
return russearch($dbh,$sstr,0,$allnf); |
return $sstr; |
} |
} |
|
|
|
|
Line 504 sub Search {
|
Line 508 sub Search {
|
my $sstr=$$s; |
my $sstr=$$s; |
my (@arr, @Questions, @fields); |
my (@arr, @Questions, @fields); |
my (@sar, $i, $sth,$where,$query); |
my (@sar, $i, $sth,$where,$query); |
# my $ip=$ENV{'REMOTE_ADDR'}; |
|
|
|
# $ip=$dbh->quote($ip); |
|
# $query= |
|
# "INSERT into queries (query,metod,searchin,ip) |
|
# values (". $dbh->quote($sstr).', '. |
|
# $dbh->quote($metod) . ', ' . |
|
# $dbh->quote(join ' ', grep $searchin{$_}, keys %searchin) . |
|
# ", $ip)"; |
|
#print $query if $printqueries; |
|
# $dbh -> do ($query); |
|
if ($metod eq 'rus') |
if ($metod eq 'rus') |
{ |
{ |
my @tasks=russearch($dbh,$sstr,$all,$allnf); |
my @tasks=russearch($dbh,$sstr,$all,$allnf); |
Line 522 sub Search {
|
Line 515 sub Search {
|
} |
} |
elsif ($metod eq 'proxy') |
elsif ($metod eq 'proxy') |
{ |
{ |
# $searchin{'question'}=1; |
|
# $searchin{'answer'}=1; |
|
my @task=proxy($dbh,$s,$allnf); |
my @task=proxy($dbh,$s,$allnf); |
# $$s=$sstr; |
|
return @task |
return @task |
} |
} |
|
|
Line 1146 sub PrintQuestion {
|
Line 1136 sub PrintQuestion {
|
{ |
{ |
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)"; |
$Name=~s/£/[Å£]/g; |
|
$Surname=~s/£/[Å£]/g; |
|
my $sha="(?:$Name\\s+$Surname)|(?:$Surname\\s+$Name)|(?:$firstletter\\.\\s*$Surname)|(?:$Surname\\s+$firstletter\\.)|(?:$Surname)"; |
if ($Nicks) |
if ($Nicks) |
{ |
{ |
$Nicks=~s/^\|//; |
$Nicks=~s/^\|//; |
Line 1161 sub PrintQuestion {
|
Line 1153 sub PrintQuestion {
|
} |
} |
} |
} |
$q=~s/($sha)/a({href=>url."?qofauthor=$AuthorId"},$1)/ei; |
$q=~s/($sha)/a({href=>url."?qofauthor=$AuthorId"},$1)/ei; |
|
unless ($1) |
|
{ |
|
$q=~s/$Name/a({href=>url."?qofauthor=$AuthorId"},$1)/ei; |
|
} |
} |
} |
} |
} |
$output .= &PrintField("á×ÔÏÒ(Ù)", $q, $text); |
$output .= &PrintField("á×ÔÏÒ(Ù)", $q, $text); |
Line 1629 sub WriteFile {
|
Line 1625 sub WriteFile {
|
|
|
MAIN: |
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; |
Line 1644 MAIN:
|
Line 1641 MAIN:
|
print end_html; |
print end_html; |
die "Can't connect to DB chgk\n"; |
die "Can't connect to DB chgk\n"; |
}; |
}; |
|
my $sstr=param('sstr'); |
|
if (param('qid')) { |
|
my $sth; |
|
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"; |
|
$sth=$dbh->prepare($query); |
|
$sth->execute; |
|
$sstr= join ' ',$sth->fetchrow; |
|
$sth->finish; |
|
$searchin{'Question'}=1; |
|
$searchin{'Answer'}=1; |
|
$sstr=~tr/£³/Åå/; |
|
$sstr=~s/[^ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔØÂÀêãõëåîçûýúèÿæù÷áðòïìäöüñþóíéôøâàa-zA-Z0-9]/ /gi; |
|
$proxysstr=$sstr; |
|
$proxysstr=makeproxysstr($dbh,\$proxysstr); |
|
} |
|
|
|
|
if (!param('comp') and !param('sqldump') and !$text) { |
if (!param('comp') and !param('sqldump') and !$text) { |
print start_html(-"title"=>'Database of the questions', |
my $title="òÅÚÕÌØÔÁÔÙ ÐÏÉÓËÁ ÎÁ \"". ($proxysstr||$sstr) .'"' |
|
if ($proxysstr||$sstr); |
|
$title||="âÁÚÁ ×ÏÐÒÏÓÏ×"; |
|
|
|
print start_html(-"title"=>$title, |
-author=>'dimrub@icomverse.com', |
-author=>'dimrub@icomverse.com', |
-bgcolor=>'#fff0e0', |
-bgcolor=>'#fff0e0', |
-vlink=>'#800020'); |
-vlink=>'#800020'); |
Line 1658 th {font-size: x-small; font-family : sa
|
Line 1704 th {font-size: x-small; font-family : sa
|
} |
} |
|
|
|
|
if ($^O =~ /win/i) { |
|
$thislocale = "Russian_Russia.20866"; |
|
} else { |
|
$thislocale = "ru_RU.KOI8-R"; |
|
} |
|
POSIX::setlocale( &POSIX::LC_ALL, $thislocale ); |
|
|
|
if ((uc 'Á') ne 'á') {print "Koi8-r locale not installed!\n"}; |
|
|
|
|
|
if (param('hideequal')) { |
if (param('hideequal')) { |
Line 1741 EOT
|
Line 1779 EOT
|
(time_to_sec(now())-time_to_sec(t) >3600)") |
(time_to_sec(now())-time_to_sec(t) >3600)") |
} |
} |
elsif (param('qid')) { |
elsif (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"; |
|
print $query if $printqueries; |
|
my $sth=$dbh->prepare($query); |
|
$sth->execute; |
|
my $sstr= join ' ',$sth->fetchrow; |
|
$sth->finish; |
|
$searchin{'Question'}=1; |
|
$searchin{'Answer'}=1; |
|
$sstr=~tr/£³/Åå/; |
|
$sstr=~s/[^ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔØÂÀêãõëåîçûýúèÿæù÷áðòïìäöüñþóíéôøâàa-zA-Z0-9]/ /gi; |
|
# print &PrintQuestion($dbh,$qid, 1, '!'); |
|
&PrintSearch($dbh, $sstr, 'proxy'); |
&PrintSearch($dbh, $sstr, 'proxy'); |
} |
} |
elsif (param('getfile')){ |
elsif (param('getfile')){ |
Line 1839 $sstr=~s/[^ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔ
|
Line 1838 $sstr=~s/[^ÊÃÕËÅÎÇÛÝÚÈßÆÙ×ÁÐÒÏÌÄÖÜÑÞÓÍÉÔ
|
} |
} |
if (!$text) { |
if (!$text) { |
print &Include_virtual("../dimrub/db/footer.html"); |
print &Include_virtual("../dimrub/db/footer.html"); |
|
print p."<center><font size=-2>ïÂÎÏ×ÌÅÎÉÅ: ".&Include_virtual("../dimrub/db/date")."</center></font>"; |
print <<EEE |
print <<EEE |
<SCRIPT LANGUAGE="JavaScript"> |
<SCRIPT LANGUAGE="JavaScript"> |
function toggle(e) { |
function toggle(e) { |