Newer
Older
<?php
// Forum integration component
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
// Attempt to divine which punbb file is wanted
$file_index = array_search("Forum", $pathlist) + 1;
if ($pathlist[$file_index] == "") {
$punbb_file = "index.php";
} else {
$punbb_file = $pathlist[$file_index];
}
// Stick relevant get parameters somewhere where the template can get them
// This is to cure problems with the login form eating essential get params
// Done here instead of site-wide to limit potential for an XSS vulnerabilityy
// (it occurs though that this could be solved using session data rather than writing GET params)
$gets = array();
if (isset($_GET['id']))
$gets['id'] = intval($_GET['id']);
if (isset($_GET['p']))
$gets['p'] = intval($_GET['p']);
$smarty->assign("gets", $gets);
// move to the punbb directory and start buffering
$oldcwd = getcwd();
chdir($punbb_base);
ob_start();
// include the wanted punbb file
try {
include($punbb_base."/".$punbb_file);
} catch (Exception $e) {
// do nothing. This is practically expected as our punbb throws exceptions when it's done rendering
// this sounds nasty, but it's better than calling exit() like the stock punbb does ;-)
}
// stop buffering, move back to where we were
$page = ob_get_contents();
ob_clean();
chdir($oldcwd);
// if this is for syndication purposes or the punbb installer, we don't want a template
if ($punbb_file == "extern.php" || $punbb_file == "install.php") {
$no_template = TRUE;
echo $page;
} else {
// make the breadcrumbs tastier
$pathlist = array_slice($pathlist, 0, $file_index);
$smarty->assign("title", "Forum");
$smarty->assign("extra_styles", "$baseurl/css/forum/SUCS.css");
$smarty->assign("rss_url", "/Community/Forum/extern.php?action=active&type=rss");
$smarty->assign("body", $page);
}
?>