PCPin Brigde 1.10
PHP-Fusion v7.2.5
Author: Douwe Yntema
Download:
http://www.douwe.schoonheidssalonanneke.nl

-------------------------------------------
Released under the terms and conditions of
GNU Affero GNU General Public License (Version 3)
-------------------------------------------


FEATURES
--------
- Bridge between PHP Fusion and PCPIN

STARTING POINT
1. Install PCPin V6.22 under the root of PHP-Fusion, e.g. http://www.yourdomain.com/chat
PCPin can be downloaded at http://www.pcpin.com

CHANGELOG
---------
New in V1.10
- Button in panel adjusted in theme of the site
- Button connection test in admin panel
- Joining of userfields of Fusion with PCPPIN
	The admin panel is extended with a second tab
	On the second tab on the left there is a list of the userfields in Fusion.
	After each field there is a dropdown box to select te joined field in PCPPIN.
	After selection of te field for PCPIN click on the "+" button.
	To remove the join, click on the "-" button.
- Synchronizing of avatar in Fusion to PCPIN.
- Updatebutton to force updating of all userdata to PCPin.

UPDATE from V1.00
-----------------
For upgrading from version 1.00, update script is provided
After uploading the files to your webserver, point your browser at:
http://www.yourdomain.com/infusions/pcpinbridge/updates/update_from_v1.00.php
A message is indicating the update is finished.
Please remove the file update_from_v1.00.php from your webserver after upgrading for security reasons!


INSTALLATION
------------
Make a backup of your running website before starting the installation!

1. Unzip the folder
2. Upload contents of the 'files' folder to the webserver.
3. Log on to the site als admin.
4. Go to admin panel --> system admin -->infusions.
5. Select the PCPINbrigde infusion from the dropdown list and press " infuse"
6. Go to admin panel --> infusions --> PCPIN Chat Brigde.
7. Fill in the required settings. This can be taken from /chat/config/db.inc.php. 
8. Infusion is ready now.
9. The following files must be modified in PHP fusion. Line numbers given are approx.

********** CONFIG.PHP **********

Search for:
define("DB_PREFIX", "yourprefix_");
define("COOKIE_PREFIX", "yourprefix_");

replace with: 
/***** Start of PCPIN Brigde Modification *****/
if (!defined("DB_PREFIX")) {
	define("DB_PREFIX", "yourprefix_");
	}
if (!defined("COOKIE_PREFIX")) {
	define("COOKIE_PREFIX", "yourprefix_");
	}
/***** End of PCPIN Brigde Modification ******/

********** END CONFIG.PHP **********



********** REGISTER.PHP **********

Search for:
require_once CLASSES."UserFieldsInput.class.php";

add after:
/***** Start of PCPIN Brigde Modification *****/
require_once INFUSIONS."pcpinbridge/includes/register_include.php";
/***** End of PCPIN Brigde Modification ******/

Search for: (approx line 36)
	$result = dbquery(
	"SELECT user_info FROM ".DB_NEW_USERS."
	WHERE user_code='".$_GET['code']."' AND user_email='".$_GET['email']."'
	LIMIT 1"
	);

replace with:
	/***** Start of PCPIN Brigde Modification *****/	
	$result = dbquery(
		"SELECT user_info, user_password, user_email FROM ".DB_NEW_USERS."
		WHERE user_code='".$_GET['code']."' AND user_email='".$_GET['email']."'
		LIMIT 1"
	);	
	/***** End of PCPIN Brigde Modification ******/

Search for:   (approx line 69)
		$user_info = unserializeFix(stripslashes($data['user_info']));
		$result = dbquery("INSERT INTO ".DB_USERS." (".$user_info['user_field_fields'].") VALUES (".$user_info['user_field_inputs'].")");
		$result = dbquery("DELETE FROM ".DB_NEW_USERS." WHERE user_code='".$_GET['code']."' LIMIT 1");
		
add BEFORE:
/***** Start of PCPIN Brigde Modification *****/		
$pb_password = convert($data['user_password'],'PCPinBridge');
$pb_email = $data['user_email'];
/***** End of PCPIN Brigde Modification ******/

add AFTER:
/***** Start of PCPIN Brigde Modification *****/
$pb_result = dbquery(
"SELECT user_id, user_name,user_email FROM ".DB_USERS."
WHERE user_email='".$pb_email."'
LIMIT 1"
);
$pb_data= dbarray($pb_result);
$pb_username = $pb_data['user_name'];
$pb_fusionid = $pb_data['user_id'];

$result=pb_pcpin_insert($pb_username,$pb_password,$pb_email,$pb_fusionid);
/***** End of PCPIN Brigde Modification ******/

********** END REGISTER.PHP **********


********** ADMINISTRATION/MEMBERS.PHP **********

Search for:
require_once INCLUDES."suspend_include.php";

add after:
/***** Start of PCPIN Brigde Modification *****/
require_once INFUSIONS."pcpinbridge/includes/register_include.php";
/***** End of PCPIN Brigde Modification ******/

Search for: (approx line 226)
result = dbquery("DELETE FROM ".DB_THREAD_NOTIFY." WHERE notify_user='".$user_id."'"); 

add after:
/***** Start of PCPIN Brigde Modification *****/
$result = pb_pcpin_delete ($user_id);
/***** End of PCPIN Brigde Modification ******/

********** END ADMINISTRATION/MEMBERS.PHP **********


********** ADMINISTRATION/UPDATEUSER.PHP **********

Search for:
if (!defined("IN_FUSION")) { die("Access Denied"); }

add after:
/***** Start of PCPIN Brigde Modification *****/
require_once INFUSIONS."pcpinbridge/includes/register_include.php";
/***** End of PCPIN Brigde Modification ******/

Search for: (approx line 123)
				include INCLUDES."user_fields/".$data['field_name']."_include.php";   
			}
		}
	}

add after:
/***** Start of PCPIN Brigde Modification *****/
if ($user_new_password) { $pb_new_pass = $user_new_password)) } else { $pb_new_pass = ""; }
/***** End of PCPIN Brigde Modification ******/

Search for: (approx line 131)
if ($user_new_password) { $new_pass = " user_password='".md5(md5($user_new_password))."', "; } else { $new_pass = " "; }
$result = dbquery("UPDATE ".DB_USERS." SET user_name='$user_name',".$new_pass."user_email='$user_email', user_hide_email='$user_hide_email'".($set_avatar ? $set_avatar : "").$db_values." WHERE user_id='".$user_data['user_id']."'");

add after:
/***** Start of PCPIN Brigde Modification *****/
$result=pb_pcpin_update($user_name,$pb_new_pass,$user_email,$user_data['user_id']);
/***** End of PCPIN Brigde Modification ******/

********** END ADMINISTRATION/UPDATEUSER.PHP **********



********** INCLUDES/CLASSES/USERFIELDINPUT.CLASS.PHP **********

Search for:
require_once CLASSES."PasswordAuth.class.php";

add after:
/***** Start of PCPIN Brigde Modification *****/
require_once INFUSIONS."pcpinbridge/includes/register_include.php";
/***** End of PCPIN Brigde Modification ******/

Search for: (approx line 600)
			$result = dbquery(
				"INSERT INTO ".DB_NEW_USERS." (
					user_code, user_name, user_email, user_datestamp, user_info
				) VALUES(
					'".$userCode."', '".$this->_userName."', '".$this->_userEmail."', '".time()."', '".$userInfo."'
				)"
			);

replace with:

	/***** Start of PCPIN Brigde Modification *****/
	$result = dbquery(
		"INSERT INTO ".DB_NEW_USERS." (
			user_code, user_name, user_email, user_datestamp, user_info, user_password
		) VALUES(
			'".$userCode."', '".$this->_userName."', '".$this->_userEmail."', '".time()."', '".$userInfo."', '".convert($this->_newUserPassword,'PCPinBridge')."'
		)"
	);			
	/***** End of PCPIN Brigde Modification ******/

Search for:  (approx line 615)
	private function _setUserDataInput() {
		global $locale, $settings, $userdata, $aidlink;

		$result = dbquery("INSERT INTO ".DB_USERS." (".$this->_dbFields.") VALUES(".$this->_dbValues.")");
 

add after:
	/***** Start of PCPIN Brigde Modification *****/
	$pb_result = dbquery(
	"SELECT user_id, user_name, user_email FROM ".DB_USERS."
	 WHERE user_email='".$this->_userEmail."'
	LIMIT 1"
	);
	$pb_data = dbarray($pb_result);
	$pb_password = $this->_newUserPassword;
	$pb_username = $pb_data['user_name'];
	$pb_email    =  $pb_data['user_email'];
	$pb_fusionid = $pb_data['user_id'];
	
	$result=pb_pcpin_insert($pb_username,$pb_password,$pb_email,$pb_fusionid);
	/***** End of PCPIN Brigde Modification ******/

Search for:  (approx line 657)
	private function _setUserDataUpdate() {
		global $locale;

		$this->_saveUserLog();

		$result = dbquery("UPDATE ".DB_USERS." SET ".$this->_dbValues." WHERE user_id='".$this->userData['user_id']."'");
		$this->_completeMessage = $locale['u163'];

add after:
		/***** Start of PCPIN Brigde Modification *****/
		$pb_result = dbquery(
		"SELECT user_id, user_name,user_email FROM ".DB_USERS."
		WHERE user_id='".$this->userData['user_id']."'
		LIMIT 1"
		);
		$pb_data = dbarray($pb_result);
		$pb_username = $pb_data['user_name'];
		$pb_fusionid = $pb_data['user_id'];
		$pb_email    = $pb_data['user_email'];
		$pb_password = $this->_newUserPassword;

		$result = pb_pcpin_update($pb_username,$pb_password,$pb_email,$pb_fusionid); 
		/***** End of PCPIN Brigde Modification ******/
		
	
********** END INCLUDES/CLASSES/USERFIELDINPUT.CLASS.PHP **********



********** THEMES/TEMPLATES/FOOTER.PHP **********

Search for:
require_once INCLUDES."footer_includes.php";

add after:
/***** Start of PCPIN Brigde Modification *****/
require_once INFUSIONS."pcpinbridge/includes/register_include.php";
/***** End of PCPIN Brigde Modification ******/

Search for:  (approx line 89)
	$result = dbquery("DELETE FROM ".DB_THREAD_NOTIFY." WHERE notify_user='".$data['user_id']."'");

add after:
		/***** Start of PCPIN Brigde Modification *****/
		$result = pb_pcpin_delete ($user_id);
		/***** End of PCPIN Brigde Modification ******/


********** END THEMES/TEMPLATES/FOOTER.PHP **********



10. The following files must be modified in PCPIN Line numbers given are approx.


********** INC/AJAX/DO_LOGIN.INC.PHP **********
Find:  (approx line 65)
if (md5($password)==$userdata['password'] || PCPIN_SLAVE_MODE && $_pcpin_slave_userdata_md5_password!='' && $_pcpin_slave_userdata_md5_password==$userdata['password']) {

Replace with:
	/***** Start of PCPIN Brigde Modification *****/
    if (($password==$userdata['password']) || (md5($password)==$userdata['password']) || PCPIN_SLAVE_MODE && $_pcpin_slave_userdata_md5_password!='' && $_pcpin_slave_userdata_md5_password==$userdata['password']) {
	/***** End of PCPIN Brigde Modification ******/ 

********** END INC/AJAX/DO_LOGIN.INC.PHP **********



********** TPL/PROFILE_MAIN.TPL **********

Search for: (approx line 273)
 	<!-- <button type="button" onclick="setMemberLevel()" title="{LNG_SAVE_CHANGES}">{LNG_SAVE_CHANGES}</button> 

Delete this line


********** END TPL/PROFILE_MAIN.TPL **********



********** JS/PROFILE.JS **********
Search for:

                      +'<a href="." title="'+htmlspecialchars(getLng('delete_avatar'))+'" onclick="deleteAvatar('+htmlspecialchars(avatar_id)+');return false;">'
                      +htmlspecialchars(getLng('delete_avatar'))
                      +'</a>'

on line 747 approx.

Delete this lines

********** END JS/PROFILE.JS **********


11. The following settings must be done in PCPIN:
	- Server settings --> 4.	Chat exit page URL.
		Must be set to: http://www.yourdomain.com/infusions/pcpinbridge/pcpinbridge_logout.php
	- Account settings --> 16.	Allow account registration?
		Must be set to NO.
	- Account settings --> Allow users to delete own account?
		Must be se to NO.
	- Account setting --> 3. set the number of avatars per user to 1.
	- Account setting --> 4. set allow avatar gallery? to no.
		
12. Finally enjoy the PCPIN Brigde!

NOTES
-----
During Infusion: there are three database tables created: PINBR_SEtTINGS, PINBR_JOIN and PINBR_JOINUSER
Table NEW_USERS is modified.

CHANGELOG
---------
1.0
First Version


TODO
-----

Douwe Yntema
