| ############################################################################### |
| ############################################################################### |
| # Search.pl # |
| # Search.pm # |
| |
| # $Date: 01.05.16 $ # |
| ############################################################################### |
| ############################################################################### |
| # YaBB: Yet another Bulletin Board # |
| # YaBB: Yet another Bulletin Board # |
| # Open-Source Community Software for Webmasters # |
| # Open-Source Community Software for Webmasters # |
| # Version: YaBB 2.5.2 # |
| # Version: YaBB 2.6.12 # |
| # Packaged: October 21, 2012 # |
| # Packaged: January 5, 2016 # |
| # Distributed by: http://www.yabbforum.com # |
| # Distributed by: http://www.yabbforum.com # |
| # =========================================================================== # |
| # =========================================================================== # |
| # Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved. # |
| # Copyright (c) 2000-2016 YaBB (www.yabbforum.com) - All Rights Reserved. # |
| # Software by: The YaBB Development Team # |
| # Software by: The YaBB Development Team # |
| # with assistance from the YaBB community. # |
| # with assistance from the YaBB community. # |
| ############################################################################### |
| ############################################################################### |
| |
| our $VERSION = '2.6.12'; |
| |
| |
| $searchplver = 'YaBB 2.5.2 $Revision: 1.0 $'; |
| $searchpmver = 'YaBB 2.6.12 $Revision: 1710 $'; |
| if ($action eq 'detailedversion') { return 1; } |
| if ( $action eq 'detailedversion' ) { return 1; } |
| |
| |
| &LoadLanguage('Search'); |
| LoadLanguage('Search'); |
| |
| get_micon(); |
| if($FORM{'searchboards'} =~ /\A\!/) { |
| get_template('Search'); |
| my($checklist, $catid, $curboard); |
| |
| $checklist = ''; |
| if ( $FORM{'searchboards'} =~ /\A\!/xsm ) { |
| unless ($mloaded == 1) { require "$boardsdir/forum.master"; } |
| my $checklist = q{}; |
| foreach $catid (@categoryorder) { |
| get_forum_master(); |
| my($boardlist, @bdlist, $curboard); |
| foreach my $catid (@categoryorder) { |
| # if ($catselect ne $catid && $catselect) { next; } |
| (@bdlist) = split /\,/xsm, $cat{$catid}; |
| $boardlist = $cat{$catid}; |
| my ( $catname, $catperms, $catallowcol ) = split /\|/xsm, |
| @bdlist = split(/\,/, $boardlist); |
| $catinfo{$catid}; |
| my ($catname, $catperms, $catallowcol) = split(/\|/, $catinfo{$catid}); |
| my $access = CatAccess($catperms); |
| my $access = &CatAccess($catperms); |
| if ( !$access ) { next; } |
| if (!$access) { next; } |
| |
| foreach $curboard (@bdlist) { |
| recursive_search(@bdlist); |
| chomp $curboard; |
| } |
| $cat_boardcnt{$catid}++; |
| |
| my ($boardname, $boardperms, $boardview) = split(/\|/, $board{$curboard}); |
| sub recursive_search { |
| my $access = &AccessCheck($curboard, '', $boardperms); |
| my @x = @_; |
| if (!$iamadmin && $access ne 'granted') { next; } |
| foreach my $curboard (@x) { |
| $checklist .= qq~$curboard, ~; |
| chomp $curboard; |
| } |
| |
| } |
| # don't add to count if it's a sub board |
| $checklist =~ s/, \Z//; |
| if ( !${ $uid . $curboard }{'parent'} ) { $cat_boardcnt{$catid}++; } |
| $FORM{'searchboards'} = $checklist; |
| my ( $boardname, $boardperms, $boardview ) = split /\|/xsm, |
| |
| $board{$curboard}; |
| |
| my $access = AccessCheck( $curboard, q{}, $boardperms ); |
| |
| if ( !$iamadmin && $access ne 'granted' ) { next; } |
| |
| $checklist .= qq~$curboard, ~; |
| |
| |
| |
| if ( $subboard{$curboard} ) { |
| |
| recursive_search( split /\|/xsm, $subboard{$curboard} ); |
| |
| } |
| |
| } |
| |
| return; |
| |
| } |
| |
| $checklist =~ s/, \Z//sm; |
| |
| $FORM{'searchboards'} = $checklist; |
| } |
| } |
| |
| |
| sub plushSearch1 { |
| sub plushSearch1 { |
| # generate error if admin has disabled search options |
| |
| if ($maxsearchdisplay < 0) { &fatal_error("search_disabled"); } |
| # generate error if admin has disabled search options |
| my (@categories, $curcat, %catname, %cataccess, %catboards, $openmemgr, @membergroups, $tmpa, %openmemgr, $curboard, @threads, @boardinfo, $counter); |
| if ( $maxsearchdisplay < 0 ) { fatal_error('search_disabled'); } |
| |
| if ( $advsearchaccess ne 'granted' ) { fatal_error('no_access'); } |
| &LoadCensorList; |
| my ( |
| if (!$iamguest) { |
| @categories, $curcat, %catname, %cataccess, @membergroups, |
| &Collapse_Load; |
| %openmemgr, $curboard, @threads, @boardinfo, $counter |
| } |
| ); |
| $yymain .= qq~ |
| |
| <script language="JavaScript1.2" src="$yyhtml_root/ubbc.js" type="text/javascript"></script> |
| LoadCensorList(); |
| <script language="JavaScript1.2" type="text/javascript"> |
| if ( !$iamguest ) { |
| <!-- |
| Collapse_Load(); |
| |
| } |
| |
| $yymain .= qq~ |
| |
| <script type="text/javascript"> |
| function removeUser() { |
| function removeUser() { |
| if (document.getElementById('userspec').value && confirm("$searchselector_txt{'removeconfirm'}")) { |
| if (document.getElementById('userspec').value && confirm("$searchselector_txt{'removeconfirm'}")) { |
| document.getElementById('userspec').value = ""; |
| document.getElementById('userspec').value = ""; |
| document.getElementById('userspectext').value = ""; |
| document.getElementById('userspectext').value = ""; |
| if(document.getElementById('searchme').checked) { |
| if(document.getElementById('searchme').checked) { |
| document.getElementById('searchme').checked = false; |
| document.getElementById('searchme').checked = false; |
| document.getElementById('userkind').disabled=false; |
| document.getElementById('userkind').disabled=false; |
| document.getElementById('noguests').selected=true; |
| document.getElementById('noguests').selected=true; |
| } |
| } |
| document.getElementById('usrsel').style.display = 'inline'; |
| document.getElementById('usrsel').style.display = 'inline'; |
| document.getElementById('usrrem').style.display = 'none'; |
| document.getElementById('usrrem').style.display = 'none'; |
| document.getElementById('searchme').disabled = false; |
| document.getElementById('searchme').disabled = false; |
| } |
| } |
| } |
| } |
| |
| |
| function addUser() { |
| function addUser() { |
| window.open('$scripturl?action=imlist;sort=username;toid=userspec','','status=no,height=360,width=464,menubar=no,toolbar=no,top=50,left=50,scrollbars=no'); |
| window.open('$scripturl?action=imlist;sort=username;toid=userspec','','status=no,height=360,width=464,menubar=no,toolbar=no,top=50,left=50,scrollbars=no'); |
| } |
| } |
| |
| |
| function searchMe(chelem) { |
| function searchMe(chelem) { |
| if(chelem.checked) { |
| if(chelem.checked) { |
| document.getElementById('userspectext').value='${$uid.$username}{'realname'}'; |
| document.getElementById('userspectext').value='${$uid.$username}{'realname'}'; |
| document.getElementById('userspec').value='$username'; |
| document.getElementById('userspec').value='$username'; |
| document.getElementById('userkind').value='poster'; |
| document.getElementById('userkind').value='poster'; |
| document.getElementById('poster').selected=true; |
| document.getElementById('poster').selected=true; |
| document.getElementById('userkind').disabled=true; |
| document.getElementById('userkind').disabled=true; |
| } else { |
| } else { |
| document.getElementById('userspectext').value=''; |
| document.getElementById('userspectext').value=''; |
| document.getElementById('userspec').value=''; |
| document.getElementById('userspec').value=''; |
| document.getElementById('userkind').value='noguests'; |
| document.getElementById('userkind').value='noguests'; |
| document.getElementById('noguests').selected=true; |
| document.getElementById('noguests').selected=true; |
| document.getElementById('userkind').disabled=false; |
| document.getElementById('userkind').disabled=false; |
| } |
| } |
| } |
| } |
| //--> |
| |
| </script> |
| </script> |
| |
| |
| <form action="$scripturl?action=search2" method="post" name="searchform" onsubmit="return CheckSearchFields();"> |
| <form action="$scripturl?action=search2" method="post" name="searchform" onsubmit="return CheckSearchFields();" accept-charset="$yymycharset">~; |
| <table width="100%" align="center" border="0" cellpadding="4" cellspacing="1" class="bordercolor" > |
| $yymain .= $mysearch_template . ( |
| <colgroup> |
| $enable_ubbc |
| <col width="45%" /> |
| ? qq~<br /> |
| <col width="55%" /> |
| <input type="checkbox" name="searchyabbtags" id="searchyabbtags" value="1" /><label for="searchyabbtags">$search_txt{'searchyabbtags'}</label>~ |
| </colgroup> |
| : q{} |
| <tr> |
| ); |
| <td align="left" colspan="2" class="catbg"> |
| |
| <img src="$imagesdir/search.gif" alt="" /> <span class="text1"><b>$search_txt{'183'}</b></span> |
| if ( !$ML_Allowed |
| </td> |
| || ( $ML_Allowed == 1 && !$iamguest ) |
| </tr> |
| || ( $ML_Allowed == 2 && $staff ) |
| <tr> |
| || ( $ML_Allowed == 3 && ( $iamadmin || $iamgmod ) ) |
| <td class="windowbg" align="right" valign="top"><label for="search"><b>$search_txt{'582'}:</b></label></td> |
| || ( $ML_Allowed == 4 && ( $iamadmin || $iamgmod || $iamfmod ) ) ) |
| <td class="windowbg2"> |
| { |
| <div style="padding: 2px;"> |
| $yymain .= $mysearch_template2; |
| <input type="text" size="30" name="search" id="search" /> <label for="searchtype">$search_txt{'582'}</label> |
| if ( !$iamguest ) { |
| <select name="searchtype" id="searchtype"> |
| $yymain .= |
| <option value="allwords" selected="selected">$search_txt{'343'}</option> |
| qq~<input type="checkbox" name="searchme" id="searchme" style="margin: 0px; border: 0px; padding: 0px; vertical-align: middle;" onclick="searchMe(this);" /> <label for="searchme" class="lille">$search_txt{'searchme'}</label><br />~; |
| <option value="anywords">$search_txt{'344'}</option> |
| } |
| <option value="asphrase">$search_txt{'345'}</option> |
| else { |
| <option value="aspartial">$search_txt{'345a'}</option> |
| $yymain .= |
| </select><br /> |
| q~<input type="checkbox" name="searchme" id="searchme" style="visibility: hidden;" /><br />~; |
| <input type="checkbox" name="casesensitiv" id="casesensitiv" value="1" /><label for="casesensitiv">$search_txt{'casesensitiv'}</label>~ . ($enable_ubbc ? qq~<br /> |
| } |
| <input type="checkbox" name="searchyabbtags" id="searchyabbtags" value="1" /><label for="searchyabbtags">$search_txt{'searchyabbtags'}</label>~ : '') . qq~ |
| $yymain .= $mysearch_template3; |
| </div>~; |
| } |
| |
| else { |
| if (!$ML_Allowed || ($ML_Allowed == 1 && !$iamguest) || ($ML_Allowed == 2 && $staff) || ($ML_Allowed == 3 && ($iamadmin || $iamgmod))) { |
| $yymain .= q~<input type="hidden" name="userkind" value="any" />~; |
| $yymain .= qq~ |
| } |
| </td> |
| |
| </tr> |
| $yymain .= $mysearch_template4; |
| <tr> |
| |
| <td class="windowbg" align="right" valign="top"> |
| $allselected = 0; |
| <b>$search_txt{'583'}:</b> |
| $isselected = 0; |
| </td> |
| $boardscheck = q{}; |
| <td class="windowbg2"> |
| get_forum_master(); |
| <div style="padding: 4px 0px 4px 0px;"> |
| |
| <input type="text" size="30" style="width: 220px; padding-left: 3px;" name="userspectext" id="userspectext" value="" readonly="readonly" /><input type="button" class="button" id="usrsel" style="border-left: 0px; display: inline;" value="$searchselector_txt{'select'}" onclick="javascript:addUser();" /><input type="button" class="button" id="usrrem" style="border-left: 0px; display: none;" value="$searchselector_txt{'remove'}" onclick="javascript:removeUser();" /> |
| foreach my $catid (@categoryorder) { |
| ~; |
| $boardlist = $cat{$catid}; |
| if(!$iamguest) { |
| (@bdlist) = split /\,/xsm, $boardlist; |
| $yymain .= qq~<input type="checkbox" name="searchme" id="searchme" style="margin: 0px; border: 0px; padding: 0px; vertical-align: middle;" onclick="searchMe(this);" /> <label for="searchme" class="lille">$search_txt{'searchme'}</label><br />~; |
| ( $catname, $catperms ) = split /\|/xsm, $catinfo{"$catid"}; |
| } else { |
| $cataccess = CatAccess($catperms); |
| $yymain .= qq~<input type="checkbox" name="searchme" id="searchme" style="visibility: hidden;" /><br />~; |
| if ( !$cataccess ) { next; } |
| } |
| |
| $yymain .= qq~ |
| foreach my $curboard (@bdlist) { |
| <input type="hidden" size="30" name="userspec" id="userspec" value="" /> |
| ( $boardname, $boardperms, $boardview ) = split /\|/xsm, |
| </div> |
| $board{"$curboard"}; |
| <div style="padding: 4px 0px 4px 0px;"> |
| ToChars($boardname); |
| <select name="userkind" id="userkind"> |
| my $access = AccessCheck( $curboard, q{}, $boardperms ); |
| <option value="any">$search_txt{'577'}</option> |
| if ( !$iamadmin && $access ne 'granted' ) { next; } |
| <option value="starter">$search_txt{'186'}</option> |
| |
| <option id="poster" value="poster">$search_txt{'187'}</option> |
| if ( ${ $uid . $curboard }{'brdpasswr'} ) { |
| <option id="noguests" value="noguests" selected="selected">$search_txt{'346'}</option> |
| my $bdmods = ${ $uid . $curboard }{'mods'}; |
| <option value="onlyguests">$search_txt{'572'}</option> |
| $bdmods =~ s/\, /\,/gsm; |
| </select> |
| $bdmods =~ s/\ /\,/gsm; |
| </div> ~; |
| my %moderators = (); |
| |
| my $pswiammod = 0; |
| } else { |
| foreach my $curuser ( split /\,/xsm, $bdmods ) { |
| $yymain .= qq~<input type="hidden" name="userkind" value="any" />~; |
| if ( $username eq $curuser ) { $pswiammod = 1; } |
| } |
| } |
| |
| my $bdmodgroups = ${ $uid . $curboard }{'modgroups'}; |
| $yymain .= qq~ |
| $bdmodgroups =~ s/\, /\,/gsm; |
| </td> |
| my %moderatorgroups = (); |
| </tr> |
| foreach my $curgroup ( split /\,/xsm, $bdmodgroups ) { |
| <tr> |
| if ( ${ $uid . $username }{'position'} eq $curgroup ) { |
| <td class="windowbg" align="right" valign="top"><b>$search_txt{'189'}:</b><br /><span class="small">$search_txt{'190'}</span></td> |
| $pswiammod = 1; |
| <td class="windowbg2" >~; |
| } |
| $allselected = 0; |
| foreach my $memberaddgroups ( split /\, /sm, |
| $isselected = 0; |
| ${ $uid . $username }{'addgroups'} ) |
| $boardscheck = ""; |
| { |
| unless ($mloaded == 1) { require "$boardsdir/forum.master"; } |
| chomp $memberaddgroups; |
| |
| if ( $memberaddgroups eq $curgroup ) { |
| foreach $catid (@categoryorder) { |
| $pswiammod = 1; |
| $boardlist = $cat{$catid}; |
| last; |
| (@bdlist) = split(/\,/, $boardlist); |
| } |
| ($catname, $catperms) = split(/\|/, $catinfo{"$catid"}); |
| } |
| $cataccess = &CatAccess($catperms); |
| } |
| if (!$cataccess) { next; } |
| my $cookiename = "$cookiepassword$curboard$username"; |
| |
| my $crypass = ${ $uid . $curboard }{'brdpassw'}; |
| foreach $curboard (@bdlist) { |
| if ( !$iamadmin |
| ($boardname, $boardperms, $boardview) = split(/\|/, $board{"$curboard"}); |
| && !$iamgmod |
| &ToChars($boardname); |
| && !$pswiammod |
| my $access = &AccessCheck($curboard, '', $boardperms); |
| && $yyCookies{$cookiename} ne $crypass ) |
| if (!$iamadmin && $access ne "granted") { next; } |
| { |
| |
| next; |
| # Checks to see if category is expanded or collapsed |
| } |
| if ($username ne "Guest") { |
| } |
| if ($catcol{$catid}) { |
| |
| $selected = qq~selected="selected"~; |
| # Checks to see if category is expanded or collapsed |
| $isselected++; |
| if ( $username ne 'Guest' ) { |
| } else { |
| if ( $catcol{$catid} ) { |
| $selected = ""; |
| $selected = q~selected="selected"~; |
| } |
| $isselected++; |
| } else { |
| } |
| $selected = qq~selected="selected"~; |
| else { |
| $isselected++; |
| $selected = q{}; |
| } |
| } |
| $allselected++; |
| } |
| $checklist .= qq~<option value="$curboard" $selected>$boardname</option>\n ~; |
| else { |
| } |
| $selected = q~selected="selected"~; |
| } |
| $isselected++; |
| if ($isselected == $allselected) { $boardscheck = qq~ checked="checked"~; } |
| } |
| $yymain .= qq~ |
| $allselected++; |
| <select multiple="multiple" name="searchboards" size="5" onchange="selectnum();"> |
| $checklist .= |
| $checklist |
| qq~<option value="$curboard" $selected>$boardname</option>\n ~; |
| </select> |
| if ( !$subboard{$curboard} ) { next; } |
| <input type="checkbox" name="srchAll" id="srchAll"$boardscheck onclick="if (this.checked) searchAll(true); else searchAll(false);" /> <label for="srchAll">$search_txt{'737'}</label> |
| my $indent; |
| <script language="JavaScript1.2" type="text/javascript"> |
| |
| <!-- // |
| *get_subboards = sub { |
| function searchAll(_v) { |
| my @x = @_; |
| for(var i=0;i<document.searchform.searchboards.length;i++) |
| $indent += 2; |
| document.searchform.searchboards[i].selected=_v; |
| foreach my $childbd (@x) { |
| } |
| my $dash; |
| |
| if ( $indent > 0 ) { $dash = q{-}; } |
| function selectnum() { |
| ( $chldboardname, undef, undef ) = split /\|/xsm, |
| document.searchform.srchAll.checked = true; |
| $board{"$childbd"}; |
| for(var i=0;i<document.searchform.searchboards.length;i++) { |
| ToChars($chldboardname); |
| if (! document.searchform.searchboards[i].selected) { document.searchform.srchAll.checked = false; } |
| $checklist .= |
| } |
| qq~<option value="$childbd" $selected>~ |
| } |
| . ( ' ' x $indent ) |
| // --> |
| . ( $dash x ( $indent / 2 ) ) |
| </script> |
| . qq~ $chldboardname</option>\n ~; |
| </td> |
| if ( $subboard{$childbd} ) { |
| </tr> |
| get_subboards( split /\|/xsm, $subboard{$childbd} ); |
| <tr> |
| } |
| <td align="right" class="windowbg"><b>$search_txt{'573'}:</b></td> |
| } |
| <td class="windowbg2"> |
| $indent -= 2; |
| <input type="checkbox" name="subfield" id="subfield" value="on" checked="checked" /><label for="subfield"> $search_txt{'70'}</label> |
| return; |
| <input type="checkbox" name="msgfield" id="msgfield" value="on" checked="checked" /><label for="msgfield"> $search_txt{'72'}</label> |
| }; |
| </td> |
| get_subboards( split /\|/xsm, $subboard{$curboard} ); |
| </tr> |
| } |
| <tr> |
| } |
| <td align="right" class="windowbg"><label for="age"><b>$search_txt{'1'}</b></label></td> |
| if ( $isselected == $allselected ) { |
| <td class="windowbg2"> |
| $boardscheck = q~ checked="checked"~; |
| <select name="age" id="age"> |
| } |
| <option value="7" selected="selected">$search_txt{'2'}</option> |
| if ( $iamadmin || $iamfmod || $iamgmod && $gmod_access2{'ipban2'} eq 'on' ) |
| <option value="31">$search_txt{'3'}</option> |
| { |
| <option value="92">$search_txt{'4'}</option> |
| $search_ip = |
| <option value="365">$search_txt{'5'}</option> |
| qq~<input type="checkbox" name="search_ip" id="search_ip" value="on" /><label for="search_ip"> $search_txt{'73'}</label>~; |
| <option value="0">$search_txt{'6'}</option> |
| } |
| </select> |
| |
| </td> |
| $yymain .= qq~ |
| </tr> |
| <select multiple="multiple" name="searchboards" size="5" onchange="selectnum();"> |
| <tr> |
| $checklist |
| <td align="right" class="windowbg"><label for="numberreturned"><b>$search_txt{'191'}</b><br /><span class="small">$search_txt{'191b'}</span></label></td> |
| </select> |
| <td class="windowbg2"><input type="text" size="5" name="numberreturned" id="numberreturned" maxlength="5" value="$maxsearchdisplay" /></td> |
| <input type="checkbox" name="srchAll" id="srchAll"$boardscheck onclick="if (this.checked) searchAll(true); else searchAll(false);" /> <label for="srchAll">$search_txt{'737'}</label> |
| </tr> |
| <script type="text/javascript"> |
| <tr> |
| function searchAll(_v) { |
| <td align="right" class="windowbg"><label for="oneperthread"><b>$search_txt{'191a'}</b></label></td> |
| for(var i=0;i<document.searchform.searchboards.length;i++) |
| <td class="windowbg2"><input type="checkbox" name="oneperthread" id="oneperthread" value="1"/></td> |
| document.searchform.searchboards[i].selected=_v; |
| </tr> |
| } |
| <tr> |
| |
| <td class="catbg" colspan="2" height="50" valign="middle" align="center"> |
| function selectnum() { |
| <input type="submit" name="submit" value="$search_txt{'182'}" class="button" /> |
| document.searchform.srchAll.checked = true; |
| </td> |
| for(var i=0;i<document.searchform.searchboards.length;i++) { |
| </tr> |
| if (! document.searchform.searchboards[i].selected) { document.searchform.srchAll.checked = false; } |
| </table> |
| } |
| </form> |
| } |
| <script type="text/javascript" language="JavaScript"> |
| </script>~; |
| <!-- |
| $yymain .= $mysearch_template5; |
| document.searchform.search.focus(); |
| $yymain =~ s/{yabb maxsearchdisplay}/$maxsearchdisplay/sm; |
| |
| $yymain =~ s/{yabb search_ip}/$search_ip/sm; |
| function CheckSearchFields() { |
| |
| if (document.searchform.numberreturned.value > $maxsearchdisplay) { |
| $yymain .= qq~ |
| alert("$search_txt{'191x'}"); |
| <script type="text/javascript"> |
| document.searchform.numberreturned.focus(); |
| document.searchform.search.focus(); |
| return false; |
| function CheckSearchFields() { |
| } |
| if (document.searchform.numberreturned.value > $maxsearchdisplay) { |
| return true; |
| alert("$search_txt{'191x'}"); |
| } |
| document.searchform.numberreturned.focus(); |
| //--> |
| return false; |
| |
| } |
| |
| return true; |
| |
| } |
| </script> |
| </script> |
| ~; |
| ~; |
| |
| |
| $yytitle = $search_txt{'183'}; |
| $yytitle = $search_txt{'183'}; |
| $yynavigation = qq~› $search_txt{'182'}~; |
| $yynavigation = qq~› $search_txt{'182'}~; |
| &template; |
| template(); |
| |
| return; |
| } |
| } |
| |
| |
| sub plushSearch2 { |
| sub plushSearch2 { |
| # generate error if admin has disabled search options |
| |
| if ($maxsearchdisplay < 0) { &fatal_error("search_disabled"); } |
| |
| &spam_protection; |
| |
| |
| |
| my $maxage = $FORM{'age'} || (int(($date - &stringtotime($forumstart)) / 86400) + 1); |
| |
| |
| |
| my $display = $FORM{'numberreturned'} || $maxsearchdisplay; |
| |
| if ($maxage =~ /\D/) { &fatal_error("only_numbers_allowed"); } |
| |
| if ($display =~ /\D/) { &fatal_error("only_numbers_allowed"); } |
| |
| |
| |
| # restrict flooding using form abuse |
| |
| if ($display > $maxsearchdisplay) { &fatal_error("result_too_high"); } |
| |
| |
| |
| 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("no_user_slash"); } |
| |
| if ($userspec =~ m~\\~) { &fatal_error("no_user_backslash"); } |
| |
| $userspec =~ s/\A\s+//; |
| |
| $userspec =~ s/\s+\Z//; |
| |
| $userspec =~ s/[^0-9A-Za-z#%+,-\.@^_]//g; |
| |
| if ($do_scramble_id) { |
| |
| $userspec =~ s/ //g; |
| |
| $userspec = &decloak($userspec); |
| |
| } |
| |
| if ($FORM{'searchme'} eq 'on' && !$iamguest) { |
| |
| $userkind = 2; |
| |
| $userspec = $username; |
| |
| } |
| |
| $searchtype = $FORM{'searchtype'}; |
| |
| my $search = $FORM{'search'}; |
| |
| &FromChars($search); |
| |
| my $one_per_thread = $FORM{'oneperthread'} || 0; |
| |
| if ($searchtype eq 'anywords') { $searchtype = 2; } |
| |
| elsif ($searchtype eq 'asphrase') { $searchtype = 3; } |
| |
| elsif ($searchtype eq 'aspartial') { $searchtype = 4; } |
| |
| else { $searchtype = 1; } |
| |
| $search =~ s/\A\s+//; |
| |
| $search =~ s/\s+\Z//; |
| |
| $search =~ s/\s+/ /g if $searchtype != 3; |
| |
| if ($search eq "" || $search eq " ") { &fatal_error("no_search"); } |
| |
| if ($search =~ m~/~) { &fatal_error("no_search_slashes"); } |
| |
| if ($search =~ m~\\~) { &fatal_error("no_search_slashes"); } |
| |
| my $searchsubject = $FORM{'subfield'} eq 'on'; |
| |
| my $searchmessage = $FORM{'msgfield'} eq 'on'; |
| |
| &ToHTML($search); |
| |
| $search =~ s/\t/ \ \ \ /g; |
| |
| $search =~ s/\cM//g; |
| |
| $search =~ s/\n/<br \/>/g; |
| |
| if ($searchtype != 3) { @search = split(/\s+/, $search); } |
| |
| else { @search = ($search); } |
| |
| my $case = $FORM{'casesensitiv'}; |
| |
| |
| |
| my ($curboard, @threads, $curthread, $tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate, @messages, $curpost, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $ns, $subfound, $msgfound, $numfound, %data, $i, $board, $curcat, @categories, %catid, %catname, %cataccess, %openmemgr, @membergroups, %cats, @boardinfo, %boardinfo, @boards, $counter, $msgnum); |
| |
| my $maxtime = $date + (3600 * ${$uid.$username}{'timeoffset'}) - ($maxage * 86400); |
| |
| my $oldestfound = 9999999999; |
| |
| |
| |
| unless ($mloaded == 1) { require "$boardsdir/forum.master"; } |
| |
| foreach $catid (@categoryorder) { |
| |
| $boardlist = $cat{$catid}; |
| |
| (@bdlist) = split(/\,/, $boardlist); |
| |
| ($catname, $catperms) = split(/\|/, $catinfo{$catid}); |
| |
| $cataccess = &CatAccess($catperms); |
| |
| if (!$cataccess) { next; } |
| |
| |
| |
| foreach $cboard (@bdlist) { |
| |
| ($bname, $bperms, $bview) = split(/\|/, $board{$cboard}); |
| |
| $catid{$cboard} = $catid; |
| |
| $catname{$cboard} = $catname; |
| |
| } |
| |
| } |
| |
| |
| |
| if ($enable_ubbc) { require "$sourcedir/YaBBC.pl"; } |
| |
| |
| |
| @boards = split(/\,\ /, $FORM{'searchboards'}); |
| |
| boardcheck: foreach $curboard (@boards) { |
| |
| ($boardname{$curboard}, $boardperms, $boardview) = split(/\|/, $board{$curboard}); |
| |
| |
| |
| my $access = &AccessCheck($curboard, '', $boardperms); |
| |
| if (!$iamadmin && $access ne "granted") { next; } |
| |
| |
| |
| fopen(FILE, "$boardsdir/$curboard.txt") || next; |
| |
| @threads = <FILE>; |
| |
| fclose(FILE); |
| |
| |
| |
| threadcheck: foreach $curthread (@threads) { |
| |
| chomp $curthread; |
| |
| |
| |
| ($tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate) = split(/\|/, $curthread); |
| |
| |
| |
| if ($tdate < $maxtime || $tstate =~ /m/i || (!$iamadmin && !$iamgmod && $tstate =~ /h/i)) { next threadcheck; } |
| |
| 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; } |
| |
| } |
| |
| } |
| |
| |
| |
| fopen(FILE, "$datadir/$tnum.txt") || next; |
| |
| @messages = <FILE>; |
| |
| fclose(FILE); |
| |
| |
| |
| postcheck: for ($msgnum = @messages; $msgnum >= 0; $msgnum--) { |
| |
| $curpost = $messages[$msgnum]; |
| |
| chomp $curpost; |
| |
| |
| |
| my ($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $savedmessage, $ns) = split(/\|/, $curpost); |
| |
| |
| |
| ## if either max to display or outside of filter, next |
| |
| if ($mdate < $maxtime || ($numfound >= $display && $mdate <= $oldestfound)) { next postcheck; } |
| |
| |
| |
| &ToChars($msub); |
| |
| ($msub, undef) = &Split_Splice_Move($msub,0); |
| |
| |
| |
| &ToChars($savedmessage); |
| |
| $message = $savedmessage; |
| |
| if ($FORM{'searchyabbtags'} && $message =~ /\[\w[^\[]*?\]/) { |
| |
| &wrap; |
| |
| ($message, undef) = &Split_Splice_Move($message,$tnum); |
| |
| if ($enable_ubbc) { &DoUBBC; } |
| |
| &wrap2; |
| |
| $savedmessage = $message; |
| |
| $message =~ s/<.+?>//g; |
| |
| } elsif (!$FORM{'searchyabbtags'}) { |
| |
| $message =~ s/\[\w[^\[]*?\]//g; |
| |
| } |
| |
| |
| |
| 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; } |
| |
| } |
| |
| |
| |
| if ($case) { |
| |
| if ($searchsubject) { |
| |
| if ($searchtype == 2 || $searchtype == 4) { |
| |
| $subfound = 0; |
| |
| foreach (@search) { |
| |
| if ($searchtype == 4 && $msub =~ m~\Q$_\E~) { $subfound = 1; last; } |
| |
| elsif ($msub =~ m~(^|\W|_)\Q$_\E(?=$|\W|_)~) { $subfound = 1; last; } |
| |
| } |
| |
| } else { |
| |
| $subfound = 1; |
| |
| foreach (@search) { |
| |
| if ($msub !~ m~(^|\W|_)\Q$_\E(?=$|\W|_)~) { $subfound = 0; last; } |
| |
| } |
| |
| } |
| |
| } |
| |
| if ($searchmessage && !$subfound) { |
| |
| if ($searchtype == 2 || $searchtype == 4) { |
| |
| $msgfound = 0; |
| |
| foreach (@search) { |
| |
| if ($searchtype == 4 && $message =~ m~\Q$_\E~) { $msgfound = 1; last; } |
| |
| elsif ($message =~ m~(^|\W|_)\Q$_\E(?=$|\W|_)~) { $msgfound = 1; last; } |
| |
| } |
| |
| } else { |
| |
| $msgfound = 1; |
| |
| foreach (@search) { |
| |
| if ($message !~ m~(^|\W|_)\Q$_\E(?=$|\W|_)~) { $msgfound = 0; last; } |
| |
| } |
| |
| } |
| |
| } |
| |
| } else { |
| |
| if ($searchsubject) { |
| |
| if ($searchtype == 2 || $searchtype == 4) { |
| |
| $subfound = 0; |
| |
| foreach (@search) { |
| |
| if ($searchtype == 4 && $msub =~ m~\Q$_\E~i) { $subfound = 1; last; } |
| |
| elsif ($msub =~ m~(^|\W|_)\Q$_\E(?=$|\W|_)~i) { $subfound = 1; last; } |
| |
| } |
| |
| } else { |
| |
| $subfound = 1; |
| |
| foreach (@search) { |
| |
| if ($msub !~ m~(^|\W|_)\Q$_\E(?=$|\W|_)~i) { $subfound = 0; last; } |
| |
| } |
| |
| } |
| |
| } |
| |
| if ($searchmessage && !$subfound) { |
| |
| if ($searchtype == 2 || $searchtype == 4) { |
| |
| $msgfound = 0; |
| |
| foreach (@search) { |
| |
| if ($searchtype == 4 && $message =~ m~\Q$_\E~i) { $msgfound = 1; last; } |
| |
| elsif ($message =~ m~(^|\W|_)\Q$_\E(?=$|\W|_)~i) { $msgfound = 1; last; } |
| |
| } |
| |
| } else { |
| |
| $msgfound = 1; |
| |
| foreach (@search) { |
| |
| if ($message !~ m~(^|\W|_)\Q$_\E(?=$|\W|_)~i) { $msgfound = 0; last; } |
| |
| } |
| |
| } |
| |
| } |
| |
| } |
| |
| |
| |
| ## blank? try next = else => build list from found mess/sub |
| |
| unless ($msgfound || $subfound) { next postcheck; } |
| |
| |
| |
| $data{$mdate} = [$curboard, $tnum, $msgnum, $tusername, $tname, $msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $savedmessage, $ns, $tstate]; |
| |
| if ($mdate < $oldestfound) { $oldestfound = $mdate; } |
| |
| $numfound++; |
| |
| if ($one_per_thread) { last postcheck; } |
| |
| } |
| |
| } |
| |
| } |
| |
| |
| |
| @messages = sort { $b <=> $a } keys %data; |
| |
| if (@messages) { |
| |
| if (@messages > $display) { $#messages = $display - 1; } |
| |
| &LoadCensorList; |
| |
| } else { |
| |
| $yymain .= qq~<hr class="hr" /><b>$search_txt{'170'}<br /><a href="javascript:history.go(-1)">$search_txt{'171'}</a></b><hr class="hr" />~; |
| |
| } |
| |
| $search = &Censor($search); |
| |
| |
| |
| # Search for censored or uncencored search string and remove duplicate words |
| |
| my @tmpsearch; |
| |
| if ($searchtype == 3) { @tmpsearch = ($search); } |
| |
| else { @tmpsearch = split(/\s+/, $search); } |
| |
| push @tmpsearch, @search; |
| |
| undef %found; |
| |
| @search = grep(!$found{$_}++, @tmpsearch); |
| |
| |
| |
| for ($i = 0; $i < @messages; $i++) { |
| |
| ($board, $tnum, $msgnum, $tusername, $tname, $msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $ns, $tstate) = @{ $data{ $messages[$i] } }; |
| |
| |
| |
| $tname = &addMemberLink($tusername,$tname,$tnum); |
| |
| $mname = &addMemberLink($musername,$mname,$mdate); |
| |
| |
| |
| $mdate = &timeformat($mdate); |
| |
| |
| |
| if (!$FORM{'searchyabbtags'}) { |
| |
| &wrap; |
| |
| ($message, undef) = &Split_Splice_Move($message,$tnum); |
| |
| if ($enable_ubbc) { &DoUBBC; } |
| |
| &wrap2; |
| |
| } |
| |
| |
| |
| $message = &Censor($message); |
| |
| $msub = &Censor($msub); |
| |
| |
| |
| &Highlight(\$msub,\$message,\@search,$case); |
| |
| |
| |
| &ToChars($catname{$board}); |
| |
| &ToChars($boardname{$board}); |
| |
| |
| |
| ++$counter; |
| |
| |
| |
| $yymain .= qq~ |
| |
| <table border="0" width="100%" cellspacing="1" class="bordercolor" style="table-layout: fixed;"> |
| |
| <tr> |
| |
| <td align="center" width="5%" class="titlebg">$counter</td> |
| |
| <td align="left" width="95%" class="titlebg"> <a href="$scripturl?catselect=$catid{$board}"><u>$catname{$board}</u></a> / <a href="$scripturl?board=$board"><u>$boardname{$board}</u></a> / <a href="$scripturl?num=$tnum/$msgnum#$msgnum"><u>$msub</u></a><br /> |
| |
| <span class="small">$search_txt{'30'}: $mdate</span> </td> |
| |
| </tr> |
| |
| <tr> |
| |
| <td colspan="2"> |
| |
| <table border="0" width="100%" class="catbg"> |
| |
| <tr> |
| |
| <td align="left">$search_txt{'109'} $tname | $search_txt{'105'} $search_txt{'525'} $mname</td> |
| |
| <td align="right"> ~; |
| |
| |
| |
| if ($tstate != 1 && (!$iamguest || ($iamguest && $enable_guestposting))) { |
| |
| my $notify = ''; |
| |
| if (!$iamguest) { |
| |
| if (${$uid.$username}{'thread_notifications'} =~ /\b$tnum\b/) { |
| |
| $notify = qq~$menusep<a href="$scripturl?action=notify3;oldnotify=1;num=$tnum/$msgnum#$msgnum">$img{'del_notify'}</a>~; |
| |
| } else { |
| |
| $notify = qq~$menusep<a href="$scripturl?action=notify2;oldnotify=1;num=$tnum/$msgnum#$msgnum">$img{'add_notify'}</a>~; |
| |
| } |
| |
| } |
| |
| $yymain .= qq~<a href="$scripturl?board=$board;action=post;num=$tnum/$msgnum#$msgnum;title=PostReply">$img{'reply'}</a>$menusep<a href="$scripturl?board=$board;action=post;num=$tnum;quote=$msgnum;title=PostReply">$img{'recentquote'}</a>$notify ~; |
| |
| } |
| |
| |
| |
| $yymain .= qq~ |
| |
| </td> |
| |
| </tr> |
| |
| </table> |
| |
| </td> |
| |
| </tr> |
| |
| <tr> |
| |
| <td align="left" height="80" colspan="2" class="windowbg2" valign="top"><div class="message" style="float: left; width: 99%; overflow: auto;">$message</div></td> |
| |
| </tr> |
| |
| </table><br />~; |
| |
| } |
| |
| |
| |
| $yymain .= qq~ |
| # generate error if admin has disabled search options |
| |
| if ( $maxsearchdisplay < 0 ) { fatal_error('search_disabled'); } |
| |
| if ( $advsearchaccess ne 'granted' && $qcksearchaccess ne 'granted' ) { |
| |
| fatal_error('no_access'); |
| |
| } |
| |
| spam_protection(); |
| |
| |
| |
| my $maxage = $FORM{'age'} |
| |
| || ( int( ( $date - stringtotime($forumstart) ) / 86400 ) + 1 ); |
| |
| |
| |
| my $display = $FORM{'numberreturned'} || $maxsearchdisplay; |
| |
| if ( $maxage =~ /\D/xsm ) { fatal_error('only_numbers_allowed'); } |
| |
| if ( $display =~ /\D/xsm ) { fatal_error('only_numbers_allowed'); } |
| |
| |
| |
| # restrict flooding using form abuse |
| |
| if ( $display > $maxsearchdisplay ) { fatal_error('result_too_high'); } |
| |
| |
| |
| 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 = q{}; } |
| |
| |
| |
| if ( $userspec =~ m{/}xsm ) { fatal_error('no_user_slash'); } |
| |
| if ( $userspec =~ m{\\}xsm ) { fatal_error('no_user_backslash'); } |
| |
| $userspec =~ s/\A\s+//xsm; |
| |
| $userspec =~ s/\s+\Z//xsm; |
| |
| $userspec =~ s/[^0-9A-Za-z#%+,-\.@^_]//gxsm; |
| |
| if ($do_scramble_id) { |
| |
| $userspec =~ s/ //gsm; |
| |
| $userspec = decloak($userspec); |
| |
| } |
| |
| if ( $FORM{'searchme'} eq 'on' && !$iamguest ) { |
| |
| $userkind = 2; |
| |
| $userspec = $username; |
| |
| } |
| |
| $searchtype = $FORM{'searchtype'}; |
| |
| my $search = $FORM{'search'}; |
| |
| FromChars($search); |
| |
| my $one_per_thread = $FORM{'oneperthread'} || 0; |
| |
| if ( $searchtype eq 'anywords' ) { $searchtype = 2; } |
| |
| elsif ( $searchtype eq 'asphrase' ) { $searchtype = 3; } |
| |
| elsif ( $searchtype eq 'aspartial' ) { $searchtype = 4; } |
| |
| else { $searchtype = 1; } |
| |
| $search =~ s/\A\s+//xsm; |
| |
| $search =~ s/\s+\Z//xsm; |
| |
| if ( $searchtype != 3 ) { $search =~ s/\s+/ /gxsm; } |
| |
| if ( $search eq q{} || $search eq q{ } ) { fatal_error('no_search'); } |
| |
| if ( $search =~ m{/}xsm ) { fatal_error('no_search_slashes'); } |
| |
| if ( $search =~ m{\\}xsm ) { fatal_error('no_search_slashes'); } |
| |
| my $searchsubject = $FORM{'subfield'} eq 'on'; |
| |
| my $searchmessage = $FORM{'msgfield'} eq 'on'; |
| |
| if ( $FORM{'search_ip'} eq 'on' ) { $search_ip = $FORM{'search'}; } |
| |
| ToHTML($search); |
| |
| $search =~ s/\t/ \ \ \ /gxsm; |
| |
| $search =~ s/\cM//gxsm; |
| |
| $search =~ s/\n/<br \/>/gxsm; |
| |
| if ( $searchtype != 3 ) { @search = split /\s+/xsm, $search; } |
| |
| else { @search = ($search); } |
| |
| my $case = $FORM{'casesensitiv'}; |
| |
| |
| |
| my ( |
| |
| $curboard, @threads, $curthread, $tnum, $tsub, |
| |
| $tname, $temail, $tdate, $treplies, $tusername, |
| |
| $ticon, $tstate, @messages, $curpost, $subfound, |
| |
| $msgfound, $numfound, %data, $i, $board, |
| |
| $curcat, @categories, %catid, %catname, %cataccess, |
| |
| %openmemgr, @membergroups, %cats, @boardinfo, %boardinfo, |
| |
| @boards, $counter, $msgnum |
| |
| ); |
| |
| my $maxtime = |
| |
| $date + |
| |
| ( 3600 * ${ $uid . $username }{'timeoffset'} ) - |
| |
| ( $maxage * 86400 ); |
| |
| my $oldestfound = 9999999999; |
| |
| |
| |
| get_forum_master(); |
| |
| foreach my $catid (@categoryorder) { |
| |
| $boardlist = $cat{$catid}; |
| |
| (@bdlist) = split /\,/xsm, $boardlist; |
| |
| ( $catname, $catperms ) = split /\|/xsm, $catinfo{$catid}; |
| |
| $cataccess = CatAccess($catperms); |
| |
| if ( !$cataccess ) { next; } |
| |
| |
| |
| foreach my $cboard (@bdlist) { |
| |
| ( $bname, $bperms, $bview ) = split /\|/xsm, $board{$cboard}; |
| |
| $catid{$cboard} = $catid; |
| |
| $catname{$cboard} = $catname; |
| |
| } |
| |
| } |
| |
| |
| |
| foreach my $cbdlist ( keys %subboard ) { |
| |
| foreach my $cboard ( split /\|/xsm, $subboard{$cbdlist} ) { |
| |
| my $catid = ${ $uid . $cboard }{'cat'}; |
| |
| ( $catname, $catperms ) = split /\|/xsm, $catinfo{$catid}; |
| |
| $cataccess = CatAccess($catperms); |
| |
| if ( !$cataccess ) { next; } |
| |
| $catid{$cboard} = $catid; |
| |
| $catname{$cboard} = $catname; |
| |
| } |
| |
| } |
| |
| if ($enable_ubbc) { require Sources::YaBBC; } |
| |
| |
| |
| @boards = split /\,\ /xsm, $FORM{'searchboards'}; |
| |
| BOARDCHECK: foreach my $curboard (@boards) { |
| |
| ( $boardname{$curboard}, $boardperms, $boardview ) = split /\|/xsm, |
| |
| $board{$curboard}; |
| |
| |
| |
| my $access = AccessCheck( $curboard, q{}, $boardperms ); |
| |
| if ( !$iamadmin && $access ne 'granted' ) { next; } |
| |
| |
| |
| if ( ${ $uid . $curboard }{'brdpasswr'} ) { |
| |
| my $bdmods = ${ $uid . $curboard }{'mods'}; |
| |
| $bdmods =~ s/\, /\,/gsm; |
| |
| $bdmods =~ s/\ /\,/gsm; |
| |
| my %moderators = (); |
| |
| my $pswiammod = 0; |
| |
| foreach my $curuser ( split /\,/xsm, $bdmods ) { |
| |
| if ( $username eq $curuser ) { $pswiammod = 1; } |
| |
| } |
| |
| my $bdmodgroups = ${ $uid . $curboard }{'modgroups'}; |
| |
| $bdmodgroups =~ s/\, /\,/gsm; |
| |
| my %moderatorgroups = (); |
| |
| foreach my $curgroup ( split /\,/xsm, $bdmodgroups ) { |
| |
| if ( ${ $uid . $username }{'position'} eq $curgroup ) { |
| |
| $pswiammod = 1; |
| |
| } |
| |
| foreach my $memberaddgroups ( split /\, /sm, |
| |
| ${ $uid . $username }{'addgroups'} ) |
| |
| { |
| |
| chomp $memberaddgroups; |
| |
| if ( $memberaddgroups eq $curgroup ) { |
| |
| $pswiammod = 1; |
| |
| last; |
| |
| } |
| |
| } |
| |
| } |
| |
| my $cookiename = "$cookiepassword$curboard$username"; |
| |
| my $crypass = ${ $uid . $curboard }{'brdpassw'}; |
| |
| if ( !$iamadmin |
| |
| && !$iamgmod |
| |
| && !$pswiammod |
| |
| && $yyCookies{$cookiename} ne $crypass ) |
| |
| { |
| |
| next; |
| |
| } |
| |
| } |
| |
| |
| |
| fopen( FILE, "$boardsdir/$curboard.txt" ) || next; |
| |
| @threads = <FILE>; |
| |
| fclose(FILE); |
| |
| |
| |
| THREADCHECK: foreach my $curthread (@threads) { |
| |
| chomp $curthread; |
| |
| |
| |
| ( |
| |
| $tnum, $tsub, $tname, $temail, $tdate, |
| |
| $treplies, $tusername, $ticon, $tstate |
| |
| ) = split /\|/xsm, $curthread; |
| |
| |
| |
| if ( $tdate < $maxtime |
| |
| || $tstate =~ /m/ism |
| |
| || ( !$iamadmin && !$iamgmod && $tstate =~ /h/ism ) ) |
| |
| { |
| |
| next THREADCHECK; |
| |
| } |
| |
| if ( $userkind == 1 ) { |
| |
| if ( $tusername eq 'Guest' ) { |
| |
| if ( $tname !~ m{\A\Q$userspec\E\Z}ism ) { |
| |
| next THREADCHECK; |
| |
| } |
| |
| } |
| |
| else { |
| |
| if ( $tusername !~ m{\A\Q$userspec\E\Z}ism ) { |
| |
| next THREADCHECK; |
| |
| } |
| |
| } |
| |
| } |
| |
| |
| |
| fopen( FILE, "$datadir/$tnum.txt" ) || next; |
| |
| @messages = <FILE>; |
| |
| fclose(FILE); |
| |
| |
| |
| POSTCHECK: foreach my $msgnum ( reverse 0 .. @messages ) { |
| |
| $curpost = $messages[$msgnum]; |
| |
| chomp $curpost; |
| |
| |
| |
| my ( |
| |
| $msub, $mname, $memail, $mdate, |
| |
| $musername, $micon, $mattach, $mip, |
| |
| $savedmessage, $ns |
| |
| ) = split /\|/xsm, $curpost; |
| |
| |
| |
| ## if either max to display or outside of filter, next |
| |
| if ( $mdate < $maxtime |
| |
| || ( $numfound >= $display && $mdate <= $oldestfound ) ) |
| |
| { |
| |
| next POSTCHECK; |
| |
| } |
| |
| |
| |
| ToChars($msub); |
| |
| ( $msub, undef ) = Split_Splice_Move( $msub, 0 ); |
| |
| |
| |
| ToChars($savedmessage); |
| |
| $message = $savedmessage; |
| |
| if ( $FORM{'searchyabbtags'} && $message =~ /\[\w[^\[]*?\]/xsm ) |
| |
| { |
| |
| wrap(); |
| |
| ( $message, undef ) = Split_Splice_Move( $message, $tnum ); |
| |
| if ($enable_ubbc) { DoUBBC(); } |
| |
| wrap2(); |
| |
| $savedmessage = $message; |
| |
| $message =~ s/<.+?>//gxsm; |
| |
| } |
| |
| elsif ( !$FORM{'searchyabbtags'} ) { |
| |
| $message =~ s/\[\w[^\[]*?\]//gxsm; |
| |
| } |
| |
| |
| |
| if ( $musername eq 'Guest' ) { |
| |
| if ( |
| |
| $userkind == 3 |
| |
| || ( $userkind == 2 |
| |
| && $mname !~ m{\A\Q$userspec\E\Z}ism ) |
| |
| ) |
| |
| { |
| |
| next POSTCHECK; |
| |
| } |
| |
| } |
| |
| else { |
| |
| if ( |
| |
| $userkind == 4 |
| |
| || ( $userkind == 2 |
| |
| && $musername !~ m{\A\Q$userspec\E\Z}ism ) |
| |
| ) |
| |
| { |
| |
| next POSTCHECK; |
| |
| } |
| |
| } |
| |
| |
| |
| if ($searchsubject) { |
| |
| if ( $searchtype == 2 || $searchtype == 4 ) { |
| |
| $subfound = case_subfound( $case, $searchtype, $msub ); |
| |
| } |
| |
| else { |
| |
| $subfound = case_subfound2( $case, $msub ); |
| |
| } |
| |
| } |
| |
| if ( $searchmessage && !$subfound ) { |
| |
| if ( $searchtype == 2 || $searchtype == 4 ) { |
| |
| $msgfound = |
| |
| case_subfound( $case, $searchtype, $message ); |
| |
| } |
| |
| else { |
| |
| $msgfound = case_subfound2( $case, $message ); |
| |
| } |
| |
| } |
| |
| |
| |
| ## blank? try next = else => build list from found mess/sub |
| |
| ## Search for IP Address start |
| |
| if ( $search_ip && !$msgfound && !$subfound ) { |
| |
| $ipfound = 0; |
| |
| @mip = split / /sm, $mip; |
| |
| $mip = q~~; |
| |
| $mip_class = q~~; |
| |
| foreach (@mip) { |
| |
| if ( $_ =~ /\b$search_ip/sm ) { |
| |
| $ipfound = 1; |
| |
| } |
| |
| if ( $ipLookup ) { |
| |
| if ( $_ =~ /\b$search_ip/sm ) { |
| |
| $mip_class = ' highlight'; |
| |
| } |
| |
| $mip .= |
| |
| qq~<a href="$scripturl?action=iplookup;ip=$_"><span class="small$mip_class">$_</span></a> ~; |
| |
| } |
| |
| else { |
| |
| $mip .= qq~<span class="small$mip_class">$_</span> ~; |
| |
| } |
| |
| } |
| |
| } |
| |
| else { |
| |
| @mip = split / /sm, $mip; |
| |
| $mip = q~~; |
| |
| foreach (@mip) { |
| |
| if ( $ipLookup ) { |
| |
| $mip .= |
| |
| qq~<a href="$scripturl?action=iplookup;ip=$_"><span class="small">$_</span></a> ~; |
| |
| } |
| |
| else { |
| |
| $mip .= qq~<span class="small">$_</span> ~; |
| |
| } |
| |
| } |
| |
| } |
| |
| ## Search for IP Address end |
| |
| if ( !$msgfound && !$subfound && !$ipfound ) { next POSTCHECK; } |
| |
| |
| |
| $data{$mdate} = [ |
| |
| $curboard, $tnum, $msgnum, $tusername, |
| |
| $tname, $msub, $mname, $memail, |
| |
| $mdate, $musername, $micon, $mattach, |
| |
| $mip, $savedmessage, $ns, $tstate |
| |
| ]; |
| |
| if ( $mdate < $oldestfound ) { $oldestfound = $mdate; } |
| |
| $numfound++; |
| |
| if ($one_per_thread) { last POSTCHECK; } |
| |
| } |
| |
| } |
| |
| } |
| |
| |
| |
| @messages = reverse sort { $a <=> $b } keys %data; |
| |
| if (@messages) { |
| |
| if ( @messages > $display ) { $#messages = $display - 1; } |
| |
| LoadCensorList(); |
| |
| } |
| |
| else { |
| |
| $yymain .= |
| |
| qq~<hr class="hr" /><b>$search_txt{'170'}<br /><a href="javascript:history.go(-1)">$search_txt{'171'}</a></b><hr class="hr" />~; |
| |
| } |
| |
| $search = Censor($search); |
| |
| |
| |
| # Search for censored or uncencored search string and remove duplicate words |
| |
| my @tmpsearch; |
| |
| if ( $searchtype == 3 ) { @tmpsearch = ($search); } |
| |
| else { @tmpsearch = split /\s+/xsm, $search; } |
| |
| push @tmpsearch, @search; |
| |
| undef %found; |
| |
| @search = grep { !$found{$_}++ } @tmpsearch; |
| |
| my $icanbypass = checkUserLockBypass(); |
| |
| for my $i ( 0 .. $#messages ) { |
| |
| ( |
| |
| $board, $tnum, $msgnum, $tusername, $tname, $msub, |
| |
| $mname, $memail, $mdate, $musername, $micon, $mattach, |
| |
| $mip, $message, $ns, $tstate |
| |
| ) = @{ $data{ $messages[$i] } }; |
| |
| |
| |
| $tname = addMemberLink( $tusername, $tname, $tnum ); |
| |
| $mname = addMemberLink( $musername, $mname, $mdate ); |
| |
| |
| |
| $mdate = timeformat($mdate); |
| |
| |
| |
| if ( !$FORM{'searchyabbtags'} ) { |
| |
| wrap(); |
| |
| ( $message, undef ) = Split_Splice_Move( $message, $tnum ); |
| |
| if ($enable_ubbc) { DoUBBC(); } |
| |
| wrap2(); |
| |
| } |
| |
| ToChars($message); |
| |
| |
| |
| $message = Censor($message); |
| |
| $msub = Censor($msub); |
| |
| |
| |
| Highlight( \$msub, \$message, \@search, $case ); |
| |
| |
| |
| ToChars( $catname{$board} ); |
| |
| ToChars( $boardname{$board} ); |
| |
| |
| |
| # generate a sub board tree |
| |
| my $boardtree = q{}; |
| |
| my $parentboard = $board; |
| |
| while ($parentboard) { |
| |
| my ( $pboardname, undef, undef ) = |
| |
| split /\|/xsm, $board{"$parentboard"}; |
| |
| ToChars($pboardname); |
| |
| if ( ${ $uid . $parentboard }{'canpost'} ) { |
| |
| $pboardname = |
| |
| qq~<a href="$scripturl?board=$parentboard"><span class="under">$pboardname</span></a>~; |
| |
| } |
| |
| else { |
| |
| $pboardname = |
| |
| qq~<a href="$scripturl?boardselect=$parentboard&subboards=1"><u>$pboardname</u></a>~; |
| |
| } |
| |
| $boardtree = qq~ / $pboardname$boardtree~; |
| |
| $parentboard = ${ $uid . $parentboard }{'parent'}; |
| |
| } |
| |
| |
| |
| ++$counter; |
| |
| |
| |
| $yymain .= $mysearch_template6; |
| |
| $yymain =~ s/{yabb counter}/$counter/sm; |
| |
| $yymain .= |
| |
| qq~<a href="$scripturl?catselect=$catid{$board}"><span class="under">$catname{$board}</span></a> / <a href="$scripturl?board=$board"><span class="under">$boardname{$board}</span></a> / <a href="$scripturl?num=$tnum/$msgnum#$msgnum"><span class="under">$msub</span></a> <br /><span class="small">$search_txt{'30'}: $mdate</span>~; |
| |
| $yymain .= $mysearch_template7; |
| |
| $yymain =~ s/{yabb tname}/$tname/sm; |
| |
| $yymain =~ s/{yabb mname}/$mname/sm; |
| |
| |
| |
| if ( $tstate != 1 |
| |
| && ( !$iamguest || ( $iamguest && $enable_guestposting ) ) ) |
| |
| { |
| |
| my $notify = q{}; |
| |
| if ( !$iamguest ) { |
| |
| if ( ${ $uid . $username }{'thread_notifications'} =~ |
| |
| /\b$tnum\b/xsm ) |
| |
| { |
| |
| $notify = |
| |
| qq~$menusep<a href="$scripturl?action=notify3;oldnotify=1;num=$tnum/$msgnum#$msgnum">$img{'del_notify'}</a>~; |
| |
| } |
| |
| else { |
| |
| $notify = |
| |
| qq~$menusep<a href="$scripturl?action=notify2;oldnotify=1;num=$tnum/$msgnum#$msgnum">$img{'add_notify'}</a>~; |
| |
| } |
| |
| } |
| |
| $yymain .= |
| |
| qq~<a href="$scripturl?board=$board;action=post;num=$tnum/$msgnum#$msgnum;title=PostReply">$img{'reply'}</a>$menusep<a href="$scripturl?board=$board;action=post;num=$tnum;quote=$msgnum;title=PostReply">$img{'recentquote'}</a>$notify~; |
| |
| } |
| |
| if ( $staff |
| |
| && ( $icanbypass || $tstate !~ /l/ism ) |
| |
| && ( !$iammod || is_moderator( $username, $board ) ) ) |
| |
| { |
| |
| LoadLanguage('Display'); |
| |
| $yymain .= |
| |
| qq~$menusep<a href="$scripturl?action=multidel;recent=1;thread=$tnum;del$c=$c" onclick="return confirm('~ |
| |
| . ( |
| |
| ( $icanbypass && $tstate =~ /l/ism ) |
| |
| ? qq~$display_txt{'modifyinlocked'}\\n\\n~ |
| |
| : q{} |
| |
| ) . qq~$display_txt{'rempost'}')">$img{'delete'}</a>~; |
| |
| } |
| |
| if ( $iamadmin |
| |
| || $iamfmod |
| |
| || $iamgmod && $gmod_access2{'ipban2'} eq 'on' ) |
| |
| { |
| |
| $my_ipfind = $mysearch_template10; |
| |
| $ipimg = qq~<img src="$micon_bg{'ip'}" alt="" />~; |
| |
| $my_ipfind =~ s/{yabb ipimg}/$ipimg/sm; |
| |
| $my_ipfind =~ s/{yabb mip}/$mip/sm; |
| |
| } |
| |
| |
| |
| $yymain .= $mysearch_template9; |
| |
| $yymain =~ s/{yabb message}/$message/sm; |
| |
| $yymain =~ s/{yabb my_ipfind}/$my_ipfind/sm; |
| |
| } |
| |
| |
| |
| if (@messages) { |
| |
| $yymain .= qq~ |
| $search_txt{'167'}<hr class="hr" /> |
| $search_txt{'167'}<hr class="hr" /> |
| <span class="small"><a href="$scripturl">$search_txt{'236'}</a> $search_txt{'237'}<br /></span>~ if @messages; |
| <span class="small"><a href="$scripturl">$search_txt{'236'}</a> $search_txt{'237'}<br /></span>~; |
| |
| } |
| |
| |
| $yynavigation = qq~› $search_txt{'166'}~; |
| $yynavigation = qq~› $search_txt{'166'}~; |
| $yytitle = $search_txt{'166'}; |
| $yytitle = $search_txt{'166'}; |
| &template; |
| template(); |
| |
| return; |
| } |
| } |
| |
| |
| ## does a search of all member's pm files |
| ## does a search of all member pm files |
| |
| |
| sub pmsearch { |
| sub pmsearch { |
| # generate error if admin has disabled search options |
| $enable_PMsearch ||= 0; |
| if ($enable_PMsearch < 0) { &fatal_error("search_disabled"); } |
| # generate error if admin has disabled search options |
| |
| if ( $enable_PMsearch <= 0 ) { fatal_error('search_disabled'); } |
| my $display = $FORM{'numberreturned'} || $enable_PMsearch; |
| |
| if ($display =~ /\D/) { &fatal_error("only_numbers_allowed"); } |
| my $display = $FORM{'numberreturned'} || $enable_PMsearch; |
| if ($display > $enable_PMsearch) { &fatal_error("result_too_high"); } |
| if ( $display =~ /\D/xsm ) { fatal_error('only_numbers_allowed'); } |
| |
| if ( $display > $enable_PMsearch ) { fatal_error('result_too_high'); } |
| $searchtype = $FORM{'searchtype'} || $INFO{'searchtype'}; |
| |
| my $search = $FORM{'search'} || $INFO{'search'}; |
| $searchtype = $FORM{'searchtype'} || $INFO{'searchtype'}; |
| my $pmbox = $FORM{'pmbox'} || '!all'; |
| my $search = $FORM{'search'} || $INFO{'search'}; |
| |
| my $pmbox = $FORM{'pmbox'} || '!all'; |
| &FromChars($search); |
| |
| if ($searchtype eq 'anywords') { $searchtype = 2; } |
| FromChars($search); |
| elsif ($searchtype eq 'asphrase') { $searchtype = 3; } |
| if ( $searchtype eq 'anywords' ) { $searchtype = 2; } |
| elsif ($searchtype eq 'aspartial') { $searchtype = 4; } |
| elsif ( $searchtype eq 'asphrase' ) { $searchtype = 3; } |
| elsif ($searchtype eq 'user') { |
| elsif ( $searchtype eq 'aspartial' ) { $searchtype = 4; } |
| $searchtype = 5; |
| elsif ( $searchtype eq 'user' ) { |
| &ManageMemberinfo("load"); |
| $searchtype = 5; |
| my $username; |
| ManageMemberinfo('load'); |
| foreach (keys %memberinf) { |
| my $username; |
| ($memrealname, undef) = split(/\|/, $memberinf{$_}, 2); |
| foreach ( keys %memberinf ) { |
| $username = $_ if $memrealname eq $search; |
| ( $memrealname, undef ) = split /\|/xsm, $memberinf{$_}, 2; |
| } |
| if ( $memrealname eq $search ) { $username = $_; } |
| $search = $username; |
| } |
| } else { $searchtype = 1; } |
| $search = $username; |
| |
| } |
| if ($searchtype != 5) { |
| else { $searchtype = 1; } |
| $search =~ s/\A\s+//; |
| |
| $search =~ s/\s+\Z//; |
| if ( $searchtype != 5 ) { |
| $search =~ s/\s+/ /g if $searchtype != 3; |
| $search =~ s/\A\s+//xsm; |
| if ($search eq "" || $search eq " ") { &fatal_error("no_search"); } |
| $search =~ s/\s+\Z//xsm; |
| if ($search =~ m~/~) { &fatal_error("no_search_slashes"); } |
| if ( $searchtype != 3 ) { $search =~ s/\s+/ /gsm; } |
| if ($search =~ m~\\~) { &fatal_error("no_search_slashes"); } |
| if ( $search eq q{} || $search eq q{ } ) { fatal_error('no_search'); } |
| &ToHTML($search); |
| if ( $search =~ m{/}xsm ) { fatal_error('no_search_slashes'); } |
| $search =~ s/\t/ \ \ \ /g; |
| if ( $search =~ m{\\}xsm ) { fatal_error('no_search_slashes'); } |
| $search =~ s/\cM//g; |
| ToHTML($search); |
| $search =~ s/\n/<br \/>/g; |
| $search =~ s/\t/ \ \ \ /gsm; |
| } |
| $search =~ s/\cM//gxsm; |
| |
| $search =~ s/\n/<br \/>/gxsm; |
| my $pmboxesCount = 1; |
| } |
| if ($pmbox eq "!all") { $pmboxesCount = 3; } |
| |
| if ($searchtype == 5) { @search = ($search); } |
| my $pmboxesCount = 1; |
| elsif ($searchtype != 3) { @search = split(/\s+/, lc $search); } |
| if ( $pmbox eq '!all' ) { $pmboxesCount = 3; } |
| else { @search = (lc $search); } |
| if ( $searchtype == 5 ) { @search = ($search); } |
| |
| elsif ( $searchtype != 3 ) { @search = split /\s+/xsm, lc $search; } |
| my ($curboard, @threads, $curthread, $tnum, $tsub, $tname, $temail, $treplies, $tusername, $ticon, $tstate, @messages, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $userfound, $subfound, $msgfound, $numfound, %data, $i, $board, $curcat, @categories, %catname, %cataccess, %openmemgr, @membergroups, %cats, @boardinfo, %boardinfo, @boards, $counter, $msgnum, @scanthreads); |
| else { @search = ( lc $search ); } |
| my $oldestfound = 9999999999; |
| |
| |
| my ( |
| if($pmbox eq "!all" || $pmbox eq "1") { |
| $curboard, @threads, $curthread, $tnum, $tsub, |
| if(-e "$memberdir/$username.msg") { |
| $tname, $temail, $treplies, $tusername, $ticon, |
| fopen(FILE, "$memberdir/$username.msg"); |
| $tstate, $musername, $micon, $mattach, $userfound, |
| @msgthreads = <FILE>; |
| $subfound, $msgfound, $numfound, %data, $i, |
| fclose(FILE); |
| $board, $curcat, @categories, %catname, %cataccess, |
| } |
| %openmemgr, @membergroups, %cats, @boardinfo, %boardinfo, |
| } |
| @boards, $counter, @scanthreads |
| |
| ); |
| if($pmbox eq "!all" || $pmbox eq "2") { |
| my $oldestfound = 9_999_999_999; |
| if(-e "$memberdir/$username.outbox") { |
| |
| fopen(FILE, "$memberdir/$username.outbox"); |
| if ( $pmbox eq '!all' || $pmbox eq '1' ) { |
| @outthreads = <FILE>; |
| if ( -e "$memberdir/$username.msg" ) { |
| fclose(FILE); |
| fopen( FILE, "$memberdir/$username.msg" ); |
| } |
| @msgthreads = <FILE>; |
| } |
| fclose(FILE); |
| |
| } |
| if($pmbox eq "!all" || $pmbox eq "3") { |
| } |
| if(-e "$memberdir/$username.imstore") { |
| |
| fopen(FILE, "$memberdir/$username.imstore"); |
| if ( $pmbox eq '!all' || $pmbox eq '2' ) { |
| @storethreads = <FILE>; |
| if ( -e "$memberdir/$username.outbox" ) { |
| fclose(FILE); |
| fopen( FILE, "$memberdir/$username.outbox" ); |
| } |
| @outthreads = <FILE>; |
| } |
| fclose(FILE); |
| |
| } |
| if ($enable_ubbc) { require "$sourcedir/YaBBC.pl"; } |
| } |
| |
| |
| for (my $boxCount = 1; $boxCount <= $pmboxesCount; $boxCount++) { |
| if ( $pmbox eq '!all' || $pmbox eq '3' ) { |
| |
| if ( -e "$memberdir/$username.imstore" ) { |
| if ($boxCount == 1 || $pmbox == 1) { |
| fopen( FILE, "$memberdir/$username.imstore" ); |
| @scanthreads = @msgthreads; |
| @storethreads = <FILE>; |
| $pmboxName = 1; |
| fclose(FILE); |
| } |
| } |
| if ($boxCount == 2 || $pmbox == 2) { |
| } |
| @scanthreads = @outthreads; |
| |
| $pmboxName = 2; |
| if ($enable_ubbc) { require Sources::YaBBC; } |
| } |
| |
| if ($boxCount == 3 || $pmbox == 3) { |
| for my $boxCount ( 1 .. $pmboxesCount ) { |
| @scanthreads = @storethreads; |
| |
| $pmboxName = 3; |
| if ( $boxCount == 1 || $pmbox == 1 ) { |
| } |
| @scanthreads = @msgthreads; |
| chomp(@scanthreads); |
| $pmboxName = 1; |
| |
| } |
| ## reverse through messages |
| if ( $boxCount == 2 || $pmbox == 2 ) { |
| postcheck: for ($msgnum = $#scanthreads; $msgnum >= 0; $msgnum--) { |
| @scanthreads = @outthreads; |
| my ($messageid, $mfromuser, $mtouser, $mccuser, $mbccuser, $msub, $mdate, $savedmessage, $mparentmid, $mreply, $mip, $mmessagestatus, $mflags, $mstorefolder, $mattachment) = split(/\|/, $scanthreads[$msgnum]); |
| $pmboxName = 2; |
| |
| } |
| ## if either max to display or outside of filter, next |
| if ( $boxCount == 3 || $pmbox == 3 ) { |
| if ($numfound >= $display && $mdate <= $oldestfound) { next postcheck; } |
| @scanthreads = @storethreads; |
| |
| $pmboxName = 3; |
| &ToChars($msub); |
| } |
| |
| chomp @scanthreads; |
| &ToChars($savedmessage); |
| |
| $message = $savedmessage; |
| ## reverse through messages |
| if ($message =~ /\[\w[^\[]*?\]/) { |
| POSTCHECK: foreach my $msgnum ( reverse 0 .. $#scanthreads ) { |
| &wrap; |
| my ( |
| if ($enable_ubbc) { &DoUBBC; } |
| $messageid, $mfromuser, $mtouser, $mccuser, |
| &wrap2; |
| $mbccuser, $msub, $mdate, $savedmessage, |
| $savedmessage = $message; |
| $mparentmid, $mreply, $mip, $mmessagestatus, |
| $message =~ s/<.+?>//g; |
| $mflags, $mstorefolder, $mattachment |
| } |
| ) = split /\|/xsm, $scanthreads[$msgnum]; |
| |
| |
| if ($searchtype == 5) { |
| ## if either max to display or outside of filter, next |
| $userfound = 0; |
| if ( $numfound >= $display && $mdate <= $oldestfound ) { |
| foreach (@search) { |
| next POSTCHECK; |
| if ($mfromuser eq $_ || $mtouser eq $_) { $userfound = 1; } |
| } |
| } |
| |
| |
| ToChars($msub); |
| } else { |
| |
| if ($searchtype == 2 || $searchtype == 4) { |
| ToChars($savedmessage); |
| $subfound = 0; |
| $message = $savedmessage; |
| foreach (@search) { |
| if ( $message =~ /\[\w[^\[]*?\]/xsm ) { |
| if ($searchtype == 4 && $msub =~ m~\Q$_\E~i) { $subfound = 1; last; } |
| wrap(); |
| elsif ($msub =~ m~(^|\W|_)\Q$_\E(?=$|\W|_)~i) { $subfound = 1; last; } |
| if ($enable_ubbc) { DoUBBC(); } |
| } |
| wrap2(); |
| } else { |
| $savedmessage = $message; |
| $subfound = 1; |
| $message =~ s/<.+?>//gxsm; |
| foreach (@search) { |
| } |
| if ($msub !~ m~(^|\W|_)\Q$_\E(?=$|\W|_)~i) { $subfound = 0; last; } |
| |
| } |
| if ( $searchtype == 5 ) { |
| } |
| $userfound = 0; |
| ## nothing found? message |
| foreach (@search) { |
| if (!$subfound) { |
| if ( $mfromuser eq $_ || $mtouser eq $_ ) { |
| if ($searchtype == 2 || $searchtype == 4) { |
| $userfound = 1; |
| $msgfound = 0; |
| } |
| foreach (@search) { |
| } |
| if ($searchtype == 4 && $message =~ m~\Q$_\E~i) { $msgfound = 1; last; } |
| |
| elsif ($message =~ m~(^|\W|_)\Q$_\E(?=$|\W|_)~i) { $msgfound = 1; last; } |
| } |
| } |
| elsif ( $searchtype == 2 || $searchtype == 4 ) { |
| } else { |
| $subfound = 0; |
| $msgfound = 1; |
| foreach (@search) { |
| foreach (@search) { |
| if ( $searchtype == 4 && $msub =~ m{\Q$_\E}ixsm ) { |
| if ($message !~ m~(^|\W|_)\Q$_\E(?=$|\W|_)~i) { $msgfound = 0; last; } |
| $subfound = 1; |
| } |
| last; |
| } |
| } |
| } |
| elsif ( $msub =~ m{(^|\W|_)\Q$_\E(?=$|\W|_)}ixsm ) { |
| } |
| $subfound = 1; |
| ## blank? try next = else => build list from found mess/sub |
| last; |
| unless ($msgfound || $subfound || $userfound) { next postcheck; } |
| } |
| |
| } |
| $data{$mdate} = [$pmboxName, $msgnum, $msub, $mname, $memail, $mdate, $mfromuser, $mtouser, $mccuser, $mbccuser, $mattachment, $mip, $savedmessage, $messageid, $mstorefolder]; |
| } |
| if ($mdate < $oldestfound) { $oldestfound = $mdate; } |
| else { |
| $numfound++; |
| $subfound = 1; |
| } |
| foreach (@search) { |
| } |
| if ( $msub !~ m{(^|\W|_)\Q$_\E(?=$|\W|_)}ixsm ) { |
| |
| $subfound = 0; |
| ## sort result |
| last; |
| my @messages = sort { $b <=> $a } keys %data; |
| } |
| if (@messages) { |
| } |
| if (@messages > $display) { $#messages = $display - 1; } |
| } |
| &LoadCensorList; |
| ## nothing found? message |
| } else { |
| if ( !$subfound ) { |
| $yysearchmain .= qq~<hr class="hr" /> <b>$search_txt{'170'}</b><hr />~; |
| if ( $searchtype == 2 || $searchtype == 4 ) { |
| } |
| $msgfound = msgfnd( $searchtype, $message ); |
| if ($searchtype == 5) { $search = $FORM{'search'} || $INFO{'search'}; @search = ($search); } # not to display username |
| } |
| $search = &Censor($search); |
| else { |
| |
| $msgfound = msgfnd2($message); |
| # Search for censored or uncencored search string and remove duplicate words |
| } |
| my @tmpsearch; |
| } |
| if ($searchtype != 5) { |
| ## blank? try next = else => build list from found mess/sub |
| if ($searchtype == 3) { @tmpsearch = (lc $search); } |
| if ( !$msgfound && !$subfound && !$userfound ) { |
| else { @tmpsearch = split(/\s+/, lc $search); } |
| next POSTCHECK; |
| } |
| } |
| push @tmpsearch, @search; |
| |
| undef %found; |
| $data{$mdate} = [ |
| @search = grep(!$found{$_}++, @tmpsearch); |
| $pmboxName, $msgnum, $msub, |
| |
| $mname, $memail, $mdate, |
| ## output results |
| $mfromuser, $mtouser, $mccuser, |
| for ($i = 0; $i < @messages; $i++) { |
| $mbccuser, $mattachment, $mip, |
| my ($thispmbox, $msgnum, $msub, $mname, $memail, $mdate, $mfromuser, $mtouser, $mccuser, $mbccuser, $mattachment, $mip, $message, $messageid, $mstorefolder) = @{ $data{ $messages[$i] } }; |
| $savedmessage, $messageid, $mstorefolder, |
| my ($MemberFromLink, $MemberToLink, $MemberCCLink, $MemberBCCLink); |
| $mmessagestatus |
| my ($fromTitle, $toTitle, $toTitleCC, $toTitleBCC, $FolderName); |
| ]; |
| |
| if ( $mdate < $oldestfound ) { $oldestfound = $mdate; } |
| if ($mfromuser) { |
| $numfound++; |
| foreach my $uname (split(/\,/, $mfromuser)) { |
| } |
| $MemberFromLink .= &addMemberLink($uname,$uname,$mdate) . ', '; |
| } |
| } |
| |
| $MemberFromLink =~ s/, \Z//; |
| ## sort result |
| $fromTitle = qq~$search_txt{'pmfrom'}: $MemberFromLink<br />~; |
| @messages = reverse sort { $a <=> $b } keys %data; |
| } |
| if (@messages) { |
| |
| if ( @messages > $display ) { $#messages = $display - 1; } |
| if ($mtouser) { |
| LoadCensorList(); |
| foreach my $uname (split(/\,/, $mtouser)) { |
| } |
| $MemberToLink .= &addMemberLink($uname,$uname,$mdate) . ', '; |
| else { |
| } |
| $yysearchmain .= |
| $MemberToLink =~ s/, \Z//; |
| qq~<hr class="hr" /> <b>$search_txt{'170'}</b><hr />~; |
| $toTitle = qq~$search_txt{'pmto'}: $MemberToLink<br />~; |
| } |
| } |
| if ( $searchtype == 5 ) { |
| |
| $search = $FORM{'search'} || $INFO{'search'}; |
| if ($mccuser && $mfromuser eq $username) { |
| @search = ($search); |
| foreach my $uname (split(/\,/, $mccuser)) { |
| } # not to display username |
| $MemberCCLink .= &addMemberLink($uname,$uname,$mdate) . ', '; |
| $search = Censor($search); |
| } |
| |
| $MemberCCLink =~ s/, \Z//; |
| # Search for censored or uncencored search string and remove duplicate words |
| $toTitleCC = qq~$search_txt{'pmcc'}: $MemberCCLink<br />~; |
| my @tmpsearch; |
| } |
| if ( $searchtype != 5 ) { |
| |
| if ( $searchtype == 3 ) { @tmpsearch = ( lc $search ); } |
| if ($mbccuser && $mfromuser eq $username) { |
| else { @tmpsearch = split /\s+/xsm, lc $search; } |
| foreach my $uname (split(/\,/, $mbccuser)) { |
| } |
| $MemberBCCLink .= &addMemberLink($uname,$uname,$mdate) . ', '; |
| push @tmpsearch, @search; |
| } |
| undef %found; |
| $MemberBCCLink =~ s/, \Z//; |
| @search = grep { !$found{$_}++ } @tmpsearch; |
| $toTitleBCC = qq~$search_txt{'pmbcc'}: $MemberBCCLink<br />~; |
| |
| } |
| ## output results |
| |
| for my $i ( 0 .. $#messages ) { |
| if ($thispmbox == 1) { |
| my ( |
| $FolderName = $pmboxes_txt{'inbox'}; |
| $thispmbox, $msgnum, $msub, $mname, |
| } elsif ($thispmbox == 2) { |
| $memail, $mdate, $mfromuser, $mtouser, |
| $FolderName = $pmboxes_txt{'outbox'}; |
| $mccuser, $mbccuser, $mattachment, $mip, |
| } elsif ($thispmbox == 3) { |
| $message, $messageid, $mstorefolder, $mstatus |
| if ($mstorefolder eq 'in') { $FolderName = $pmboxes_txt{'in'}; } |
| ) = @{ $data{ $messages[$i] } }; |
| elsif ($mstorefolder eq 'out') { $FolderName = $pmboxes_txt{'out'}; } |
| my ( $MemberFromLink, $MemberToLink, $MemberCCLink, $MemberBCCLink ); |
| else { $FolderName = $mstorefolder; } |
| my ( $fromTitle, $toTitle, $toTitleCC, $toTitleBCC, $FolderName ); |
| $FolderName = qq~$pmboxes_txt{'store'} » $FolderName~; |
| |
| } |
| if ($mfromuser) { |
| |
| foreach my $uname ( split /\,/xsm, $mfromuser ) { |
| $mdate = &timeformat($mdate); |
| my ( $guestName, $guestEmail ) = split / /sm, $uname; |
| |
| if ($guestEmail) { $uname = 'Guest'; } |
| &Highlight(\$msub,\$message,\@search,0); |
| $MemberFromLink .= |
| &MakeSmileys if $enable_ubbc && $message !~ /#nosmileys/isg; |
| addMemberLink( $uname, $guestName, $mdate ) . q{, }; |
| |
| } |
| $message = &Censor($message); |
| $MemberFromLink =~ s/, \Z//sm; |
| $msub = &Censor($msub); |
| $MemberFromLink =~ s/%20/ /gsm; |
| |
| $fromTitle = qq~$search_txt{'pmfrom'}: $MemberFromLink<br />~; |
| ++$counter; |
| } |
| |
| |
| $yysearchmain .= qq~ |
| if ($mtouser) { |
| <table border="0" width="100%" cellspacing="1" class="bordercolor" style="table-layout: fixed;"> |
| if ( $mstatus ne 'sb' ) { |
| <tr> |
| foreach my $uname ( split /\,/xsm, $mtouser ) { |
| <td align="center" width="5%" class="titlebg"> $counter </td> |
| $MemberToLink .= |
| <td align="left" width="95%" class="titlebg"> $FolderName » <a href="$scripturl?action=imshow;caller=$thispmbox;id=$messageid"><u>$msub</u></a><br /> |
| addMemberLink( $uname, $uname, $mdate ) . q{, }; |
| <span class="small">$search_txt{'30'}: $mdate</span> </td> |
| } |
| </tr> |
| $MemberToLink =~ s/, \Z//sm; |
| <tr> |
| $toTitle = qq~$search_txt{'pmto'}: $MemberToLink<br />~; |
| <td colspan="2"> |
| } |
| <table border="0" width="100%" class="catbg"> |
| else { |
| <tr> |
| require Sources::InstantMessage; |
| <td align="left"> |
| foreach my $uname ( split /\,/xsm, $mtouser ) { |
| $fromTitle |
| $MemberToLink .= links_to($uname); |
| $toTitle |
| } |
| $toTitleCC |
| $MemberToLink =~ s/, \Z//sm; |
| $toTitleBCC |
| $toTitle = qq~$search_txt{'pmto'}: $MemberToLink<br />~; |
| </td> |
| } |
| <td align="right"> <a href="$scripturl?action=imsend;caller=$thispmbox;reply=1;to=;id=$messageid">$img{'reply'}</a>$menusep<a href="$scripturl?action=imsend;caller=$thispmbox;num=;quote=1;to=;id=$messageid">$img{'recentquote'}</a> </td> |
| } |
| </tr> |
| |
| </table> |
| if ( $mccuser && $mfromuser eq $username ) { |
| </td> |
| foreach my $uname ( split /\,/xsm, $mccuser ) { |
| </tr> |
| $MemberCCLink .= |
| <tr> |
| addMemberLink( $uname, $uname, $mdate ) . q{, }; |
| <td align="left" height="80" colspan="2" class="windowbg2" valign="top"><div class="message" style="float: left; width: 99%; overflow: auto;">$message</div></td> |
| } |
| </tr> |
| $MemberCCLink =~ s/, \Z//sm; |
| </table><br /> |
| $toTitleCC = qq~$search_txt{'pmcc'}: $MemberCCLink<br />~; |
| ~; |
| } |
| } |
| |
| |
| if ( $mbccuser && $mfromuser eq $username ) { |
| $yysearchmain .= qq~ |
| foreach my $uname ( split /\,/xsm, $mbccuser ) { |
| $search_txt{'167'} |
| $MemberBCCLink .= |
| <hr class="hr" /> |
| addMemberLink( $uname, $uname, $mdate ) . q{, }; |
| ~ if @messages; |
| } |
| |
| $MemberBCCLink =~ s/, \Z//sm; |
| $yynavigation = qq~› $search_txt{'166'}~; |
| $toTitleBCC = qq~$search_txt{'pmbcc'}: $MemberBCCLink<br />~; |
| $yytitle = $search_txt{'166'}; |
| } |
| |
| |
| |
| if ( $thispmbox == 1 ) { |
| |
| $FolderName = $pmboxes_txt{'inbox'}; |
| |
| } |
| |
| elsif ( $thispmbox == 2 ) { |
| |
| $FolderName = $pmboxes_txt{'outbox'}; |
| |
| } |
| |
| elsif ( $thispmbox == 3 ) { |
| |
| if ( $mstorefolder eq 'in' ) { $FolderName = $pmboxes_txt{'in'}; } |
| |
| elsif ( $mstorefolder eq 'out' ) { |
| |
| $FolderName = $pmboxes_txt{'out'}; |
| |
| } |
| |
| else { $FolderName = $mstorefolder; } |
| |
| $FolderName = qq~$pmboxes_txt{'store'} » $FolderName~; |
| |
| } |
| |
| |
| |
| $mdate = timeformat($mdate); |
| |
| |
| |
| Highlight( \$msub, \$message, \@search, 0 ); |
| |
| if ( $enable_ubbc && $message !~ /\x23nosmileys/isgm ) { MakeSmileys(); } |
| |
| |
| |
| $message = Censor($message); |
| |
| $msub = Censor($msub); |
| |
| |
| |
| ++$counter; |
| |
| |
| |
| $yysearchmain .= $mysearch_PM; |
| |
| $yysearchmain =~ s/{yabb counter}/$counter/sm; |
| |
| $yysearchmain =~ s/{yabb FolderName}/$FolderName/sm; |
| |
| $yysearchmain =~ s/{yabb msub}/$msub/sm; |
| |
| $yysearchmain =~ s/{yabb mdate}/$mdate/sm; |
| |
| $yysearchmain =~ s/{yabb thispmbox}/$thispmbox/gsm; |
| |
| $yysearchmain =~ s/{yabb messageid}/$messageid/gsm; |
| |
| $yysearchmain =~ s/{yabb message}/$message/sm; |
| |
| $yysearchmain =~ s/{yabb fromTitle}/$fromTitle/sm; |
| |
| $yysearchmain =~ s/{yabb toTitle}/$toTitle/sm; |
| |
| $yysearchmain =~ s/{yabb toTitleCC}/$toTitleCC/sm; |
| |
| $yysearchmain =~ s/{yabb toTitleBCC}/$toTitleBCC/sm; |
| |
| |
| |
| } |
| |
| |
| |
| if (@messages) { |
| |
| $yysearchmain .= qq~ |
| |
| $search_txt{'167'} |
| |
| <hr class="hr" /> |
| |
| ~; |
| |
| } |
| |
| |
| |
| $yynavigation = qq~› $search_txt{'166'}~; |
| |
| $yytitle = $search_txt{'166'}; |
| |
| return; |
| } |
| } |
| |
| |
| sub addMemberLink { |
| sub addMemberLink { |
| my ($user,$displayname,$mdate) = @_; |
| my ( $user, $displayname, $mdate ) = @_; |
| if (-e "$memberdir/$user.vars") { &LoadUser($user); } |
| if ( -e "$memberdir/$user.vars" ) { LoadUser($user); } |
| if (${$uid.$user}{'regdate'} && $mdate >= (${$uid.$user}{'regtime'} || $date)) { |
| if ( ${ $uid . $user }{'regdate'} |
| $mname = qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$user}">${$uid.$user}{'realname'}</a>~; |
| && $mdate >= ( ${ $uid . $user }{'regtime'} || $date ) ) |
| } elsif ($user !~ m~Guest~ && $mdate < (${$uid.$user}{'regtime'} || $date)) { |
| { |
| $mname = qq~$displayname - $maintxt{'470a'}~; |
| if ( $iamguest) { |
| } else { |
| $mname = $format_unbold{$user}; |
| $mname = $user . " ($maintxt{'28'})"; |
| } |
| } |
| else { |
| $mname; |
| $mname = |
| |
| qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$user}">$format_unbold{$user}</a>~; |
| |
| } |
| |
| } |
| |
| elsif ($user !~ m/Guest/sm |
| |
| && $mdate < ( ${ $uid . $user }{'regtime'} || $date ) ) |
| |
| { |
| |
| $mname = qq~$displayname - $maintxt{'470a'}~; |
| |
| } |
| |
| else { |
| |
| $mname = $displayname . " ($maintxt{'28'})"; |
| |
| } |
| |
| return $mname; |
| } |
| } |
| |
| |
| sub Highlight { |
| sub Highlight { |
| my ($msub,$message,$search,$case) = @_; |
| my ( $msub, $message, $search, $case ) = @_; |
| my $i = 0; |
| my $i = 0; |
| my @HTMLtags; |
| my @HTMLtags; |
| my $HTMLtag = 'HTML'; |
| my $HTMLtag = 'HTML'; |
| while ($$message =~ /\[$HTMLtag\d+\]/) { $HTMLtag .= '1'; } |
| while ( ${$message} =~ /\[$HTMLtag\d+\]/sm ) { $HTMLtag .= '1'; } |
| while ($$message =~ s/(<.+?>)/[$HTMLtag$i]/s) { push(@HTMLtags, $1); $i++; } |
| while ( ${$message} =~ s/(<.+?>)/[$HTMLtag$i]/sm ) { |
| |
| push @HTMLtags, $1; |
| foreach my $tmp (@$search) { |
| $i++; |
| if ($case) { |
| } |
| if ($searchtype == 4) { |
| |
| $$msub =~ s~(\Q$tmp\E)~<span class="highlight">$1</span>~g; |
| foreach my $tmp ( @{$search} ) { |
| $$message =~ s~(\Q$tmp\E)~<span class="highlight">$1</span>~g; |
| if ($case) { |
| } else { |
| if ( $searchtype == 4 ) { |
| $$msub =~ s~(^|\W|_)(\Q$tmp\E)(?=$|\W|_)~$1<span class="highlight">$2</span>$3~g; |
| ${$msub} =~ s/(\Q$tmp\E)/<span class="highlight">$1<\/span>/gsm; |
| $$message =~ s~(^|\W|_)(\Q$tmp\E)(?=$|\W|_)~$1<span class="highlight">$2</span>$3~g; |
| ${$message} =~ s/(\Q$tmp\E)/<span class="highlight">$1<\/span>/gsm; |
| } |
| } |
| } else { |
| else { |
| if ($searchtype == 4) { |
| ${$msub} =~ s/(^|\W|_)(\Q$tmp\E)(?=$|\W|_)/$1<span class="highlight">$2<\/span>$3/gsm; |
| $$msub =~ s~(\Q$tmp\E)~<span class="highlight">$1</span>~ig; |
| ${$message} =~ s/(^|\W|_)(\Q$tmp\E)(?=$|\W|_)/$1<span class="highlight">$2<\/span>$3/gsm; |
| $$message =~ s~(\Q$tmp\E)~<span class="highlight">$1</span>~ig; |
| } |
| } else { |
| } |
| $$msub =~ s~(^|\W|_)(\Q$tmp\E)(?=$|\W|_)~$1<span class="highlight">$2</span>$3~ig; |
| else { |
| $$message =~ s~(^|\W|_)(\Q$tmp\E)(?=$|\W|_)~$1<span class="highlight">$2</span>$3~ig; |
| if ( $searchtype == 4 ) { |
| } |
| ${$msub} =~ s/(\Q$tmp\E)/<span class="highlight">$1<\/span>/igsm; |
| } |
| ${$message} =~ s/(\Q$tmp\E)/<span class="highlight">$1<\/span>/igsm; |
| } |
| } |
| |
| else { |
| |
| ${$msub} =~ s/(^|\W|_)(\Q$tmp\E)(?=$|\W|_)/$1<span class="highlight">$2<\/span>$3/igsm; |
| |
| ${$message} =~ s/(^|\W|_)(\Q$tmp\E)(?=$|\W|_)/$1<span class="highlight">$2<\/span>$3/igsm; |
| |
| } |
| |
| } |
| |
| } |
| |
| |
| |
| $i = 0; |
| |
| while ( ${$message} =~ s/\[$HTMLtag$i\]/$HTMLtags[$i]/xsm ) { $i++; } |
| |
| return; |
| |
| } |
| |
| |
| |
| sub case_subfound { |
| |
| my ( $case, $searchtype, $msub ) = @_; |
| |
| $subfound = 0; |
| |
| foreach (@search) { |
| |
| if ( $case |
| |
| && $searchtype == 4 |
| |
| && $msub =~ m{\Q$_\E}xsm ) |
| |
| { |
| |
| $subfound = 1; |
| |
| last; |
| |
| } |
| |
| elsif ( !$case |
| |
| && $searchtype == 4 |
| |
| && $msub =~ m{\Q$_\E}ixsm ) |
| |
| { |
| |
| $subfound = 1; |
| |
| last; |
| |
| } |
| |
| if ( $case |
| |
| && $msub =~ m{(^|\W|_)\Q$_\E(?=$|\W|_)}xsm ) |
| |
| { |
| |
| $subfound = 1; |
| |
| last; |
| |
| } |
| |
| elsif ( !$case |
| |
| && $msub =~ m{(^|\W|_)\Q$_\E(?=$|\W|_)}ixsm ) |
| |
| { |
| |
| $subfound = 1; |
| |
| last; |
| |
| } |
| |
| } |
| |
| return $subfound; |
| |
| } |
| |
| |
| $i = 0; |
| sub case_subfound2 { |
| while ($$message =~ s/\[$HTMLtag$i\]/$HTMLtags[$i]/s) { $i++; } |
| my ( $case, $msub ) = @_; |
| |
| $subfound = 1; |
| |
| foreach (@search) { |
| |
| if ( $case |
| |
| && $msub !~ m{(^|\W|_)\Q$_\E(?=$|\W|_)}xsm ) |
| |
| { |
| |
| $subfound = 0; |
| |
| last; |
| |
| } |
| |
| elsif ( !$case |
| |
| && $msub !~ m{(^|\W|_)\Q$_\E(?=$|\W|_)}ixsm ) |
| |
| { |
| |
| $subfound = 0; |
| |
| last; |
| |
| } |
| |
| } |
| |
| return $subfound; |
| } |
| } |
| |
| |
| 1; |
| sub msgfnd { |
| |
| my ( $searchtype, $message ) = @_; |
| |
| $msgfound = 0; |
| |
| foreach (@search) { |
| |
| if ( $searchtype == 4 && $message =~ m{\Q$_\E}ixsm ) { |
| |
| $msgfound = 1; |
| |
| last; |
| |
| } |
| |
| elsif ( $message =~ m{(^|\W|_)\Q$_\E(?=$|\W|_)}ixsm ) { |
| |
| $msgfound = 1; |
| |
| last; |
| |
| } |
| |
| } |
| |
| return $msgfound; |
| |
| } |
| |
| |
| |
| sub msgfnd2 { |
| |
| my ($message) = @_; |
| |
| $msgfound = 1; |
| |
| foreach (@search) { |
| |
| if ( $message !~ m{(^|\W|_)\Q$_\E(?=$|\W|_)}ixsm ) { |
| |
| $msgfound = 0; |
| |
| last; |
| |
| } |
| |
| } |
| |
| return $msgfound; |
| |
| } |
| |
| 1; |
| |
| |