[2.2] Ähnliche Themen

rellek

relativ sensationell
Teammitglied
Zur Zeit wird nur nach Foren gesucht, in denen man das Recht hat auch Themen zu lesen.

Du könntest es höchstens so einstellen, dass nur in bestimmten Foren gesucht wird (was zwar eine DB-Abfrage spart, aber nicht nach Rechten prüft).

Bei Interesse sag ich dir, wie.
 

Anubis

[inaktiv]
Original von rellek
Zur Zeit wird nur nach Foren gesucht, in denen man das Recht hat auch Themen zu lesen.

Du könntest es höchstens so einstellen, dass nur in bestimmten Foren gesucht wird (was zwar eine DB-Abfrage spart, aber nicht nach Rechten prüft).

Bei Interesse sag ich dir, wie.

Das wäre echt cool, die prüfung nach rechten ist für mich eh überflüssig da bei
mir alle sektionen von allen usern angesehen werden können.

Jo, wäre sehr sehr nett, wenn du mir da weiterhelfen könntest, thx!
 

rellek

relativ sensationell
Teammitglied
OK, bei der SQL-Abfrage (was mit $db->query losgeht), steht u.a. folgendes:
Code:
AND t.boardid IN (0".GetAccessableForums().")
das änderst du in:
Code:
AND t.boardid IN (0,x,y,...,n)
und anstatt "x,y,...,n" schreibst du die Board-IDs der Foren, in denen gesucht werden soll.
Die IDs bekommst du aus dem Link. z.B. hier das wBB-Hack-Forum hat folgenden Link:
http://board.rellek.org/board.php?boardid=129
Und da ist 129 die Zahl, die da rein muss usw.. Die Zahlen einfach mit Komma abtrennen.
 

rellek

relativ sensationell
Teammitglied
Für alle mit mySQL 5-Problemen!!!

Ersetze die Codestelle in der thread.php damit:
Code:
/* Ähnliche Themen */
function GetAccessableForums() {
	global $db, $n, $wbbuserdata, $boardcache;
	
	if (!isset($boardcache) || !is_array($boardcache)) $boardcache = array();
	$result = $db->query("SELECT boardid,boardorder,parentid,parentlist FROM bb".$n."_boards ORDER BY parentid ASC, boardorder ASC");
	while ($row = $db->fetch_array($result)) {
		$boardcache[$row['parentid']][$row['boardorder']][$row['boardid']] = $row;
	}

	$boardpermissions = getPermissions();
	$boardids = '';
	foreach ($boardcache as $key => $val) {
		foreach ($val as $key2 => $val2) {
			foreach ($val2 as $row) if ((!isset($boardpermissions[$row['boardid']]['can_view_board']) || $boardpermissions[$row['boardid']]['can_view_board'] != 0) && (!isset($boardpermissions[$row['boardid']]['can_enter_board']) || $boardpermissions[$row['boardid']]['can_enter_board'] != 0) && (!isset($boardpermissions[$row['boardid']]['can_read_thread']) || $boardpermissions[$row['boardid']]['can_read_thread'] != 0)) $boardids .= ",".$row['boardid'];
		}	
	}
	return $boardids;
}

/* Unset Used Vars To Avoid Hacking Attempts */
unset($similar_thread_bit);
unset($like_string);

$ttopic = str_replace("."," ",$threadtopic);
$ttopic = str_replace("!"," ",$ttopic);
$ttopic = str_replace("?"," ",$ttopic);
$ttopic = str_replace("/"," ",$ttopic);
$ttopic = str_replace("§"," ",$ttopic);
$ttopic = str_replace("$"," ",$ttopic);
$ttopic = str_replace("%"," ",$ttopic);
$ttopic = str_replace("&"," ",$ttopic);
$ttopic = str_replace("("," ",$ttopic);
$ttopic = str_replace(")"," ",$ttopic);
$ttopic = str_replace("="," ",$ttopic);
$ttopic = str_replace("\\"," ",$ttopic);
$ttopic = str_replace("?"," ",$ttopic);
$ttopic = str_replace("-"," ",$ttopic);
$ttopic = str_replace("*"," ",$ttopic);
$ttopic = str_replace("+"," ",$ttopic);
$ttopic = str_replace("#"," ",$ttopic);
$ttopic = str_replace("_"," ",$ttopic);
$ttopic = str_replace(","," ",$ttopic);
$ttopic = str_replace(":"," ",$ttopic);
$ttopic = str_replace(";"," ",$ttopic);
$ttopic = str_replace("<"," ",$ttopic);
$ttopic = str_replace(">"," ",$ttopic);
$ttopic = str_replace("|"," ",$ttopic);
$ttopic = str_replace("~"," ",$ttopic);
$ttopic = str_replace("'"," ",$ttopic);
$ttopic = str_replace('"',' ',$ttopic);
$ttopic = explode(" ",$ttopic);
$badwordlist = explode("\n",$badsearchwords);
$y = count($ttopic);
if($y>1) {
  foreach($ttopic as $tt) {
  	if(!in_array($tt, $badwordlist)) {
  		if(strlen($tt)>=$minwordlength && strlen($tt)<=$maxwordlength) $x++;
  		if($x>1 && (strlen($tt)>=$minwordlength && strlen($tt)<=$maxwordlength)) $like_string .= " OR t.topic LIKE ";
  		if(strlen($tt)>=$minwordlength && strlen($tt)<=$maxwordlength) $like_string .= "'%".$tt."%'";
  }
}
} else $like_string = "'%$threadtopic%'";
if($like_string) {
	$similar = $db->query("SELECT
                      t.threadid, t.boardid, x.title, x.boardid, t.prefix, t.topic, t.starttime, t.starterid, t.starter, t.lastposttime, t.lastposterid, t.lastposter, t.replycount, t.views, t.attachments, t.closed, t.important, t.pollid
                      FROM bb".$n."_threads t, bb".$n."_boards x
                      WHERE t.visible='1'
                      AND t.closed <> 3
                      AND t.threadid <> $threadid
                      AND x.password=''
                      AND t.boardid=x.boardid
                      AND t.boardid IN (0".GetAccessableForums().")
                      AND (t.topic LIKE ".$like_string.")
                      ORDER BY t.lastposttime DESC
                      LIMIT 0, 5;");
	}
if($like_string && $db->num_rows($similar)) {
	$i = "0";
	while ($row = $db->fetch_array($similar)) {
		$i++;
		$tdclass = getone($i, "tablea", "tableb");
		$started = formatdate($wbbuserdata['dateformat'], $row['starttime'],1);
		$started .= " <span class=\"time\">".formatdate($wbbuserdata['timeformat'], $row['starttime'])."</span>";
		$lastreply = formatdate($wbbuserdata['dateformat'], $row['lastposttime'],1);
		$lastreply .= " <span class=\"time\">".formatdate($wbbuserdata['timeformat'], $row['lastposttime'])."</span>";
		if ($row['replycount'] >= 1000) $row['replycount'] = number_format($row['replycount'], 0, "", $lang->get("LANG_GLOBAL_THOUSANDS_SEP"));
		if ($row['views'] >= 1000) $row['views'] = number_format($row['views'], 0, "", $lang->get("LANG_GLOBAL_THOUSANDS_SEP"));
		if (strlen($row['topic']) > 60) $row['topic'] = substr($row['topic'], 0, 54).' [...]';
		$row['topic'] = htmlconverter($row['topic']);
		eval("\$similar_thread_bit .= \"".$tpl->get("thread_similarthread_bit")."\";");
	}
	eval("\$similar_thread = \"".$tpl->get("thread_similarthread")."\";");
}
/* Ähnliche Themen Ende */
 
Oben