'; echo ''.basename(getcwd()).' / '; echo 'search'; echo ''; // View Latest button if (isset($overboard) && ($overboard == true)) { echo ''; } else { // echo htmlspecialchars($CONFIG['title_full']); } if(isset($_GET['group'])) { $searching = $_GET['group']; } else { $searching = $config_name; } echo ''; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; if(isset($_GET['group'])) { echo ''; } echo ''; ?>
Search recent messages
(Body searches '.$searching.' - Subject, Poster, Message-ID search entire site)
Search Terms: '; echo '
'; if ($_GET['searchpoint'] == 'Poster') { if($CONFIG['article_database'] == '1') { echo 'Body '; } echo 'Subject '; echo 'Poster '; echo 'Message-ID'; } else { if($CONFIG['article_database'] == '1') { echo ' Body '; } echo 'Subject '; echo 'Poster '; echo 'Message-ID'; } echo '
'.$grouplist[0].' (latest)'; echo ''; // Article List button echo ''; // Newsgroups button (hidden) echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; } else { echo '

'; echo ''.basename(getcwd()).' / '; echo 'search results for: '.$_POST['terms'].'

'; echo ''; // Newsgroups button (hidden) echo ''; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; } echo ''; # Iterate through groups $results=0; if(isset($_COOKIE['tzo'])) { $offset=$_COOKIE['tzo']; } else { $offset=$CONFIG['timezone']; } $overview = array(); if($_POST['searchpoint'] == 'body') { $overview = get_body_search($group, $_POST['terms']); } else { $overview = get_header_search($group, $_POST['terms']); } foreach($overview as $overviewline) { /* Find section for links */ $menulist = file($config_dir."menu.conf", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach($menulist as $menu) { if($menu[0] == '#') { continue; } $menuitem=explode(':', $menu); $glfp=fopen($config_dir.$menuitem[0]."/groups.txt", 'r'); $section=""; while($gl=fgets($glfp)) { $group_name = preg_split("/( |\t)/", $gl, 2); if(stripos(trim($overviewline['newsgroup']), trim($group_name[0])) !== false) { $section=$menuitem[0]; break 2; } } } fclose($glfp); # Generate link $url = "../".$section."/article-flat.php?id=".$overviewline['number']."&group="._rawurlencode($overviewline['newsgroup'])."#".$overviewline['number']; $groupurl = "../".$section."/thread.php?group="._rawurlencode($overviewline['newsgroup']); $fromoutput = explode("<", html_entity_decode($overviewline['name'])); // Use local timezone if possible $ts = new DateTime(date($text_header["date_format"], $overviewline['date']), new DateTimeZone('UTC')); $ts->add(DateInterval::createFromDateString($offset.' minutes')); if($offset != 0) { $newdate = $ts->format('D, j M Y H:i'); } else { $newdate = $ts->format($text_header["date_format"]); } unset($ts); $fromline=address_decode(headerDecode($overviewline['name']),"nirgendwo"); if (!isset($fromline[0]["personal"])) { $lastname=$fromline[0]["mailbox"];; } else { $lastname=$fromline[0]["personal"]; } if(($results % 2) != 0){ echo ''; if($results++ > ($maxdisplay - 2)) break; // } } echo '
'; } else { echo '
'; } echo '

'; echo ''.htmlspecialchars(mb_decode_mimeheader($overviewline['subject']))."\r\n"; echo '

'; echo ''.$overviewline['newsgroup'].''; echo '

'; $articlefrom[0] = $overviewline['name']; $fromoutput = explode("<", html_entity_decode($articlefrom[0])); // Just an email address? if(strlen($fromoutput[0]) < 2) { preg_match("/\<([^\)]*)\@/", html_entity_decode($articlefrom[0]), $fromaddress); $fromoutput[0] = $fromaddress[1]; } if(strpos($fromoutput[0], "(")) { preg_match("/\(([^\)]*)\)/", html_entity_decode($articlefrom[0]), $fromaddress); $fromoutput[0] = $fromaddress[1]; } if((isset($CONFIG['hide_email']) && $CONFIG['hide_email'] == true) && (strpos($fromoutput[0], '@') !== false)) { $poster_name = truncate_email($fromoutput[0]); } else { $poster_name = $fromoutput[0]; } $poster_name = trim($poster_name, "\""); echo '

Posted: '.$newdate.' by: '.create_name_link(mb_decode_mimeheader(mb_decode_mimeheader($poster_name))).'

'; if($_POST['searchpoint'] == 'body') { $snip = strip_tags(mb_decode_mimeheader($overviewline['snippet']), ''); echo $snip; } echo '
'; echo "

".$results." matching articles found.

\r\n"; #echo "
Rocksolid Overboard version ".$version; include "tail.inc"; $thispage = ob_get_contents(); ob_end_clean(); echo $thispage; function get_body_search($group, $terms) { GLOBAL $CONFIG, $config_name, $spooldir; $terms = trim($terms); if($terms[0] !== '"' && substr($terms, -1) !== '"') { $terms = preg_replace('/"/', '', $terms); $terms = preg_replace('/\ /', '" "', $terms); $terms = preg_replace('/"NEAR"/', 'NEAR', $terms); $terms = preg_replace('/"AND"/', 'AND', $terms); $terms = preg_replace('/"OR"/', 'OR', $terms); $terms = preg_replace('/"NOT"/', 'NOT', $terms); $terms = '"'.$terms.'"'; } if(isset($_POST['group'])) { $grouplist[0] = $_POST['group']; } else { $local_groupfile=$spooldir."/".$config_name."/local_groups.txt"; $grouplist = file($local_groupfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); } foreach($grouplist as $thisgroup) { $name = explode(':', $thisgroup); $group=$name[0]; $database = $spooldir.'/'.$group.'-articles.db3'; $dbh = article_db_open($database); $stmt = $dbh->prepare("SELECT snippet(search_fts, 6, '', '', '...', 50) as snippet, newsgroup, number, name, date, subject, rank FROM search_fts WHERE search_fts MATCH 'search_snippet:$terms' ORDER BY rank"); $stmt->execute(); while ($row = $stmt->fetch()) { $overview[] = $row; } $dbh = null; } usort($overview, function($a, $b) { return $a['rank'] <=> $b['rank']; }); return $overview; } function get_header_search($group, $terms) { GLOBAL $CONFIG, $spooldir; $searchterms = "%".$terms."%"; # Prepare search database $database = $spooldir.'/articles-overview.db3'; $table = 'overview'; $dbh = rslight_db_open($database, $table); if($dbh) { if(is_multibyte($_POST['terms'])) { $stmt = $dbh->query("SELECT * FROM $table"); while($row = $stmt->fetch()) { if(stripos(quoted_printable_decode(mb_decode_mimeheader($row[$_POST['searchpoint']])), $_POST['terms']) !== false) { $overview[] = $row; } } } else { $stmt = $dbh->prepare("SELECT * FROM $table WHERE ".$_POST['searchpoint']." like :terms ORDER BY date DESC"); $stmt->bindParam(':terms', $searchterms); $stmt->execute(); while($found = $stmt->fetch()) { $overview[] = $found; } } $dbh = null; } return $overview; } function highlightStr($haystack, $needle) { preg_match_all("/$needle+/i", $haystack, $matches); if (is_array($matches[0]) && count($matches[0]) >= 1) { foreach ($matches[0] as $match) { $haystack = str_replace($match, ''.$match.'', $haystack); } } return $haystack; } ?>