############################################################################### # Search.pl # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Community Software for Webmasters # # Software Version: YaBB 1 Gold - SP1 # # Released: December 2001 # # =========================================================================== # # Software Distributed by: http://yabb.xnull.com # # Support, News, Updates at: http://yabb.xnull.com/community/ # # =========================================================================== # # Copyright (c) 2000-2002 Xnull (www.xnull.com) - All Rights Reserved. # # Software by: The YaBB Development Team # # with assistance from the YaBB community. # ############################################################################### $searchplver = "1 Gold - SP1"; sub plushSearch1 { my( @categories, %cat, $curcat, %catname, %cataccess, %catboards, $openmemgr, @membergroups, $tmpa, %openmemgr, $curboard, @threads, @boardinfo, $counter ); @categories = (); fopen(FILE, "$vardir/cat.txt"); @categories = ; fclose(FILE); &LoadCensorList; # Load Censor List $searchpageurl = $curposlinks ? qq~$txt{'182'}~ : $txt{'182'}; $yymain .= qq~
  $mbname
  $searchpageurl
$txt{'183'}
$txt{'582'}:  
$txt{'583'}:  
$txt{'189'}: ~; $counter = 1; foreach $curcat (@categories) { chomp $curcat; fopen(FILE, "$boardsdir/$curcat.cat"); $catname{$curcat} = ; chomp $catname{$curcat}; $cataccess{$curcat} = ; chomp $cataccess{$curcat}; @{$catboards{$curcat}} = ; fclose(FILE); $openmemgr{$curcat} = 0; @membergroups = split( /,/, $cataccess{$curcat} ); foreach $tmpa (@membergroups) { if( $tmpa eq $settings[7]) { $openmemgr{$curcat} = 1; last; } } if( ! $cataccess{$curcat} || $settings[7] eq 'Administrator' ) { $openmemgr{$curcat} = 1; } unless( $openmemgr{$curcat} ) { next; } boardcheck: foreach $curboard (@{$catboards{$curcat}}) { chomp $curboard; fopen(FILE, "$boardsdir/$curboard.dat"); @boardinfo = ; fclose(FILE); chomp @boardinfo; @{$boardinfo{$curboard}} = @boardinfo; $cat{$curboard} = $curcat; $yymain .= qq~~; unless( $counter % 2 ) { $yymain .= qq~~; } ++$counter; } } $yymain .= qq~
$boardinfo[0]

$txt{'737'}
$txt{'573'}:
$txt{'70'} $txt{'72'}
$txt{'575'} $txt{'574'}: $txt{'578'} + $txt{'579'}
$txt{'576'} $txt{'574'}: $txt{'578'} + $txt{'579'}
$txt{'191'}


~; $yytitle = $txt{'183'}; &template; exit; } sub plushSearch2 { my $minripe = $FORM{'minripe'} || 0; my $minage = $FORM{'minage'} || 0; my $maxripe = $FORM{'maxripe'} || 0; my $maxage = $FORM{'maxage'} || 7; my $display = $FORM{'numberreturned'} || 25; if( $minripe =~ /\D/ ) { &fatal_error($txt{'337'}); } if( $minage =~ /\D/ ) { &fatal_error($txt{'337'}); } if( $maxripe =~ /\D/ ) { &fatal_error($txt{'337'}); } if( $maxage =~ /\D/ ) { &fatal_error($txt{'337'}); } if( $display =~ /\D/ ) { &fatal_error($txt{'337'}); } my $userkind = $FORM{'userkind'}; my $userspec = $FORM{'userspec'}; if( $userkind eq 'starter' ) { $userkind = 1; } elsif( $userkind eq 'poster' ) { $userkind = 2; } elsif( $userkind eq 'noguests' ) { $userkind = 3; } elsif( $userkind eq 'onlyguests' ) { $userkind = 4; } else { $userkind = 0; $userspec = ''; } if ($userspec =~ m~/~){ &fatal_error($txt{'224'}); } if ($userspec =~ m~\\~){ &fatal_error($txt{'225'}); } $userspec =~ s/\A\s+//; $userspec =~ s/\s+\Z//; $userspec =~ s/[^0-9A-Za-z#%+,-\.@^_]//g; my $searchtype = $FORM{'searchtype'}; my $search = $FORM{'search'}; if( $searchtype eq 'anywords' ) { $searchtype = 2; } elsif( $searchtype eq 'asphrase' ) { $searchtype = 3; } else { $searchtype = 1; } if ($search eq ""){ &fatal_error($txt{'754'}); } if ($search =~ m~/~){ &fatal_error($txt{'397'}); } if ($search =~ m~\\~){ &fatal_error($txt{'397'}); } if ($search =~ /\AIs UBB Good\?\Z/i) { &fatal_error("Many llamas have pondered this question for ages. They each came up with logical answers to this question, each being quite different. The consensus of their answers: UBB is a decent piece of software made by a large company. They, however, lack a strong supporting community, charge a lot for their software and the employees are very biased towards their own products. And so, once again, let it be written into the books that
\"\"
YaBB is the greatest community software there ever was!
"); } my $searchsubject = $FORM{'subfield'} eq 'on'; my $searchmessage = $FORM{'msgfield'} eq 'on'; $search =~ s/\A\s+//; $search =~ s/\s+\Z//; &ToHTML($search); $search =~ s/\t/ \  \  \ /g; $search =~ s/\cM//g; $search =~ s/\n/
/g; if( $searchtype != 3 ) { @search = split( /\s+/, $search ); } else { @search = ( $search ); } my( $curboard, @threads, $curthread, $tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate, $ttime, @messages, $curpost, $mtime, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mns, $subfound, $msgfound, $numfound, %data, $i, $board, $curcat, @categories, %catname, %cataccess, %openmemgr, @membergroups, %cats, @boardinfo, %boardinfo, @boards, $counter, $msgnum ); my $curtime = time + (3600*$settings[17]); my $mintime = $curtime - (($minage*86400)+($minripe*3600) - 1); my $maxtime = $curtime - (($maxage*86400)+($maxripe*3600) + 1); my $oldestfound = stringtotime("01/10/37 $txt{'107'} 00:00:00"); fopen(FILE, "$vardir/cat.txt"); @categories = ; fclose(FILE); foreach $curcat (@categories) { chomp $curcat; fopen(FILE, "$boardsdir/$curcat.cat"); $catname{$curcat} = ; chomp $catname{$curcat}; $cataccess{$curcat} = ; chomp $cataccess{$curcat}; @{$catboards{$curcat}} = ; fclose(FILE); $openmemgr{$curcat} = 0; @membergroups = split( /,/, $cataccess{$curcat} ); foreach $tmpa (@membergroups) { if( $tmpa eq $settings[7]) { $openmemgr{$curcat} = 1; last; } } if( ! $cataccess{$curcat} || $settings[7] eq 'Administrator' ) { $openmemgr{$curcat} = 1; } unless( $openmemgr{$curcat} ) { next; } foreach $curboard (@{$catboards{$curcat}}) { chomp $curboard; fopen(FILE, "$boardsdir/$curboard.dat"); @boardinfo = ; fclose(FILE); chomp @boardinfo; @{$boardinfo{$curboard}} = @boardinfo; $cat{$curboard} = $curcat; } } $counter = 1; while( $_ = each(%FORM) ) { unless( $_ =~ m~\Abrd(\d+)\Z~ ) { next; } $_ = $FORM{$_}; if ($_ =~ m~/~){ &fatal_error($txt{'397'}); } if ($_ =~ m~\\~){ &fatal_error($txt{'397'}); } if( $cat{$_} ) { push( @boards, $_ ); } ++$counter; } boardcheck: foreach $curboard (@boards) { fopen(FILE, "$boardsdir/$curboard.txt") || next; @threads = ; fclose(FILE); #$yymain .= qq~
    Beginning search in board $curboard
      ~; threadcheck: foreach $curthread (@threads) { chomp $curthread; #$yymain .= qq~
    Beginning search in topic $curthread.
      ~; ($tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate) = split( /\|/, $curthread ); if( $userkind == 1 ) { if( $tusername eq 'Guest' ) { if( $tname !~ m~\A\Q$userspec\E\Z~i ) { next threadcheck; } } else { if( $tusername !~ m~\A\Q$userspec\E\Z~i ) { next threadcheck; } } } $ttime = stringtotime($tdate); unless( $ttime < $mintime ) { next threadcheck; } unless( $ttime > $maxtime ) { next threadcheck; } fopen(FILE, "$datadir/$tnum.txt") || next; @messages = ; fclose(FILE); postcheck: for( $msgnum = 0; $msgnum < @messages; $msgnum++ ) { $curpost = $messages[$msgnum]; chomp $curpost; #$yymain .= qq~Beginning search in post $curpost.
      ~; ($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns) = split(/\|/,$curpost); $mtime = stringtotime($mdate); unless( $mtime < $mintime ) { next postcheck; } if( $numfound >= $display && $mtime <= $oldestfound ) { next postcheck; } if( $musername eq 'Guest' ) { if( $userkind == 3 || ( $userkind == 2 && $mname !~ m~\A\Q$userspec\E\Z~i ) ) { next postcheck; } } else { if( $userkind == 4 || ( $userkind == 2 && $musername !~ m~\A\Q$userspec\E\Z~i ) ) { next postcheck; } } #$yymain .= qq~
        Performing search in post $curpost.
      ~; if( $searchsubject ) { if( $searchtype == 2 ) { $subfound = 0; foreach( @search ) { if( $msub =~ m~\Q$_\E~i ) { $subfound = 1; last; } } } else { $subfound = 1; foreach( @search ) { if( $msub !~ m~\Q$_\E~i ) { $subfound = 0; last; } } } } if( $searchmessage && ! $subfound ) { if( $searchtype == 2 ) { $msgfound = 0; foreach( @search ) { if( $message =~ m~\Q$_\E~i ) { $msgfound = 1; last; } } } else { $msgfound = 1; foreach( @search ) { if( $message !~ m~\Q$_\E~i ) { $msgfound = 0; last; } } } } unless( $msgfound || $subfound ) { next postcheck; } if( $subfound ) { foreach( @search ) { $msub =~ s~(\Q$_\E)~$_~ig; } } $data{$mtime} = [$curboard, $tnum, $msgnum, $tusername, $tname, $msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns, $tstate]; if( $mtime < $oldestfound ) { $oldestfound = $mtime; } ++$numfound; } } } @messages = sort {$b <=> $a } keys %data; if( @messages ) { if( @messages > $display ) { $#messages = $display - 1; } $counter = 1; &LoadCensorList; # Load Censor List } else { $yymain .= qq~
      $txt{'170'}
      ~; } for( $i = 0; $i < @messages; $i++ ) { ($board, $tnum, $msgnum, $tusername, $tname, $msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns, $tstate) = @{ $data{$messages[$i]} }; $mdate = &timeformat($mdate); if( $tusername ne 'Guest' ) { if( &LoadUser($tusername) ) { $tname = "$userprofile{$tusername}->[1]"; } } if( $musername ne 'Guest' ) { if( &LoadUser($musername) ) { $mname = "$userprofile{$musername}->[1]"; } } foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $message =~ s~\Q$tmpa\E~$tmpb~gi; $msub =~ s~\Q$tmpa\E~$tmpb~gi; } $sender = "search"; # for efficiency we let bolding be done in the wrap function &wrap; if($enable_ubbc) { $ns = $mns; if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; if($enable_notification) { $notify = qq~$menusep$img{'notify'}~; } $yymain .= qq~
       $counter   $catname{$cat{$board}} / $boardinfo{$board}->[0] / $msub  $txt{'30'}: $mdate 
      $txt{'109'} $tname | $txt{'105'} $txt{'525'} $mname
      $message
        ~; if ($tstate != 1) { $yymain .= qq~$img{'reply'}$menusep$img{'replyquote'}$notify~; } $yymain .= qq~

      ~; ++$counter; } $yymain .= qq~ $txt{'167'}
      $txt{'236'} $txt{'237'}
      ~; $yytitle = $txt{'166'}; &template; exit; } 1;