############################################################################### # Search.pl # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Project started by Zef Hemel (zef@zefnet.com) # # Software Version: YaBB 1 Gold - Release # # =========================================================================== # # Software Distributed by: http://yabb.xnull.com # # Support, News, Updates at: http://yabb.xnull.com/community/ # # =========================================================================== # # Copyright (c) 2000-2001 X-Null - All Rights Reserved # # Software by: The YaBB Development Team # ############################################################################### $searchplver="1 Gold - Release"; 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); # Load Censor List &LoadCensorList; $yytitle = $txt{'183'}; &header; $searchpageurl = $curposlinks ? qq~$txt{'182'}~ : $txt{'182'}; print <<"EOT";
  $mbname
  $searchpageurl
$txt{'183'}
$txt{'582'}:
 
$txt{'583'}:
 
$txt{'189'}:
EOT $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; print qq~~; unless( $counter % 2 ) { print q~~; } ++$counter; } } print <<"EOT";
$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'}
EOT &footer; 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 =~ 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 egons. They each came up with answers to this question, each being quite different. The agreement: UBB is a good 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 BBS system there ever was!
"); } my $searchsubject = $FORM{'subfield'} eq 'on'; my $searchmessage = $FORM{'msgfield'} eq 'on'; $search =~ s/\A\s+//; $search =~ s/\s+\Z//; $search =~ s/\&/\&/g; $search =~ s/"/\"/g; $search =~ s/ / \ /g; $search =~ s//>/g; $search =~ s/\t/ \  \  \ /g; $search =~ s/\cM//g; $search =~ s~(\S{80})(?=\S)~$1\n~g; $search =~ s/\n/
/g; $search =~ s/\|/\|/g; my @search; 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*$timeoffset); 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"); $yytitle = $txt{'166'}; &header; 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); #print qq~
    Beginning search in board $curboard
      ~; threadcheck: foreach $curthread (@threads) { chomp $curthread; #print qq~
    Beginning search in thread $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 boardcheck; } fopen(FILE, "$datadir/$tnum.txt") || next; @messages = ; fclose(FILE); postcheck: for( $msgnum = 0; $msgnum < @messages; $msgnum++ ) { #print qq~Beginning search in post $curpost.
      ~; $curpost = $messages[$msgnum]; chomp $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; } } #print 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; } } if( $msgfound ) { foreach( @search ) { $message =~ s~(\Q$_\E)~$_~ig; } } $data{$mtime} = [$curboard, $tnum, $msgnum, $tusername, $tname, $msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns]; if( $mtime < $oldestfound ) { $oldestfound = $mtime; } ++$numfound; } } } @messages = sort {$b <=> $a } keys %data; if( @messages ) { if( @messages > $display ) { $#messages = $display - 1; } $counter = 1; # Load Censor List &LoadCensorList; } else { print qq~
      $txt{'170'}
      ~; } for( $i = 0; $i < @messages; $i++ ) { ($board, $tnum, $msgnum, $tusername, $tname, $msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns) = @{ $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; } if($enable_ubbc) { $ns = $mns; &DoUBBC; } if($enable_notification) { $notify = qq~$menusep$img{'notify'}~; } print <<"EOT";
       $counter   $catname{$cat{$board}} / $boardinfo{$board}->[0] / $msub  $txt{'30'}: $mdate 
      $txt{'109'} $tname | $txt{'105'} $txt{'525'} $mname
      $message
       $img{'reply'}$menusep$img{'replyquote'}$notify

      EOT ++$counter; } print <<"EOT"; $txt{'167'}
      $txt{'236'} $txt{'237'}
      EOT &footer; exit; }