This is still in beta, testing in live store not recommended. V0.2 contribution must be installed first, and bug fixes in this thread. Make sure both osC and phpbb2 are working. There are some other things need to be done before applying these codes.
1. Customers must register in both osc and phpbb
2. Turn off auto login in phpbb admin
3. Create a .htaccess file to password protect phpbb/admin folder, and chmod to 777
4. Turn on Check IP Address and Recreate Session in admin->configuration->sessions
STEP-1 mySQL table
Run this script to add one new table in phpMyAdmin:
create table trans_phpbb ( osCsid char(32) default '' not null, sess_uid int(11) default 0 not null, sess_uip char(8) default '' not null, sess_logged int(1) default 0 not null, sess_trans char(32) default '' not null, primary key (osCsid))
STEP-2 osC files
STEP-2.1
Put this code into a new file - trans_phpbb.php - in catalog folder
<?php
/*
$id: trans_phpbb.php v.01 (beta) 2006/10/04 9:41:30 alexstudio
*/
require('includes/application_top.php');
$page_phpbb = HTTP_SERVER . '/phpBB2/index.php';
if (tep_session_is_registered('customer_id')) {
$_sid = 'trid=' . tep_session_id();
$page_phpbb .= '?' . tep_output_string($_sid);
tep_redirect($page_phpbb, '', 'NONSSL');
} else {
tep_redirect($page_phpbb, '', 'NONSSL');
}
?>
STEP-2.2 catalog/login.php
find:
tep_session_register('customer_first_name');
tep_session_register('customer_country_id');
tep_session_register('customer_zone_id');
tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_of_last_logon = now(), customers_info_number_of_logons = customers_info_number_of_logons+1 where customers_info_id = '" . (int)$customer_id . "'");Add after:// #CHAVEIRO16# BEGIN PHPBB2
$last_visit = 0;
$current_time = time();
$check_bbusers_query = tep_db_query("select * from " . TABLE_PHPBB_USERS . " where user_id = '" . $check_customer['customers_id'] . "'");
if (!tep_db_num_rows($check_bbusers_query)) {
// Creates forum account if does't exists already
$sql_data_array = array('user_id' => $customer_id,
'user_active' =>1,
'username' => strtoupper(substr($check_customer['customers_firstname'],0,1)) . ucwords(strtolower($check_customer['customers_lastname'])),
'user_password' => md5($password),
'user_session_time' => time(),
'user_session_page' => 0,
'user_lastvisit' => '',
'user_regdate' => time(),
'user_level' => 0,
'user_posts' => 0,
'user_timezone' => 0.00,
'user_style' => 1,
'user_lang' => 'english',
'user_dateformat' => 'D M d, Y g:i a',
'user_new_privmsg' => 0,
'user_unread_privmsg' => 0,
'user_last_privmsg' => 0,
'user_emailtime' => '',
'user_viewemail' => 0,
'user_attachsig' => 1,
'user_allowhtml' => 0,
'user_allowbbcode' => 1,
'user_allowsmile' => 1,
'user_allowavatar' => 1,
'user_allow_pm' => 1,
'user_allow_viewonline' => 1,
'user_notify' => 0,
'user_notify_pm' => 1,
'user_popup_pm' => 1,
'user_rank' => 0,
'user_avatar' => '',
'user_avatar_type' => 0,
'user_email' => $check_customer['customers_email_address'],
'user_icq' => '',
'user_website' => '',
// removed to avoid error 'user_from' => tep_get_zone_name((int)($check_country['entry_country_id']),(int)($check_country['entry_zone_id'])),
'user_sig' => '',
'user_sig_bbcode_uid' => '',
'user_aim' => '',
'user_yim' => '',
'user_msnm' => '',
'user_occ' => '',
'user_interests' => '',
'user_actkey' => '',
'user_newpasswd' => '');
tep_db_perform(TABLE_PHPBB_USERS, $sql_data_array);
tep_db_query("insert into " . TABLE_PHPBB_GROUPS . " (group_name, group_description, group_single_user, group_moderator) VALUES ('', 'Personal User', 1, 0)");
tep_db_query("insert into " . TABLE_PHPBB_USER_GROUPS . " (group_id, user_id, user_pending)VALUES ('".tep_db_insert_id()."', $customer_id, 0)");
} else {
$userdata = tep_db_fetch_array($check_bbusers_query);
$last_visit = ( $userdata['user_session_time'] > 0 ) ? $userdata['user_session_time'] : $current_time;
tep_db_query("UPDATE " . TABLE_PHPBB_USERS . " SET user_session_time = '".$current_time."', user_session_page = '0', user_lastvisit = '".$last_visit."' WHERE user_id ='" . $check_customer['customers_id'] . "'");
// $userdata['user_lastvisit'] = $last_visit; <------------ Not used, Removed by AlexStudio
// BOF phpBB2 login from osc by AlexStudio
// encode ip for phpbb2
$uip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : getenv('REMOTE_ADDR') );
$ip_sep = explode('.', $uip);
$phpbb_ip = sprintf('%02x%02x%02x%02x', $ip_sep[0], $ip_sep[1], $ip_sep[2], $ip_sep[3]);
$sql_trans_phpbb = array( 'osCsid' => tep_session_id(),
'sess_uid' => $customer_id,
'sess_uip' => $phpbb_ip,
'sess_logged' => 1);
$check_trans_phpbb = tep_db_query("select osCsid, sess_uid, sess_uip, sess_logged from trans_phpbb where sess_uid = '" . $customer_id . "'");
if (!tep_db_num_rows( $check_trans_phpbb ))
{
tep_db_perform( trans_phpbb, $sql_trans_phpbb);
} else {
tep_db_query("update trans_phpbb set osCsid = '" . tep_session_id() . "', sess_uip = '" . $phpbb_ip . "', sess_logged = 1, sess_trans ='' where sess_uid = '" . $customer_id . "'" );
}
}
//// EOF phpBB2 login from osC by AlexStudio
// #CHAVEIRO16# END PHPBB2
Find:
// restore cart contents
$cart->restore_contents();
if (sizeof($navigation->snapshot) > 0) {
$origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);Replace with:// restore cart contents
$cart->restore_contents();
//// BOF phpbb2 by AlexStudio
if ( isset( $HTTP_GET_VARS[ 'trans' ] ) && ( $HTTP_GET_VARS[ 'trans' ] == 'yes' )) {
tep_redirect( 'trans_phpbb.php' );
} elseif (sizeof($navigation->snapshot) > 0 && $navigation->snapshot['page'] != FILENAME_PASSWORD_FORGOTTEN) {
$origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), 'SSL');
//// EOF AlexStudio
STEP-2.3 catalog/logoff.php
Find:
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_LOGOFF); $breadcrumb->add(NAVBAR_TITLE);Add after:
//// BOF phpBB2 Logoff from both side by AlexStudio
$check_trans = tep_db_query( "select sess_uid, sess_logged, sess_trans from trans_phpbb where sess_uid = '" . (int)$customer_id . "'" );
$sess_phpbb = tep_db_fetch_array( $check_trans );
if ( empty( $sess_phpbb ) ) die('sess_phpbb empty !');
$trid=$sess_phpbb[ 'sess_trans' ];
if ( empty( $trid ) ) die('trid empty !');
tep_db_query("update trans_phpbb set sess_logged = 0 where sess_uid = '" . (int)$customer_id . "'");
//// EOF phpBB2 Logoff from both side by AlexStudio
Find:
tep_session_unregister('customer_id');
tep_session_unregister('customer_default_address_id');
tep_session_unregister('customer_first_name');
tep_session_unregister('customer_country_id');
tep_session_unregister('customer_zone_id');
tep_session_unregister('comments');
$cart->reset();Add after: if (sizeof($navigation->snapshot) > 0) {
$origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);
$navigation->clear_snapshot();
$link = $origin_href;
} else {
$link = tep_href_link(FILENAME_DEFAULT);
}
// BOF Logoff from phpBB2 by AlexStudio
if ( isset( $HTTP_GET_VARS[ 'trans' ] ) && $HTTP_GET_VARS[ 'yes' ] )
{
tep_redirect( 'trans_phpbb.php' );
} else {
$page_phpbb = HTTP_SERVER . '/phpBB2/login.php?logout=true&trans=yes&sid=' . tep_output_string($trid);
tep_redirect($page_phpbb, '', 'NONSSL');
}
// EOF Logoff from phpBB2 by AlexStudio










