--- db/prgsrc/db.cgi 2001/11/21 02:02:09 1.35 +++ db/prgsrc/db.cgi 2001/11/25 23:40:27 1.36 @@ -7,9 +7,10 @@ use strict; use Time::Local; use POSIX qw(locale_h); use locale; -#open STDERR, ">errors"; -my $printqueries=0; -my $debug=0; #added by R7 +open STDERR, ">errors"; +my $printqueries=1; +my %forbidden=(); +my $debug=1; #added by R7 my %fieldname= (0,'Question', 1, 'Answer', 2, 'Comments', 3, 'Authors', 4, 'Sources'); my %searchin; @@ -192,25 +193,6 @@ print "$query",br if $printqueries; $_= " word2question.word=".$_. ' ' foreach @arr; $_= " nf.id=".$_. ' ' foreach @arr1; -# $_= " nests.w2=".$_. ' ' foreach @arr2; -# $query="select w1 from nests where". (join ' OR ', @arr2); -#print $query if $printqueries; -# $sth=$dbh -> prepare($query); -# $sth->execute; -# while (@ar=$sth->fetchrow) -# { -# $ar[0]=~s/(.)/&nocase($1)/ge; -# push(@sf,'(?:'.$ar[0].')'); -# } -# $selectshablon=join '|',@sf; - -#print $selectshablon,br if $printqueries; - -# $selectshablon=qr/$selectshablon/i; - - - - $query="select questions from word2question where". (join ' OR ', @arr); print "$query\n",br if $printqueries; @@ -405,9 +387,12 @@ sub Search { } else { $sstr = join " OR $f LIKE ", @sar; } - -my $query="SELECT QuestionId FROM Questions + + my $query; + $query="SELECT QuestionId FROM Questions WHERE $f LIKE $sstr ORDER BY QuestionId"; + + print $query if $printqueries; $sth = $dbh->prepare($query) @@ -415,7 +400,7 @@ print $query if $printqueries; $sth->execute; while (@arr = $sth->fetchrow) { - push @Questions, $arr[0]; + push @Questions, $arr[0] unless $forbidden{$arr[0]}; } return @Questions; @@ -768,15 +753,18 @@ sub PrintQuestion { { my ($firstletter)=$Name=~m/^./g; # $other.=a({href=>url."?qofauthor=$AuthorId"},"$Name $Surname").". "; + $Name=~s/\./\\\./g; my $sha="(?:$Name\\s+$Surname)|(?:$Surname\\s+$Name)|(?:$firstletter\\.\\s*$Surname)|(?:$Surname\\s+$firstletter\\.)|(?:$Surname)|(?:$Name)"; $Nicks=~s/^\|//; foreach (split /\|/, $Nicks) { - s/ /\\s+/; + s/\s+/ /g; + s/\s+$//; + s/ /\\s+/g; + s/\./\\\./g; if (s/>$//) {$sha="$sha|(?:$_)"} else {$sha="(?:$_)|$sha"} } -#$output.=br."sha=$sha".br; $q=~s/($sha)/a({href=>url."?qofauthor=$AuthorId"},$1)/ei; } @@ -934,7 +922,7 @@ sub PrintQOfAuthor my $q; my @Questions; while (($q)=$sth->fetchrow,$q) - {push @Questions,$q;} + {push @Questions,$q unless $forbidden{$q}} my ($output, $i, $suffix, $hits) = ('', 0, '', $#Questions + 1); @@ -1026,6 +1014,7 @@ MAIN: setlocale(LC_CTYPE,'russian'); my($i, $tour); my($text) = (param('text')) ? 1 : 0; + my($dbh) = DBI->connect("DBI:mysql:chgk", "piataev", "") or do { print h1("Временные проблемы") . "База данных временно не @@ -1057,6 +1046,17 @@ if ((uc 'а') ne 'А') {print "Koi8-r loca print header('text/plain'); } + if (param('showequal')) { + my ($sth)= $dbh -> prepare("select first, second FROM equalto"); + $sth -> execute; + while ( my ($first, $second)=$sth -> fetchrow) + { + $forbidden{$first}=1; + } + $sth->finish; + } + + if (param('rand')) { my ($type, $qnum) = ('', 12); $type .= 'Б' if (param('brain'));