Topic: PunBB integration with (almost?) any php-page
My solution is simple and is based on Apache module mod_rewrite.
1. Put a .htaccess file in your PunBB installation directory.
.htaccess:
RewriteEngine On
RewriteBase /your/path/here/
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteRule (.*) punbb_wrapper.php [L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteRule ^/?$ punbb_wrapper.php [L]
2. Put a punbb_wrapper.php to the same directory.
punbb_wrapper.php:
<?php
$uri = parse_url($_SERVER['REQUEST_URI']);
if (@$uri['path'] == ($self_dir = dirname($_SERVER['PHP_SELF'])) ||
@$uri['path'] == $self_dir."/") {
$inc = dirname(__FILE__)."/index.php";
} elseif (is_file($inc = dirname(__FILE__)."/".basename($uri['path']))) {
;
} else {
die("Illegal usage");
}
// getting HTML generated by PunBB
ob_start();
include_once($inc);
$_ob_contents_punbb = ob_get_contents();
ob_end_clean();
// got HTML generated by PunBB
/**
* Voila!
*
* in the $_ob_contents_punbb variable is the whole HTML output of PunBB page
*
* We could now simply write
*
* echo $_ob_contents_punbb;
* (this is, as you can see, not in any way sensible :-)) )
*
* Or use $_ob_contents_punbb in some other way (for example:
* $my_smarty->assign('punbb_html', $_ob_contents_punbb);
* )
*
*/
?>
Forgot to mention:
there _is_ one line of PunBB php code that has to be changed if you want to succeed with my approach.
line 161 of footer.php must be changed from
exit($tpl_main);
to
echo($tpl_main);
Have fun ))
-------------- Rubbish before this line ------------------
Sorry everybody. I'm new to PunBB and haven't discovered the <pun_include> template directive before current minute...