############################################################################### # SearchNew.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 # ############################################################################### # SearchNew.pl hacks by Forge[FU] (forge@forgeunited.com) # ############################################################################### $searchplver="1 Gold - SP1"; sub NewSearch { 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'}; $searchpageurl = $curposlinks ? qq~$txt{'182'}~ : $txt{'182'}; $yymain .= qq~
  $mbname
  $searchpageurl
$txt{'582'} $txt{'302'}
~; # We can only do this search for valid users if ($username ne 'Guest') { $yymain .=qq~ $searchnew{'01'}

$searchnew{'02'} ~; } else { $yymain .=qq~ $searchnew{'02'} ~; } $yymain .= qq~
  $txt{'575'}: $txt{'578'} + $txt{'579'}.
  $txt{'576'}: $txt{'578'} + $txt{'579'}.


$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} ); fopen(MEM, "$memberdir/$username.kri"); @kms = ; fclose(MEM); chomp @kms; foreach $tmpa (@membergroups) { if($tmpa eq $settings[7] || $tmpa eq $kms[0] || $tmpa eq $kms[1] || $tmpa eq $kms[2] || $tmpa eq $kms[3] || $tmpa eq $kms[4]) { $openmemgr{$curcat} = 1; last; } } if( ! $cataccess{$curcat} || $settings[7] eq 'Administrator' || $settings[7] eq 'Global Moderator' ) { $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 .= q~~; } ++$counter; } } $yymain .= qq~
$boardinfo[0]

$txt{'737'}

~; &template; exit; } ################################################################################## sub NewSearchResults { ### ### Get and Validate Form Values ### my $searchmethod = $FORM{'method'} || "bytime"; my $minhours = $FORM{'minagehours'} || 0; my $mindays = $FORM{'minagedays'} || 0; my $maxhours = $FORM{'maxagehours'} || 0; my $maxdays = $FORM{'maxagedays'} || 0; if( $minhours =~ /\D/ ) { &fatal_error($txt{'337'}); } if( $mindays =~ /\D/ ) { &fatal_error($txt{'337'}); } if( $maxhours =~ /\D/ ) { &fatal_error($txt{'337'}); } if( $maxdays =~ /\D/ ) { &fatal_error($txt{'337'}); } 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, $dlp); my($tispoll); my($counta, $countb, $countc, $threaddate); $countc=0; # my $curtime = time + (3600*$timeoffset); my $curtime = time + (3600*$settings[18]); my $minage = $curtime - (($mindays*86400)+($minhours*3600) - 1); my $maxage = $curtime - (($maxdays*86400)+($maxhours*3600) + 1); my $oldestfound = stringtotime("01/10/37 $txt{'107'} 00:00:00"); $yytitle = $txt{'166'}; $yymain .=qq~
$yytitle
~; ############################################################ # Figure out which categories this user can/wants to access ############################################################ 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} ); fopen(MEM, "$memberdir/$username.kri"); @kms = ; fclose(MEM); chomp @kms; foreach $tmpa (@membergroups) { if($tmpa eq $settings[7] || $tmpa eq $kms[0] || $tmpa eq $kms[1] || $tmpa eq $kms[2] || $tmpa eq $kms[3] || $tmpa eq $kms[4]) { $openmemgr{$curcat} = 1; last; } } if( ! $cataccess{$curcat} || $settings[7] eq 'Administrator' || $settings[7] eq 'Global Moderator' ) { $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; } } # Which boards did user want to search? $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; } ###################################################################### # Loop through boards, threads and posts looking for new messages ###################################################################### boardcheck: foreach $curboard (@boards) { fopen(FILE, "$boardsdir/$curboard.txt") || next; @threads = ; fclose(FILE); #$yymain .= qq~
    Beginning search in board $curboard
      ~; $counta=0; threadcheck: foreach $curthread (@threads) { $countb=0; chomp $curthread; #$yymain .= qq~
    Beginning search in thread $curthread.
      ~; ($tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate, $tispoll) = split( /\|/, $curthread ); $threaddate = stringtotime($tdate); ################################################################### # Check Date/Time at thread level (avoids unnecessary searching). ################################################################### if ($searchmethod eq 'byacct') { # Figure out if the user read this thread. $dlp = &getlog($tnum); if( $dlp == $threaddate || &getlog("$curboard--mark") > $threaddate ) {next threadcheck; } } else { if( $threaddate > $minage ) { next threadcheck; } if( $threaddate < $maxage ) { next boardcheck; } } # At this point, we know this thread has a new message if($counta == 0){ $yymain .=qq~   $boardinfo{$curboard}->[0]
      ~; } ++$counta; if($countb == 0){ $yymain .=qq~ $tsub
      ~; } ++$countb; fopen(FILE, "$datadir/$tnum.txt") || next; @messages = ; fclose(FILE); ############################################# # Check all posts in thread for new messages. ############################################# postcheck: for( $msgnum = 0; $msgnum < @messages; $msgnum++ ) { #$yymain .= qq~Beginning search in post $curpost.
      ~; $curpost = $messages[$msgnum]; chomp $curpost; ($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns) = split(/\|/,$curpost); $threaddate = stringtotime($mdate); if ($searchmethod eq 'byacct') { # Figure out if the user read this post. if( $dlp >= $threaddate || &getlog("$curboard--mark") > $threaddate ) { next postcheck; } } else { if( $threaddate > $minage ) { next postcheck; } if( $threaddate < $maxage ) { next postcheck; } } # Remove line breaks and crop to first 60 characters. # $message =~ s/
      //gi; # $message = substr($message, 0, 220); &DoSUBBC; $message = substr($message, 0, 60); $yymain .= qq~ $mname - $mdate - $message
      ~; ++$countc } } } $yymain .= qq~
$txt{'167'}:  $countc $txt{'174'}

$txt{'236'} $txt{'237'}
$img{'markallread'}
~; &template; exit; } sub DoSUBBC { $message =~ s~\[code\]~ \[code\]~ig; $message =~ s~\[/code\]~ \[/code\]~ig; $message =~ s~\[quote\]~ \[quote\]~ig; $message =~ s~\[/quote\]~ \[/quote\]~ig; $message =~ s~\[glow\]~ \[glow\]~ig; $message =~ s~\[/glow\]~ \[/glow\]~ig; $message =~ s~
~ -> ~ig; $message =~ s~\[code\]\n*(.+?)\n*\[/code\]~ (CODE) ~eisg; $message =~ s~\[([^\]]{0,30})\n([^\]]{0,30})\]~\[$1$2\]~g; $message =~ s~\[/([^\]]{0,30})\n([^\]]{0,30})\]~\[/$1$2\]~g; $message =~ s~(\w+://[^<>\s\n\"\]\[]+)\n([^<>\s\n\"\]\[]+)~$1\n$2~g; $message =~ s~\[b\](.+?)\[/b\]~$1~isg; $message =~ s~\[i\](.+?)\[/i\]~$1~isg; $message =~ s~\[u\](.+?)\[/u\]~$1~isg; $message =~ s~\[s\](.+?)\[/s\]~$1~isg; $message =~ s~\[move\](.+?)\[/move\]~ $1~isg; $message =~ s~\[glow(.*?)\](.*?)\[/glow\]~ $2~eisg; $message =~ s~\[shadow(.*?)\](.*?)\[/shadow\]~ $2~eisg; $message =~ s~\/me\s(\S*)~ AUTHOR SAID: $1~g; $message =~ s~\[color=([\w#]+)\](.*?)\[/color\]~$2~isg; $message =~ s~\[black\](.*?)\[/black\]~$1~isg; $message =~ s~\[white\](.*?)\[/white\]~$1~isg; $message =~ s~\[red\](.*?)\[/red\]~$1~isg; $message =~ s~\[green\](.*?)\[/green\]~$1~isg; $message =~ s~\[blue\](.*?)\[/blue\]~$1~isg; $message =~ s~\[font=(.+?)\](.+?)\[/font\]~$2~isg; $message =~ s~\[size=(.+?)\](.+?)\[/size\]~$2~isg; $char_160 = chr(160); $message =~ s~\[img\][\s*\t*\n*( )*($char_160)*]*(http\:\/\/)*(.+?)[\s*\t*\n*( )*($char_160)*]*\[/img\]~IMAGE ~isg; $message =~ s~\[img width=(\d+) height=(\d+)\][\s*\t*\n*( )*($char_160)*]*(http\:\/\/)*(.+?)[\s*\t*\n*( )*($char_160)*]*\[/img\]~IMAGE ~eisg; $message =~ s~\[tt\](.*?)\[/tt\]~$1~isg; $message =~ s~\[left\](.+?)\[/left\]~$1~isg; $message =~ s~\[center\](.+?)\[/center\]~$1~isg; $message =~ s~\[right\](.+?)\[/right\]~$1~isg; $message =~ s~\[sub\](.+?)\[/sub\]~$1~isg; $message =~ s~\[sup\](.+?)\[/sup\]~$1~isg; $message =~ s~\[fixed\](.+?)\[/fixed\]~$1~isg; $message =~ s~\[hr\]\n~ - ~g; $message =~ s~\[hr\]~ - ~g; $message =~ s~\[br\]~ -> ~ig; $message =~ s~\[rquote\]~ (QUOTE) ~ig; if( $autolinkurls ) { $message =~ s~([^\w\"\=\[\]]|[\n\b]|\A)\\*(\w+://[\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%]+\.[\w\~\;\:\$\-\+\!\*\?/\=\&\@\#\%]+[\w\~\;\:\$\-\+\!\*\?/\=\&\@\#\%])~(URL)~isg; $message =~ s~([^\"\=\[\]/\:\.(\://\w+)]|[\n\b]|\A)\\*(www\.[^\.][\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%]+\.[\w\~\;\:\$\-\+\!\*\?/\=\&\@\#\%]+[\w\~\;\:\$\-\+\!\*\?/\=\&\@\#\%])~(URL)~isg; } $message =~ s~\[url\]www\.\s*(.+?)\s*\[/url\]~ (URL) ~isg; $message =~ s~\[url=\s*(\w+\://.+?)\](.+?)\s*\[/url\]~ (URL) ~isg; $message =~ s~\[url=\s*(.+?)\]\s*(.+?)\s*\[/url\]~ (URL) ~isg; $message =~ s~\[url\]\s*(.+?)\s*\[/url\]~ (URL) ~isg; $message =~ s~\[link\]www\.\s*(.+?)\s*\[/link\]~ (URL) ~isg; $message =~ s~\[link=\s*(\w+\://.+?)\](.+?)\s*\[/link\]~ (URL) ~isg; $message =~ s~\[link=\s*(.+?)\]\s*(.+?)\s*\[/link\]~ (URL) ~isg; $message =~ s~\[link\]\s*(.+?)\s*\[/link\]~ (URL) ~isg; $message =~ s~\[email\]\s*(\S+?\@\S+?)\s*\[/email\]~ (MailTo) ~isg; $message =~ s~\[email=\s*(\S+?\@\S+?)\]\s*(.*?)\s*\[/email\]~ (MailTo) ~isg; $message =~ s~\[news\](.+?)\[/news\]~ (NEWSURL) ~isg; $message =~ s~\[gopher\](.+?)\[/gopher\]~ (GOPHURL) ~isg; $message =~ s~\[ftp\](.+?)\[/ftp\]~ (FTPURL) ~isg; $message =~ s~\[quote\s+author=(.*?)link=(.*?)\s+date=(.*?)\s*\]\n*(.*?)\n*\[/quote\]~ (QUOTE) ~isg; $message =~ s~\[quote\]\n*(.+?)\n*\[/quote\]~ (QUOTE) ~isg; $message =~ s~\[list\]~List ~isg; $message =~ s~\[\*\]~ListItem ~isg; $message =~ s~\[/list\]~ListEnd ~isg; $message =~ s~\[pre\](.+?)\[/pre\]~$1~iseg; $message =~ s~\[flash\=(.+?)\[/flash\]~ (Flash File) ~isg; $message =~ s~\[table\](.+?)\[/table\]~ (Table) ~isg; while( $message =~ s~]*?)\n([^>]*)>~ (URL) ~ ) {} while( $message =~ s~]*)>([^<]*?)\n([^<]*)~ (URL) ~ ) {} while( $message =~ s~]*?)&([^>]*)>~ (URL) ~ ) {} while( $message =~ s~]*?)\n([^>]*)>~ (IMAGE) ~ ) {} while( $message =~ s~]*?)&([^>]*)>~ (IMAGE) ~ ) {} $message =~ s~\[\&table(.*?)\]~ (Table) ~g; $message =~ s~\[/\&table\]~ (Table) ~g; $message =~ s~\n~ ~ig; }