The forums should already be listed in the order they are displayed in forumhome. It orders them by categoryid and then by displayorder to get the same sequence.
Here is the code where you can change the number of threads shown. Just change the LIMIT on the second Query to modify the amount.
Code:
<?
require("global.php");
$foruminfo=$DB_site->query("SELECT forumid, title FROM forum ORDER BY categoryid,displayorder");
while ($forum=$DB_site->fetch_array($foruminfo)) {
echo ("<a href=\"forumdisplay.php?forumid=".$forum[forumid]."\">".$forum[title]."</a><br>");
$threadinfo=$DB_site->query("SELECT threadid,title,replycount,views FROM thread WHERE forumid=$forum[forumid] AND dateline > UNIX_TIMESTAMP(curdate()-30) ORDER BY views DESC LIMIT 5");
while ($thread=$DB_site->fetch_array($threadinfo)) {
echo (" <a href=\"showthread.php?threadid=".$thread[threadid]."\">".htmlspecialchars($thread[title])."</a> [views: ".$thread[views]."] [replies: ".$thread[replycount]."]<br>");
}
}
?>