prepare($qry)) {
$stmt->bind_param("i", $userID);
$stmt->execute();
$catres = $stmt->get_result();
while ($catrow = $catres->fetch_assoc()) {
$replace = array(
"###BOARDCATS.CAT.ID###" => $catrow["ID"],
"###BOARDCATS.CAT.NAME###" => $catrow["name"],
"###BOARDCATS.CAT.DESC###" => $catrow["description"]
);
$cat = tplReplMarkerArray($tpl["cat"], $replace);
$threads = "";
$qry = "SELECT m.ID, m.dttm, m.title, m.text, g.prenames, g.surnames, "
."(SELECT COUNT(*) FROM board_messages ms WHERE ms.rootID=m.ID) replies "
."FROM board_messages m LEFT JOIN guests g ON g.ID = m.guestID "
."WHERE m.parentID IS NULL AND m.categoryID = ".$catrow["ID"]." "
."ORDER BY m.dttm DESC";
if ($thrres = $mysqli->query($qry)) {
if ($thrres->num_rows==0) {
$threads = $tpl["nothreads"];
} else {
while ($thrrow = $thrres->fetch_assoc()) {
$thread = tplReplMarker($tpl["thread"], "###BOARDCATS.CAT.THREAD.MSG###", tplExtrSection(tplLoadFile("pgs/board/msg.html"), "###BOARDMSG###"));
$thread = tplReplSection($thread, "###BOARDMSG.FOOTER###", "");
$thread = tplReplSection($thread, "###BOARDMSG.INDENT.IN###", "");
$thread = tplReplSection($thread, "###BOARDMSG.INDENT.OUT###", "");
preg_match_all("/([\s-]?)([A-Z])/", $thrrow["surnames"], $matches);
$replace = array(
"###BOARDMSG.ID###" => $thrrow["ID"],
"###BOARDMSG.TITLE###" => cntCipherTextSym($thrrow["title"], SYM_CIPHER_KEY),
"###BOARDMSG.AUTHOR###" => $thrrow["prenames"]." ".implode(".", $matches[0]).".",
"###BOARDMSG.DATETIME###" => $thrrow["dttm"],
"###BOARDMSG.LEVEL###" => 0
);
$decText = cntCipherTextSym($thrrow["text"], SYM_CIPHER_KEY);
if (strlen($decText)>33) {
$replace["###BOARDMSG.TEXT###"] = substr($decText, 0, 30)."...
".$thrrow["replies"]." Antwort".($thrrow["replies"]!="1" ? "en" : "")."";
} else {
$replace["###BOARDMSG.TEXT###"] = $decText."
".$thrrow["replies"]." Antwort".($thrrow["replies"]!="1" ? "en" : "")."";
}
$threads.= tplReplMarkerArray($thread, $replace);
}
}
} else {
addError("Mysql", $mysqli->error);
}
$cat = tplReplSection($cat, "###BOARDCATS.CAT.NOTHREADS###", "");
$cats.= tplReplSection($cat, "###BOARDCATS.CAT.THREAD###", $threads);
}
$stmt->close();
$tpl["cat"] = $cats;
}
}
$tpl["main"] = tplReplSection($tpl["main"], "###BOARDCATS.CAT###", $tpl["cat"]);
?>