Version 3.2.3
This commit is contained in:
1 parent
ae5c01cc78
commit
78706903a2
2641 files changed
+228363
-201264
No files matched your search
@@ -2,18 +2,18 @@
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.1.4
|
||||
* IP.Board v3.2.3
|
||||
* Twitter Connect Library
|
||||
* Created by Matt Mecham
|
||||
* Last Updated: $Date: 2010-11-16 11:26:43 -0500 (Tue, 16 Nov 2010) $
|
||||
* Last Updated: $Date: 2011-09-21 05:45:37 -0400 (Wed, 21 Sep 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: mmecham $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @link http://www.invisionpower.com
|
||||
* @version $Rev: 7195 $
|
||||
* @link http://hatynka.in
|
||||
* @version $Rev: 9521 $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -25,8 +25,10 @@ class facebook_connect
|
||||
* @access protected
|
||||
* @var object
|
||||
*/
|
||||
protected $registry;
|
||||
protected $DB;
|
||||
protected $settings;
|
||||
protected $request;
|
||||
protected $lang;
|
||||
protected $member;
|
||||
protected $memberData;
|
||||
@@ -37,58 +39,58 @@ class facebook_connect
|
||||
/**
|
||||
* Facebook wrapper
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @var object
|
||||
*/
|
||||
private $_api;
|
||||
protected $_api;
|
||||
|
||||
/**
|
||||
* Facebook OAUTH wrapper
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @var object
|
||||
*/
|
||||
private $_oauth;
|
||||
protected $_oauth;
|
||||
|
||||
/**
|
||||
* IPBs log in handler
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @var object
|
||||
*/
|
||||
private $_login;
|
||||
protected $_login;
|
||||
|
||||
/**
|
||||
* User connected
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @var boolean
|
||||
*/
|
||||
private $_connected = false;
|
||||
protected $_connected = false;
|
||||
|
||||
/**
|
||||
* User: Token
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
private $_userToken;
|
||||
protected $_userToken;
|
||||
|
||||
/**
|
||||
* User: ID
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @var int
|
||||
*/
|
||||
private $_userId;
|
||||
protected $_userId;
|
||||
|
||||
/**
|
||||
* User: Data
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
private $_userData = array();
|
||||
protected $_userData = array();
|
||||
|
||||
/**
|
||||
* Required permissions
|
||||
@@ -106,7 +108,7 @@ class facebook_connect
|
||||
* @param int User ID
|
||||
* @param boolean Force an exception to be thrown rather than output error (used in IPSMember::buildDisplayPhoto)
|
||||
* @access public
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( $registry, $token='', $userId=0, $forceThrowException=false )
|
||||
{
|
||||
@@ -148,7 +150,7 @@ class facebook_connect
|
||||
{
|
||||
if ( $forceThrowException === false )
|
||||
{
|
||||
$this->registry->output->showError( $this->lang->words['gbl_fb_no_app_id'], 911 );
|
||||
$this->registry->output->showError( $this->lang->words['gbl_fb_no_app_id'], 1090001 );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -184,11 +186,11 @@ class facebook_connect
|
||||
}
|
||||
|
||||
/* Load oAuth */
|
||||
require_once( IPS_KERNEL_PATH . 'facebook/facebookoauth.php' );
|
||||
require_once( IPS_KERNEL_PATH . 'facebook/facebookoauth.php' );/*noLibHook*/
|
||||
$this->_oauth = new FacebookOAuth( FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, FACEBOOK_CALLBACK, $this->extendedPerms );
|
||||
|
||||
/* Load API */
|
||||
require_once( IPS_KERNEL_PATH . 'facebook/facebook.php' );
|
||||
require_once( IPS_KERNEL_PATH . 'facebook/facebook.php' );/*noLibHook*/
|
||||
$this->_api = new Facebook( array( 'appId' => FACEBOOK_APP_ID, 'secret' => FACEBOOK_APP_SECRET, 'cookie' => true ) );
|
||||
|
||||
if ( $this->_userToken AND $this->_userId )
|
||||
@@ -320,7 +322,6 @@ class facebook_connect
|
||||
}
|
||||
catch( Exception $e ){}
|
||||
|
||||
|
||||
if ( count( $updates[0] ) )
|
||||
{
|
||||
foreach( $updates[0] as $k => $v )
|
||||
@@ -433,10 +434,10 @@ class facebook_connect
|
||||
$content = IPSText::mbsubstr( $content, 0, 474 ) . '...';
|
||||
|
||||
/* Generate short URL */
|
||||
require_once( IPS_ROOT_PATH . 'sources/classes/url/shorten.php' );
|
||||
$shorten = new urlShorten();
|
||||
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/url/shorten.php', 'urlShorten' );
|
||||
$shorten = new $classToLoad();
|
||||
|
||||
$data = $shorten->shorten( $url, 'bitly' );
|
||||
$data = $shorten->shorten( $url, IPS_URL_SHORTEN_SERVICE );
|
||||
|
||||
$content .= ' ' . $data['url'];
|
||||
}
|
||||
@@ -476,6 +477,12 @@ class facebook_connect
|
||||
IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'fb_token' => $key ) ) );
|
||||
}
|
||||
|
||||
/* Is mobile? */
|
||||
if ( $this->member->isMobileApp || ! empty( $_REQUEST['mobile'] ) )
|
||||
{
|
||||
$this->_oauth->setFormFactor( 'touch' );
|
||||
}
|
||||
|
||||
/* Update callback url */
|
||||
$this->_oauth->setCallBackUrl( FACEBOOK_CALLBACK . $_urlExtra );
|
||||
|
||||
@@ -495,11 +502,11 @@ class facebook_connect
|
||||
if ( $_REQUEST['code'] )
|
||||
{
|
||||
/* Load oAuth */
|
||||
require_once( IPS_KERNEL_PATH . 'facebook/facebookoauth.php' );
|
||||
require_once( IPS_KERNEL_PATH . 'facebook/facebookoauth.php' );/*noLibHook*/
|
||||
$this->_oauth = new FacebookOAuth( FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, FACEBOOK_CALLBACK, $this->extendedPerms );
|
||||
|
||||
/* Load API */
|
||||
require_once( IPS_KERNEL_PATH . 'facebook/facebook.php' );
|
||||
require_once( IPS_KERNEL_PATH . 'facebook/facebook.php' );/*noLibHook*/
|
||||
$this->_api = new Facebook( array( 'appId' => FACEBOOK_APP_ID, 'secret' => FACEBOOK_APP_SECRET, 'cookie' => true ) );
|
||||
|
||||
/* Ensure URL is correct */
|
||||
@@ -517,7 +524,7 @@ class facebook_connect
|
||||
|
||||
/* Update callback url */
|
||||
$this->_oauth->setCallBackUrl( FACEBOOK_CALLBACK . $_urlExtra );
|
||||
|
||||
|
||||
/* Generate oAuth token */
|
||||
$rToken = $this->_oauth->getAccessToken( $_REQUEST['code'] );
|
||||
|
||||
@@ -541,14 +548,14 @@ class facebook_connect
|
||||
{
|
||||
$_member = IPSMember::load( $_userData['email'], 'all', 'email' );
|
||||
|
||||
/* We have an existing account, so trash email forcing user to sign up with new */
|
||||
/* We do have an existing account, so trash email forcing user to sign up with new */
|
||||
if ( $_member['member_id'] )
|
||||
{
|
||||
unset( $_member );
|
||||
unset( $_userData['email'] );
|
||||
/* Update row */
|
||||
IPSMember::save( $_member['member_id'], array( 'core' => array( 'fb_uid' => $_userData['id'], 'fb_token' => $rToken ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( $_member['member_id'] )
|
||||
{
|
||||
$memberData = $_member;
|
||||
@@ -559,19 +566,28 @@ class facebook_connect
|
||||
/* Here, so log us in!! */
|
||||
$data = $this->_login()->loginWithoutCheckingCredentials( $memberData['member_id'], TRUE );
|
||||
|
||||
$this->registry->getClass('output')->silentRedirect( $data[1] ? $data[1] : $this->settings['base_url'] );
|
||||
$this->registry->getClass('output')->silentRedirect( $this->settings['_original_base_url'], '', true, 'act=idx' );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No? Create a new member */
|
||||
foreach( array( 'fbc_s_pic', 'fbc_s_avatar', 'fbc_s_status', 'fbc_s_aboutme' ) as $field )
|
||||
foreach( array( 'fbc_s_pic', 'fbc_s_status', 'fbc_s_aboutme' ) as $field )
|
||||
{
|
||||
$toSave[ $field ] = 1;
|
||||
}
|
||||
|
||||
$fb_bwoptions = IPSBWOptions::freeze( $toSave, 'facebook' );
|
||||
$safeFBName = str_replace( ' ', '', IPSText::convertCharsets( $_userData['name'], 'utf-8', IPS_DOC_CHAR_SET ) );
|
||||
$displayName = ( ! $this->settings['auth_allow_dnames'] ) ? $safeFBName : FALSE;
|
||||
$safeFBName = ( IPS_DOC_CHAR_SET != 'UTF-8' ) ? IPSText::utf8ToEntities( $_userData['name'] ) : $_userData['name'];
|
||||
$displayName = $safeFBName;
|
||||
|
||||
/* Make sure usernames are safe */
|
||||
if ( $this->settings['username_characters'] )
|
||||
{
|
||||
$check_against = preg_quote( $this->settings['username_characters'], "/" );
|
||||
$check_against = str_replace( '\-', '-', $check_against );
|
||||
|
||||
$safeFBName = preg_replace( '/[^' . $check_against . ']+/i', '', $safeFBName );
|
||||
}
|
||||
|
||||
/* If we're not allowing display names, then use may not hit partial form, so.. */
|
||||
if ( ! $this->settings['auth_allow_dnames'] AND $displayName AND $_userData['email'] AND $_userData['id'] )
|
||||
@@ -582,6 +598,12 @@ class facebook_connect
|
||||
$this->registry->output->showError( 'no_remote_reg', 1090002 );
|
||||
}
|
||||
}
|
||||
|
||||
/* Check ban filters? */
|
||||
if ( IPSMember::isBanned( 'email', $_userData['email'] ) or IPSMember::isBanned( 'name', $displayName ) )
|
||||
{
|
||||
$this->registry->output->showError( 'you_are_banned', 1090003 );
|
||||
}
|
||||
|
||||
/* From reg, so create new account properly */
|
||||
$toSave = array( 'core' => array( 'name' => $safeFBName,
|
||||
@@ -591,21 +613,21 @@ class facebook_connect
|
||||
'email' => $_userData['email'],
|
||||
'fb_uid' => $_userData['id'],
|
||||
'time_offset' => $_userData['timezone'],
|
||||
'members_auto_dst' => 1,
|
||||
'fb_token' => $rToken ),
|
||||
'extendedProfile' => array( 'pp_about_me' => IPSText::getTextClass( 'bbcode' )->stripBadWords( IPSText::convertCharsets( $_userData['about'], 'utf-8', IPS_DOC_CHAR_SET ) ),
|
||||
'fb_photo' => $_userData['pic_big'],
|
||||
'fb_photo_thumb' => $_userData['pic_square'],
|
||||
'fb_bwoptions' => $fb_bwoptions,
|
||||
'avatar_location' => $_userData['pic_square'],
|
||||
'avatar_type' => 'facebook' ) );
|
||||
'fb_bwoptions' => $fb_bwoptions ) );
|
||||
|
||||
|
||||
$memberData = IPSMember::create( $toSave, TRUE, FALSE, FALSE );
|
||||
$memberData = IPSMember::create( $toSave, TRUE, FALSE, TRUE );
|
||||
|
||||
if ( ! $memberData['member_id'] )
|
||||
{
|
||||
throw new Exception( 'CREATION_FAIL' );
|
||||
}
|
||||
|
||||
/* Sync up photo */
|
||||
$this->syncMember( $memberData['member_id'] );
|
||||
|
||||
$pmember = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'members_partial', 'where' => "partial_member_id=" . $memberData['member_id'] ) );
|
||||
|
||||
@@ -620,7 +642,26 @@ class facebook_connect
|
||||
{
|
||||
/* Here, so log us in!! */
|
||||
$data = $this->_login()->loginWithoutCheckingCredentials( $memberData['member_id'], TRUE );
|
||||
|
||||
|
||||
IPSLib::runMemberSync( 'onCompleteAccount', $memberData );
|
||||
|
||||
if ( $this->settings['new_reg_notify'] )
|
||||
{
|
||||
$this->registry->class_localization->loadLanguageFile( array( 'public_register' ), 'core' );
|
||||
|
||||
IPSText::getTextClass('email')->setPlainTextTemplate( IPSText::getTextClass('email')->getTemplate("admin_newuser") );
|
||||
|
||||
IPSText::getTextClass('email')->buildMessage( array( 'DATE' => $this->registry->getClass('class_localization')->getDate( time(), 'LONG', 1 ),
|
||||
'LOG_IN_NAME' => $safeFBName,
|
||||
'EMAIL' => $_userData['email'],
|
||||
'IP' => $this->member->ip_address,
|
||||
'DISPLAY_NAME' => $displayName ) );
|
||||
|
||||
IPSText::getTextClass('email')->subject = sprintf( $this->lang->words['new_registration_email'], $this->settings['board_name'] );
|
||||
IPSText::getTextClass('email')->to = $this->settings['email_in'];
|
||||
IPSText::getTextClass('email')->sendMail();
|
||||
}
|
||||
|
||||
$this->registry->getClass('output')->silentRedirect( $data[1] ? $data[1] : $this->settings['base_url'] );
|
||||
}
|
||||
else
|
||||
@@ -653,11 +694,11 @@ class facebook_connect
|
||||
if ( $member['fb_token'] == $_REQUEST['key'] )
|
||||
{
|
||||
/* Load oAuth */
|
||||
require_once( IPS_KERNEL_PATH . 'facebook/facebookoauth.php' );
|
||||
require_once( IPS_KERNEL_PATH . 'facebook/facebookoauth.php' );/*noLibHook*/
|
||||
$this->_oauth = new FacebookOAuth( FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, FACEBOOK_CALLBACK, $this->extendedPerms );
|
||||
|
||||
/* Load API */
|
||||
require_once( IPS_KERNEL_PATH . 'facebook/facebook.php' );
|
||||
require_once( IPS_KERNEL_PATH . 'facebook/facebook.php' );/*noLibHook*/
|
||||
$this->_api = new Facebook( array( 'appId' => FACEBOOK_APP_ID, 'secret' => FACEBOOK_APP_SECRET, 'cookie' => true ) );
|
||||
|
||||
/* Ensure URL is correct */
|
||||
@@ -695,7 +736,7 @@ class facebook_connect
|
||||
}
|
||||
|
||||
/* Redirect back to settings page */
|
||||
$this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . 'app=core&module=usercp&tab=members&area=facebook' );
|
||||
$this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . 'app=core&module=usercp&tab=core&area=facebook' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -774,22 +815,16 @@ class facebook_connect
|
||||
{
|
||||
$user = $this->fetchUserData();
|
||||
|
||||
/* Update.. */
|
||||
$exProfile['fb_photo'] = ( $bwOptions['fbc_s_pic'] ) ? $user['pic_big'] : '';
|
||||
$exProfile['fb_photo_thumb'] = ( $bwOptions['fbc_s_pic'] ) ? $user['pic_square'] : '';
|
||||
|
||||
if ( $bwOptions['fbc_s_avatar'] )
|
||||
/* Load library */
|
||||
if ( $bwOptions['fbc_s_pic'] )
|
||||
{
|
||||
$exProfile['avatar_location'] = $user['pic_square'];
|
||||
$exProfile['avatar_type'] = 'facebook';
|
||||
}
|
||||
|
||||
if ( $bwOptions['fbc_s_aboutme'] )
|
||||
{
|
||||
$exProfile['pp_about_me'] = IPSText::getTextClass( 'bbcode' )->stripBadWords( IPSText::convertCharsets( $user['about'], 'utf-8', IPS_DOC_CHAR_SET ) );
|
||||
}
|
||||
|
||||
if ( $bwOptions['fbc_si_status'] AND ( isset( $memberData['gbw_no_status_import'] ) AND ! $memberData['gbw_no_status_import'] ) )
|
||||
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/member/photo.php', 'classes_member_photo' );
|
||||
$photo = new $classToLoad( $this->registry );
|
||||
|
||||
$photo->save( $memberData, 'facebook' );
|
||||
}
|
||||
|
||||
if ( $bwOptions['fbc_si_status'] AND ( isset( $memberData['gbw_no_status_import'] ) AND ! $memberData['gbw_no_status_import'] ) AND !$memberData['bw_no_status_update'] )
|
||||
{
|
||||
/* Fetch timeline */
|
||||
//$memberData['tc_last_sid_import'] = ( $memberData['tc_last_sid_import'] < 1 ) ? 100 : $memberData['tc_last_sid_import'];
|
||||
@@ -802,6 +837,9 @@ class facebook_connect
|
||||
|
||||
if ( is_array( $update ) AND isset( $update['message'] ) )
|
||||
{
|
||||
/* @link http://community.invisionpower.com/tracker/issue-27746-video-in-facebook-status */
|
||||
$update['message'] = strip_tags( $update['message'] );
|
||||
|
||||
/* Load status class */
|
||||
if ( ! $this->registry->isClassLoaded( 'memberStatus' ) )
|
||||
{
|
||||
@@ -811,6 +849,7 @@ class facebook_connect
|
||||
|
||||
/* Set Author */
|
||||
$this->registry->getClass('memberStatus')->setAuthor( $memberData );
|
||||
$this->registry->getClass('memberStatus')->setStatusOwner( $memberData );
|
||||
|
||||
/* Convert if need be */
|
||||
if ( IPS_DOC_CHAR_SET != 'UTF-8' )
|
||||
@@ -902,12 +941,11 @@ class facebook_connect
|
||||
{
|
||||
if ( ! is_object( $this->_login ) )
|
||||
{
|
||||
require_once( IPS_ROOT_PATH . 'sources/handlers/han_login.php' );
|
||||
$this->_login = new han_login( $this->registry );
|
||||
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
|
||||
$this->_login = new $classToLoad( $this->registry );
|
||||
$this->_login->init();
|
||||
}
|
||||
|
||||
return $this->_login;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user