function mid_to_iid($mid) { global $indexes; $index = find_msg_index($mid); if (!isset($index)) { return null; } return $indexes[$index]['iid']; }
$tpl->set_file(array("showthread" => "showthread.tpl", "forum_header" => array("forum/" . $forum['shortname'] . ".tpl", "forum/generic.tpl"))); $tpl->set_var("FORUM_NAME", $forum['name']); $tpl->set_var("FORUM_SHORTNAME", $forum['shortname']); $tpl->parse("FORUM_HEADER", "forum_header"); /* $tid set by main.php for showthread.php */ $thread = get_thread($tid); if (!isset($thread)) { err_not_found("No such thread {$tid}"); } /* Mark the thread as read if need be */ if (is_thread_bumped($thread)) { $sql = "update f_tracking set tstamp = NOW() where tid = ? and aid = ?"; db_exec($sql, array($tid, $user->aid)); } /* look for my message and later */ for ($index = find_msg_index($thread['mid']); isset($indexes[$index]); $index++) { $iid = $indexes[$index]['iid']; /* TZ: unixtime is seconds since epoch */ $sql = "select " . "mid, tid, pid, aid, state, UNIX_TIMESTAMP(date) as unixtime, ip, subject, " . "message, url, urltext, video, flags, name, email, views, changes " . "from f_messages{$iid} where tid = ? order by mid"; $sth = db_query($sql, array($tid)); while ($message = $sth->fetch()) { $message['date'] = gen_date($user, $message['unixtime']); /* FIXME: translate pid -> pmid */ if (!isset($message['pmid']) && isset($message['pid'])) { $message['pmid'] = $message['pid']; } $messages[] = $message; } $sth->closeCursor(); } /* Filter out moderated or deleted messages, if necessary */