This repository has been archived by the owner on Sep 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathviewboard.php
57 lines (45 loc) · 1.63 KB
/
viewboard.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
require_once(dirname(__FILE__)."/config.inc.php");
require_once(dirname(__FILE__)."/classes/session.class.php");
$session = new Session($config);
$template = $config->getTemplate($session->getAuth());
$boardid = !empty($_REQUEST["boardid"]) ? $_REQUEST["boardid"] : null;
try {
$board = $config->getBoard($boardid);
if (!$board->mayRead($session->getAuth())) {
throw new Exception("Keine Berechtigung!");
}
$connection = $board->getConnection();
if ($connection !== null) {
$connection->open($session->getAuth());
$group = $connection->getGroup();
$connection->close();
// Erzwinge mindestens eine Seite
$pages = max(ceil($group->getThreadCount() / $config->getThreadsPerPage()), 1);
$page = 0;
if (isset($_REQUEST["page"])) {
$page = intval($_REQUEST["page"]);
}
// Vorsichtshalber erlauben wir nur Seiten, auf dennen auch Nachrichten stehen
if ($page < 0 || $page > $pages) {
$page = 0;
}
$threads = array();
/** getThreadIDs() gibt alle ThreadIDs in der Reihenfolge Alt => Neu
* zurueck. In der Forendarstellung wollen wir die neuesten x Threads
* von Neu => Alt. */
$threadids = array_slice(array_reverse($group->getThreadIDs()), $page * $config->getThreadsPerPage(), $config->getThreadsPerPage());
foreach ($threadids AS $threadid) {
$thread = $group->getThread($threadid);
if ($thread != NULL) {
$threads[] = $thread;
}
}
$template->viewboard($board, $group, $page, $pages, $threads, $board->mayPost($session->getAuth()), $board->mayAcknowledge($session->getAuth()));
} else {
$template->viewboard($board, null);
}
} catch (Exception $e) {
$template->viewexception($e);
}
?>