I would like to use the following (http://gwshack.us/gwbbcode-1.5.4.zip) phpbb/vbultin plugin with punbb.
the plugin basicly add to the bbcode interpretor [] some new command displaying picture (exemple can be see there http://dynasty-warriors.net/forum/viewtopic.php?t=3729 ).
I assume it can be easyly ported, I might be wrong
here is the install code
install.php:
$gwbbcode_root_path = './';
require_once($gwbbcode_root_path.'install.inc.php');
define('OLD_PICKUP_PATH', $gwbbcode_root_path.'pickup.txt');
install_header();
$successful = true;
$step = 1;
echo "\nTesting writability...\n";
$pickup = load(PICKUP_PATH);
$pickup = $pickup ? $pickup : Array();
echo PICKUP_PATH . ' is ' . (save(PICKUP_PATH, $pickup) ? success('writable', true) : failure('not writable', true));
echo "\nCleaning phpBB from previous installations...\n";
rm('functions_gw.php');
rm('bbcode.tpl');
rm('skills_php.txt');
rm('skill_names.txt');
//phpBB
if (file_exists($gwbbcode_root_path.'../index.php') && strpos(file_get_contents($gwbbcode_root_path.'../index.php'), 'phpBB') !== false) {
//Cleaning
sub_from_file($step++, "// Remove our padding from the string..\n\t\$text = substr(\$text, 1);",
"include_once('gwbbcode/functions_gw.php');",
$gwbbcode_root_path.'../includes/bbcode.php');
sub_from_file($step++, "'T_SPAN_CLASS3' => \$theme['span_class3'],",
" 'GWBBCODE_HEAD' => file_get_contents('gwbbcode/overall_header.tpl'),",
$gwbbcode_root_path.'../includes/page_header.php');
if (file_exists(OLD_PICKUP_PATH)) {
$pickup = eval('return '.file_get_contents(OLD_PICKUP_PATH).';');
if (save(PICKUP_PATH, $pickup)) {
echo 'Transfering ' . OLD_PICKUP_PATH . ' to ' . PICKUP_PATH . ': ' . success('done', true);
rm(OLD_PICKUP_PATH, false);
}
}
echo "\nHooking phpBB...\n";
add_to_file($step++, "'T_SPAN_CLASS3' => \$theme['span_class3'],",
" 'GWBBCODE_HEAD' => include('gwbbcode/header.php'),",
$gwbbcode_root_path.'../includes/page_header.php');
add_to_file($step++, "'T_SPAN_CLASS3' => \$theme['span_class3'],",
" 'GWBBCODE_BODY' => include('gwbbcode/body.php'),",
$gwbbcode_root_path.'../includes/page_header.php');
add_to_file($step++, "// Remove our padding from the string..\n\t\$text = substr(\$text, 1);",
"include('gwbbcode/gwbbcode.php');",
$gwbbcode_root_path.'../includes/bbcode.php');
//Hook all templates
$templates = template_list();
foreach ($templates as $template) {
if (in_array($template, $not_to_hook))
continue;
echo "\nProcessing template " . basename($template) . "...\n";
add_to_file($step++, '@<head[^>]*>@Uis',
'{GWBBCODE_HEAD}',
$template.'/overall_header.tpl',
true);
add_to_file($step++, '@<body[^>]*>@Uis',
'{GWBBCODE_BODY}',
$template.'/overall_header.tpl',
true);
}
echo "\nIf you add templates, please rerun install.php to hook gwbbcode on them";
}
//vBulletin
//TODO
if (file_exists($gwbbcode_root_path.'../index.php') && strpos(file_get_contents($gwbbcode_root_path.'../index.php'), 'vBulletin') !== false) {
echo "\nHooking vBulletin...\n";
add_to_file($step++, "eval('\$headinclude = \"' . fetch_template('headinclude') . '\";');",
"\$headinclude .= include('gwbbcode/header.php');",
$gwbbcode_root_path.'../global.php');
add_to_file($step++, "eval('\$header = \"' . fetch_template('header') . '\";');",
"\$header .= include('gwbbcode/body.php');",
$gwbbcode_root_path.'../global.php');
add_to_file($step++, "function parse_bbcode(\$input_text, \$do_smilies, \$do_html = false)\n\t{",
"include('gwbbcode/gwbbcode.php');\n\$input_text = parse_gwbbcode(\$input_text);",
$gwbbcode_root_path.'../includes/class_bbcode.php');
echo "\nYou need to change the number of images allowed in a post otherwise gwBBCode's images won't show :(";
echo "\nTo do that, go to vBulletin Options/Message Posting and Editing Options and change Maximum Images Per Post";
}
echo "\n\n";
if ($successful)
success('Installation successfully completed!');
else
failure('Installation failed! If you can\'t resolve the issue(s), please contact me.');
?>
</pre></body></html>
install.inc.php
require_once($gwbbcode_root_path.'gwbbcode.inc.php');
function install_header() {
$gwbbcode_version = GWBBCODE_VERSION;
$stars = str_repeat('*', strlen(GWBBCODE_VERSION));
echo "
*************$stars
* gwBBCode $gwbbcode_version *
*************$stars
";
}
function rm($filename, $verbose=true) {
if (file_exists($filename))
if (unlink($filename))
success("File $filename successfully removed.", !$verbose);
else
failure("File $filename unsuccessfully removed.", !$verbose);
}
function sub_from_file($step, $where, $what, $filename, $regexp=false) {
echo "Step $step: ";
if ($content = file_get_contents($filename)) {
$content = str_replace("\r\n", "\n", $content);
//If $what isn't in the file
if (strpos($content, $what) === false) {
//Say it
success("already clean");
}
else {
//else remove it
$content = str_replace("\n".$what, '', $content); //UNSAFE TODO
//If $what is no longer in the file
if (strpos($content, $what) === false) {
//Try to save the file
if ($f = fopen($filename, 'wb')) {
fwrite($f, $content);
fclose($f);
success("clean");
}
else
failure("Error 1: '$filename' couldn't be opened for modification.\n".
'Change access rights and try again or replace it by the original file from phpBB');
}
else
failure("Error 2: '$what' was found in '$filename' but couldn't be removed.\n".
"Please manually remove it, or replace its file by the original file from phpBB");
}
}
}
function add_to_file($step, $where, $what, $filename, $regexp=false) {
echo "Step $step: ";
if ($content = file_get_contents($filename)) {
$content = str_replace("\r\n", "\n", $content);
//If $what isn't in the file
if (strpos($content, $what) === false) {
//Add it
if ($regexp === false)
$content = str_replace($where, $where."\n".$what, $content);
else
$content = preg_replace($where, "$0\n".$what, $content);
//If $what now is in the file
if (strpos($content, $what) !== false) {
//Try to save the file
if ($f = fopen($filename, 'wb')) {
fwrite($f, $content);
fclose($f);
success("hooked");
}
else
failure("Error 3: '$filename' couldn't be opened for modification.\n".
'Please change its access rights and try again.');
}
else
failure("Error 4: '$what' wasn't found in '$filename'.");
}
else
success("already hooked");
}
}
function success($text, $return=false) {
$text = str_replace('<', '<', $text);
$output = "<span style='color:green'>$text</span>\n";
if ($return)
return $output;
else
echo $output;
}
function failure($text, $return=false) {
global $successful;
$successful = false;
$text = str_replace('<', '<', $text);
$output = "<span style='color:red'>$text</span>\n";
if ($return)
return $output;
else
echo $output;
}
function template_list() {
global $gwbbcode_root_path;
$list = Array();
$dir = $gwbbcode_root_path.'../templates/';
$dh = opendir($dir);
while (false !== ($filename = readdir($dh)))
if (is_dir($dir.$filename) && substr($filename, 0, 1) != '.')
$list[] = $dir.$filename;
return $list;
}
?>