'; echo ''.basename(getcwd()).' / '; echo 'search'; echo ''; if(isset($_GET['group'])) { $searching = $_GET['group']; } else { $searching = $config_name; } echo ''; echo '
'; echo ''; echo ''; echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; if(!isset($_REQUEST['data'])) { echo ''; echo ''; echo ''; echo ''; if(isset($_GET['group'])) { echo ''; } echo ''; if(isset($_GET['data'])) { echo ''; } echo ''; echo ''; echo '
Searching '.$searching.'
Search Terms: '; } else { echo 'Search Poster: '; } 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 '
'; exit(0); } if(isset($frames_on) && $frames_on === true) { ?> '.$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 { if(isset($_REQUEST['data'])) { $overview = get_header_search($group, base64_decode(urldecode($_REQUEST['data']))); } 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 '

'; $fromline = address_decode($overviewline['name'],"nirgendwo"); if (!isset($fromline[0]["host"])) $fromline[0]["host"]=""; $name_from=$fromline[0]["mailbox"]."@".$fromline[0]["host"]; $name_username=$fromline[0]["mailbox"]; if (!isset($fromline[0]["personal"])) { $poster_name=$fromline[0]["mailbox"]; } else { $poster_name=$fromline[0]["personal"]; } if(trim($poster_name) == '') { $fromoutput = explode("<", html_entity_decode($c->name)); if(strlen($fromoutput[0]) < 1) { $poster_name = $fromoutput[1]; } else { $poster_name = $fromoutput[0]; } } $poster_name = trim(mb_decode_mimeheader($poster_name), " \n\r\t\v\0\""); echo '

Posted: '.$newdate.' by: '.create_name_link($poster_name, $name_from).'

'; if($_POST['searchpoint'] == 'body') { $snip = strip_tags(quoted_printable_decode($overviewline['snippet']), ''); } else { $snip = strip_tags(quoted_printable_decode($overviewline['search_snippet']), ''); $snip = substr($snip, 0, $snippet_size); } 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, $snippet_size; $terms = preg_replace("/'/", ' ', $terms); $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'; if(!is_file($database)) { continue; } $dbh = article_db_open($database); $stmt = $dbh->prepare("SELECT snippet(search_fts, 6, '', '', '...', $snippet_size) 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, $config_name, $spooldir, $snippet_size; $terms = preg_replace('/\%/', '\%', $terms); $searchterms = "%".$terms."%"; if(isset($_POST['group']) && $_POST['searchpoint'] != 'msgid') { $grouplist[0] = $_POST['group']; } elseif($_POST['searchpoint'] != 'msgid') { $local_groupfile=$spooldir."/".$config_name."/local_groups.txt"; $grouplist = file($local_groupfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); } else { $local_groupfile=$spooldir."/spoolnews/groups.txt"; $grouplist = file($local_groupfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); } # Prepare search database $database = $spooldir.'/articles-overview.db3'; $table = 'overview'; $dbh = rslight_db_open($database, $table); $overview = array(); foreach($grouplist as $thisgroup) { $name = explode(':', $thisgroup); $group=$name[0]; $article_database = $spooldir.'/'.$group.'-articles.db3'; if(!is_file($article_database)) { continue; } $article_dbh = article_db_open($article_database); $article_stmt = $article_dbh->prepare("SELECT * FROM articles WHERE number=:number"); if(is_multibyte($_POST['terms'])) { $stmt = $dbh->prepare("SELECT * FROM $table WHERE newsgroup=:group"); $stmt->bindParam(':group', $group); $stmt->execute(); while($found = $stmt->fetch()) { if(stripos(mb_decode_mimeheader($found[$_POST['searchpoint']]), $_POST['terms']) !== false) { $article_stmt->bindParam(':number', $found['number']); $article_stmt->execute(); $found_snip = $article_stmt->fetch(); $found['search_snippet'] = $found_snip['search_snippet']; $found['sort_date'] = $found_snip['date']; $overview[] = $found; } } } else { $stmt = $dbh->prepare("SELECT * FROM $table WHERE newsgroup=:group AND ".$_POST['searchpoint']." like :terms ESCAPE '\' ORDER BY date DESC"); $stmt->bindParam(':group', $group); $stmt->bindParam(':terms', $searchterms); $check = "/([a-z]|[0-9]|\!|#|\$|\%|\&|\'|\*|\+|\-|\/|\=|\?|\^|\_|\"|\`|\{|\||\}|\~|\;)".trim($searchterms, '\%')."/i"; $stmt->execute(); while($found = $stmt->fetch()) { if(isset($_REQUEST['data']) && ($_REQUEST['searchpoint'] == 'name')) { if(preg_match($check, $found['name'])) { continue; } } $article_stmt->bindParam(':number', $found['number']); $article_stmt->execute(); $found_snip = $article_stmt->fetch(); $found['search_snippet'] = $found_snip['search_snippet']; $found['sort_date'] = $found_snip['date']; $overview[] = $found; } } $article_dbh = null; } $dbh = null; usort($overview, function($b, $a) { return $a['sort_date'] <=> $b['sort_date']; }); 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; } ?>