function nntp_search($stream, $group, $search, $threaded = TRUE) { // print("<p>nntp_search(stream=$stream, group='$group', search='$search'</p>\n"); // Get the start and end messages in the group... $status = nntp_command($stream, "GROUP {$group}", 211); if ((int) $status != 211) { nntp_error("We were unable to open the forum '{$group}' for the following " . "reason:", $status, $group); return NULL; } // Read the messages in the group... $fields = explode(" ", $status); $status = nntp_command($stream, "XOVER {$fields['2']}-{$fields['3']}", 224); if ((int) $status != 224) { nntp_error("We were unable to search the forum '{$group}' for the following " . "reason:", $status, $group); return NULL; } $words = html_search_words($search); $num_matches = 0; $matches = NULL; while ($line = fgets($stream, 1024)) { $line = rtrim($line); if ($line == ".") { break; } // print("<pre>" . htmlspecialchars($line) . "</pre>\n"); if ($search == "") { // Return all matches... $matches[$num_matches] = $line; $num_matches++; } else { // Search for words... reset($words); $fields = explode("\t", $line); foreach ($words as $word) { if (stristr($fields[1], $word) || stristr($fields[2], $word)) { $matches[$num_matches] = $line; $num_matches++; break; } } } } if ($threaded) { // Thread the articles... $threads = array(); $parents = array(); for ($i = 0; $i < sizeof($matches); $i++) { $fields = explode("\t", $matches[$i]); $subject = eregi_replace("(re:|\\[[a-z]+\\.[a-z]+\\]) ", "", $fields[1]); if (array_key_exists($subject, $parents)) { $threads[$i] = sprintf("%06d%06d", $parents[$subject], $i); } else { $parents["{$subject}"] = $i; $threads[$i] = sprintf("%06d%06d", $i, $i); } } array_multisort($threads, SORT_NUMERIC, $matches); } // Return the matches... return $matches; }
} else { $email = ""; } if ($LOGIN_LEVEL >= AUTH_DEVEL) { $query .= "{$prefix}(manager_email = '' OR manager_email = '{$email}')"; $prefix = " AND "; } else { if ($email != "") { $query .= "{$prefix}create_user = '******'"; $prefix = " AND "; } } } if ($search) { // Convert the search string to an array of words... $words = html_search_words($search); // Loop through the array of words, adding them to the query... $query .= "{$prefix}("; $prefix = ""; $next = " OR"; $logic = ""; reset($words); foreach ($words as $word) { if ($word == "or") { $next = ' OR'; if ($prefix != '') { $prefix = ' OR'; } } else { if ($word == "and") { $next = ' AND';