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-10-27 11:07:09 -0400 (Wed, 27 Oct 2010) $
|
||||
* Last Updated: $Date: 2011-06-06 16:33:53 -0400 (Mon, 06 Jun 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: mmecham $
|
||||
* @author $Author: bfarber $
|
||||
* @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: 7052 $
|
||||
* @link http://hatynka.in
|
||||
* @version $Rev: 8980 $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -25,8 +25,10 @@ class twitter_connect
|
||||
* @access protected
|
||||
* @var object
|
||||
*/
|
||||
protected $registry;
|
||||
protected $DB;
|
||||
protected $settings;
|
||||
protected $request;
|
||||
protected $lang;
|
||||
protected $member;
|
||||
protected $memberData;
|
||||
@@ -37,56 +39,56 @@ class twitter_connect
|
||||
/**
|
||||
* Twitter OAUTH wrapper
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @var object
|
||||
*/
|
||||
private $_api;
|
||||
protected $_api;
|
||||
|
||||
/**
|
||||
* 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: Secret
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
private $_userSecret;
|
||||
protected $_userSecret;
|
||||
|
||||
/**
|
||||
* User: Data
|
||||
*
|
||||
* @access private
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
private $_userData = array();
|
||||
protected $_userData = array();
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
* $this->memberData['twitter_token'] $this->memberData['twitter_secret']
|
||||
* @access public
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( $registry, $token='', $secret='' )
|
||||
{
|
||||
@@ -104,10 +106,7 @@ class twitter_connect
|
||||
define("CONSUMER_KEY" , trim( ipsRegistry::$settings['tc_token'] ) );
|
||||
define("CONSUMER_SECRET", trim( ipsRegistry::$settings['tc_secret'] ) );
|
||||
define("OAUTH_CALLBACK" , $this->settings['_original_base_url'] . '/interface/twitter/index.php?m=' . $this->memberData['member_id'] );
|
||||
|
||||
/* @todo : Remove this in 3.2 just a tmp fix for 3.1.3 */
|
||||
$this->request['_reg'] = ( isset( $this->request['reg'] ) ) ? $this->request['reg'] : $this->request['_reg'];
|
||||
|
||||
|
||||
/* Auto do it man */
|
||||
if ( ! $token AND $this->memberData['member_id'] AND $this->memberData['twitter_token'] )
|
||||
{
|
||||
@@ -125,7 +124,7 @@ class twitter_connect
|
||||
}
|
||||
|
||||
/* Set include path.. */
|
||||
@set_include_path( IPS_KERNEL_PATH . 'twitter/' . PATH_SEPARATOR . ini_get( 'include_path' ) );
|
||||
@set_include_path( IPS_KERNEL_PATH . 'twitter/' . PATH_SEPARATOR . ini_get( 'include_path' ) );/*noLibHook*/
|
||||
|
||||
/* Reset the API */
|
||||
$this->resetApi( $token, $secret );
|
||||
@@ -144,7 +143,7 @@ class twitter_connect
|
||||
$this->_userSecret = trim( $secret );
|
||||
|
||||
/* Load API */
|
||||
require_once( IPS_KERNEL_PATH . 'twitter/twitteroauth.php' );
|
||||
require_once( IPS_KERNEL_PATH . 'twitter/twitteroauth.php' );/*noLibHook*/
|
||||
$this->_api = new TwitterOAuth( CONSUMER_KEY, CONSUMER_SECRET, $this->_userToken, $this->_userSecret );
|
||||
|
||||
if ( $this->_userToken AND $this->_userSecret )
|
||||
@@ -215,10 +214,10 @@ class twitter_connect
|
||||
}
|
||||
|
||||
/* 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 );
|
||||
|
||||
return $this->updateStatus( $content . ' ' . $data['url'] );
|
||||
}
|
||||
@@ -237,22 +236,22 @@ class twitter_connect
|
||||
*/
|
||||
public function updateStatus( $text )
|
||||
{
|
||||
if ( $text AND $this->isConnected() )
|
||||
if ( IPSLib::twitter_enabled() && $text AND $this->isConnected() )
|
||||
{
|
||||
$status = $this->_api->post( 'statuses/update', array( 'status' => IPSText::convertCharsets( $text, IPS_DOC_CHAR_SET, 'utf-8' ) ) );
|
||||
$code = $this->_api->http_code;
|
||||
|
||||
/* 200 is OK, 403 is returned if API limit is hit */
|
||||
if ( $code == 200 AND $status['id'] )
|
||||
if ( $code == 200 AND $status['id_str'] )
|
||||
{
|
||||
/* Update member */
|
||||
if ( $this->memberData['member_id'] )
|
||||
{
|
||||
/* Update member */
|
||||
IPSMember::save( $this->memberData['member_id'], array( 'extendedProfile' => array( 'tc_last_sid_import' => $status['id'] ) ) );
|
||||
IPSMember::save( $this->memberData['member_id'], array( 'extendedProfile' => array( 'tc_last_sid_import' => $status['id_str'] ) ) );
|
||||
}
|
||||
|
||||
return $status['id'];
|
||||
return $status['id_str'];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -279,7 +278,7 @@ class twitter_connect
|
||||
$key = '';
|
||||
|
||||
/* From registration/log in? */
|
||||
if ( ! $this->memberData['member_id'] AND $this->request['_reg'] )
|
||||
if ( ! $this->memberData['member_id'] AND $this->request['reg'] )
|
||||
{
|
||||
/* Create validating account for the member */
|
||||
$key = md5( uniqid( microtime() ) );
|
||||
@@ -333,6 +332,7 @@ class twitter_connect
|
||||
*
|
||||
* @access public
|
||||
* @return redirect
|
||||
*
|
||||
*/
|
||||
public function finishLogin()
|
||||
{
|
||||
@@ -347,7 +347,6 @@ class twitter_connect
|
||||
|
||||
if ( ! $connectData['t_key'] )
|
||||
{
|
||||
/* @todo something more useful here */
|
||||
throw new Exception( "NO_KEY_FOUND" );
|
||||
}
|
||||
|
||||
@@ -363,7 +362,7 @@ class twitter_connect
|
||||
if ( $member['twitter_token'] == $_REQUEST['oauth_token'] )
|
||||
{
|
||||
/* Reset api to ensure user is not logged in */
|
||||
require_once( IPS_KERNEL_PATH . 'twitter/twitteroauth.php' );
|
||||
require_once( IPS_KERNEL_PATH . 'twitter/twitteroauth.php' );/*noLibHook*/
|
||||
$this->_api = new TwitterOAuth( CONSUMER_KEY, CONSUMER_SECRET, $member['twitter_token'], $member['twitter_secret'] );
|
||||
|
||||
/* Generate oAuth token */
|
||||
@@ -406,7 +405,7 @@ class twitter_connect
|
||||
{
|
||||
/* No? Create a new member */
|
||||
/* Generate BW options */
|
||||
foreach( array( 'tc_s_pic', 'tc_s_avatar', 'tc_s_status', 'tc_s_aboutme', 'tc_si_status' ) as $field )
|
||||
foreach( array( 'tc_s_pic', 'tc_s_status', 'tc_s_aboutme', 'tc_si_status' ) as $field )
|
||||
{
|
||||
$_toSave[ $field ] = 1;
|
||||
}
|
||||
@@ -414,6 +413,15 @@ class twitter_connect
|
||||
$tc_bwoptions = IPSBWOptions::freeze( $_toSave, 'twitter' );
|
||||
$safeFBName = str_replace( ' ', '', IPSText::convertCharsets( $_userData['screen_name'], 'utf-8', IPS_DOC_CHAR_SET ) );
|
||||
$displayName = ( ! $this->settings['auth_allow_dnames'] ) ? $safeFBName : FALSE;
|
||||
|
||||
/* 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 );
|
||||
}
|
||||
|
||||
/* From reg, so create new account properly */
|
||||
$toSave = array( 'core' => array( 'name' => $safeFBName,
|
||||
@@ -425,18 +433,18 @@ class twitter_connect
|
||||
'twitter_token' => $rToken['oauth_token'],
|
||||
'twitter_secret' => $rToken['oauth_token_secret'] ),
|
||||
'extendedProfile' => array( 'pp_about_me' => IPSText::getTextClass( 'bbcode' )->stripBadWords( IPSText::convertCharsets( $_userData['description'], 'utf-8', IPS_DOC_CHAR_SET ) ),
|
||||
'tc_photo' => $_userData['profile_image_url'],
|
||||
'tc_bwoptions' => $tc_bwoptions,
|
||||
'avatar_location' => $_userData['profile_image_url'],
|
||||
'avatar_type' => 'twitter' ) );
|
||||
'tc_bwoptions' => $tc_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'] ) );
|
||||
|
||||
if ( $pmember['partial_member_id'] )
|
||||
@@ -470,7 +478,7 @@ class twitter_connect
|
||||
if ( $member['twitter_token'] == $_REQUEST['oauth_token'] )
|
||||
{
|
||||
/* Reset api to ensure user is not logged in */
|
||||
require_once( IPS_KERNEL_PATH . 'twitter/twitteroauth.php' );
|
||||
require_once( IPS_KERNEL_PATH . 'twitter/twitteroauth.php' );/*noLibHook*/
|
||||
$this->_api = new TwitterOAuth( CONSUMER_KEY, CONSUMER_SECRET, $member['twitter_token'], $member['twitter_secret'] );
|
||||
|
||||
/* Generate oAuth token */
|
||||
@@ -489,7 +497,7 @@ class twitter_connect
|
||||
}
|
||||
|
||||
/* Redirect back to settings page */
|
||||
$this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . 'app=core&module=usercp&tab=members&area=twitter' );
|
||||
$this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . 'app=core&module=usercp&tab=core&area=twitter' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -574,21 +582,21 @@ class twitter_connect
|
||||
{
|
||||
$user = $this->fetchUserData();
|
||||
|
||||
/* Update.. */
|
||||
$exProfile['tc_photo'] = ( $bwOptions['tc_s_pic'] ) ? $user['profile_image_url'] : '';
|
||||
|
||||
if ( $bwOptions['tc_s_avatar'] )
|
||||
/* Load library */
|
||||
if ( $bwOptions['tc_s_pic'] )
|
||||
{
|
||||
$exProfile['avatar_location'] = $user['profile_image_url'];
|
||||
$exProfile['avatar_type'] = 'twitter';
|
||||
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/member/photo.php', 'classes_member_photo' );
|
||||
$photo = new $classToLoad( $this->registry );
|
||||
|
||||
$photo->save( $memberData, 'twitter' );
|
||||
}
|
||||
|
||||
|
||||
if ( $bwOptions['tc_s_aboutme'] )
|
||||
{
|
||||
$exProfile['pp_about_me'] = IPSText::getTextClass( 'bbcode' )->stripBadWords( IPSText::convertCharsets( $user['description'], 'utf-8', IPS_DOC_CHAR_SET ) );
|
||||
}
|
||||
|
||||
if ( $bwOptions['tc_si_status'] AND ( isset( $memberData['gbw_no_status_import'] ) AND ! $memberData['gbw_no_status_import'] ) )
|
||||
if ( $bwOptions['tc_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'];
|
||||
@@ -610,6 +618,7 @@ class twitter_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' )
|
||||
@@ -706,8 +715,8 @@ class twitter_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();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user