Jump to content



Latest News: (loading..)

- - - - -

pbpBB2 and osC shared account creation


  • Please log in to reply
213 replies to this topic

#21   AlexStudio

AlexStudio
  • Members
  • 1,092 posts
  • Real Name:Alex Li
  • Gender:Male
  • Location:Taipei, Taiwan

Posted 05 October 2006 - 11:47 AM

Login/Logoff from either osC or phpbb

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

Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

#22   AlexStudio

AlexStudio
  • Members
  • 1,092 posts
  • Real Name:Alex Li
  • Gender:Male
  • Location:Taipei, Taiwan

Posted 05 October 2006 - 01:23 PM

STEP-3 phpBB2 files

STEP-3.1 phpBB2/common.php
Find:
// Protect against HTTP_SESSION_VARS tricks
if (isset($HTTP_SESSION_VARS) && !is_array($HTTP_SESSION_VARS))
{
	die("Hacking attempt");
}

if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
{
Add after:
// BOF phpBB2 login in osC by AlexStudio
if ( isset( $HTTP_GET_VARS[ 'trid' ] ))
{
  $osc_sid = $HTTP_GET_VARS[ 'trid' ];
}
// EOF phpBB2 login in osC by AlexStudio

Find at the bottom:
?>
Add before:
// BOF AlexStudio
if ( isset( $osc_sid ))
{
  $sql = "select osCsid, sess_uid, sess_uip, sess_logged from trans_phpbb where osCsid = '" . $osc_sid . "'";
  if( !($result = $db->sql_query($sql)) )
  {
  message_die(CRITICAL_ERROR, "Could not query trans_php sess_trans", "", __LINE__, __FILE__, $sql);
  }
  global $oscdata;
  $oscdata = $db->sql_fetchrow($result);
  $db->sql_freeresult($result);
  $osc_uid = $oscdata[ 'sess_uid' ];
}
// EOF AlexStudio

STEP-3.2 phpBB2/login.php
Find:
		// session id check
		if ($sid == '' || $sid != $userdata['session_id'])
		{
			message_die(GENERAL_ERROR, 'Invalid_session');
		}

		if( $userdata['session_logged_in'] )
		{
Add after:
//// BOF AlexStudio phpbb2 logoff
			$sql = "select osCsid, sess_uid, sess_uip, sess_logged, sess_trans from trans_phpbb where sess_uid = '" . $userdata[ 'user_id' ] ."'";
			if ( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, 'Error in obtaining transata', '', __LINE__, __FILE__, $sql);
			}
			if( $row = $db->sql_fetchrow($result) )
			{
				$osCsid = $row[ 'osCsid' ];
			}
//// EOF AlexStudio phpbb2 logoff

Find:
		if (!empty($HTTP_POST_VARS['redirect']) || !empty($HTTP_GET_VARS['redirect']))
		{
			$url = (!empty($HTTP_POST_VARS['redirect'])) ? htmlspecialchars($HTTP_POST_VARS['redirect']) : htmlspecialchars($HTTP_GET_VARS['redirect']);
			$url = str_replace('&', '&', $url);
			redirect(append_sid($url, true));
		}
		else
		{
			redirect(append_sid("index.$phpEx", true));
replace with:
		if (!empty($HTTP_POST_VARS['redirect']) || !empty($HTTP_GET_VARS['redirect']))
		{
			$url = (!empty($HTTP_POST_VARS['redirect'])) ? htmlspecialchars($HTTP_POST_VARS['redirect']) : htmlspecialchars($HTTP_GET_VARS['redirect']);
			$url = str_replace('&', '&', $url);
			redirect(append_sid($url, true));
		}
//// BOF AlexStudio logoff in phpbb
		else if( isset( $HTTP_GET_VARS[ 'trans' ]) && $HTTP_GET_VARS[ 'trans' ] == 'yes' )
		{
			header('Location: http://yourdomain.com/catalog/index.php');
			session_write_close();
			exit();
		}
		else
		{
			header('Location: http://yourdomain.com/catalog/logoff.php?trans=yes&osCsid=' . $osCsid);
			session_write_close();
			exit();
//			redirect(append_sid("index.$phpEx", true));
//// EOF AlexStudio logoff in phpbb
Don't forget to put your osC URL in this code, 2 places

Find:
		$template->assign_vars(array(
			'USERNAME' => $username,

			'L_ENTER_PASSWORD' => (isset($HTTP_GET_VARS['admin'])) ? $lang['Admin_reauthenticate'] : $lang['Enter_password'],
			'L_SEND_PASSWORD' => $lang['Forgotten_password'],

			'U_SEND_PASSWORD' => append_sid("profile.$phpEx?mode=sendpassword"),
Replace with:
		$template->assign_vars(array(
			'USERNAME' => $username,

			'L_ENTER_PASSWORD' => (isset($HTTP_GET_VARS['admin'])) ? $lang['Admin_reauthenticate'] : $lang['Enter_password'],
			'L_SEND_PASSWORD' => $lang['Forgotten_password'],

//			'U_SEND_PASSWORD' => append_sid("profile.$phpEx?mode=sendpassword"),
			'U_SEND_PASSWORD' => 'http://yourdoamin.com/catalog/password_forgotten.php',
Actually replace the last line only, put your osC URL in it.

STEP-3.3 phpBB2/admin/pagestart.php
Find:
if (!$userdata['session_admin'])
{
	redirect(append_sid("login.$phpEx?redirect=admin/index.$phpEx&admin=1", true));
}
Replace with:
/*
if (!$userdata['session_admin'])
{
	redirect(append_sid("login.$phpEx?redirect=admin/index.$phpEx&admin=1", true));
}
*/

STEP-3.4 phpBB2/includes/page_header.php
Find:
	'S_LOGIN_ACTION' => append_sid('login.'.$phpEx),
Replace with:
//// BOF phpBB2 login osC in phpbb2 AlexStudio 
	'S_LOGIN_ACTION' => append_sid('http://yourdomain.com/catalog/login.php?action=process&trans=yes'),
//// EOF phpBB2 login osC in phpbb2 AlexStudio
put your osC URL here, too

STEP-3.5 phpBB2/includes/sessions.php
Find:
function session_begin($user_id, $user_ip, $page_id, $auto_create = 0, $enable_autologin = 0, $admin = 0)
{
	global $db, $board_config;
	global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;
Add after:
	global $oscdata;

Find:
if (isset($sessiondata['autologinid']) && (string) $sessiondata['autologinid'] != '' && $user_id)
		{
			$sql = 'SELECT u.* 
				FROM ' . USERS_TABLE . ' u, ' . SESSIONS_KEYS_TABLE . ' k
				WHERE u.user_id = ' . (int) $user_id . "
					AND u.user_active = 1
					AND k.user_id = u.user_id
					AND k.key_id = '" . md5($sessiondata['autologinid']) . "'";
			if (!($result = $db->sql_query($sql)))
			{
				message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);
			}

			$userdata = $db->sql_fetchrow($result);
			$db->sql_freeresult($result);
		
			$enable_autologin = $login = 1;
		}
Add after:
// BOF add osCsid trans login check by AlexStudio
		else if ( isset( $oscdata ) && $oscdata[ 'sess_logged' ] == 1 && $oscdata[ 'sess_uip' ] == $user_ip )
		{
		  $sql = "update trans_phpbb set sess_trans = '2' where sess_uid = '" . $oscdata[ 'sess_uid' ] . "'";
		  if ( !( $result = $db->sql_query($sql) ) )
		  {
			message_die(CRITICAL_ERROR, 'Error update trans_phpbb sess_trans', '', __LINE__, __FILE__, $sql);
		  }
			$sessiondata['autologinid'] = '';
			$sessiondata['userid'] = $user_id;

			$sql = 'SELECT *
				FROM ' . USERS_TABLE . '
				WHERE user_id = ' . (int) $user_id . '
					AND user_active = 1';
			if (!($result = $db->sql_query($sql)))
			{
				message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);
			}

			$userdata = $db->sql_fetchrow($result);
			$db->sql_freeresult($result);

			$enable_autologin = 0;
			$login = 1;
		}
// EOF add osCsid trans login check by AlexStudio

Find:
	setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);
	setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);

	$SID = 'sid=' . $session_id;
Add after:
//// BOF AlexStudio add sess_trans
	if ( isset( $oscdata ) && $oscdata[ 'sess_uip' ] == $user_ip )
	{
	  $sql = "update trans_phpbb set sess_trans = '" . $session_id . "' where sess_uid = '" . $oscdata[ 'sess_uid' ] . "'";
	  if ( !( $result = $db->sql_query($sql) ) )
	  {
		message_die(CRITICAL_ERROR, 'Error update trans_phpbb sess_trans', '', __LINE__, __FILE__, $sql);
	  }
	}
//// EOF AlexStudio add sess_trans

Find:
function session_pagestart($user_ip, $thispage_id)
{
	global $db, $lang, $board_config;
	global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;
Add after:
	global $oscdata;

Find:
		//
		// Did the session exist in the DB?
		//
		if ( isset($userdata['user_id']) )
Replace with:
		//
		// Did the session exist in the DB?
		//
		if ( isset($userdata['user_id']) && !isset( $oscdata) )

Find:
	//
	// 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($sessiondata['userid']) ) ? intval($sessiondata['userid']) : ANONYMOUS;
Replace with:
// BOF osCsid trans check by AlexStudio
	if( isset( $oscdata ) )
	{
	  $user_id = $oscdata[ 'sess_uid' ];
	  $sql = "update trans_phpbb set sess_trans = '1' where sess_uid = '" . $oscdata[ 'sess_uid' ] . "'";
	  if( !($result = $db->sql_query($sql)) )
	  {
	  message_die(CRITICAL_ERROR, "Could not update trans_php sess_trans", "", __LINE__, __FILE__, $sql);
	  }
	//
	// 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.
	//
	} else {
	  $user_id = ( isset($sessiondata['userid']) ) ? intval($sessiondata['userid']) : ANONYMOUS;
	}
// EOF osCsid trans check by AlexStudio

STEP-3.6 phpBB2/language/lang_english/lang_main.php
Find:
$lang['Username_Email'] =
Replace that line with:
$lang['Username_Email'] = 'Email Address'; ////<--- Added by Username or Email mod

STEP-3.7 phpBB2/templates/subSilver/index_body.tpl
Find:
	  <td class="row1" align="center" valign="middle" height="28"><span class="gensmall">{L_USERNAME_EMAIL}: 
		<input class="post" type="text" name="username" size="10" />
		   {L_PASSWORD}: 
		<input class="post" type="password" name="password" size="10" maxlength="32" />
		<!-- BEGIN switch_allow_autologin -->
		     {L_AUTO_LOGIN} 
		<input class="text" type="checkbox" name="autologin" />
		<!-- END switch_allow_autologin -->
		    
		<input type="submit" class="mainoption" name="login" value="{L_LOGIN}" />
		</span> </td>
Rplace with:
	  <td class="row1" align="center" valign="middle" height="28"><span class="gensmall">{L_USERNAME_EMAIL}: 
		<input class="post" type="text" name="email_address" size="25" />
		   {L_PASSWORD}: 
		<input class="post" type="password" name="password" size="25" maxlength="32" />
		<!-- BEGIN switch_allow_autologin -->
<!--
		     {L_AUTO_LOGIN} 
		<input class="text" type="checkbox" name="autologin" />  -->
		<!-- END switch_allow_autologin -->
		    
		<input type="submit" class="mainoption" name="login" value="{L_LOGIN}" />
		</span> </td>

Not finished yet...
Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

#23   AlexStudio

AlexStudio
  • Members
  • 1,092 posts
  • Real Name:Alex Li
  • Gender:Male
  • Location:Taipei, Taiwan

Posted 05 October 2006 - 01:51 PM

STEP-3.8 phpBB2/templates/subSilver/login_body.tpl
Find:
			  <input type="text" class="post" name="username" size="25" maxlength="40" value="{USERNAME}" />
Replace with:
			  <input type="text" class="post" name="email_address" size="25" maxlength="40" value="{USERNAME}" />

Find:
		  <!-- BEGIN switch_allow_autologin -->
		  <tr align="center"> 
			<td colspan="2"><span class="gen">{L_AUTO_LOGIN}: <input type="checkbox" name="autologin" /></span></td>
		  </tr>
		  <!-- END switch_allow_autologin -->
Replace with:
		  <!-- BEGIN switch_allow_autologin -->
<!--		  <tr align="center"> 
			<td colspan="2"><span class="gen">{L_AUTO_LOGIN}: <input type="checkbox" name="autologin" /></span></td>
		  </tr>  -->
		  <!-- END switch_allow_autologin -->

STEP-3.9 phpBB2/tamplates/subSilver/overall_header.tpl
Find:
<a href="{U_FAQ}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_faq.gif" width="12" height="13" border="0" alt="{L_FAQ}" hspace="3" />{L_FAQ}</a>   <a href="{U_SEARCH}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_search.gif" width="12" height="13" border="0" alt="{L_SEARCH}" hspace="3" />{L_SEARCH}</a>   <a href="{U_MEMBERLIST}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_members.gif" width="12" height="13" border="0" alt="{L_MEMBERLIST}" hspace="3" />{L_MEMBERLIST}</a>   <a href="{U_GROUP_CP}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_groups.gif" width="12" height="13" border="0" alt="{L_USERGROUPS}" hspace="3" />{L_USERGROUPS}</a> 
Add a button to link to your store in this section.




I think that is all, but can't be very sure. Please test these codes if you're interested, and kindly let me know if any problem. The codes in my store work perfectly, if there is any problem in the codes here, probably I missed something in here.

cheers! :)
Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

#24   AlexStudio

AlexStudio
  • Members
  • 1,092 posts
  • Real Name:Alex Li
  • Gender:Male
  • Location:Taipei, Taiwan

Posted 05 October 2006 - 02:00 PM

oh yes, I did miss something.

STEP-2.4 catalog/includes/information.php or any other files you put the link to phpbb2. Change the link to:
'<a href="http://yourdomain.com/catalog/trans_phpbb.php">phpBB2</a>'

Edited by AlexStudio, 05 October 2006 - 02:01 PM.

Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

#25   AlexStudio

AlexStudio
  • Members
  • 1,092 posts
  • Real Name:Alex Li
  • Gender:Male
  • Location:Taipei, Taiwan

Posted 06 October 2006 - 01:23 AM

Found an issue when phpbb board disabled in phpbb admin->configuration, there is no way to get back in the phpbb admin page again if the session closed.

Fix: phpbb2/admin/pagestart.php
Find:
//
// End session management
//
Replace all after with:
/* ///////// Removed by AlexStudio for osC phpbb integration
if (!$userdata['session_logged_in'])
{
	redirect(append_sid("login.$phpEx?redirect=admin/index.$phpEx", true));
}
else if ($userdata['user_level'] != ADMIN)
{
	message_die(GENERAL_MESSAGE, $lang['Not_admin']);
}

if ($HTTP_GET_VARS['sid'] != $userdata['session_id'])
{
	redirect("index.$phpEx?sid=" . $userdata['session_id']);
}

if (!$userdata['session_admin'])
{
	redirect(append_sid("login.$phpEx?redirect=admin/index.$phpEx&admin=1", true));
}
*/
if (empty($no_page_header))
{
	// Not including the pageheader can be neccesarry if META tags are
	// needed in the calling script.
	include('./page_header_admin.'.$phpEx);
}

?>
And you have to get in the admin page by the URL:
http://yourdomain.com/phpbb2/admin/index.php
By applying this change, you must have a .htaccess file in phpbb2/admin folder to password protect it.
Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

#26   Eighteen48

Eighteen48
  • Members
  • 170 posts
  • Real Name:Ano Hito

Posted 05 November 2006 - 01:48 AM

Just out of curiousity what is the difference between your contrib and the other one PHPBB 2.0.8a implementation?

Also you say you have it set-up that users sign-up through osC, is there a way to have it the other way around?  That way the user can come back later and add the rest of the fields when they want to buy something?
Powered By osC 2.2RC2a STS 4.5.8 - HTC 2.6.3 - FP 1.5.9 - BCH 1.0.0

#27   AlexStudio

AlexStudio
  • Members
  • 1,092 posts
  • Real Name:Alex Li
  • Gender:Male
  • Location:Taipei, Taiwan

Posted 05 November 2006 - 11:48 AM

that phpBB 2.08a is obsolete, the latest version is phpBB 2.0.21 and the implementation seems not working anymore.

My code is not completed and need more works to make it stable. Users sign-in from either end will go to the same file - catalog/login.php - which is by osC not phpbb. New user registration form either end will go to catalog/create_account.php and create the user record in both osC and phpBB table.

Users will not notice the difference when they login from phpbb, for they are sending back to phpbb index page automatically.

I have a stable implementation in my live store, need more time to clean up the code and upload it as a new package.
Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

#28   AlexStudio

AlexStudio
  • Members
  • 1,092 posts
  • Real Name:Alex Li
  • Gender:Male
  • Location:Taipei, Taiwan

Posted 27 December 2006 - 11:22 AM

phpBB2 Integration  v1.0 - click here to download
for osCommerce 2.2 MS2 Update 060817 or later
with phpBB 2.0.22

v1.0
2006/12/22 04:50pm GMT+08:00 update by alexstudio

Description
Based on pbpBB2 and osC shared account creation v0.2 by anderskiel
and PHPBB 2.0.8a implementation in oscommerce ms2 by chaveiro
and partially from phpBB-osCommerce Bridge version 1.1 by gabrielk

This is for integrating phpBB into osCommerce, including following features:
  • Shared database. Only one MySQL database needed for both osCommerce and phpBB. phpBB installation will create its own tables in your existing database.
  • Shared account creation. Accounts are all created in osCommerce, and mirrored to phpBB. Users register new accounts in phpBB will be redirected to use the create_account.php form in osCommerce. Existing osCommerce customers' data will be inserted to phpBB automatically when they login next time.
  • Shared login/logoff and secured by IP checking. Unified login page, and stay logged in/off when switching from osCommerce to phpBB and vise cersa. Coded to check user IP when switching side. The quick login in phpBB has been standardized to use email address. osCommerce session time lengthened from 24mins to 24hrs, to keep users logged in with osCommerce when accessing phpBB. Auto login option in phpBB removed to prevent logging in users to cart unaware. This is to make your site more user friendly, no need to login again when switching sides, and keep everything seamless as a single website.
  • Added Username in account creation. Username field has been added to the create account form in osCommerce. This username is required, and will check existing usernames in database for collision. Old customers will have their usernames generated automatically when they login the next time, with first name + last initial + random 4-digit number.
  • Synchronized account info. Users can change their email address and password from either osCommerce or phpBB, and automatically synchronized on the other side.
  • phpBB admin secured by using .htaccess password protection, don't need to login phpBB prior to access admin page anymore.
  • Compatible with Ultimate SEO URLs in the first place. Don't need to modify seo codes.
This contribution is to fully integrate phpBB into osCommerce. Users will not notice a thing when switching from one side to the other. Extra security check hardcoded to prevent hacking. Minimized file modifications for easier installation.

This contribution was developed with phpBB 2.0.21, and updated to 2.0.22 at the last minute before releasing. If you have phpbb 2.0.21 installed, you can apply this contrib manually by using file comparing tools like WinMerge.
Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

#29   rossoe

rossoe
  • Members
  • 58 posts
  • Real Name:Ross

Posted 27 December 2006 - 07:21 PM

Quote

STEP 2.5
----------------------------------------------------
open catalog/account_password.php

Fine: (Line 105 in the original file)
tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$customer_default_address_id . "'");


Add after:
//// BOF phpBB2 Integration v1.0
      tep_db_query("update " . TABLE_PHPBB_USERS . " set user_email = '$email_address' where user_id = '" . (int)$customer_id . "'");
//// EOF phpBB2 Integration v1.0


Seems to be a duplicate of step 2.4 ?  is this a typo ? because that code is not in account_password.php

#30   AlexStudio

AlexStudio
  • Members
  • 1,092 posts
  • Real Name:Alex Li
  • Gender:Male
  • Location:Taipei, Taiwan

Posted 27 December 2006 - 11:55 PM

Sorry, it is a typo in the install.html

Here is the correct Step 2.5:

open catalog/account_password.php

Fine: (Line 51 in the original file)
		tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int)$customer_id . "'");

Add after:
//// BOF phpBB2 Integration v1.0
// #CHAVEIRO16# BEGIN PHPBB2 
		$sql_data_array = array('user_password' =>  md5($password_new),
								'user_session_time' => time());							  
		tep_db_perform(TABLE_PHPBB_USERS, $sql_data_array,'update', "user_id = '" . tep_db_input($customer_id) . "'");
// #CHAVEIRO16# END PHPBB2
//// EOF phpBB2 Integration v1.0

That's it.
Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

#31   rossoe

rossoe
  • Members
  • 58 posts
  • Real Name:Ross

Posted 28 December 2006 - 12:23 AM

Thankyou very much

I'm nearly there

only problem I'm having now is when I try and log in through phpbb2

I'm being directed to the following url :

https://yourdomain.com/catalog/login.php?ac...amp;sid=........

where is this link coming from ?

It'll do the same if I try and register through phpbb2 ?

#32   AlexStudio

AlexStudio
  • Members
  • 1,092 posts
  • Real Name:Alex Li
  • Gender:Male
  • Location:Taipei, Taiwan

Posted 28 December 2006 - 01:07 AM

phpBB2 Integration v1.0 Fix - 2006/12/28 GMT+08:00

Only changed the Install.html.
--------------------------------
Fixed typos in
  • STEP 2.5 - was identical to STEP 2.4 by mistake.
  • STEP 2.6 - corrected fine line xx in original....
Changed in
STEP 2.7 and STEP 2.15 - defined the optional new buttons in a better way for easier multi-language development

--------------------------------
Full package.
Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

#33   AlexStudio

AlexStudio
  • Members
  • 1,092 posts
  • Real Name:Alex Li
  • Gender:Male
  • Location:Taipei, Taiwan

Posted 28 December 2006 - 01:15 AM

View Postrossoe, on Dec 28 2006, 08:23 AM, said:

Thankyou very much

I'm nearly there

only problem I'm having now is when I try and log in through phpbb2

I'm being directed to the following url :

https://yourdomain.com/catalog/login.php?ac...amp;sid=........

where is this link coming from ?

It'll do the same if I try and register through phpbb2 ?
Ross, it seems to me that you didn't change the path defenitions mentioned in STEP 1.2:

Open phpbb2/includes/trans_osc.php and make necessary changes to define both your http/https url and the path where your /catalog is located.
Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

#34   AlexStudio

AlexStudio
  • Members
  • 1,092 posts
  • Real Name:Alex Li
  • Gender:Male
  • Location:Taipei, Taiwan

Posted 28 December 2006 - 03:02 AM

uploaded another fix again for typo....

corrected Fine: (Line xx in original file) to Find: (Line xx in original file)
everywhere in the Install.html

What was I doing....probably lack of good sleep.... <_<
Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

#35   rossoe

rossoe
  • Members
  • 58 posts
  • Real Name:Ross

Posted 28 December 2006 - 06:33 PM

Sorry it was late - I was missing whole sections ! lol

I don't have HTTPS running or available for my site, do I just take the line :

define('HTTPS_SERVER', 'https://www.********.co.uk');

out of the "trans_osc.php" file

or simply edit the url to become plain old "http" :

define('HTTPS_SERVER', 'http://www.********.co.uk');

I will be using Paypal intially so I pressume I do not have any need for https on my site as I'm not handling financial data.

#36   rossoe

rossoe
  • Members
  • 58 posts
  • Real Name:Ross

Posted 29 December 2006 - 12:47 AM

Ok, I'm getting really confused with User_id's

can you clarify the requirements upon first login on a fresh install of both oscommerce and phpbb2.

When I look in customers table there is the default oscommerce user  jon Doe with customr_id "1"

When I look in phpbb_users there are already 2 entries  :

"Anonymous" holds user_id "-1"
"user I set in phpbb2 install" holds "2"

Am I supposed to delete or rename these ?

when I log in on phpbb2 side then move into cart and try to logout it goes to "The page cannot be displayed"
I assume this is something to do with user_id although I'm not sure

Any help would be much appreciated

Ross

#37   AlexStudio

AlexStudio
  • Members
  • 1,092 posts
  • Real Name:Alex Li
  • Gender:Male
  • Location:Taipei, Taiwan

Posted 29 December 2006 - 01:50 AM

the #1 user_id created by phpBB installation actually is "2". So, if you have customer_id=2 as an admin in the store, then you don't need to worry about it.

Quote

when I log in on phpbb2 side then move into cart and try to logout it goes to "The page cannot be displayed"
could you please tell me the url where you get this?
Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

#38   rossoe

rossoe
  • Members
  • 58 posts
  • Real Name:Ross

Posted 29 December 2006 - 08:08 PM

Thanks Alex, it was a typo in "trans_osc.php" that caused the above error.

Now I have this running I hope to integrate it into not only the phpbb2 forum but a portal front page as well - which should use this template :  http://www.ezportalplus.oftheweek.de/portal.php

I am considering 2 options :

1. taking the login box found on the portal page off altogether leaving just the header login button

2. editing the code on the portal login box to match the one used on the phpbb2 page (at the bottom)

what you you advise as the best option ?

My main concern is if there will be any conflicts with passing session ID's around - logged in / logged off status if I add a portal page into the mix ?

Thanks again for all your help

Ross

#39   AlexStudio

AlexStudio
  • Members
  • 1,092 posts
  • Real Name:Alex Li
  • Gender:Male
  • Location:Taipei, Taiwan

Posted 30 December 2006 - 02:29 AM

View Postrossoe, on Dec 30 2006, 04:08 AM, said:

:
:
I am considering 2 options :

1. taking the login box found on the portal page off altogether leaving just the header login button

2. editing the code on the portal login box to match the one used on the phpbb2 page (at the bottom)
:
:
I'm checking the ezportalplus package, but I may not be able to handle it.

Currently I would suggest to use the header login button, and/or the quick login form at the bottom. I need to check that portal login box and see if I can do anything with it. No guarantee.
Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

#40   rossoe

rossoe
  • Members
  • 58 posts
  • Real Name:Ross

Posted 30 December 2006 - 02:47 AM

Oh your a star  - it would be great if you could, I'm going to be working on it tomorrow as well.

The guy who's created ezportalplus has just updated it's to use phpbb2 v. 2.0.22    so that's helped a little.

I've been up late tonight trying to figure out paypal integration  :blink: