History of phpBB Edits

Version 25

phpBB Edits

phpBB edits

Created by: spiderr, Last modification: 09 Jun 2005 (17:35 UTC) by spiderr
phpBB 2.0.x Edits

This is the current phpBB 2.0.11 edits required for user integration to bitweaver. Remeber to make a backup of everything before you start editing!

These edits should work for all phpBB 2.0.x boards.



Files: That need to be created and/or edited.
  • ./common.php
  • ./bit_setup_inc.php #Needs to be created!
  • ./admin/index.php
  • ./admin/schema_inc.php #Needs to be created!
  • ./includes/page_tail.php
  • ./includes/sessions.php
  • ./templates/menu_phpbb.tpl #Needs to be created!
  • ./templates/menu_phpbb_admin.tpl #Needs to be created!
  • ./templates/phpbb_mini_search.tpl #Needs to be created!
  • ./templates/bit_phpbb.tpl #Needs to be created!




In ./common.php:

Find:
{CODE(colors=>'php')}$board_config = array();
$userdata = array();
$theme = array();
$images = array();
$lang = array();
$gen_simple_header = FALSE;{CODE}

Add After:
{CODE(colors=>'php')}// {{{ BIT_MOD
if( file_exists( $phpbb_root_path . 'config.'.$phpEx ) ) {
include($phpbb_root_path . 'config.'.$phpEx);
}
if( !defined("PHPBB_INSTALLED") )
{
header("Location: install/install.$phpEx");
exit;
}

require_once( $phpbb_root_path.'/../bit_setup_inc.php' );
//phpBB is not as clean as tiki. errors only
error_reporting ( E_ALL & ~E_NOTICE );
// }}} BIT_MOD{CODE}

Save and upload the file.



Create a new file called bit_setup_inc.php in your phpBB root folder.

Add this into the file:
{CODE(colors=>'php')}<?php
global $gTikiSystem;

$gTikiSystem->registerPackage( 'phpBB', dirname( FILE ).'/' );
if( $gTikiSystem->isPackageActive( 'phpbb' ) ) {
$gTikiSystem->registerAppMenu( 'phpbb', 'Forums', PHPBB_PKG_URL.'index.php', 'tikipackage:phpbb/menu_phpbb.tpl' );
}
?>{CODE}

Save and upload the file.



In ./admin/index.php:

Find:
{CODE(colors=>'php')} $db->sql_close();
exit;

}

?>{CODE}

Add ABOVE:
{CODE(colors=>'php')}// {{{ BIT_MOD
$template->flush_buffer();
// }}} BIT_MOD{CODE}

Save and upload the file.



Create a new file called schema_inc.php in your ./admin/ folder.

Add this into the file:
{CODE(colors=>'php')}<?php
global $gTikiInstaller;
$gTikiInstaller->registerPackageInfo( PHPBB_PKG_DIR, array(
'description' => "phpBB is a high powered, fully scalable, and highly customizable Open Source bulletin board package. phpBB has a user-friendly interface, simple and straightforward administration panel, and helpful FAQ.",
'license' => 'LGPL',
'version' => '2.0.6',
'state' => 'external package',
'dependencies' => '',
'install' => array(
'package' => 'phpbb',
'file' => 'install/install.php'
)
) );
?>{CODE}

Save and upload the file.



In ./includes/page_tail.php:
"Find:" (~lines 45-48 )
{CODE(colors=>'php')}//
//
// Close our DB connection.
//
$db->sql_close();
{CODE}

and delete

Find: (~lines 52-70 )
{CODE(colors=>'php')}//
// Compress buffered output if required and send to browser
//
if ( $do_gzip_compress )
{
//
// Borrowed from php.net!
//
$gzip_contents = ob_get_contents();
ob_end_clean();

$gzip_size = strlen($gzip_contents);
$gzip_crc = crc32($gzip_contents);

$gzip_contents = gzcompress($gzip_contents, 9);
$gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4);

echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $gzip_contents;
echo pack('V', $gzip_crc);
echo pack('V', $gzip_size);
}
{CODE}

Add After:
{CODE(colors=>'php')}// {{{ BIT_MOD
global $gTikiPhpBBSubFrame, $smarty, $gTikiSystem, $dbs_tiki;
// hack around php database driver issues when tiki is a different db from bitweaver
$gTikiSystem->mDb->mDb->SelectDB( $dbs_tiki );
if( !empty( $gTikiPhpBBSubFrame ) ) {
$smarty->display( 'tikipackage:phpbb/bit_phpbb.tpl' );
} else {
$gTikiSystem->display( 'tikipackage:phpbb/bit_phpbb.tpl' );
}

//
// Close our DB connection.
// Do this *after* $gTikiSystem->display so modules that use phpBB database still display
$db->sql_close();
// }}} BIT_MOD
{CODE}



In ./includes/sessions.php:

Find:
{CODE(colors=>'php')} if ( isset($HTTP_COOKIE_VARS>$cookiename . '_sid')
isset($HTTP_COOKIE_VARS>$cookiename . '_data') )
{
$session_id = isset($HTTP_COOKIE_VARS>$cookiename . '_sid') ? $HTTP_COOKIE_VARS>$cookiename . '_sid' : ;
$sessiondata = isset($HTTP_COOKIE_VARS>$cookiename . '_data') ? unserialize(stripslashes($HTTP_COOKIE_VARS>$cookiename . '_data')) : array();
$sessionmethod = SESSION_METHOD_COOKIE;
}
else
{
$sessiondata = array();
$session_id = ( isset($HTTP_GET_VARSsid>'sid') ) ? $HTTP_GET_VARSsid>'sid' : ;
$sessionmethod = SESSION_METHOD_GET;
}
{CODE}
Add After:
{CODE(colors=>'php')}// {{{ BIT_MOD
// we always force auto login
$sessiondataautologinid>'autologinid' = TRUE;
// }}} BIT_MOD{CODE}
Find:
{CODE(colors=>'php')} //
// Did the session exist in the DB?
//
if ( isset($userdatauser_id>'user_id') )
{{CODE}
Add After:
{CODE(colors=>'php')} // {{{ BEGIN BIT_MOD
$sessiondatasession_page>'session_page' = $thispage_id;
check_bit_user( $userdata );
// }}} END BIT_MOD{CODE}
Find:
{CODE(colors=>'php')} setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);
setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);
}
return $userdata;
}
}
}{CODE}
Add After:
{CODE(colors=>'php')} // {{{ BEGIN BIT_MOD
// make sure we keep copy a few variables over if we automatically start a new bit_session
$sessiondatasession_page>'session_page' = $thispage_id;
$sessiondatasession_ip>'session_ip' = $user_ip;
check_bit_user( $sessiondata );
// {{{ END BIT_MOD{CODE}
Find:
{CODE(colors=>'php')} //
// If we reach here then no (valid) session exists. So we'll create a new one,
// using the cookie user_id if available to pull basic user prefs.
//
$user_id = ( isset($sessiondatauserid>'userid') ) ? intval($sessiondatauserid>'userid') : ANONYMOUS;
if ( !($userdata = session_begin($user_id, $user_ip, $thispage_id, TRUE)) )
{
message_die(CRITICAL_ERROR, 'Error creating user session', , LINE, FILE, $sql);
}
return $userdata;
}
{CODE}
Add After:
{CODE(colors=>'php')}// {{{ BEGIN TIKI MOD
function check_bit_user( &$p_user_data ) {
// We have a valid tiki user, however we do not have a phpBB user
global $db, $gTikiSystem, $gTikiUser, $userlib, $HTTP_GET_VARS;
$anon = $p_user_datauser_id>'user_id' == ANONYMOUS;
if( empty($p_user_datauser_id''>'user_id')
$anon
( $gTikiUser->isRegistered() && $gTikiUser->mUserId != $p_user_datauser_id>'user_id' )
) {
if( $gTikiUser->isRegistered() ) {
//
// Try and pull the last time stored in a cookie, if it exists
//
$sql = "SELECT *
FROM " . USERS_TABLE . "
WHERE user_id = '".$gTikiUser->mUserId."'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Could not obtain tiki user from phpBB user table', , LINE, FILE, $sql);
}
$user_row = $db->sql_fetchrow($result);
//vd( $user_row );
$md5 = ( $gTikiSystem->mPrefsfeature_clear_passwords>'feature_clear_passwords' == 'y' );
$phpbb_password = ( $md5 ? $gTikiUser->mInfopassword>'password' : md5( $gTikiUser->mInfopassword>'password' ) );
// nuke their existing session cause it stores anonymous_id (-1) initially
$sql = "DELETE FROM " . SESSIONS_TABLE . "
WHERE session_id = '".$p_user_datasession_id>'session_id'."'";
if ( !$db->sql_query($sql) )
{
message_die(CRITICAL_ERROR, 'Error clearing sessions table', , LINE, FILE, $sql);
}
if( empty( $user_rowuser_id>'user_id' ) ) {
$sql = "INSERT INTO ". USERS_TABLE ." (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_avatar_type, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey)
VALUES ( ".$gTikiUser->mInfouser_id>'user_id'.", ".$gTikiSystem->mDb->qstr( $gTikiUser->mInfologin>'login', get_magic_quotes_gpc() ).", ".strtotime('now').", ".$gTikiSystem->mDb->qstr( $phpbb_password, get_magic_quotes_gpc() ).", '".$gTikiUser->mInfoemail>'email'."',
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, 0, 1, 0, 1, 0, 0, 1, 1, 0, 'd M Y h:i a', 'english', 1, ".(int)$gTikiUser->isAdmin().", 0, 1, NULL)";
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Could not create tiki user for phpBB', , LINE, FILE, $sql);
}
} else {
// Has user data changed?
if( ($user_rowuser_email>'user_email' != $gTikiUser->mInfoemail>'email')
($user_rowuser_password''>'user_password' != $phpbb_password)
|| ($user_rowusername>'username' != $gTikiUser->mInfologin>'login')
)
{
$sql = "UPDATE ". USERS_TABLE ." SET username=".$gTikiSystem->mDb->qstr( $gTikiUser->mInfologin>'login', get_magic_quotes_gpc() ).", user_email = ".$gTikiSystem->mDb->qstr( $gTikiUser->mInfoemail>'email', get_magic_quotes_gpc() ).", user_password=".$gTikiSystem->mDb->qstr( $phpbb_password, get_magic_quotes_gpc() )."
WHERE user_id = ".$user_rowuser_id>'user_id';
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Could not create tiki user for phpBB', '', LINE, FILE, $sql);
die;
}
}
}
// Restart the session because somehow we lost it.
$p_user_data = session_begin( $gTikiUser->mUserId, $p_user_datasession_ip>'session_ip', $p_user_datasession_page>'session_page', TRUE, TRUE );
} else {
// We have an anonymous session
$user_id = ( isset($p_user_datauser_id>'user_id') ) ? intval($p_user_datauser_id>'user_id') : ANONYMOUS;

if ( !($p_user_data = session_begin( $user_id, $p_user_datauser_ip>'user_ip', $p_user_datasession_page>'session_page', TRUE, TRUE, , (int)$gTikiUser->isAdmin() )) )
{
message_die(CRITICAL_ERROR, 'Error creating user session', '', LINE, FILE, $sql);
}
}
} elseif( $gTikiUser->isRegistered() ) {
if( empty( $p_user_datasession_id>'session_id' ) ) {
// we need a session
$p_user_data = session_begin( $gTikiUser->mUserId, $p_user_datasession_ip>'session_ip', $p_user_datasession_page>'session_page', TRUE, TRUE, (int)$gTikiUser->isAdmin() );
}
} else {
if( $p_user_datasession_logged_in>'session_logged_in' ) {
//our Tiki session has ended before our phpBB session
session_end( $p_user_datasession_id>'session_id', $p_user_datauser_id>'user_id' );
$p_user_data = session_begin( ANONYMOUS, $p_user_datasession_ip>'session_ip', $p_user_datasession_page>'session_page' );
}
}
}
{CODE}

Save and upload the file.



In ./db/postgres7.php:

Bug fix for phpBB in postgres schemas.

Find:

<?php
            
if( preg_match("/^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)/is"$this->last_query_text[$query_id], $tablename) )
?>


replace with

<?php
if( preg_match("/^INSERT[\t\n ]+INTO[\t\n ]+([-a-z0-9\_\.]+)/is"$this->last_query_text[$query_id], $tablename) )
?>




In ./viewtopic.php

Bug fix for mystery function "phpbb_rtrim" which doesn't appear to be defined anywhere.

Find:

<?php
       $highlight_match 
phpbb_rtrim($highlight_match"\\");
?>


replace with

<?php
       $highlight_match 
rtrim($highlight_match"\\");
?>




Create a new file called menu_phpbb.tpl in your ./templates/ folder.

Add this into the file:
{CODE(colors=>'php')}{tr}Browse Forums{/tr}
{if $user}
{tr}Posts since last visit{/tr}
{tr}Your posts{/tr}
{tr}Unanswered posts{/tr}
{/if}
{CODE}

Save and upload the file.



Create a new file called menu_phpbb_admin.tpl in your ./templates/ folder.

Add this into the file:
{CODE(colors=>'php')}{tr}Administer phpBB{/tr}
{CODE}

Save and upload the file.



Create a new file called phpbb_mini_search.tpl in your ./templates/ folder.

Add this into the file:
{CODE(colors=>'php')}<form action="{$gTikiLoc.PHPBB_PKG_URL}search.php" method="POST">
<input type="hidden" name="search_fields" value="all" /><input type="text" style="width: 75px" class="post" name="search_keywords" size="30" /><input class="liteoption" type="submit" value="{tr}Search{/tr}" />

Match: <input type="radio" name="search_terms" value="any" checked="checked" /> {tr}Any{/tr}
<input type="radio" name="search_terms" value="all" />{tr}All{/tr}

</form>
{tr}More options{/tr}
{CODE}

Save and upload the file.



Create a new file called bit_phpbb.tpl in your ./templates/ folder.

Add this into the file:
{CODE(colors=>'php')}{* BIT_MOD - this is a new file*}

{php}
global $template;
$template->flush_buffer();
{/php}

{* BIT_MOD *}
{CODE}

Save and upload the file.




Fin.



Page History
Date/CommentUserIPVersion
21 Apr 2006 (12:10 UTC)
use different highlighting for one code block to avoid crashes
SV1206.105.169.16032
Current • Source
xing194.152.164.4530
View • Compare • Difference • Source
spiderr66.93.240.20429
View • Compare • Difference • Source
spiderr66.93.240.20428
View • Compare • Difference • Source
spiderr66.93.240.20426
View • Compare • Difference • Source
spiderr66.93.240.20425
View • Compare • Difference • Source
spiderr66.93.240.20423
View • Compare • Difference • Source
spiderr66.93.240.20422
View • Compare • Difference • Source
spiderr66.93.240.20421
View • Compare • Difference • Source
spiderr66.93.240.20420
View • Compare • Difference • Source
spiderr66.93.240.20419
View • Compare • Difference • Source
spiderr66.93.240.20418
View • Compare • Difference • Source
spiderr66.93.240.20416
View • Compare • Difference • Source
Southpaw213.202.174.1115
View • Compare • Difference • Source
Southpaw213.202.168.5414
View • Compare • Difference • Source
Southpaw213.202.159.6113
View • Compare • Difference • Source
Southpaw213.202.159.6112
View • Compare • Difference • Source
Southpaw213.202.159.6111
View • Compare • Difference • Source
Southpaw213.202.159.6110
View • Compare • Difference • Source
Southpaw213.202.161.779
View • Compare • Difference • Source
Southpaw213.202.161.778
View • Compare • Difference • Source
Southpaw213.202.161.777
View • Compare • Difference • Source
Southpaw213.202.161.776
View • Compare • Difference • Source
Southpaw213.202.161.775
View • Compare • Difference • Source
Southpaw213.202.161.774
View • Compare • Difference • Source
Southpaw213.202.161.773
View • Compare • Difference • Source