Skip to content
Snippets Groups Projects
forum.php 1.78 KiB
Newer Older
  • Learn to ignore specific revisions
  • <?php
    
    // Forum integration component
    
    
    $punbb_base = "$base/lib/punbb";
    
    
    // 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&amp;type=rss");
    	$smarty->assign("body", $page);
    }
    
    ?>