/*
# UBB.threads, Version 6
# Official Release Date for UBB.threads Version6: 06/05/2002
# First version of UBB.threads created July 30, 1996 (by Rick Baker).
# This entire program is copyright Groupee, Inc., 2005.
# For more info on UBB.threads and other Groupee Services
# visit http://www.groupee.com/ & http://www.ubbcentral.com/
# Program Author: Rick Baker.
# File Version 6.5.5
# You may not distribute this program in any manner, modified or otherwise,
# without the express, written written consent from Groupee, Inc..
# Note: if you modify ANY code within UBB.threads, we at Groupee, Inc.
# cannot offer you support-- thus modify at your own peril :)
# ---------------------------------------------------------------------------
*/
// Require the library
require ("./includes/main.inc.php");
require ("languages/{$_SESSION['myprefs']['language']}/search.php");
// -------------
// Get the input
$Cat = get_input("Cat","get","cat");
// -------------------------
// Predefine a few variables
$referer = "";
$board = "";
$groupquery = "";
$catonly = "";
$initialcat = "";
$options = "";
// -----------------
// Get the user info
$userob = new user;
$html = new html;
$user = $userob -> authenticate("U_Groups");
if (!$user['U_Groups']) {
$user['U_Groups'] = "-4-";
if (!isset($config['guestsearch']) || !$config['guestsearch']) {
$html->not_right($ubbt_lang['NO_SEARCH'],$Cat);
}
}
// ------------------------------------------------------------------------
// Let's figure out if they were on a forum, so we can default to searching
// that forum
$referer = find_environmental ("HTTP_REFERER");
if ($referer!="") {
if (preg_match("#/Board/#",$referer)){
preg_match("#Board/(.*)#",$referer,$piece);
}else{
preg_match("#Board=(.*)#",$referer,$piece);
}
if (isset($piece['1'])) {
$referer = $piece['1'];
$board = $referer;
if (stristr($referer,"&")) {
list ($board,$crap) = split("&",$referer);
}
if (stristr($referer,"/")) {
list ($board,$crap) = split("/",$referer);
}
}
}
// ---------------------
// Give them the search
$html -> send_header($ubbt_lang['TEXT_SEARCH'],$Cat,0,$user);
// ---------------
// Grab the forums
// -----------------------------------------------
// If we have a Cat variable we only search those
if ($Cat) {
$Cat = preg_replace("/[^\d,]/","",$Cat);
$pattern = ",";
$replace = " OR t1.Bo_Cat = ";
$thiscat = str_replace($pattern,$replace,$Cat);
$catonly = "AND (t1.Bo_Cat = $thiscat )";
}
// --------------------------------------------------------------
// We need to format a portion of the SQL query depending on what
// groups this user is in
$Grouparray = split("-",$user['U_Groups']);
$gsize = sizeof($Grouparray);
$g = 0;
for ($i=0; $i<=$gsize; $i++) {
if (!isset($Grouparray[$i])) { continue; }
if (!preg_match("/[0-9]/",$Grouparray[$i])) { continue; }
$g++;
if ($g > 1) {
$groupquery .= " OR ";
}
$groupquery .= "t1.Bo_Read_Perm LIKE '%-$Grouparray[$i]-%'";
}
$query = "
SELECT t1.Bo_Number,t1.Bo_Title,t1.Bo_Keyword,t1.Bo_Cat,t1.Bo_CatName,t1.Bo_Sorter
FROM {$config['tbprefix']}Boards AS t1,
{$config['tbprefix']}Category AS t2
WHERE ($groupquery)
AND t1.Bo_Active = '1'
AND t1.Bo_Cat = t2.Cat_Entry
$catonly
ORDER BY t2.Cat_Number,t1.Bo_Sorter
";
$sth = $dbh -> do_query($query,__LINE__,__FILE__);
while (list($Bo_Number,$Bo_Title,$Bo_Keyword,$Bo_Cat,$Bo_CatName,$Bo_Sorter) = $dbh -> fetch_array($sth)) {
if ($initialcat != $Bo_Cat) {
$forum = 0;
$initialcat = $Bo_Cat;
}
$catarray[$Bo_Cat] = $Bo_CatName;
$forumarray[$Bo_Cat][$forum]['BoNum'] = $Bo_Number;
$forumarray[$Bo_Cat][$forum]['BoTitle'] = $Bo_Title;
$forumarray[$Bo_Cat][$forum]['BoKeyword'] = $Bo_Keyword;
$forum++;
}
$allselected = "selected=\"selected\"";
while(list($catnum,$catname) = each($catarray)) {
$options .= "";
for($j=0;$j {$forumarray[$catnum][$j]['BoTitle']}";
}
}
// What type of range?
$config['rangetype'] = $ubbt_lang[$config['rangetype']];
if ($config['rangevalue'] == 1) {
$config['rangetype'] = preg_replace("/s$/","",$config['rangetype']);
}
// ---------------------
// Grab the tablewrapper
list($tbopen,$tbclose) = $html -> table_wrapper();
if (!$debug) {
include("$thispath/templates/$tempstyle/search.tmpl");
}
$html -> send_footer();
?>